Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--.htaccess2
-rw-r--r--3rdparty/Sabre.includes.php2
-rw-r--r--3rdparty/Sabre/CardDAV/AddressBook.php10
-rw-r--r--3rdparty/Sabre/CardDAV/Backend/Abstract.php14
-rw-r--r--3rdparty/Sabre/CardDAV/Backend/PDO.php6
-rw-r--r--3rdparty/Sabre/CardDAV/Card.php8
-rw-r--r--3rdparty/Sabre/CardDAV/ICard.php10
-rw-r--r--3rdparty/Sabre/CardDAV/Plugin.php9
-rw-r--r--3rdparty/Sabre/CardDAV/UserAddressBooks.php8
-rw-r--r--3rdparty/Sabre/CardDAV/Version.php6
-rw-r--r--3rdparty/Sabre/DAV/Browser/GuessContentType.php2
-rw-r--r--3rdparty/Sabre/DAV/Server.php2
-rw-r--r--3rdparty/Sabre/DAV/Version.php2
-rw-r--r--3rdparty/Sabre/DAVACL/Exception/NeedPrivileges.php10
-rw-r--r--3rdparty/Sabre/DAVACL/PrincipalCollection.php2
-rw-r--r--3rdparty/Sabre/LICENCE27
-rw-r--r--3rdparty/Sabre/VObject/Component.php13
-rw-r--r--3rdparty/Sabre/VObject/Element/DateTime.php43
-rw-r--r--3rdparty/Sabre/VObject/Element/MultiDateTime.php6
-rw-r--r--3rdparty/Sabre/VObject/Node.php7
-rw-r--r--3rdparty/Sabre/VObject/Property.php13
-rw-r--r--3rdparty/Sabre/VObject/Reader.php8
-rw-r--r--3rdparty/Sabre/VObject/Version.php2
-rw-r--r--3rdparty/css/chosen/chosen-sprite.pngbin742 -> 3998 bytes
-rw-r--r--3rdparty/css/chosen/chosen.css84
-rw-r--r--3rdparty/fullcalendar/GPL-LICENSE.txt278
-rw-r--r--3rdparty/fullcalendar/MIT-LICENSE.txt20
-rw-r--r--3rdparty/fullcalendar/changelog.txt313
-rw-r--r--3rdparty/fullcalendar/css/fullcalendar.css616
-rw-r--r--3rdparty/fullcalendar/css/fullcalendar.print.css59
-rw-r--r--3rdparty/fullcalendar/js/fullcalendar.js5210
-rw-r--r--3rdparty/fullcalendar/js/fullcalendar.min.js113
-rw-r--r--3rdparty/fullcalendar/js/gcal.js112
-rw-r--r--3rdparty/js/chosen/VERSION2
-rw-r--r--3rdparty/js/chosen/chosen.jquery.js169
-rw-r--r--3rdparty/js/chosen/chosen.jquery.min.js4
-rw-r--r--3rdparty/when/MIT-LICENSE.txt9
-rwxr-xr-x3rdparty/when/When.php725
-rw-r--r--apps/admin_dependencies_chk/appinfo/app.php9
-rw-r--r--apps/admin_dependencies_chk/appinfo/info.xml11
-rw-r--r--apps/admin_dependencies_chk/css/style.css9
-rw-r--r--apps/admin_dependencies_chk/settings.php96
-rw-r--r--apps/admin_dependencies_chk/templates/settings.php16
-rw-r--r--apps/bookmarks/ajax/addBookmark.php8
-rw-r--r--apps/bookmarks/bookmarksHelper.php5
-rw-r--r--apps/bookmarks/settings.php2
-rw-r--r--apps/calendar/ajax/activation.php8
-rw-r--r--apps/calendar/ajax/changeview.php5
-rw-r--r--apps/calendar/ajax/createcalendar.php10
-rw-r--r--apps/calendar/ajax/deletecalendar.php8
-rw-r--r--apps/calendar/ajax/deleteevent.php12
-rw-r--r--apps/calendar/ajax/editcalendar.php4
-rw-r--r--apps/calendar/ajax/editevent.php20
-rw-r--r--apps/calendar/ajax/editeventform.php41
-rw-r--r--apps/calendar/ajax/events.php84
-rw-r--r--apps/calendar/ajax/getcal.php70
-rwxr-xr-xapps/calendar/ajax/guesstimezone.php39
-rw-r--r--apps/calendar/ajax/moveevent.php118
-rw-r--r--apps/calendar/ajax/neweventform.php54
-rw-r--r--apps/calendar/ajax/resizeevent.php32
-rw-r--r--apps/calendar/ajax/updatecalendar.php11
-rw-r--r--apps/calendar/appinfo/app.php3
-rw-r--r--apps/calendar/css/style.css83
-rw-r--r--apps/calendar/export.php18
-rw-r--r--apps/calendar/import.php8
-rw-r--r--apps/calendar/index.php39
-rw-r--r--apps/calendar/js/calendar.js1124
-rwxr-xr-xapps/calendar/js/geo.js20
-rw-r--r--apps/calendar/l10n/xgettextfiles10
-rw-r--r--apps/calendar/lib/app.php82
-rw-r--r--apps/calendar/lib/calendar.php16
-rw-r--r--apps/calendar/lib/object.php137
-rw-r--r--apps/calendar/lib/search.php26
-rwxr-xr-x[-rw-r--r--]apps/calendar/templates/calendar.php223
-rw-r--r--apps/calendar/templates/part.choosecalendar.rowfields.php2
-rw-r--r--apps/calendar/templates/part.editevent.php1
-rw-r--r--apps/calendar/templates/part.eventform.php12
-rw-r--r--apps/contacts/ajax/addcard.php27
-rw-r--r--apps/contacts/ajax/addproperty.php28
-rw-r--r--apps/contacts/ajax/deletebook.php11
-rw-r--r--apps/contacts/ajax/deletecard.php17
-rw-r--r--apps/contacts/ajax/deleteproperty.php38
-rw-r--r--apps/contacts/ajax/getdetails.php33
-rw-r--r--apps/contacts/ajax/setproperty.php62
-rw-r--r--apps/contacts/ajax/showaddcard.php7
-rw-r--r--apps/contacts/ajax/showaddproperty.php16
-rw-r--r--apps/contacts/ajax/showsetproperty.php39
-rw-r--r--apps/contacts/appinfo/app.php1
-rw-r--r--apps/contacts/css/formtastic.css8
-rw-r--r--apps/contacts/css/styles.css16
-rw-r--r--apps/contacts/index.php14
-rw-r--r--apps/contacts/js/interface.js21
-rw-r--r--apps/contacts/lib/addressbook.php4
-rw-r--r--apps/contacts/lib/app.php122
-rw-r--r--apps/contacts/lib/vcard.php123
-rw-r--r--apps/contacts/photo.php2
-rw-r--r--apps/contacts/templates/index.php9
-rw-r--r--apps/contacts/templates/part.addcardform.php28
-rw-r--r--apps/contacts/templates/part.details.php26
-rw-r--r--apps/contacts/templates/part.property.FN.php9
-rw-r--r--apps/contacts/templates/part.property.php29
-rw-r--r--apps/contacts/templates/part.setpropertyform.php19
-rw-r--r--apps/external/ajax/seturls.php20
-rw-r--r--apps/external/appinfo/app.php10
-rw-r--r--apps/external/index.php2
-rw-r--r--apps/external/settings.php20
-rw-r--r--apps/files_imageviewer/css/jquery.fancybox-1.3.4.css42
-rw-r--r--apps/files_sharing/ajax/getitem.php3
-rw-r--r--apps/files_sharing/ajax/setpermissions.php2
-rw-r--r--apps/files_sharing/ajax/share.php2
-rw-r--r--apps/files_sharing/ajax/unshare.php2
-rw-r--r--apps/files_sharing/ajax/userautocomplete.php2
-rw-r--r--apps/files_sharing/js/share.js9
-rw-r--r--apps/files_sharing/sharedstorage.php4
-rw-r--r--apps/gallery/ajax/createAlbum.php3
-rw-r--r--apps/gallery/ajax/getAlbums.php7
-rw-r--r--apps/gallery/ajax/getCovers.php16
-rw-r--r--apps/gallery/ajax/scanForAlbums.php6
-rw-r--r--apps/gallery/ajax/thumbnail.php17
-rw-r--r--apps/gallery/appinfo/app.php4
-rw-r--r--apps/gallery/css/styles.css14
-rw-r--r--apps/gallery/index.php7
-rw-r--r--apps/gallery/js/albums.js2
-rw-r--r--apps/gallery/lib/album.php18
-rw-r--r--apps/gallery/lib/photo.php28
-rw-r--r--apps/gallery/lib/scanner.php (renamed from apps/gallery/lib_scanner.php)24
-rw-r--r--apps/gallery/templates/view_album.php10
-rw-r--r--apps/media/css/music.css3
-rw-r--r--apps/media/lib_ampache.php12
-rw-r--r--apps/media/lib_collection.php2
-rw-r--r--apps/media/lib_scanner.php6
-rw-r--r--apps/remoteStorage/WebDAV.php (renamed from apps/remoteStorage/compat.php)52
-rw-r--r--apps/remoteStorage/appinfo/database.xml9
-rw-r--r--apps/remoteStorage/appinfo/info.xml2
-rw-r--r--apps/remoteStorage/auth.php100
-rw-r--r--apps/remoteStorage/lib_remoteStorage.php54
-rw-r--r--apps/remoteStorage/oauth_ro_auth.php3
-rw-r--r--apps/user_ldap/appinfo/app.php5
-rw-r--r--apps/user_ldap/settings.php21
-rw-r--r--apps/user_ldap/templates/settings.php17
-rw-r--r--apps/user_ldap/user_ldap.php78
-rw-r--r--apps/user_webfinger/webfinger.php21
-rw-r--r--core/css/styles.css4
-rw-r--r--core/img/actions/upload.pngbin0 -> 236 bytes
-rw-r--r--core/img/actions/upload.svg73
-rw-r--r--core/js/jquery-tipsy.js7
-rw-r--r--core/js/js.js9
-rw-r--r--core/lostpassword/index.php2
-rw-r--r--files/ajax/newfile.php27
-rw-r--r--files/css/files.css19
-rw-r--r--files/index.php5
-rw-r--r--files/js/fileactions.js2
-rw-r--r--files/js/filelist.js63
-rw-r--r--files/js/files.js123
-rw-r--r--files/templates/index.php54
-rw-r--r--files/templates/part.list.php2
-rw-r--r--index.php2
-rw-r--r--l10n/templates/calendar.pot366
-rw-r--r--lib/app.php6
-rw-r--r--lib/base.php11
-rw-r--r--lib/config.php1
-rw-r--r--lib/connector/sabre/file.php2
-rw-r--r--lib/db.php12
-rw-r--r--lib/filestorage/local.php5
-rw-r--r--lib/helper.php25
-rw-r--r--lib/hook.php2
-rw-r--r--lib/l10n.php16
-rw-r--r--lib/log.php3
-rw-r--r--lib/ocsclient.php2
-rw-r--r--lib/setup.php6
-rw-r--r--lib/template.php27
-rw-r--r--lib/updater.php81
-rw-r--r--lib/util.php16
-rw-r--r--lib/vobject.php207
-rw-r--r--settings/ajax/setquota.php2
-rw-r--r--settings/apps.php8
-rw-r--r--settings/js/users.js7
-rw-r--r--settings/templates/help.php5
-rw-r--r--settings/templates/personal.php4
180 files changed, 10462 insertions, 2518 deletions
diff --git a/.gitignore b/.gitignore
index cc4d3bf03b0..68c48822e9d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,3 +40,7 @@ nbproject
# Mac OS
.DS_Store
+
+# WebFinger
+.well-known
+/.buildpath
diff --git a/.htaccess b/.htaccess
index bd2f42d6658..b181f8b8452 100644
--- a/.htaccess
+++ b/.htaccess
@@ -5,8 +5,6 @@ php_value post_max_size 512M
php_value memory_limit 512M
SetEnv htaccessWorking true
</IfModule>
-<IfModule !mod_php5.c>
RewriteEngine on
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization},last]
-</IfModule>
Options -Indexes
diff --git a/3rdparty/Sabre.includes.php b/3rdparty/Sabre.includes.php
index 9d389288c78..d41b287b77d 100644
--- a/3rdparty/Sabre.includes.php
+++ b/3rdparty/Sabre.includes.php
@@ -71,6 +71,7 @@ include 'Sabre/DAV/IExtendedCollection.php';
/* Node abstract implementations */
include 'Sabre/DAV/Node.php';
include 'Sabre/DAV/File.php';
+include 'Sabre/DAV/Collection.php';
include 'Sabre/DAV/Directory.php';
/* Utilities */
@@ -124,4 +125,3 @@ include 'Sabre/DAV/Auth/Backend/PDO.php';
/* DavMount plugin */
include 'Sabre/DAV/Mount/Plugin.php';
-
diff --git a/3rdparty/Sabre/CardDAV/AddressBook.php b/3rdparty/Sabre/CardDAV/AddressBook.php
index 3333480ea85..471ca7b338a 100644
--- a/3rdparty/Sabre/CardDAV/AddressBook.php
+++ b/3rdparty/Sabre/CardDAV/AddressBook.php
@@ -1,7 +1,9 @@
<?php
/**
- * UserAddressBook class
+ * The AddressBook class represents a CardDAV addressbook, owned by a specific user
+ *
+ * The AddressBook can contain multiple vcards
*
* @package Sabre
* @subpackage CardDAV
@@ -9,12 +11,6 @@
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
*/
-
-/**
- * The AddressBook class represents a CardDAV addressbook, owned by a specific user
- *
- * The AddressBook can contain multiple vcards
- */
class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_CardDAV_IAddressBook, Sabre_DAV_IProperties, Sabre_DAVACL_IACL {
/**
diff --git a/3rdparty/Sabre/CardDAV/Backend/Abstract.php b/3rdparty/Sabre/CardDAV/Backend/Abstract.php
index f6d10291ca6..1f0253ddab8 100644
--- a/3rdparty/Sabre/CardDAV/Backend/Abstract.php
+++ b/3rdparty/Sabre/CardDAV/Backend/Abstract.php
@@ -2,6 +2,12 @@
/**
* Abstract Backend class
+ *
+ * This class serves as a base-class for addressbook backends
+ *
+ * Note that there are references to 'addressBookId' scattered throughout the
+ * class. The value of the addressBookId is completely up to you, it can be any
+ * arbitrary value you can use as an unique identifier.
*
* @package Sabre
* @subpackage CardDAV
@@ -9,14 +15,6 @@
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
*/
-
-/**
- * This class serves as a base-class for addressbook backends
- *
- * Note that there are references to 'addressBookId' scattered throughout the
- * class. The value of the addressBookId is completely up to you, it can be any
- * arbitrary value you can use as an unique identifier.
- */
abstract class Sabre_CardDAV_Backend_Abstract {
/**
diff --git a/3rdparty/Sabre/CardDAV/Backend/PDO.php b/3rdparty/Sabre/CardDAV/Backend/PDO.php
index 5556d0a7648..f4e44610ccf 100644
--- a/3rdparty/Sabre/CardDAV/Backend/PDO.php
+++ b/3rdparty/Sabre/CardDAV/Backend/PDO.php
@@ -2,6 +2,8 @@
/**
* PDO CardDAV backend
+ *
+ * This CardDAV backend uses PDO to store addressbooks
*
* @package Sabre
* @subpackage CardDAV
@@ -9,10 +11,6 @@
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
*/
-
-/**
- * This CardDAV backend uses PDO to store addressbooks
- */
class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
/**
diff --git a/3rdparty/Sabre/CardDAV/Card.php b/3rdparty/Sabre/CardDAV/Card.php
index 5298d31e245..2844eaf7ed6 100644
--- a/3rdparty/Sabre/CardDAV/Card.php
+++ b/3rdparty/Sabre/CardDAV/Card.php
@@ -1,18 +1,14 @@
<?php
/**
- * Card class
+ * The Card object represents a single Card from an addressbook
*
* @package Sabre
* @subpackage CardDAV
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
- *
- /
-/**
- * The Card object represents a single Card from an addressbook
- */
+ */
class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard, Sabre_DAVACL_IACL {
/**
diff --git a/3rdparty/Sabre/CardDAV/ICard.php b/3rdparty/Sabre/CardDAV/ICard.php
index 8f9bb097b56..25bcc551b73 100644
--- a/3rdparty/Sabre/CardDAV/ICard.php
+++ b/3rdparty/Sabre/CardDAV/ICard.php
@@ -2,18 +2,16 @@
/**
* Card interface
+ *
+ * Extend the ICard interface to allow your custom nodes to be picked up as
+ * 'Cards'.
*
* @package Sabre
* @subpackage CardDAV
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
- *
- /
-/**
- * Extend the ICard interface to allow your custom nodes to be picked up as
- * 'Cards'.
- */
+ */
interface Sabre_CardDAV_ICard extends Sabre_DAV_IFile {
}
diff --git a/3rdparty/Sabre/CardDAV/Plugin.php b/3rdparty/Sabre/CardDAV/Plugin.php
index 17766b78278..14c9c72b0d5 100644
--- a/3rdparty/Sabre/CardDAV/Plugin.php
+++ b/3rdparty/Sabre/CardDAV/Plugin.php
@@ -1,7 +1,9 @@
<?php
/**
- * CardDAV plugin
+ * CardDAV plugin
+ *
+ * The CardDAV plugin adds CardDAV functionality to the WebDAV server
*
* @package Sabre
* @subpackage CardDAV
@@ -9,11 +11,6 @@
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
*/
-
-
-/**
- * The CardDAV plugin adds CardDAV functionality to the WebDAV server
- */
class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
/**
diff --git a/3rdparty/Sabre/CardDAV/UserAddressBooks.php b/3rdparty/Sabre/CardDAV/UserAddressBooks.php
index 564ecd701f0..e9f2de7f741 100644
--- a/3rdparty/Sabre/CardDAV/UserAddressBooks.php
+++ b/3rdparty/Sabre/CardDAV/UserAddressBooks.php
@@ -2,17 +2,15 @@
/**
* UserAddressBooks class
- *
+ *
+ * The UserAddressBooks collection contains a list of addressbooks associated with a user
+ *
* @package Sabre
* @subpackage CardDAV
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
*/
-
-/**
- * The UserAddressBooks collection contains a list of addressbooks associated with a user
- */
class Sabre_CardDAV_UserAddressBooks extends Sabre_DAV_Collection implements Sabre_DAV_IExtendedCollection, Sabre_DAVACL_IACL {
/**
diff --git a/3rdparty/Sabre/CardDAV/Version.php b/3rdparty/Sabre/CardDAV/Version.php
index c76ee360354..900fbf5e75c 100644
--- a/3rdparty/Sabre/CardDAV/Version.php
+++ b/3rdparty/Sabre/CardDAV/Version.php
@@ -2,6 +2,8 @@
/**
* Version Class
+ *
+ * This class contains the Sabre_CardDAV version information
*
* @package Sabre
* @subpackage CardDAV
@@ -9,10 +11,6 @@
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
*/
-
-/**
- * This class contains the Sabre_CardDAV version information
- */
class Sabre_CardDAV_Version {
/**
diff --git a/3rdparty/Sabre/DAV/Browser/GuessContentType.php b/3rdparty/Sabre/DAV/Browser/GuessContentType.php
index 8b55ec3ad9f..ee8c698d782 100644
--- a/3rdparty/Sabre/DAV/Browser/GuessContentType.php
+++ b/3rdparty/Sabre/DAV/Browser/GuessContentType.php
@@ -88,7 +88,7 @@ class Sabre_DAV_Browser_GuessContentType extends Sabre_DAV_ServerPlugin {
protected function getContentType($fileName) {
// Just grabbing the extension
- $extension = substr($fileName,strrpos($fileName,'.')+1);
+ $extension = strtolower(substr($fileName,strrpos($fileName,'.')+1));
if (isset($this->extensionMap[$extension]))
return $this->extensionMap[$extension];
diff --git a/3rdparty/Sabre/DAV/Server.php b/3rdparty/Sabre/DAV/Server.php
index b99866dad5e..3d76d4f1918 100644
--- a/3rdparty/Sabre/DAV/Server.php
+++ b/3rdparty/Sabre/DAV/Server.php
@@ -821,7 +821,7 @@ class Sabre_DAV_Server {
$node->put($body);
$this->httpResponse->setHeader('Content-Length','0');
- $this->httpResponse->sendStatus(200);
+ $this->httpResponse->sendStatus(204);
} else {
diff --git a/3rdparty/Sabre/DAV/Version.php b/3rdparty/Sabre/DAV/Version.php
index e7f7f83e6ff..6bece1985e4 100644
--- a/3rdparty/Sabre/DAV/Version.php
+++ b/3rdparty/Sabre/DAV/Version.php
@@ -14,7 +14,7 @@ class Sabre_DAV_Version {
/**
* Full version number
*/
- const VERSION = '1.5.3';
+ const VERSION = '1.5.4';
/**
* Stability : alpha, beta, stable
diff --git a/3rdparty/Sabre/DAVACL/Exception/NeedPrivileges.php b/3rdparty/Sabre/DAVACL/Exception/NeedPrivileges.php
index 640ab8efff4..024ab6641f3 100644
--- a/3rdparty/Sabre/DAVACL/Exception/NeedPrivileges.php
+++ b/3rdparty/Sabre/DAVACL/Exception/NeedPrivileges.php
@@ -2,6 +2,9 @@
/**
* NeedPrivileges
+ *
+ * The 403-need privileges is thrown when a user didn't have the appropriate
+ * permissions to perform an operation
*
* @package Sabre
* @subpackage DAVACL
@@ -10,13 +13,6 @@
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
*/
-
-/**
- * NeedPrivileges
- *
- * The 403-need privileges is thrown when a user didn't have the appropriate
- * permissions to perform an operation
- */
class Sabre_DAVACL_Exception_NeedPrivileges extends Sabre_DAV_Exception_Forbidden {
/**
diff --git a/3rdparty/Sabre/DAVACL/PrincipalCollection.php b/3rdparty/Sabre/DAVACL/PrincipalCollection.php
index 3cc0ae84621..4d22bf8aa75 100644
--- a/3rdparty/Sabre/DAVACL/PrincipalCollection.php
+++ b/3rdparty/Sabre/DAVACL/PrincipalCollection.php
@@ -9,7 +9,7 @@
* The users are instances of Sabre_DAV_Auth_Principal
*
* @package Sabre
- * @subpackage DAV
+ * @subpackage DAVACL
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
diff --git a/3rdparty/Sabre/LICENCE b/3rdparty/Sabre/LICENCE
new file mode 100644
index 00000000000..3d07eaace83
--- /dev/null
+++ b/3rdparty/Sabre/LICENCE
@@ -0,0 +1,27 @@
+Copyright (C) 2007-2011 Rooftop Solutions.
+Copyright (C) 2007-2009 FileMobile inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of the SabreDAV nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
diff --git a/3rdparty/Sabre/VObject/Component.php b/3rdparty/Sabre/VObject/Component.php
index 3d5a3d75635..47cf9f3d812 100644
--- a/3rdparty/Sabre/VObject/Component.php
+++ b/3rdparty/Sabre/VObject/Component.php
@@ -83,13 +83,16 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
if (!is_null($itemValue)) {
throw new InvalidArgumentException('The second argument must not be specified, when passing a VObject');
}
+ $item->parent = $this;
$this->children[] = $item;
} elseif(is_string($item)) {
if (!is_scalar($itemValue)) {
throw new InvalidArgumentException('The second argument must be scalar');
}
- $this->children[] = new Sabre_VObject_Property($item,$itemValue);
+ $item = new Sabre_VObject_Property($item,$itemValue);
+ $item->parent = $this;
+ $this->children[] = $item;
} else {
@@ -208,16 +211,19 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
$overWrite = count($matches)?key($matches):null;
if ($value instanceof Sabre_VObject_Component || $value instanceof Sabre_VObject_Property) {
+ $value->parent = $this;
if (!is_null($overWrite)) {
$this->children[$overWrite] = $value;
} else {
$this->children[] = $value;
}
} elseif (is_scalar($value)) {
+ $property = new Sabre_VObject_Property($name,$value);
+ $property->parent = $this;
if (!is_null($overWrite)) {
- $this->children[$overWrite] = new Sabre_VObject_Property($name,$value);
+ $this->children[$overWrite] = $property;
} else {
- $this->children[] = new Sabre_VObject_Property($name,$value);
+ $this->children[] = $property;
}
} else {
throw new InvalidArgumentException('You must pass a Sabre_VObject_Component, Sabre_VObject_Property or scalar type');
@@ -237,6 +243,7 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
foreach($matches as $k=>$child) {
unset($this->children[$k]);
+ $child->parent = null;
}
diff --git a/3rdparty/Sabre/VObject/Element/DateTime.php b/3rdparty/Sabre/VObject/Element/DateTime.php
index 30e5c6ca86a..3350ec02c88 100644
--- a/3rdparty/Sabre/VObject/Element/DateTime.php
+++ b/3rdparty/Sabre/VObject/Element/DateTime.php
@@ -70,7 +70,7 @@ class Sabre_VObject_Element_DateTime extends Sabre_VObject_Property {
$this->setValue($dt->format('Ymd\\THis'));
$this->offsetUnset('VALUE');
$this->offsetUnset('TZID');
- $this->offsetSet('VALUE','DATE-TIME');
+ $this->offsetSet('VALUE','DATE-TIME');
break;
case self::UTC :
$dt->setTimeZone(new DateTimeZone('UTC'));
@@ -116,7 +116,7 @@ class Sabre_VObject_Element_DateTime extends Sabre_VObject_Property {
list(
$this->dateType,
$this->dateTime
- ) = self::parseData($this->value, $this->offsetGet('TZID'));
+ ) = self::parseData($this->value, $this);
return $this->dateTime;
}
@@ -137,7 +137,7 @@ class Sabre_VObject_Element_DateTime extends Sabre_VObject_Property {
list(
$this->dateType,
$this->dateTime,
- ) = self::parseData($this->value, $this->offsetGet('TZID'));
+ ) = self::parseData($this->value, $this);
return $this->dateType;
}
@@ -151,12 +151,12 @@ class Sabre_VObject_Element_DateTime extends Sabre_VObject_Property {
* 2. A DateTime object (or null)
*
* @param string|null $propertyValue The string to parse (yymmdd or
- * ymmddThhmmss, etc..)
- * @param string|null $tzid The value of the 'TZID' property.
+ * ymmddThhmmss, etc..)
+ * @param Sabre_VObject_Property|null $property The instance of the
+ * property we're parsing.
* @return array
*/
- static public function parseData($propertyValue, $tzid) {
-
+ static public function parseData($propertyValue, Sabre_VObject_Property $property = null) {
if (is_null($propertyValue)) {
return array(null, null);
@@ -195,6 +195,8 @@ class Sabre_VObject_Element_DateTime extends Sabre_VObject_Property {
);
}
+ // Finding the timezone.
+ $tzid = $property['TZID'];
if (!$tzid) {
return array(
self::LOCAL,
@@ -202,7 +204,32 @@ class Sabre_VObject_Element_DateTime extends Sabre_VObject_Property {
);
}
- $tz = new DateTimeZone($tzid->value);
+ try {
+ $tz = new DateTimeZone($tzid->value);
+ } catch (Exception $e) {
+
+ // The id was invalid, we're going to try to find the information
+ // through the VTIMEZONE object.
+
+ // First we find the root object
+ $root = $property;
+ while($root->parent) {
+ $root = $root->parent;
+ }
+
+ if (isset($root->VTIMEZONE)) {
+ foreach($root->VTIMEZONE as $vtimezone) {
+ if (((string)$vtimezone->TZID) == $tzid) {
+ if (isset($vtimezone->{'X-LIC-LOCATION'})) {
+ $tzid = (string)$vtimezone->{'X-LIC-LOCATION'};
+ }
+ }
+ }
+ }
+
+ $tz = new DateTimeZone($tzid);
+
+ }
$dt = new DateTime($dateStr, $tz);
$dt->setTimeZone($tz);
diff --git a/3rdparty/Sabre/VObject/Element/MultiDateTime.php b/3rdparty/Sabre/VObject/Element/MultiDateTime.php
index 5e677f5e5b5..dc6ca5abb80 100644
--- a/3rdparty/Sabre/VObject/Element/MultiDateTime.php
+++ b/3rdparty/Sabre/VObject/Element/MultiDateTime.php
@@ -60,7 +60,7 @@ class Sabre_VObject_Element_MultiDateTime extends Sabre_VObject_Property {
$val[] = $i->format('Ymd\\THis');
}
$this->setValue(implode(',',$val));
- $this->offsetSet('VALUE','DATE-TIME');
+ $this->offsetSet('VALUE','DATE-TIME');
break;
case Sabre_VObject_Element_DateTime::UTC :
$val = array();
@@ -121,7 +121,7 @@ class Sabre_VObject_Element_MultiDateTime extends Sabre_VObject_Property {
list(
$type,
$dt
- ) = Sabre_VObject_Element_DateTime::parseData($val, $this->offsetGet('TZID'));
+ ) = Sabre_VObject_Element_DateTime::parseData($val, $this);
$dts[] = $dt;
$this->dateType = $type;
}
@@ -154,7 +154,7 @@ class Sabre_VObject_Element_MultiDateTime extends Sabre_VObject_Property {
list(
$type,
$dt
- ) = Sabre_VObject_Element_DateTime::parseData($val, $this->offsetGet('TZID'));
+ ) = Sabre_VObject_Element_DateTime::parseData($val, $this);
$dts[] = $dt;
$this->dateType = $type;
}
diff --git a/3rdparty/Sabre/VObject/Node.php b/3rdparty/Sabre/VObject/Node.php
index efc7f76da79..7100b62f1cb 100644
--- a/3rdparty/Sabre/VObject/Node.php
+++ b/3rdparty/Sabre/VObject/Node.php
@@ -25,6 +25,13 @@ abstract class Sabre_VObject_Node implements IteratorAggregate, ArrayAccess, Cou
*/
protected $iterator = null;
+ /**
+ * A link to the parent node
+ *
+ * @var Sabre_VObject_Node
+ */
+ protected $parent = null;
+
/* {{{ IteratorAggregator interface */
/**
diff --git a/3rdparty/Sabre/VObject/Property.php b/3rdparty/Sabre/VObject/Property.php
index 624dd4b8a58..06058229043 100644
--- a/3rdparty/Sabre/VObject/Property.php
+++ b/3rdparty/Sabre/VObject/Property.php
@@ -149,13 +149,16 @@ class Sabre_VObject_Property extends Sabre_VObject_Element {
if (!is_null($itemValue)) {
throw new InvalidArgumentException('The second argument must not be specified, when passing a VObject');
}
+ $item->parent = $this;
$this->parameters[] = $item;
} elseif(is_string($item)) {
if (!is_scalar($itemValue)) {
throw new InvalidArgumentException('The second argument must be scalar');
}
- $this->parameters[] = new Sabre_VObject_Parameter($item,$itemValue);
+ $parameter = new Sabre_VObject_Parameter($item,$itemValue);
+ $parameter->parent = $this;
+ $this->parameters[] = $parameter;
} else {
@@ -231,12 +234,15 @@ class Sabre_VObject_Property extends Sabre_VObject_Element {
throw new InvalidArgumentException('A parameter name must be specified. This means you cannot use the $array[]="string" to add parameters.');
$this->offsetUnset($name);
- $this->parameters[] = new Sabre_VObject_Parameter($name, $value);
+ $parameter = new Sabre_VObject_Parameter($name, $value);
+ $parameter->parent = $this;
+ $this->parameters[] = $parameter;
} elseif ($value instanceof Sabre_VObject_Parameter) {
if (!is_null($name))
throw new InvalidArgumentException('Don\'t specify a parameter name if you\'re passing a Sabre_VObject_Parameter. Add using $array[]=$parameterObject.');
-
+
+ $value->parent = $this;
$this->parameters[] = $value;
} else {
throw new InvalidArgumentException('You can only add parameters to the property object');
@@ -258,6 +264,7 @@ class Sabre_VObject_Property extends Sabre_VObject_Element {
$result = array();
foreach($this->parameters as $key=>$parameter) {
if ($parameter->name == $name) {
+ $parameter->parent = null;
unset($this->parameters[$key]);
}
diff --git a/3rdparty/Sabre/VObject/Reader.php b/3rdparty/Sabre/VObject/Reader.php
index c38afbfb632..7d1c282838e 100644
--- a/3rdparty/Sabre/VObject/Reader.php
+++ b/3rdparty/Sabre/VObject/Reader.php
@@ -95,7 +95,7 @@ class Sabre_VObject_Reader {
while(stripos($nextLine,"END:")!==0) {
- $obj->children[] = self::readLine($lines);
+ $obj->add(self::readLine($lines));
$nextLine = current($lines);
if ($nextLine===false)
@@ -117,7 +117,7 @@ class Sabre_VObject_Reader {
//$result = preg_match('/(?P<name>[A-Z0-9-]+)(?:;(?P<parameters>^(?<!:):))(.*)$/',$line,$matches);
- $token = '[A-Z0-9-\.]+';
+ $token = '[A-Z0-9-\/\.]+';
$parameters = "(?:;(?P<parameters>([^:^\"]|\"([^\"]*)\")*))?";
$regex = "/^(?P<name>$token)$parameters:(?P<value>.*)$/i";
@@ -140,7 +140,9 @@ class Sabre_VObject_Reader {
if ($matches['parameters']) {
- $obj->parameters = self::readParameters($matches['parameters']);
+ foreach(self::readParameters($matches['parameters']) as $param) {
+ $obj->add($param);
+ }
}
return $obj;
diff --git a/3rdparty/Sabre/VObject/Version.php b/3rdparty/Sabre/VObject/Version.php
index 950c1c51104..937c367e222 100644
--- a/3rdparty/Sabre/VObject/Version.php
+++ b/3rdparty/Sabre/VObject/Version.php
@@ -14,7 +14,7 @@ class Sabre_VObject_Version {
/**
* Full version number
*/
- const VERSION = '1.2.2';
+ const VERSION = '1.2.4';
/**
* Stability : alpha, beta, stable
diff --git a/3rdparty/css/chosen/chosen-sprite.png b/3rdparty/css/chosen/chosen-sprite.png
index f20db4439ea..9edce05a6a8 100644
--- a/3rdparty/css/chosen/chosen-sprite.png
+++ b/3rdparty/css/chosen/chosen-sprite.png
Binary files differ
diff --git a/3rdparty/css/chosen/chosen.css b/3rdparty/css/chosen/chosen.css
index 247d07bf021..b9c6d88028f 100644
--- a/3rdparty/css/chosen/chosen.css
+++ b/3rdparty/css/chosen/chosen.css
@@ -1,9 +1,4 @@
/* @group Base */
-select.chzn-select {
- visibility: hidden;
- height: 28px !important;
- min-height: 28px !important;
-}
.chzn-container {
font-size: 13px;
position: relative;
@@ -60,9 +55,21 @@ select.chzn-select {
white-space: nowrap;
-o-text-overflow: ellipsis;
-ms-text-overflow: ellipsis;
- -moz-binding: url('/xml/ellipsis.xml#ellipsis');
text-overflow: ellipsis;
}
+.chzn-container-single .chzn-single abbr {
+ display: block;
+ position: absolute;
+ right: 26px;
+ top: 8px;
+ width: 12px;
+ height: 13px;
+ font-size: 1px;
+ background: url(chosen-sprite.png) right top no-repeat;
+}
+.chzn-container-single .chzn-single abbr:hover {
+ background-position: right -11px;
+}
.chzn-container-single .chzn-single div {
-webkit-border-radius: 0 4px 4px 0;
-moz-border-radius : 0 4px 4px 0;
@@ -94,18 +101,19 @@ select.chzn-select {
}
.chzn-container-single .chzn-search {
padding: 3px 4px;
+ position: relative;
margin: 0;
white-space: nowrap;
}
.chzn-container-single .chzn-search input {
- background: #fff url('chosen-sprite.png') no-repeat 100% -20px;
- background: url('chosen-sprite.png') no-repeat 100% -20px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee));
- background: url('chosen-sprite.png') no-repeat 100% -20px, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%);
- background: url('chosen-sprite.png') no-repeat 100% -20px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%);
- background: url('chosen-sprite.png') no-repeat 100% -20px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%);
- background: url('chosen-sprite.png') no-repeat 100% -20px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
- background: url('chosen-sprite.png') no-repeat 100% -20px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
- background: url('chosen-sprite.png') no-repeat 100% -20px, linear-gradient(top, #ffffff 85%,#eeeeee 99%);
+ background: #fff url('chosen-sprite.png') no-repeat 100% -22px;
+ background: url('chosen-sprite.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee));
+ background: url('chosen-sprite.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%);
+ background: url('chosen-sprite.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%);
+ background: url('chosen-sprite.png') no-repeat 100% -22px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%);
+ background: url('chosen-sprite.png') no-repeat 100% -22px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
+ background: url('chosen-sprite.png') no-repeat 100% -22px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
+ background: url('chosen-sprite.png') no-repeat 100% -22px, linear-gradient(top, #ffffff 85%,#eeeeee 99%);
margin: 1px 0;
padding: 4px 20px 4px 5px;
outline: 0;
@@ -123,6 +131,11 @@ select.chzn-select {
}
/* @end */
+.chzn-container-single-nosearch .chzn-search input {
+ position: absolute;
+ left: -9000px;
+}
+
/* @group Multi Chosen */
.chzn-container-multi .chzn-choices {
background-color: #fff;
@@ -197,18 +210,18 @@ select.chzn-select {
.chzn-container-multi .chzn-choices .search-choice .search-choice-close {
display: block;
position: absolute;
- right: 5px;
- top: 6px;
- width: 8px;
- height: 9px;
+ right: 3px;
+ top: 4px;
+ width: 12px;
+ height: 13px;
font-size: 1px;
background: url(chosen-sprite.png) right top no-repeat;
}
.chzn-container-multi .chzn-choices .search-choice .search-choice-close:hover {
- background-position: right -9px;
+ background-position: right -11px;
}
.chzn-container-multi .chzn-choices .search-choice-focus .search-choice-close {
- background-position: right -9px;
+ background-position: right -11px;
}
/* @end */
@@ -226,6 +239,7 @@ select.chzn-select {
padding: 0;
}
.chzn-container .chzn-results li {
+ display: none;
line-height: 80%;
padding: 7px 7px 8px;
margin: 0;
@@ -233,6 +247,7 @@ select.chzn-select {
}
.chzn-container .chzn-results .active-result {
cursor: pointer;
+ display: list-item;
}
.chzn-container .chzn-results .highlighted {
background: #3875d7;
@@ -247,6 +262,7 @@ select.chzn-select {
}
.chzn-container .chzn-results .no-results {
background: #f4f4f4;
+ display: list-item;
}
.chzn-container .chzn-results .group-result {
cursor: default;
@@ -309,6 +325,18 @@ select.chzn-select {
}
/* @end */
+/* @group Disabled Support */
+.chzn-disabled {
+ cursor: default;
+ opacity:0.5 !important;
+}
+.chzn-disabled .chzn-single {
+ cursor: default;
+}
+.chzn-disabled .chzn-choices .search-choice .search-choice-close {
+ cursor: default;
+}
+
/* @group Right to Left */
.chzn-rtl { direction:rtl;text-align: right; }
.chzn-rtl .chzn-single { padding-left: 0; padding-right: 8px; }
@@ -327,14 +355,14 @@ select.chzn-select {
.chzn-rtl .chzn-results .group-option { padding-left: 0; padding-right: 20px; }
.chzn-rtl.chzn-container-active .chzn-single-with-drop div { border-right: none; }
.chzn-rtl .chzn-search input {
- background: url('chosen-sprite.png') no-repeat -38px -20px, #ffffff;
- background: url('chosen-sprite.png') no-repeat -38px -20px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee));
- background: url('chosen-sprite.png') no-repeat -38px -20px, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%);
- background: url('chosen-sprite.png') no-repeat -38px -20px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%);
- background: url('chosen-sprite.png') no-repeat -38px -20px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%);
- background: url('chosen-sprite.png') no-repeat -38px -20px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
- background: url('chosen-sprite.png') no-repeat -38px -20px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
- background: url('chosen-sprite.png') no-repeat -38px -20px, linear-gradient(top, #ffffff 85%,#eeeeee 99%);
+ background: url('chosen-sprite.png') no-repeat -38px -22px, #ffffff;
+ background: url('chosen-sprite.png') no-repeat -38px -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee));
+ background: url('chosen-sprite.png') no-repeat -38px -22px, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%);
+ background: url('chosen-sprite.png') no-repeat -38px -22px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%);
+ background: url('chosen-sprite.png') no-repeat -38px -22px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%);
+ background: url('chosen-sprite.png') no-repeat -38px -22px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
+ background: url('chosen-sprite.png') no-repeat -38px -22px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
+ background: url('chosen-sprite.png') no-repeat -38px -22px, linear-gradient(top, #ffffff 85%,#eeeeee 99%);
padding: 4px 5px 4px 20px;
}
/* @end */ \ No newline at end of file
diff --git a/3rdparty/fullcalendar/GPL-LICENSE.txt b/3rdparty/fullcalendar/GPL-LICENSE.txt
new file mode 100644
index 00000000000..11dddd00ef0
--- /dev/null
+++ b/3rdparty/fullcalendar/GPL-LICENSE.txt
@@ -0,0 +1,278 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
diff --git a/3rdparty/fullcalendar/MIT-LICENSE.txt b/3rdparty/fullcalendar/MIT-LICENSE.txt
new file mode 100644
index 00000000000..46d47544964
--- /dev/null
+++ b/3rdparty/fullcalendar/MIT-LICENSE.txt
@@ -0,0 +1,20 @@
+Copyright (c) 2009 Adam Shaw
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/3rdparty/fullcalendar/changelog.txt b/3rdparty/fullcalendar/changelog.txt
new file mode 100644
index 00000000000..50d0880fd7a
--- /dev/null
+++ b/3rdparty/fullcalendar/changelog.txt
@@ -0,0 +1,313 @@
+
+version 1.5.2 (8/21/11)
+ - correctly process UTC "Z" ISO8601 date strings (issue 750)
+
+version 1.5.1 (4/9/11)
+ - more flexible ISO8601 date parsing (issue 814)
+ - more flexible parsing of UNIX timestamps (issue 826)
+ - FullCalendar now buildable from source on a Mac (issue 795)
+ - FullCalendar QA'd in FF4 (issue 883)
+ - upgraded to jQuery 1.5.2 (which supports IE9) and jQuery UI 1.8.11
+
+version 1.5 (3/19/11)
+ - slicker default styling for buttons
+ - reworked a lot of the calendar's HTML and accompanying CSS
+ (solves issues 327 and 395)
+ - more printer-friendly (fullcalendar-print.css)
+ - fullcalendar now inherits styles from jquery-ui themes differently.
+ styles for buttons are distinct from styles for calendar cells.
+ (solves issue 299)
+ - can now color events through FullCalendar options and Event-Object properties (issue 117)
+ THIS IS NOW THE PREFERRED METHOD OF COLORING EVENTS (as opposed to using className and CSS)
+ - FullCalendar options:
+ - eventColor (changes both background and border)
+ - eventBackgroundColor
+ - eventBorderColor
+ - eventTextColor
+ - Event-Object options:
+ - color (changes both background and border)
+ - backgroundColor
+ - borderColor
+ - textColor
+ - can now specify an event source as an *object* with a `url` property (json feed) or
+ an `events` property (function or array) with additional properties that will
+ be applied to the entire event source:
+ - color (changes both background and border)
+ - backgroudColor
+ - borderColor
+ - textColor
+ - className
+ - editable
+ - allDayDefault
+ - ignoreTimezone
+ - startParam (for a feed)
+ - endParam (for a feed)
+ - ANY OF THE JQUERY $.ajax OPTIONS
+ allows for easily changing from GET to POST and sending additional parameters (issue 386)
+ allows for easily attaching ajax handlers such as `error` (issue 754)
+ allows for turning caching on (issue 355)
+ - Google Calendar feeds are now specified differently:
+ - specify a simple string of your feed's URL
+ - specify an *object* with a `url` property of your feed's URL.
+ you can include any of the new Event-Source options in this object.
+ - the old `$.fullCalendar.gcalFeed` method still works
+ - no more IE7 SSL popup (issue 504)
+ - remove `cacheParam` - use json event source `cache` option instead
+ - latest jquery/jquery-ui
+
+version 1.4.11 (2/22/11)
+ - fixed rerenderEvents bug (issue 790)
+ - fixed bug with faulty dragging of events from all-day slot in agenda views
+ - bundled with jquery 1.5 and jquery-ui 1.8.9
+
+version 1.4.10 (1/2/11)
+ - fixed bug with resizing event to different week in 5-day month view (issue 740)
+ - fixed bug with events not sticking after a removeEvents call (issue 757)
+ - fixed bug with underlying parseTime method, and other uses of parseInt (issue 688)
+
+version 1.4.9 (11/16/10)
+ - new algorithm for vertically stacking events (issue 111)
+ - resizing an event to a different week (issue 306)
+ - bug: some events not rendered with consecutive calls to addEventSource (issue 679)
+
+version 1.4.8 (10/16/10)
+ - ignoreTimezone option (set to `false` to process UTC offsets in ISO8601 dates)
+ - bugfixes
+ - event refetching not being called under certain conditions (issues 417, 554)
+ - event refetching being called multiple times under certain conditions (issues 586, 616)
+ - selection cannot be triggered by right mouse button (issue 558)
+ - agenda view left axis sized incorrectly (issue 465)
+ - IE js error when calendar is too narrow (issue 517)
+ - agenda view looks strange when no scrollbars (issue 235)
+ - improved parsing of ISO8601 dates with UTC offsets
+ - $.fullCalendar.version
+ - an internal refactor of the code, for easier future development and modularity
+
+version 1.4.7 (7/5/10)
+ - "dropping" external objects onto the calendar
+ - droppable (boolean, to turn on/off)
+ - dropAccept (to filter which events the calendar will accept)
+ - drop (trigger)
+ - selectable options can now be specified with a View Option Hash
+ - bugfixes
+ - dragged & reverted events having wrong time text (issue 406)
+ - bug rendering events that have an endtime with seconds, but no hours/minutes (issue 477)
+ - gotoDate date overflow bug (issue 429)
+ - wrong date reported when clicking on edge of last column in agenda views (412)
+ - support newlines in event titles
+ - select/unselect callbacks now passes native js event
+
+version 1.4.6 (5/31/10)
+ - "selecting" days or timeslots
+ - options: selectable, selectHelper, unselectAuto, unselectCancel
+ - callbacks: select, unselect
+ - methods: select, unselect
+ - when dragging an event, the highlighting reflects the duration of the event
+ - code compressing by Google Closure Compiler
+ - bundled with jQuery 1.4.2 and jQuery UI 1.8.1
+
+version 1.4.5 (2/21/10)
+ - lazyFetching option, which can force the calendar to fetch events on every view/date change
+ - scroll state of agenda views are preserved when switching back to view
+ - bugfixes
+ - calling methods on an uninitialized fullcalendar throws error
+ - IE6/7 bug where an entire view becomes invisible (issue 320)
+ - error when rendering a hidden calendar (in jquery ui tabs for example) in IE (issue 340)
+ - interconnected bugs related to calendar resizing and scrollbars
+ - when switching views or clicking prev/next, calendar would "blink" (issue 333)
+ - liquid-width calendar's events shifted (depending on initial height of browser) (issue 341)
+ - more robust underlying algorithm for calendar resizing
+
+version 1.4.4 (2/3/10)
+ - optimized event rendering in all views (events render in 1/10 the time)
+ - gotoDate() does not force the calendar to unnecessarily rerender
+ - render() method now correctly readjusts height
+
+version 1.4.3 (12/22/09)
+ - added destroy method
+ - Google Calendar event pages respect currentTimezone
+ - caching now handled by jQuery's ajax
+ - protection from setting aspectRatio to zero
+ - bugfixes
+ - parseISO8601 and DST caused certain events to display day before
+ - button positioning problem in IE6
+ - ajax event source removed after recently being added, events still displayed
+ - event not displayed when end is an empty string
+ - dynamically setting calendar height when no events have been fetched, throws error
+
+version 1.4.2 (12/02/09)
+ - eventAfterRender trigger
+ - getDate & getView methods
+ - height & contentHeight options (explicitly sets the pixel height)
+ - minTime & maxTime options (restricts shown hours in agenda view)
+ - getters [for all options] and setters [for height, contentHeight, and aspectRatio ONLY! stay tuned..]
+ - render method now readjusts calendar's size
+ - bugfixes
+ - lightbox scripts that use iframes (like fancybox)
+ - day-of-week classNames were off when firstDay=1
+ - guaranteed space on right side of agenda events (even when stacked)
+ - accepts ISO8601 dates with a space (instead of 'T')
+
+version 1.4.1 (10/31/09)
+ - can exclude weekends with new 'weekends' option
+ - gcal feed 'currentTimezone' option
+ - bugfixes
+ - year/month/date option sometimes wouldn't set correctly (depending on current date)
+ - daylight savings issue caused agenda views to start at 1am (for BST users)
+ - cleanup of gcal.js code
+
+version 1.4 (10/19/09)
+ - agendaWeek and agendaDay views
+ - added some options for agenda views:
+ - allDaySlot
+ - allDayText
+ - firstHour
+ - slotMinutes
+ - defaultEventMinutes
+ - axisFormat
+ - modified some existing options/triggers to work with agenda views:
+ - dragOpacity and timeFormat can now accept a "View Hash" (a new concept)
+ - dayClick now has an allDay parameter
+ - eventDrop now has an an allDay parameter
+ (this will affect those who use revertFunc, adjust parameter list)
+ - added 'prevYear' and 'nextYear' for buttons in header
+ - minor change for theme users, ui-state-hover not applied to active/inactive buttons
+ - added event-color-changing example in docs
+ - better defaults for right-to-left themed button icons
+
+version 1.3.2 (10/13/09)
+ - Bugfixes (please upgrade from 1.3.1!)
+ - squashed potential infinite loop when addMonths and addDays
+ is called with an invalid date
+ - $.fullCalendar.parseDate() now correctly parses IETF format
+ - when switching views, the 'today' button sticks inactive, fixed
+ - gotoDate now can accept a single Date argument
+ - documentation for changes in 1.3.1 and 1.3.2 now on website
+
+version 1.3.1 (9/30/09)
+ - Important Bugfixes (please upgrade from 1.3!)
+ - When current date was late in the month, for long months, and prev/next buttons
+ were clicked in month-view, some months would be skipped/repeated
+ - In certain time zones, daylight savings time would cause certain days
+ to be misnumbered in month-view
+ - Subtle change in way week interval is chosen when switching from month to basicWeek/basicDay view
+ - Added 'allDayDefault' option
+ - Added 'changeView' and 'render' methods
+
+version 1.3 (9/21/09)
+ - different 'views': month/basicWeek/basicDay
+ - more flexible 'header' system for buttons
+ - themable by jQuery UI themes
+ - resizable events (require jQuery UI resizable plugin)
+ - rescoped & rewritten CSS, enhanced default look
+ - cleaner css & rendering techniques for right-to-left
+ - reworked options & API to support multiple views / be consistent with jQuery UI
+ - refactoring of entire codebase
+ - broken into different JS & CSS files, assembled w/ build scripts
+ - new test suite for new features, uses firebug-lite
+ - refactored docs
+ - Options
+ + date
+ + defaultView
+ + aspectRatio
+ + disableResizing
+ + monthNames (use instead of $.fullCalendar.monthNames)
+ + monthNamesShort (use instead of $.fullCalendar.monthAbbrevs)
+ + dayNames (use instead of $.fullCalendar.dayNames)
+ + dayNamesShort (use instead of $.fullCalendar.dayAbbrevs)
+ + theme
+ + buttonText
+ + buttonIcons
+ x draggable -> editable/disableDragging
+ x fixedWeeks -> weekMode
+ x abbrevDayHeadings -> columnFormat
+ x buttons/title -> header
+ x eventDragOpacity -> dragOpacity
+ x eventRevertDuration -> dragRevertDuration
+ x weekStart -> firstDay
+ x rightToLeft -> isRTL
+ x showTime (use 'allDay' CalEvent property instead)
+ - Triggered Actions
+ + eventResizeStart
+ + eventResizeStop
+ + eventResize
+ x monthDisplay -> viewDisplay
+ x resize -> windowResize
+ 'eventDrop' params changed, can revert if ajax cuts out
+ - CalEvent Properties
+ x showTime -> allDay
+ x draggable -> editable
+ 'end' is now INCLUSIVE when allDay=true
+ 'url' now produces a real <a> tag, more native clicking/tab behavior
+ - Methods:
+ + renderEvent
+ x prevMonth -> prev
+ x nextMonth -> next
+ x prevYear/nextYear -> moveDate
+ x refresh -> rerenderEvents/refetchEvents
+ x removeEvent -> removeEvents
+ x getEventsByID -> clientEvents
+ - Utilities:
+ 'formatDate' format string completely changed (inspired by jQuery UI datepicker + datejs)
+ 'formatDates' added to support date-ranges
+ - Google Calendar Options:
+ x draggable -> editable
+ - Bugfixes
+ - gcal extension fetched 25 results max, now fetches all
+
+version 1.2.1 (6/29/09)
+ - bugfixes
+ - allows and corrects invalid end dates for events
+ - doesn't throw an error in IE while rendering when display:none
+ - fixed 'loading' callback when used w/ multiple addEventSource calls
+ - gcal className can now be an array
+
+version 1.2 (5/31/09)
+ - expanded API
+ - 'className' CalEvent attribute
+ - 'source' CalEvent attribute
+ - dynamically get/add/remove/update events of current month
+ - locale improvements: change month/day name text
+ - better date formatting ($.fullCalendar.formatDate)
+ - multiple 'event sources' allowed
+ - dynamically add/remove event sources
+ - options for prevYear and nextYear buttons
+ - docs have been reworked (include addition of Google Calendar docs)
+ - changed behavior of parseDate for number strings
+ (now interpets as unix timestamp, not MS times)
+ - bugfixes
+ - rightToLeft month start bug
+ - off-by-one errors with month formatting commands
+ - events from previous months sticking when clicking prev/next quickly
+ - Google Calendar API changed to work w/ multiple event sources
+ - can also provide 'className' and 'draggable' options
+ - date utilties moved from $ to $.fullCalendar
+ - more documentation in source code
+ - minified version of fullcalendar.js
+ - test suit (available from svn)
+ - top buttons now use <button> w/ an inner <span> for better css cusomization
+ - thus CSS has changed. IF UPGRADING FROM PREVIOUS VERSIONS,
+ UPGRADE YOUR FULLCALENDAR.CSS FILE!!!
+
+version 1.1 (5/10/09)
+ - Added the following options:
+ - weekStart
+ - rightToLeft
+ - titleFormat
+ - timeFormat
+ - cacheParam
+ - resize
+ - Fixed rendering bugs
+ - Opera 9.25 (events placement & window resizing)
+ - IE6 (window resizing)
+ - Optimized window resizing for ALL browsers
+ - Events on same day now sorted by start time (but first by timespan)
+ - Correct z-index when dragging
+ - Dragging contained in overflow DIV for IE6
+ - Modified fullcalendar.css
+ - for right-to-left support
+ - for variable start-of-week
+ - for IE6 resizing bug
+ - for THEAD and TBODY (in 1.0, just used TBODY, restructured in 1.1)
+ - IF UPGRADING FROM FULLCALENDAR 1.0, YOU MUST UPGRADE FULLCALENDAR.CSS
+ !!!!!!!!!!!
diff --git a/3rdparty/fullcalendar/css/fullcalendar.css b/3rdparty/fullcalendar/css/fullcalendar.css
new file mode 100644
index 00000000000..4e9e95e894f
--- /dev/null
+++ b/3rdparty/fullcalendar/css/fullcalendar.css
@@ -0,0 +1,616 @@
+/*
+ * FullCalendar v1.5.2 Stylesheet
+ *
+ * Copyright (c) 2011 Adam Shaw
+ * Dual licensed under the MIT and GPL licenses, located in
+ * MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
+ *
+ * Date: Sun Aug 21 22:06:09 2011 -0700
+ *
+ */
+
+
+.fc {
+ direction: ltr;
+ text-align: left;
+ }
+
+.fc table {
+ border-collapse: collapse;
+ border-spacing: 0;
+ }
+
+html .fc,
+.fc table {
+ font-size: 1em;
+ }
+
+.fc td,
+.fc th {
+ padding: 0;
+ vertical-align: top;
+ }
+
+
+
+/* Header
+------------------------------------------------------------------------*/
+
+.fc-header td {
+ white-space: nowrap;
+ }
+
+.fc-header-left {
+ width: 25%;
+ text-align: left;
+ }
+
+.fc-header-center {
+ text-align: center;
+ }
+
+.fc-header-right {
+ width: 25%;
+ text-align: right;
+ }
+
+.fc-header-title {
+ display: inline-block;
+ vertical-align: top;
+ }
+
+.fc-header-title h2 {
+ margin-top: 0;
+ white-space: nowrap;
+ }
+
+.fc .fc-header-space {
+ padding-left: 10px;
+ }
+
+.fc-header .fc-button {
+ margin-bottom: 1em;
+ vertical-align: top;
+ }
+
+/* buttons edges butting together */
+
+.fc-header .fc-button {
+ margin-right: -1px;
+ }
+
+.fc-header .fc-corner-right {
+ margin-right: 1px; /* back to normal */
+ }
+
+.fc-header .ui-corner-right {
+ margin-right: 0; /* back to normal */
+ }
+
+/* button layering (for border precedence) */
+
+.fc-header .fc-state-hover,
+.fc-header .ui-state-hover {
+ z-index: 2;
+ }
+
+.fc-header .fc-state-down {
+ z-index: 3;
+ }
+
+.fc-header .fc-state-active,
+.fc-header .ui-state-active {
+ z-index: 4;
+ }
+
+
+
+/* Content
+------------------------------------------------------------------------*/
+
+.fc-content {
+ clear: both;
+ }
+
+.fc-view {
+ width: 100%; /* needed for view switching (when view is absolute) */
+ overflow: hidden;
+ }
+
+
+
+/* Cell Styles
+------------------------------------------------------------------------*/
+
+.fc-widget-header, /* <th>, usually */
+.fc-widget-content { /* <td>, usually */
+ border: 1px solid #ccc;
+ }
+
+.fc-state-highlight { /* <td> today cell */ /* TODO: add .fc-today to <th> */
+ background: #ffc;
+ }
+
+.fc-cell-overlay { /* semi-transparent rectangle while dragging */
+ background: #9cf;
+ opacity: .2;
+ filter: alpha(opacity=20); /* for IE */
+ }
+
+
+
+/* Buttons
+------------------------------------------------------------------------*/
+
+.fc-button {
+ position: relative;
+ display: inline-block;
+ cursor: pointer;
+ }
+
+.fc-state-default { /* non-theme */
+ border-style: solid;
+ border-width: 1px 0;
+ }
+
+.fc-button-inner {
+ position: relative;
+ float: left;
+ overflow: hidden;
+ }
+
+.fc-state-default .fc-button-inner { /* non-theme */
+ border-style: solid;
+ border-width: 0 1px;
+ }
+
+.fc-button-content {
+ position: relative;
+ float: left;
+ height: 1.9em;
+ line-height: 1.9em;
+ padding: 0 .6em;
+ white-space: nowrap;
+ }
+
+/* icon (for jquery ui) */
+
+.fc-button-content .fc-icon-wrap {
+ position: relative;
+ float: left;
+ top: 50%;
+ }
+
+.fc-button-content .ui-icon {
+ position: relative;
+ float: left;
+ margin-top: -50%;
+ *margin-top: 0;
+ *top: -50%;
+ }
+
+/* gloss effect */
+
+.fc-state-default .fc-button-effect {
+ position: absolute;
+ top: 50%;
+ left: 0;
+ }
+
+.fc-state-default .fc-button-effect span {
+ position: absolute;
+ top: -100px;
+ left: 0;
+ width: 500px;
+ height: 100px;
+ border-width: 100px 0 0 1px;
+ border-style: solid;
+ border-color: #fff;
+ background: #444;
+ opacity: .09;
+ filter: alpha(opacity=9);
+ }
+
+/* button states (determines colors) */
+
+.fc-state-default,
+.fc-state-default .fc-button-inner {
+ border-style: solid;
+ border-color: #ccc #bbb #aaa;
+ background: #F3F3F3;
+ color: #000;
+ }
+
+.fc-state-hover,
+.fc-state-hover .fc-button-inner {
+ border-color: #999;
+ }
+
+.fc-state-down,
+.fc-state-down .fc-button-inner {
+ border-color: #555;
+ background: #777;
+ }
+
+.fc-state-active,
+.fc-state-active .fc-button-inner {
+ border-color: #555;
+ background: #777;
+ color: #fff;
+ }
+
+.fc-state-disabled,
+.fc-state-disabled .fc-button-inner {
+ color: #999;
+ border-color: #ddd;
+ }
+
+.fc-state-disabled {
+ cursor: default;
+ }
+
+.fc-state-disabled .fc-button-effect {
+ display: none;
+ }
+
+
+
+/* Global Event Styles
+------------------------------------------------------------------------*/
+
+.fc-event {
+ border-style: solid;
+ border-width: 0;
+ font-size: .85em;
+ cursor: default;
+ }
+
+a.fc-event,
+.fc-event-draggable {
+ cursor: pointer;
+ }
+
+a.fc-event {
+ text-decoration: none;
+ }
+
+.fc-rtl .fc-event {
+ text-align: right;
+ }
+
+.fc-event-skin {
+ border-color: #36c; /* default BORDER color */
+ background-color: #36c; /* default BACKGROUND color */
+ color: #fff; /* default TEXT color */
+ }
+
+.fc-event-inner {
+ position: relative;
+ width: 100%;
+ height: 100%;
+ border-style: solid;
+ border-width: 0;
+ overflow: hidden;
+ }
+
+.fc-event-time,
+.fc-event-title {
+ padding: 0 1px;
+ }
+
+.fc .ui-resizable-handle { /*** TODO: don't use ui-resizable anymore, change class ***/
+ display: block;
+ position: absolute;
+ z-index: 99999;
+ overflow: hidden; /* hacky spaces (IE6/7) */
+ font-size: 300%; /* */
+ line-height: 50%; /* */
+ }
+
+
+
+/* Horizontal Events
+------------------------------------------------------------------------*/
+
+.fc-event-hori {
+ border-width: 1px 0;
+ margin-bottom: 1px;
+ }
+
+/* resizable */
+
+.fc-event-hori .ui-resizable-e {
+ top: 0 !important; /* importants override pre jquery ui 1.7 styles */
+ right: -3px !important;
+ width: 7px !important;
+ height: 100% !important;
+ cursor: e-resize;
+ }
+
+.fc-event-hori .ui-resizable-w {
+ top: 0 !important;
+ left: -3px !important;
+ width: 7px !important;
+ height: 100% !important;
+ cursor: w-resize;
+ }
+
+.fc-event-hori .ui-resizable-handle {
+ _padding-bottom: 14px; /* IE6 had 0 height */
+ }
+
+
+
+/* Fake Rounded Corners (for buttons and events)
+------------------------------------------------------------*/
+
+.fc-corner-left {
+ margin-left: 1px;
+ }
+
+.fc-corner-left .fc-button-inner,
+.fc-corner-left .fc-event-inner {
+ margin-left: -1px;
+ }
+
+.fc-corner-right {
+ margin-right: 1px;
+ }
+
+.fc-corner-right .fc-button-inner,
+.fc-corner-right .fc-event-inner {
+ margin-right: -1px;
+ }
+
+.fc-corner-top {
+ margin-top: 1px;
+ }
+
+.fc-corner-top .fc-event-inner {
+ margin-top: -1px;
+ }
+
+.fc-corner-bottom {
+ margin-bottom: 1px;
+ }
+
+.fc-corner-bottom .fc-event-inner {
+ margin-bottom: -1px;
+ }
+
+
+
+/* Fake Rounded Corners SPECIFICALLY FOR EVENTS
+-----------------------------------------------------------------*/
+
+.fc-corner-left .fc-event-inner {
+ border-left-width: 1px;
+ }
+
+.fc-corner-right .fc-event-inner {
+ border-right-width: 1px;
+ }
+
+.fc-corner-top .fc-event-inner {
+ border-top-width: 1px;
+ }
+
+.fc-corner-bottom .fc-event-inner {
+ border-bottom-width: 1px;
+ }
+
+
+
+/* Reusable Separate-border Table
+------------------------------------------------------------*/
+
+table.fc-border-separate {
+ border-collapse: separate;
+ }
+
+.fc-border-separate th,
+.fc-border-separate td {
+ border-width: 1px 0 0 1px;
+ }
+
+.fc-border-separate th.fc-last,
+.fc-border-separate td.fc-last {
+ border-right-width: 1px;
+ }
+
+.fc-border-separate tr.fc-last th,
+.fc-border-separate tr.fc-last td {
+ border-bottom-width: 1px;
+ }
+
+.fc-border-separate tbody tr.fc-first td,
+.fc-border-separate tbody tr.fc-first th {
+ border-top-width: 0;
+ }
+
+
+
+/* Month View, Basic Week View, Basic Day View
+------------------------------------------------------------------------*/
+
+.fc-grid th {
+ text-align: center;
+ }
+
+.fc-grid .fc-day-number {
+ float: right;
+ padding: 0 2px;
+ }
+
+.fc-grid .fc-other-month .fc-day-number {
+ opacity: 0.3;
+ filter: alpha(opacity=30); /* for IE */
+ /* opacity with small font can sometimes look too faded
+ might want to set the 'color' property instead
+ making day-numbers bold also fixes the problem */
+ }
+
+.fc-grid .fc-day-content {
+ clear: both;
+ padding: 2px 2px 1px; /* distance between events and day edges */
+ }
+
+/* event styles */
+
+.fc-grid .fc-event-time {
+ font-weight: bold;
+ }
+
+/* right-to-left */
+
+.fc-rtl .fc-grid .fc-day-number {
+ float: left;
+ }
+
+.fc-rtl .fc-grid .fc-event-time {
+ float: right;
+ }
+
+
+
+/* Agenda Week View, Agenda Day View
+------------------------------------------------------------------------*/
+
+.fc-agenda table {
+ border-collapse: separate;
+ }
+
+.fc-agenda-days th {
+ text-align: center;
+ }
+
+.fc-agenda .fc-agenda-axis {
+ width: 50px;
+ padding: 0 4px;
+ vertical-align: middle;
+ text-align: right;
+ white-space: nowrap;
+ font-weight: normal;
+ }
+
+.fc-agenda .fc-day-content {
+ padding: 2px 2px 1px;
+ }
+
+/* make axis border take precedence */
+
+.fc-agenda-days .fc-agenda-axis {
+ border-right-width: 1px;
+ }
+
+.fc-agenda-days .fc-col0 {
+ border-left-width: 0;
+ }
+
+/* all-day area */
+
+.fc-agenda-allday th {
+ border-width: 0 1px;
+ }
+
+.fc-agenda-allday .fc-day-content {
+ min-height: 34px; /* TODO: doesnt work well in quirksmode */
+ _height: 34px;
+ }
+
+/* divider (between all-day and slots) */
+
+.fc-agenda-divider-inner {
+ height: 2px;
+ overflow: hidden;
+ }
+
+.fc-widget-header .fc-agenda-divider-inner {
+ background: #eee;
+ }
+
+/* slot rows */
+
+.fc-agenda-slots th {
+ border-width: 1px 1px 0;
+ }
+
+.fc-agenda-slots td {
+ border-width: 1px 0 0;
+ background: none;
+ }
+
+.fc-agenda-slots td div {
+ height: 20px;
+ }
+
+.fc-agenda-slots tr.fc-slot0 th,
+.fc-agenda-slots tr.fc-slot0 td {
+ border-top-width: 0;
+ }
+
+.fc-agenda-slots tr.fc-minor th,
+.fc-agenda-slots tr.fc-minor td {
+ border-top-style: dotted;
+ }
+
+.fc-agenda-slots tr.fc-minor th.ui-widget-header {
+ *border-top-style: solid; /* doesn't work with background in IE6/7 */
+ }
+
+
+
+/* Vertical Events
+------------------------------------------------------------------------*/
+
+.fc-event-vert {
+ border-width: 0 1px;
+ }
+
+.fc-event-vert .fc-event-head,
+.fc-event-vert .fc-event-content {
+ position: relative;
+ z-index: 2;
+ width: 100%;
+ overflow: hidden;
+ }
+
+.fc-event-vert .fc-event-time {
+ white-space: nowrap;
+ font-size: 10px;
+ }
+
+.fc-event-vert .fc-event-bg { /* makes the event lighter w/ a semi-transparent overlay */
+ position: absolute;
+ z-index: 1;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ background: #fff;
+ opacity: .3;
+ filter: alpha(opacity=30);
+ }
+
+.fc .ui-draggable-dragging .fc-event-bg, /* TODO: something nicer like .fc-opacity */
+.fc-select-helper .fc-event-bg {
+ display: none\9; /* for IE6/7/8. nested opacity filters while dragging don't work */
+ }
+
+/* resizable */
+
+.fc-event-vert .ui-resizable-s {
+ bottom: 0 !important; /* importants override pre jquery ui 1.7 styles */
+ width: 100% !important;
+ height: 8px !important;
+ overflow: hidden !important;
+ line-height: 8px !important;
+ font-size: 11px !important;
+ font-family: monospace;
+ text-align: center;
+ cursor: s-resize;
+ }
+
+.fc-agenda .ui-resizable-resizing { /* TODO: better selector */
+ _overflow: hidden;
+ }
diff --git a/3rdparty/fullcalendar/css/fullcalendar.print.css b/3rdparty/fullcalendar/css/fullcalendar.print.css
new file mode 100644
index 00000000000..18c7c9b10af
--- /dev/null
+++ b/3rdparty/fullcalendar/css/fullcalendar.print.css
@@ -0,0 +1,59 @@
+/*
+ * FullCalendar v1.5.2 Print Stylesheet
+ *
+ * Include this stylesheet on your page to get a more printer-friendly calendar.
+ * When including this stylesheet, use the media='print' attribute of the <link> tag.
+ * Make sure to include this stylesheet IN ADDITION to the regular fullcalendar.css.
+ *
+ * Copyright (c) 2011 Adam Shaw
+ * Dual licensed under the MIT and GPL licenses, located in
+ * MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
+ *
+ * Date: Sun Aug 21 22:06:09 2011 -0700
+ *
+ */
+
+
+ /* Events
+-----------------------------------------------------*/
+
+.fc-event-skin {
+ background: none !important;
+ color: #000 !important;
+ }
+
+/* horizontal events */
+
+.fc-event-hori {
+ border-width: 0 0 1px 0 !important;
+ border-bottom-style: dotted !important;
+ border-bottom-color: #000 !important;
+ padding: 1px 0 0 0 !important;
+ }
+
+.fc-event-hori .fc-event-inner {
+ border-width: 0 !important;
+ padding: 0 1px !important;
+ }
+
+/* vertical events */
+
+.fc-event-vert {
+ border-width: 0 0 0 1px !important;
+ border-left-style: dotted !important;
+ border-left-color: #000 !important;
+ padding: 0 1px 0 0 !important;
+ }
+
+.fc-event-vert .fc-event-inner {
+ border-width: 0 !important;
+ padding: 1px 0 !important;
+ }
+
+.fc-event-bg {
+ display: none !important;
+ }
+
+.fc-event .ui-resizable-handle {
+ display: none !important;
+ }
diff --git a/3rdparty/fullcalendar/js/fullcalendar.js b/3rdparty/fullcalendar/js/fullcalendar.js
new file mode 100644
index 00000000000..fcdafbfca49
--- /dev/null
+++ b/3rdparty/fullcalendar/js/fullcalendar.js
@@ -0,0 +1,5210 @@
+/**
+ * @preserve
+ * FullCalendar v1.5.2
+ * http://arshaw.com/fullcalendar/
+ *
+ * Use fullcalendar.css for basic styling.
+ * For event drag & drop, requires jQuery UI draggable.
+ * For event resizing, requires jQuery UI resizable.
+ *
+ * Copyright (c) 2011 Adam Shaw
+ * Dual licensed under the MIT and GPL licenses, located in
+ * MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
+ *
+ * Date: Sun Aug 21 22:06:09 2011 -0700
+ *
+ */
+
+(function($, undefined) {
+
+
+var defaults = {
+
+ // display
+ defaultView: 'month',
+ aspectRatio: 1.35,
+ header: {
+ left: 'title',
+ center: '',
+ right: 'today prev,next'
+ },
+ weekends: true,
+
+ // editing
+ //editable: false,
+ //disableDragging: false,
+ //disableResizing: false,
+
+ allDayDefault: true,
+ ignoreTimezone: true,
+
+ // event ajax
+ lazyFetching: true,
+ startParam: 'start',
+ endParam: 'end',
+
+ // time formats
+ titleFormat: {
+ month: 'MMMM yyyy',
+ week: "MMM d[ yyyy]{ '&#8212;'[ MMM] d yyyy}",
+ day: 'dddd, MMM d, yyyy'
+ },
+ columnFormat: {
+ month: 'ddd',
+ week: 'ddd M/d',
+ day: 'dddd M/d'
+ },
+ timeFormat: { // for event elements
+ '': 'h(:mm)t' // default
+ },
+
+ // locale
+ isRTL: false,
+ firstDay: 0,
+ monthNames: ['January','February','March','April','May','June','July','August','September','October','November','December'],
+ monthNamesShort: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
+ dayNames: ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
+ dayNamesShort: ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],
+ buttonText: {
+ prev: '&nbsp;&#9668;&nbsp;',
+ next: '&nbsp;&#9658;&nbsp;',
+ prevYear: '&nbsp;&lt;&lt;&nbsp;',
+ nextYear: '&nbsp;&gt;&gt;&nbsp;',
+ today: 'today',
+ month: 'month',
+ week: 'week',
+ day: 'day'
+ },
+
+ // jquery-ui theming
+ theme: false,
+ buttonIcons: {
+ prev: 'circle-triangle-w',
+ next: 'circle-triangle-e'
+ },
+
+ //selectable: false,
+ unselectAuto: true,
+
+ dropAccept: '*'
+
+};
+
+// right-to-left defaults
+var rtlDefaults = {
+ header: {
+ left: 'next,prev today',
+ center: '',
+ right: 'title'
+ },
+ buttonText: {
+ prev: '&nbsp;&#9658;&nbsp;',
+ next: '&nbsp;&#9668;&nbsp;',
+ prevYear: '&nbsp;&gt;&gt;&nbsp;',
+ nextYear: '&nbsp;&lt;&lt;&nbsp;'
+ },
+ buttonIcons: {
+ prev: 'circle-triangle-e',
+ next: 'circle-triangle-w'
+ }
+};
+
+
+
+var fc = $.fullCalendar = { version: "1.5.2" };
+var fcViews = fc.views = {};
+
+
+$.fn.fullCalendar = function(options) {
+
+
+ // method calling
+ if (typeof options == 'string') {
+ var args = Array.prototype.slice.call(arguments, 1);
+ var res;
+ this.each(function() {
+ var calendar = $.data(this, 'fullCalendar');
+ if (calendar && $.isFunction(calendar[options])) {
+ var r = calendar[options].apply(calendar, args);
+ if (res === undefined) {
+ res = r;
+ }
+ if (options == 'destroy') {
+ $.removeData(this, 'fullCalendar');
+ }
+ }
+ });
+ if (res !== undefined) {
+ return res;
+ }
+ return this;
+ }
+
+
+ // would like to have this logic in EventManager, but needs to happen before options are recursively extended
+ var eventSources = options.eventSources || [];
+ delete options.eventSources;
+ if (options.events) {
+ eventSources.push(options.events);
+ delete options.events;
+ }
+
+
+ options = $.extend(true, {},
+ defaults,
+ (options.isRTL || options.isRTL===undefined && defaults.isRTL) ? rtlDefaults : {},
+ options
+ );
+
+
+ this.each(function(i, _element) {
+ var element = $(_element);
+ var calendar = new Calendar(element, options, eventSources);
+ element.data('fullCalendar', calendar); // TODO: look into memory leak implications
+ calendar.render();
+ });
+
+
+ return this;
+
+};
+
+
+// function for adding/overriding defaults
+function setDefaults(d) {
+ $.extend(true, defaults, d);
+}
+
+
+
+
+function Calendar(element, options, eventSources) {
+ var t = this;
+
+
+ // exports
+ t.options = options;
+ t.render = render;
+ t.destroy = destroy;
+ t.refetchEvents = refetchEvents;
+ t.reportEvents = reportEvents;
+ t.reportEventChange = reportEventChange;
+ t.rerenderEvents = rerenderEvents;
+ t.changeView = changeView;
+ t.select = select;
+ t.unselect = unselect;
+ t.prev = prev;
+ t.next = next;
+ t.prevYear = prevYear;
+ t.nextYear = nextYear;
+ t.today = today;
+ t.gotoDate = gotoDate;
+ t.incrementDate = incrementDate;
+ t.formatDate = function(format, date) { return formatDate(format, date, options) };
+ t.formatDates = function(format, date1, date2) { return formatDates(format, date1, date2, options) };
+ t.getDate = getDate;
+ t.getView = getView;
+ t.option = option;
+ t.trigger = trigger;
+
+
+ // imports
+ EventManager.call(t, options, eventSources);
+ var isFetchNeeded = t.isFetchNeeded;
+ var fetchEvents = t.fetchEvents;
+
+
+ // locals
+ var _element = element[0];
+ var header;
+ var headerElement;
+ var content;
+ var tm; // for making theme classes
+ var currentView;
+ var viewInstances = {};
+ var elementOuterWidth;
+ var suggestedViewHeight;
+ var absoluteViewElement;
+ var resizeUID = 0;
+ var ignoreWindowResize = 0;
+ var date = new Date();
+ var events = [];
+ var _dragElement;
+
+
+
+ /* Main Rendering
+ -----------------------------------------------------------------------------*/
+
+
+ setYMD(date, options.year, options.month, options.date);
+
+
+ function render(inc) {
+ if (!content) {
+ initialRender();
+ }else{
+ calcSize();
+ markSizesDirty();
+ markEventsDirty();
+ renderView(inc);
+ }
+ }
+
+
+ function initialRender() {
+ tm = options.theme ? 'ui' : 'fc';
+ element.addClass('fc');
+ if (options.isRTL) {
+ element.addClass('fc-rtl');
+ }
+ if (options.theme) {
+ element.addClass('ui-widget');
+ }
+ content = $("<div class='fc-content' style='position:relative'/>")
+ .prependTo(element);
+ header = new Header(t, options);
+ headerElement = header.render();
+ if (headerElement) {
+ element.prepend(headerElement);
+ }
+ changeView(options.defaultView);
+ $(window).resize(windowResize);
+ // needed for IE in a 0x0 iframe, b/c when it is resized, never triggers a windowResize
+ if (!bodyVisible()) {
+ lateRender();
+ }
+ }
+
+
+ // called when we know the calendar couldn't be rendered when it was initialized,
+ // but we think it's ready now
+ function lateRender() {
+ setTimeout(function() { // IE7 needs this so dimensions are calculated correctly
+ if (!currentView.start && bodyVisible()) { // !currentView.start makes sure this never happens more than once
+ renderView();
+ }
+ },0);
+ }
+
+
+ function destroy() {
+ $(window).unbind('resize', windowResize);
+ header.destroy();
+ content.remove();
+ element.removeClass('fc fc-rtl ui-widget');
+ }
+
+
+
+ function elementVisible() {
+ return _element.offsetWidth !== 0;
+ }
+
+
+ function bodyVisible() {
+ return $('body')[0].offsetWidth !== 0;
+ }
+
+
+
+ /* View Rendering
+ -----------------------------------------------------------------------------*/
+
+ // TODO: improve view switching (still weird transition in IE, and FF has whiteout problem)
+
+ function changeView(newViewName) {
+ if (!currentView || newViewName != currentView.name) {
+ ignoreWindowResize++; // because setMinHeight might change the height before render (and subsequently setSize) is reached
+
+ unselect();
+
+ var oldView = currentView;
+ var newViewElement;
+
+ if (oldView) {
+ (oldView.beforeHide || noop)(); // called before changing min-height. if called after, scroll state is reset (in Opera)
+ setMinHeight(content, content.height());
+ oldView.element.hide();
+ }else{
+ setMinHeight(content, 1); // needs to be 1 (not 0) for IE7, or else view dimensions miscalculated
+ }
+ content.css('overflow', 'hidden');
+
+ currentView = viewInstances[newViewName];
+ if (currentView) {
+ currentView.element.show();
+ }else{
+ currentView = viewInstances[newViewName] = new fcViews[newViewName](
+ newViewElement = absoluteViewElement =
+ $("<div class='fc-view fc-view-" + newViewName + "' style='position:absolute'/>")
+ .appendTo(content),
+ t // the calendar object
+ );
+ }
+
+ if (oldView) {
+ header.deactivateButton(oldView.name);
+ }
+ header.activateButton(newViewName);
+
+ renderView(); // after height has been set, will make absoluteViewElement's position=relative, then set to null
+
+ content.css('overflow', '');
+ if (oldView) {
+ setMinHeight(content, 1);
+ }
+
+ if (!newViewElement) {
+ (currentView.afterShow || noop)(); // called after setting min-height/overflow, so in final scroll state (for Opera)
+ }
+
+ ignoreWindowResize--;
+ }
+ }
+
+
+
+ function renderView(inc) {
+ if (elementVisible()) {
+ ignoreWindowResize++; // because renderEvents might temporarily change the height before setSize is reached
+
+ unselect();
+
+ if (suggestedViewHeight === undefined) {
+ calcSize();
+ }
+
+ var forceEventRender = false;
+ if (!currentView.start || inc || date < currentView.start || date >= currentView.end) {
+ // view must render an entire new date range (and refetch/render events)
+ currentView.render(date, inc || 0); // responsible for clearing events
+ setSize(true);
+ forceEventRender = true;
+ }
+ else if (currentView.sizeDirty) {
+ // view must resize (and rerender events)
+ currentView.clearEvents();
+ setSize();
+ forceEventRender = true;
+ }
+ else if (currentView.eventsDirty) {
+ currentView.clearEvents();
+ forceEventRender = true;
+ }
+ currentView.sizeDirty = false;
+ currentView.eventsDirty = false;
+ updateEvents(forceEventRender);
+
+ elementOuterWidth = element.outerWidth();
+
+ header.updateTitle(currentView.title);
+ var today = new Date();
+ if (today >= currentView.start && today < currentView.end) {
+ header.disableButton('today');
+ }else{
+ header.enableButton('today');
+ }
+
+ ignoreWindowResize--;
+ currentView.trigger('viewDisplay', _element);
+ }
+ }
+
+
+
+ /* Resizing
+ -----------------------------------------------------------------------------*/
+
+
+ function updateSize() {
+ markSizesDirty();
+ if (elementVisible()) {
+ calcSize();
+ setSize();
+ unselect();
+ currentView.clearEvents();
+ currentView.renderEvents(events);
+ currentView.sizeDirty = false;
+ }
+ }
+
+
+ function markSizesDirty() {
+ $.each(viewInstances, function(i, inst) {
+ inst.sizeDirty = true;
+ });
+ }
+
+
+ function calcSize() {
+ if (options.contentHeight) {
+ suggestedViewHeight = options.contentHeight;
+ }
+ else if (options.height) {
+ suggestedViewHeight = options.height - (headerElement ? headerElement.height() : 0) - vsides(content);
+ }
+ else {
+ suggestedViewHeight = Math.round(content.width() / Math.max(options.aspectRatio, .5));
+ }
+ }
+
+
+ function setSize(dateChanged) { // todo: dateChanged?
+ ignoreWindowResize++;
+ currentView.setHeight(suggestedViewHeight, dateChanged);
+ if (absoluteViewElement) {
+ absoluteViewElement.css('position', 'relative');
+ absoluteViewElement = null;
+ }
+ currentView.setWidth(content.width(), dateChanged);
+ ignoreWindowResize--;
+ }
+
+
+ function windowResize() {
+ if (!ignoreWindowResize) {
+ if (currentView.start) { // view has already been rendered
+ var uid = ++resizeUID;
+ setTimeout(function() { // add a delay
+ if (uid == resizeUID && !ignoreWindowResize && elementVisible()) {
+ if (elementOuterWidth != (elementOuterWidth = element.outerWidth())) {
+ ignoreWindowResize++; // in case the windowResize callback changes the height
+ updateSize();
+ currentView.trigger('windowResize', _element);
+ ignoreWindowResize--;
+ }
+ }
+ }, 200);
+ }else{
+ // calendar must have been initialized in a 0x0 iframe that has just been resized
+ lateRender();
+ }
+ }
+ }
+
+
+
+ /* Event Fetching/Rendering
+ -----------------------------------------------------------------------------*/
+
+
+ // fetches events if necessary, rerenders events if necessary (or if forced)
+ function updateEvents(forceRender) {
+ if (!options.lazyFetching || isFetchNeeded(currentView.visStart, currentView.visEnd)) {
+ refetchEvents();
+ }
+ else if (forceRender) {
+ rerenderEvents();
+ }
+ }
+
+
+ function refetchEvents() {
+ fetchEvents(currentView.visStart, currentView.visEnd); // will call reportEvents
+ }
+
+
+ // called when event data arrives
+ function reportEvents(_events) {
+ events = _events;
+ rerenderEvents();
+ }
+
+
+ // called when a single event's data has been changed
+ function reportEventChange(eventID) {
+ rerenderEvents(eventID);
+ }
+
+
+ // attempts to rerenderEvents
+ function rerenderEvents(modifiedEventID) {
+ markEventsDirty();
+ if (elementVisible()) {
+ currentView.clearEvents();
+ currentView.renderEvents(events, modifiedEventID);
+ currentView.eventsDirty = false;
+ }
+ }
+
+
+ function markEventsDirty() {
+ $.each(viewInstances, function(i, inst) {
+ inst.eventsDirty = true;
+ });
+ }
+
+
+
+ /* Selection
+ -----------------------------------------------------------------------------*/
+
+
+ function select(start, end, allDay) {
+ currentView.select(start, end, allDay===undefined ? true : allDay);
+ }
+
+
+ function unselect() { // safe to be called before renderView
+ if (currentView) {
+ currentView.unselect();
+ }
+ }
+
+
+
+ /* Date
+ -----------------------------------------------------------------------------*/
+
+
+ function prev() {
+ renderView(-1);
+ }
+
+
+ function next() {
+ renderView(1);
+ }
+
+
+ function prevYear() {
+ addYears(date, -1);
+ renderView();
+ }
+
+
+ function nextYear() {
+ addYears(date, 1);
+ renderView();
+ }
+
+
+ function today() {
+ date = new Date();
+ renderView();
+ }
+
+
+ function gotoDate(year, month, dateOfMonth) {
+ if (year instanceof Date) {
+ date = cloneDate(year); // provided 1 argument, a Date
+ }else{
+ setYMD(date, year, month, dateOfMonth);
+ }
+ renderView();
+ }
+
+
+ function incrementDate(years, months, days) {
+ if (years !== undefined) {
+ addYears(date, years);
+ }
+ if (months !== undefined) {
+ addMonths(date, months);
+ }
+ if (days !== undefined) {
+ addDays(date, days);
+ }
+ renderView();
+ }
+
+
+ function getDate() {
+ return cloneDate(date);
+ }
+
+
+
+ /* Misc
+ -----------------------------------------------------------------------------*/
+
+
+ function getView() {
+ return currentView;
+ }
+
+
+ function option(name, value) {
+ if (value === undefined) {
+ return options[name];
+ }
+ if (name == 'height' || name == 'contentHeight' || name == 'aspectRatio') {
+ options[name] = value;
+ updateSize();
+ }
+ }
+
+
+ function trigger(name, thisObj) {
+ if (options[name]) {
+ return options[name].apply(
+ thisObj || _element,
+ Array.prototype.slice.call(arguments, 2)
+ );
+ }
+ }
+
+
+
+ /* External Dragging
+ ------------------------------------------------------------------------*/
+
+ if (options.droppable) {
+ $(document)
+ .bind('dragstart', function(ev, ui) {
+ var _e = ev.target;
+ var e = $(_e);
+ if (!e.parents('.fc').length) { // not already inside a calendar
+ var accept = options.dropAccept;
+ if ($.isFunction(accept) ? accept.call(_e, e) : e.is(accept)) {
+ _dragElement = _e;
+ currentView.dragStart(_dragElement, ev, ui);
+ }
+ }
+ })
+ .bind('dragstop', function(ev, ui) {
+ if (_dragElement) {
+ currentView.dragStop(_dragElement, ev, ui);
+ _dragElement = null;
+ }
+ });
+ }
+
+
+}
+
+function Header(calendar, options) {
+ var t = this;
+
+
+ // exports
+ t.render = render;
+ t.destroy = destroy;
+ t.updateTitle = updateTitle;
+ t.activateButton = activateButton;
+ t.deactivateButton = deactivateButton;
+ t.disableButton = disableButton;
+ t.enableButton = enableButton;
+
+
+ // locals
+ var element = $([]);
+ var tm;
+
+
+
+ function render() {
+ tm = options.theme ? 'ui' : 'fc';
+ var sections = options.header;
+ if (sections) {
+ element = $("<table class='fc-header' style='width:100%'/>")
+ .append(
+ $("<tr/>")
+ .append(renderSection('left'))
+ .append(renderSection('center'))
+ .append(renderSection('right'))
+ );
+ return element;
+ }
+ }
+
+
+ function destroy() {
+ element.remove();
+ }
+
+
+ function renderSection(position) {
+ var e = $("<td class='fc-header-" + position + "'/>");
+ var buttonStr = options.header[position];
+ if (buttonStr) {
+ $.each(buttonStr.split(' '), function(i) {
+ if (i > 0) {
+ e.append("<span class='fc-header-space'/>");
+ }
+ var prevButton;
+ $.each(this.split(','), function(j, buttonName) {
+ if (buttonName == 'title') {
+ e.append("<span class='fc-header-title'><h2>&nbsp;</h2></span>");
+ if (prevButton) {
+ prevButton.addClass(tm + '-corner-right');
+ }
+ prevButton = null;
+ }else{
+ var buttonClick;
+ if (calendar[buttonName]) {
+ buttonClick = calendar[buttonName]; // calendar method
+ }
+ else if (fcViews[buttonName]) {
+ buttonClick = function() {
+ button.removeClass(tm + '-state-hover'); // forget why
+ calendar.changeView(buttonName);
+ };
+ }
+ if (buttonClick) {
+ var icon = options.theme ? smartProperty(options.buttonIcons, buttonName) : null; // why are we using smartProperty here?
+ var text = smartProperty(options.buttonText, buttonName); // why are we using smartProperty here?
+ var button = $(
+ "<span class='fc-button fc-button-" + buttonName + " " + tm + "-state-default'>" +
+ "<span class='fc-button-inner'>" +
+ "<span class='fc-button-content'>" +
+ (icon ?
+ "<span class='fc-icon-wrap'>" +
+ "<span class='ui-icon ui-icon-" + icon + "'/>" +
+ "</span>" :
+ text
+ ) +
+ "</span>" +
+ "<span class='fc-button-effect'><span></span></span>" +
+ "</span>" +
+ "</span>"
+ );
+ if (button) {
+ button
+ .click(function() {
+ if (!button.hasClass(tm + '-state-disabled')) {
+ buttonClick();
+ }
+ })
+ .mousedown(function() {
+ button
+ .not('.' + tm + '-state-active')
+ .not('.' + tm + '-state-disabled')
+ .addClass(tm + '-state-down');
+ })
+ .mouseup(function() {
+ button.removeClass(tm + '-state-down');
+ })
+ .hover(
+ function() {
+ button
+ .not('.' + tm + '-state-active')
+ .not('.' + tm + '-state-disabled')
+ .addClass(tm + '-state-hover');
+ },
+ function() {
+ button
+ .removeClass(tm + '-state-hover')
+ .removeClass(tm + '-state-down');
+ }
+ )
+ .appendTo(e);
+ if (!prevButton) {
+ button.addClass(tm + '-corner-left');
+ }
+ prevButton = button;
+ }
+ }
+ }
+ });
+ if (prevButton) {
+ prevButton.addClass(tm + '-corner-right');
+ }
+ });
+ }
+ return e;
+ }
+
+
+ function updateTitle(html) {
+ element.find('h2')
+ .html(html);
+ }
+
+
+ function activateButton(buttonName) {
+ element.find('span.fc-button-' + buttonName)
+ .addClass(tm + '-state-active');
+ }
+
+
+ function deactivateButton(buttonName) {
+ element.find('span.fc-button-' + buttonName)
+ .removeClass(tm + '-state-active');
+ }
+
+
+ function disableButton(buttonName) {
+ element.find('span.fc-button-' + buttonName)
+ .addClass(tm + '-state-disabled');
+ }
+
+
+ function enableButton(buttonName) {
+ element.find('span.fc-button-' + buttonName)
+ .removeClass(tm + '-state-disabled');
+ }
+
+
+}
+
+fc.sourceNormalizers = [];
+fc.sourceFetchers = [];
+
+var ajaxDefaults = {
+ dataType: 'json',
+ cache: false
+};
+
+var eventGUID = 1;
+
+
+function EventManager(options, _sources) {
+ var t = this;
+
+
+ // exports
+ t.isFetchNeeded = isFetchNeeded;
+ t.fetchEvents = fetchEvents;
+ t.addEventSource = addEventSource;
+ t.removeEventSource = removeEventSource;
+ t.updateEvent = updateEvent;
+ t.renderEvent = renderEvent;
+ t.removeEvents = removeEvents;
+ t.clientEvents = clientEvents;
+ t.normalizeEvent = normalizeEvent;
+
+
+ // imports
+ var trigger = t.trigger;
+ var getView = t.getView;
+ var reportEvents = t.reportEvents;
+
+
+ // locals
+ var stickySource = { events: [] };
+ var sources = [ stickySource ];
+ var rangeStart, rangeEnd;
+ var currentFetchID = 0;
+ var pendingSourceCnt = 0;
+ var loadingLevel = 0;
+ var cache = [];
+
+
+ for (var i=0; i<_sources.length; i++) {
+ _addEventSource(_sources[i]);
+ }
+
+
+
+ /* Fetching
+ -----------------------------------------------------------------------------*/
+
+
+ function isFetchNeeded(start, end) {
+ return !rangeStart || start < rangeStart || end > rangeEnd;
+ }
+
+
+ function fetchEvents(start, end) {
+ rangeStart = start;
+ rangeEnd = end;
+ cache = [];
+ var fetchID = ++currentFetchID;
+ var len = sources.length;
+ pendingSourceCnt = len;
+ for (var i=0; i<len; i++) {
+ fetchEventSource(sources[i], fetchID);
+ }
+ }
+
+
+ function fetchEventSource(source, fetchID) {
+ _fetchEventSource(source, function(events) {
+ if (fetchID == currentFetchID) {
+ if (events) {
+ for (var i=0; i<events.length; i++) {
+ events[i].source = source;
+ normalizeEvent(events[i]);
+ }
+ cache = cache.concat(events);
+ }
+ pendingSourceCnt--;
+ if (!pendingSourceCnt) {
+ reportEvents(cache);
+ }
+ }
+ });
+ }
+
+
+ function _fetchEventSource(source, callback) {
+ var i;
+ var fetchers = fc.sourceFetchers;
+ var res;
+ for (i=0; i<fetchers.length; i++) {
+ res = fetchers[i](source, rangeStart, rangeEnd, callback);
+ if (res === true) {
+ // the fetcher is in charge. made its own async request
+ return;
+ }
+ else if (typeof res == 'object') {
+ // the fetcher returned a new source. process it
+ _fetchEventSource(res, callback);
+ return;
+ }
+ }
+ var events = source.events;
+ if (events) {
+ if ($.isFunction(events)) {
+ pushLoading();
+ events(cloneDate(rangeStart), cloneDate(rangeEnd), function(events) {
+ callback(events);
+ popLoading();
+ });
+ }
+ else if ($.isArray(events)) {
+ callback(events);
+ }
+ else {
+ callback();
+ }
+ }else{
+ var url = source.url;
+ if (url) {
+ var success = source.success;
+ var error = source.error;
+ var complete = source.complete;
+ var data = $.extend({}, source.data || {});
+ var startParam = firstDefined(source.startParam, options.startParam);
+ var endParam = firstDefined(source.endParam, options.endParam);
+ if (startParam) {
+ data[startParam] = Math.round(+rangeStart / 1000);
+ }
+ if (endParam) {
+ data[endParam] = Math.round(+rangeEnd / 1000);
+ }
+ pushLoading();
+ $.ajax($.extend({}, ajaxDefaults, source, {
+ data: data,
+ success: function(events) {
+ events = events || [];
+ var res = applyAll(success, this, arguments);
+ if ($.isArray(res)) {
+ events = res;
+ }
+ callback(events);
+ },
+ error: function() {
+ applyAll(error, this, arguments);
+ callback();
+ },
+ complete: function() {
+ applyAll(complete, this, arguments);
+ popLoading();
+ }
+ }));
+ }else{
+ callback();
+ }
+ }
+ }
+
+
+
+ /* Sources
+ -----------------------------------------------------------------------------*/
+
+
+ function addEventSource(source) {
+ source = _addEventSource(source);
+ if (source) {
+ pendingSourceCnt++;
+ fetchEventSource(source, currentFetchID); // will eventually call reportEvents
+ }
+ }
+
+
+ function _addEventSource(source) {
+ if ($.isFunction(source) || $.isArray(source)) {
+ source = { events: source };
+ }
+ else if (typeof source == 'string') {
+ source = { url: source };
+ }
+ if (typeof source == 'object') {
+ normalizeSource(source);
+ sources.push(source);
+ return source;
+ }
+ }
+
+
+ function removeEventSource(source) {
+ sources = $.grep(sources, function(src) {
+ return !isSourcesEqual(src, source);
+ });
+ // remove all client events from that source
+ cache = $.grep(cache, function(e) {
+ return !isSourcesEqual(e.source, source);
+ });
+ reportEvents(cache);
+ }
+
+
+
+ /* Manipulation
+ -----------------------------------------------------------------------------*/
+
+
+ function updateEvent(event) { // update an existing event
+ var i, len = cache.length, e,
+ defaultEventEnd = getView().defaultEventEnd, // getView???
+ startDelta = event.start - event._start,
+ endDelta = event.end ?
+ (event.end - (event._end || defaultEventEnd(event))) // event._end would be null if event.end
+ : 0; // was null and event was just resized
+ for (i=0; i<len; i++) {
+ e = cache[i];
+ if (e._id == event._id && e != event) {
+ e.start = new Date(+e.start + startDelta);
+ if (event.end) {
+ if (e.end) {
+ e.end = new Date(+e.end + endDelta);
+ }else{
+ e.end = new Date(+defaultEventEnd(e) + endDelta);
+ }
+ }else{
+ e.end = null;
+ }
+ e.title = event.title;
+ e.url = event.url;
+ e.allDay = event.allDay;
+ e.className = event.className;
+ e.editable = event.editable;
+ e.color = event.color;
+ e.backgroudColor = event.backgroudColor;
+ e.borderColor = event.borderColor;
+ e.textColor = event.textColor;
+ normalizeEvent(e);
+ }
+ }
+ normalizeEvent(event);
+ reportEvents(cache);
+ }
+
+
+ function renderEvent(event, stick) {
+ normalizeEvent(event);
+ if (!event.source) {
+ if (stick) {
+ stickySource.events.push(event);
+ event.source = stickySource;
+ }
+ cache.push(event);
+ }
+ reportEvents(cache);
+ }
+
+
+ function removeEvents(filter) {
+ if (!filter) { // remove all
+ cache = [];
+ // clear all array sources
+ for (var i=0; i<sources.length; i++) {
+ if ($.isArray(sources[i].events)) {
+ sources[i].events = [];
+ }
+ }
+ }else{
+ if (!$.isFunction(filter)) { // an event ID
+ var id = filter + '';
+ filter = function(e) {
+ return e._id == id;
+ };
+ }
+ cache = $.grep(cache, filter, true);
+ // remove events from array sources
+ for (var i=0; i<sources.length; i++) {
+ if ($.isArray(sources[i].events)) {
+ sources[i].events = $.grep(sources[i].events, filter, true);
+ }
+ }
+ }
+ reportEvents(cache);
+ }
+
+
+ function clientEvents(filter) {
+ if ($.isFunction(filter)) {
+ return $.grep(cache, filter);
+ }
+ else if (filter) { // an event ID
+ filter += '';
+ return $.grep(cache, function(e) {
+ return e._id == filter;
+ });
+ }
+ return cache; // else, return all
+ }
+
+
+
+ /* Loading State
+ -----------------------------------------------------------------------------*/
+
+
+ function pushLoading() {
+ if (!loadingLevel++) {
+ trigger('loading', null, true);
+ }
+ }
+
+
+ function popLoading() {
+ if (!--loadingLevel) {
+ trigger('loading', null, false);
+ }
+ }
+
+
+
+ /* Event Normalization
+ -----------------------------------------------------------------------------*/
+
+
+ function normalizeEvent(event) {
+ var source = event.source || {};
+ var ignoreTimezone = firstDefined(source.ignoreTimezone, options.ignoreTimezone);
+ event._id = event._id || (event.id === undefined ? '_fc' + eventGUID++ : event.id + '');
+ if (event.date) {
+ if (!event.start) {
+ event.start = event.date;
+ }
+ delete event.date;
+ }
+ event._start = cloneDate(event.start = parseDate(event.start, ignoreTimezone));
+ event.end = parseDate(event.end, ignoreTimezone);
+ if (event.end && event.end <= event.start) {
+ event.end = null;
+ }
+ event._end = event.end ? cloneDate(event.end) : null;
+ if (event.allDay === undefined) {
+ event.allDay = firstDefined(source.allDayDefault, options.allDayDefault);
+ }
+ if (event.className) {
+ if (typeof event.className == 'string') {
+ event.className = event.className.split(/\s+/);
+ }
+ }else{
+ event.className = [];
+ }
+ // TODO: if there is no start date, return false to indicate an invalid event
+ }
+
+
+
+ /* Utils
+ ------------------------------------------------------------------------------*/
+
+
+ function normalizeSource(source) {
+ if (source.className) {
+ // TODO: repeat code, same code for event classNames
+ if (typeof source.className == 'string') {
+ source.className = source.className.split(/\s+/);
+ }
+ }else{
+ source.className = [];
+ }
+ var normalizers = fc.sourceNormalizers;
+ for (var i=0; i<normalizers.length; i++) {
+ normalizers[i](source);
+ }
+ }
+
+
+ function isSourcesEqual(source1, source2) {
+ return source1 && source2 && getSourcePrimitive(source1) == getSourcePrimitive(source2);
+ }
+
+
+ function getSourcePrimitive(source) {
+ return ((typeof source == 'object') ? (source.events || source.url) : '') || source;
+ }
+
+
+}
+
+
+fc.addDays = addDays;
+fc.cloneDate = cloneDate;
+fc.parseDate = parseDate;
+fc.parseISO8601 = parseISO8601;
+fc.parseTime = parseTime;
+fc.formatDate = formatDate;
+fc.formatDates = formatDates;
+
+
+
+/* Date Math
+-----------------------------------------------------------------------------*/
+
+var dayIDs = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'],
+ DAY_MS = 86400000,
+ HOUR_MS = 3600000,
+ MINUTE_MS = 60000;
+
+
+function addYears(d, n, keepTime) {
+ d.setFullYear(d.getFullYear() + n);
+ if (!keepTime) {
+ clearTime(d);
+ }
+ return d;
+}
+
+
+function addMonths(d, n, keepTime) { // prevents day overflow/underflow
+ if (+d) { // prevent infinite looping on invalid dates
+ var m = d.getMonth() + n,
+ check = cloneDate(d);
+ check.setDate(1);
+ check.setMonth(m);
+ d.setMonth(m);
+ if (!keepTime) {
+ clearTime(d);
+ }
+ while (d.getMonth() != check.getMonth()) {
+ d.setDate(d.getDate() + (d < check ? 1 : -1));
+ }
+ }
+ return d;
+}
+
+
+function addDays(d, n, keepTime) { // deals with daylight savings
+ if (+d) {
+ var dd = d.getDate() + n,
+ check = cloneDate(d);
+ check.setHours(9); // set to middle of day
+ check.setDate(dd);
+ d.setDate(dd);
+ if (!keepTime) {
+ clearTime(d);
+ }
+ fixDate(d, check);
+ }
+ return d;
+}
+
+
+function fixDate(d, check) { // force d to be on check's YMD, for daylight savings purposes
+ if (+d) { // prevent infinite looping on invalid dates
+ while (d.getDate() != check.getDate()) {
+ d.setTime(+d + (d < check ? 1 : -1) * HOUR_MS);
+ }
+ }
+}
+
+
+function addMinutes(d, n) {
+ d.setMinutes(d.getMinutes() + n);
+ return d;
+}
+
+
+function clearTime(d) {
+ d.setHours(0);
+ d.setMinutes(0);
+ d.setSeconds(0);
+ d.setMilliseconds(0);
+ return d;
+}
+
+
+function cloneDate(d, dontKeepTime) {
+ if (dontKeepTime) {
+ return clearTime(new Date(+d));
+ }
+ return new Date(+d);
+}
+
+
+function zeroDate() { // returns a Date with time 00:00:00 and dateOfMonth=1
+ var i=0, d;
+ do {
+ d = new Date(1970, i++, 1);
+ } while (d.getHours()); // != 0
+ return d;
+}
+
+
+function skipWeekend(date, inc, excl) {
+ inc = inc || 1;
+ while (!date.getDay() || (excl && date.getDay()==1 || !excl && date.getDay()==6)) {
+ addDays(date, inc);
+ }
+ return date;
+}
+
+
+function dayDiff(d1, d2) { // d1 - d2
+ return Math.round((cloneDate(d1, true) - cloneDate(d2, true)) / DAY_MS);
+}
+
+
+function setYMD(date, y, m, d) {
+ if (y !== undefined && y != date.getFullYear()) {
+ date.setDate(1);
+ date.setMonth(0);
+ date.setFullYear(y);
+ }
+ if (m !== undefined && m != date.getMonth()) {
+ date.setDate(1);
+ date.setMonth(m);
+ }
+ if (d !== undefined) {
+ date.setDate(d);
+ }
+}
+
+
+
+/* Date Parsing
+-----------------------------------------------------------------------------*/
+
+
+function parseDate(s, ignoreTimezone) { // ignoreTimezone defaults to true
+ if (typeof s == 'object') { // already a Date object
+ return s;
+ }
+ if (typeof s == 'number') { // a UNIX timestamp
+ return new Date(s * 1000);
+ }
+ if (typeof s == 'string') {
+ if (s.match(/^\d+(\.\d+)?$/)) { // a UNIX timestamp
+ return new Date(parseFloat(s) * 1000);
+ }
+ if (ignoreTimezone === undefined) {
+ ignoreTimezone = true;
+ }
+ return parseISO8601(s, ignoreTimezone) || (s ? new Date(s) : null);
+ }
+ // TODO: never return invalid dates (like from new Date(<string>)), return null instead
+ return null;
+}
+
+
+function parseISO8601(s, ignoreTimezone) { // ignoreTimezone defaults to false
+ // derived from http://delete.me.uk/2005/03/iso8601.html
+ // TODO: for a know glitch/feature, read tests/issue_206_parseDate_dst.html
+ var m = s.match(/^([0-9]{4})(-([0-9]{2})(-([0-9]{2})([T ]([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?(Z|(([-+])([0-9]{2})(:?([0-9]{2}))?))?)?)?)?$/);
+ if (!m) {
+ return null;
+ }
+ var date = new Date(m[1], 0, 1);
+ if (ignoreTimezone || !m[13]) {
+ var check = new Date(m[1], 0, 1, 9, 0);
+ if (m[3]) {
+ date.setMonth(m[3] - 1);
+ check.setMonth(m[3] - 1);
+ }
+ if (m[5]) {
+ date.setDate(m[5]);
+ check.setDate(m[5]);
+ }
+ fixDate(date, check);
+ if (m[7]) {
+ date.setHours(m[7]);
+ }
+ if (m[8]) {
+ date.setMinutes(m[8]);
+ }
+ if (m[10]) {
+ date.setSeconds(m[10]);
+ }
+ if (m[12]) {
+ date.setMilliseconds(Number("0." + m[12]) * 1000);
+ }
+ fixDate(date, check);
+ }else{
+ date.setUTCFullYear(
+ m[1],
+ m[3] ? m[3] - 1 : 0,
+ m[5] || 1
+ );
+ date.setUTCHours(
+ m[7] || 0,
+ m[8] || 0,
+ m[10] || 0,
+ m[12] ? Number("0." + m[12]) * 1000 : 0
+ );
+ if (m[14]) {
+ var offset = Number(m[16]) * 60 + (m[18] ? Number(m[18]) : 0);
+ offset *= m[15] == '-' ? 1 : -1;
+ date = new Date(+date + (offset * 60 * 1000));
+ }
+ }
+ return date;
+}
+
+
+function parseTime(s) { // returns minutes since start of day
+ if (typeof s == 'number') { // an hour
+ return s * 60;
+ }
+ if (typeof s == 'object') { // a Date object
+ return s.getHours() * 60 + s.getMinutes();
+ }
+ var m = s.match(/(\d+)(?::(\d+))?\s*(\w+)?/);
+ if (m) {
+ var h = parseInt(m[1], 10);
+ if (m[3]) {
+ h %= 12;
+ if (m[3].toLowerCase().charAt(0) == 'p') {
+ h += 12;
+ }
+ }
+ return h * 60 + (m[2] ? parseInt(m[2], 10) : 0);
+ }
+}
+
+
+
+/* Date Formatting
+-----------------------------------------------------------------------------*/
+// TODO: use same function formatDate(date, [date2], format, [options])
+
+
+function formatDate(date, format, options) {
+ return formatDates(date, null, format, options);
+}
+
+
+function formatDates(date1, date2, format, options) {
+ options = options || defaults;
+ var date = date1,
+ otherDate = date2,
+ i, len = format.length, c,
+ i2, formatter,
+ res = '';
+ for (i=0; i<len; i++) {
+ c = format.charAt(i);
+ if (c == "'") {
+ for (i2=i+1; i2<len; i2++) {
+ if (format.charAt(i2) == "'") {
+ if (date) {
+ if (i2 == i+1) {
+ res += "'";
+ }else{
+ res += format.substring(i+1, i2);
+ }
+ i = i2;
+ }
+ break;
+ }
+ }
+ }
+ else if (c == '(') {
+ for (i2=i+1; i2<len; i2++) {
+ if (format.charAt(i2) == ')') {
+ var subres = formatDate(date, format.substring(i+1, i2), options);
+ if (parseInt(subres.replace(/\D/, ''), 10)) {
+ res += subres;
+ }
+ i = i2;
+ break;
+ }
+ }
+ }
+ else if (c == '[') {
+ for (i2=i+1; i2<len; i2++) {
+ if (format.charAt(i2) == ']') {
+ var subformat = format.substring(i+1, i2);
+ var subres = formatDate(date, subformat, options);
+ if (subres != formatDate(otherDate, subformat, options)) {
+ res += subres;
+ }
+ i = i2;
+ break;
+ }
+ }
+ }
+ else if (c == '{') {
+ date = date2;
+ otherDate = date1;
+ }
+ else if (c == '}') {
+ date = date1;
+ otherDate = date2;
+ }
+ else {
+ for (i2=len; i2>i; i2--) {
+ if (formatter = dateFormatters[format.substring(i, i2)]) {
+ if (date) {
+ res += formatter(date, options);
+ }
+ i = i2 - 1;
+ break;
+ }
+ }
+ if (i2 == i) {
+ if (date) {
+ res += c;
+ }
+ }
+ }
+ }
+ return res;
+};
+
+
+var dateFormatters = {
+ s : function(d) { return d.getSeconds() },
+ ss : function(d) { return zeroPad(d.getSeconds()) },
+ m : function(d) { return d.getMinutes() },
+ mm : function(d) { return zeroPad(d.getMinutes()) },
+ h : function(d) { return d.getHours() % 12 || 12 },
+ hh : function(d) { return zeroPad(d.getHours() % 12 || 12) },
+ H : function(d) { return d.getHours() },
+ HH : function(d) { return zeroPad(d.getHours()) },
+ d : function(d) { return d.getDate() },
+ dd : function(d) { return zeroPad(d.getDate()) },
+ ddd : function(d,o) { return o.dayNamesShort[d.getDay()] },
+ dddd: function(d,o) { return o.dayNames[d.getDay()] },
+ M : function(d) { return d.getMonth() + 1 },
+ MM : function(d) { return zeroPad(d.getMonth() + 1) },
+ MMM : function(d,o) { return o.monthNamesShort[d.getMonth()] },
+ MMMM: function(d,o) { return o.monthNames[d.getMonth()] },
+ yy : function(d) { return (d.getFullYear()+'').substring(2) },
+ yyyy: function(d) { return d.getFullYear() },
+ t : function(d) { return d.getHours() < 12 ? 'a' : 'p' },
+ tt : function(d) { return d.getHours() < 12 ? 'am' : 'pm' },
+ T : function(d) { return d.getHours() < 12 ? 'A' : 'P' },
+ TT : function(d) { return d.getHours() < 12 ? 'AM' : 'PM' },
+ u : function(d) { return formatDate(d, "yyyy-MM-dd'T'HH:mm:ss'Z'") },
+ S : function(d) {
+ var date = d.getDate();
+ if (date > 10 && date < 20) {
+ return 'th';
+ }
+ return ['st', 'nd', 'rd'][date%10-1] || 'th';
+ }
+};
+
+
+
+fc.applyAll = applyAll;
+
+
+/* Event Date Math
+-----------------------------------------------------------------------------*/
+
+
+function exclEndDay(event) {
+ if (event.end) {
+ return _exclEndDay(event.end, event.allDay);
+ }else{
+ return addDays(cloneDate(event.start), 1);
+ }
+}
+
+
+function _exclEndDay(end, allDay) {
+ end = cloneDate(end);
+ return allDay || end.getHours() || end.getMinutes() ? addDays(end, 1) : clearTime(end);
+}
+
+
+function segCmp(a, b) {
+ return (b.msLength - a.msLength) * 100 + (a.event.start - b.event.start);
+}
+
+
+function segsCollide(seg1, seg2) {
+ return seg1.end > seg2.start && seg1.start < seg2.end;
+}
+
+
+
+/* Event Sorting
+-----------------------------------------------------------------------------*/
+
+
+// event rendering utilities
+function sliceSegs(events, visEventEnds, start, end) {
+ var segs = [],
+ i, len=events.length, event,
+ eventStart, eventEnd,
+ segStart, segEnd,
+ isStart, isEnd;
+ for (i=0; i<len; i++) {
+ event = events[i];
+ eventStart = event.start;
+ eventEnd = visEventEnds[i];
+ if (eventEnd > start && eventStart < end) {
+ if (eventStart < start) {
+ segStart = cloneDate(start);
+ isStart = false;
+ }else{
+ segStart = eventStart;
+ isStart = true;
+ }
+ if (eventEnd > end) {
+ segEnd = cloneDate(end);
+ isEnd = false;
+ }else{
+ segEnd = eventEnd;
+ isEnd = true;
+ }
+ segs.push({
+ event: event,
+ start: segStart,
+ end: segEnd,
+ isStart: isStart,
+ isEnd: isEnd,
+ msLength: segEnd - segStart
+ });
+ }
+ }
+ return segs.sort(segCmp);
+}
+
+
+// event rendering calculation utilities
+function stackSegs(segs) {
+ var levels = [],
+ i, len = segs.length, seg,
+ j, collide, k;
+ for (i=0; i<len; i++) {
+ seg = segs[i];
+ j = 0; // the level index where seg should belong
+ while (true) {
+ collide = false;
+ if (levels[j]) {
+ for (k=0; k<levels[j].length; k++) {
+ if (segsCollide(levels[j][k], seg)) {
+ collide = true;
+ break;
+ }
+ }
+ }
+ if (collide) {
+ j++;
+ }else{
+ break;
+ }
+ }
+ if (levels[j]) {
+ levels[j].push(seg);
+ }else{
+ levels[j] = [seg];
+ }
+ }
+ return levels;
+}
+
+
+
+/* Event Element Binding
+-----------------------------------------------------------------------------*/
+
+
+function lazySegBind(container, segs, bindHandlers) {
+ container.unbind('mouseover').mouseover(function(ev) {
+ var parent=ev.target, e,
+ i, seg;
+ while (parent != this) {
+ e = parent;
+ parent = parent.parentNode;
+ }
+ if ((i = e._fci) !== undefined) {
+ e._fci = undefined;
+ seg = segs[i];
+ bindHandlers(seg.event, seg.element, seg);
+ $(ev.target).trigger(ev);
+ }
+ ev.stopPropagation();
+ });
+}
+
+
+
+/* Element Dimensions
+-----------------------------------------------------------------------------*/
+
+
+function setOuterWidth(element, width, includeMargins) {
+ for (var i=0, e; i<element.length; i++) {
+ e = $(element[i]);
+ e.width(Math.max(0, width - hsides(e, includeMargins)));
+ }
+}
+
+
+function setOuterHeight(element, height, includeMargins) {
+ for (var i=0, e; i<element.length; i++) {
+ e = $(element[i]);
+ e.height(Math.max(0, height - vsides(e, includeMargins)));
+ }
+}
+
+
+// TODO: curCSS has been deprecated (jQuery 1.4.3 - 10/16/2010)
+
+
+function hsides(element, includeMargins) {
+ return hpadding(element) + hborders(element) + (includeMargins ? hmargins(element) : 0);
+}
+
+
+function hpadding(element) {
+ return (parseFloat($.curCSS(element[0], 'paddingLeft', true)) || 0) +
+ (parseFloat($.curCSS(element[0], 'paddingRight', true)) || 0);
+}
+
+
+function hmargins(element) {
+ return (parseFloat($.curCSS(element[0], 'marginLeft', true)) || 0) +
+ (parseFloat($.curCSS(element[0], 'marginRight', true)) || 0);
+}
+
+
+function hborders(element) {
+ return (parseFloat($.curCSS(element[0], 'borderLeftWidth', true)) || 0) +
+ (parseFloat($.curCSS(element[0], 'borderRightWidth', true)) || 0);
+}
+
+
+function vsides(element, includeMargins) {
+ return vpadding(element) + vborders(element) + (includeMargins ? vmargins(element) : 0);
+}
+
+
+function vpadding(element) {
+ return (parseFloat($.curCSS(element[0], 'paddingTop', true)) || 0) +
+ (parseFloat($.curCSS(element[0], 'paddingBottom', true)) || 0);
+}
+
+
+function vmargins(element) {
+ return (parseFloat($.curCSS(element[0], 'marginTop', true)) || 0) +
+ (parseFloat($.curCSS(element[0], 'marginBottom', true)) || 0);
+}
+
+
+function vborders(element) {
+ return (parseFloat($.curCSS(element[0], 'borderTopWidth', true)) || 0) +
+ (parseFloat($.curCSS(element[0], 'borderBottomWidth', true)) || 0);
+}
+
+
+function setMinHeight(element, height) {
+ height = (typeof height == 'number' ? height + 'px' : height);
+ element.each(function(i, _element) {
+ _element.style.cssText += ';min-height:' + height + ';_height:' + height;
+ // why can't we just use .css() ? i forget
+ });
+}
+
+
+
+/* Misc Utils
+-----------------------------------------------------------------------------*/
+
+
+//TODO: arraySlice
+//TODO: isFunction, grep ?
+
+
+function noop() { }
+
+
+function cmp(a, b) {
+ return a - b;
+}
+
+
+function arrayMax(a) {
+ return Math.max.apply(Math, a);
+}
+
+
+function zeroPad(n) {
+ return (n < 10 ? '0' : '') + n;
+}
+
+
+function smartProperty(obj, name) { // get a camel-cased/namespaced property of an object
+ if (obj[name] !== undefined) {
+ return obj[name];
+ }
+ var parts = name.split(/(?=[A-Z])/),
+ i=parts.length-1, res;
+ for (; i>=0; i--) {
+ res = obj[parts[i].toLowerCase()];
+ if (res !== undefined) {
+ return res;
+ }
+ }
+ return obj[''];
+}
+
+
+function htmlEscape(s) {
+ return s.replace(/&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/'/g, '&#039;')
+ .replace(/"/g, '&quot;')
+ .replace(/\n/g, '<br />');
+}
+
+
+function cssKey(_element) {
+ return _element.id + '/' + _element.className + '/' + _element.style.cssText.replace(/(^|;)\s*(top|left|width|height)\s*:[^;]*/ig, '');
+}
+
+
+function disableTextSelection(element) {
+ element
+ .attr('unselectable', 'on')
+ .css('MozUserSelect', 'none')
+ .bind('selectstart.ui', function() { return false; });
+}
+
+
+/*
+function enableTextSelection(element) {
+ element
+ .attr('unselectable', 'off')
+ .css('MozUserSelect', '')
+ .unbind('selectstart.ui');
+}
+*/
+
+
+function markFirstLast(e) {
+ e.children()
+ .removeClass('fc-first fc-last')
+ .filter(':first-child')
+ .addClass('fc-first')
+ .end()
+ .filter(':last-child')
+ .addClass('fc-last');
+}
+
+
+function setDayID(cell, date) {
+ cell.each(function(i, _cell) {
+ _cell.className = _cell.className.replace(/^fc-\w*/, 'fc-' + dayIDs[date.getDay()]);
+ // TODO: make a way that doesn't rely on order of classes
+ });
+}
+
+
+function getSkinCss(event, opt) {
+ var source = event.source || {};
+ var eventColor = event.color;
+ var sourceColor = source.color;
+ var optionColor = opt('eventColor');
+ var backgroundColor =
+ event.backgroundColor ||
+ eventColor ||
+ source.backgroundColor ||
+ sourceColor ||
+ opt('eventBackgroundColor') ||
+ optionColor;
+ var borderColor =
+ event.borderColor ||
+ eventColor ||
+ source.borderColor ||
+ sourceColor ||
+ opt('eventBorderColor') ||
+ optionColor;
+ var textColor =
+ event.textColor ||
+ source.textColor ||
+ opt('eventTextColor');
+ var statements = [];
+ if (backgroundColor) {
+ statements.push('background-color:' + backgroundColor);
+ }
+ if (borderColor) {
+ statements.push('border-color:' + borderColor);
+ }
+ if (textColor) {
+ statements.push('color:' + textColor);
+ }
+ return statements.join(';');
+}
+
+
+function applyAll(functions, thisObj, args) {
+ if ($.isFunction(functions)) {
+ functions = [ functions ];
+ }
+ if (functions) {
+ var i;
+ var ret;
+ for (i=0; i<functions.length; i++) {
+ ret = functions[i].apply(thisObj, args) || ret;
+ }
+ return ret;
+ }
+}
+
+
+function firstDefined() {
+ for (var i=0; i<arguments.length; i++) {
+ if (arguments[i] !== undefined) {
+ return arguments[i];
+ }
+ }
+}
+
+
+
+fcViews.month = MonthView;
+
+function MonthView(element, calendar) {
+ var t = this;
+
+
+ // exports
+ t.render = render;
+
+
+ // imports
+ BasicView.call(t, element, calendar, 'month');
+ var opt = t.opt;
+ var renderBasic = t.renderBasic;
+ var formatDate = calendar.formatDate;
+
+
+
+ function render(date, delta) {
+ if (delta) {
+ addMonths(date, delta);
+ date.setDate(1);
+ }
+ var start = cloneDate(date, true);
+ start.setDate(1);
+ var end = addMonths(cloneDate(start), 1);
+ var visStart = cloneDate(start);
+ var visEnd = cloneDate(end);
+ var firstDay = opt('firstDay');
+ var nwe = opt('weekends') ? 0 : 1;
+ if (nwe) {
+ skipWeekend(visStart);
+ skipWeekend(visEnd, -1, true);
+ }
+ addDays(visStart, -((visStart.getDay() - Math.max(firstDay, nwe) + 7) % 7));
+ addDays(visEnd, (7 - visEnd.getDay() + Math.max(firstDay, nwe)) % 7);
+ var rowCnt = Math.round((visEnd - visStart) / (DAY_MS * 7));
+ if (opt('weekMode') == 'fixed') {
+ addDays(visEnd, (6 - rowCnt) * 7);
+ rowCnt = 6;
+ }
+ t.title = formatDate(start, opt('titleFormat'));
+ t.start = start;
+ t.end = end;
+ t.visStart = visStart;
+ t.visEnd = visEnd;
+ renderBasic(6, rowCnt, nwe ? 5 : 7, true);
+ }
+
+
+}
+
+fcViews.basicWeek = BasicWeekView;
+
+function BasicWeekView(element, calendar) {
+ var t = this;
+
+
+ // exports
+ t.render = render;
+
+
+ // imports
+ BasicView.call(t, element, calendar, 'basicWeek');
+ var opt = t.opt;
+ var renderBasic = t.renderBasic;
+ var formatDates = calendar.formatDates;
+
+
+
+ function render(date, delta) {
+ if (delta) {
+ addDays(date, delta * 7);
+ }
+ var start = addDays(cloneDate(date), -((date.getDay() - opt('firstDay') + 7) % 7));
+ var end = addDays(cloneDate(start), 7);
+ var visStart = cloneDate(start);
+ var visEnd = cloneDate(end);
+ var weekends = opt('weekends');
+ if (!weekends) {
+ skipWeekend(visStart);
+ skipWeekend(visEnd, -1, true);
+ }
+ t.title = formatDates(
+ visStart,
+ addDays(cloneDate(visEnd), -1),
+ opt('titleFormat')
+ );
+ t.start = start;
+ t.end = end;
+ t.visStart = visStart;
+ t.visEnd = visEnd;
+ renderBasic(1, 1, weekends ? 7 : 5, false);
+ }
+
+
+}
+
+fcViews.basicDay = BasicDayView;
+
+//TODO: when calendar's date starts out on a weekend, shouldn't happen
+
+
+function BasicDayView(element, calendar) {
+ var t = this;
+
+
+ // exports
+ t.render = render;
+
+
+ // imports
+ BasicView.call(t, element, calendar, 'basicDay');
+ var opt = t.opt;
+ var renderBasic = t.renderBasic;
+ var formatDate = calendar.formatDate;
+
+
+
+ function render(date, delta) {
+ if (delta) {
+ addDays(date, delta);
+ if (!opt('weekends')) {
+ skipWeekend(date, delta < 0 ? -1 : 1);
+ }
+ }
+ t.title = formatDate(date, opt('titleFormat'));
+ t.start = t.visStart = cloneDate(date, true);
+ t.end = t.visEnd = addDays(cloneDate(t.start), 1);
+ renderBasic(1, 1, 1, false);
+ }
+
+
+}
+
+setDefaults({
+ weekMode: 'fixed'
+});
+
+
+function BasicView(element, calendar, viewName) {
+ var t = this;
+
+
+ // exports
+ t.renderBasic = renderBasic;
+ t.setHeight = setHeight;
+ t.setWidth = setWidth;
+ t.renderDayOverlay = renderDayOverlay;
+ t.defaultSelectionEnd = defaultSelectionEnd;
+ t.renderSelection = renderSelection;
+ t.clearSelection = clearSelection;
+ t.reportDayClick = reportDayClick; // for selection (kinda hacky)
+ t.dragStart = dragStart;
+ t.dragStop = dragStop;
+ t.defaultEventEnd = defaultEventEnd;
+ t.getHoverListener = function() { return hoverListener };
+ t.colContentLeft = colContentLeft;
+ t.colContentRight = colContentRight;
+ t.dayOfWeekCol = dayOfWeekCol;
+ t.dateCell = dateCell;
+ t.cellDate = cellDate;
+ t.cellIsAllDay = function() { return true };
+ t.allDayRow = allDayRow;
+ t.allDayBounds = allDayBounds;
+ t.getRowCnt = function() { return rowCnt };
+ t.getColCnt = function() { return colCnt };
+ t.getColWidth = function() { return colWidth };
+ t.getDaySegmentContainer = function() { return daySegmentContainer };
+
+
+ // imports
+ View.call(t, element, calendar, viewName);
+ OverlayManager.call(t);
+ SelectionManager.call(t);
+ BasicEventRenderer.call(t);
+ var opt = t.opt;
+ var trigger = t.trigger;
+ var clearEvents = t.clearEvents;
+ var renderOverlay = t.renderOverlay;
+ var clearOverlays = t.clearOverlays;
+ var daySelectionMousedown = t.daySelectionMousedown;
+ var formatDate = calendar.formatDate;
+
+
+ // locals
+
+ var head;
+ var headCells;
+ var body;
+ var bodyRows;
+ var bodyCells;
+ var bodyFirstCells;
+ var bodyCellTopInners;
+ var daySegmentContainer;
+
+ var viewWidth;
+ var viewHeight;
+ var colWidth;
+
+ var rowCnt, colCnt;
+ var coordinateGrid;
+ var hoverListener;
+ var colContentPositions;
+
+ var rtl, dis, dit;
+ var firstDay;
+ var nwe;
+ var tm;
+ var colFormat;
+
+
+
+ /* Rendering
+ ------------------------------------------------------------*/
+
+
+ disableTextSelection(element.addClass('fc-grid'));
+
+
+ function renderBasic(maxr, r, c, showNumbers) {
+ rowCnt = r;
+ colCnt = c;
+ updateOptions();
+ var firstTime = !body;
+ if (firstTime) {
+ buildSkeleton(maxr, showNumbers);
+ }else{
+ clearEvents();
+ }
+ updateCells(firstTime);
+ }
+
+
+
+ function updateOptions() {
+ rtl = opt('isRTL');
+ if (rtl) {
+ dis = -1;
+ dit = colCnt - 1;
+ }else{
+ dis = 1;
+ dit = 0;
+ }
+ firstDay = opt('firstDay');
+ nwe = opt('weekends') ? 0 : 1;
+ tm = opt('theme') ? 'ui' : 'fc';
+ colFormat = opt('columnFormat');
+ }
+
+
+
+ function buildSkeleton(maxRowCnt, showNumbers) {
+ var s;
+ var headerClass = tm + "-widget-header";
+ var contentClass = tm + "-widget-content";
+ var i, j;
+ var table;
+
+ s =
+ "<table class='fc-border-separate' style='width:100%' cellspacing='0'>" +
+ "<thead>" +
+ "<tr>";
+ for (i=0; i<colCnt; i++) {
+ s +=
+ "<th class='fc- " + headerClass + "'/>"; // need fc- for setDayID
+ }
+ s +=
+ "</tr>" +
+ "</thead>" +
+ "<tbody>";
+ for (i=0; i<maxRowCnt; i++) {
+ s +=
+ "<tr class='fc-week" + i + "'>";
+ for (j=0; j<colCnt; j++) {
+ s +=
+ "<td class='fc- " + contentClass + " fc-day" + (i*colCnt+j) + "'>" + // need fc- for setDayID
+ "<div>" +
+ (showNumbers ?
+ "<div class='fc-day-number'/>" :
+ ''
+ ) +
+ "<div class='fc-day-content'>" +
+ "<div style='position:relative'>&nbsp;</div>" +
+ "</div>" +
+ "</div>" +
+ "</td>";
+ }
+ s +=
+ "</tr>";
+ }
+ s +=
+ "</tbody>" +
+ "</table>";
+ table = $(s).appendTo(element);
+
+ head = table.find('thead');
+ headCells = head.find('th');
+ body = table.find('tbody');
+ bodyRows = body.find('tr');
+ bodyCells = body.find('td');
+ bodyFirstCells = bodyCells.filter(':first-child');
+ bodyCellTopInners = bodyRows.eq(0).find('div.fc-day-content div');
+
+ markFirstLast(head.add(head.find('tr'))); // marks first+last tr/th's
+ markFirstLast(bodyRows); // marks first+last td's
+ bodyRows.eq(0).addClass('fc-first'); // fc-last is done in updateCells
+
+ dayBind(bodyCells);
+
+ daySegmentContainer =
+ $("<div style='position:absolute;z-index:8;top:0;left:0'/>")
+ .appendTo(element);
+ }
+
+
+
+ function updateCells(firstTime) {
+ var dowDirty = firstTime || rowCnt == 1; // could the cells' day-of-weeks need updating?
+ var month = t.start.getMonth();
+ var today = clearTime(new Date());
+ var cell;
+ var date;
+ var row;
+
+ if (dowDirty) {
+ headCells.each(function(i, _cell) {
+ cell = $(_cell);
+ date = indexDate(i);
+ cell.html(formatDate(date, colFormat));
+ setDayID(cell, date);
+ });
+ }
+
+ bodyCells.each(function(i, _cell) {
+ cell = $(_cell);
+ date = indexDate(i);
+ if (date.getMonth() == month) {
+ cell.removeClass('fc-other-month');
+ }else{
+ cell.addClass('fc-other-month');
+ }
+ if (+date == +today) {
+ cell.addClass(tm + '-state-highlight fc-today');
+ }else{
+ cell.removeClass(tm + '-state-highlight fc-today');
+ }
+ cell.find('div.fc-day-number').text(date.getDate());
+ if (dowDirty) {
+ setDayID(cell, date);
+ }
+ });
+
+ bodyRows.each(function(i, _row) {
+ row = $(_row);
+ if (i < rowCnt) {
+ row.show();
+ if (i == rowCnt-1) {
+ row.addClass('fc-last');
+ }else{
+ row.removeClass('fc-last');
+ }
+ }else{
+ row.hide();
+ }
+ });
+ }
+
+
+
+ function setHeight(height) {
+ viewHeight = height;
+
+ var bodyHeight = viewHeight - head.height();
+ var rowHeight;
+ var rowHeightLast;
+ var cell;
+
+ if (opt('weekMode') == 'variable') {
+ rowHeight = rowHeightLast = Math.floor(bodyHeight / (rowCnt==1 ? 2 : 6));
+ }else{
+ rowHeight = Math.floor(bodyHeight / rowCnt);
+ rowHeightLast = bodyHeight - rowHeight * (rowCnt-1);
+ }
+
+ bodyFirstCells.each(function(i, _cell) {
+ if (i < rowCnt) {
+ cell = $(_cell);
+ setMinHeight(
+ cell.find('> div'),
+ (i==rowCnt-1 ? rowHeightLast : rowHeight) - vsides(cell)
+ );
+ }
+ });
+
+ }
+
+
+ function setWidth(width) {
+ viewWidth = width;
+ colContentPositions.clear();
+ colWidth = Math.floor(viewWidth / colCnt);
+ setOuterWidth(headCells.slice(0, -1), colWidth);
+ }
+
+
+
+ /* Day clicking and binding
+ -----------------------------------------------------------*/
+
+
+ function dayBind(days) {
+ days.click(dayClick)
+ .mousedown(daySelectionMousedown);
+ }
+
+
+ function dayClick(ev) {
+ if (!opt('selectable')) { // if selectable, SelectionManager will worry about dayClick
+ var index = parseInt(this.className.match(/fc\-day(\d+)/)[1]); // TODO: maybe use .data
+ var date = indexDate(index);
+ trigger('dayClick', this, date, true, ev);
+ }
+ }
+
+
+
+ /* Semi-transparent Overlay Helpers
+ ------------------------------------------------------*/
+
+
+ function renderDayOverlay(overlayStart, overlayEnd, refreshCoordinateGrid) { // overlayEnd is exclusive
+ if (refreshCoordinateGrid) {
+ coordinateGrid.build();
+ }
+ var rowStart = cloneDate(t.visStart);
+ var rowEnd = addDays(cloneDate(rowStart), colCnt);
+ for (var i=0; i<rowCnt; i++) {
+ var stretchStart = new Date(Math.max(rowStart, overlayStart));
+ var stretchEnd = new Date(Math.min(rowEnd, overlayEnd));
+ if (stretchStart < stretchEnd) {
+ var colStart, colEnd;
+ if (rtl) {
+ colStart = dayDiff(stretchEnd, rowStart)*dis+dit+1;
+ colEnd = dayDiff(stretchStart, rowStart)*dis+dit+1;
+ }else{
+ colStart = dayDiff(stretchStart, rowStart);
+ colEnd = dayDiff(stretchEnd, rowStart);
+ }
+ dayBind(
+ renderCellOverlay(i, colStart, i, colEnd-1)
+ );
+ }
+ addDays(rowStart, 7);
+ addDays(rowEnd, 7);
+ }
+ }
+
+
+ function renderCellOverlay(row0, col0, row1, col1) { // row1,col1 is inclusive
+ var rect = coordinateGrid.rect(row0, col0, row1, col1, element);
+ return renderOverlay(rect, element);
+ }
+
+
+
+ /* Selection
+ -----------------------------------------------------------------------*/
+
+
+ function defaultSelectionEnd(startDate, allDay) {
+ return cloneDate(startDate);
+ }
+
+
+ function renderSelection(startDate, endDate, allDay) {
+ renderDayOverlay(startDate, addDays(cloneDate(endDate), 1), true); // rebuild every time???
+ }
+
+
+ function clearSelection() {
+ clearOverlays();
+ }
+
+
+ function reportDayClick(date, allDay, ev) {
+ var cell = dateCell(date);
+ var _element = bodyCells[cell.row*colCnt + cell.col];
+ trigger('dayClick', _element, date, allDay, ev);
+ }
+
+
+
+ /* External Dragging
+ -----------------------------------------------------------------------*/
+
+
+ function dragStart(_dragElement, ev, ui) {
+ hoverListener.start(function(cell) {
+ clearOverlays();
+ if (cell) {
+ renderCellOverlay(cell.row, cell.col, cell.row, cell.col);
+ }
+ }, ev);
+ }
+
+
+ function dragStop(_dragElement, ev, ui) {
+ var cell = hoverListener.stop();
+ clearOverlays();
+ if (cell) {
+ var d = cellDate(cell);
+ trigger('drop', _dragElement, d, true, ev, ui);
+ }
+ }
+
+
+
+ /* Utilities
+ --------------------------------------------------------*/
+
+
+ function defaultEventEnd(event) {
+ return cloneDate(event.start);
+ }
+
+
+ coordinateGrid = new CoordinateGrid(function(rows, cols) {
+ var e, n, p;
+ headCells.each(function(i, _e) {
+ e = $(_e);
+ n = e.offset().left;
+ if (i) {
+ p[1] = n;
+ }
+ p = [n];
+ cols[i] = p;
+ });
+ p[1] = n + e.outerWidth();
+ bodyRows.each(function(i, _e) {
+ if (i < rowCnt) {
+ e = $(_e);
+ n = e.offset().top;
+ if (i) {
+ p[1] = n;
+ }
+ p = [n];
+ rows[i] = p;
+ }
+ });
+ p[1] = n + e.outerHeight();
+ });
+
+
+ hoverListener = new HoverListener(coordinateGrid);
+
+
+ colContentPositions = new HorizontalPositionCache(function(col) {
+ return bodyCellTopInners.eq(col);
+ });
+
+
+ function colContentLeft(col) {
+ return colContentPositions.left(col);
+ }
+
+
+ function colContentRight(col) {
+ return colContentPositions.right(col);
+ }
+
+
+
+
+ function dateCell(date) {
+ return {
+ row: Math.floor(dayDiff(date, t.visStart) / 7),
+ col: dayOfWeekCol(date.getDay())
+ };
+ }
+
+
+ function cellDate(cell) {
+ return _cellDate(cell.row, cell.col);
+ }
+
+
+ function _cellDate(row, col) {
+ return addDays(cloneDate(t.visStart), row*7 + col*dis+dit);
+ // what about weekends in middle of week?
+ }
+
+
+ function indexDate(index) {
+ return _cellDate(Math.floor(index/colCnt), index%colCnt);
+ }
+
+
+ function dayOfWeekCol(dayOfWeek) {
+ return ((dayOfWeek - Math.max(firstDay, nwe) + colCnt) % colCnt) * dis + dit;
+ }
+
+
+
+
+ function allDayRow(i) {
+ return bodyRows.eq(i);
+ }
+
+
+ function allDayBounds(i) {
+ return {
+ left: 0,
+ right: viewWidth
+ };
+ }
+
+
+}
+
+function BasicEventRenderer() {
+ var t = this;
+
+
+ // exports
+ t.renderEvents = renderEvents;
+ t.compileDaySegs = compileSegs; // for DayEventRenderer
+ t.clearEvents = clearEvents;
+ t.bindDaySeg = bindDaySeg;
+
+
+ // imports
+ DayEventRenderer.call(t);
+ var opt = t.opt;
+ var trigger = t.trigger;
+ //var setOverflowHidden = t.setOverflowHidden;
+ var isEventDraggable = t.isEventDraggable;
+ var isEventResizable = t.isEventResizable;
+ var reportEvents = t.reportEvents;
+ var reportEventClear = t.reportEventClear;
+ var eventElementHandlers = t.eventElementHandlers;
+ var showEvents = t.showEvents;
+ var hideEvents = t.hideEvents;
+ var eventDrop = t.eventDrop;
+ var getDaySegmentContainer = t.getDaySegmentContainer;
+ var getHoverListener = t.getHoverListener;
+ var renderDayOverlay = t.renderDayOverlay;
+ var clearOverlays = t.clearOverlays;
+ var getRowCnt = t.getRowCnt;
+ var getColCnt = t.getColCnt;
+ var renderDaySegs = t.renderDaySegs;
+ var resizableDayEvent = t.resizableDayEvent;
+
+
+
+ /* Rendering
+ --------------------------------------------------------------------*/
+
+
+ function renderEvents(events, modifiedEventId) {
+ reportEvents(events);
+ renderDaySegs(compileSegs(events), modifiedEventId);
+ }
+
+
+ function clearEvents() {
+ reportEventClear();
+ getDaySegmentContainer().empty();
+ }
+
+
+ function compileSegs(events) {
+ var rowCnt = getRowCnt(),
+ colCnt = getColCnt(),
+ d1 = cloneDate(t.visStart),
+ d2 = addDays(cloneDate(d1), colCnt),
+ visEventsEnds = $.map(events, exclEndDay),
+ i, row,
+ j, level,
+ k, seg,
+ segs=[];
+ for (i=0; i<rowCnt; i++) {
+ row = stackSegs(sliceSegs(events, visEventsEnds, d1, d2));
+ for (j=0; j<row.length; j++) {
+ level = row[j];
+ for (k=0; k<level.length; k++) {
+ seg = level[k];
+ seg.row = i;
+ seg.level = j; // not needed anymore
+ segs.push(seg);
+ }
+ }
+ addDays(d1, 7);
+ addDays(d2, 7);
+ }
+ return segs;
+ }
+
+
+ function bindDaySeg(event, eventElement, seg) {
+ if (isEventDraggable(event)) {
+ draggableDayEvent(event, eventElement);
+ }
+ if (seg.isEnd && isEventResizable(event)) {
+ resizableDayEvent(event, eventElement, seg);
+ }
+ eventElementHandlers(event, eventElement);
+ // needs to be after, because resizableDayEvent might stopImmediatePropagation on click
+ }
+
+
+
+ /* Dragging
+ ----------------------------------------------------------------------------*/
+
+
+ function draggableDayEvent(event, eventElement) {
+ var hoverListener = getHoverListener();
+ var dayDelta;
+ eventElement.draggable({
+ zIndex: 9,
+ delay: 50,
+ opacity: opt('dragOpacity'),
+ revertDuration: opt('dragRevertDuration'),
+ start: function(ev, ui) {
+ trigger('eventDragStart', eventElement, event, ev, ui);
+ hideEvents(event, eventElement);
+ hoverListener.start(function(cell, origCell, rowDelta, colDelta) {
+ eventElement.draggable('option', 'revert', !cell || !rowDelta && !colDelta);
+ clearOverlays();
+ if (cell) {
+ //setOverflowHidden(true);
+ dayDelta = rowDelta*7 + colDelta * (opt('isRTL') ? -1 : 1);
+ renderDayOverlay(
+ addDays(cloneDate(event.start), dayDelta),
+ addDays(exclEndDay(event), dayDelta)
+ );
+ }else{
+ //setOverflowHidden(false);
+ dayDelta = 0;
+ }
+ }, ev, 'drag');
+ },
+ stop: function(ev, ui) {
+ hoverListener.stop();
+ clearOverlays();
+ trigger('eventDragStop', eventElement, event, ev, ui);
+ if (dayDelta) {
+ eventDrop(this, event, dayDelta, 0, event.allDay, ev, ui);
+ }else{
+ eventElement.css('filter', ''); // clear IE opacity side-effects
+ showEvents(event, eventElement);
+ }
+ //setOverflowHidden(false);
+ }
+ });
+ }
+
+
+}
+
+fcViews.agendaWeek = AgendaWeekView;
+
+function AgendaWeekView(element, calendar) {
+ var t = this;
+
+
+ // exports
+ t.render = render;
+
+
+ // imports
+ AgendaView.call(t, element, calendar, 'agendaWeek');
+ var opt = t.opt;
+ var renderAgenda = t.renderAgenda;
+ var formatDates = calendar.formatDates;
+
+
+
+ function render(date, delta) {
+ if (delta) {
+ addDays(date, delta * 7);
+ }
+ var start = addDays(cloneDate(date), -((date.getDay() - opt('firstDay') + 7) % 7));
+ var end = addDays(cloneDate(start), 7);
+ var visStart = cloneDate(start);
+ var visEnd = cloneDate(end);
+ var weekends = opt('weekends');
+ if (!weekends) {
+ skipWeekend(visStart);
+ skipWeekend(visEnd, -1, true);
+ }
+ t.title = formatDates(
+ visStart,
+ addDays(cloneDate(visEnd), -1),
+ opt('titleFormat')
+ );
+ t.start = start;
+ t.end = end;
+ t.visStart = visStart;
+ t.visEnd = visEnd;
+ renderAgenda(weekends ? 7 : 5);
+ }
+
+
+}
+
+fcViews.agendaDay = AgendaDayView;
+
+function AgendaDayView(element, calendar) {
+ var t = this;
+
+
+ // exports
+ t.render = render;
+
+
+ // imports
+ AgendaView.call(t, element, calendar, 'agendaDay');
+ var opt = t.opt;
+ var renderAgenda = t.renderAgenda;
+ var formatDate = calendar.formatDate;
+
+
+
+ function render(date, delta) {
+ if (delta) {
+ addDays(date, delta);
+ if (!opt('weekends')) {
+ skipWeekend(date, delta < 0 ? -1 : 1);
+ }
+ }
+ var start = cloneDate(date, true);
+ var end = addDays(cloneDate(start), 1);
+ t.title = formatDate(date, opt('titleFormat'));
+ t.start = t.visStart = start;
+ t.end = t.visEnd = end;
+ renderAgenda(1);
+ }
+
+
+}
+
+setDefaults({
+ allDaySlot: true,
+ allDayText: 'all-day',
+ firstHour: 6,
+ slotMinutes: 30,
+ defaultEventMinutes: 120,
+ axisFormat: 'h(:mm)tt',
+ timeFormat: {
+ agenda: 'h:mm{ - h:mm}'
+ },
+ dragOpacity: {
+ agenda: .5
+ },
+ minTime: 0,
+ maxTime: 24
+});
+
+
+// TODO: make it work in quirks mode (event corners, all-day height)
+// TODO: test liquid width, especially in IE6
+
+
+function AgendaView(element, calendar, viewName) {
+ var t = this;
+
+
+ // exports
+ t.renderAgenda = renderAgenda;
+ t.setWidth = setWidth;
+ t.setHeight = setHeight;
+ t.beforeHide = beforeHide;
+ t.afterShow = afterShow;
+ t.defaultEventEnd = defaultEventEnd;
+ t.timePosition = timePosition;
+ t.dayOfWeekCol = dayOfWeekCol;
+ t.dateCell = dateCell;
+ t.cellDate = cellDate;
+ t.cellIsAllDay = cellIsAllDay;
+ t.allDayRow = getAllDayRow;
+ t.allDayBounds = allDayBounds;
+ t.getHoverListener = function() { return hoverListener };
+ t.colContentLeft = colContentLeft;
+ t.colContentRight = colContentRight;
+ t.getDaySegmentContainer = function() { return daySegmentContainer };
+ t.getSlotSegmentContainer = function() { return slotSegmentContainer };
+ t.getMinMinute = function() { return minMinute };
+ t.getMaxMinute = function() { return maxMinute };
+ t.getBodyContent = function() { return slotContent }; // !!??
+ t.getRowCnt = function() { return 1 };
+ t.getColCnt = function() { return colCnt };
+ t.getColWidth = function() { return colWidth };
+ t.getSlotHeight = function() { return slotHeight };
+ t.defaultSelectionEnd = defaultSelectionEnd;
+ t.renderDayOverlay = renderDayOverlay;
+ t.renderSelection = renderSelection;
+ t.clearSelection = clearSelection;
+ t.reportDayClick = reportDayClick; // selection mousedown hack
+ t.dragStart = dragStart;
+ t.dragStop = dragStop;
+
+
+ // imports
+ View.call(t, element, calendar, viewName);
+ OverlayManager.call(t);
+ SelectionManager.call(t);
+ AgendaEventRenderer.call(t);
+ var opt = t.opt;
+ var trigger = t.trigger;
+ var clearEvents = t.clearEvents;
+ var renderOverlay = t.renderOverlay;
+ var clearOverlays = t.clearOverlays;
+ var reportSelection = t.reportSelection;
+ var unselect = t.unselect;
+ var daySelectionMousedown = t.daySelectionMousedown;
+ var slotSegHtml = t.slotSegHtml;
+ var formatDate = calendar.formatDate;
+
+
+ // locals
+
+ var dayTable;
+ var dayHead;
+ var dayHeadCells;
+ var dayBody;
+ var dayBodyCells;
+ var dayBodyCellInners;
+ var dayBodyFirstCell;
+ var dayBodyFirstCellStretcher;
+ var slotLayer;
+ var daySegmentContainer;
+ var allDayTable;
+ var allDayRow;
+ var slotScroller;
+ var slotContent;
+ var slotSegmentContainer;
+ var slotTable;
+ var slotTableFirstInner;
+ var axisFirstCells;
+ var gutterCells;
+ var selectionHelper;
+
+ var viewWidth;
+ var viewHeight;
+ var axisWidth;
+ var colWidth;
+ var gutterWidth;
+ var slotHeight; // TODO: what if slotHeight changes? (see issue 650)
+ var savedScrollTop;
+
+ var colCnt;
+ var slotCnt;
+ var coordinateGrid;
+ var hoverListener;
+ var colContentPositions;
+ var slotTopCache = {};
+
+ var tm;
+ var firstDay;
+ var nwe; // no weekends (int)
+ var rtl, dis, dit; // day index sign / translate
+ var minMinute, maxMinute;
+ var colFormat;
+
+
+
+ /* Rendering
+ -----------------------------------------------------------------------------*/
+
+
+ disableTextSelection(element.addClass('fc-agenda'));
+
+
+ function renderAgenda(c) {
+ colCnt = c;
+ updateOptions();
+ if (!dayTable) {
+ buildSkeleton();
+ }else{
+ clearEvents();
+ }
+ updateCells();
+ }
+
+
+
+ function updateOptions() {
+ tm = opt('theme') ? 'ui' : 'fc';
+ nwe = opt('weekends') ? 0 : 1;
+ firstDay = opt('firstDay');
+ if (rtl = opt('isRTL')) {
+ dis = -1;
+ dit = colCnt - 1;
+ }else{
+ dis = 1;
+ dit = 0;
+ }
+ minMinute = parseTime(opt('minTime'));
+ maxMinute = parseTime(opt('maxTime'));
+ colFormat = opt('columnFormat');
+ }
+
+
+
+ function buildSkeleton() {
+ var headerClass = tm + "-widget-header";
+ var contentClass = tm + "-widget-content";
+ var s;
+ var i;
+ var d;
+ var maxd;
+ var minutes;
+ var slotNormal = opt('slotMinutes') % 15 == 0;
+
+ s =
+ "<table style='width:100%' class='fc-agenda-days fc-border-separate' cellspacing='0'>" +
+ "<thead>" +
+ "<tr>" +
+ "<th class='fc-agenda-axis " + headerClass + "'>&nbsp;</th>";
+ for (i=0; i<colCnt; i++) {
+ s +=
+ "<th class='fc- fc-col" + i + ' ' + headerClass + "'/>"; // fc- needed for setDayID
+ }
+ s +=
+ "<th class='fc-agenda-gutter " + headerClass + "'>&nbsp;</th>" +
+ "</tr>" +
+ "</thead>" +
+ "<tbody>" +
+ "<tr>" +
+ "<th class='fc-agenda-axis " + headerClass + "'>&nbsp;</th>";
+ for (i=0; i<colCnt; i++) {
+ s +=
+ "<td class='fc- fc-col" + i + ' ' + contentClass + "'>" + // fc- needed for setDayID
+ "<div>" +
+ "<div class='fc-day-content'>" +
+ "<div style='position:relative'>&nbsp;</div>" +
+ "</div>" +
+ "</div>" +
+ "</td>";
+ }
+ s +=
+ "<td class='fc-agenda-gutter " + contentClass + "'>&nbsp;</td>" +
+ "</tr>" +
+ "</tbody>" +
+ "</table>";
+ dayTable = $(s).appendTo(element);
+ dayHead = dayTable.find('thead');
+ dayHeadCells = dayHead.find('th').slice(1, -1);
+ dayBody = dayTable.find('tbody');
+ dayBodyCells = dayBody.find('td').slice(0, -1);
+ dayBodyCellInners = dayBodyCells.find('div.fc-day-content div');
+ dayBodyFirstCell = dayBodyCells.eq(0);
+ dayBodyFirstCellStretcher = dayBodyFirstCell.find('> div');
+
+ markFirstLast(dayHead.add(dayHead.find('tr')));
+ markFirstLast(dayBody.add(dayBody.find('tr')));
+
+ axisFirstCells = dayHead.find('th:first');
+ gutterCells = dayTable.find('.fc-agenda-gutter');
+
+ slotLayer =
+ $("<div style='position:absolute;z-index:2;left:0;width:100%'/>")
+ .appendTo(element);
+
+ if (opt('allDaySlot')) {
+
+ daySegmentContainer =
+ $("<div style='position:absolute;z-index:8;top:0;left:0'/>")
+ .appendTo(slotLayer);
+
+ s =
+ "<table style='width:100%' class='fc-agenda-allday' cellspacing='0'>" +
+ "<tr>" +
+ "<th class='" + headerClass + " fc-agenda-axis'>" + opt('allDayText') + "</th>" +
+ "<td>" +
+ "<div class='fc-day-content'><div style='position:relative'/></div>" +
+ "</td>" +
+ "<th class='" + headerClass + " fc-agenda-gutter'>&nbsp;</th>" +
+ "</tr>" +
+ "</table>";
+ allDayTable = $(s).appendTo(slotLayer);
+ allDayRow = allDayTable.find('tr');
+
+ dayBind(allDayRow.find('td'));
+
+ axisFirstCells = axisFirstCells.add(allDayTable.find('th:first'));
+ gutterCells = gutterCells.add(allDayTable.find('th.fc-agenda-gutter'));
+
+ slotLayer.append(
+ "<div class='fc-agenda-divider " + headerClass + "'>" +
+ "<div class='fc-agenda-divider-inner'/>" +
+ "</div>"
+ );
+
+ }else{
+
+ daySegmentContainer = $([]); // in jQuery 1.4, we can just do $()
+
+ }
+
+ slotScroller =
+ $("<div style='position:absolute;width:100%;overflow-x:hidden;overflow-y:auto'/>")
+ .appendTo(slotLayer);
+
+ slotContent =
+ $("<div style='position:relative;width:100%;overflow:hidden'/>")
+ .appendTo(slotScroller);
+
+ slotSegmentContainer =
+ $("<div style='position:absolute;z-index:8;top:0;left:0'/>")
+ .appendTo(slotContent);
+
+ s =
+ "<table class='fc-agenda-slots' style='width:100%' cellspacing='0'>" +
+ "<tbody>";
+ d = zeroDate();
+ maxd = addMinutes(cloneDate(d), maxMinute);
+ addMinutes(d, minMinute);
+ slotCnt = 0;
+ for (i=0; d < maxd; i++) {
+ minutes = d.getMinutes();
+ s +=
+ "<tr class='fc-slot" + i + ' ' + (!minutes ? '' : 'fc-minor') + "'>" +
+ "<th class='fc-agenda-axis " + headerClass + "'>" +
+ ((!slotNormal || !minutes) ? formatDate(d, opt('axisFormat')) : '&nbsp;') +
+ "</th>" +
+ "<td class='" + contentClass + "'>" +
+ "<div style='position:relative'>&nbsp;</div>" +
+ "</td>" +
+ "</tr>";
+ addMinutes(d, opt('slotMinutes'));
+ slotCnt++;
+ }
+ s +=
+ "</tbody>" +
+ "</table>";
+ slotTable = $(s).appendTo(slotContent);
+ slotTableFirstInner = slotTable.find('div:first');
+
+ slotBind(slotTable.find('td'));
+
+ axisFirstCells = axisFirstCells.add(slotTable.find('th:first'));
+ }
+
+
+
+ function updateCells() {
+ var i;
+ var headCell;
+ var bodyCell;
+ var date;
+ var today = clearTime(new Date());
+ for (i=0; i<colCnt; i++) {
+ date = colDate(i);
+ headCell = dayHeadCells.eq(i);
+ headCell.html(formatDate(date, colFormat));
+ bodyCell = dayBodyCells.eq(i);
+ if (+date == +today) {
+ bodyCell.addClass(tm + '-state-highlight fc-today');
+ }else{
+ bodyCell.removeClass(tm + '-state-highlight fc-today');
+ }
+ setDayID(headCell.add(bodyCell), date);
+ }
+ }
+
+
+
+ function setHeight(height, dateChanged) {
+ if (height === undefined) {
+ height = viewHeight;
+ }
+ viewHeight = height;
+ slotTopCache = {};
+
+ var headHeight = dayBody.position().top;
+ var allDayHeight = slotScroller.position().top; // including divider
+ var bodyHeight = Math.min( // total body height, including borders
+ height - headHeight, // when scrollbars
+ slotTable.height() + allDayHeight + 1 // when no scrollbars. +1 for bottom border
+ );
+
+ dayBodyFirstCellStretcher
+ .height(bodyHeight - vsides(dayBodyFirstCell));
+
+ slotLayer.css('top', headHeight);
+
+ slotScroller.height(bodyHeight - allDayHeight - 1);
+
+ slotHeight = slotTableFirstInner.height() + 1; // +1 for border
+
+ if (dateChanged) {
+ resetScroll();
+ }
+ }
+
+
+
+ function setWidth(width) {
+ viewWidth = width;
+ colContentPositions.clear();
+
+ axisWidth = 0;
+ setOuterWidth(
+ axisFirstCells
+ .width('')
+ .each(function(i, _cell) {
+ axisWidth = Math.max(axisWidth, $(_cell).outerWidth());
+ }),
+ axisWidth
+ );
+
+ var slotTableWidth = slotScroller[0].clientWidth; // needs to be done after axisWidth (for IE7)
+ //slotTable.width(slotTableWidth);
+
+ gutterWidth = slotScroller.width() - slotTableWidth;
+ if (gutterWidth) {
+ setOuterWidth(gutterCells, gutterWidth);
+ gutterCells
+ .show()
+ .prev()
+ .removeClass('fc-last');
+ }else{
+ gutterCells
+ .hide()
+ .prev()
+ .addClass('fc-last');
+ }
+
+ colWidth = Math.floor((slotTableWidth - axisWidth) / colCnt);
+ setOuterWidth(dayHeadCells.slice(0, -1), colWidth);
+ }
+
+
+
+ function resetScroll() {
+ var d0 = zeroDate();
+ var scrollDate = cloneDate(d0);
+ scrollDate.setHours(opt('firstHour'));
+ var top = timePosition(d0, scrollDate) + 1; // +1 for the border
+ function scroll() {
+ slotScroller.scrollTop(top);
+ }
+ scroll();
+ setTimeout(scroll, 0); // overrides any previous scroll state made by the browser
+ }
+
+
+ function beforeHide() {
+ savedScrollTop = slotScroller.scrollTop();
+ }
+
+
+ function afterShow() {
+ slotScroller.scrollTop(savedScrollTop);
+ }
+
+
+
+ /* Slot/Day clicking and binding
+ -----------------------------------------------------------------------*/
+
+
+ function dayBind(cells) {
+ cells.click(slotClick)
+ .mousedown(daySelectionMousedown);
+ }
+
+
+ function slotBind(cells) {
+ cells.click(slotClick)
+ .mousedown(slotSelectionMousedown);
+ }
+
+
+ function slotClick(ev) {
+ if (!opt('selectable')) { // if selectable, SelectionManager will worry about dayClick
+ var col = Math.min(colCnt-1, Math.floor((ev.pageX - dayTable.offset().left - axisWidth) / colWidth));
+ var date = colDate(col);
+ var rowMatch = this.parentNode.className.match(/fc-slot(\d+)/); // TODO: maybe use data
+ if (rowMatch) {
+ var mins = parseInt(rowMatch[1]) * opt('slotMinutes');
+ var hours = Math.floor(mins/60);
+ date.setHours(hours);
+ date.setMinutes(mins%60 + minMinute);
+ trigger('dayClick', dayBodyCells[col], date, false, ev);
+ }else{
+ trigger('dayClick', dayBodyCells[col], date, true, ev);
+ }
+ }
+ }
+
+
+
+ /* Semi-transparent Overlay Helpers
+ -----------------------------------------------------*/
+
+
+ function renderDayOverlay(startDate, endDate, refreshCoordinateGrid) { // endDate is exclusive
+ if (refreshCoordinateGrid) {
+ coordinateGrid.build();
+ }
+ var visStart = cloneDate(t.visStart);
+ var startCol, endCol;
+ if (rtl) {
+ startCol = dayDiff(endDate, visStart)*dis+dit+1;
+ endCol = dayDiff(startDate, visStart)*dis+dit+1;
+ }else{
+ startCol = dayDiff(startDate, visStart);
+ endCol = dayDiff(endDate, visStart);
+ }
+ startCol = Math.max(0, startCol);
+ endCol = Math.min(colCnt, endCol);
+ if (startCol < endCol) {
+ dayBind(
+ renderCellOverlay(0, startCol, 0, endCol-1)
+ );
+ }
+ }
+
+
+ function renderCellOverlay(row0, col0, row1, col1) { // only for all-day?
+ var rect = coordinateGrid.rect(row0, col0, row1, col1, slotLayer);
+ return renderOverlay(rect, slotLayer);
+ }
+
+
+ function renderSlotOverlay(overlayStart, overlayEnd) {
+ var dayStart = cloneDate(t.visStart);
+ var dayEnd = addDays(cloneDate(dayStart), 1);
+ for (var i=0; i<colCnt; i++) {
+ var stretchStart = new Date(Math.max(dayStart, overlayStart));
+ var stretchEnd = new Date(Math.min(dayEnd, overlayEnd));
+ if (stretchStart < stretchEnd) {
+ var col = i*dis+dit;
+ var rect = coordinateGrid.rect(0, col, 0, col, slotContent); // only use it for horizontal coords
+ var top = timePosition(dayStart, stretchStart);
+ var bottom = timePosition(dayStart, stretchEnd);
+ rect.top = top;
+ rect.height = bottom - top;
+ slotBind(
+ renderOverlay(rect, slotContent)
+ );
+ }
+ addDays(dayStart, 1);
+ addDays(dayEnd, 1);
+ }
+ }
+
+
+
+ /* Coordinate Utilities
+ -----------------------------------------------------------------------------*/
+
+
+ coordinateGrid = new CoordinateGrid(function(rows, cols) {
+ var e, n, p;
+ dayHeadCells.each(function(i, _e) {
+ e = $(_e);
+ n = e.offset().left;
+ if (i) {
+ p[1] = n;
+ }
+ p = [n];
+ cols[i] = p;
+ });
+ p[1] = n + e.outerWidth();
+ if (opt('allDaySlot')) {
+ e = allDayRow;
+ n = e.offset().top;
+ rows[0] = [n, n+e.outerHeight()];
+ }
+ var slotTableTop = slotContent.offset().top;
+ var slotScrollerTop = slotScroller.offset().top;
+ var slotScrollerBottom = slotScrollerTop + slotScroller.outerHeight();
+ function constrain(n) {
+ return Math.max(slotScrollerTop, Math.min(slotScrollerBottom, n));
+ }
+ for (var i=0; i<slotCnt; i++) {
+ rows.push([
+ constrain(slotTableTop + slotHeight*i),
+ constrain(slotTableTop + slotHeight*(i+1))
+ ]);
+ }
+ });
+
+
+ hoverListener = new HoverListener(coordinateGrid);
+
+
+ colContentPositions = new HorizontalPositionCache(function(col) {
+ return dayBodyCellInners.eq(col);
+ });
+
+
+ function colContentLeft(col) {
+ return colContentPositions.left(col);
+ }
+
+
+ function colContentRight(col) {
+ return colContentPositions.right(col);
+ }
+
+
+
+
+ function dateCell(date) { // "cell" terminology is now confusing
+ return {
+ row: Math.floor(dayDiff(date, t.visStart) / 7),
+ col: dayOfWeekCol(date.getDay())
+ };
+ }
+
+
+ function cellDate(cell) {
+ var d = colDate(cell.col);
+ var slotIndex = cell.row;
+ if (opt('allDaySlot')) {
+ slotIndex--;
+ }
+ if (slotIndex >= 0) {
+ addMinutes(d, minMinute + slotIndex * opt('slotMinutes'));
+ }
+ return d;
+ }
+
+
+ function colDate(col) { // returns dates with 00:00:00
+ return addDays(cloneDate(t.visStart), col*dis+dit);
+ }
+
+
+ function cellIsAllDay(cell) {
+ return opt('allDaySlot') && !cell.row;
+ }
+
+
+ function dayOfWeekCol(dayOfWeek) {
+ return ((dayOfWeek - Math.max(firstDay, nwe) + colCnt) % colCnt)*dis+dit;
+ }
+
+
+
+
+ // get the Y coordinate of the given time on the given day (both Date objects)
+ function timePosition(day, time) { // both date objects. day holds 00:00 of current day
+ day = cloneDate(day, true);
+ if (time < addMinutes(cloneDate(day), minMinute)) {
+ return 0;
+ }
+ if (time >= addMinutes(cloneDate(day), maxMinute)) {
+ return slotTable.height();
+ }
+ var slotMinutes = opt('slotMinutes'),
+ minutes = time.getHours()*60 + time.getMinutes() - minMinute,
+ slotI = Math.floor(minutes / slotMinutes),
+ slotTop = slotTopCache[slotI];
+ if (slotTop === undefined) {
+ slotTop = slotTopCache[slotI] = slotTable.find('tr:eq(' + slotI + ') td div')[0].offsetTop; //.position().top; // need this optimization???
+ }
+ return Math.max(0, Math.round(
+ slotTop - 1 + slotHeight * ((minutes % slotMinutes) / slotMinutes)
+ ));
+ }
+
+
+ function allDayBounds() {
+ return {
+ left: axisWidth,
+ right: viewWidth - gutterWidth
+ }
+ }
+
+
+ function getAllDayRow(index) {
+ return allDayRow;
+ }
+
+
+ function defaultEventEnd(event) {
+ var start = cloneDate(event.start);
+ if (event.allDay) {
+ return start;
+ }
+ return addMinutes(start, opt('defaultEventMinutes'));
+ }
+
+
+
+ /* Selection
+ ---------------------------------------------------------------------------------*/
+
+
+ function defaultSelectionEnd(startDate, allDay) {
+ if (allDay) {
+ return cloneDate(startDate);
+ }
+ return addMinutes(cloneDate(startDate), opt('slotMinutes'));
+ }
+
+
+ function renderSelection(startDate, endDate, allDay) { // only for all-day
+ if (allDay) {
+ if (opt('allDaySlot')) {
+ renderDayOverlay(startDate, addDays(cloneDate(endDate), 1), true);
+ }
+ }else{
+ renderSlotSelection(startDate, endDate);
+ }
+ }
+
+
+ function renderSlotSelection(startDate, endDate) {
+ var helperOption = opt('selectHelper');
+ coordinateGrid.build();
+ if (helperOption) {
+ var col = dayDiff(startDate, t.visStart) * dis + dit;
+ if (col >= 0 && col < colCnt) { // only works when times are on same day
+ var rect = coordinateGrid.rect(0, col, 0, col, slotContent); // only for horizontal coords
+ var top = timePosition(startDate, startDate);
+ var bottom = timePosition(startDate, endDate);
+ if (bottom > top) { // protect against selections that are entirely before or after visible range
+ rect.top = top;
+ rect.height = bottom - top;
+ rect.left += 2;
+ rect.width -= 5;
+ if ($.isFunction(helperOption)) {
+ var helperRes = helperOption(startDate, endDate);
+ if (helperRes) {
+ rect.position = 'absolute';
+ rect.zIndex = 8;
+ selectionHelper = $(helperRes)
+ .css(rect)
+ .appendTo(slotContent);
+ }
+ }else{
+ rect.isStart = true; // conside rect a "seg" now
+ rect.isEnd = true; //
+ selectionHelper = $(slotSegHtml(
+ {
+ title: '',
+ start: startDate,
+ end: endDate,
+ className: ['fc-select-helper'],
+ editable: false
+ },
+ rect
+ ));
+ selectionHelper.css('opacity', opt('dragOpacity'));
+ }
+ if (selectionHelper) {
+ slotBind(selectionHelper);
+ slotContent.append(selectionHelper);
+ setOuterWidth(selectionHelper, rect.width, true); // needs to be after appended
+ setOuterHeight(selectionHelper, rect.height, true);
+ }
+ }
+ }
+ }else{
+ renderSlotOverlay(startDate, endDate);
+ }
+ }
+
+
+ function clearSelection() {
+ clearOverlays();
+ if (selectionHelper) {
+ selectionHelper.remove();
+ selectionHelper = null;
+ }
+ }
+
+
+ function slotSelectionMousedown(ev) {
+ if (ev.which == 1 && opt('selectable')) { // ev.which==1 means left mouse button
+ unselect(ev);
+ var dates;
+ hoverListener.start(function(cell, origCell) {
+ clearSelection();
+ if (cell && cell.col == origCell.col && !cellIsAllDay(cell)) {
+ var d1 = cellDate(origCell);
+ var d2 = cellDate(cell);
+ dates = [
+ d1,
+ addMinutes(cloneDate(d1), opt('slotMinutes')),
+ d2,
+ addMinutes(cloneDate(d2), opt('slotMinutes'))
+ ].sort(cmp);
+ renderSlotSelection(dates[0], dates[3]);
+ }else{
+ dates = null;
+ }
+ }, ev);
+ $(document).one('mouseup', function(ev) {
+ hoverListener.stop();
+ if (dates) {
+ if (+dates[0] == +dates[1]) {
+ reportDayClick(dates[0], false, ev);
+ }
+ reportSelection(dates[0], dates[3], false, ev);
+ }
+ });
+ }
+ }
+
+
+ function reportDayClick(date, allDay, ev) {
+ trigger('dayClick', dayBodyCells[dayOfWeekCol(date.getDay())], date, allDay, ev);
+ }
+
+
+
+ /* External Dragging
+ --------------------------------------------------------------------------------*/
+
+
+ function dragStart(_dragElement, ev, ui) {
+ hoverListener.start(function(cell) {
+ clearOverlays();
+ if (cell) {
+ if (cellIsAllDay(cell)) {
+ renderCellOverlay(cell.row, cell.col, cell.row, cell.col);
+ }else{
+ var d1 = cellDate(cell);
+ var d2 = addMinutes(cloneDate(d1), opt('defaultEventMinutes'));
+ renderSlotOverlay(d1, d2);
+ }
+ }
+ }, ev);
+ }
+
+
+ function dragStop(_dragElement, ev, ui) {
+ var cell = hoverListener.stop();
+ clearOverlays();
+ if (cell) {
+ trigger('drop', _dragElement, cellDate(cell), cellIsAllDay(cell), ev, ui);
+ }
+ }
+
+
+}
+
+function AgendaEventRenderer() {
+ var t = this;
+
+
+ // exports
+ t.renderEvents = renderEvents;
+ t.compileDaySegs = compileDaySegs; // for DayEventRenderer
+ t.clearEvents = clearEvents;
+ t.slotSegHtml = slotSegHtml;
+ t.bindDaySeg = bindDaySeg;
+
+
+ // imports
+ DayEventRenderer.call(t);
+ var opt = t.opt;
+ var trigger = t.trigger;
+ //var setOverflowHidden = t.setOverflowHidden;
+ var isEventDraggable = t.isEventDraggable;
+ var isEventResizable = t.isEventResizable;
+ var eventEnd = t.eventEnd;
+ var reportEvents = t.reportEvents;
+ var reportEventClear = t.reportEventClear;
+ var eventElementHandlers = t.eventElementHandlers;
+ var setHeight = t.setHeight;
+ var getDaySegmentContainer = t.getDaySegmentContainer;
+ var getSlotSegmentContainer = t.getSlotSegmentContainer;
+ var getHoverListener = t.getHoverListener;
+ var getMaxMinute = t.getMaxMinute;
+ var getMinMinute = t.getMinMinute;
+ var timePosition = t.timePosition;
+ var colContentLeft = t.colContentLeft;
+ var colContentRight = t.colContentRight;
+ var renderDaySegs = t.renderDaySegs;
+ var resizableDayEvent = t.resizableDayEvent; // TODO: streamline binding architecture
+ var getColCnt = t.getColCnt;
+ var getColWidth = t.getColWidth;
+ var getSlotHeight = t.getSlotHeight;
+ var getBodyContent = t.getBodyContent;
+ var reportEventElement = t.reportEventElement;
+ var showEvents = t.showEvents;
+ var hideEvents = t.hideEvents;
+ var eventDrop = t.eventDrop;
+ var eventResize = t.eventResize;
+ var renderDayOverlay = t.renderDayOverlay;
+ var clearOverlays = t.clearOverlays;
+ var calendar = t.calendar;
+ var formatDate = calendar.formatDate;
+ var formatDates = calendar.formatDates;
+
+
+
+ /* Rendering
+ ----------------------------------------------------------------------------*/
+
+
+ function renderEvents(events, modifiedEventId) {
+ reportEvents(events);
+ var i, len=events.length,
+ dayEvents=[],
+ slotEvents=[];
+ for (i=0; i<len; i++) {
+ if (events[i].allDay) {
+ dayEvents.push(events[i]);
+ }else{
+ slotEvents.push(events[i]);
+ }
+ }
+ if (opt('allDaySlot')) {
+ renderDaySegs(compileDaySegs(dayEvents), modifiedEventId);
+ setHeight(); // no params means set to viewHeight
+ }
+ renderSlotSegs(compileSlotSegs(slotEvents), modifiedEventId);
+ }
+
+
+ function clearEvents() {
+ reportEventClear();
+ getDaySegmentContainer().empty();
+ getSlotSegmentContainer().empty();
+ }
+
+
+ function compileDaySegs(events) {
+ var levels = stackSegs(sliceSegs(events, $.map(events, exclEndDay), t.visStart, t.visEnd)),
+ i, levelCnt=levels.length, level,
+ j, seg,
+ segs=[];
+ for (i=0; i<levelCnt; i++) {
+ level = levels[i];
+ for (j=0; j<level.length; j++) {
+ seg = level[j];
+ seg.row = 0;
+ seg.level = i; // not needed anymore
+ segs.push(seg);
+ }
+ }
+ return segs;
+ }
+
+
+ function compileSlotSegs(events) {
+ var colCnt = getColCnt(),
+ minMinute = getMinMinute(),
+ maxMinute = getMaxMinute(),
+ d = addMinutes(cloneDate(t.visStart), minMinute),
+ visEventEnds = $.map(events, slotEventEnd),
+ i, col,
+ j, level,
+ k, seg,
+ segs=[];
+ for (i=0; i<colCnt; i++) {
+ col = stackSegs(sliceSegs(events, visEventEnds, d, addMinutes(cloneDate(d), maxMinute-minMinute)));
+ countForwardSegs(col);
+ for (j=0; j<col.length; j++) {
+ level = col[j];
+ for (k=0; k<level.length; k++) {
+ seg = level[k];
+ seg.col = i;
+ seg.level = j;
+ segs.push(seg);
+ }
+ }
+ addDays(d, 1, true);
+ }
+ return segs;
+ }
+
+
+ function slotEventEnd(event) {
+ if (event.end) {
+ return cloneDate(event.end);
+ }else{
+ return addMinutes(cloneDate(event.start), opt('defaultEventMinutes'));
+ }
+ }
+
+
+ // renders events in the 'time slots' at the bottom
+
+ function renderSlotSegs(segs, modifiedEventId) {
+
+ var i, segCnt=segs.length, seg,
+ event,
+ classes,
+ top, bottom,
+ colI, levelI, forward,
+ leftmost,
+ availWidth,
+ outerWidth,
+ left,
+ html='',
+ eventElements,
+ eventElement,
+ triggerRes,
+ vsideCache={},
+ hsideCache={},
+ key, val,
+ contentElement,
+ height,
+ slotSegmentContainer = getSlotSegmentContainer(),
+ rtl, dis, dit,
+ colCnt = getColCnt();
+
+ if (rtl = opt('isRTL')) {
+ dis = -1;
+ dit = colCnt - 1;
+ }else{
+ dis = 1;
+ dit = 0;
+ }
+
+ // calculate position/dimensions, create html
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ event = seg.event;
+ top = timePosition(seg.start, seg.start);
+ bottom = timePosition(seg.start, seg.end);
+ colI = seg.col;
+ levelI = seg.level;
+ forward = seg.forward || 0;
+ leftmost = colContentLeft(colI*dis + dit);
+ availWidth = colContentRight(colI*dis + dit) - leftmost;
+ availWidth = Math.min(availWidth-6, availWidth*.95); // TODO: move this to CSS
+ if (levelI) {
+ // indented and thin
+ outerWidth = availWidth / (levelI + forward + 1);
+ }else{
+ if (forward) {
+ // moderately wide, aligned left still
+ outerWidth = ((availWidth / (forward + 1)) - (12/2)) * 2; // 12 is the predicted width of resizer =
+ }else{
+ // can be entire width, aligned left
+ outerWidth = availWidth;
+ }
+ }
+ left = leftmost + // leftmost possible
+ (availWidth / (levelI + forward + 1) * levelI) // indentation
+ * dis + (rtl ? availWidth - outerWidth : 0); // rtl
+ seg.top = top;
+ seg.left = left;
+ seg.outerWidth = outerWidth;
+ seg.outerHeight = bottom - top;
+ html += slotSegHtml(event, seg);
+ }
+ slotSegmentContainer[0].innerHTML = html; // faster than html()
+ eventElements = slotSegmentContainer.children();
+
+ // retrieve elements, run through eventRender callback, bind event handlers
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ event = seg.event;
+ eventElement = $(eventElements[i]); // faster than eq()
+ triggerRes = trigger('eventRender', event, event, eventElement);
+ if (triggerRes === false) {
+ eventElement.remove();
+ }else{
+ if (triggerRes && triggerRes !== true) {
+ eventElement.remove();
+ eventElement = $(triggerRes)
+ .css({
+ position: 'absolute',
+ top: seg.top,
+ left: seg.left
+ })
+ .appendTo(slotSegmentContainer);
+ }
+ seg.element = eventElement;
+ if (event._id === modifiedEventId) {
+ bindSlotSeg(event, eventElement, seg);
+ }else{
+ eventElement[0]._fci = i; // for lazySegBind
+ }
+ reportEventElement(event, eventElement);
+ }
+ }
+
+ lazySegBind(slotSegmentContainer, segs, bindSlotSeg);
+
+ // record event sides and title positions
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ if (eventElement = seg.element) {
+ val = vsideCache[key = seg.key = cssKey(eventElement[0])];
+ seg.vsides = val === undefined ? (vsideCache[key] = vsides(eventElement, true)) : val;
+ val = hsideCache[key];
+ seg.hsides = val === undefined ? (hsideCache[key] = hsides(eventElement, true)) : val;
+ contentElement = eventElement.find('div.fc-event-content');
+ if (contentElement.length) {
+ seg.contentTop = contentElement[0].offsetTop;
+ }
+ }
+ }
+
+ // set all positions/dimensions at once
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ if (eventElement = seg.element) {
+ eventElement[0].style.width = Math.max(0, seg.outerWidth - seg.hsides) + 'px';
+ height = Math.max(0, seg.outerHeight - seg.vsides);
+ eventElement[0].style.height = height + 'px';
+ event = seg.event;
+ if (seg.contentTop !== undefined && height - seg.contentTop < 10) {
+ // not enough room for title, put it in the time header
+ eventElement.find('div.fc-event-time')
+ .text(formatDate(event.start, opt('timeFormat')) + ' - ' + event.title);
+ eventElement.find('div.fc-event-title')
+ .remove();
+ }
+ trigger('eventAfterRender', event, event, eventElement);
+ }
+ }
+
+ }
+
+
+ function slotSegHtml(event, seg) {
+ var html = "<";
+ var url = event.url;
+ var skinCss = getSkinCss(event, opt);
+ var skinCssAttr = (skinCss ? " style='" + skinCss + "'" : '');
+ var classes = ['fc-event', 'fc-event-skin', 'fc-event-vert'];
+ if (isEventDraggable(event)) {
+ classes.push('fc-event-draggable');
+ }
+ if (seg.isStart) {
+ classes.push('fc-corner-top');
+ }
+ if (seg.isEnd) {
+ classes.push('fc-corner-bottom');
+ }
+ classes = classes.concat(event.className);
+ if (event.source) {
+ classes = classes.concat(event.source.className || []);
+ }
+ if (url) {
+ html += "a href='" + htmlEscape(event.url) + "'";
+ }else{
+ html += "div";
+ }
+ html +=
+ " class='" + classes.join(' ') + "'" +
+ " style='position:absolute;z-index:8;top:" + seg.top + "px;left:" + seg.left + "px;" + skinCss + "'" +
+ ">" +
+ "<div class='fc-event-inner fc-event-skin'" + skinCssAttr + ">" +
+ "<div class='fc-event-head fc-event-skin'" + skinCssAttr + ">" +
+ "<div class='fc-event-time'>" +
+ htmlEscape(formatDates(event.start, event.end, opt('timeFormat'))) +
+ "</div>" +
+ "</div>" +
+ "<div class='fc-event-content'>" +
+ "<div class='fc-event-title'>" +
+ htmlEscape(event.title) +
+ "</div>" +
+ "</div>" +
+ "<div class='fc-event-bg'></div>" +
+ "</div>"; // close inner
+ if (seg.isEnd && isEventResizable(event)) {
+ html +=
+ "<div class='ui-resizable-handle ui-resizable-s'>=</div>";
+ }
+ html +=
+ "</" + (url ? "a" : "div") + ">";
+ return html;
+ }
+
+
+ function bindDaySeg(event, eventElement, seg) {
+ if (isEventDraggable(event)) {
+ draggableDayEvent(event, eventElement, seg.isStart);
+ }
+ if (seg.isEnd && isEventResizable(event)) {
+ resizableDayEvent(event, eventElement, seg);
+ }
+ eventElementHandlers(event, eventElement);
+ // needs to be after, because resizableDayEvent might stopImmediatePropagation on click
+ }
+
+
+ function bindSlotSeg(event, eventElement, seg) {
+ var timeElement = eventElement.find('div.fc-event-time');
+ if (isEventDraggable(event)) {
+ draggableSlotEvent(event, eventElement, timeElement);
+ }
+ if (seg.isEnd && isEventResizable(event)) {
+ resizableSlotEvent(event, eventElement, timeElement);
+ }
+ eventElementHandlers(event, eventElement);
+ }
+
+
+
+ /* Dragging
+ -----------------------------------------------------------------------------------*/
+
+
+ // when event starts out FULL-DAY
+
+ function draggableDayEvent(event, eventElement, isStart) {
+ var origWidth;
+ var revert;
+ var allDay=true;
+ var dayDelta;
+ var dis = opt('isRTL') ? -1 : 1;
+ var hoverListener = getHoverListener();
+ var colWidth = getColWidth();
+ var slotHeight = getSlotHeight();
+ var minMinute = getMinMinute();
+ eventElement.draggable({
+ zIndex: 9,
+ opacity: opt('dragOpacity', 'month'), // use whatever the month view was using
+ revertDuration: opt('dragRevertDuration'),
+ start: function(ev, ui) {
+ trigger('eventDragStart', eventElement, event, ev, ui);
+ hideEvents(event, eventElement);
+ origWidth = eventElement.width();
+ hoverListener.start(function(cell, origCell, rowDelta, colDelta) {
+ clearOverlays();
+ if (cell) {
+ //setOverflowHidden(true);
+ revert = false;
+ dayDelta = colDelta * dis;
+ if (!cell.row) {
+ // on full-days
+ renderDayOverlay(
+ addDays(cloneDate(event.start), dayDelta),
+ addDays(exclEndDay(event), dayDelta)
+ );
+ resetElement();
+ }else{
+ // mouse is over bottom slots
+ if (isStart) {
+ if (allDay) {
+ // convert event to temporary slot-event
+ eventElement.width(colWidth - 10); // don't use entire width
+ setOuterHeight(
+ eventElement,
+ slotHeight * Math.round(
+ (event.end ? ((event.end - event.start) / MINUTE_MS) : opt('defaultEventMinutes'))
+ / opt('slotMinutes')
+ )
+ );
+ eventElement.draggable('option', 'grid', [colWidth, 1]);
+ allDay = false;
+ }
+ }else{
+ revert = true;
+ }
+ }
+ revert = revert || (allDay && !dayDelta);
+ }else{
+ resetElement();
+ //setOverflowHidden(false);
+ revert = true;
+ }
+ eventElement.draggable('option', 'revert', revert);
+ }, ev, 'drag');
+ },
+ stop: function(ev, ui) {
+ hoverListener.stop();
+ clearOverlays();
+ trigger('eventDragStop', eventElement, event, ev, ui);
+ if (revert) {
+ // hasn't moved or is out of bounds (draggable has already reverted)
+ resetElement();
+ eventElement.css('filter', ''); // clear IE opacity side-effects
+ showEvents(event, eventElement);
+ }else{
+ // changed!
+ var minuteDelta = 0;
+ if (!allDay) {
+ minuteDelta = Math.round((eventElement.offset().top - getBodyContent().offset().top) / slotHeight)
+ * opt('slotMinutes')
+ + minMinute
+ - (event.start.getHours() * 60 + event.start.getMinutes());
+ }
+ eventDrop(this, event, dayDelta, minuteDelta, allDay, ev, ui);
+ }
+ //setOverflowHidden(false);
+ }
+ });
+ function resetElement() {
+ if (!allDay) {
+ eventElement
+ .width(origWidth)
+ .height('')
+ .draggable('option', 'grid', null);
+ allDay = true;
+ }
+ }
+ }
+
+
+ // when event starts out IN TIMESLOTS
+
+ function draggableSlotEvent(event, eventElement, timeElement) {
+ var origPosition;
+ var allDay=false;
+ var dayDelta;
+ var minuteDelta;
+ var prevMinuteDelta;
+ var dis = opt('isRTL') ? -1 : 1;
+ var hoverListener = getHoverListener();
+ var colCnt = getColCnt();
+ var colWidth = getColWidth();
+ var slotHeight = getSlotHeight();
+ eventElement.draggable({
+ zIndex: 9,
+ scroll: false,
+ grid: [colWidth, slotHeight],
+ axis: colCnt==1 ? 'y' : false,
+ opacity: opt('dragOpacity'),
+ revertDuration: opt('dragRevertDuration'),
+ start: function(ev, ui) {
+ trigger('eventDragStart', eventElement, event, ev, ui);
+ hideEvents(event, eventElement);
+ origPosition = eventElement.position();
+ minuteDelta = prevMinuteDelta = 0;
+ hoverListener.start(function(cell, origCell, rowDelta, colDelta) {
+ eventElement.draggable('option', 'revert', !cell);
+ clearOverlays();
+ if (cell) {
+ dayDelta = colDelta * dis;
+ if (opt('allDaySlot') && !cell.row) {
+ // over full days
+ if (!allDay) {
+ // convert to temporary all-day event
+ allDay = true;
+ timeElement.hide();
+ eventElement.draggable('option', 'grid', null);
+ }
+ renderDayOverlay(
+ addDays(cloneDate(event.start), dayDelta),
+ addDays(exclEndDay(event), dayDelta)
+ );
+ }else{
+ // on slots
+ resetElement();
+ }
+ }
+ }, ev, 'drag');
+ },
+ drag: function(ev, ui) {
+ minuteDelta = Math.round((ui.position.top - origPosition.top) / slotHeight) * opt('slotMinutes');
+ if (minuteDelta != prevMinuteDelta) {
+ if (!allDay) {
+ updateTimeText(minuteDelta);
+ }
+ prevMinuteDelta = minuteDelta;
+ }
+ },
+ stop: function(ev, ui) {
+ var cell = hoverListener.stop();
+ clearOverlays();
+ trigger('eventDragStop', eventElement, event, ev, ui);
+ if (cell && (dayDelta || minuteDelta || allDay)) {
+ // changed!
+ eventDrop(this, event, dayDelta, allDay ? 0 : minuteDelta, allDay, ev, ui);
+ }else{
+ // either no change or out-of-bounds (draggable has already reverted)
+ resetElement();
+ eventElement.css('filter', ''); // clear IE opacity side-effects
+ eventElement.css(origPosition); // sometimes fast drags make event revert to wrong position
+ updateTimeText(0);
+ showEvents(event, eventElement);
+ }
+ }
+ });
+ function updateTimeText(minuteDelta) {
+ var newStart = addMinutes(cloneDate(event.start), minuteDelta);
+ var newEnd;
+ if (event.end) {
+ newEnd = addMinutes(cloneDate(event.end), minuteDelta);
+ }
+ timeElement.text(formatDates(newStart, newEnd, opt('timeFormat')));
+ }
+ function resetElement() {
+ // convert back to original slot-event
+ if (allDay) {
+ timeElement.css('display', ''); // show() was causing display=inline
+ eventElement.draggable('option', 'grid', [colWidth, slotHeight]);
+ allDay = false;
+ }
+ }
+ }
+
+
+
+ /* Resizing
+ --------------------------------------------------------------------------------------*/
+
+
+ function resizableSlotEvent(event, eventElement, timeElement) {
+ var slotDelta, prevSlotDelta;
+ var slotHeight = getSlotHeight();
+ eventElement.resizable({
+ handles: {
+ s: 'div.ui-resizable-s'
+ },
+ grid: slotHeight,
+ start: function(ev, ui) {
+ slotDelta = prevSlotDelta = 0;
+ hideEvents(event, eventElement);
+ eventElement.css('z-index', 9);
+ trigger('eventResizeStart', this, event, ev, ui);
+ },
+ resize: function(ev, ui) {
+ // don't rely on ui.size.height, doesn't take grid into account
+ slotDelta = Math.round((Math.max(slotHeight, eventElement.height()) - ui.originalSize.height) / slotHeight);
+ if (slotDelta != prevSlotDelta) {
+ timeElement.text(
+ formatDates(
+ event.start,
+ (!slotDelta && !event.end) ? null : // no change, so don't display time range
+ addMinutes(eventEnd(event), opt('slotMinutes')*slotDelta),
+ opt('timeFormat')
+ )
+ );
+ prevSlotDelta = slotDelta;
+ }
+ },
+ stop: function(ev, ui) {
+ trigger('eventResizeStop', this, event, ev, ui);
+ if (slotDelta) {
+ eventResize(this, event, 0, opt('slotMinutes')*slotDelta, ev, ui);
+ }else{
+ eventElement.css('z-index', 8);
+ showEvents(event, eventElement);
+ // BUG: if event was really short, need to put title back in span
+ }
+ }
+ });
+ }
+
+
+}
+
+
+function countForwardSegs(levels) {
+ var i, j, k, level, segForward, segBack;
+ for (i=levels.length-1; i>0; i--) {
+ level = levels[i];
+ for (j=0; j<level.length; j++) {
+ segForward = level[j];
+ for (k=0; k<levels[i-1].length; k++) {
+ segBack = levels[i-1][k];
+ if (segsCollide(segForward, segBack)) {
+ segBack.forward = Math.max(segBack.forward||0, (segForward.forward||0)+1);
+ }
+ }
+ }
+ }
+}
+
+
+
+
+function View(element, calendar, viewName) {
+ var t = this;
+
+
+ // exports
+ t.element = element;
+ t.calendar = calendar;
+ t.name = viewName;
+ t.opt = opt;
+ t.trigger = trigger;
+ //t.setOverflowHidden = setOverflowHidden;
+ t.isEventDraggable = isEventDraggable;
+ t.isEventResizable = isEventResizable;
+ t.reportEvents = reportEvents;
+ t.eventEnd = eventEnd;
+ t.reportEventElement = reportEventElement;
+ t.reportEventClear = reportEventClear;
+ t.eventElementHandlers = eventElementHandlers;
+ t.showEvents = showEvents;
+ t.hideEvents = hideEvents;
+ t.eventDrop = eventDrop;
+ t.eventResize = eventResize;
+ // t.title
+ // t.start, t.end
+ // t.visStart, t.visEnd
+
+
+ // imports
+ var defaultEventEnd = t.defaultEventEnd;
+ var normalizeEvent = calendar.normalizeEvent; // in EventManager
+ var reportEventChange = calendar.reportEventChange;
+
+
+ // locals
+ var eventsByID = {};
+ var eventElements = [];
+ var eventElementsByID = {};
+ var options = calendar.options;
+
+
+
+ function opt(name, viewNameOverride) {
+ var v = options[name];
+ if (typeof v == 'object') {
+ return smartProperty(v, viewNameOverride || viewName);
+ }
+ return v;
+ }
+
+
+ function trigger(name, thisObj) {
+ return calendar.trigger.apply(
+ calendar,
+ [name, thisObj || t].concat(Array.prototype.slice.call(arguments, 2), [t])
+ );
+ }
+
+
+ /*
+ function setOverflowHidden(bool) {
+ element.css('overflow', bool ? 'hidden' : '');
+ }
+ */
+
+
+ function isEventDraggable(event) {
+ return isEventEditable(event) && !opt('disableDragging');
+ }
+
+
+ function isEventResizable(event) { // but also need to make sure the seg.isEnd == true
+ return isEventEditable(event) && !opt('disableResizing');
+ }
+
+
+ function isEventEditable(event) {
+ return firstDefined(event.editable, (event.source || {}).editable, opt('editable'));
+ }
+
+
+
+ /* Event Data
+ ------------------------------------------------------------------------------*/
+
+
+ // report when view receives new events
+ function reportEvents(events) { // events are already normalized at this point
+ eventsByID = {};
+ var i, len=events.length, event;
+ for (i=0; i<len; i++) {
+ event = events[i];
+ if (eventsByID[event._id]) {
+ eventsByID[event._id].push(event);
+ }else{
+ eventsByID[event._id] = [event];
+ }
+ }
+ }
+
+
+ // returns a Date object for an event's end
+ function eventEnd(event) {
+ return event.end ? cloneDate(event.end) : defaultEventEnd(event);
+ }
+
+
+
+ /* Event Elements
+ ------------------------------------------------------------------------------*/
+
+
+ // report when view creates an element for an event
+ function reportEventElement(event, element) {
+ eventElements.push(element);
+ if (eventElementsByID[event._id]) {
+ eventElementsByID[event._id].push(element);
+ }else{
+ eventElementsByID[event._id] = [element];
+ }
+ }
+
+
+ function reportEventClear() {
+ eventElements = [];
+ eventElementsByID = {};
+ }
+
+
+ // attaches eventClick, eventMouseover, eventMouseout
+ function eventElementHandlers(event, eventElement) {
+ eventElement
+ .click(function(ev) {
+ if (!eventElement.hasClass('ui-draggable-dragging') &&
+ !eventElement.hasClass('ui-resizable-resizing')) {
+ return trigger('eventClick', this, event, ev);
+ }
+ })
+ .hover(
+ function(ev) {
+ trigger('eventMouseover', this, event, ev);
+ },
+ function(ev) {
+ trigger('eventMouseout', this, event, ev);
+ }
+ );
+ // TODO: don't fire eventMouseover/eventMouseout *while* dragging is occuring (on subject element)
+ // TODO: same for resizing
+ }
+
+
+ function showEvents(event, exceptElement) {
+ eachEventElement(event, exceptElement, 'show');
+ }
+
+
+ function hideEvents(event, exceptElement) {
+ eachEventElement(event, exceptElement, 'hide');
+ }
+
+
+ function eachEventElement(event, exceptElement, funcName) {
+ var elements = eventElementsByID[event._id],
+ i, len = elements.length;
+ for (i=0; i<len; i++) {
+ if (!exceptElement || elements[i][0] != exceptElement[0]) {
+ elements[i][funcName]();
+ }
+ }
+ }
+
+
+
+ /* Event Modification Reporting
+ ---------------------------------------------------------------------------------*/
+
+
+ function eventDrop(e, event, dayDelta, minuteDelta, allDay, ev, ui) {
+ var oldAllDay = event.allDay;
+ var eventId = event._id;
+ moveEvents(eventsByID[eventId], dayDelta, minuteDelta, allDay);
+ trigger(
+ 'eventDrop',
+ e,
+ event,
+ dayDelta,
+ minuteDelta,
+ allDay,
+ function() {
+ // TODO: investigate cases where this inverse technique might not work
+ moveEvents(eventsByID[eventId], -dayDelta, -minuteDelta, oldAllDay);
+ reportEventChange(eventId);
+ },
+ ev,
+ ui
+ );
+ reportEventChange(eventId);
+ }
+
+
+ function eventResize(e, event, dayDelta, minuteDelta, ev, ui) {
+ var eventId = event._id;
+ elongateEvents(eventsByID[eventId], dayDelta, minuteDelta);
+ trigger(
+ 'eventResize',
+ e,
+ event,
+ dayDelta,
+ minuteDelta,
+ function() {
+ // TODO: investigate cases where this inverse technique might not work
+ elongateEvents(eventsByID[eventId], -dayDelta, -minuteDelta);
+ reportEventChange(eventId);
+ },
+ ev,
+ ui
+ );
+ reportEventChange(eventId);
+ }
+
+
+
+ /* Event Modification Math
+ ---------------------------------------------------------------------------------*/
+
+
+ function moveEvents(events, dayDelta, minuteDelta, allDay) {
+ minuteDelta = minuteDelta || 0;
+ for (var e, len=events.length, i=0; i<len; i++) {
+ e = events[i];
+ if (allDay !== undefined) {
+ e.allDay = allDay;
+ }
+ addMinutes(addDays(e.start, dayDelta, true), minuteDelta);
+ if (e.end) {
+ e.end = addMinutes(addDays(e.end, dayDelta, true), minuteDelta);
+ }
+ normalizeEvent(e, options);
+ }
+ }
+
+
+ function elongateEvents(events, dayDelta, minuteDelta) {
+ minuteDelta = minuteDelta || 0;
+ for (var e, len=events.length, i=0; i<len; i++) {
+ e = events[i];
+ e.end = addMinutes(addDays(eventEnd(e), dayDelta, true), minuteDelta);
+ normalizeEvent(e, options);
+ }
+ }
+
+
+}
+
+function DayEventRenderer() {
+ var t = this;
+
+
+ // exports
+ t.renderDaySegs = renderDaySegs;
+ t.resizableDayEvent = resizableDayEvent;
+
+
+ // imports
+ var opt = t.opt;
+ var trigger = t.trigger;
+ var isEventDraggable = t.isEventDraggable;
+ var isEventResizable = t.isEventResizable;
+ var eventEnd = t.eventEnd;
+ var reportEventElement = t.reportEventElement;
+ var showEvents = t.showEvents;
+ var hideEvents = t.hideEvents;
+ var eventResize = t.eventResize;
+ var getRowCnt = t.getRowCnt;
+ var getColCnt = t.getColCnt;
+ var getColWidth = t.getColWidth;
+ var allDayRow = t.allDayRow;
+ var allDayBounds = t.allDayBounds;
+ var colContentLeft = t.colContentLeft;
+ var colContentRight = t.colContentRight;
+ var dayOfWeekCol = t.dayOfWeekCol;
+ var dateCell = t.dateCell;
+ var compileDaySegs = t.compileDaySegs;
+ var getDaySegmentContainer = t.getDaySegmentContainer;
+ var bindDaySeg = t.bindDaySeg; //TODO: streamline this
+ var formatDates = t.calendar.formatDates;
+ var renderDayOverlay = t.renderDayOverlay;
+ var clearOverlays = t.clearOverlays;
+ var clearSelection = t.clearSelection;
+
+
+
+ /* Rendering
+ -----------------------------------------------------------------------------*/
+
+
+ function renderDaySegs(segs, modifiedEventId) {
+ var segmentContainer = getDaySegmentContainer();
+ var rowDivs;
+ var rowCnt = getRowCnt();
+ var colCnt = getColCnt();
+ var i = 0;
+ var rowI;
+ var levelI;
+ var colHeights;
+ var j;
+ var segCnt = segs.length;
+ var seg;
+ var top;
+ var k;
+ segmentContainer[0].innerHTML = daySegHTML(segs); // faster than .html()
+ daySegElementResolve(segs, segmentContainer.children());
+ daySegElementReport(segs);
+ daySegHandlers(segs, segmentContainer, modifiedEventId);
+ daySegCalcHSides(segs);
+ daySegSetWidths(segs);
+ daySegCalcHeights(segs);
+ rowDivs = getRowDivs();
+ // set row heights, calculate event tops (in relation to row top)
+ for (rowI=0; rowI<rowCnt; rowI++) {
+ levelI = 0;
+ colHeights = [];
+ for (j=0; j<colCnt; j++) {
+ colHeights[j] = 0;
+ }
+ while (i<segCnt && (seg = segs[i]).row == rowI) {
+ // loop through segs in a row
+ top = arrayMax(colHeights.slice(seg.startCol, seg.endCol));
+ seg.top = top;
+ top += seg.outerHeight;
+ for (k=seg.startCol; k<seg.endCol; k++) {
+ colHeights[k] = top;
+ }
+ i++;
+ }
+ rowDivs[rowI].height(arrayMax(colHeights));
+ }
+ daySegSetTops(segs, getRowTops(rowDivs));
+ }
+
+
+ function renderTempDaySegs(segs, adjustRow, adjustTop) {
+ var tempContainer = $("<div/>");
+ var elements;
+ var segmentContainer = getDaySegmentContainer();
+ var i;
+ var segCnt = segs.length;
+ var element;
+ tempContainer[0].innerHTML = daySegHTML(segs); // faster than .html()
+ elements = tempContainer.children();
+ segmentContainer.append(elements);
+ daySegElementResolve(segs, elements);
+ daySegCalcHSides(segs);
+ daySegSetWidths(segs);
+ daySegCalcHeights(segs);
+ daySegSetTops(segs, getRowTops(getRowDivs()));
+ elements = [];
+ for (i=0; i<segCnt; i++) {
+ element = segs[i].element;
+ if (element) {
+ if (segs[i].row === adjustRow) {
+ element.css('top', adjustTop);
+ }
+ elements.push(element[0]);
+ }
+ }
+ return $(elements);
+ }
+
+
+ function daySegHTML(segs) { // also sets seg.left and seg.outerWidth
+ var rtl = opt('isRTL');
+ var i;
+ var segCnt=segs.length;
+ var seg;
+ var event;
+ var url;
+ var classes;
+ var bounds = allDayBounds();
+ var minLeft = bounds.left;
+ var maxLeft = bounds.right;
+ var leftCol;
+ var rightCol;
+ var left;
+ var right;
+ var skinCss;
+ var html = '';
+ // calculate desired position/dimensions, create html
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ event = seg.event;
+ classes = ['fc-event', 'fc-event-skin', 'fc-event-hori'];
+ if (isEventDraggable(event)) {
+ classes.push('fc-event-draggable');
+ }
+ if (rtl) {
+ if (seg.isStart) {
+ classes.push('fc-corner-right');
+ }
+ if (seg.isEnd) {
+ classes.push('fc-corner-left');
+ }
+ leftCol = dayOfWeekCol(seg.end.getDay()-1);
+ rightCol = dayOfWeekCol(seg.start.getDay());
+ left = seg.isEnd ? colContentLeft(leftCol) : minLeft;
+ right = seg.isStart ? colContentRight(rightCol) : maxLeft;
+ }else{
+ if (seg.isStart) {
+ classes.push('fc-corner-left');
+ }
+ if (seg.isEnd) {
+ classes.push('fc-corner-right');
+ }
+ leftCol = dayOfWeekCol(seg.start.getDay());
+ rightCol = dayOfWeekCol(seg.end.getDay()-1);
+ left = seg.isStart ? colContentLeft(leftCol) : minLeft;
+ right = seg.isEnd ? colContentRight(rightCol) : maxLeft;
+ }
+ classes = classes.concat(event.className);
+ if (event.source) {
+ classes = classes.concat(event.source.className || []);
+ }
+ url = event.url;
+ skinCss = getSkinCss(event, opt);
+ if (url) {
+ html += "<a href='" + htmlEscape(url) + "'";
+ }else{
+ html += "<div";
+ }
+ html +=
+ " class='" + classes.join(' ') + "'" +
+ " style='position:absolute;z-index:8;left:"+left+"px;" + skinCss + "'" +
+ ">" +
+ "<div" +
+ " class='fc-event-inner fc-event-skin'" +
+ (skinCss ? " style='" + skinCss + "'" : '') +
+ ">";
+ if (!event.allDay && seg.isStart) {
+ html +=
+ "<span class='fc-event-time'>" +
+ htmlEscape(formatDates(event.start, event.end, opt('timeFormat'))) +
+ "</span>";
+ }
+ html +=
+ "<span class='fc-event-title'>" + htmlEscape(event.title) + "</span>" +
+ "</div>";
+ if (seg.isEnd && isEventResizable(event)) {
+ html +=
+ "<div class='ui-resizable-handle ui-resizable-" + (rtl ? 'w' : 'e') + "'>" +
+ "&nbsp;&nbsp;&nbsp;" + // makes hit area a lot better for IE6/7
+ "</div>";
+ }
+ html +=
+ "</" + (url ? "a" : "div" ) + ">";
+ seg.left = left;
+ seg.outerWidth = right - left;
+ seg.startCol = leftCol;
+ seg.endCol = rightCol + 1; // needs to be exclusive
+ }
+ return html;
+ }
+
+
+ function daySegElementResolve(segs, elements) { // sets seg.element
+ var i;
+ var segCnt = segs.length;
+ var seg;
+ var event;
+ var element;
+ var triggerRes;
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ event = seg.event;
+ element = $(elements[i]); // faster than .eq()
+ triggerRes = trigger('eventRender', event, event, element);
+ if (triggerRes === false) {
+ element.remove();
+ }else{
+ if (triggerRes && triggerRes !== true) {
+ triggerRes = $(triggerRes)
+ .css({
+ position: 'absolute',
+ left: seg.left
+ });
+ element.replaceWith(triggerRes);
+ element = triggerRes;
+ }
+ seg.element = element;
+ }
+ }
+ }
+
+
+ function daySegElementReport(segs) {
+ var i;
+ var segCnt = segs.length;
+ var seg;
+ var element;
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ element = seg.element;
+ if (element) {
+ reportEventElement(seg.event, element);
+ }
+ }
+ }
+
+
+ function daySegHandlers(segs, segmentContainer, modifiedEventId) {
+ var i;
+ var segCnt = segs.length;
+ var seg;
+ var element;
+ var event;
+ // retrieve elements, run through eventRender callback, bind handlers
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ element = seg.element;
+ if (element) {
+ event = seg.event;
+ if (event._id === modifiedEventId) {
+ bindDaySeg(event, element, seg);
+ }else{
+ element[0]._fci = i; // for lazySegBind
+ }
+ }
+ }
+ lazySegBind(segmentContainer, segs, bindDaySeg);
+ }
+
+
+ function daySegCalcHSides(segs) { // also sets seg.key
+ var i;
+ var segCnt = segs.length;
+ var seg;
+ var element;
+ var key, val;
+ var hsideCache = {};
+ // record event horizontal sides
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ element = seg.element;
+ if (element) {
+ key = seg.key = cssKey(element[0]);
+ val = hsideCache[key];
+ if (val === undefined) {
+ val = hsideCache[key] = hsides(element, true);
+ }
+ seg.hsides = val;
+ }
+ }
+ }
+
+
+ function daySegSetWidths(segs) {
+ var i;
+ var segCnt = segs.length;
+ var seg;
+ var element;
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ element = seg.element;
+ if (element) {
+ element[0].style.width = Math.max(0, seg.outerWidth - seg.hsides) + 'px';
+ }
+ }
+ }
+
+
+ function daySegCalcHeights(segs) {
+ var i;
+ var segCnt = segs.length;
+ var seg;
+ var element;
+ var key, val;
+ var vmarginCache = {};
+ // record event heights
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ element = seg.element;
+ if (element) {
+ key = seg.key; // created in daySegCalcHSides
+ val = vmarginCache[key];
+ if (val === undefined) {
+ val = vmarginCache[key] = vmargins(element);
+ }
+ seg.outerHeight = element[0].offsetHeight + val;
+ }
+ }
+ }
+
+
+ function getRowDivs() {
+ var i;
+ var rowCnt = getRowCnt();
+ var rowDivs = [];
+ for (i=0; i<rowCnt; i++) {
+ rowDivs[i] = allDayRow(i)
+ .find('td:first div.fc-day-content > div'); // optimal selector?
+ }
+ return rowDivs;
+ }
+
+
+ function getRowTops(rowDivs) {
+ var i;
+ var rowCnt = rowDivs.length;
+ var tops = [];
+ for (i=0; i<rowCnt; i++) {
+ tops[i] = rowDivs[i][0].offsetTop; // !!?? but this means the element needs position:relative if in a table cell!!!!
+ }
+ return tops;
+ }
+
+
+ function daySegSetTops(segs, rowTops) { // also triggers eventAfterRender
+ var i;
+ var segCnt = segs.length;
+ var seg;
+ var element;
+ var event;
+ for (i=0; i<segCnt; i++) {
+ seg = segs[i];
+ element = seg.element;
+ if (element) {
+ element[0].style.top = rowTops[seg.row] + (seg.top||0) + 'px';
+ event = seg.event;
+ trigger('eventAfterRender', event, event, element);
+ }
+ }
+ }
+
+
+
+ /* Resizing
+ -----------------------------------------------------------------------------------*/
+
+
+ function resizableDayEvent(event, element, seg) {
+ var rtl = opt('isRTL');
+ var direction = rtl ? 'w' : 'e';
+ var handle = element.find('div.ui-resizable-' + direction);
+ var isResizing = false;
+
+ // TODO: look into using jquery-ui mouse widget for this stuff
+ disableTextSelection(element); // prevent native <a> selection for IE
+ element
+ .mousedown(function(ev) { // prevent native <a> selection for others
+ ev.preventDefault();
+ })
+ .click(function(ev) {
+ if (isResizing) {
+ ev.preventDefault(); // prevent link from being visited (only method that worked in IE6)
+ ev.stopImmediatePropagation(); // prevent fullcalendar eventClick handler from being called
+ // (eventElementHandlers needs to be bound after resizableDayEvent)
+ }
+ });
+
+ handle.mousedown(function(ev) {
+ if (ev.which != 1) {
+ return; // needs to be left mouse button
+ }
+ isResizing = true;
+ var hoverListener = t.getHoverListener();
+ var rowCnt = getRowCnt();
+ var colCnt = getColCnt();
+ var dis = rtl ? -1 : 1;
+ var dit = rtl ? colCnt-1 : 0;
+ var elementTop = element.css('top');
+ var dayDelta;
+ var helpers;
+ var eventCopy = $.extend({}, event);
+ var minCell = dateCell(event.start);
+ clearSelection();
+ $('body')
+ .css('cursor', direction + '-resize')
+ .one('mouseup', mouseup);
+ trigger('eventResizeStart', this, event, ev);
+ hoverListener.start(function(cell, origCell) {
+ if (cell) {
+ var r = Math.max(minCell.row, cell.row);
+ var c = cell.col;
+ if (rowCnt == 1) {
+ r = 0; // hack for all-day area in agenda views
+ }
+ if (r == minCell.row) {
+ if (rtl) {
+ c = Math.min(minCell.col, c);
+ }else{
+ c = Math.max(minCell.col, c);
+ }
+ }
+ dayDelta = (r*7 + c*dis+dit) - (origCell.row*7 + origCell.col*dis+dit);
+ var newEnd = addDays(eventEnd(event), dayDelta, true);
+ if (dayDelta) {
+ eventCopy.end = newEnd;
+ var oldHelpers = helpers;
+ helpers = renderTempDaySegs(compileDaySegs([eventCopy]), seg.row, elementTop);
+ helpers.find('*').css('cursor', direction + '-resize');
+ if (oldHelpers) {
+ oldHelpers.remove();
+ }
+ hideEvents(event);
+ }else{
+ if (helpers) {
+ showEvents(event);
+ helpers.remove();
+ helpers = null;
+ }
+ }
+ clearOverlays();
+ renderDayOverlay(event.start, addDays(cloneDate(newEnd), 1)); // coordinate grid already rebuild at hoverListener.start
+ }
+ }, ev);
+
+ function mouseup(ev) {
+ trigger('eventResizeStop', this, event, ev);
+ $('body').css('cursor', '');
+ hoverListener.stop();
+ clearOverlays();
+ if (dayDelta) {
+ eventResize(this, event, dayDelta, 0, ev);
+ // event redraw will clear helpers
+ }
+ // otherwise, the drag handler already restored the old events
+
+ setTimeout(function() { // make this happen after the element's click event
+ isResizing = false;
+ },0);
+ }
+
+ });
+ }
+
+
+}
+
+//BUG: unselect needs to be triggered when events are dragged+dropped
+
+function SelectionManager() {
+ var t = this;
+
+
+ // exports
+ t.select = select;
+ t.unselect = unselect;
+ t.reportSelection = reportSelection;
+ t.daySelectionMousedown = daySelectionMousedown;
+
+
+ // imports
+ var opt = t.opt;
+ var trigger = t.trigger;
+ var defaultSelectionEnd = t.defaultSelectionEnd;
+ var renderSelection = t.renderSelection;
+ var clearSelection = t.clearSelection;
+
+
+ // locals
+ var selected = false;
+
+
+
+ // unselectAuto
+ if (opt('selectable') && opt('unselectAuto')) {
+ $(document).mousedown(function(ev) {
+ var ignore = opt('unselectCancel');
+ if (ignore) {
+ if ($(ev.target).parents(ignore).length) { // could be optimized to stop after first match
+ return;
+ }
+ }
+ unselect(ev);
+ });
+ }
+
+
+ function select(startDate, endDate, allDay) {
+ unselect();
+ if (!endDate) {
+ endDate = defaultSelectionEnd(startDate, allDay);
+ }
+ renderSelection(startDate, endDate, allDay);
+ reportSelection(startDate, endDate, allDay);
+ }
+
+
+ function unselect(ev) {
+ if (selected) {
+ selected = false;
+ clearSelection();
+ trigger('unselect', null, ev);
+ }
+ }
+
+
+ function reportSelection(startDate, endDate, allDay, ev) {
+ selected = true;
+ trigger('select', null, startDate, endDate, allDay, ev);
+ }
+
+
+ function daySelectionMousedown(ev) { // not really a generic manager method, oh well
+ var cellDate = t.cellDate;
+ var cellIsAllDay = t.cellIsAllDay;
+ var hoverListener = t.getHoverListener();
+ var reportDayClick = t.reportDayClick; // this is hacky and sort of weird
+ if (ev.which == 1 && opt('selectable')) { // which==1 means left mouse button
+ unselect(ev);
+ var _mousedownElement = this;
+ var dates;
+ hoverListener.start(function(cell, origCell) { // TODO: maybe put cellDate/cellIsAllDay info in cell
+ clearSelection();
+ if (cell && cellIsAllDay(cell)) {
+ dates = [ cellDate(origCell), cellDate(cell) ].sort(cmp);
+ renderSelection(dates[0], dates[1], true);
+ }else{
+ dates = null;
+ }
+ }, ev);
+ $(document).one('mouseup', function(ev) {
+ hoverListener.stop();
+ if (dates) {
+ if (+dates[0] == +dates[1]) {
+ reportDayClick(dates[0], true, ev);
+ }
+ reportSelection(dates[0], dates[1], true, ev);
+ }
+ });
+ }
+ }
+
+
+}
+
+function OverlayManager() {
+ var t = this;
+
+
+ // exports
+ t.renderOverlay = renderOverlay;
+ t.clearOverlays = clearOverlays;
+
+
+ // locals
+ var usedOverlays = [];
+ var unusedOverlays = [];
+
+
+ function renderOverlay(rect, parent) {
+ var e = unusedOverlays.shift();
+ if (!e) {
+ e = $("<div class='fc-cell-overlay' style='position:absolute;z-index:3'/>");
+ }
+ if (e[0].parentNode != parent[0]) {
+ e.appendTo(parent);
+ }
+ usedOverlays.push(e.css(rect).show());
+ return e;
+ }
+
+
+ function clearOverlays() {
+ var e;
+ while (e = usedOverlays.shift()) {
+ unusedOverlays.push(e.hide().unbind());
+ }
+ }
+
+
+}
+
+function CoordinateGrid(buildFunc) {
+
+ var t = this;
+ var rows;
+ var cols;
+
+
+ t.build = function() {
+ rows = [];
+ cols = [];
+ buildFunc(rows, cols);
+ };
+
+
+ t.cell = function(x, y) {
+ var rowCnt = rows.length;
+ var colCnt = cols.length;
+ var i, r=-1, c=-1;
+ for (i=0; i<rowCnt; i++) {
+ if (y >= rows[i][0] && y < rows[i][1]) {
+ r = i;
+ break;
+ }
+ }
+ for (i=0; i<colCnt; i++) {
+ if (x >= cols[i][0] && x < cols[i][1]) {
+ c = i;
+ break;
+ }
+ }
+ return (r>=0 && c>=0) ? { row:r, col:c } : null;
+ };
+
+
+ t.rect = function(row0, col0, row1, col1, originElement) { // row1,col1 is inclusive
+ var origin = originElement.offset();
+ return {
+ top: rows[row0][0] - origin.top,
+ left: cols[col0][0] - origin.left,
+ width: cols[col1][1] - cols[col0][0],
+ height: rows[row1][1] - rows[row0][0]
+ };
+ };
+
+}
+
+function HoverListener(coordinateGrid) {
+
+
+ var t = this;
+ var bindType;
+ var change;
+ var firstCell;
+ var cell;
+
+
+ t.start = function(_change, ev, _bindType) {
+ change = _change;
+ firstCell = cell = null;
+ coordinateGrid.build();
+ mouse(ev);
+ bindType = _bindType || 'mousemove';
+ $(document).bind(bindType, mouse);
+ };
+
+
+ function mouse(ev) {
+ var newCell = coordinateGrid.cell(ev.pageX, ev.pageY);
+ if (!newCell != !cell || newCell && (newCell.row != cell.row || newCell.col != cell.col)) {
+ if (newCell) {
+ if (!firstCell) {
+ firstCell = newCell;
+ }
+ change(newCell, firstCell, newCell.row-firstCell.row, newCell.col-firstCell.col);
+ }else{
+ change(newCell, firstCell);
+ }
+ cell = newCell;
+ }
+ }
+
+
+ t.stop = function() {
+ $(document).unbind(bindType, mouse);
+ return cell;
+ };
+
+
+}
+
+function HorizontalPositionCache(getElement) {
+
+ var t = this,
+ elements = {},
+ lefts = {},
+ rights = {};
+
+ function e(i) {
+ return elements[i] = elements[i] || getElement(i);
+ }
+
+ t.left = function(i) {
+ return lefts[i] = lefts[i] === undefined ? e(i).position().left : lefts[i];
+ };
+
+ t.right = function(i) {
+ return rights[i] = rights[i] === undefined ? t.left(i) + e(i).width() : rights[i];
+ };
+
+ t.clear = function() {
+ elements = {};
+ lefts = {};
+ rights = {};
+ };
+
+}
+
+})(jQuery);
diff --git a/3rdparty/fullcalendar/js/fullcalendar.min.js b/3rdparty/fullcalendar/js/fullcalendar.min.js
new file mode 100644
index 00000000000..fc06a89a610
--- /dev/null
+++ b/3rdparty/fullcalendar/js/fullcalendar.min.js
@@ -0,0 +1,113 @@
+/*
+
+ FullCalendar v1.5.2
+ http://arshaw.com/fullcalendar/
+
+ Use fullcalendar.css for basic styling.
+ For event drag & drop, requires jQuery UI draggable.
+ For event resizing, requires jQuery UI resizable.
+
+ Copyright (c) 2011 Adam Shaw
+ Dual licensed under the MIT and GPL licenses, located in
+ MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
+
+ Date: Sun Aug 21 22:06:09 2011 -0700
+
+*/
+(function(m,oa){function wb(a){m.extend(true,Ya,a)}function Yb(a,b,e){function d(k){if(E){u();q();ma();S(k)}else f()}function f(){B=b.theme?"ui":"fc";a.addClass("fc");b.isRTL&&a.addClass("fc-rtl");b.theme&&a.addClass("ui-widget");E=m("<div class='fc-content' style='position:relative'/>").prependTo(a);C=new Zb(X,b);(P=C.render())&&a.prepend(P);y(b.defaultView);m(window).resize(na);t()||g()}function g(){setTimeout(function(){!n.start&&t()&&S()},0)}function l(){m(window).unbind("resize",na);C.destroy();
+E.remove();a.removeClass("fc fc-rtl ui-widget")}function j(){return i.offsetWidth!==0}function t(){return m("body")[0].offsetWidth!==0}function y(k){if(!n||k!=n.name){F++;pa();var D=n,Z;if(D){(D.beforeHide||xb)();Za(E,E.height());D.element.hide()}else Za(E,1);E.css("overflow","hidden");if(n=Y[k])n.element.show();else n=Y[k]=new Ja[k](Z=s=m("<div class='fc-view fc-view-"+k+"' style='position:absolute'/>").appendTo(E),X);D&&C.deactivateButton(D.name);C.activateButton(k);S();E.css("overflow","");D&&
+Za(E,1);Z||(n.afterShow||xb)();F--}}function S(k){if(j()){F++;pa();o===oa&&u();var D=false;if(!n.start||k||r<n.start||r>=n.end){n.render(r,k||0);fa(true);D=true}else if(n.sizeDirty){n.clearEvents();fa();D=true}else if(n.eventsDirty){n.clearEvents();D=true}n.sizeDirty=false;n.eventsDirty=false;ga(D);W=a.outerWidth();C.updateTitle(n.title);k=new Date;k>=n.start&&k<n.end?C.disableButton("today"):C.enableButton("today");F--;n.trigger("viewDisplay",i)}}function Q(){q();if(j()){u();fa();pa();n.clearEvents();
+n.renderEvents(J);n.sizeDirty=false}}function q(){m.each(Y,function(k,D){D.sizeDirty=true})}function u(){o=b.contentHeight?b.contentHeight:b.height?b.height-(P?P.height():0)-Sa(E):Math.round(E.width()/Math.max(b.aspectRatio,0.5))}function fa(k){F++;n.setHeight(o,k);if(s){s.css("position","relative");s=null}n.setWidth(E.width(),k);F--}function na(){if(!F)if(n.start){var k=++v;setTimeout(function(){if(k==v&&!F&&j())if(W!=(W=a.outerWidth())){F++;Q();n.trigger("windowResize",i);F--}},200)}else g()}function ga(k){if(!b.lazyFetching||
+ya(n.visStart,n.visEnd))ra();else k&&da()}function ra(){K(n.visStart,n.visEnd)}function sa(k){J=k;da()}function ha(k){da(k)}function da(k){ma();if(j()){n.clearEvents();n.renderEvents(J,k);n.eventsDirty=false}}function ma(){m.each(Y,function(k,D){D.eventsDirty=true})}function ua(k,D,Z){n.select(k,D,Z===oa?true:Z)}function pa(){n&&n.unselect()}function U(){S(-1)}function ca(){S(1)}function ka(){gb(r,-1);S()}function qa(){gb(r,1);S()}function G(){r=new Date;S()}function p(k,D,Z){if(k instanceof Date)r=
+N(k);else yb(r,k,D,Z);S()}function L(k,D,Z){k!==oa&&gb(r,k);D!==oa&&hb(r,D);Z!==oa&&ba(r,Z);S()}function c(){return N(r)}function z(){return n}function H(k,D){if(D===oa)return b[k];if(k=="height"||k=="contentHeight"||k=="aspectRatio"){b[k]=D;Q()}}function T(k,D){if(b[k])return b[k].apply(D||i,Array.prototype.slice.call(arguments,2))}var X=this;X.options=b;X.render=d;X.destroy=l;X.refetchEvents=ra;X.reportEvents=sa;X.reportEventChange=ha;X.rerenderEvents=da;X.changeView=y;X.select=ua;X.unselect=pa;
+X.prev=U;X.next=ca;X.prevYear=ka;X.nextYear=qa;X.today=G;X.gotoDate=p;X.incrementDate=L;X.formatDate=function(k,D){return Oa(k,D,b)};X.formatDates=function(k,D,Z){return ib(k,D,Z,b)};X.getDate=c;X.getView=z;X.option=H;X.trigger=T;$b.call(X,b,e);var ya=X.isFetchNeeded,K=X.fetchEvents,i=a[0],C,P,E,B,n,Y={},W,o,s,v=0,F=0,r=new Date,J=[],M;yb(r,b.year,b.month,b.date);b.droppable&&m(document).bind("dragstart",function(k,D){var Z=k.target,ja=m(Z);if(!ja.parents(".fc").length){var ia=b.dropAccept;if(m.isFunction(ia)?
+ia.call(Z,ja):ja.is(ia)){M=Z;n.dragStart(M,k,D)}}}).bind("dragstop",function(k,D){if(M){n.dragStop(M,k,D);M=null}})}function Zb(a,b){function e(){q=b.theme?"ui":"fc";if(b.header)return Q=m("<table class='fc-header' style='width:100%'/>").append(m("<tr/>").append(f("left")).append(f("center")).append(f("right")))}function d(){Q.remove()}function f(u){var fa=m("<td class='fc-header-"+u+"'/>");(u=b.header[u])&&m.each(u.split(" "),function(na){na>0&&fa.append("<span class='fc-header-space'/>");var ga;
+m.each(this.split(","),function(ra,sa){if(sa=="title"){fa.append("<span class='fc-header-title'><h2>&nbsp;</h2></span>");ga&&ga.addClass(q+"-corner-right");ga=null}else{var ha;if(a[sa])ha=a[sa];else if(Ja[sa])ha=function(){ma.removeClass(q+"-state-hover");a.changeView(sa)};if(ha){ra=b.theme?jb(b.buttonIcons,sa):null;var da=jb(b.buttonText,sa),ma=m("<span class='fc-button fc-button-"+sa+" "+q+"-state-default'><span class='fc-button-inner'><span class='fc-button-content'>"+(ra?"<span class='fc-icon-wrap'><span class='ui-icon ui-icon-"+
+ra+"'/></span>":da)+"</span><span class='fc-button-effect'><span></span></span></span></span>");if(ma){ma.click(function(){ma.hasClass(q+"-state-disabled")||ha()}).mousedown(function(){ma.not("."+q+"-state-active").not("."+q+"-state-disabled").addClass(q+"-state-down")}).mouseup(function(){ma.removeClass(q+"-state-down")}).hover(function(){ma.not("."+q+"-state-active").not("."+q+"-state-disabled").addClass(q+"-state-hover")},function(){ma.removeClass(q+"-state-hover").removeClass(q+"-state-down")}).appendTo(fa);
+ga||ma.addClass(q+"-corner-left");ga=ma}}}});ga&&ga.addClass(q+"-corner-right")});return fa}function g(u){Q.find("h2").html(u)}function l(u){Q.find("span.fc-button-"+u).addClass(q+"-state-active")}function j(u){Q.find("span.fc-button-"+u).removeClass(q+"-state-active")}function t(u){Q.find("span.fc-button-"+u).addClass(q+"-state-disabled")}function y(u){Q.find("span.fc-button-"+u).removeClass(q+"-state-disabled")}var S=this;S.render=e;S.destroy=d;S.updateTitle=g;S.activateButton=l;S.deactivateButton=
+j;S.disableButton=t;S.enableButton=y;var Q=m([]),q}function $b(a,b){function e(c,z){return!ca||c<ca||z>ka}function d(c,z){ca=c;ka=z;L=[];c=++qa;G=z=U.length;for(var H=0;H<z;H++)f(U[H],c)}function f(c,z){g(c,function(H){if(z==qa){if(H){for(var T=0;T<H.length;T++){H[T].source=c;na(H[T])}L=L.concat(H)}G--;G||ua(L)}})}function g(c,z){var H,T=Aa.sourceFetchers,X;for(H=0;H<T.length;H++){X=T[H](c,ca,ka,z);if(X===true)return;else if(typeof X=="object"){g(X,z);return}}if(H=c.events)if(m.isFunction(H)){u();
+H(N(ca),N(ka),function(C){z(C);fa()})}else m.isArray(H)?z(H):z();else if(c.url){var ya=c.success,K=c.error,i=c.complete;H=m.extend({},c.data||{});T=Ta(c.startParam,a.startParam);X=Ta(c.endParam,a.endParam);if(T)H[T]=Math.round(+ca/1E3);if(X)H[X]=Math.round(+ka/1E3);u();m.ajax(m.extend({},ac,c,{data:H,success:function(C){C=C||[];var P=$a(ya,this,arguments);if(m.isArray(P))C=P;z(C)},error:function(){$a(K,this,arguments);z()},complete:function(){$a(i,this,arguments);fa()}}))}else z()}function l(c){if(c=
+j(c)){G++;f(c,qa)}}function j(c){if(m.isFunction(c)||m.isArray(c))c={events:c};else if(typeof c=="string")c={url:c};if(typeof c=="object"){ga(c);U.push(c);return c}}function t(c){U=m.grep(U,function(z){return!ra(z,c)});L=m.grep(L,function(z){return!ra(z.source,c)});ua(L)}function y(c){var z,H=L.length,T,X=ma().defaultEventEnd,ya=c.start-c._start,K=c.end?c.end-(c._end||X(c)):0;for(z=0;z<H;z++){T=L[z];if(T._id==c._id&&T!=c){T.start=new Date(+T.start+ya);T.end=c.end?T.end?new Date(+T.end+K):new Date(+X(T)+
+K):null;T.title=c.title;T.url=c.url;T.allDay=c.allDay;T.className=c.className;T.editable=c.editable;T.color=c.color;T.backgroudColor=c.backgroudColor;T.borderColor=c.borderColor;T.textColor=c.textColor;na(T)}}na(c);ua(L)}function S(c,z){na(c);if(!c.source){if(z){pa.events.push(c);c.source=pa}L.push(c)}ua(L)}function Q(c){if(c){if(!m.isFunction(c)){var z=c+"";c=function(T){return T._id==z}}L=m.grep(L,c,true);for(H=0;H<U.length;H++)if(m.isArray(U[H].events))U[H].events=m.grep(U[H].events,c,true)}else{L=
+[];for(var H=0;H<U.length;H++)if(m.isArray(U[H].events))U[H].events=[]}ua(L)}function q(c){if(m.isFunction(c))return m.grep(L,c);else if(c){c+="";return m.grep(L,function(z){return z._id==c})}return L}function u(){p++||da("loading",null,true)}function fa(){--p||da("loading",null,false)}function na(c){var z=c.source||{},H=Ta(z.ignoreTimezone,a.ignoreTimezone);c._id=c._id||(c.id===oa?"_fc"+bc++:c.id+"");if(c.date){if(!c.start)c.start=c.date;delete c.date}c._start=N(c.start=kb(c.start,H));c.end=kb(c.end,
+H);if(c.end&&c.end<=c.start)c.end=null;c._end=c.end?N(c.end):null;if(c.allDay===oa)c.allDay=Ta(z.allDayDefault,a.allDayDefault);if(c.className){if(typeof c.className=="string")c.className=c.className.split(/\s+/)}else c.className=[]}function ga(c){if(c.className){if(typeof c.className=="string")c.className=c.className.split(/\s+/)}else c.className=[];for(var z=Aa.sourceNormalizers,H=0;H<z.length;H++)z[H](c)}function ra(c,z){return c&&z&&sa(c)==sa(z)}function sa(c){return(typeof c=="object"?c.events||
+c.url:"")||c}var ha=this;ha.isFetchNeeded=e;ha.fetchEvents=d;ha.addEventSource=l;ha.removeEventSource=t;ha.updateEvent=y;ha.renderEvent=S;ha.removeEvents=Q;ha.clientEvents=q;ha.normalizeEvent=na;var da=ha.trigger,ma=ha.getView,ua=ha.reportEvents,pa={events:[]},U=[pa],ca,ka,qa=0,G=0,p=0,L=[];for(ha=0;ha<b.length;ha++)j(b[ha])}function gb(a,b,e){a.setFullYear(a.getFullYear()+b);e||Ka(a);return a}function hb(a,b,e){if(+a){b=a.getMonth()+b;var d=N(a);d.setDate(1);d.setMonth(b);a.setMonth(b);for(e||Ka(a);a.getMonth()!=
+d.getMonth();)a.setDate(a.getDate()+(a<d?1:-1))}return a}function ba(a,b,e){if(+a){b=a.getDate()+b;var d=N(a);d.setHours(9);d.setDate(b);a.setDate(b);e||Ka(a);lb(a,d)}return a}function lb(a,b){if(+a)for(;a.getDate()!=b.getDate();)a.setTime(+a+(a<b?1:-1)*cc)}function xa(a,b){a.setMinutes(a.getMinutes()+b);return a}function Ka(a){a.setHours(0);a.setMinutes(0);a.setSeconds(0);a.setMilliseconds(0);return a}function N(a,b){if(b)return Ka(new Date(+a));return new Date(+a)}function zb(){var a=0,b;do b=new Date(1970,
+a++,1);while(b.getHours());return b}function Fa(a,b,e){for(b=b||1;!a.getDay()||e&&a.getDay()==1||!e&&a.getDay()==6;)ba(a,b);return a}function Ca(a,b){return Math.round((N(a,true)-N(b,true))/Ab)}function yb(a,b,e,d){if(b!==oa&&b!=a.getFullYear()){a.setDate(1);a.setMonth(0);a.setFullYear(b)}if(e!==oa&&e!=a.getMonth()){a.setDate(1);a.setMonth(e)}d!==oa&&a.setDate(d)}function kb(a,b){if(typeof a=="object")return a;if(typeof a=="number")return new Date(a*1E3);if(typeof a=="string"){if(a.match(/^\d+(\.\d+)?$/))return new Date(parseFloat(a)*
+1E3);if(b===oa)b=true;return Bb(a,b)||(a?new Date(a):null)}return null}function Bb(a,b){a=a.match(/^([0-9]{4})(-([0-9]{2})(-([0-9]{2})([T ]([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?(Z|(([-+])([0-9]{2})(:?([0-9]{2}))?))?)?)?)?$/);if(!a)return null;var e=new Date(a[1],0,1);if(b||!a[13]){b=new Date(a[1],0,1,9,0);if(a[3]){e.setMonth(a[3]-1);b.setMonth(a[3]-1)}if(a[5]){e.setDate(a[5]);b.setDate(a[5])}lb(e,b);a[7]&&e.setHours(a[7]);a[8]&&e.setMinutes(a[8]);a[10]&&e.setSeconds(a[10]);a[12]&&e.setMilliseconds(Number("0."+
+a[12])*1E3);lb(e,b)}else{e.setUTCFullYear(a[1],a[3]?a[3]-1:0,a[5]||1);e.setUTCHours(a[7]||0,a[8]||0,a[10]||0,a[12]?Number("0."+a[12])*1E3:0);if(a[14]){b=Number(a[16])*60+(a[18]?Number(a[18]):0);b*=a[15]=="-"?1:-1;e=new Date(+e+b*60*1E3)}}return e}function mb(a){if(typeof a=="number")return a*60;if(typeof a=="object")return a.getHours()*60+a.getMinutes();if(a=a.match(/(\d+)(?::(\d+))?\s*(\w+)?/)){var b=parseInt(a[1],10);if(a[3]){b%=12;if(a[3].toLowerCase().charAt(0)=="p")b+=12}return b*60+(a[2]?parseInt(a[2],
+10):0)}}function Oa(a,b,e){return ib(a,null,b,e)}function ib(a,b,e,d){d=d||Ya;var f=a,g=b,l,j=e.length,t,y,S,Q="";for(l=0;l<j;l++){t=e.charAt(l);if(t=="'")for(y=l+1;y<j;y++){if(e.charAt(y)=="'"){if(f){Q+=y==l+1?"'":e.substring(l+1,y);l=y}break}}else if(t=="(")for(y=l+1;y<j;y++){if(e.charAt(y)==")"){l=Oa(f,e.substring(l+1,y),d);if(parseInt(l.replace(/\D/,""),10))Q+=l;l=y;break}}else if(t=="[")for(y=l+1;y<j;y++){if(e.charAt(y)=="]"){t=e.substring(l+1,y);l=Oa(f,t,d);if(l!=Oa(g,t,d))Q+=l;l=y;break}}else if(t==
+"{"){f=b;g=a}else if(t=="}"){f=a;g=b}else{for(y=j;y>l;y--)if(S=dc[e.substring(l,y)]){if(f)Q+=S(f,d);l=y-1;break}if(y==l)if(f)Q+=t}}return Q}function Ua(a){return a.end?ec(a.end,a.allDay):ba(N(a.start),1)}function ec(a,b){a=N(a);return b||a.getHours()||a.getMinutes()?ba(a,1):Ka(a)}function fc(a,b){return(b.msLength-a.msLength)*100+(a.event.start-b.event.start)}function Cb(a,b){return a.end>b.start&&a.start<b.end}function nb(a,b,e,d){var f=[],g,l=a.length,j,t,y,S,Q;for(g=0;g<l;g++){j=a[g];t=j.start;
+y=b[g];if(y>e&&t<d){if(t<e){t=N(e);S=false}else{t=t;S=true}if(y>d){y=N(d);Q=false}else{y=y;Q=true}f.push({event:j,start:t,end:y,isStart:S,isEnd:Q,msLength:y-t})}}return f.sort(fc)}function ob(a){var b=[],e,d=a.length,f,g,l,j;for(e=0;e<d;e++){f=a[e];for(g=0;;){l=false;if(b[g])for(j=0;j<b[g].length;j++)if(Cb(b[g][j],f)){l=true;break}if(l)g++;else break}if(b[g])b[g].push(f);else b[g]=[f]}return b}function Db(a,b,e){a.unbind("mouseover").mouseover(function(d){for(var f=d.target,g;f!=this;){g=f;f=f.parentNode}if((f=
+g._fci)!==oa){g._fci=oa;g=b[f];e(g.event,g.element,g);m(d.target).trigger(d)}d.stopPropagation()})}function Va(a,b,e){for(var d=0,f;d<a.length;d++){f=m(a[d]);f.width(Math.max(0,b-pb(f,e)))}}function Eb(a,b,e){for(var d=0,f;d<a.length;d++){f=m(a[d]);f.height(Math.max(0,b-Sa(f,e)))}}function pb(a,b){return gc(a)+hc(a)+(b?ic(a):0)}function gc(a){return(parseFloat(m.curCSS(a[0],"paddingLeft",true))||0)+(parseFloat(m.curCSS(a[0],"paddingRight",true))||0)}function ic(a){return(parseFloat(m.curCSS(a[0],
+"marginLeft",true))||0)+(parseFloat(m.curCSS(a[0],"marginRight",true))||0)}function hc(a){return(parseFloat(m.curCSS(a[0],"borderLeftWidth",true))||0)+(parseFloat(m.curCSS(a[0],"borderRightWidth",true))||0)}function Sa(a,b){return jc(a)+kc(a)+(b?Fb(a):0)}function jc(a){return(parseFloat(m.curCSS(a[0],"paddingTop",true))||0)+(parseFloat(m.curCSS(a[0],"paddingBottom",true))||0)}function Fb(a){return(parseFloat(m.curCSS(a[0],"marginTop",true))||0)+(parseFloat(m.curCSS(a[0],"marginBottom",true))||0)}
+function kc(a){return(parseFloat(m.curCSS(a[0],"borderTopWidth",true))||0)+(parseFloat(m.curCSS(a[0],"borderBottomWidth",true))||0)}function Za(a,b){b=typeof b=="number"?b+"px":b;a.each(function(e,d){d.style.cssText+=";min-height:"+b+";_height:"+b})}function xb(){}function Gb(a,b){return a-b}function Hb(a){return Math.max.apply(Math,a)}function Pa(a){return(a<10?"0":"")+a}function jb(a,b){if(a[b]!==oa)return a[b];b=b.split(/(?=[A-Z])/);for(var e=b.length-1,d;e>=0;e--){d=a[b[e].toLowerCase()];if(d!==
+oa)return d}return a[""]}function Qa(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#039;").replace(/"/g,"&quot;").replace(/\n/g,"<br />")}function Ib(a){return a.id+"/"+a.className+"/"+a.style.cssText.replace(/(^|;)\s*(top|left|width|height)\s*:[^;]*/ig,"")}function qb(a){a.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false})}function ab(a){a.children().removeClass("fc-first fc-last").filter(":first-child").addClass("fc-first").end().filter(":last-child").addClass("fc-last")}
+function rb(a,b){a.each(function(e,d){d.className=d.className.replace(/^fc-\w*/,"fc-"+lc[b.getDay()])})}function Jb(a,b){var e=a.source||{},d=a.color,f=e.color,g=b("eventColor"),l=a.backgroundColor||d||e.backgroundColor||f||b("eventBackgroundColor")||g;d=a.borderColor||d||e.borderColor||f||b("eventBorderColor")||g;a=a.textColor||e.textColor||b("eventTextColor");b=[];l&&b.push("background-color:"+l);d&&b.push("border-color:"+d);a&&b.push("color:"+a);return b.join(";")}function $a(a,b,e){if(m.isFunction(a))a=
+[a];if(a){var d,f;for(d=0;d<a.length;d++)f=a[d].apply(b,e)||f;return f}}function Ta(){for(var a=0;a<arguments.length;a++)if(arguments[a]!==oa)return arguments[a]}function mc(a,b){function e(j,t){if(t){hb(j,t);j.setDate(1)}j=N(j,true);j.setDate(1);t=hb(N(j),1);var y=N(j),S=N(t),Q=f("firstDay"),q=f("weekends")?0:1;if(q){Fa(y);Fa(S,-1,true)}ba(y,-((y.getDay()-Math.max(Q,q)+7)%7));ba(S,(7-S.getDay()+Math.max(Q,q))%7);Q=Math.round((S-y)/(Ab*7));if(f("weekMode")=="fixed"){ba(S,(6-Q)*7);Q=6}d.title=l(j,
+f("titleFormat"));d.start=j;d.end=t;d.visStart=y;d.visEnd=S;g(6,Q,q?5:7,true)}var d=this;d.render=e;sb.call(d,a,b,"month");var f=d.opt,g=d.renderBasic,l=b.formatDate}function nc(a,b){function e(j,t){t&&ba(j,t*7);j=ba(N(j),-((j.getDay()-f("firstDay")+7)%7));t=ba(N(j),7);var y=N(j),S=N(t),Q=f("weekends");if(!Q){Fa(y);Fa(S,-1,true)}d.title=l(y,ba(N(S),-1),f("titleFormat"));d.start=j;d.end=t;d.visStart=y;d.visEnd=S;g(1,1,Q?7:5,false)}var d=this;d.render=e;sb.call(d,a,b,"basicWeek");var f=d.opt,g=d.renderBasic,
+l=b.formatDates}function oc(a,b){function e(j,t){if(t){ba(j,t);f("weekends")||Fa(j,t<0?-1:1)}d.title=l(j,f("titleFormat"));d.start=d.visStart=N(j,true);d.end=d.visEnd=ba(N(d.start),1);g(1,1,1,false)}var d=this;d.render=e;sb.call(d,a,b,"basicDay");var f=d.opt,g=d.renderBasic,l=b.formatDate}function sb(a,b,e){function d(w,I,R,V){v=I;F=R;f();(I=!C)?g(w,V):z();l(I)}function f(){if(k=L("isRTL")){D=-1;Z=F-1}else{D=1;Z=0}ja=L("firstDay");ia=L("weekends")?0:1;la=L("theme")?"ui":"fc";$=L("columnFormat")}function g(w,
+I){var R,V=la+"-widget-header",ea=la+"-widget-content",aa;R="<table class='fc-border-separate' style='width:100%' cellspacing='0'><thead><tr>";for(aa=0;aa<F;aa++)R+="<th class='fc- "+V+"'/>";R+="</tr></thead><tbody>";for(aa=0;aa<w;aa++){R+="<tr class='fc-week"+aa+"'>";for(V=0;V<F;V++)R+="<td class='fc- "+ea+" fc-day"+(aa*F+V)+"'><div>"+(I?"<div class='fc-day-number'/>":"")+"<div class='fc-day-content'><div style='position:relative'>&nbsp;</div></div></div></td>";R+="</tr>"}R+="</tbody></table>";w=
+m(R).appendTo(a);K=w.find("thead");i=K.find("th");C=w.find("tbody");P=C.find("tr");E=C.find("td");B=E.filter(":first-child");n=P.eq(0).find("div.fc-day-content div");ab(K.add(K.find("tr")));ab(P);P.eq(0).addClass("fc-first");y(E);Y=m("<div style='position:absolute;z-index:8;top:0;left:0'/>").appendTo(a)}function l(w){var I=w||v==1,R=p.start.getMonth(),V=Ka(new Date),ea,aa,va;I&&i.each(function(wa,Ga){ea=m(Ga);aa=ca(wa);ea.html(ya(aa,$));rb(ea,aa)});E.each(function(wa,Ga){ea=m(Ga);aa=ca(wa);aa.getMonth()==
+R?ea.removeClass("fc-other-month"):ea.addClass("fc-other-month");+aa==+V?ea.addClass(la+"-state-highlight fc-today"):ea.removeClass(la+"-state-highlight fc-today");ea.find("div.fc-day-number").text(aa.getDate());I&&rb(ea,aa)});P.each(function(wa,Ga){va=m(Ga);if(wa<v){va.show();wa==v-1?va.addClass("fc-last"):va.removeClass("fc-last")}else va.hide()})}function j(w){o=w;w=o-K.height();var I,R,V;if(L("weekMode")=="variable")I=R=Math.floor(w/(v==1?2:6));else{I=Math.floor(w/v);R=w-I*(v-1)}B.each(function(ea,
+aa){if(ea<v){V=m(aa);Za(V.find("> div"),(ea==v-1?R:I)-Sa(V))}})}function t(w){W=w;M.clear();s=Math.floor(W/F);Va(i.slice(0,-1),s)}function y(w){w.click(S).mousedown(X)}function S(w){if(!L("selectable")){var I=parseInt(this.className.match(/fc\-day(\d+)/)[1]);I=ca(I);c("dayClick",this,I,true,w)}}function Q(w,I,R){R&&r.build();R=N(p.visStart);for(var V=ba(N(R),F),ea=0;ea<v;ea++){var aa=new Date(Math.max(R,w)),va=new Date(Math.min(V,I));if(aa<va){var wa;if(k){wa=Ca(va,R)*D+Z+1;aa=Ca(aa,R)*D+Z+1}else{wa=
+Ca(aa,R);aa=Ca(va,R)}y(q(ea,wa,ea,aa-1))}ba(R,7);ba(V,7)}}function q(w,I,R,V){w=r.rect(w,I,R,V,a);return H(w,a)}function u(w){return N(w)}function fa(w,I){Q(w,ba(N(I),1),true)}function na(){T()}function ga(w,I,R){var V=ua(w);c("dayClick",E[V.row*F+V.col],w,I,R)}function ra(w,I){J.start(function(R){T();R&&q(R.row,R.col,R.row,R.col)},I)}function sa(w,I,R){var V=J.stop();T();if(V){V=pa(V);c("drop",w,V,true,I,R)}}function ha(w){return N(w.start)}function da(w){return M.left(w)}function ma(w){return M.right(w)}
+function ua(w){return{row:Math.floor(Ca(w,p.visStart)/7),col:ka(w.getDay())}}function pa(w){return U(w.row,w.col)}function U(w,I){return ba(N(p.visStart),w*7+I*D+Z)}function ca(w){return U(Math.floor(w/F),w%F)}function ka(w){return(w-Math.max(ja,ia)+F)%F*D+Z}function qa(w){return P.eq(w)}function G(){return{left:0,right:W}}var p=this;p.renderBasic=d;p.setHeight=j;p.setWidth=t;p.renderDayOverlay=Q;p.defaultSelectionEnd=u;p.renderSelection=fa;p.clearSelection=na;p.reportDayClick=ga;p.dragStart=ra;p.dragStop=
+sa;p.defaultEventEnd=ha;p.getHoverListener=function(){return J};p.colContentLeft=da;p.colContentRight=ma;p.dayOfWeekCol=ka;p.dateCell=ua;p.cellDate=pa;p.cellIsAllDay=function(){return true};p.allDayRow=qa;p.allDayBounds=G;p.getRowCnt=function(){return v};p.getColCnt=function(){return F};p.getColWidth=function(){return s};p.getDaySegmentContainer=function(){return Y};Kb.call(p,a,b,e);Lb.call(p);Mb.call(p);pc.call(p);var L=p.opt,c=p.trigger,z=p.clearEvents,H=p.renderOverlay,T=p.clearOverlays,X=p.daySelectionMousedown,
+ya=b.formatDate,K,i,C,P,E,B,n,Y,W,o,s,v,F,r,J,M,k,D,Z,ja,ia,la,$;qb(a.addClass("fc-grid"));r=new Nb(function(w,I){var R,V,ea;i.each(function(aa,va){R=m(va);V=R.offset().left;if(aa)ea[1]=V;ea=[V];I[aa]=ea});ea[1]=V+R.outerWidth();P.each(function(aa,va){if(aa<v){R=m(va);V=R.offset().top;if(aa)ea[1]=V;ea=[V];w[aa]=ea}});ea[1]=V+R.outerHeight()});J=new Ob(r);M=new Pb(function(w){return n.eq(w)})}function pc(){function a(U,ca){S(U);ua(e(U),ca)}function b(){Q();ga().empty()}function e(U){var ca=da(),ka=
+ma(),qa=N(g.visStart);ka=ba(N(qa),ka);var G=m.map(U,Ua),p,L,c,z,H,T,X=[];for(p=0;p<ca;p++){L=ob(nb(U,G,qa,ka));for(c=0;c<L.length;c++){z=L[c];for(H=0;H<z.length;H++){T=z[H];T.row=p;T.level=c;X.push(T)}}ba(qa,7);ba(ka,7)}return X}function d(U,ca,ka){t(U)&&f(U,ca);ka.isEnd&&y(U)&&pa(U,ca,ka);q(U,ca)}function f(U,ca){var ka=ra(),qa;ca.draggable({zIndex:9,delay:50,opacity:l("dragOpacity"),revertDuration:l("dragRevertDuration"),start:function(G,p){j("eventDragStart",ca,U,G,p);fa(U,ca);ka.start(function(L,
+c,z,H){ca.draggable("option","revert",!L||!z&&!H);ha();if(L){qa=z*7+H*(l("isRTL")?-1:1);sa(ba(N(U.start),qa),ba(Ua(U),qa))}else qa=0},G,"drag")},stop:function(G,p){ka.stop();ha();j("eventDragStop",ca,U,G,p);if(qa)na(this,U,qa,0,U.allDay,G,p);else{ca.css("filter","");u(U,ca)}}})}var g=this;g.renderEvents=a;g.compileDaySegs=e;g.clearEvents=b;g.bindDaySeg=d;Qb.call(g);var l=g.opt,j=g.trigger,t=g.isEventDraggable,y=g.isEventResizable,S=g.reportEvents,Q=g.reportEventClear,q=g.eventElementHandlers,u=g.showEvents,
+fa=g.hideEvents,na=g.eventDrop,ga=g.getDaySegmentContainer,ra=g.getHoverListener,sa=g.renderDayOverlay,ha=g.clearOverlays,da=g.getRowCnt,ma=g.getColCnt,ua=g.renderDaySegs,pa=g.resizableDayEvent}function qc(a,b){function e(j,t){t&&ba(j,t*7);j=ba(N(j),-((j.getDay()-f("firstDay")+7)%7));t=ba(N(j),7);var y=N(j),S=N(t),Q=f("weekends");if(!Q){Fa(y);Fa(S,-1,true)}d.title=l(y,ba(N(S),-1),f("titleFormat"));d.start=j;d.end=t;d.visStart=y;d.visEnd=S;g(Q?7:5)}var d=this;d.render=e;Rb.call(d,a,b,"agendaWeek");
+var f=d.opt,g=d.renderAgenda,l=b.formatDates}function rc(a,b){function e(j,t){if(t){ba(j,t);f("weekends")||Fa(j,t<0?-1:1)}t=N(j,true);var y=ba(N(t),1);d.title=l(j,f("titleFormat"));d.start=d.visStart=t;d.end=d.visEnd=y;g(1)}var d=this;d.render=e;Rb.call(d,a,b,"agendaDay");var f=d.opt,g=d.renderAgenda,l=b.formatDate}function Rb(a,b,e){function d(h){Ba=h;f();v?P():g();l()}function f(){Wa=i("theme")?"ui":"fc";Sb=i("weekends")?0:1;Tb=i("firstDay");if(Ub=i("isRTL")){Ha=-1;Ia=Ba-1}else{Ha=1;Ia=0}La=mb(i("minTime"));
+bb=mb(i("maxTime"));Vb=i("columnFormat")}function g(){var h=Wa+"-widget-header",O=Wa+"-widget-content",x,A,ta,za,Da,Ea=i("slotMinutes")%15==0;x="<table style='width:100%' class='fc-agenda-days fc-border-separate' cellspacing='0'><thead><tr><th class='fc-agenda-axis "+h+"'>&nbsp;</th>";for(A=0;A<Ba;A++)x+="<th class='fc- fc-col"+A+" "+h+"'/>";x+="<th class='fc-agenda-gutter "+h+"'>&nbsp;</th></tr></thead><tbody><tr><th class='fc-agenda-axis "+h+"'>&nbsp;</th>";for(A=0;A<Ba;A++)x+="<td class='fc- fc-col"+
+A+" "+O+"'><div><div class='fc-day-content'><div style='position:relative'>&nbsp;</div></div></div></td>";x+="<td class='fc-agenda-gutter "+O+"'>&nbsp;</td></tr></tbody></table>";v=m(x).appendTo(a);F=v.find("thead");r=F.find("th").slice(1,-1);J=v.find("tbody");M=J.find("td").slice(0,-1);k=M.find("div.fc-day-content div");D=M.eq(0);Z=D.find("> div");ab(F.add(F.find("tr")));ab(J.add(J.find("tr")));aa=F.find("th:first");va=v.find(".fc-agenda-gutter");ja=m("<div style='position:absolute;z-index:2;left:0;width:100%'/>").appendTo(a);
+if(i("allDaySlot")){ia=m("<div style='position:absolute;z-index:8;top:0;left:0'/>").appendTo(ja);x="<table style='width:100%' class='fc-agenda-allday' cellspacing='0'><tr><th class='"+h+" fc-agenda-axis'>"+i("allDayText")+"</th><td><div class='fc-day-content'><div style='position:relative'/></div></td><th class='"+h+" fc-agenda-gutter'>&nbsp;</th></tr></table>";la=m(x).appendTo(ja);$=la.find("tr");q($.find("td"));aa=aa.add(la.find("th:first"));va=va.add(la.find("th.fc-agenda-gutter"));ja.append("<div class='fc-agenda-divider "+
+h+"'><div class='fc-agenda-divider-inner'/></div>")}else ia=m([]);w=m("<div style='position:absolute;width:100%;overflow-x:hidden;overflow-y:auto'/>").appendTo(ja);I=m("<div style='position:relative;width:100%;overflow:hidden'/>").appendTo(w);R=m("<div style='position:absolute;z-index:8;top:0;left:0'/>").appendTo(I);x="<table class='fc-agenda-slots' style='width:100%' cellspacing='0'><tbody>";ta=zb();za=xa(N(ta),bb);xa(ta,La);for(A=tb=0;ta<za;A++){Da=ta.getMinutes();x+="<tr class='fc-slot"+A+" "+
+(!Da?"":"fc-minor")+"'><th class='fc-agenda-axis "+h+"'>"+(!Ea||!Da?s(ta,i("axisFormat")):"&nbsp;")+"</th><td class='"+O+"'><div style='position:relative'>&nbsp;</div></td></tr>";xa(ta,i("slotMinutes"));tb++}x+="</tbody></table>";V=m(x).appendTo(I);ea=V.find("div:first");u(V.find("td"));aa=aa.add(V.find("th:first"))}function l(){var h,O,x,A,ta=Ka(new Date);for(h=0;h<Ba;h++){A=ua(h);O=r.eq(h);O.html(s(A,Vb));x=M.eq(h);+A==+ta?x.addClass(Wa+"-state-highlight fc-today"):x.removeClass(Wa+"-state-highlight fc-today");
+rb(O.add(x),A)}}function j(h,O){if(h===oa)h=Wb;Wb=h;ub={};var x=J.position().top,A=w.position().top;h=Math.min(h-x,V.height()+A+1);Z.height(h-Sa(D));ja.css("top",x);w.height(h-A-1);Xa=ea.height()+1;O&&y()}function t(h){Ga=h;cb.clear();Ma=0;Va(aa.width("").each(function(O,x){Ma=Math.max(Ma,m(x).outerWidth())}),Ma);h=w[0].clientWidth;if(vb=w.width()-h){Va(va,vb);va.show().prev().removeClass("fc-last")}else va.hide().prev().addClass("fc-last");db=Math.floor((h-Ma)/Ba);Va(r.slice(0,-1),db)}function y(){function h(){w.scrollTop(A)}
+var O=zb(),x=N(O);x.setHours(i("firstHour"));var A=ca(O,x)+1;h();setTimeout(h,0)}function S(){Xb=w.scrollTop()}function Q(){w.scrollTop(Xb)}function q(h){h.click(fa).mousedown(W)}function u(h){h.click(fa).mousedown(H)}function fa(h){if(!i("selectable")){var O=Math.min(Ba-1,Math.floor((h.pageX-v.offset().left-Ma)/db)),x=ua(O),A=this.parentNode.className.match(/fc-slot(\d+)/);if(A){A=parseInt(A[1])*i("slotMinutes");var ta=Math.floor(A/60);x.setHours(ta);x.setMinutes(A%60+La);C("dayClick",M[O],x,false,
+h)}else C("dayClick",M[O],x,true,h)}}function na(h,O,x){x&&Na.build();var A=N(K.visStart);if(Ub){x=Ca(O,A)*Ha+Ia+1;h=Ca(h,A)*Ha+Ia+1}else{x=Ca(h,A);h=Ca(O,A)}x=Math.max(0,x);h=Math.min(Ba,h);x<h&&q(ga(0,x,0,h-1))}function ga(h,O,x,A){h=Na.rect(h,O,x,A,ja);return E(h,ja)}function ra(h,O){for(var x=N(K.visStart),A=ba(N(x),1),ta=0;ta<Ba;ta++){var za=new Date(Math.max(x,h)),Da=new Date(Math.min(A,O));if(za<Da){var Ea=ta*Ha+Ia;Ea=Na.rect(0,Ea,0,Ea,I);za=ca(x,za);Da=ca(x,Da);Ea.top=za;Ea.height=Da-za;u(E(Ea,
+I))}ba(x,1);ba(A,1)}}function sa(h){return cb.left(h)}function ha(h){return cb.right(h)}function da(h){return{row:Math.floor(Ca(h,K.visStart)/7),col:U(h.getDay())}}function ma(h){var O=ua(h.col);h=h.row;i("allDaySlot")&&h--;h>=0&&xa(O,La+h*i("slotMinutes"));return O}function ua(h){return ba(N(K.visStart),h*Ha+Ia)}function pa(h){return i("allDaySlot")&&!h.row}function U(h){return(h-Math.max(Tb,Sb)+Ba)%Ba*Ha+Ia}function ca(h,O){h=N(h,true);if(O<xa(N(h),La))return 0;if(O>=xa(N(h),bb))return V.height();
+h=i("slotMinutes");O=O.getHours()*60+O.getMinutes()-La;var x=Math.floor(O/h),A=ub[x];if(A===oa)A=ub[x]=V.find("tr:eq("+x+") td div")[0].offsetTop;return Math.max(0,Math.round(A-1+Xa*(O%h/h)))}function ka(){return{left:Ma,right:Ga-vb}}function qa(){return $}function G(h){var O=N(h.start);if(h.allDay)return O;return xa(O,i("defaultEventMinutes"))}function p(h,O){if(O)return N(h);return xa(N(h),i("slotMinutes"))}function L(h,O,x){if(x)i("allDaySlot")&&na(h,ba(N(O),1),true);else c(h,O)}function c(h,O){var x=
+i("selectHelper");Na.build();if(x){var A=Ca(h,K.visStart)*Ha+Ia;if(A>=0&&A<Ba){A=Na.rect(0,A,0,A,I);var ta=ca(h,h),za=ca(h,O);if(za>ta){A.top=ta;A.height=za-ta;A.left+=2;A.width-=5;if(m.isFunction(x)){if(h=x(h,O)){A.position="absolute";A.zIndex=8;wa=m(h).css(A).appendTo(I)}}else{A.isStart=true;A.isEnd=true;wa=m(o({title:"",start:h,end:O,className:["fc-select-helper"],editable:false},A));wa.css("opacity",i("dragOpacity"))}if(wa){u(wa);I.append(wa);Va(wa,A.width,true);Eb(wa,A.height,true)}}}}else ra(h,
+O)}function z(){B();if(wa){wa.remove();wa=null}}function H(h){if(h.which==1&&i("selectable")){Y(h);var O;Ra.start(function(x,A){z();if(x&&x.col==A.col&&!pa(x)){A=ma(A);x=ma(x);O=[A,xa(N(A),i("slotMinutes")),x,xa(N(x),i("slotMinutes"))].sort(Gb);c(O[0],O[3])}else O=null},h);m(document).one("mouseup",function(x){Ra.stop();if(O){+O[0]==+O[1]&&T(O[0],false,x);n(O[0],O[3],false,x)}})}}function T(h,O,x){C("dayClick",M[U(h.getDay())],h,O,x)}function X(h,O){Ra.start(function(x){B();if(x)if(pa(x))ga(x.row,
+x.col,x.row,x.col);else{x=ma(x);var A=xa(N(x),i("defaultEventMinutes"));ra(x,A)}},O)}function ya(h,O,x){var A=Ra.stop();B();A&&C("drop",h,ma(A),pa(A),O,x)}var K=this;K.renderAgenda=d;K.setWidth=t;K.setHeight=j;K.beforeHide=S;K.afterShow=Q;K.defaultEventEnd=G;K.timePosition=ca;K.dayOfWeekCol=U;K.dateCell=da;K.cellDate=ma;K.cellIsAllDay=pa;K.allDayRow=qa;K.allDayBounds=ka;K.getHoverListener=function(){return Ra};K.colContentLeft=sa;K.colContentRight=ha;K.getDaySegmentContainer=function(){return ia};
+K.getSlotSegmentContainer=function(){return R};K.getMinMinute=function(){return La};K.getMaxMinute=function(){return bb};K.getBodyContent=function(){return I};K.getRowCnt=function(){return 1};K.getColCnt=function(){return Ba};K.getColWidth=function(){return db};K.getSlotHeight=function(){return Xa};K.defaultSelectionEnd=p;K.renderDayOverlay=na;K.renderSelection=L;K.clearSelection=z;K.reportDayClick=T;K.dragStart=X;K.dragStop=ya;Kb.call(K,a,b,e);Lb.call(K);Mb.call(K);sc.call(K);var i=K.opt,C=K.trigger,
+P=K.clearEvents,E=K.renderOverlay,B=K.clearOverlays,n=K.reportSelection,Y=K.unselect,W=K.daySelectionMousedown,o=K.slotSegHtml,s=b.formatDate,v,F,r,J,M,k,D,Z,ja,ia,la,$,w,I,R,V,ea,aa,va,wa,Ga,Wb,Ma,db,vb,Xa,Xb,Ba,tb,Na,Ra,cb,ub={},Wa,Tb,Sb,Ub,Ha,Ia,La,bb,Vb;qb(a.addClass("fc-agenda"));Na=new Nb(function(h,O){function x(eb){return Math.max(Ea,Math.min(tc,eb))}var A,ta,za;r.each(function(eb,uc){A=m(uc);ta=A.offset().left;if(eb)za[1]=ta;za=[ta];O[eb]=za});za[1]=ta+A.outerWidth();if(i("allDaySlot")){A=
+$;ta=A.offset().top;h[0]=[ta,ta+A.outerHeight()]}for(var Da=I.offset().top,Ea=w.offset().top,tc=Ea+w.outerHeight(),fb=0;fb<tb;fb++)h.push([x(Da+Xa*fb),x(Da+Xa*(fb+1))])});Ra=new Ob(Na);cb=new Pb(function(h){return k.eq(h)})}function sc(){function a(o,s){sa(o);var v,F=o.length,r=[],J=[];for(v=0;v<F;v++)o[v].allDay?r.push(o[v]):J.push(o[v]);if(u("allDaySlot")){L(e(r),s);ma()}g(d(J),s)}function b(){ha();ua().empty();pa().empty()}function e(o){o=ob(nb(o,m.map(o,Ua),q.visStart,q.visEnd));var s,v=o.length,
+F,r,J,M=[];for(s=0;s<v;s++){F=o[s];for(r=0;r<F.length;r++){J=F[r];J.row=0;J.level=s;M.push(J)}}return M}function d(o){var s=z(),v=ka(),F=ca(),r=xa(N(q.visStart),v),J=m.map(o,f),M,k,D,Z,ja,ia,la=[];for(M=0;M<s;M++){k=ob(nb(o,J,r,xa(N(r),F-v)));vc(k);for(D=0;D<k.length;D++){Z=k[D];for(ja=0;ja<Z.length;ja++){ia=Z[ja];ia.col=M;ia.level=D;la.push(ia)}}ba(r,1,true)}return la}function f(o){return o.end?N(o.end):xa(N(o.start),u("defaultEventMinutes"))}function g(o,s){var v,F=o.length,r,J,M,k,D,Z,ja,ia,la,
+$="",w,I,R={},V={},ea=pa(),aa;v=z();if(w=u("isRTL")){I=-1;aa=v-1}else{I=1;aa=0}for(v=0;v<F;v++){r=o[v];J=r.event;M=qa(r.start,r.start);k=qa(r.start,r.end);D=r.col;Z=r.level;ja=r.forward||0;ia=G(D*I+aa);la=p(D*I+aa)-ia;la=Math.min(la-6,la*0.95);D=Z?la/(Z+ja+1):ja?(la/(ja+1)-6)*2:la;Z=ia+la/(Z+ja+1)*Z*I+(w?la-D:0);r.top=M;r.left=Z;r.outerWidth=D;r.outerHeight=k-M;$+=l(J,r)}ea[0].innerHTML=$;w=ea.children();for(v=0;v<F;v++){r=o[v];J=r.event;$=m(w[v]);I=fa("eventRender",J,J,$);if(I===false)$.remove();
+else{if(I&&I!==true){$.remove();$=m(I).css({position:"absolute",top:r.top,left:r.left}).appendTo(ea)}r.element=$;if(J._id===s)t(J,$,r);else $[0]._fci=v;ya(J,$)}}Db(ea,o,t);for(v=0;v<F;v++){r=o[v];if($=r.element){J=R[s=r.key=Ib($[0])];r.vsides=J===oa?(R[s]=Sa($,true)):J;J=V[s];r.hsides=J===oa?(V[s]=pb($,true)):J;s=$.find("div.fc-event-content");if(s.length)r.contentTop=s[0].offsetTop}}for(v=0;v<F;v++){r=o[v];if($=r.element){$[0].style.width=Math.max(0,r.outerWidth-r.hsides)+"px";R=Math.max(0,r.outerHeight-
+r.vsides);$[0].style.height=R+"px";J=r.event;if(r.contentTop!==oa&&R-r.contentTop<10){$.find("div.fc-event-time").text(Y(J.start,u("timeFormat"))+" - "+J.title);$.find("div.fc-event-title").remove()}fa("eventAfterRender",J,J,$)}}}function l(o,s){var v="<",F=o.url,r=Jb(o,u),J=r?" style='"+r+"'":"",M=["fc-event","fc-event-skin","fc-event-vert"];na(o)&&M.push("fc-event-draggable");s.isStart&&M.push("fc-corner-top");s.isEnd&&M.push("fc-corner-bottom");M=M.concat(o.className);if(o.source)M=M.concat(o.source.className||
+[]);v+=F?"a href='"+Qa(o.url)+"'":"div";v+=" class='"+M.join(" ")+"' style='position:absolute;z-index:8;top:"+s.top+"px;left:"+s.left+"px;"+r+"'><div class='fc-event-inner fc-event-skin'"+J+"><div class='fc-event-head fc-event-skin'"+J+"><div class='fc-event-time'>"+Qa(W(o.start,o.end,u("timeFormat")))+"</div></div><div class='fc-event-content'><div class='fc-event-title'>"+Qa(o.title)+"</div></div><div class='fc-event-bg'></div></div>";if(s.isEnd&&ga(o))v+="<div class='ui-resizable-handle ui-resizable-s'>=</div>";
+v+="</"+(F?"a":"div")+">";return v}function j(o,s,v){na(o)&&y(o,s,v.isStart);v.isEnd&&ga(o)&&c(o,s,v);da(o,s)}function t(o,s,v){var F=s.find("div.fc-event-time");na(o)&&S(o,s,F);v.isEnd&&ga(o)&&Q(o,s,F);da(o,s)}function y(o,s,v){function F(){if(!M){s.width(r).height("").draggable("option","grid",null);M=true}}var r,J,M=true,k,D=u("isRTL")?-1:1,Z=U(),ja=H(),ia=T(),la=ka();s.draggable({zIndex:9,opacity:u("dragOpacity","month"),revertDuration:u("dragRevertDuration"),start:function($,w){fa("eventDragStart",
+s,o,$,w);i(o,s);r=s.width();Z.start(function(I,R,V,ea){B();if(I){J=false;k=ea*D;if(I.row)if(v){if(M){s.width(ja-10);Eb(s,ia*Math.round((o.end?(o.end-o.start)/wc:u("defaultEventMinutes"))/u("slotMinutes")));s.draggable("option","grid",[ja,1]);M=false}}else J=true;else{E(ba(N(o.start),k),ba(Ua(o),k));F()}J=J||M&&!k}else{F();J=true}s.draggable("option","revert",J)},$,"drag")},stop:function($,w){Z.stop();B();fa("eventDragStop",s,o,$,w);if(J){F();s.css("filter","");K(o,s)}else{var I=0;M||(I=Math.round((s.offset().top-
+X().offset().top)/ia)*u("slotMinutes")+la-(o.start.getHours()*60+o.start.getMinutes()));C(this,o,k,I,M,$,w)}}})}function S(o,s,v){function F(I){var R=xa(N(o.start),I),V;if(o.end)V=xa(N(o.end),I);v.text(W(R,V,u("timeFormat")))}function r(){if(M){v.css("display","");s.draggable("option","grid",[$,w]);M=false}}var J,M=false,k,D,Z,ja=u("isRTL")?-1:1,ia=U(),la=z(),$=H(),w=T();s.draggable({zIndex:9,scroll:false,grid:[$,w],axis:la==1?"y":false,opacity:u("dragOpacity"),revertDuration:u("dragRevertDuration"),
+start:function(I,R){fa("eventDragStart",s,o,I,R);i(o,s);J=s.position();D=Z=0;ia.start(function(V,ea,aa,va){s.draggable("option","revert",!V);B();if(V){k=va*ja;if(u("allDaySlot")&&!V.row){if(!M){M=true;v.hide();s.draggable("option","grid",null)}E(ba(N(o.start),k),ba(Ua(o),k))}else r()}},I,"drag")},drag:function(I,R){D=Math.round((R.position.top-J.top)/w)*u("slotMinutes");if(D!=Z){M||F(D);Z=D}},stop:function(I,R){var V=ia.stop();B();fa("eventDragStop",s,o,I,R);if(V&&(k||D||M))C(this,o,k,M?0:D,M,I,R);
+else{r();s.css("filter","");s.css(J);F(0);K(o,s)}}})}function Q(o,s,v){var F,r,J=T();s.resizable({handles:{s:"div.ui-resizable-s"},grid:J,start:function(M,k){F=r=0;i(o,s);s.css("z-index",9);fa("eventResizeStart",this,o,M,k)},resize:function(M,k){F=Math.round((Math.max(J,s.height())-k.originalSize.height)/J);if(F!=r){v.text(W(o.start,!F&&!o.end?null:xa(ra(o),u("slotMinutes")*F),u("timeFormat")));r=F}},stop:function(M,k){fa("eventResizeStop",this,o,M,k);if(F)P(this,o,0,u("slotMinutes")*F,M,k);else{s.css("z-index",
+8);K(o,s)}}})}var q=this;q.renderEvents=a;q.compileDaySegs=e;q.clearEvents=b;q.slotSegHtml=l;q.bindDaySeg=j;Qb.call(q);var u=q.opt,fa=q.trigger,na=q.isEventDraggable,ga=q.isEventResizable,ra=q.eventEnd,sa=q.reportEvents,ha=q.reportEventClear,da=q.eventElementHandlers,ma=q.setHeight,ua=q.getDaySegmentContainer,pa=q.getSlotSegmentContainer,U=q.getHoverListener,ca=q.getMaxMinute,ka=q.getMinMinute,qa=q.timePosition,G=q.colContentLeft,p=q.colContentRight,L=q.renderDaySegs,c=q.resizableDayEvent,z=q.getColCnt,
+H=q.getColWidth,T=q.getSlotHeight,X=q.getBodyContent,ya=q.reportEventElement,K=q.showEvents,i=q.hideEvents,C=q.eventDrop,P=q.eventResize,E=q.renderDayOverlay,B=q.clearOverlays,n=q.calendar,Y=n.formatDate,W=n.formatDates}function vc(a){var b,e,d,f,g,l;for(b=a.length-1;b>0;b--){f=a[b];for(e=0;e<f.length;e++){g=f[e];for(d=0;d<a[b-1].length;d++){l=a[b-1][d];if(Cb(g,l))l.forward=Math.max(l.forward||0,(g.forward||0)+1)}}}}function Kb(a,b,e){function d(G,p){G=qa[G];if(typeof G=="object")return jb(G,p||e);
+return G}function f(G,p){return b.trigger.apply(b,[G,p||da].concat(Array.prototype.slice.call(arguments,2),[da]))}function g(G){return j(G)&&!d("disableDragging")}function l(G){return j(G)&&!d("disableResizing")}function j(G){return Ta(G.editable,(G.source||{}).editable,d("editable"))}function t(G){U={};var p,L=G.length,c;for(p=0;p<L;p++){c=G[p];if(U[c._id])U[c._id].push(c);else U[c._id]=[c]}}function y(G){return G.end?N(G.end):ma(G)}function S(G,p){ca.push(p);if(ka[G._id])ka[G._id].push(p);else ka[G._id]=
+[p]}function Q(){ca=[];ka={}}function q(G,p){p.click(function(L){if(!p.hasClass("ui-draggable-dragging")&&!p.hasClass("ui-resizable-resizing"))return f("eventClick",this,G,L)}).hover(function(L){f("eventMouseover",this,G,L)},function(L){f("eventMouseout",this,G,L)})}function u(G,p){na(G,p,"show")}function fa(G,p){na(G,p,"hide")}function na(G,p,L){G=ka[G._id];var c,z=G.length;for(c=0;c<z;c++)if(!p||G[c][0]!=p[0])G[c][L]()}function ga(G,p,L,c,z,H,T){var X=p.allDay,ya=p._id;sa(U[ya],L,c,z);f("eventDrop",
+G,p,L,c,z,function(){sa(U[ya],-L,-c,X);pa(ya)},H,T);pa(ya)}function ra(G,p,L,c,z,H){var T=p._id;ha(U[T],L,c);f("eventResize",G,p,L,c,function(){ha(U[T],-L,-c);pa(T)},z,H);pa(T)}function sa(G,p,L,c){L=L||0;for(var z,H=G.length,T=0;T<H;T++){z=G[T];if(c!==oa)z.allDay=c;xa(ba(z.start,p,true),L);if(z.end)z.end=xa(ba(z.end,p,true),L);ua(z,qa)}}function ha(G,p,L){L=L||0;for(var c,z=G.length,H=0;H<z;H++){c=G[H];c.end=xa(ba(y(c),p,true),L);ua(c,qa)}}var da=this;da.element=a;da.calendar=b;da.name=e;da.opt=
+d;da.trigger=f;da.isEventDraggable=g;da.isEventResizable=l;da.reportEvents=t;da.eventEnd=y;da.reportEventElement=S;da.reportEventClear=Q;da.eventElementHandlers=q;da.showEvents=u;da.hideEvents=fa;da.eventDrop=ga;da.eventResize=ra;var ma=da.defaultEventEnd,ua=b.normalizeEvent,pa=b.reportEventChange,U={},ca=[],ka={},qa=b.options}function Qb(){function a(i,C){var P=z(),E=pa(),B=U(),n=0,Y,W,o=i.length,s,v;P[0].innerHTML=e(i);d(i,P.children());f(i);g(i,P,C);l(i);j(i);t(i);C=y();for(P=0;P<E;P++){Y=[];for(W=
+0;W<B;W++)Y[W]=0;for(;n<o&&(s=i[n]).row==P;){W=Hb(Y.slice(s.startCol,s.endCol));s.top=W;W+=s.outerHeight;for(v=s.startCol;v<s.endCol;v++)Y[v]=W;n++}C[P].height(Hb(Y))}Q(i,S(C))}function b(i,C,P){var E=m("<div/>"),B=z(),n=i.length,Y;E[0].innerHTML=e(i);E=E.children();B.append(E);d(i,E);l(i);j(i);t(i);Q(i,S(y()));E=[];for(B=0;B<n;B++)if(Y=i[B].element){i[B].row===C&&Y.css("top",P);E.push(Y[0])}return m(E)}function e(i){var C=fa("isRTL"),P,E=i.length,B,n,Y,W;P=ka();var o=P.left,s=P.right,v,F,r,J,M,k=
+"";for(P=0;P<E;P++){B=i[P];n=B.event;W=["fc-event","fc-event-skin","fc-event-hori"];ga(n)&&W.push("fc-event-draggable");if(C){B.isStart&&W.push("fc-corner-right");B.isEnd&&W.push("fc-corner-left");v=p(B.end.getDay()-1);F=p(B.start.getDay());r=B.isEnd?qa(v):o;J=B.isStart?G(F):s}else{B.isStart&&W.push("fc-corner-left");B.isEnd&&W.push("fc-corner-right");v=p(B.start.getDay());F=p(B.end.getDay()-1);r=B.isStart?qa(v):o;J=B.isEnd?G(F):s}W=W.concat(n.className);if(n.source)W=W.concat(n.source.className||
+[]);Y=n.url;M=Jb(n,fa);k+=Y?"<a href='"+Qa(Y)+"'":"<div";k+=" class='"+W.join(" ")+"' style='position:absolute;z-index:8;left:"+r+"px;"+M+"'><div class='fc-event-inner fc-event-skin'"+(M?" style='"+M+"'":"")+">";if(!n.allDay&&B.isStart)k+="<span class='fc-event-time'>"+Qa(T(n.start,n.end,fa("timeFormat")))+"</span>";k+="<span class='fc-event-title'>"+Qa(n.title)+"</span></div>";if(B.isEnd&&ra(n))k+="<div class='ui-resizable-handle ui-resizable-"+(C?"w":"e")+"'>&nbsp;&nbsp;&nbsp;</div>";k+="</"+(Y?
+"a":"div")+">";B.left=r;B.outerWidth=J-r;B.startCol=v;B.endCol=F+1}return k}function d(i,C){var P,E=i.length,B,n,Y;for(P=0;P<E;P++){B=i[P];n=B.event;Y=m(C[P]);n=na("eventRender",n,n,Y);if(n===false)Y.remove();else{if(n&&n!==true){n=m(n).css({position:"absolute",left:B.left});Y.replaceWith(n);Y=n}B.element=Y}}}function f(i){var C,P=i.length,E,B;for(C=0;C<P;C++){E=i[C];(B=E.element)&&ha(E.event,B)}}function g(i,C,P){var E,B=i.length,n,Y,W;for(E=0;E<B;E++){n=i[E];if(Y=n.element){W=n.event;if(W._id===
+P)H(W,Y,n);else Y[0]._fci=E}}Db(C,i,H)}function l(i){var C,P=i.length,E,B,n,Y,W={};for(C=0;C<P;C++){E=i[C];if(B=E.element){n=E.key=Ib(B[0]);Y=W[n];if(Y===oa)Y=W[n]=pb(B,true);E.hsides=Y}}}function j(i){var C,P=i.length,E,B;for(C=0;C<P;C++){E=i[C];if(B=E.element)B[0].style.width=Math.max(0,E.outerWidth-E.hsides)+"px"}}function t(i){var C,P=i.length,E,B,n,Y,W={};for(C=0;C<P;C++){E=i[C];if(B=E.element){n=E.key;Y=W[n];if(Y===oa)Y=W[n]=Fb(B);E.outerHeight=B[0].offsetHeight+Y}}}function y(){var i,C=pa(),
+P=[];for(i=0;i<C;i++)P[i]=ca(i).find("td:first div.fc-day-content > div");return P}function S(i){var C,P=i.length,E=[];for(C=0;C<P;C++)E[C]=i[C][0].offsetTop;return E}function Q(i,C){var P,E=i.length,B,n;for(P=0;P<E;P++){B=i[P];if(n=B.element){n[0].style.top=C[B.row]+(B.top||0)+"px";B=B.event;na("eventAfterRender",B,B,n)}}}function q(i,C,P){var E=fa("isRTL"),B=E?"w":"e",n=C.find("div.ui-resizable-"+B),Y=false;qb(C);C.mousedown(function(W){W.preventDefault()}).click(function(W){if(Y){W.preventDefault();
+W.stopImmediatePropagation()}});n.mousedown(function(W){function o(ia){na("eventResizeStop",this,i,ia);m("body").css("cursor","");s.stop();ya();k&&ua(this,i,k,0,ia);setTimeout(function(){Y=false},0)}if(W.which==1){Y=true;var s=u.getHoverListener(),v=pa(),F=U(),r=E?-1:1,J=E?F-1:0,M=C.css("top"),k,D,Z=m.extend({},i),ja=L(i.start);K();m("body").css("cursor",B+"-resize").one("mouseup",o);na("eventResizeStart",this,i,W);s.start(function(ia,la){if(ia){var $=Math.max(ja.row,ia.row);ia=ia.col;if(v==1)$=0;
+if($==ja.row)ia=E?Math.min(ja.col,ia):Math.max(ja.col,ia);k=$*7+ia*r+J-(la.row*7+la.col*r+J);la=ba(sa(i),k,true);if(k){Z.end=la;$=D;D=b(c([Z]),P.row,M);D.find("*").css("cursor",B+"-resize");$&&$.remove();ma(i)}else if(D){da(i);D.remove();D=null}ya();X(i.start,ba(N(la),1))}},W)}})}var u=this;u.renderDaySegs=a;u.resizableDayEvent=q;var fa=u.opt,na=u.trigger,ga=u.isEventDraggable,ra=u.isEventResizable,sa=u.eventEnd,ha=u.reportEventElement,da=u.showEvents,ma=u.hideEvents,ua=u.eventResize,pa=u.getRowCnt,
+U=u.getColCnt,ca=u.allDayRow,ka=u.allDayBounds,qa=u.colContentLeft,G=u.colContentRight,p=u.dayOfWeekCol,L=u.dateCell,c=u.compileDaySegs,z=u.getDaySegmentContainer,H=u.bindDaySeg,T=u.calendar.formatDates,X=u.renderDayOverlay,ya=u.clearOverlays,K=u.clearSelection}function Mb(){function a(Q,q,u){b();q||(q=j(Q,u));t(Q,q,u);e(Q,q,u)}function b(Q){if(S){S=false;y();l("unselect",null,Q)}}function e(Q,q,u,fa){S=true;l("select",null,Q,q,u,fa)}function d(Q){var q=f.cellDate,u=f.cellIsAllDay,fa=f.getHoverListener(),
+na=f.reportDayClick;if(Q.which==1&&g("selectable")){b(Q);var ga;fa.start(function(ra,sa){y();if(ra&&u(ra)){ga=[q(sa),q(ra)].sort(Gb);t(ga[0],ga[1],true)}else ga=null},Q);m(document).one("mouseup",function(ra){fa.stop();if(ga){+ga[0]==+ga[1]&&na(ga[0],true,ra);e(ga[0],ga[1],true,ra)}})}}var f=this;f.select=a;f.unselect=b;f.reportSelection=e;f.daySelectionMousedown=d;var g=f.opt,l=f.trigger,j=f.defaultSelectionEnd,t=f.renderSelection,y=f.clearSelection,S=false;g("selectable")&&g("unselectAuto")&&m(document).mousedown(function(Q){var q=
+g("unselectCancel");if(q)if(m(Q.target).parents(q).length)return;b(Q)})}function Lb(){function a(g,l){var j=f.shift();j||(j=m("<div class='fc-cell-overlay' style='position:absolute;z-index:3'/>"));j[0].parentNode!=l[0]&&j.appendTo(l);d.push(j.css(g).show());return j}function b(){for(var g;g=d.shift();)f.push(g.hide().unbind())}var e=this;e.renderOverlay=a;e.clearOverlays=b;var d=[],f=[]}function Nb(a){var b=this,e,d;b.build=function(){e=[];d=[];a(e,d)};b.cell=function(f,g){var l=e.length,j=d.length,
+t,y=-1,S=-1;for(t=0;t<l;t++)if(g>=e[t][0]&&g<e[t][1]){y=t;break}for(t=0;t<j;t++)if(f>=d[t][0]&&f<d[t][1]){S=t;break}return y>=0&&S>=0?{row:y,col:S}:null};b.rect=function(f,g,l,j,t){t=t.offset();return{top:e[f][0]-t.top,left:d[g][0]-t.left,width:d[j][1]-d[g][0],height:e[l][1]-e[f][0]}}}function Ob(a){function b(j){j=a.cell(j.pageX,j.pageY);if(!j!=!l||j&&(j.row!=l.row||j.col!=l.col)){if(j){g||(g=j);f(j,g,j.row-g.row,j.col-g.col)}else f(j,g);l=j}}var e=this,d,f,g,l;e.start=function(j,t,y){f=j;g=l=null;
+a.build();b(t);d=y||"mousemove";m(document).bind(d,b)};e.stop=function(){m(document).unbind(d,b);return l}}function Pb(a){function b(l){return d[l]=d[l]||a(l)}var e=this,d={},f={},g={};e.left=function(l){return f[l]=f[l]===oa?b(l).position().left:f[l]};e.right=function(l){return g[l]=g[l]===oa?e.left(l)+b(l).width():g[l]};e.clear=function(){d={};f={};g={}}}var Ya={defaultView:"month",aspectRatio:1.35,header:{left:"title",center:"",right:"today prev,next"},weekends:true,allDayDefault:true,ignoreTimezone:true,
+lazyFetching:true,startParam:"start",endParam:"end",titleFormat:{month:"MMMM yyyy",week:"MMM d[ yyyy]{ '&#8212;'[ MMM] d yyyy}",day:"dddd, MMM d, yyyy"},columnFormat:{month:"ddd",week:"ddd M/d",day:"dddd M/d"},timeFormat:{"":"h(:mm)t"},isRTL:false,firstDay:0,monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday",
+"Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],buttonText:{prev:"&nbsp;&#9668;&nbsp;",next:"&nbsp;&#9658;&nbsp;",prevYear:"&nbsp;&lt;&lt;&nbsp;",nextYear:"&nbsp;&gt;&gt;&nbsp;",today:"today",month:"month",week:"week",day:"day"},theme:false,buttonIcons:{prev:"circle-triangle-w",next:"circle-triangle-e"},unselectAuto:true,dropAccept:"*"},xc={header:{left:"next,prev today",center:"",right:"title"},buttonText:{prev:"&nbsp;&#9658;&nbsp;",next:"&nbsp;&#9668;&nbsp;",
+prevYear:"&nbsp;&gt;&gt;&nbsp;",nextYear:"&nbsp;&lt;&lt;&nbsp;"},buttonIcons:{prev:"circle-triangle-e",next:"circle-triangle-w"}},Aa=m.fullCalendar={version:"1.5.2"},Ja=Aa.views={};m.fn.fullCalendar=function(a){if(typeof a=="string"){var b=Array.prototype.slice.call(arguments,1),e;this.each(function(){var f=m.data(this,"fullCalendar");if(f&&m.isFunction(f[a])){f=f[a].apply(f,b);if(e===oa)e=f;a=="destroy"&&m.removeData(this,"fullCalendar")}});if(e!==oa)return e;return this}var d=a.eventSources||[];
+delete a.eventSources;if(a.events){d.push(a.events);delete a.events}a=m.extend(true,{},Ya,a.isRTL||a.isRTL===oa&&Ya.isRTL?xc:{},a);this.each(function(f,g){f=m(g);g=new Yb(f,a,d);f.data("fullCalendar",g);g.render()});return this};Aa.sourceNormalizers=[];Aa.sourceFetchers=[];var ac={dataType:"json",cache:false},bc=1;Aa.addDays=ba;Aa.cloneDate=N;Aa.parseDate=kb;Aa.parseISO8601=Bb;Aa.parseTime=mb;Aa.formatDate=Oa;Aa.formatDates=ib;var lc=["sun","mon","tue","wed","thu","fri","sat"],Ab=864E5,cc=36E5,wc=
+6E4,dc={s:function(a){return a.getSeconds()},ss:function(a){return Pa(a.getSeconds())},m:function(a){return a.getMinutes()},mm:function(a){return Pa(a.getMinutes())},h:function(a){return a.getHours()%12||12},hh:function(a){return Pa(a.getHours()%12||12)},H:function(a){return a.getHours()},HH:function(a){return Pa(a.getHours())},d:function(a){return a.getDate()},dd:function(a){return Pa(a.getDate())},ddd:function(a,b){return b.dayNamesShort[a.getDay()]},dddd:function(a,b){return b.dayNames[a.getDay()]},
+M:function(a){return a.getMonth()+1},MM:function(a){return Pa(a.getMonth()+1)},MMM:function(a,b){return b.monthNamesShort[a.getMonth()]},MMMM:function(a,b){return b.monthNames[a.getMonth()]},yy:function(a){return(a.getFullYear()+"").substring(2)},yyyy:function(a){return a.getFullYear()},t:function(a){return a.getHours()<12?"a":"p"},tt:function(a){return a.getHours()<12?"am":"pm"},T:function(a){return a.getHours()<12?"A":"P"},TT:function(a){return a.getHours()<12?"AM":"PM"},u:function(a){return Oa(a,
+"yyyy-MM-dd'T'HH:mm:ss'Z'")},S:function(a){a=a.getDate();if(a>10&&a<20)return"th";return["st","nd","rd"][a%10-1]||"th"}};Aa.applyAll=$a;Ja.month=mc;Ja.basicWeek=nc;Ja.basicDay=oc;wb({weekMode:"fixed"});Ja.agendaWeek=qc;Ja.agendaDay=rc;wb({allDaySlot:true,allDayText:"all-day",firstHour:6,slotMinutes:30,defaultEventMinutes:120,axisFormat:"h(:mm)tt",timeFormat:{agenda:"h:mm{ - h:mm}"},dragOpacity:{agenda:0.5},minTime:0,maxTime:24})})(jQuery);
diff --git a/3rdparty/fullcalendar/js/gcal.js b/3rdparty/fullcalendar/js/gcal.js
new file mode 100644
index 00000000000..709e25cb262
--- /dev/null
+++ b/3rdparty/fullcalendar/js/gcal.js
@@ -0,0 +1,112 @@
+/*
+ * FullCalendar v1.5.2 Google Calendar Plugin
+ *
+ * Copyright (c) 2011 Adam Shaw
+ * Dual licensed under the MIT and GPL licenses, located in
+ * MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
+ *
+ * Date: Sun Aug 21 22:06:09 2011 -0700
+ *
+ */
+
+(function($) {
+
+
+var fc = $.fullCalendar;
+var formatDate = fc.formatDate;
+var parseISO8601 = fc.parseISO8601;
+var addDays = fc.addDays;
+var applyAll = fc.applyAll;
+
+
+fc.sourceNormalizers.push(function(sourceOptions) {
+ if (sourceOptions.dataType == 'gcal' ||
+ sourceOptions.dataType === undefined &&
+ (sourceOptions.url || '').match(/^(http|https):\/\/www.google.com\/calendar\/feeds\//)) {
+ sourceOptions.dataType = 'gcal';
+ if (sourceOptions.editable === undefined) {
+ sourceOptions.editable = false;
+ }
+ }
+});
+
+
+fc.sourceFetchers.push(function(sourceOptions, start, end) {
+ if (sourceOptions.dataType == 'gcal') {
+ return transformOptions(sourceOptions, start, end);
+ }
+});
+
+
+function transformOptions(sourceOptions, start, end) {
+
+ var success = sourceOptions.success;
+ var data = $.extend({}, sourceOptions.data || {}, {
+ 'start-min': formatDate(start, 'u'),
+ 'start-max': formatDate(end, 'u'),
+ 'singleevents': true,
+ 'max-results': 9999
+ });
+
+ var ctz = sourceOptions.currentTimezone;
+ if (ctz) {
+ data.ctz = ctz = ctz.replace(' ', '_');
+ }
+
+ return $.extend({}, sourceOptions, {
+ url: sourceOptions.url.replace(/\/basic$/, '/full') + '?alt=json-in-script&callback=?',
+ dataType: 'jsonp',
+ data: data,
+ startParam: false,
+ endParam: false,
+ success: function(data) {
+ var events = [];
+ if (data.feed.entry) {
+ $.each(data.feed.entry, function(i, entry) {
+ var startStr = entry['gd$when'][0]['startTime'];
+ var start = parseISO8601(startStr, true);
+ var end = parseISO8601(entry['gd$when'][0]['endTime'], true);
+ var allDay = startStr.indexOf('T') == -1;
+ var url;
+ $.each(entry.link, function(i, link) {
+ if (link.type == 'text/html') {
+ url = link.href;
+ if (ctz) {
+ url += (url.indexOf('?') == -1 ? '?' : '&') + 'ctz=' + ctz;
+ }
+ }
+ });
+ if (allDay) {
+ addDays(end, -1); // make inclusive
+ }
+ events.push({
+ id: entry['gCal$uid']['value'],
+ title: entry['title']['$t'],
+ url: url,
+ start: start,
+ end: end,
+ allDay: allDay,
+ location: entry['gd$where'][0]['valueString'],
+ description: entry['content']['$t']
+ });
+ });
+ }
+ var args = [events].concat(Array.prototype.slice.call(arguments, 1));
+ var res = applyAll(success, this, args);
+ if ($.isArray(res)) {
+ return res;
+ }
+ return events;
+ }
+ });
+
+}
+
+
+// legacy
+fc.gcalFeed = function(url, sourceOptions) {
+ return $.extend({}, sourceOptions, { url: url, dataType: 'gcal' });
+};
+
+
+})(jQuery);
diff --git a/3rdparty/js/chosen/VERSION b/3rdparty/js/chosen/VERSION
index f374f6662e9..b0bb878545d 100644
--- a/3rdparty/js/chosen/VERSION
+++ b/3rdparty/js/chosen/VERSION
@@ -1 +1 @@
-0.9.1
+0.9.5
diff --git a/3rdparty/js/chosen/chosen.jquery.js b/3rdparty/js/chosen/chosen.jquery.js
index 5ea409d90e3..e7e661c0962 100644
--- a/3rdparty/js/chosen/chosen.jquery.js
+++ b/3rdparty/js/chosen/chosen.jquery.js
@@ -1,7 +1,7 @@
// Chosen, a Select Box Enhancer for jQuery and Protoype
// by Patrick Filler for Harvest, http://getharvest.com
//
-// Version 0.9
+// Version 0.9.5
// Full source at https://github.com/harvesthq/chosen
// Copyright (c) 2011 Harvest http://getharvest.com
@@ -16,18 +16,22 @@
root = this;
$ = jQuery;
$.fn.extend({
- chosen: function(data, options) {
+ chosen: function(options) {
+ if ($.browser === "msie" && ($.browser.version === "6.0" || $.browser.version === "7.0")) {
+ return this;
+ }
return $(this).each(function(input_field) {
if (!($(this)).hasClass("chzn-done")) {
- return new Chosen(this, data, options);
+ return new Chosen(this, options);
}
});
}
});
Chosen = (function() {
- function Chosen(elmn) {
+ function Chosen(form_field, options) {
+ this.form_field = form_field;
+ this.options = options != null ? options : {};
this.set_default_values();
- this.form_field = elmn;
this.form_field_jq = $(this.form_field);
this.is_multiple = this.form_field.multiple;
this.is_rtl = this.form_field_jq.hasClass("chzn-rtl");
@@ -40,22 +44,28 @@
this.click_test_action = __bind(function(evt) {
return this.test_active_click(evt);
}, this);
+ this.activate_action = __bind(function(evt) {
+ return this.activate_field(evt);
+ }, this);
this.active_field = false;
this.mouse_on_container = false;
this.results_showing = false;
this.result_highlighted = null;
this.result_single_selected = null;
- return this.choices = 0;
+ this.allow_single_deselect = (this.options.allow_single_deselect != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
+ this.disable_search_threshold = this.options.disable_search_threshold || 0;
+ this.choices = 0;
+ return this.results_none_found = this.options.no_results_text || "No results match";
};
Chosen.prototype.set_up_html = function() {
var container_div, dd_top, dd_width, sf_width;
this.container_id = this.form_field.id.length ? this.form_field.id.replace(/(:|\.)/g, '_') : this.generate_field_id();
this.container_id += "_chzn";
- this.f_width = this.form_field_jq.width();
+ this.f_width = this.form_field_jq.outerWidth();
this.default_text = this.form_field_jq.data('placeholder') ? this.form_field_jq.data('placeholder') : this.default_text_default;
container_div = $("<div />", {
id: this.container_id,
- "class": "chzn-container " + (this.is_rtl ? ' chzn-rtl' : void 0),
+ "class": "chzn-container" + (this.is_rtl ? ' chzn-rtl' : ''),
style: 'width: ' + this.f_width + 'px;'
});
if (this.is_multiple) {
@@ -66,6 +76,9 @@
this.form_field_jq.hide().after(container_div);
this.container = $('#' + this.container_id);
this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single"));
+ if (!this.is_multiple && this.form_field.options.length <= this.disable_search_threshold) {
+ this.container.addClass("chzn-container-single-nosearch");
+ }
this.dropdown = this.container.find('div.chzn-drop').first();
dd_top = this.container.height();
dd_width = this.f_width - get_side_border_padding(this.dropdown);
@@ -92,8 +105,11 @@
return this.set_tab_index();
};
Chosen.prototype.register_observers = function() {
- this.container.click(__bind(function(evt) {
- return this.container_click(evt);
+ this.container.mousedown(__bind(function(evt) {
+ return this.container_mousedown(evt);
+ }, this));
+ this.container.mouseup(__bind(function(evt) {
+ return this.container_mouseup(evt);
}, this));
this.container.mouseenter(__bind(function(evt) {
return this.mouse_enter(evt);
@@ -101,8 +117,8 @@
this.container.mouseleave(__bind(function(evt) {
return this.mouse_leave(evt);
}, this));
- this.search_results.click(__bind(function(evt) {
- return this.search_results_click(evt);
+ this.search_results.mouseup(__bind(function(evt) {
+ return this.search_results_mouseup(evt);
}, this));
this.search_results.mouseover(__bind(function(evt) {
return this.search_results_mouseover(evt);
@@ -129,30 +145,52 @@
return this.search_field.focus(__bind(function(evt) {
return this.input_focus(evt);
}, this));
- } else {
- return this.selected_item.focus(__bind(function(evt) {
- return this.activate_field(evt);
- }, this));
}
};
- Chosen.prototype.container_click = function(evt) {
- if (evt && evt.type === "click") {
- evt.stopPropagation();
+ Chosen.prototype.search_field_disabled = function() {
+ this.is_disabled = this.form_field_jq.attr('disabled');
+ if (this.is_disabled) {
+ this.container.addClass('chzn-disabled');
+ this.search_field.attr('disabled', true);
+ if (!this.is_multiple) {
+ this.selected_item.unbind("focus", this.activate_action);
+ }
+ return this.close_field();
+ } else {
+ this.container.removeClass('chzn-disabled');
+ this.search_field.attr('disabled', false);
+ if (!this.is_multiple) {
+ return this.selected_item.bind("focus", this.activate_action);
+ }
}
- if (!this.pending_destroy_click) {
- if (!this.active_field) {
- if (this.is_multiple) {
- this.search_field.val("");
+ };
+ Chosen.prototype.container_mousedown = function(evt) {
+ var target_closelink;
+ if (!this.is_disabled) {
+ target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false;
+ if (evt && evt.type === "mousedown") {
+ evt.stopPropagation();
+ }
+ if (!this.pending_destroy_click && !target_closelink) {
+ if (!this.active_field) {
+ if (this.is_multiple) {
+ this.search_field.val("");
+ }
+ $(document).click(this.click_test_action);
+ this.results_show();
+ } else if (!this.is_multiple && evt && ($(evt.target) === this.selected_item || $(evt.target).parents("a.chzn-single").length)) {
+ evt.preventDefault();
+ this.results_toggle();
}
- $(document).click(this.click_test_action);
- this.results_show();
- } else if (!this.is_multiple && evt && ($(evt.target) === this.selected_item || $(evt.target).parents("a.chzn-single").length)) {
- evt.preventDefault();
- this.results_toggle();
+ return this.activate_field();
+ } else {
+ return this.pending_destroy_click = false;
}
- return this.activate_field();
- } else {
- return this.pending_destroy_click = false;
+ }
+ };
+ Chosen.prototype.container_mouseup = function(evt) {
+ if (evt.target.nodeName === "ABBR") {
+ return this.results_reset(evt);
}
};
Chosen.prototype.mouse_enter = function() {
@@ -164,7 +202,7 @@
Chosen.prototype.input_focus = function(evt) {
if (!this.active_field) {
return setTimeout((__bind(function() {
- return this.container_click();
+ return this.container_mousedown();
}, this)), 50);
}
};
@@ -235,9 +273,13 @@
this.choice_build(data);
} else if (data.selected && !this.is_multiple) {
this.selected_item.find("span").text(data.text);
+ if (this.allow_single_deselect) {
+ this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
+ }
}
}
}
+ this.search_field_disabled();
this.show_search_field_default();
this.search_field_scale();
this.search_results.html(content);
@@ -252,7 +294,7 @@
}
};
Chosen.prototype.result_add_option = function(option) {
- var classes;
+ var classes, style;
if (!option.disabled) {
option.dom_id = this.container_id + "_o_" + option.array_index;
classes = option.selected && this.is_multiple ? [] : ["active-result"];
@@ -262,7 +304,11 @@
if (option.group_array_index != null) {
classes.push("group-option");
}
- return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '">' + option.html + '</li>';
+ if (option.classes !== "") {
+ classes.push(option.classes);
+ }
+ style = option.style.cssText !== "" ? " style=\"" + option.style + "\"" : "";
+ return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"' + style + '>' + option.html + '</li>';
} else {
return "";
}
@@ -353,12 +399,12 @@
return this.search_field.removeClass("default");
}
};
- Chosen.prototype.search_results_click = function(evt) {
+ Chosen.prototype.search_results_mouseup = function(evt) {
var target;
target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
if (target.length) {
this.result_highlight = target;
- return this.result_select();
+ return this.result_select(evt);
}
};
Chosen.prototype.search_results_mouseover = function(evt) {
@@ -391,8 +437,12 @@
};
Chosen.prototype.choice_destroy_link_click = function(evt) {
evt.preventDefault();
- this.pending_destroy_click = true;
- return this.choice_destroy($(evt.target));
+ if (!this.is_disabled) {
+ this.pending_destroy_click = true;
+ return this.choice_destroy($(evt.target));
+ } else {
+ return evt.stopPropagation;
+ }
};
Chosen.prototype.choice_destroy = function(link) {
this.choices -= 1;
@@ -403,18 +453,29 @@
this.result_deselect(link.attr("rel"));
return link.parents('li').first().remove();
};
- Chosen.prototype.result_select = function() {
+ Chosen.prototype.results_reset = function(evt) {
+ this.form_field.options[0].selected = true;
+ this.selected_item.find("span").text(this.default_text);
+ this.show_search_field_default();
+ $(evt.target).remove();
+ this.form_field_jq.trigger("change");
+ if (this.active_field) {
+ return this.results_hide();
+ }
+ };
+ Chosen.prototype.result_select = function(evt) {
var high, high_id, item, position;
if (this.result_highlight) {
high = this.result_highlight;
high_id = high.attr("id");
this.result_clear_highlight();
- high.addClass("result-selected");
if (this.is_multiple) {
this.result_deactivate(high);
} else {
+ this.search_results.find(".result-selected").removeClass("result-selected");
this.result_single_selected = high;
}
+ high.addClass("result-selected");
position = high_id.substr(high_id.lastIndexOf("_") + 1);
item = this.results_data[position];
item.selected = true;
@@ -423,18 +484,23 @@
this.choice_build(item);
} else {
this.selected_item.find("span").first().text(item.text);
+ if (this.allow_single_deselect) {
+ this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
+ }
+ }
+ if (!(evt.metaKey && this.is_multiple)) {
+ this.results_hide();
}
- this.results_hide();
this.search_field.val("");
this.form_field_jq.trigger("change");
return this.search_field_scale();
}
};
Chosen.prototype.result_activate = function(el) {
- return el.addClass("active-result").show();
+ return el.addClass("active-result");
};
Chosen.prototype.result_deactivate = function(el) {
- return el.removeClass("active-result").hide();
+ return el.removeClass("active-result");
};
Chosen.prototype.result_deselect = function(pos) {
var result, result_data;
@@ -530,17 +596,18 @@
return _results;
};
Chosen.prototype.winnow_results_set_highlight = function() {
- var do_high;
+ var do_high, selected_results;
if (!this.result_highlight) {
- do_high = this.search_results.find(".active-result").first();
- if (do_high) {
+ selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
+ do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
+ if (do_high != null) {
return this.result_do_highlight(do_high);
}
}
};
Chosen.prototype.no_results = function(terms) {
var no_results_html;
- no_results_html = $('<li class="no-results">No results match "<span></span>"</li>');
+ no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
no_results_html.find("span").first().html(terms);
return this.search_results.append(no_results_html);
};
@@ -611,7 +678,7 @@
case 13:
evt.preventDefault();
if (this.results_showing) {
- return this.result_select();
+ return this.result_select(evt);
}
break;
case 27:
@@ -623,6 +690,8 @@
case 38:
case 40:
case 16:
+ case 91:
+ case 17:
break;
default:
return this.results_search();
@@ -758,7 +827,9 @@
html: option.innerHTML,
selected: option.selected,
disabled: group_disabled === true ? group_disabled : option.disabled,
- group_array_index: group_position
+ group_array_index: group_position,
+ classes: option.className,
+ style: option.style.cssText
});
} else {
this.parsed.push({
diff --git a/3rdparty/js/chosen/chosen.jquery.min.js b/3rdparty/js/chosen/chosen.jquery.min.js
index 1d6a6983d8a..371ee53e7a3 100644
--- a/3rdparty/js/chosen/chosen.jquery.min.js
+++ b/3rdparty/js/chosen/chosen.jquery.min.js
@@ -1,10 +1,10 @@
// Chosen, a Select Box Enhancer for jQuery and Protoype
// by Patrick Filler for Harvest, http://getharvest.com
//
-// Version 0.9
+// Version 0.9.5
// Full source at https://github.com/harvesthq/chosen
// Copyright (c) 2011 Harvest http://getharvest.com
// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
// This file is generated by `cake build`, do not edit it by hand.
-(function(){var a,b,c,d,e=function(a,b){return function(){return a.apply(b,arguments)}};d=this,a=jQuery,a.fn.extend({chosen:function(c,d){return a(this).each(function(e){if(!a(this).hasClass("chzn-done"))return new b(this,c,d)})}}),b=function(){function b(b){this.set_default_values(),this.form_field=b,this.form_field_jq=a(this.form_field),this.is_multiple=this.form_field.multiple,this.is_rtl=this.form_field_jq.hasClass("chzn-rtl"),this.default_text_default=this.form_field.multiple?"Select Some Options":"Select an Option",this.set_up_html(),this.register_observers(),this.form_field_jq.addClass("chzn-done")}b.prototype.set_default_values=function(){this.click_test_action=e(function(a){return this.test_active_click(a)},this),this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.result_single_selected=null;return this.choices=0},b.prototype.set_up_html=function(){var b,d,e,f;this.container_id=this.form_field.id.length?this.form_field.id.replace(/(:|\.)/g,"_"):this.generate_field_id(),this.container_id+="_chzn",this.f_width=this.form_field_jq.width(),this.default_text=this.form_field_jq.data("placeholder")?this.form_field_jq.data("placeholder"):this.default_text_default,b=a("<div />",{id:this.container_id,"class":"chzn-container "+(this.is_rtl?" chzn-rtl":void 0),style:"width: "+this.f_width+"px;"}),this.is_multiple?b.html('<ul class="chzn-choices"><li class="search-field"><input type="text" value="'+this.default_text+'" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>'):b.html('<a href="javascript:void(0)" class="chzn-single"><span>'+this.default_text+'</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>'),this.form_field_jq.hide().after(b),this.container=a("#"+this.container_id),this.container.addClass("chzn-container-"+(this.is_multiple?"multi":"single")),this.dropdown=this.container.find("div.chzn-drop").first(),d=this.container.height(),e=this.f_width-c(this.dropdown),this.dropdown.css({width:e+"px",top:d+"px"}),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chzn-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chzn-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chzn-search").first(),this.selected_item=this.container.find(".chzn-single").first(),f=e-c(this.search_container)-c(this.search_field),this.search_field.css({width:f+"px"})),this.results_build();return this.set_tab_index()},b.prototype.register_observers=function(){this.container.click(e(function(a){return this.container_click(a)},this)),this.container.mouseenter(e(function(a){return this.mouse_enter(a)},this)),this.container.mouseleave(e(function(a){return this.mouse_leave(a)},this)),this.search_results.click(e(function(a){return this.search_results_click(a)},this)),this.search_results.mouseover(e(function(a){return this.search_results_mouseover(a)},this)),this.search_results.mouseout(e(function(a){return this.search_results_mouseout(a)},this)),this.form_field_jq.bind("liszt:updated",e(function(a){return this.results_update_field(a)},this)),this.search_field.blur(e(function(a){return this.input_blur(a)},this)),this.search_field.keyup(e(function(a){return this.keyup_checker(a)},this)),this.search_field.keydown(e(function(a){return this.keydown_checker(a)},this));if(this.is_multiple){this.search_choices.click(e(function(a){return this.choices_click(a)},this));return this.search_field.focus(e(function(a){return this.input_focus(a)},this))}return this.selected_item.focus(e(function(a){return this.activate_field(a)},this))},b.prototype.container_click=function(b){b&&b.type==="click"&&b.stopPropagation();if(!this.pending_destroy_click){this.active_field?!this.is_multiple&&b&&(a(b.target)===this.selected_item||a(b.target).parents("a.chzn-single").length)&&(b.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),a(document).click(this.click_test_action),this.results_show());return this.activate_field()}return this.pending_destroy_click=!1},b.prototype.mouse_enter=function(){return this.mouse_on_container=!0},b.prototype.mouse_leave=function(){return this.mouse_on_container=!1},b.prototype.input_focus=function(a){if(!this.active_field)return setTimeout(e(function(){return this.container_click()},this),50)},b.prototype.input_blur=function(a){if(!this.mouse_on_container){this.active_field=!1;return setTimeout(e(function(){return this.blur_test()},this),100)}},b.prototype.blur_test=function(a){if(!this.active_field&&this.container.hasClass("chzn-container-active"))return this.close_field()},b.prototype.close_field=function(){a(document).unbind("click",this.click_test_action),this.is_multiple||(this.selected_item.attr("tabindex",this.search_field.attr("tabindex")),this.search_field.attr("tabindex",-1)),this.active_field=!1,this.results_hide(),this.container.removeClass("chzn-container-active"),this.winnow_results_clear(),this.clear_backstroke(),this.show_search_field_default();return this.search_field_scale()},b.prototype.activate_field=function(){!this.is_multiple&&!this.active_field&&(this.search_field.attr("tabindex",this.selected_item.attr("tabindex")),this.selected_item.attr("tabindex",-1)),this.container.addClass("chzn-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val());return this.search_field.focus()},b.prototype.test_active_click=function(b){return a(b.target).parents("#"+this.container_id).length?this.active_field=!0:this.close_field()},b.prototype.results_build=function(){var a,b,c,e,f,g;c=new Date,this.parsing=!0,this.results_data=d.SelectParser.select_to_array(this.form_field),this.is_multiple&&this.choices>0?(this.search_choices.find("li.search-choice").remove(),this.choices=0):this.is_multiple||this.selected_item.find("span").text(this.default_text),a="",g=this.results_data;for(e=0,f=g.length;e<f;e++)b=g[e],b.group?a+=this.result_add_group(b):b.empty||(a+=this.result_add_option(b),b.selected&&this.is_multiple?this.choice_build(b):b.selected&&!this.is_multiple&&this.selected_item.find("span").text(b.text));this.show_search_field_default(),this.search_field_scale(),this.search_results.html(a);return this.parsing=!1},b.prototype.result_add_group=function(b){if(!b.disabled){b.dom_id=this.container_id+"_g_"+b.array_index;return'<li id="'+b.dom_id+'" class="group-result">'+a("<div />").text(b.label).html()+"</li>"}return""},b.prototype.result_add_option=function(a){var b;if(!a.disabled){a.dom_id=this.container_id+"_o_"+a.array_index,b=a.selected&&this.is_multiple?[]:["active-result"],a.selected&&b.push("result-selected"),a.group_array_index!=null&&b.push("group-option");return'<li id="'+a.dom_id+'" class="'+b.join(" ")+'">'+a.html+"</li>"}return""},b.prototype.results_update_field=function(){this.result_clear_highlight(),this.result_single_selected=null;return this.results_build()},b.prototype.result_do_highlight=function(a){var b,c,d,e,f;if(a.length){this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClass("highlighted"),d=parseInt(this.search_results.css("maxHeight"),10),f=this.search_results.scrollTop(),e=d+f,c=this.result_highlight.position().top+this.search_results.scrollTop(),b=c+this.result_highlight.outerHeight();if(b>=e)return this.search_results.scrollTop(b-d>0?b-d:0);if(c<f)return this.search_results.scrollTop(c)}},b.prototype.result_clear_highlight=function(){this.result_highlight&&this.result_highlight.removeClass("highlighted");return this.result_highlight=null},b.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},b.prototype.results_show=function(){var a;this.is_multiple||(this.selected_item.addClass("chzn-single-with-drop"),this.result_single_selected&&this.result_do_highlight(this.result_single_selected)),a=this.is_multiple?this.container.height():this.container.height()-1,this.dropdown.css({top:a+"px",left:0}),this.results_showing=!0,this.search_field.focus(),this.search_field.val(this.search_field.val());return this.winnow_results()},b.prototype.results_hide=function(){this.is_multiple||this.selected_item.removeClass("chzn-single-with-drop"),this.result_clear_highlight(),this.dropdown.css({left:"-9000px"});return this.results_showing=!1},b.prototype.set_tab_index=function(a){var b;if(this.form_field_jq.attr("tabindex")){b=this.form_field_jq.attr("tabindex"),this.form_field_jq.attr("tabindex",-1);if(this.is_multiple)return this.search_field.attr("tabindex",b);this.selected_item.attr("tabindex",b);return this.search_field.attr("tabindex",-1)}},b.prototype.show_search_field_default=function(){if(this.is_multiple&&this.choices<1&&!this.active_field){this.search_field.val(this.default_text);return this.search_field.addClass("default")}this.search_field.val("");return this.search_field.removeClass("default")},b.prototype.search_results_click=function(b){var c;c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first();if(c.length){this.result_highlight=c;return this.result_select()}},b.prototype.search_results_mouseover=function(b){var c;c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first();if(c)return this.result_do_highlight(c)},b.prototype.search_results_mouseout=function(b){if(a(b.target).hasClass("active-result"))return this.result_clear_highlight()},b.prototype.choices_click=function(b){b.preventDefault();if(this.active_field&&!a(b.target).hasClass("search-choice")&&!this.results_showing)return this.results_show()},b.prototype.choice_build=function(b){var c,d;c=this.container_id+"_c_"+b.array_index,this.choices+=1,this.search_container.before('<li class="search-choice" id="'+c+'"><span>'+b.html+'</span><a href="javascript:void(0)" class="search-choice-close" rel="'+b.array_index+'"></a></li>'),d=a("#"+c).find("a").first();return d.click(e(function(a){return this.choice_destroy_link_click(a)},this))},b.prototype.choice_destroy_link_click=function(b){b.preventDefault(),this.pending_destroy_click=!0;return this.choice_destroy(a(b.target))},b.prototype.choice_destroy=function(a){this.choices-=1,this.show_search_field_default(),this.is_multiple&&this.choices>0&&this.search_field.val().length<1&&this.results_hide(),this.result_deselect(a.attr("rel"));return a.parents("li").first().remove()},b.prototype.result_select=function(){var a,b,c,d;if(this.result_highlight){a=this.result_highlight,b=a.attr("id"),this.result_clear_highlight(),a.addClass("result-selected"),this.is_multiple?this.result_deactivate(a):this.result_single_selected=a,d=b.substr(b.lastIndexOf("_")+1),c=this.results_data[d],c.selected=!0,this.form_field.options[c.options_index].selected=!0,this.is_multiple?this.choice_build(c):this.selected_item.find("span").first().text(c.text),this.results_hide(),this.search_field.val(""),this.form_field_jq.trigger("change");return this.search_field_scale()}},b.prototype.result_activate=function(a){return a.addClass("active-result").show()},b.prototype.result_deactivate=function(a){return a.removeClass("active-result").hide()},b.prototype.result_deselect=function(b){var c,d;d=this.results_data[b],d.selected=!1,this.form_field.options[d.options_index].selected=!1,c=a("#"+this.container_id+"_o_"+b),c.removeClass("result-selected").addClass("active-result").show(),this.result_clear_highlight(),this.winnow_results(),this.form_field_jq.trigger("change");return this.search_field_scale()},b.prototype.results_search=function(a){return this.results_showing?this.winnow_results():this.results_show()},b.prototype.winnow_results=function(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;j=new Date,this.no_results_clear(),h=0,i=this.search_field.val()===this.default_text?"":a("<div/>").text(a.trim(this.search_field.val())).html(),f=new RegExp("^"+i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),m=new RegExp(i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),r=this.results_data;for(n=0,p=r.length;n<p;n++){c=r[n];if(!c.disabled&&!c.empty)if(c.group)a("#"+c.dom_id).hide();else if(!this.is_multiple||!c.selected){b=!1,g=c.dom_id;if(f.test(c.html))b=!0,h+=1;else if(c.html.indexOf(" ")>=0||c.html.indexOf("[")===0){e=c.html.replace(/\[|\]/g,"").split(" ");if(e.length)for(o=0,q=e.length;o<q;o++)d=e[o],f.test(d)&&(b=!0,h+=1)}b?(i.length?(k=c.html.search(m),l=c.html.substr(0,k+i.length)+"</em>"+c.html.substr(k+i.length),l=l.substr(0,k)+"<em>"+l.substr(k)):l=c.html,a("#"+g).html!==l&&a("#"+g).html(l),this.result_activate(a("#"+g)),c.group_array_index!=null&&a("#"+this.results_data[c.group_array_index].dom_id).show()):(this.result_highlight&&g===this.result_highlight.attr("id")&&this.result_clear_highlight(),this.result_deactivate(a("#"+g)))}}return h<1&&i.length?this.no_results(i):this.winnow_results_set_highlight()},b.prototype.winnow_results_clear=function(){var b,c,d,e,f;this.search_field.val(""),c=this.search_results.find("li"),f=[];for(d=0,e=c.length;d<e;d++)b=c[d],b=a(b),f.push(b.hasClass("group-result")?b.show():!this.is_multiple||!b.hasClass("result-selected")?this.result_activate(b):void 0);return f},b.prototype.winnow_results_set_highlight=function(){var a;if(!this.result_highlight){a=this.search_results.find(".active-result").first();if(a)return this.result_do_highlight(a)}},b.prototype.no_results=function(b){var c;c=a('<li class="no-results">No results match "<span></span>"</li>'),c.find("span").first().html(b);return this.search_results.append(c)},b.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},b.prototype.keydown_arrow=function(){var b,c;this.result_highlight?this.results_showing&&(c=this.result_highlight.nextAll("li.active-result").first(),c&&this.result_do_highlight(c)):(b=this.search_results.find("li.active-result").first(),b&&this.result_do_highlight(a(b)));if(!this.results_showing)return this.results_show()},b.prototype.keyup_arrow=function(){var a;if(!this.results_showing&&!this.is_multiple)return this.results_show();if(this.result_highlight){a=this.result_highlight.prevAll("li.active-result");if(a.length)return this.result_do_highlight(a.first());this.choices>0&&this.results_hide();return this.result_clear_highlight()}},b.prototype.keydown_backstroke=function(){if(this.pending_backstroke){this.choice_destroy(this.pending_backstroke.find("a").first());return this.clear_backstroke()}this.pending_backstroke=this.search_container.siblings("li.search-choice").last();return this.pending_backstroke.addClass("search-choice-focus")},b.prototype.clear_backstroke=function(){this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus");return this.pending_backstroke=null},b.prototype.keyup_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale();switch(b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices>0)return this.keydown_backstroke();if(!this.pending_backstroke){this.result_clear_highlight();return this.results_search()}break;case 13:a.preventDefault();if(this.results_showing)return this.result_select();break;case 27:if(this.results_showing)return this.results_hide();break;case 9:case 38:case 40:case 16:break;default:return this.results_search()}},b.prototype.keydown_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale(),b!==8&&this.pending_backstroke&&this.clear_backstroke();switch(b){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.mouse_on_container=!1;break;case 13:a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},b.prototype.search_field_scale=function(){var b,c,d,e,f,g,h,i,j;if(this.is_multiple){d=0,h=0,f="position:absolute; left: -1000px; top: -1000px; display:none;",g=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(i=0,j=g.length;i<j;i++)e=g[i],f+=e+":"+this.search_field.css(e)+";";c=a("<div />",{style:f}),c.text(this.search_field.val()),a("body").append(c),h=c.width()+25,c.remove(),h>this.f_width-10&&(h=this.f_width-10),this.search_field.css({width:h+"px"}),b=this.container.height();return this.dropdown.css({top:b+"px"})}},b.prototype.generate_field_id=function(){var a;a=this.generate_random_id(),this.form_field.id=a;return a},b.prototype.generate_random_id=function(){var b;b="sel"+this.generate_random_char()+this.generate_random_char()+this.generate_random_char();while(a("#"+b).length>0)b+=this.generate_random_char();return b},b.prototype.generate_random_char=function(){var a,b,c;a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ",c=Math.floor(Math.random()*a.length);return b=a.substring(c,c+1)};return b}(),c=function(a){var b;return b=a.outerWidth()-a.width()},d.get_side_border_padding=c}).call(this),function(){var a;a=function(){function a(){this.options_index=0,this.parsed=[]}a.prototype.add_node=function(a){return a.nodeName==="OPTGROUP"?this.add_group(a):this.add_option(a)},a.prototype.add_group=function(a){var b,c,d,e,f,g;b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:a.label,children:0,disabled:a.disabled}),f=a.childNodes,g=[];for(d=0,e=f.length;d<e;d++)c=f[d],g.push(this.add_option(c,b,a.disabled));return g},a.prototype.add_option=function(a,b,c){if(a.nodeName==="OPTION"){a.text!==""?(b!=null&&(this.parsed[b].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:a.value,text:a.text,html:a.innerHTML,selected:a.selected,disabled:c===!0?c:a.disabled,group_array_index:b})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0});return this.options_index+=1}};return a}(),a.select_to_array=function(b){var c,d,e,f,g;d=new a,g=b.childNodes;for(e=0,f=g.length;e<f;e++)c=g[e],d.add_node(c);return d.parsed},this.SelectParser=a}.call(this) \ No newline at end of file
+(function(){var a,b,c,d,e=function(a,b){return function(){return a.apply(b,arguments)}};d=this,a=jQuery,a.fn.extend({chosen:function(c){return a.browser!=="msie"||a.browser.version!=="6.0"&&a.browser.version!=="7.0"?a(this).each(function(d){if(!a(this).hasClass("chzn-done"))return new b(this,c)}):this}}),b=function(){function b(b,c){this.form_field=b,this.options=c!=null?c:{},this.set_default_values(),this.form_field_jq=a(this.form_field),this.is_multiple=this.form_field.multiple,this.is_rtl=this.form_field_jq.hasClass("chzn-rtl"),this.default_text_default=this.form_field.multiple?"Select Some Options":"Select an Option",this.set_up_html(),this.register_observers(),this.form_field_jq.addClass("chzn-done")}b.prototype.set_default_values=function(){this.click_test_action=e(function(a){return this.test_active_click(a)},this),this.activate_action=e(function(a){return this.activate_field(a)},this),this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.result_single_selected=null,this.allow_single_deselect=this.options.allow_single_deselect!=null&&this.form_field.options[0].text===""?this.options.allow_single_deselect:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.choices=0;return this.results_none_found=this.options.no_results_text||"No results match"},b.prototype.set_up_html=function(){var b,d,e,f;this.container_id=this.form_field.id.length?this.form_field.id.replace(/(:|\.)/g,"_"):this.generate_field_id(),this.container_id+="_chzn",this.f_width=this.form_field_jq.outerWidth(),this.default_text=this.form_field_jq.data("placeholder")?this.form_field_jq.data("placeholder"):this.default_text_default,b=a("<div />",{id:this.container_id,"class":"chzn-container"+(this.is_rtl?" chzn-rtl":""),style:"width: "+this.f_width+"px;"}),this.is_multiple?b.html('<ul class="chzn-choices"><li class="search-field"><input type="text" value="'+this.default_text+'" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>'):b.html('<a href="javascript:void(0)" class="chzn-single"><span>'+this.default_text+'</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>'),this.form_field_jq.hide().after(b),this.container=a("#"+this.container_id),this.container.addClass("chzn-container-"+(this.is_multiple?"multi":"single")),!this.is_multiple&&this.form_field.options.length<=this.disable_search_threshold&&this.container.addClass("chzn-container-single-nosearch"),this.dropdown=this.container.find("div.chzn-drop").first(),d=this.container.height(),e=this.f_width-c(this.dropdown),this.dropdown.css({width:e+"px",top:d+"px"}),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chzn-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chzn-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chzn-search").first(),this.selected_item=this.container.find(".chzn-single").first(),f=e-c(this.search_container)-c(this.search_field),this.search_field.css({width:f+"px"})),this.results_build();return this.set_tab_index()},b.prototype.register_observers=function(){this.container.mousedown(e(function(a){return this.container_mousedown(a)},this)),this.container.mouseup(e(function(a){return this.container_mouseup(a)},this)),this.container.mouseenter(e(function(a){return this.mouse_enter(a)},this)),this.container.mouseleave(e(function(a){return this.mouse_leave(a)},this)),this.search_results.mouseup(e(function(a){return this.search_results_mouseup(a)},this)),this.search_results.mouseover(e(function(a){return this.search_results_mouseover(a)},this)),this.search_results.mouseout(e(function(a){return this.search_results_mouseout(a)},this)),this.form_field_jq.bind("liszt:updated",e(function(a){return this.results_update_field(a)},this)),this.search_field.blur(e(function(a){return this.input_blur(a)},this)),this.search_field.keyup(e(function(a){return this.keyup_checker(a)},this)),this.search_field.keydown(e(function(a){return this.keydown_checker(a)},this));if(this.is_multiple){this.search_choices.click(e(function(a){return this.choices_click(a)},this));return this.search_field.focus(e(function(a){return this.input_focus(a)},this))}},b.prototype.search_field_disabled=function(){this.is_disabled=this.form_field_jq.attr("disabled");if(this.is_disabled){this.container.addClass("chzn-disabled"),this.search_field.attr("disabled",!0),this.is_multiple||this.selected_item.unbind("focus",this.activate_action);return this.close_field()}this.container.removeClass("chzn-disabled"),this.search_field.attr("disabled",!1);if(!this.is_multiple)return this.selected_item.bind("focus",this.activate_action)},b.prototype.container_mousedown=function(b){var c;if(!this.is_disabled){c=b!=null?a(b.target).hasClass("search-choice-close"):!1,b&&b.type==="mousedown"&&b.stopPropagation();if(!this.pending_destroy_click&&!c){this.active_field?!this.is_multiple&&b&&(a(b.target)===this.selected_item||a(b.target).parents("a.chzn-single").length)&&(b.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),a(document).click(this.click_test_action),this.results_show());return this.activate_field()}return this.pending_destroy_click=!1}},b.prototype.container_mouseup=function(a){if(a.target.nodeName==="ABBR")return this.results_reset(a)},b.prototype.mouse_enter=function(){return this.mouse_on_container=!0},b.prototype.mouse_leave=function(){return this.mouse_on_container=!1},b.prototype.input_focus=function(a){if(!this.active_field)return setTimeout(e(function(){return this.container_mousedown()},this),50)},b.prototype.input_blur=function(a){if(!this.mouse_on_container){this.active_field=!1;return setTimeout(e(function(){return this.blur_test()},this),100)}},b.prototype.blur_test=function(a){if(!this.active_field&&this.container.hasClass("chzn-container-active"))return this.close_field()},b.prototype.close_field=function(){a(document).unbind("click",this.click_test_action),this.is_multiple||(this.selected_item.attr("tabindex",this.search_field.attr("tabindex")),this.search_field.attr("tabindex",-1)),this.active_field=!1,this.results_hide(),this.container.removeClass("chzn-container-active"),this.winnow_results_clear(),this.clear_backstroke(),this.show_search_field_default();return this.search_field_scale()},b.prototype.activate_field=function(){!this.is_multiple&&!this.active_field&&(this.search_field.attr("tabindex",this.selected_item.attr("tabindex")),this.selected_item.attr("tabindex",-1)),this.container.addClass("chzn-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val());return this.search_field.focus()},b.prototype.test_active_click=function(b){return a(b.target).parents("#"+this.container_id).length?this.active_field=!0:this.close_field()},b.prototype.results_build=function(){var a,b,c,e,f,g;c=new Date,this.parsing=!0,this.results_data=d.SelectParser.select_to_array(this.form_field),this.is_multiple&&this.choices>0?(this.search_choices.find("li.search-choice").remove(),this.choices=0):this.is_multiple||this.selected_item.find("span").text(this.default_text),a="",g=this.results_data;for(e=0,f=g.length;e<f;e++)b=g[e],b.group?a+=this.result_add_group(b):b.empty||(a+=this.result_add_option(b),b.selected&&this.is_multiple?this.choice_build(b):b.selected&&!this.is_multiple&&(this.selected_item.find("span").text(b.text),this.allow_single_deselect&&this.selected_item.find("span").first().after('<abbr class="search-choice-close"></abbr>')));this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.search_results.html(a);return this.parsing=!1},b.prototype.result_add_group=function(b){if(!b.disabled){b.dom_id=this.container_id+"_g_"+b.array_index;return'<li id="'+b.dom_id+'" class="group-result">'+a("<div />").text(b.label).html()+"</li>"}return""},b.prototype.result_add_option=function(a){var b,c;if(!a.disabled){a.dom_id=this.container_id+"_o_"+a.array_index,b=a.selected&&this.is_multiple?[]:["active-result"],a.selected&&b.push("result-selected"),a.group_array_index!=null&&b.push("group-option"),a.classes!==""&&b.push(a.classes),c=a.style.cssText!==""?' style="'+a.style+'"':"";return'<li id="'+a.dom_id+'" class="'+b.join(" ")+'"'+c+">"+a.html+"</li>"}return""},b.prototype.results_update_field=function(){this.result_clear_highlight(),this.result_single_selected=null;return this.results_build()},b.prototype.result_do_highlight=function(a){var b,c,d,e,f;if(a.length){this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClass("highlighted"),d=parseInt(this.search_results.css("maxHeight"),10),f=this.search_results.scrollTop(),e=d+f,c=this.result_highlight.position().top+this.search_results.scrollTop(),b=c+this.result_highlight.outerHeight();if(b>=e)return this.search_results.scrollTop(b-d>0?b-d:0);if(c<f)return this.search_results.scrollTop(c)}},b.prototype.result_clear_highlight=function(){this.result_highlight&&this.result_highlight.removeClass("highlighted");return this.result_highlight=null},b.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},b.prototype.results_show=function(){var a;this.is_multiple||(this.selected_item.addClass("chzn-single-with-drop"),this.result_single_selected&&this.result_do_highlight(this.result_single_selected)),a=this.is_multiple?this.container.height():this.container.height()-1,this.dropdown.css({top:a+"px",left:0}),this.results_showing=!0,this.search_field.focus(),this.search_field.val(this.search_field.val());return this.winnow_results()},b.prototype.results_hide=function(){this.is_multiple||this.selected_item.removeClass("chzn-single-with-drop"),this.result_clear_highlight(),this.dropdown.css({left:"-9000px"});return this.results_showing=!1},b.prototype.set_tab_index=function(a){var b;if(this.form_field_jq.attr("tabindex")){b=this.form_field_jq.attr("tabindex"),this.form_field_jq.attr("tabindex",-1);if(this.is_multiple)return this.search_field.attr("tabindex",b);this.selected_item.attr("tabindex",b);return this.search_field.attr("tabindex",-1)}},b.prototype.show_search_field_default=function(){if(this.is_multiple&&this.choices<1&&!this.active_field){this.search_field.val(this.default_text);return this.search_field.addClass("default")}this.search_field.val("");return this.search_field.removeClass("default")},b.prototype.search_results_mouseup=function(b){var c;c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first();if(c.length){this.result_highlight=c;return this.result_select(b)}},b.prototype.search_results_mouseover=function(b){var c;c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first();if(c)return this.result_do_highlight(c)},b.prototype.search_results_mouseout=function(b){if(a(b.target).hasClass("active-result"))return this.result_clear_highlight()},b.prototype.choices_click=function(b){b.preventDefault();if(this.active_field&&!a(b.target).hasClass("search-choice")&&!this.results_showing)return this.results_show()},b.prototype.choice_build=function(b){var c,d;c=this.container_id+"_c_"+b.array_index,this.choices+=1,this.search_container.before('<li class="search-choice" id="'+c+'"><span>'+b.html+'</span><a href="javascript:void(0)" class="search-choice-close" rel="'+b.array_index+'"></a></li>'),d=a("#"+c).find("a").first();return d.click(e(function(a){return this.choice_destroy_link_click(a)},this))},b.prototype.choice_destroy_link_click=function(b){b.preventDefault();if(!this.is_disabled){this.pending_destroy_click=!0;return this.choice_destroy(a(b.target))}return b.stopPropagation},b.prototype.choice_destroy=function(a){this.choices-=1,this.show_search_field_default(),this.is_multiple&&this.choices>0&&this.search_field.val().length<1&&this.results_hide(),this.result_deselect(a.attr("rel"));return a.parents("li").first().remove()},b.prototype.results_reset=function(b){this.form_field.options[0].selected=!0,this.selected_item.find("span").text(this.default_text),this.show_search_field_default(),a(b.target).remove(),this.form_field_jq.trigger("change");if(this.active_field)return this.results_hide()},b.prototype.result_select=function(a){var b,c,d,e;if(this.result_highlight){b=this.result_highlight,c=b.attr("id"),this.result_clear_highlight(),this.is_multiple?this.result_deactivate(b):(this.search_results.find(".result-selected").removeClass("result-selected"),this.result_single_selected=b),b.addClass("result-selected"),e=c.substr(c.lastIndexOf("_")+1),d=this.results_data[e],d.selected=!0,this.form_field.options[d.options_index].selected=!0,this.is_multiple?this.choice_build(d):(this.selected_item.find("span").first().text(d.text),this.allow_single_deselect&&this.selected_item.find("span").first().after('<abbr class="search-choice-close"></abbr>')),(!a.metaKey||!this.is_multiple)&&this.results_hide(),this.search_field.val(""),this.form_field_jq.trigger("change");return this.search_field_scale()}},b.prototype.result_activate=function(a){return a.addClass("active-result")},b.prototype.result_deactivate=function(a){return a.removeClass("active-result")},b.prototype.result_deselect=function(b){var c,d;d=this.results_data[b],d.selected=!1,this.form_field.options[d.options_index].selected=!1,c=a("#"+this.container_id+"_o_"+b),c.removeClass("result-selected").addClass("active-result").show(),this.result_clear_highlight(),this.winnow_results(),this.form_field_jq.trigger("change");return this.search_field_scale()},b.prototype.results_search=function(a){return this.results_showing?this.winnow_results():this.results_show()},b.prototype.winnow_results=function(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;j=new Date,this.no_results_clear(),h=0,i=this.search_field.val()===this.default_text?"":a("<div/>").text(a.trim(this.search_field.val())).html(),f=new RegExp("^"+i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),m=new RegExp(i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),r=this.results_data;for(n=0,p=r.length;n<p;n++){c=r[n];if(!c.disabled&&!c.empty)if(c.group)a("#"+c.dom_id).hide();else if(!this.is_multiple||!c.selected){b=!1,g=c.dom_id;if(f.test(c.html))b=!0,h+=1;else if(c.html.indexOf(" ")>=0||c.html.indexOf("[")===0){e=c.html.replace(/\[|\]/g,"").split(" ");if(e.length)for(o=0,q=e.length;o<q;o++)d=e[o],f.test(d)&&(b=!0,h+=1)}b?(i.length?(k=c.html.search(m),l=c.html.substr(0,k+i.length)+"</em>"+c.html.substr(k+i.length),l=l.substr(0,k)+"<em>"+l.substr(k)):l=c.html,a("#"+g).html!==l&&a("#"+g).html(l),this.result_activate(a("#"+g)),c.group_array_index!=null&&a("#"+this.results_data[c.group_array_index].dom_id).show()):(this.result_highlight&&g===this.result_highlight.attr("id")&&this.result_clear_highlight(),this.result_deactivate(a("#"+g)))}}return h<1&&i.length?this.no_results(i):this.winnow_results_set_highlight()},b.prototype.winnow_results_clear=function(){var b,c,d,e,f;this.search_field.val(""),c=this.search_results.find("li"),f=[];for(d=0,e=c.length;d<e;d++)b=c[d],b=a(b),f.push(b.hasClass("group-result")?b.show():!this.is_multiple||!b.hasClass("result-selected")?this.result_activate(b):void 0);return f},b.prototype.winnow_results_set_highlight=function(){var a,b;if(!this.result_highlight){b=this.is_multiple?[]:this.search_results.find(".result-selected.active-result"),a=b.length?b.first():this.search_results.find(".active-result").first();if(a!=null)return this.result_do_highlight(a)}},b.prototype.no_results=function(b){var c;c=a('<li class="no-results">'+this.results_none_found+' "<span></span>"</li>'),c.find("span").first().html(b);return this.search_results.append(c)},b.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},b.prototype.keydown_arrow=function(){var b,c;this.result_highlight?this.results_showing&&(c=this.result_highlight.nextAll("li.active-result").first(),c&&this.result_do_highlight(c)):(b=this.search_results.find("li.active-result").first(),b&&this.result_do_highlight(a(b)));if(!this.results_showing)return this.results_show()},b.prototype.keyup_arrow=function(){var a;if(!this.results_showing&&!this.is_multiple)return this.results_show();if(this.result_highlight){a=this.result_highlight.prevAll("li.active-result");if(a.length)return this.result_do_highlight(a.first());this.choices>0&&this.results_hide();return this.result_clear_highlight()}},b.prototype.keydown_backstroke=function(){if(this.pending_backstroke){this.choice_destroy(this.pending_backstroke.find("a").first());return this.clear_backstroke()}this.pending_backstroke=this.search_container.siblings("li.search-choice").last();return this.pending_backstroke.addClass("search-choice-focus")},b.prototype.clear_backstroke=function(){this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus");return this.pending_backstroke=null},b.prototype.keyup_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale();switch(b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices>0)return this.keydown_backstroke();if(!this.pending_backstroke){this.result_clear_highlight();return this.results_search()}break;case 13:a.preventDefault();if(this.results_showing)return this.result_select(a);break;case 27:if(this.results_showing)return this.results_hide();break;case 9:case 38:case 40:case 16:case 91:case 17:break;default:return this.results_search()}},b.prototype.keydown_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale(),b!==8&&this.pending_backstroke&&this.clear_backstroke();switch(b){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.mouse_on_container=!1;break;case 13:a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},b.prototype.search_field_scale=function(){var b,c,d,e,f,g,h,i,j;if(this.is_multiple){d=0,h=0,f="position:absolute; left: -1000px; top: -1000px; display:none;",g=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(i=0,j=g.length;i<j;i++)e=g[i],f+=e+":"+this.search_field.css(e)+";";c=a("<div />",{style:f}),c.text(this.search_field.val()),a("body").append(c),h=c.width()+25,c.remove(),h>this.f_width-10&&(h=this.f_width-10),this.search_field.css({width:h+"px"}),b=this.container.height();return this.dropdown.css({top:b+"px"})}},b.prototype.generate_field_id=function(){var a;a=this.generate_random_id(),this.form_field.id=a;return a},b.prototype.generate_random_id=function(){var b;b="sel"+this.generate_random_char()+this.generate_random_char()+this.generate_random_char();while(a("#"+b).length>0)b+=this.generate_random_char();return b},b.prototype.generate_random_char=function(){var a,b,c;a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ",c=Math.floor(Math.random()*a.length);return b=a.substring(c,c+1)};return b}(),c=function(a){var b;return b=a.outerWidth()-a.width()},d.get_side_border_padding=c}).call(this),function(){var a;a=function(){function a(){this.options_index=0,this.parsed=[]}a.prototype.add_node=function(a){return a.nodeName==="OPTGROUP"?this.add_group(a):this.add_option(a)},a.prototype.add_group=function(a){var b,c,d,e,f,g;b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:a.label,children:0,disabled:a.disabled}),f=a.childNodes,g=[];for(d=0,e=f.length;d<e;d++)c=f[d],g.push(this.add_option(c,b,a.disabled));return g},a.prototype.add_option=function(a,b,c){if(a.nodeName==="OPTION"){a.text!==""?(b!=null&&(this.parsed[b].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:a.value,text:a.text,html:a.innerHTML,selected:a.selected,disabled:c===!0?c:a.disabled,group_array_index:b,classes:a.className,style:a.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0});return this.options_index+=1}};return a}(),a.select_to_array=function(b){var c,d,e,f,g;d=new a,g=b.childNodes;for(e=0,f=g.length;e<f;e++)c=g[e],d.add_node(c);return d.parsed},this.SelectParser=a}.call(this) \ No newline at end of file
diff --git a/3rdparty/when/MIT-LICENSE.txt b/3rdparty/when/MIT-LICENSE.txt
new file mode 100644
index 00000000000..b4429c89ac1
--- /dev/null
+++ b/3rdparty/when/MIT-LICENSE.txt
@@ -0,0 +1,9 @@
+License
+
+Copyright (c) 2010 Thomas Planer
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file
diff --git a/3rdparty/when/When.php b/3rdparty/when/When.php
new file mode 100755
index 00000000000..5f97f0eb9bf
--- /dev/null
+++ b/3rdparty/when/When.php
@@ -0,0 +1,725 @@
+<?php
+/**
+ * Name: When
+ * Author: Thomas Planer <tplaner@gmail.com>
+ * Location: http://github.com/tplaner/When
+ * Created: September 2010
+ * Description: Determines the next date of recursion given an iCalendar "rrule" like pattern.
+ * Requirements: PHP 5.3+ - makes extensive use of the Date and Time library (http://us2.php.net/manual/en/book.datetime.php)
+ */
+class When
+{
+ protected $frequency;
+
+ protected $start_date;
+ protected $try_date;
+
+ protected $end_date;
+
+ protected $gobymonth;
+ protected $bymonth;
+
+ protected $gobyweekno;
+ protected $byweekno;
+
+ protected $gobyyearday;
+ protected $byyearday;
+
+ protected $gobymonthday;
+ protected $bymonthday;
+
+ protected $gobyday;
+ protected $byday;
+
+ protected $gobysetpos;
+ protected $bysetpos;
+
+ protected $suggestions;
+
+ protected $count;
+ protected $counter;
+
+ protected $goenddate;
+
+ protected $interval;
+
+ protected $wkst;
+
+ protected $valid_week_days;
+ protected $valid_frequency;
+
+ /**
+ * __construct
+ */
+ public function __construct()
+ {
+ $this->frequency = null;
+
+ $this->gobymonth = false;
+ $this->bymonth = range(1,12);
+
+ $this->gobymonthday = false;
+ $this->bymonthday = range(1,31);
+
+ $this->gobyday = false;
+ // setup the valid week days (0 = sunday)
+ $this->byday = range(0,6);
+
+ $this->gobyyearday = false;
+ $this->byyearday = range(0,366);
+
+ $this->gobysetpos = false;
+ $this->bysetpos = range(1,366);
+
+ $this->gobyweekno = false;
+ // setup the range for valid weeks
+ $this->byweekno = range(0,54);
+
+ $this->suggestions = array();
+
+ // this will be set if a count() is specified
+ $this->count = 0;
+ // how many *valid* results we returned
+ $this->counter = 0;
+
+ // max date we'll return
+ $this->end_date = new DateTime('9999-12-31');
+
+ // the interval to increase the pattern by
+ $this->interval = 1;
+
+ // what day does the week start on? (0 = sunday)
+ $this->wkst = 0;
+
+ $this->valid_week_days = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA');
+
+ $this->valid_frequency = array('SECONDLY', 'MINUTELY', 'HOURLY', 'DAILY', 'WEEKLY', 'MONTHLY', 'YEARLY');
+ }
+
+ /**
+ * @param DateTime|string $start_date of the recursion - also is the first return value.
+ * @param string $frequency of the recrusion, valid frequencies: secondly, minutely, hourly, daily, weekly, monthly, yearly
+ */
+ public function recur($start_date, $frequency = "daily")
+ {
+ try
+ {
+ if(is_object($start_date))
+ {
+ $this->start_date = clone $start_date;
+ }
+ else
+ {
+ // timestamps within the RFC have a 'Z' at the end of them, remove this.
+ $start_date = trim($start_date, 'Z');
+ $this->start_date = new DateTime($start_date);
+ }
+
+ $this->try_date = clone $this->start_date;
+ }
+ catch(Exception $e)
+ {
+ throw new InvalidArgumentException('Invalid start date DateTime: ' . $e);
+ }
+
+ $this->freq($frequency);
+
+ return $this;
+ }
+
+ public function freq($frequency)
+ {
+ if(in_array(strtoupper($frequency), $this->valid_frequency))
+ {
+ $this->frequency = strtoupper($frequency);
+ }
+ else
+ {
+ throw new InvalidArgumentException('Invalid frequency type.');
+ }
+
+ return $this;
+ }
+
+ // accepts an rrule directly
+ public function rrule($rrule)
+ {
+ // strip off a trailing semi-colon
+ $rrule = trim($rrule, ";");
+
+ $parts = explode(";", $rrule);
+
+ foreach($parts as $part)
+ {
+ list($rule, $param) = explode("=", $part);
+
+ $rule = strtoupper($rule);
+ $param = strtoupper($param);
+
+ switch($rule)
+ {
+ case "FREQ":
+ $this->frequency = $param;
+ break;
+ case "UNTIL":
+ $this->until($param);
+ break;
+ case "COUNT":
+ $this->count($param);
+ break;
+ case "INTERVAL":
+ $this->interval($param);
+ break;
+ case "BYDAY":
+ $params = explode(",", $param);
+ $this->byday($params);
+ break;
+ case "BYMONTHDAY":
+ $params = explode(",", $param);
+ $this->bymonthday($params);
+ break;
+ case "BYYEARDAY":
+ $params = explode(",", $param);
+ $this->byyearday($params);
+ break;
+ case "BYWEEKNO":
+ $params = explode(",", $param);
+ $this->byweekno($params);
+ break;
+ case "BYMONTH":
+ $params = explode(",", $param);
+ $this->bymonth($params);
+ break;
+ case "BYSETPOS":
+ $params = explode(",", $param);
+ $this->bysetpos($params);
+ break;
+ case "WKST":
+ $this->wkst($param);
+ break;
+ }
+ }
+
+ return $this;
+ }
+
+ //max number of items to return based on the pattern
+ public function count($count)
+ {
+ $this->count = (int)$count;
+
+ return $this;
+ }
+
+ // how often the recurrence rule repeats
+ public function interval($interval)
+ {
+ $this->interval = (int)$interval;
+
+ return $this;
+ }
+
+ // starting day of the week
+ public function wkst($day)
+ {
+ switch($day)
+ {
+ case 'SU':
+ $this->wkst = 0;
+ break;
+ case 'MO':
+ $this->wkst = 1;
+ break;
+ case 'TU':
+ $this->wkst = 2;
+ break;
+ case 'WE':
+ $this->wkst = 3;
+ break;
+ case 'TH':
+ $this->wkst = 4;
+ break;
+ case 'FR':
+ $this->wkst = 5;
+ break;
+ case 'SA':
+ $this->wkst = 6;
+ break;
+ }
+
+ return $this;
+ }
+
+ // max date
+ public function until($end_date)
+ {
+ try
+ {
+ if(is_object($end_date))
+ {
+ $this->end_date = clone $end_date;
+ }
+ else
+ {
+ // timestamps within the RFC have a 'Z' at the end of them, remove this.
+ $end_date = trim($end_date, 'Z');
+ $this->end_date = new DateTime($end_date);
+ }
+ }
+ catch(Exception $e)
+ {
+ throw new InvalidArgumentException('Invalid end date DateTime: ' . $e);
+ }
+
+ return $this;
+ }
+
+ public function bymonth($months)
+ {
+ if(is_array($months))
+ {
+ $this->gobymonth = true;
+ $this->bymonth = $months;
+ }
+
+ return $this;
+ }
+
+ public function bymonthday($days)
+ {
+ if(is_array($days))
+ {
+ $this->gobymonthday = true;
+ $this->bymonthday = $days;
+ }
+
+ return $this;
+ }
+
+ public function byweekno($weeks)
+ {
+ $this->gobyweekno = true;
+
+ if(is_array($weeks))
+ {
+ $this->byweekno = $weeks;
+ }
+
+ return $this;
+ }
+
+ public function bysetpos($days)
+ {
+ $this->gobysetpos = true;
+
+ if(is_array($days))
+ {
+ $this->bysetpos = $days;
+ }
+
+ return $this;
+ }
+
+ public function byday($days)
+ {
+ $this->gobyday = true;
+
+ if(is_array($days))
+ {
+ $this->byday = array();
+ foreach($days as $day)
+ {
+ $len = strlen($day);
+
+ $as = '+';
+
+ // 0 mean no occurence is set
+ $occ = 0;
+
+ if($len == 3)
+ {
+ $occ = substr($day, 0, 1);
+ }
+ if($len == 4)
+ {
+ $as = substr($day, 0, 1);
+ $occ = substr($day, 1, 1);
+ }
+
+ if($as == '-')
+ {
+ $occ = '-' . $occ;
+ }
+ else
+ {
+ $occ = '+' . $occ;
+ }
+
+ $day = substr($day, -2, 2);
+ switch($day)
+ {
+ case 'SU':
+ $this->byday[] = $occ . 'SU';
+ break;
+ case 'MO':
+ $this->byday[] = $occ . 'MO';
+ break;
+ case 'TU':
+ $this->byday[] = $occ . 'TU';
+ break;
+ case 'WE':
+ $this->byday[] = $occ . 'WE';
+ break;
+ case 'TH':
+ $this->byday[] = $occ . 'TH';
+ break;
+ case 'FR':
+ $this->byday[] = $occ . 'FR';
+ break;
+ case 'SA':
+ $this->byday[] = $occ . 'SA';
+ break;
+ }
+ }
+ }
+
+ return $this;
+ }
+
+ public function byyearday($days)
+ {
+ $this->gobyyearday = true;
+
+ if(is_array($days))
+ {
+ $this->byyearday = $days;
+ }
+
+ return $this;
+ }
+
+ // this creates a basic list of dates to "try"
+ protected function create_suggestions()
+ {
+ switch($this->frequency)
+ {
+ case "YEARLY":
+ $interval = 'year';
+ break;
+ case "MONTHLY":
+ $interval = 'month';
+ break;
+ case "WEEKLY":
+ $interval = 'week';
+ break;
+ case "DAILY":
+ $interval = 'day';
+ break;
+ case "HOURLY":
+ $interval = 'hour';
+ break;
+ case "MINUTELY":
+ $interval = 'minute';
+ break;
+ case "SECONDLY":
+ $interval = 'second';
+ break;
+ }
+
+ $month_day = $this->try_date->format('j');
+ $month = $this->try_date->format('n');
+ $year = $this->try_date->format('Y');
+
+ $timestamp = $this->try_date->format('H:i:s');
+
+ if($this->gobysetpos)
+ {
+ if($this->try_date == $this->start_date)
+ {
+ $this->suggestions[] = clone $this->try_date;
+ }
+ else
+ {
+ if($this->gobyday)
+ {
+ foreach($this->bysetpos as $_pos)
+ {
+ $tmp_array = array();
+ $_mdays = range(1, date('t',mktime(0,0,0,$month,1,$year)));
+ foreach($_mdays as $_mday)
+ {
+ $date_time = new DateTime($year . '-' . $month . '-' . $_mday . ' ' . $timestamp);
+
+ $occur = ceil($_mday / 7);
+
+ $day_of_week = $date_time->format('l');
+ $dow_abr = strtoupper(substr($day_of_week, 0, 2));
+
+ // set the day of the month + (positive)
+ $occur = '+' . $occur . $dow_abr;
+ $occur_zero = '+0' . $dow_abr;
+
+ // set the day of the month - (negative)
+ $total_days = $date_time->format('t') - $date_time->format('j');
+ $occur_neg = '-' . ceil(($total_days + 1)/7) . $dow_abr;
+
+ $day_from_end_of_month = $date_time->format('t') + 1 - $_mday;
+
+ if(in_array($occur, $this->byday) || in_array($occur_zero, $this->byday) || in_array($occur_neg, $this->byday))
+ {
+ $tmp_array[] = clone $date_time;
+ }
+ }
+
+ if($_pos > 0)
+ {
+ $this->suggestions[] = clone $tmp_array[$_pos - 1];
+ }
+ else
+ {
+ $this->suggestions[] = clone $tmp_array[count($tmp_array) + $_pos];
+ }
+
+ }
+ }
+ }
+ }
+ elseif($this->gobyyearday)
+ {
+ foreach($this->byyearday as $_day)
+ {
+ if($_day >= 0)
+ {
+ $_day--;
+
+ $_time = strtotime('+' . $_day . ' days', mktime(0, 0, 0, 1, 1, $year));
+ $this->suggestions[] = new Datetime(date('Y-m-d', $_time) . ' ' . $timestamp);
+ }
+ else
+ {
+ $year_day_neg = 365 + $_day;
+ $leap_year = $this->try_date->format('L');
+ if($leap_year == 1)
+ {
+ $year_day_neg = 366 + $_day;
+ }
+
+ $_time = strtotime('+' . $year_day_neg . ' days', mktime(0, 0, 0, 1, 1, $year));
+ $this->suggestions[] = new Datetime(date('Y-m-d', $_time) . ' ' . $timestamp);
+ }
+ }
+ }
+ // special case because for years you need to loop through the months too
+ elseif($this->gobyday && $interval == "year")
+ {
+ foreach($this->bymonth as $_month)
+ {
+ // this creates an array of days of the month
+ $_mdays = range(1, date('t',mktime(0,0,0,$_month,1,$year)));
+ foreach($_mdays as $_mday)
+ {
+ $date_time = new DateTime($year . '-' . $_month . '-' . $_mday . ' ' . $timestamp);
+
+ // get the week of the month (1, 2, 3, 4, 5, etc)
+ $week = $date_time->format('W');
+
+ if($date_time >= $this->start_date && in_array($week, $this->byweekno))
+ {
+ $this->suggestions[] = clone $date_time;
+ }
+ }
+ }
+ }
+ elseif($interval == "day")
+ {
+ $this->suggestions[] = clone $this->try_date;
+ }
+ elseif($interval == "week")
+ {
+ $this->suggestions[] = clone $this->try_date;
+
+ if($this->gobyday)
+ {
+ $week_day = $this->try_date->format('w');
+
+ $days_in_month = $this->try_date->format('t');
+
+ $overflow_count = 1;
+ $_day = $month_day;
+
+ $run = true;
+ while($run)
+ {
+ $_day++;
+ if($_day <= $days_in_month)
+ {
+ $tmp_date = new DateTime($year . '-' . $month . '-' . $_day . ' ' . $timestamp);
+ }
+ else
+ {
+ //$tmp_month = $month+1;
+ $tmp_date = new DateTime($year . '-' . $month . '-' . $overflow_count . ' ' . $timestamp);
+ $tmp_date->modify('+1 month');
+ $overflow_count++;
+ }
+
+ $week_day = $tmp_date->format('w');
+
+ if($this->try_date == $this->start_date)
+ {
+ if($week_day == $this->wkst)
+ {
+ $this->try_date = clone $tmp_date;
+ $this->try_date->modify('-7 days');
+ $run = false;
+ }
+ }
+
+ if($week_day != $this->wkst)
+ {
+ $this->suggestions[] = clone $tmp_date;
+ }
+ else
+ {
+ $run = false;
+ }
+ }
+ }
+ }
+ elseif($this->gobyday || $interval == "month")
+ {
+ $_mdays = range(1, date('t',mktime(0,0,0,$month,1,$year)));
+ foreach($_mdays as $_mday)
+ {
+ $date_time = new DateTime($year . '-' . $month . '-' . $_mday . ' ' . $timestamp);
+
+ // get the week of the month (1, 2, 3, 4, 5, etc)
+ $week = $date_time->format('W');
+
+ if($date_time >= $this->start_date && in_array($week, $this->byweekno))
+ {
+ $this->suggestions[] = clone $date_time;
+ }
+ }
+ }
+ elseif($this->gobymonth)
+ {
+ foreach($this->bymonth as $_month)
+ {
+ $date_time = new DateTime($year . '-' . $_month . '-' . $month_day . ' ' . $timestamp);
+
+ if($date_time >= $this->start_date)
+ {
+ $this->suggestions[] = clone $date_time;
+ }
+ }
+ }
+ else
+ {
+ $this->suggestions[] = clone $this->try_date;
+ }
+
+ if($interval == "month")
+ {
+ $this->try_date->modify('last day of ' . $this->interval . ' ' . $interval);
+ }
+ else
+ {
+ $this->try_date->modify($this->interval . ' ' . $interval);
+ }
+ }
+
+ protected function valid_date($date)
+ {
+ $year = $date->format('Y');
+ $month = $date->format('n');
+ $day = $date->format('j');
+
+ $year_day = $date->format('z') + 1;
+
+ $year_day_neg = -366 + $year_day;
+ $leap_year = $date->format('L');
+ if($leap_year == 1)
+ {
+ $year_day_neg = -367 + $year_day;
+ }
+
+ // this is the nth occurence of the date
+ $occur = ceil($day / 7);
+
+ $week = $date->format('W');
+
+ $day_of_week = $date->format('l');
+ $dow_abr = strtoupper(substr($day_of_week, 0, 2));
+
+ // set the day of the month + (positive)
+ $occur = '+' . $occur . $dow_abr;
+ $occur_zero = '+0' . $dow_abr;
+
+ // set the day of the month - (negative)
+ $total_days = $date->format('t') - $date->format('j');
+ $occur_neg = '-' . ceil(($total_days + 1)/7) . $dow_abr;
+
+ $day_from_end_of_month = $date->format('t') + 1 - $day;
+
+ if(in_array($month, $this->bymonth) &&
+ (in_array($occur, $this->byday) || in_array($occur_zero, $this->byday) || in_array($occur_neg, $this->byday)) &&
+ in_array($week, $this->byweekno) &&
+ (in_array($day, $this->bymonthday) || in_array(-$day_from_end_of_month, $this->bymonthday)) &&
+ (in_array($year_day, $this->byyearday) || in_array($year_day_neg, $this->byyearday)))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ // return the next valid DateTime object which matches the pattern and follows the rules
+ public function next()
+ {
+ // check the counter is set
+ if($this->count !== 0)
+ {
+ if($this->counter >= $this->count)
+ {
+ return false;
+ }
+ }
+
+ // create initial set of suggested dates
+ if(count($this->suggestions) === 0)
+ {
+ $this->create_suggestions();
+ }
+
+ // loop through the suggested dates
+ while(count($this->suggestions) > 0)
+ {
+ // get the first one on the array
+ $try_date = array_shift($this->suggestions);
+
+ // make sure the date doesn't exceed the max date
+ if($try_date > $this->end_date)
+ {
+ return false;
+ }
+
+ // make sure it falls within the allowed days
+ if($this->valid_date($try_date) === true)
+ {
+ $this->counter++;
+ return $try_date;
+ }
+ else
+ {
+ // we might be out of suggested days, so load some more
+ if(count($this->suggestions) === 0)
+ {
+ $this->create_suggestions();
+ }
+ }
+ }
+ }
+}
diff --git a/apps/admin_dependencies_chk/appinfo/app.php b/apps/admin_dependencies_chk/appinfo/app.php
new file mode 100644
index 00000000000..e2169b5dd77
--- /dev/null
+++ b/apps/admin_dependencies_chk/appinfo/app.php
@@ -0,0 +1,9 @@
+<?php
+$l=new OC_L10N('admin_dependencies_chk');
+
+OC_App::register( array(
+ 'order' => 14,
+ 'id' => 'admin_dependencies_chk',
+ 'name' => 'Owncloud Install Info' ));
+
+OC_APP::registerAdmin('admin_dependencies_chk','settings');
diff --git a/apps/admin_dependencies_chk/appinfo/info.xml b/apps/admin_dependencies_chk/appinfo/info.xml
new file mode 100644
index 00000000000..10721ece15b
--- /dev/null
+++ b/apps/admin_dependencies_chk/appinfo/info.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<info>
+ <id>admin_dependencies_chk</id>
+ <name>Owncloud dependencies info</name>
+ <version>0.01</version>
+ <licence>AGPL</licence>
+ <author>Brice Maron (eMerzh)</author>
+ <require>2</require>
+ <description>Display OwnCloud's dependencies informations (missings modules, ...)</description>
+ <default_enable/>
+</info>
diff --git a/apps/admin_dependencies_chk/css/style.css b/apps/admin_dependencies_chk/css/style.css
new file mode 100644
index 00000000000..30f204be7bc
--- /dev/null
+++ b/apps/admin_dependencies_chk/css/style.css
@@ -0,0 +1,9 @@
+#status_list legend { font-weight: bold; color: #888888; }
+.state > li { margin-bottom: 3px; padding-left: 0.5em; list-style-type: circle; }
+.state .state_module { font-weight:bold; text-shadow: 0 1px 0 #DDD; cursor:help;}
+
+.state_used ul, .state_used li { display:inline; }
+
+.state_ok .state_module { color: #009700; }
+.state_warning .state_module { color: #FF9B29; }
+.state_error .state_module { color: #FF3B3B; }
diff --git a/apps/admin_dependencies_chk/settings.php b/apps/admin_dependencies_chk/settings.php
new file mode 100644
index 00000000000..34028056dbe
--- /dev/null
+++ b/apps/admin_dependencies_chk/settings.php
@@ -0,0 +1,96 @@
+<?php
+
+/**
+ * ownCloud - user_ldap
+ *
+ * @author Brice Maron
+ * @copyright 2011 Brice Maron brice __from__ bmaron _DOT_ net
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library 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 this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+$l=new OC_L10N('admin_dependencies_chk');
+$tmpl = new OC_Template( 'admin_dependencies_chk', 'settings');
+
+$modules = array();
+
+//Possible status are : ok, error, warning
+$modules[] =array(
+ 'status' => function_exists('json_encode') ? 'ok' : 'error',
+ 'part'=> 'php-json',
+ 'modules'=> array('core'),
+ 'message'=> $l->t('The php-json module is needed by the many applications for inter communications'));
+
+$modules[] =array(
+ 'status' => function_exists('curl_init') ? 'ok' : 'error',
+ 'part'=> 'php-curl',
+ 'modules'=> array('bookmarks'),
+ 'message'=> $l->t('The php-curl modude is needed to fetch the page title when adding a bookmarks'));
+
+$modules[] =array(
+ 'status' => function_exists('imagepng') ? 'ok' : 'error',
+ 'part'=> 'php-gd',
+ 'modules'=> array('gallery'),
+ 'message'=> $l->t('The php-gd module is needed to create thumbnails of your images'));
+
+$modules[] =array(
+ 'status' => OC_Helper::canExecute("mp3info") ? 'ok' : 'warning',
+ 'part'=> 'mp3info',
+ 'modules'=> array('media'),
+ 'message'=> $l->t('The program mp3info is useful to discover ID3 tags of your music files'));
+
+$modules[] =array(
+ 'status' => function_exists("ldap_bind") ? 'ok' : 'error',
+ 'part'=> 'php-ldap',
+ 'modules'=> array('user_ldap'),
+ 'message'=> $l->t('The php-ldap module is needed connect to your ldap server'));
+
+$modules[] =array(
+ 'status' => class_exists('ZipArchive') ? 'ok' : 'warning',
+ 'part'=> 'php-zip',
+ 'modules'=> array('admin_export','core'),
+ 'message'=> $l->t('The php-zip module is needed download multiple files at once'));
+
+$modules[] =array(
+ 'status' => function_exists('mb_detect_encoding') ? 'ok' : 'error',
+ 'part'=> 'php-mb_multibyte ',
+ 'modules'=> array('core'),
+ 'message'=> $l->t('The php-mb_multibyte module is needed to manage correctly the encoding.'));
+
+$modules[] =array(
+ 'status' => function_exists('ctype_digit') ? 'ok' : 'error',
+ 'part'=> 'php-ctype',
+ 'modules'=> array('core'),
+ 'message'=> $l->t('The php-ctype module is needed validate data.'));
+
+$modules[] =array(
+ 'status' => ini_get('allow_url_fopen') == '1' ? 'ok' : 'error',
+ 'part'=> 'allow_url_fopen',
+ 'modules'=> array('core'),
+ 'message'=> $l->t('The allow_url_fopen directive of your php.ini should be set to 1 to retrieve knowledge base from OCS servers'));
+
+foreach($modules as $key => $module) {
+ $enabled = false ;
+ foreach($module['modules'] as $app) {
+ if(OC_App::isEnabled($app) || $app=='core'){
+ $enabled = true;
+ }
+ }
+ if($enabled == false) unset($modules[$key]);
+}
+
+OC_UTIL::addStyle('admin_dependencies_chk', 'style');
+$tmpl->assign( 'items', $modules );
+
+return $tmpl->fetchPage();
diff --git a/apps/admin_dependencies_chk/templates/settings.php b/apps/admin_dependencies_chk/templates/settings.php
new file mode 100644
index 00000000000..8ff27ebb187
--- /dev/null
+++ b/apps/admin_dependencies_chk/templates/settings.php
@@ -0,0 +1,16 @@
+<fieldset id="status_list" class="personalblock">
+ <legend><?php echo $l->t('Dependencies status');?></legend>
+ <ul class="state">
+ <?php foreach($_['items'] as $item):?>
+ <li class="state_<?php echo $item['status'];?>">
+ <span class="state_module" title="<?php echo $item['message'];?>"><?php echo $item['part'];?></span>
+ <div class="state_used"><?php echo $l->t('Used by :');?>
+ <ul>
+ <?php foreach($item['modules'] as $module):?>
+ <li><?php echo $module;?></li>
+ <?php endforeach;?>
+ </ul>
+ </li>
+ <?php endforeach;?>
+ </ul>
+</fieldset> \ No newline at end of file
diff --git a/apps/bookmarks/ajax/addBookmark.php b/apps/bookmarks/ajax/addBookmark.php
index 3975fd15f81..45b16ae5fa6 100644
--- a/apps/bookmarks/ajax/addBookmark.php
+++ b/apps/bookmarks/ajax/addBookmark.php
@@ -54,13 +54,7 @@ $params=array(
);
$query->execute($params);
-if($CONFIG_DBTYPE == 'pgsql')
-{
- $query = OC_DB::prepare("SELECT currval('*PREFIX*bookmarks_id_seq')");
- $b_id = $query->execute()->fetchOne();
-} else {
- $b_id = OC_DB::insertid();
-}
+$b_id = OC_DB::insertid('*PREFIX*bookmarks');
if($b_id !== false) {
diff --git a/apps/bookmarks/bookmarksHelper.php b/apps/bookmarks/bookmarksHelper.php
index 44d4235b9b3..ac512fbc241 100644
--- a/apps/bookmarks/bookmarksHelper.php
+++ b/apps/bookmarks/bookmarksHelper.php
@@ -56,6 +56,9 @@ function getURLMetadata($url) {
}
$metadata['url'] = $url;
+ if (!function_exists('curl_init')){
+ return $metadata;
+ }
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@@ -66,4 +69,4 @@ function getURLMetadata($url) {
$metadata['title'] = htmlspecialchars_decode(@$match[1]);
return $metadata;
-} \ No newline at end of file
+}
diff --git a/apps/bookmarks/settings.php b/apps/bookmarks/settings.php
index 8186472dec9..0ace04fa2c8 100644
--- a/apps/bookmarks/settings.php
+++ b/apps/bookmarks/settings.php
@@ -8,6 +8,6 @@
$tmpl = new OC_Template( 'bookmarks', 'settings');
-OC_Util::addScript('bookmarks','settings');
+//OC_Util::addScript('bookmarks','settings');
return $tmpl->fetchPage();
diff --git a/apps/calendar/ajax/activation.php b/apps/calendar/ajax/activation.php
index 89239f21759..3c2bc6de23f 100644
--- a/apps/calendar/ajax/activation.php
+++ b/apps/calendar/ajax/activation.php
@@ -12,6 +12,10 @@ if(!OC_USER::isLoggedIn()) {
}
OC_JSON::checkAppEnabled('calendar');
$calendarid = $_POST['calendarid'];
+$calendar = OC_Calendar_App::getCalendar($calendarid);//access check
OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
-$cal = OC_Calendar_Calendar::findCalendar($calendarid);
-echo $cal['active'];
+$calendar = OC_Calendar_App::getCalendar($calendarid);
+OC_JSON::success(array(
+ 'active' => $calendar['active'],
+ 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar),
+));
diff --git a/apps/calendar/ajax/changeview.php b/apps/calendar/ajax/changeview.php
index b396ff4945b..ef05c7cd496 100644
--- a/apps/calendar/ajax/changeview.php
+++ b/apps/calendar/ajax/changeview.php
@@ -7,10 +7,9 @@
*/
require_once ("../../../lib/base.php");
-if(!OC_USER::isLoggedIn()) {
- die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
-}
+OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$currentview = $_GET["v"];
OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", $currentview);
+OC_JSON::success();
?>
diff --git a/apps/calendar/ajax/createcalendar.php b/apps/calendar/ajax/createcalendar.php
index 3fb2e8398a3..f8b5974f54c 100644
--- a/apps/calendar/ajax/createcalendar.php
+++ b/apps/calendar/ajax/createcalendar.php
@@ -8,8 +8,6 @@
require_once('../../../lib/base.php');
-$l10n = new OC_L10N('calendar');
-
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
@@ -17,7 +15,11 @@ OC_JSON::checkAppEnabled('calendar');
$userid = OC_User::getUser();
$calendarid = OC_Calendar_Calendar::addCalendar($userid, $_POST['name'], 'VEVENT,VTODO,VJOURNAL', null, 0, $_POST['color']);
OC_Calendar_Calendar::setCalendarActive($calendarid, 1);
-$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
+
+$calendar = OC_Calendar_Calendar::find($calendarid);
$tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields');
$tmpl->assign('calendar', $calendar);
-OC_JSON::success(array('data' => $tmpl->fetchPage()));
+OC_JSON::success(array(
+ 'page' => $tmpl->fetchPage(),
+ 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar),
+));
diff --git a/apps/calendar/ajax/deletecalendar.php b/apps/calendar/ajax/deletecalendar.php
index e8ffe0d0598..fc308da6dad 100644
--- a/apps/calendar/ajax/deletecalendar.php
+++ b/apps/calendar/ajax/deletecalendar.php
@@ -7,19 +7,13 @@
*/
require_once('../../../lib/base.php');
-$l10n = new OC_L10N('calendar');
-
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
}
OC_JSON::checkAppEnabled('calendar');
$cal = $_POST["calendarid"];
-$calendar = OC_Calendar_Calendar::findCalendar($cal);
-if($calendar["userid"] != OC_User::getUser()){
- OC_JSON::error(array('error'=>'permission_denied'));
- exit;
-}
+$calendar = OC_Calendar_App::getCalendar($cal);
$del = OC_Calendar_Calendar::deleteCalendar($cal);
if($del == true){
OC_JSON::success();
diff --git a/apps/calendar/ajax/deleteevent.php b/apps/calendar/ajax/deleteevent.php
index 9e3c7dd87dd..269f4a47f42 100644
--- a/apps/calendar/ajax/deleteevent.php
+++ b/apps/calendar/ajax/deleteevent.php
@@ -15,17 +15,7 @@ if(!OC_USER::isLoggedIn()) {
OC_JSON::checkAppEnabled('calendar');
$id = $_POST['id'];
-$data = OC_Calendar_Object::find($id);
-if (!$data)
-{
- OC_JSON::error();
- exit;
-}
-$calendar = OC_Calendar_Calendar::findCalendar($data['calendarid']);
-if($calendar['userid'] != OC_User::getUser()){
- OC_JSON::error();
- exit;
-}
+$event_object = OC_Calendar_App::getEventObject($id);
$result = OC_Calendar_Object::delete($id);
OC_JSON::success();
?>
diff --git a/apps/calendar/ajax/editcalendar.php b/apps/calendar/ajax/editcalendar.php
index d23e5287868..e44763c9aaa 100644
--- a/apps/calendar/ajax/editcalendar.php
+++ b/apps/calendar/ajax/editcalendar.php
@@ -7,13 +7,13 @@
*/
require_once('../../../lib/base.php');
-$l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
}
OC_JSON::checkAppEnabled('calendar');
+
$calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions();
-$calendar = OC_Calendar_Calendar::findCalendar($_GET['calendarid']);
+$calendar = OC_Calendar_App::getCalendar($_GET['calendarid']);
$tmpl = new OC_Template("calendar", "part.editcalendar");
$tmpl->assign('new', false);
$tmpl->assign('calendarcolor_options', $calendarcolor_options);
diff --git a/apps/calendar/ajax/editevent.php b/apps/calendar/ajax/editevent.php
index 3abf4de98b3..f00ab1d960b 100644
--- a/apps/calendar/ajax/editevent.php
+++ b/apps/calendar/ajax/editevent.php
@@ -7,9 +7,6 @@
*/
require_once('../../../lib/base.php');
-
-$l10n = new OC_L10N('calendar');
-
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
}
@@ -23,19 +20,12 @@ if($errarr){
}else{
$id = $_POST['id'];
$cal = $_POST['calendar'];
- $data = OC_Calendar_Object::find($id);
- if (!$data)
- {
- OC_JSON::error();
- exit;
- }
- $calendar = OC_Calendar_Calendar::findCalendar($data['calendarid']);
- if($calendar['userid'] != OC_User::getUser()){
- OC_JSON::error();
- exit;
- }
- $vcalendar = Sabre_VObject_Reader::read($data['calendardata']);
+ $data = OC_Calendar_App::getEventObject($id);
+ $vcalendar = OC_VObject::parse($data['calendardata']);
+
+ OC_Calendar_App::isNotModified($vcalendar->VEVENT, $_POST['lastmodified']);
OC_Calendar_Object::updateVCalendarFromRequest($_POST, $vcalendar);
+
$result = OC_Calendar_Object::edit($id, $vcalendar->serialize());
if ($data['calendarid'] != $cal) {
OC_Calendar_Object::moveToCalendar($id, $cal);
diff --git a/apps/calendar/ajax/editeventform.php b/apps/calendar/ajax/editeventform.php
index 34d6c657cec..fe6c6f73570 100644
--- a/apps/calendar/ajax/editeventform.php
+++ b/apps/calendar/ajax/editeventform.php
@@ -8,26 +8,16 @@
require_once('../../../lib/base.php');
-$l10n = new OC_L10N('calendar');
-
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
}
OC_JSON::checkAppEnabled('calendar');
-$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
-$category_options = OC_Calendar_Object::getCategoryOptions($l10n);
-$repeat_options = OC_Calendar_Object::getRepeatOptions($l10n);
-
$id = $_GET['id'];
-$data = OC_Calendar_Object::find($id);
-$calendar = OC_Calendar_Calendar::findCalendar($data['calendarid']);
-if($calendar['userid'] != OC_User::getUser()){
- echo $l10n->t('Wrong calendar');
- exit;
-}
-$object = Sabre_VObject_Reader::read($data['calendardata']);
+$data = OC_Calendar_App::getEventObject($id);
+$object = OC_VObject::parse($data['calendardata']);
$vevent = $object->VEVENT;
+
$dtstart = $vevent->DTSTART;
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
switch($dtstart->getDateType()) {
@@ -49,23 +39,30 @@ switch($dtstart->getDateType()) {
break;
}
-$summary = isset($vevent->SUMMARY) ? $vevent->SUMMARY->value : '';
-$location = isset($vevent->LOCATION) ? $vevent->LOCATION->value : '';
-$categories = array();
-if (isset($vevent->CATEGORIES)){
- $categories = explode(',', $vevent->CATEGORIES->value);
- $categories = array_map('trim', $categories);
-}
+$summary = $vevent->getAsString('SUMMARY');
+$location = $vevent->getAsString('LOCATION');
+$categories = $vevent->getAsArray('CATEGORIES');
+$repeat = $vevent->getAsString('CATEGORY');
+$description = $vevent->getAsString('DESCRIPTION');
foreach($categories as $category){
if (!in_array($category, $category_options)){
array_unshift($category_options, $category);
}
}
-$repeat = isset($vevent->CATEGORY) ? $vevent->CATEGORY->value : '';
-$description = isset($vevent->DESCRIPTION) ? $vevent->DESCRIPTION->value : '';
+$last_modified = $vevent->__get('LAST-MODIFIED');
+if ($last_modified){
+ $lastmodified = $last_modified->getDateTime()->format('U');
+}else{
+ $lastmodified = 0;
+}
+
+$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
+$category_options = OC_Calendar_App::getCategoryOptions();
+$repeat_options = OC_Calendar_App::getRepeatOptions();
$tmpl = new OC_Template('calendar', 'part.editevent');
$tmpl->assign('id', $id);
+$tmpl->assign('lastmodified', $lastmodified);
$tmpl->assign('calendar_options', $calendar_options);
$tmpl->assign('category_options', $category_options);
$tmpl->assign('repeat_options', $repeat_options);
diff --git a/apps/calendar/ajax/events.php b/apps/calendar/ajax/events.php
new file mode 100644
index 00000000000..1430432b8a3
--- /dev/null
+++ b/apps/calendar/ajax/events.php
@@ -0,0 +1,84 @@
+<?php
+/**
+ * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+require_once ('../../../lib/base.php');
+require_once('../../../3rdparty/when/When.php');
+
+function addoutput($event, $vevent, $return_event){
+ $return_event['id'] = (int)$event['id'];
+ $return_event['title'] = $event['summary'];
+ $return_event['description'] = isset($vevent->DESCRIPTION)?$vevent->DESCRIPTION->value:'';
+ $last_modified = $vevent->__get('LAST-MODIFIED');
+ if ($last_modified){
+ $lastmodified = $last_modified->getDateTime()->format('U');
+ }else{
+ $lastmodified = 0;
+ }
+ $return_event['lastmodified'] = (int)$lastmodified;
+ return $return_event;
+}
+
+OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('calendar');
+
+$start = DateTime::createFromFormat('U', $_GET['start']);
+$end = DateTime::createFromFormat('U', $_GET['end']);
+
+$events = OC_Calendar_Object::allInPeriod($_GET['calendar_id'], $start, $end);
+$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
+$return = array();
+foreach($events as $event){
+ $object = OC_VObject::parse($event['calendardata']);
+ $vevent = $object->VEVENT;
+ $dtstart = $vevent->DTSTART;
+ $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
+ $return_event = array();
+ $start_dt = $dtstart->getDateTime();
+ $start_dt->setTimezone(new DateTimeZone($user_timezone));
+ $end_dt = $dtend->getDateTime();
+ $end_dt->setTimezone(new DateTimeZone($user_timezone));
+ if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE){
+ $return_event['allDay'] = true;
+ }else{
+ $return_event['allDay'] = false;
+ }
+ //Repeating Events
+ if($event['repeating'] == 1){
+ $duration = (double) $end_dt->format('U') - (double) $start_dt->format('U');
+ $r = new When();
+ $r->recur((string) $start_dt->format('Ymd\THis'))->rrule((string) $vevent->RRULE);
+ while($result = $r->next()){
+ if($result->format('U') > $_GET['end']){
+ break;
+ }
+ if($return_event['allDay'] == true){
+ $return_event['start'] = $result->format('Y-m-d');
+ $return_event['end'] = date('Y-m-d', $result->format('U') + $duration--);
+ }else{
+ $return_event['start'] = $result->format('Y-m-d H:i:s');
+ $return_event['end'] = date('Y-m-d H:i:s', $result->format('U') + $duration);
+ }
+ $return[] = addoutput($event, $vevent, $return_event);
+ }
+ }else{
+ $return_event = array();
+ if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE){
+ $return_event['allDay'] = true;
+ $return_event['start'] = $start_dt->format('Y-m-d');
+ $end_dt->modify('-1 sec');
+ $return_event['end'] = $end_dt->format('Y-m-d');
+ }else{
+ $return_event['start'] = $start_dt->format('Y-m-d H:i:s');
+ $return_event['end'] = $end_dt->format('Y-m-d H:i:s');
+ $return_event['allDay'] = false;
+ }
+ $return[] = addoutput($event, $vevent, $return_event);
+ }
+}
+OC_JSON::encodedPrint($return);
+?> \ No newline at end of file
diff --git a/apps/calendar/ajax/getcal.php b/apps/calendar/ajax/getcal.php
deleted file mode 100644
index a65c6cf2602..00000000000
--- a/apps/calendar/ajax/getcal.php
+++ /dev/null
@@ -1,70 +0,0 @@
-<?php
-/**
- * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-
-require_once ("../../../lib/base.php");
-if(!OC_USER::isLoggedIn()) {
- die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
-}
-OC_JSON::checkAppEnabled('calendar');
-
-$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1);
-$events = array();
-$return = array('calendars'=>array());
-foreach($calendars as $calendar) {
- $tmp = OC_Calendar_Object::all($calendar['id']);
- $events = array_merge($events, $tmp);
- $return['calendars'][$calendar['id']] = array(
- 'displayname' => $calendar['displayname'],
- 'color' => '#'.$calendar['calendarcolor']
- );
-}
-
-$select_year = $_GET["year"];
-$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone", "Europe/London");
-foreach($events as $event)
-{
- if ($select_year != substr($event['startdate'], 0, 4))
- continue;
- $object = Sabre_VObject_Reader::read($event['calendardata']);
- $vevent = $object->VEVENT;
- $dtstart = $vevent->DTSTART;
- $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
- $start_dt = $dtstart->getDateTime();
- $start_dt->setTimezone(new DateTimeZone($user_timezone));
- $end_dt = $dtend->getDateTime();
- $end_dt->setTimezone(new DateTimeZone($user_timezone));
- $year = $start_dt->format('Y');
- $month = $start_dt->format('n') - 1; // return is 0 based
- $day = $start_dt->format('j');
- $hour = $start_dt->format('G');
- if ($dtstart->getDateType() == Sabre_VObject_Element_DateTime::DATE) {
- $hour = 'allday';
- }
-
- $return_event = array();
- foreach(array('id', 'calendarid', 'objecttype', 'repeating') as $prop)
- {
- $return_event[$prop] = $event[$prop];
- }
- $return_event['startdate'] = explode('|', $start_dt->format('Y|m|d|H|i'));
- $return_event['enddate'] = explode('|', $end_dt->format('Y|m|d|H|i'));
- $return_event['description'] = $event['summary'];
- if ($hour == 'allday')
- {
- $return_event['allday'] = true;
- }
- if (isset($return[$year][$month][$day][$hour]))
- {
- $return[$year][$month][$day][$hour][] = $return_event;
- }
- else
- {
- $return[$year][$month][$day][$hour] = array(1 => $return_event);
- }
-}
-OC_JSON::encodedPrint($return);
diff --git a/apps/calendar/ajax/guesstimezone.php b/apps/calendar/ajax/guesstimezone.php
new file mode 100755
index 00000000000..a3594498b0f
--- /dev/null
+++ b/apps/calendar/ajax/guesstimezone.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+function make_array_out_of_xml ($xml){
+ $returnarray = array();
+ $xml = (array)$xml ;
+ foreach ($xml as $property => $value){
+ $value = (array)$value;
+ if(!isset($value[0])){
+ $returnarray[$property] = make_array_out_of_xml($value);
+ }else{
+ $returnarray[$property] = trim($value[0]);
+ }
+ }
+ return $returnarray;
+}
+require_once ("../../../lib/base.php");
+OC_JSON::checkLoggedIn();
+OC_JSON::checkAppEnabled('calendar');
+$l = new OC_L10N('calendar');
+$lat = $_GET['lat'];
+$long = $_GET['long'];
+$geolocation = file_get_contents('http://ws.geonames.org/timezone?lat=' . $lat . '&lng=' . $long);
+//Information are by Geonames (http://www.geonames.org) and licensed under the Creative Commons Attribution 3.0 License
+$geoxml = simplexml_load_string($geolocation);
+$geoarray = make_array_out_of_xml($geoxml);
+if(isset($geoarray['timezone']['timezoneId']) && $geoarray['timezone']['timezoneId'] != ''){
+ OC_Preferences::setValue(OC_USER::getUser(), 'calendar', 'timezone', $geoarray['timezone']['timezoneId']);
+ $message = array('message'=> $l->t('New Timezone:') . $geoarray['timezone']['timezoneId']);
+ OC_JSON::success($message);
+}else{
+ OC_JSON::error();
+}
+
+?> \ No newline at end of file
diff --git a/apps/calendar/ajax/moveevent.php b/apps/calendar/ajax/moveevent.php
index e2b777969da..f2256d4eee6 100644
--- a/apps/calendar/ajax/moveevent.php
+++ b/apps/calendar/ajax/moveevent.php
@@ -1,103 +1,43 @@
<?php
/**
- * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
+ * Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
-error_reporting(E_ALL);
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
-$data = OC_Calendar_Object::find($_POST["id"]);
-$calendarid = $data["calendarid"];
-$cal = $calendarid;
-$id = $_POST["id"];
-$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
-if(OC_User::getUser() != $calendar["userid"]){
- OC_JSON::error();
- exit;
-}
-$newdate = $_POST["newdate"];
-$caldata = array();
-//modified part of editeventform.php
-$object = Sabre_VObject_Reader::read($data['calendardata']);
-$vevent = $object->VEVENT;
+
+$id = $_POST['id'];
+
+$vcalendar = OC_Calendar_App::getVCalendar($id);
+$vevent = $vcalendar->VEVENT;
+
+$allday = $_POST['allDay'];
+$delta = new DateInterval('P0D');
+$delta->d = $_POST['dayDelta'];
+$delta->i = $_POST['minuteDelta'];
+
+OC_Calendar_App::isNotModified($vevent, $_POST['lastmodified']);
+
$dtstart = $vevent->DTSTART;
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
-switch($dtstart->getDateType()) {
- case Sabre_VObject_Element_DateTime::LOCALTZ:
- case Sabre_VObject_Element_DateTime::LOCAL:
- $startdate = $dtstart->getDateTime()->format('d-m-Y');
- $starttime = $dtstart->getDateTime()->format('H:i');
- $enddate = $dtend->getDateTime()->format('d-m-Y');
- $endtime = $dtend->getDateTime()->format('H:i');
- $allday = false;
- break;
- case Sabre_VObject_Element_DateTime::DATE:
- $startdate = $dtstart->getDateTime()->format('d-m-Y');
- $starttime = '00:00';
- $dtend->getDateTime()->modify('-1 day');
- $enddate = $dtend->getDateTime()->format('d-m-Y');
- $endtime = '23:59';
- $allday = true;
- break;
-}
-$caldata["title"] = isset($vevent->SUMMARY) ? $vevent->SUMMARY->value : '';
-$caldata["location"] = isset($vevent->LOCATION) ? $vevent->LOCATION->value : '';
-$caldata["categories"] = array();
-if (isset($vevent->CATEGORIES)){
- $caldata["categories"] = explode(',', $vevent->CATEGORIES->value);
- $caldata["categories"] = array_map('trim', $categories);
-}
-foreach($caldata["categories"] as $category){
- if (!in_array($category, $category_options)){
- array_unshift($category_options, $category);
- }
+$start_type = $dtstart->getDateType();
+$end_type = $dtend->getDateType();
+if ($allday && $start_type != Sabre_VObject_Element_DateTime::DATE){
+ $start_type = $end_type = Sabre_VObject_Element_DateTime::DATE;
+ $dtend->setDateTime($dtend->getDateTime()->modify('+1 day'), $end_type);
}
-$caldata["repeat"] = isset($vevent->CATEGORY) ? $vevent->CATEGORY->value : '';
-$caldata["description"] = isset($vevent->DESCRIPTION) ? $vevent->DESCRIPTION->value : '';
-//end part of editeventform.php
-$startdatearray = explode("-", $startdate);
-$starttimearray = explode(":", $starttime);
-$startunix = mktime($starttimearray[0], $starttimearray[1], 0, $startdatearray[1], $startdatearray[0], $startdatearray[2]);
-$enddatearray = explode("-", $enddate);
-$endtimearray = explode(":", $endtime);
-$endunix = mktime($endtimearray[0], $endtimearray[1], 0, $enddatearray[1], $enddatearray[0], $enddatearray[2]);
-$difference = $endunix - $startunix;
-if(strlen($newdate) > 10){
- $newdatestringarray = explode("-", $newdate);
- if($newdatestringarray[1] == "allday"){
- $allday = true;
- $newdatestringarray[1] = "00:00";
- }else{
- if($allday == true){
- $difference = 3600;
- }
- $allday = false;
- }
-}else{
- $newdatestringarray = array();
- $newdatestringarray[0] = $newdate;
- $newdatestringarray[1] = $starttime;
+if (!$allday && $start_type == Sabre_VObject_Element_DateTime::DATE){
+ $start_type = $end_type = Sabre_VObject_Element_DateTime::LOCALTZ;
}
-$newdatearray = explode(".", $newdatestringarray[0]);
-$newtimearray = explode(":", $newdatestringarray[1]);
-$newstartunix = mktime($newtimearray[0], $newtimearray[1], 0, $newdatearray[1], $newdatearray[0], $newdatearray[2]);
-$newendunix = $newstartunix + $difference;
-if($allday == true){
- $caldata["allday"] = true;
-}else{
- unset($caldata["allday"]);
-}
-$caldata["from"] = date("d-m-Y", $newstartunix);
-$caldata["fromtime"] = date("H:i", $newstartunix);
-$caldata["to"] = date("d-m-Y", $newendunix);
-$caldata["totime"] = date("H:i", $newendunix);
-//modified part of editevent.php
-$vcalendar = Sabre_VObject_Reader::read($data["calendardata"]);
-OC_Calendar_Object::updateVCalendarFromRequest($caldata, $vcalendar);
+$dtstart->setDateTime($dtstart->getDateTime()->add($delta), $start_type);
+$dtend->setDateTime($dtend->getDateTime()->add($delta), $end_type);
+unset($vevent->DURATION);
+
+$vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC);
+$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC);
$result = OC_Calendar_Object::edit($id, $vcalendar->serialize());
-OC_JSON::success();
-//end part of editevent.php
-?> \ No newline at end of file
+$lastmodified = $vevent->__get('LAST-MODIFIED')->getDateTime();
+OC_JSON::success(array('lastmodified'=>(int)$lastmodified->format('U')));
diff --git a/apps/calendar/ajax/neweventform.php b/apps/calendar/ajax/neweventform.php
index 9d4dcfa2e13..e12e99219e6 100644
--- a/apps/calendar/ajax/neweventform.php
+++ b/apps/calendar/ajax/neweventform.php
@@ -8,50 +8,40 @@
require_once('../../../lib/base.php');
-$l10n = new OC_L10N('calendar');
-
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
}
OC_JSON::checkAppEnabled('calendar');
-$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
-$category_options = OC_Calendar_Object::getCategoryOptions($l10n);
-$repeat_options = OC_Calendar_Object::getRepeatOptions($l10n);
-$startday = substr($_GET['d'], 0, 2);
-$startmonth = substr($_GET['d'], 2, 2);
-$startyear = substr($_GET['d'], 4, 4);
-$starttime = $_GET['t'];
-$allday = $starttime == 'allday';
-if($starttime != 'undefined' && !is_nan($starttime) && !$allday){
- $startminutes = '00';
-}elseif($allday){
- $starttime = '0';
- $startminutes = '00';
-}else{
- $starttime = date('G');
-
- $startminutes = date('i');
+if (!isset($_POST['start'])){
+ OC_JSON::error();
+ die;
}
+$start = $_POST['start'];
+$end = $_POST['end'];
+$allday = $_POST['allday'];
-$datetimestamp = mktime($starttime, $startminutes, 0, $startmonth, $startday, $startyear);
-$duration = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'duration', "60");
-$datetimestamp = $datetimestamp + ($duration * 60);
-$endmonth = date("m", $datetimestamp);
-$endday = date("d", $datetimestamp);
-$endyear = date("Y", $datetimestamp);
-$endtime = date("G", $datetimestamp);
-$endminutes = date("i", $datetimestamp);
-
+if (!$end){
+ $duration = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'duration', '60');
+ $end = $start + ($duration * 60);
+}
+$start = new DateTime('@'.$start);
+$end = new DateTime('@'.$end);
+$timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
+$start->setTimezone(new DateTimeZone($timezone));
+$end->setTimezone(new DateTimeZone($timezone));
+$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
+$category_options = OC_Calendar_App::getCategoryOptions();
+$repeat_options = OC_Calendar_App::getRepeatOptions();
$tmpl = new OC_Template('calendar', 'part.newevent');
$tmpl->assign('calendar_options', $calendar_options);
$tmpl->assign('category_options', $category_options);
-$tmpl->assign('startdate', $startday . '-' . $startmonth . '-' . $startyear);
-$tmpl->assign('starttime', ($starttime <= 9 ? '0' : '') . $starttime . ':' . $startminutes);
-$tmpl->assign('enddate', $endday . '-' . $endmonth . '-' . $endyear);
-$tmpl->assign('endtime', ($endtime <= 9 ? '0' : '') . $endtime . ':' . $endminutes);
+$tmpl->assign('startdate', $start->format('d-m-Y'));
+$tmpl->assign('starttime', $start->format('H:i'));
+$tmpl->assign('enddate', $end->format('d-m-Y'));
+$tmpl->assign('endtime', $end->format('H:i'));
$tmpl->assign('allday', $allday);
$tmpl->printpage();
?>
diff --git a/apps/calendar/ajax/resizeevent.php b/apps/calendar/ajax/resizeevent.php
new file mode 100644
index 00000000000..68347906529
--- /dev/null
+++ b/apps/calendar/ajax/resizeevent.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+require_once('../../../lib/base.php');
+OC_JSON::checkLoggedIn();
+
+$id = $_POST['id'];
+
+$vcalendar = OC_Calendar_App::getVCalendar($id);
+$vevent = $vcalendar->VEVENT;
+
+$delta = new DateInterval('P0D');
+$delta->d = $_POST['dayDelta'];
+$delta->i = $_POST['minuteDelta'];
+
+OC_Calendar_App::isNotModified($vevent, $_POST['lastmodified']);
+
+$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
+$end_type = $dtend->getDateType();
+$dtend->setDateTime($dtend->getDateTime()->add($delta), $end_type);
+unset($vevent->DURATION);
+
+$vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC);
+$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC);
+
+$result = OC_Calendar_Object::edit($id, $vcalendar->serialize());
+$lastmodified = $vevent->__get('LAST-MODIFIED')->getDateTime();
+OC_JSON::success(array('lastmodified'=>(int)$lastmodified->format('U')));
diff --git a/apps/calendar/ajax/updatecalendar.php b/apps/calendar/ajax/updatecalendar.php
index a81644ded17..14f560da5a3 100644
--- a/apps/calendar/ajax/updatecalendar.php
+++ b/apps/calendar/ajax/updatecalendar.php
@@ -8,16 +8,19 @@
require_once('../../../lib/base.php');
-$l10n = new OC_L10N('calendar');
-
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$calendarid = $_POST['id'];
+$calendar = OC_Calendar_App::getCalendar($calendarid);//access check
OC_Calendar_Calendar::editCalendar($calendarid, $_POST['name'], null, null, null, $_POST['color']);
OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
-$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
+
+$calendar = OC_Calendar_App::getCalendar($calendarid);
$tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields');
$tmpl->assign('calendar', $calendar);
-OC_JSON::success(array('data' => $tmpl->fetchPage()));
+OC_JSON::success(array(
+ 'page' => $tmpl->fetchPage(),
+ 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar),
+));
diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php
index 2dc01eab0f6..ee990723c0c 100644
--- a/apps/calendar/appinfo/app.php
+++ b/apps/calendar/appinfo/app.php
@@ -1,5 +1,6 @@
<?php
$l=new OC_L10N('calendar');
+OC::$CLASSPATH['OC_Calendar_App'] = 'apps/calendar/lib/app.php';
OC::$CLASSPATH['OC_Calendar_Calendar'] = 'apps/calendar/lib/calendar.php';
OC::$CLASSPATH['OC_Calendar_Object'] = 'apps/calendar/lib/object.php';
OC::$CLASSPATH['OC_Calendar_Hooks'] = 'apps/calendar/lib/hooks.php';
@@ -21,3 +22,5 @@ OC_App::addNavigationEntry( array(
'name' => $l->t('Calendar')));
OC_App::registerPersonal('calendar', 'settings');
+
+require_once('apps/calendar/lib/search.php');
diff --git a/apps/calendar/css/style.css b/apps/calendar/css/style.css
index 80d29ca8974..0204f2fc12f 100644
--- a/apps/calendar/css/style.css
+++ b/apps/calendar/css/style.css
@@ -17,19 +17,12 @@
#editentry_dialog {display: none;}
#parsingfail_dialog{display: none;}
-#calendar_holder {height: 100%; width: 100%;}
-#onedayview, #oneweekview, #fourweeksview, #onemonthview, #listview {display: none; position: absolute;bottom: 0; right: 0; left: 160px; top: 80px;}
-#onedayview table {margin: 0; padding: 0; width: 100%; height: 100%; border-spacing:1px; background: #EEEEEE;}
-#oneweekview table {margin: 0; padding: 0; width: 100%; height: 100%; border-spacing:1px; background: #EEEEEE;}
-#fourweeksview table {margin: 0; padding: 0; width: 100%; height: 100%; border-spacing:1px; background: #EEEEEE;overflow: hidden;}
-#onemonthview table {margin: 0; padding: 0; width: 100%; height: 100%; border-spacing:1px; background: #EEEEEE;}
+#calendar_holder {position: relative;bottom: 0; right: 0; left: 0; top: 3em;}
+.fc-content{padding:2px 4px;}
#listview {margin: 0; padding: 10px; background: #EEEEEE;}
#listview #more_before, #listview #more_after {border: 1px solid #1a1a1a; width:25em;padding: 3px;text-align: center;}
#listview #events {width:25em;padding: 4px;}
#listview #events .day {width:auto;padding-left:10px;border-bottom: 2px solid #EEEEEE;text-align:left;}
-#fourweeksview .calw{vertical-align: middle;text-align: center;width: 50px;}
-
-#sysbox{display: none;}
.actions {height: 33px; min-width: 800px;}
.controls {min-width: 800px;}
@@ -60,3 +53,75 @@ button.category{margin:0 3px;}
.calendar-colorpicker-color{display:inline-block;width:20px;height:20px;margin-right:2px;cursor:pointer;border:2px solid transparent;}
.calendar-colorpicker-color.active{border:2px solid black;}
+
+.fc-list-table
+{
+ margin: 10px;
+ border-style: hidden;
+ border-width: 10px;
+ padding: 10px;
+ vertical-align: top;
+ width: 100%;
+}
+.fc-list-table tr:hover
+{
+ color: #0000FF;
+ background-color: #CCFFCC;
+}
+
+
+.fc-list-date
+{
+ margin: 16px;
+ white-space: nowrap;
+ text-align: left;
+ width: 100%;
+ background-color: #808080;
+ color: #FFFFFF;
+ font-weight: bold;
+ font-family: Arial, Helvetica, sans-serif;
+}
+.fc-list-time
+{
+ text-align: center;
+ white-space: nowrap;
+ width: 1%;
+}
+
+.fc-list-event
+{
+ text-align: left;
+}
+
+.fc-list-event .fc-event-title
+{
+ cursor: pointer;
+}
+.tipsy-event .tipsy-inner{
+background-color:#0098E4;
+border:2px solid #1d2d44;
+max-width:400px;
+padding:0;
+}
+.tipsy-event .tipsy-arrow-s{
+border-top-color:#1d2d44;
+}
+.tipsy-event .tipsy-arrow-n{
+border-bottom-color:#1d2d44;
+}
+.tipsy-event .summary,
+.tipsy-event .timespan,
+.tipsy-event .description{
+padding:0 8px;
+}
+.tipsy-event .summary{
+background-color:#1d2d44;
+font-size:1.2em;
+font-weight:bold;
+text-align:left;
+padding:0 8px 2px;
+}
+.tipsy-event .description{
+line-height:1.2;
+margin-bottom:4px;
+}
diff --git a/apps/calendar/export.php b/apps/calendar/export.php
index 3e93a1ad618..9b3ea5005d6 100644
--- a/apps/calendar/export.php
+++ b/apps/calendar/export.php
@@ -12,25 +12,17 @@ OC_Util::checkAppEnabled('calendar');
$cal = isset($_GET["calid"]) ? $_GET["calid"] : NULL;
$event = isset($_GET["eventid"]) ? $_GET["eventid"] : NULL;
if(isset($cal)){
- $calendar = OC_Calendar_Calendar::findCalendar($cal);
- if($calendar["userid"] != OC_User::getUser()){
- OC_JSON::error();
- exit;
- }
+ $calendar = OC_Calendar_App::getCalendar($cal);
$calobjects = OC_Calendar_Object::all($cal);
header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=calendar.ics");
- for($i = 0;$i <= count($calobjects); $i++){
- echo $calobjects[$i]["calendardata"] . "\n";
+ foreach($calobjects as $calobject){
+ echo $calobject["calendardata"] . "\n";
}
}elseif(isset($event)){
- $data = OC_Calendar_Object::find($_GET["eventid"]);
+ $data = OC_Calendar_App::getEventObject($_GET["eventid"]);
$calendarid = $data["calendarid"];
- $calendar = OC_Calendar_Calendar::findCalendar($calendarid);
- if($calendar["userid"] != OC_User::getUser()){
- OC_JSON::error();
- exit;
- }
+ $calendar = OC_Calendar_App::getCalendar($calendarid);
header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=" . $data["summary"] . ".ics");
echo $data["calendardata"];
diff --git a/apps/calendar/import.php b/apps/calendar/import.php
index 211791f551b..759726b8d10 100644
--- a/apps/calendar/import.php
+++ b/apps/calendar/import.php
@@ -12,11 +12,7 @@ OC_Util::checkAppEnabled('calendar');
if($_GET["import"] == "existing"){
$calid = $_GET["calid"];
- $calendar = OC_Calendar_Calendar::findCalendar($calid);
- if($calendar['userid'] != OC_User::getUser()){
- OC_JSON::error();
- exit;
- }
+ $calendar = OC_Calendar_App::getCalendar($calid);
if($_GET["path"] != ""){
$filename = $_GET["path"] . "/" . $_GET["file"];
}else{
@@ -47,4 +43,4 @@ for($i = 1;$i < count($vcalendar);$i++){
OC_Calendar_Object::add($calid, $vcalendar[$i]);
}
OC_JSON::success();
-?> \ No newline at end of file
+?>
diff --git a/apps/calendar/index.php b/apps/calendar/index.php
index 8b8ac729588..3313750d52e 100644
--- a/apps/calendar/index.php
+++ b/apps/calendar/index.php
@@ -10,15 +10,36 @@ require_once ('../../lib/base.php');
OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('calendar');
// Create default calendar ...
-$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
+$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1);
if( count($calendars) == 0){
OC_Calendar_Calendar::addCalendar(OC_User::getUser(),'Default calendar');
- $calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
+ $calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1);
}
-OC_UTIL::addScript('calendar', 'calendar');
-OC_UTIL::addStyle('calendar', 'style');
-OC_UTIL::addScript('', 'jquery.multiselect');
-OC_UTIL::addStyle('', 'jquery.multiselect');
-OC_APP::setActiveNavigationEntry('calendar_index');
-$output = new OC_TEMPLATE('calendar', 'calendar', 'user');
-$output -> printPage();
+$eventSources = array();
+foreach($calendars as $calendar){
+ $eventSources[] = OC_Calendar_Calendar::getEventSourceInfo($calendar);
+}
+//Fix currentview for fullcalendar
+if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') == "oneweekview"){
+ OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", "agendaWeek");
+}
+if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') == "onemonthview"){
+ OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", "month");
+}
+if(OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') == "listview"){
+ OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", "list");
+}
+
+OC_Util::addScript('3rdparty/fullcalendar', 'fullcalendar');
+OC_Util::addStyle('3rdparty/fullcalendar', 'fullcalendar');
+if(OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone") == null){
+ OC_UTIL::addScript('calendar', 'geo');
+}
+OC_Util::addScript('calendar', 'calendar');
+OC_Util::addStyle('calendar', 'style');
+OC_Util::addScript('', 'jquery.multiselect');
+OC_Util::addStyle('', 'jquery.multiselect');
+OC_App::setActiveNavigationEntry('calendar_index');
+$tmpl = new OC_Template('calendar', 'calendar', 'user');
+$tmpl->assign('eventSources', $eventSources);
+$tmpl->printPage(); \ No newline at end of file
diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js
index 2917d9f9134..c3644b53704 100644
--- a/apps/calendar/js/calendar.js
+++ b/apps/calendar/js/calendar.js
@@ -7,262 +7,10 @@
*/
Calendar={
- space:' ',
- firstdayofweek: '',
- weekend: '',
- Date:{
- normal_year_cal: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
- leap_year_cal: [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
- calw:function() {
- var dayofweek = this.current.getDay();
- if(dayofweek == 0) {
- dayofweek = 7;
- }
- var calw = Math.floor((this.doy() - dayofweek) / 7) + 1;
- return calw;
- },
-
- doy:function() {
- var cal = this.getnumberofdays(this.current.getFullYear());
- var doy = 0;
- for(var i = 0; i < this.current.getMonth(); i++) {
- doy = doy + cal[i];
- }
- doy = doy + this.current.getDate();
- return doy;
- },
-
- getnumberofdays:function(year) {
- if(this.checkforleapyear(year) == true) {
- var cal = this.leap_year_cal;
- } else {
- var cal = this.normal_year_cal;
- }
- return cal;
- },
-
- checkforleapyear:function(year2check) {
- if((year2check / 600) == Math.floor(year2check / 400)) {
- return true;
- }
- if((year2check / 4) == Math.floor(year2check / 4)) {
- if((year2check / 100) == Math.floor(year2check / 100)) {
- return false;
- }
- return true;
- }
- return false;
- },
-
- current:new Date(),
- forward_day:function(){
- this.current.setDate(this.current.getDate()+1);
- },
-
- forward_week:function(){
- this.current.setDate(this.current.getDate()+7);
- },
-
- forward_month:function(){
- this.current.setMonth(this.current.getMonth()+1);
- },
-
- backward_day:function(){
- this.current.setDate(this.current.getDate()-1);
- },
-
- backward_week:function(){
- this.current.setDate(this.current.getDate()-7);
- },
-
- backward_month:function(){
- this.current.setMonth(this.current.getMonth()-1);
- },
-
- },
UI:{
- weekdays: '',
- formatDayShort:function(day){
- if (typeof(day) == 'undefined'){
- day = Calendar.Date.current.getDay();
- }
- return this.dayshort[day];
- },
- formatDayLong:function(day){
- if (typeof(day) == 'undefined'){
- day = Calendar.Date.current.getDay();
- }
- return this.daylong[day];
- },
- formatMonthShort:function(month){
- if (typeof(month) == 'undefined'){
- month = Calendar.Date.current.getMonth();
- }
- return this.monthshort[month];
- },
- formatMonthLong:function(month){
- if (typeof(month) == 'undefined'){
- month = Calendar.Date.current.getMonth();
- }
- return this.monthlong[month];
- },
- formatDate:function(date){
- return date[0] + '-' + date[1] + '-' + date[2];
- },
- formatTime:function(date){
- return date[3] + ':' + date[4];
- },
- updateView:function() {
- this.current.removeEvents();
- this.current.renderCal();
- this.current.showEvents();
- },
- currentview:'none',
- setCurrentView:function(view){
- if (view == this.currentview){
- return;
- }
- $('#'+this.currentview).hide();
- $('#'+this.currentview + "_radio").removeClass('active');
- this.currentview = view;
- //sending ajax request on every change view
- $("#sysbox").load(OC.filePath('calendar', 'ajax', 'changeview.php') + "?v="+view);
- //not necessary to check whether the response is true or not
- switch(view) {
- case "onedayview":
- this.current = this.OneDay;
- break;
- case "oneweekview":
- this.current = this.OneWeek;
- break;
- case "fourweeksview":
- this.current = this.FourWeeks;
- break;
- case "onemonthview":
- this.current = this.OneMonth;
- break;
- case "listview":
- this.current = this.List;
- break;
- default:
- alert('Unknown view:'+view);
- break;
- }
- $(document).ready(function() {
- $('#'+Calendar.UI.currentview).show();
- $('#'+Calendar.UI.currentview + "_radio")
- .addClass('active');
- Calendar.UI.updateView()
- });
- },
- drageventid: '',
- updateDate:function(direction){
- if(direction == 'forward' && this.current.forward) {
- this.current.forward();
- if(Calendar.Date.current.getMonth() == 11){
- this.loadEvents(Calendar.Date.current.getFullYear() + 1);
- }
- this.updateView();
- }
- if(direction == 'backward' && this.current.backward) {
- this.current.backward();
- if(Calendar.Date.current.getMonth() == 0){
- this.loadEvents(Calendar.Date.current.getFullYear() - 1);
- }
- this.updateView();
- }
- },
- events:[],
- loadEvents:function(year){
- if( typeof (year) == 'undefined') {
- this.events = [];
- year = Calendar.Date.current.getFullYear();
- }
- if( typeof (this.events[year]) == "undefined") {
- this.events[year] = []
- }
- $.getJSON(OC.filePath('calendar', 'ajax', 'getcal.php') + "?year=" + year, function(jsondata, status) {
- if(status == "nosession") {
- alert("You are not logged in. That can happen if you don't use owncloud for a long time.");
- document.location(oc_webroot);
- }
- if(status == "parsingfail" || typeof (jsondata) == "undefined") {
- $.ready(function() {
- $( "#parsingfail_dialog" ).dialog();
- });
- } else {
- if (typeof(jsondata[year]) != 'undefined'){
- Calendar.UI.calendars = jsondata['calendars'];
- Calendar.UI.events[year] = jsondata[year];
- }
- $(document).ready(function() {
- Calendar.UI.updateView();
- });
- }
- });
- window.setTimeout("Calendar.UI.loadEvents(" + year + ")", 120000);
- },
- getEventsForDate:function(date){
- var day = date.getDate();
- var month = date.getMonth();
- var year = date.getFullYear();
- if( typeof (this.events[year]) == "undefined") {
- this.loadEvents(year);
- return false;
- }
- if( typeof (this.events[year][month]) == "undefined") {
- return false;
- }
- if( typeof (this.events[year][month][day]) == "undefined") {
- return false;
- }
- return this.events[year][month][day];
- },
- createEventsForDate:function(date, week){
- events = this.getEventsForDate(date);
- if (!events) {
- return;
- }
- var weekday = (date.getDay()+7-Calendar.firstdayofweek)%7;
- if( typeof (events["allday"]) != "undefined") {
- var eventnumber = 1;
- var eventcontainer = this.current.getEventContainer(week, weekday, "allday");
- while( typeof (events["allday"][eventnumber]) != "undefined") {
- this.addEventLabel(eventcontainer, events['allday'][eventnumber]);
- eventnumber++;
- }
- }
- for(var time = 0; time <= 23; time++) {
- if( typeof (events[time]) != "undefined") {
- var eventnumber = 1;
- var eventcontainer = this.current.getEventContainer(week, weekday, time);
- while( typeof (events[time][eventnumber]) != "undefined") {
- this.addEventLabel(eventcontainer, events[time][eventnumber]);
- eventnumber++;
- }
- }
- }
- },
- addEventLabel:function(eventcontainer, event){
- var event_holder = this.current.createEventLabel(event)
- .addClass('event')
- .data('event_info', event)
- .hover(this.createEventPopup,
- this.hideEventPopup)
- .draggable({
- drag: function() {
- Calendar.UI.drageventid = event.id;
- }
- })
- .click(this.editEvent);
- var color = this.calendars[event['calendarid']]['color'];
- if (color){
- event_holder.css('background-color', color)
- .addClass('colored');
- }
- eventcontainer.append(event_holder);
- },
startEventDialog:function(){
+ $('.tipsy').remove();
+ $('#calendar_holder').fullCalendar('unselect');
Calendar.UI.lockTime();
$( "#from" ).datepicker({
dateFormat : 'dd-mm-yy'
@@ -284,30 +32,20 @@ Calendar={
}
});
},
- newEvent:function(selector, time){
- var date_info = $(selector).data('date_info');
- var dayofmonth = date_info.getDate();
- var month = date_info.getMonth();
- var year = date_info.getFullYear();
- if(dayofmonth <= 9){
- dayofmonth = '0' + dayofmonth;
- }
- month++;
- if(month <= 9){
- month = '0' + month;
+ newEvent:function(start, end, allday){
+ start = Math.round(start.getTime()/1000);
+ if (end){
+ end = Math.round(end.getTime()/1000);
}
- var date = String(dayofmonth) + String(month) + String(year);
if($('#event').dialog('isOpen') == true){
// TODO: save event
$('#event').dialog('destroy').remove();
}else{
- $('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'neweventform.php') + '?d=' + date + '&t=' + time, Calendar.UI.startEventDialog);
+ $('#dialog_holder').load(OC.filePath('calendar', 'ajax', 'neweventform.php'), {start:start, end:end, allday:allday?1:0}, Calendar.UI.startEventDialog);
}
},
- editEvent:function(event){
- event.stopPropagation();
- var event_data = $(this).data('event_info');
- var id = event_data.id;
+ editEvent:function(calEvent, jsEvent, view){
+ var id = calEvent.id;
if($('#event').dialog('isOpen') == true){
// TODO: save event
$('#event').dialog('destroy').remove();
@@ -316,14 +54,14 @@ Calendar={
}
},
submitDeleteEventForm:function(url){
- var post = $( "#event_form" ).serialize();
- $("#errorbox").empty();
+ var post = $( '#event_form' ).serialize();
+ $('#errorbox').empty();
$.post(url, post, function(data){
if(data.status == 'success'){
+ $('#calendar_holder').fullCalendar('removeEvents', $('#event_form input[name=id]').val());
$('#event').dialog('destroy').remove();
- Calendar.UI.loadEvents();
} else {
- $("#errorbox").html("Deletion failed");
+ $('#errorbox').html(t('calendar', 'Deletion failed'));
}
}, "json");
@@ -334,27 +72,27 @@ Calendar={
$.post(url, post,
function(data){
if(data.status == "error"){
- var output = "Missing fields: <br />";
+ var output = missing_field + ": <br />";
if(data.title == "true"){
- output = output + "Title<br />";
+ output = output + missing_field_title + "<br />";
}
if(data.cal == "true"){
- output = output + "Calendar<br />";
+ output = output + missing_field_calendar + "<br />";
}
if(data.from == "true"){
- output = output + "From Date<br />";
+ output = output + missing_field_fromdate + "<br />";
}
if(data.fromtime == "true"){
- output = output + "From Time<br />";
+ output = output + missing_field_fromtime + "<br />";
}
if(data.to == "true"){
- output = output + "To Date<br />";
+ output = output + missing_field_todate + "<br />";
}
if(data.totime == "true"){
- output = output + "To Time<br />";
+ output = output + missing_field_totime + "<br />";
}
if(data.endbeforestart == "true"){
- output = "The event ends before it starts!";
+ output = output + missing_field_startsbeforeends + "!<br/>";
}
if(data.dberror == "true"){
output = "There was a database fail!";
@@ -363,65 +101,54 @@ Calendar={
} else
if(data.status == 'success'){
$('#event').dialog('destroy').remove();
- Calendar.UI.loadEvents();
+ $('#calendar_holder').fullCalendar('refetchEvents');
}
},"json");
},
- moveevent:function(eventid, newstartdate){
- $.post(OC.filePath('calendar', 'ajax', 'moveevent.php'), { id: eventid, newdate: newstartdate},
+ moveEvent:function(event, dayDelta, minuteDelta, allDay, revertFunc){
+ $('.tipsy').remove();
+ $.post(OC.filePath('calendar', 'ajax', 'moveevent.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, allDay: allDay?1:0, lastmodified: event.lastmodified},
function(data) {
- console.log("Event moved successfully");
+ if (data.status == 'success'){
+ event.lastmodified = data.lastmodified;
+ console.log("Event moved successfully");
+ }else{
+ revertFunc();
+ $('#calendar_holder').fullCalendar('refetchEvents');
+ }
+ });
+ },
+ resizeEvent:function(event, dayDelta, minuteDelta, revertFunc){
+ $('.tipsy').remove();
+ $.post(OC.filePath('calendar', 'ajax', 'resizeevent.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, lastmodified: event.lastmodified},
+ function(data) {
+ if (data.status == 'success'){
+ event.lastmodified = data.lastmodified;
+ console.log("Event resized successfully");
+ }else{
+ revertFunc();
+ $('#calendar_holder').fullCalendar('refetchEvents');
+ }
});
},
showadvancedoptions:function(){
$("#advanced_options").css("display", "block");
$("#advanced_options_button").css("display", "none");
},
- createEventPopup:function(e){
- var popup = $(this).data('popup');
- if (!popup){
- var event = $(this).data('event_info');
- popup = $(document.createElement('div'));
- $(this).data('popup', popup).append(popup);
- popup.addClass('popup')
- popup.addClass('event_popup')
- .html(Calendar.UI.getEventPopupText(event));
- }
- popup.css('left', -(popup.width() - $(this).width())/2)
- .show();
- },
- hideEventPopup:function(){
- $(this).data('popup').hide();
- },
getEventPopupText:function(event){
- var startdate = this.formatDate(event.startdate)
- var starttime = this.formatTime(event.startdate)
- var enddate = this.formatDate(event.enddate)
- var endtime = this.formatTime(event.enddate)
- if (event.allday){
- var timespan = startdate;
- if (event.startdate[2] != parseInt(event.enddate[2])-1){
- timespan += ' - ' + enddate;
- }
+ if (event.allDay){
+ var timespan = $.fullCalendar.formatDates(event.start, event.end, 'ddd d MMMM[ yyyy]{ -[ddd d] MMMM yyyy}', {monthNamesShort: monthNamesShort, monthNames: monthNames, dayNames: dayNames, dayNamesShort: dayNamesShort}); //t('calendar', "ddd d MMMM[ yyyy]{ -[ddd d] MMMM yyyy}")
}else{
- var start = startdate + ' ' + starttime;
- if (startdate == enddate){
- var end = endtime;
- }else{
- var end = enddate + ' ' + endtime;
- }
- var timespan = start + ' - ' + end;
+ var timespan = $.fullCalendar.formatDates(event.start, event.end, 'ddd d MMMM[ yyyy] ' + defaulttime + '{ -[ ddd d MMMM yyyy]' + defaulttime + '}', {monthNamesShort: monthNamesShort, monthNames: monthNames, dayNames: dayNames, dayNamesShort: dayNamesShort}); //t('calendar', "ddd d MMMM[ yyyy] HH:mm{ -[ ddd d MMMM yyyy] HH:mm}")
+ // Tue 18 October 2011 08:00 - 16:00
}
- return '<span class="timespan">' + timespan + '</span>'
- + ' '
- + '<span class="summary">' + event.description + '</span>';
- },
- addDateInfo:function(selector, date){
- $(selector).data('date_info', date);
- },
- switch2Today:function(){
- Calendar.Date.current = new Date();
- Calendar.UI.updateView();
+ var html =
+ '<div class="summary">' + event.title + '</div>' +
+ '<div class="timespan">' + timespan + '</div>';
+ if (event.description){
+ html += '<div class="description">' + event.description + '</div>';
+ }
+ return html;
},
lockTime:function(){
if($('#allday_checkbox').is(':checked')) {
@@ -441,54 +168,41 @@ Calendar={
$('#caldav_url').show();
$("#caldav_url_close").show();
},
- deleteCalendar:function(calid){
- var check = confirm("Do you really want to delete this calendar?");
- if(check == false){
- return false;
- }else{
- $.post(OC.filePath('calendar', 'ajax', 'deletecalendar.php'), { calendarid: calid},
- function(data) {
- Calendar.UI.loadEvents();
- $('#choosecalendar_dialog').dialog('destroy').remove();
- Calendar.UI.Calendar.overview();
- });
- }
- },
- initscroll:function(){
+ initScroll:function(){
if(window.addEventListener)
- document.addEventListener('DOMMouseScroll', Calendar.UI.scrollcalendar);
+ document.addEventListener('DOMMouseScroll', Calendar.UI.scrollCalendar);
//}else{
- document.onmousewheel = Calendar.UI.scrollcalendar;
+ document.onmousewheel = Calendar.UI.scrollCalendar;
//}
},
- scrollcalendar:function(event){
+ scrollCalendar:function(event){
+ $('.tipsy').remove();
var direction;
if(event.detail){
if(event.detail < 0){
- direction = "top";
+ direction = 'top';
}else{
- direction = "down";
+ direction = 'down';
}
}
if (event.wheelDelta){
if(event.wheelDelta > 0){
- direction = "top";
+ direction = 'top';
}else{
- direction = "down";
+ direction = 'down';
}
}
- if(Calendar.UI.currentview == "onemonthview"){
- if(direction == "down"){
- Calendar.UI.updateDate("forward");
- }else{
- Calendar.UI.updateDate("backward");
- }
- }else if(Calendar.UI.currentview == "oneweekview"){
- if(direction == "down"){
- Calendar.UI.updateDate("forward");
- }else{
- Calendar.UI.updateDate("backward");
- }
+ var scroll = $(document).scrollTop(),
+ doc_height = $(document).height(),
+ win_height = $(window).height();
+ if(direction == 'down' && win_height == (doc_height - scroll)){
+ $('#calendar_holder').fullCalendar('next');
+ $(document).scrollTop(0);
+ event.preventDefault();
+ }else if (direction == 'top' && scroll == 0) {
+ $('#calendar_holder').fullCalendar('prev');
+ $(document).scrollTop(win_height);
+ event.preventDefault();
}
},
Calendar:{
@@ -510,8 +224,14 @@ Calendar={
{
$.post(OC.filePath('calendar', 'ajax', 'activation.php'), { calendarid: calendarid, active: checkbox.checked?1:0 },
function(data) {
- checkbox.checked = data == 1;
- Calendar.UI.loadEvents();
+ if (data.status == 'success'){
+ checkbox.checked = data.active == 1;
+ if (data.active == 1){
+ $('#calendar_holder').fullCalendar('addEventSource', data.eventSource);
+ }else{
+ $('#calendar_holder').fullCalendar('removeEventSource', data.eventSource.url);
+ }
+ }
});
},
newCalendar:function(object){
@@ -526,6 +246,46 @@ Calendar={
function(){Calendar.UI.Calendar.colorPicker(this)});
$(object).closest('tr').after(tr).hide();
},
+ deleteCalendar:function(calid){
+ var check = confirm("Do you really want to delete this calendar?");
+ if(check == false){
+ return false;
+ }else{
+ $.post(OC.filePath('calendar', 'ajax', 'deletecalendar.php'), { calendarid: calid},
+ function(data) {
+ if (data.status == 'success'){
+ var url = 'ajax/events.php?calendar_id='+calid;
+ $('#calendar_holder').fullCalendar('removeEventSource', url);
+ $('#choosecalendar_dialog').dialog('destroy').remove();
+ Calendar.UI.Calendar.overview();
+ }
+ });
+ }
+ },
+ submit:function(button, calendarid){
+ var displayname = $("#displayname_"+calendarid).val();
+ var active = $("#edit_active_"+calendarid+":checked").length;
+ var description = $("#description_"+calendarid).val();
+ var calendarcolor = $("#calendarcolor_"+calendarid).val();
+
+ var url;
+ if (calendarid == 'new'){
+ url = OC.filePath('calendar', 'ajax', 'createcalendar.php');
+ }else{
+ url = OC.filePath('calendar', 'ajax', 'updatecalendar.php');
+ }
+ $.post(url, { id: calendarid, name: displayname, active: active, description: description, color: calendarcolor },
+ function(data){
+ if(data.status == 'success'){
+ $(button).closest('tr').prev().html(data.page).show().next().remove();
+ $('#calendar_holder').fullCalendar('removeEventSource', data.eventSource.url);
+ $('#calendar_holder').fullCalendar('addEventSource', data.eventSource);
+ }
+ }, 'json');
+ },
+ cancel:function(button, calendarid){
+ $(button).closest('tr').prev().show().next().remove();
+ },
colorPicker:function(container){
// based on jquery-colorpicker at jquery.webspirited.com
var obj = $('.colorpicker', container);
@@ -551,429 +311,233 @@ Calendar={
position: 'absolute',
left: -10000
});
- },
- submit:function(button, calendarid){
- var displayname = $("#displayname_"+calendarid).val();
- var active = $("#edit_active_"+calendarid+":checked").length;
- var description = $("#description_"+calendarid).val();
- var calendarcolor = $("#calendarcolor_"+calendarid).val();
+ }
+ }
+ }
+}
+$.fullCalendar.views.list = ListView;
+function ListView(element, calendar) {
+ var t = this;
- var url;
- if (calendarid == 'new'){
- url = "ajax/createcalendar.php";
- }else{
- url = "ajax/updatecalendar.php";
- }
- $.post(url, { id: calendarid, name: displayname, active: active, description: description, color: calendarcolor },
- function(data){
- if(data.error == "true"){
- }else{
- $(button).closest('tr').prev().html(data.data).show().next().remove();
- Calendar.UI.loadEvents();
- }
- }, 'json');
- },
- cancel:function(button, calendarid){
- $(button).closest('tr').prev().show().next().remove();
- },
- },/*
- OneDay:{
- forward:function(){
- Calendar.Date.forward_day();
- },
- backward:function(){
- Calendar.Date.backward_day();
- },
- removeEvents:function(){
- $("#onedayview .calendar_row").empty();
- },
- renderCal:function(){
- $("#datecontrol_date").val(Calendar.UI.formatDayShort() + Calendar.space + Calendar.Date.current.getDate() + Calendar.space + Calendar.UI.formatMonthShort() + Calendar.space + Calendar.Date.current.getFullYear());
- $("#onedayview_today").html(Calendar.UI.formatDayLong() + Calendar.space + Calendar.Date.current.getDate() + Calendar.space + Calendar.UI.formatMonthShort());
- Calendar.UI.addDateInfo('#onedayview_today', new Date(Calendar.Date.current));
- },
- showEvents:function(){
- Calendar.UI.createEventsForDate(Calendar.Date.current, 0);
- },
- getEventContainer:function(week, weekday, when){
- return $("#onedayview ." + when);
- },
- createEventLabel:function(event){
- var time = '';
- if (!event['allday']){
- time = '<strong>' + Calendar.UI.formatTime(event['startdate']) + ' - ' + Calendar.UI.formatTime(event['enddate']) + '</strong> ';
- }
- return $(document.createElement('p'))
- .html(time + event['description'])
- },
- },*/
- OneWeek:{
- forward:function(){
- Calendar.Date.forward_week();
- },
- backward:function(){
- Calendar.Date.backward_week();
- },
- removeEvents:function(){
- for( i = 0; i <= 6; i++) {
- $("#oneweekview ." + Calendar.UI.weekdays[i]).empty();
- }
- $("#oneweekview .thisday").removeClass("thisday");
- },
- renderCal:function(){
- $("#datecontrol_date").val(Calendar.UI.cw_label + ": " + Calendar.Date.calw());
- var dates = this.generateDates();
- var today = new Date();
- for(var i = 0; i <= 6; i++){
- $("#oneweekview th." + Calendar.UI.weekdays[i]).html(Calendar.UI.formatDayShort((i+Calendar.firstdayofweek)%7) + Calendar.space + dates[i].getDate() + Calendar.space + Calendar.UI.formatMonthShort(dates[i].getMonth()));
- $("#oneweekview td." + Calendar.UI.weekdays[i] + ".allday").attr('title', dates[i].getDate() + "." + String(parseInt(dates[i].getMonth()) + 1) + "." + dates[i].getFullYear() + "-" + "allday");
- $("#oneweekview td." + Calendar.UI.weekdays[i] + ".allday").droppable({
- drop: function() {
- Calendar.UI.moveevent(Calendar.UI.drageventid, this.title);
- Calendar.UI.loadEvents();
- }
- });
- for(var ii = 0;ii <= 23; ii++){
- $("#oneweekview td." + Calendar.UI.weekdays[i] + "." + String(ii)).attr('title', dates[i].getDate() + "." + String(parseInt(dates[i].getMonth()) + 1) + "." + dates[i].getFullYear() + "-" + String(ii) + ":00");
- $("#oneweekview td." + Calendar.UI.weekdays[i] + "." + String(ii)).droppable({
- drop: function() {
- Calendar.UI.moveevent(Calendar.UI.drageventid, this.title);
- Calendar.UI.loadEvents();
- }
- });
- }
- if(dates[i].getDate() == today.getDate() && dates[i].getMonth() == today.getMonth() && dates[i].getFullYear() == today.getFullYear()){
- $("#oneweekview ." + Calendar.UI.weekdays[i]).addClass("thisday");
- }
- Calendar.UI.addDateInfo('#oneweekview th.' + Calendar.UI.weekdays[i], dates[i]);
- }
- },
- showEvents:function(){
- var dates = this.generateDates();
- for(var weekday = 0; weekday <= 6; weekday++) {
- Calendar.UI.createEventsForDate(dates[weekday], 0);
- }
- },
- getEventContainer:function(week, weekday, when){
- return $("#oneweekview ." + Calendar.UI.weekdays[weekday] + "." + when);
- },
- createEventLabel:function(event){
- var time = '';
- if (!event['allday']){
- time = '<strong>' + Calendar.UI.formatTime(event['startdate']) + ' - ' + Calendar.UI.formatTime(event['enddate']) + '</strong> ';
- }
- return $(document.createElement('p'))
- .html(time + event['description'])
- },
- generateDates:function(){
- var dates = new Array();
- var date = new Date(Calendar.Date.current)
- var dayofweek = date.getDay();
- if(dayofweek == 0) {
- dayofweek = 7;
- }
- if(Calendar.firstdayofweek > dayofweek){
- date.setDate(date.getDate() - dayofweek + Calendar.firstdayofweek - 7);
- }else{
- date.setDate(date.getDate() - dayofweek + Calendar.firstdayofweek);
- }
- for(var i = 0; i <= 6; i++) {
- dates[i] = new Date(date)
- date.setDate(date.getDate() + 1);
- }
- return dates;
- },
- },/*
- FourWeeks:{
- forward:function(){
- Calendar.Date.forward_week();
- },
- backward:function(){
- Calendar.Date.backward_week();
- },
- removeEvents:function(){
- $('#fourweeksview .day.thisday').removeClass('thisday');
- $('#fourweeksview .day .events').empty();
- },
- renderCal:function(){
- var calw1 = Calendar.Date.calw();
- var calw2 = calw1 + 1;
- var calw3 = calw1 + 2;
- var calw4 = calw1 + 3;
- switch(calw1) {
- case 50:
- calw4 = 1;
- break;
- case 51:
- calw3 = 1;
- calw4 = 2;
- break;
- case 52:
- calw2 = 1;
- calw3 = 2;
- calw4 = 3;
- break;
- }
- var calwplusfour = calw4;
- var dates = this.generateDates();
- var week = 1;
- var weekday = 0;
- var today = new Date();
- for(var i = 0; i <= 27; i++){
- var dayofmonth = dates[i].getDate();
- var month = dates[i].getMonth();
- var year = dates[i].getFullYear();
- $("#fourweeksview .week_" + week + " ." + Calendar.UI.weekdays[weekday] + " .dateinfo").html(dayofmonth + Calendar.space + Calendar.UI.formatMonthShort(month));
- if(dayofmonth == today.getDate() && month == today.getMonth() && year == today.getFullYear()){
- $("#fourweeksview .week_" + week + " ." + Calendar.UI.weekdays[weekday]).addClass('thisday');
- }
- Calendar.UI.addDateInfo('#fourweeksview .week_' + week + ' .' + Calendar.UI.weekdays[weekday], dates[i]);
- if(weekday == 6){
- weekday = 0;
- week++;
- }else{
- weekday++;
- }
- }
- $("#fourweeksview .week_1 .calw").html(calw1);
- $("#fourweeksview .week_2 .calw").html(calw2);
- $("#fourweeksview .week_3 .calw").html(calw3);
- $("#fourweeksview .week_4 .calw").html(calw4);
- $("#datecontrol_date").val(Calendar.UI.cws_label + ": " + Calendar.Date.calw() + " - " + calwplusfour);
- },
- showEvents:function(){
- var dates = this.generateDates();
- var weekdaynum = 0;
- var weeknum = 1;
- for(var i = 0; i <= 27; i++) {
- Calendar.UI.createEventsForDate(dates[i], weeknum);
- if(weekdaynum == 6){
- weekdaynum = 0;
- weeknum++;
- }else{
- weekdaynum++;
- }
- }
- },
- getEventContainer:function(week, weekday, when){
- return $("#fourweeksview .week_" + week + " .day." + Calendar.UI.weekdays[weekday] + " .events");
- },
- createEventLabel:function(event){
- var time = '';
- if (!event['allday']){
- time = '<strong>' + Calendar.UI.formatTime(event['startdate']) + '</strong> ';
- }
- return $(document.createElement('p'))
- .html(time + event['description'])
- },
- generateDates:function(){
- var dates = new Array();
- var date = new Date(Calendar.Date.current)
- var dayofweek = date.getDay();
- if(dayofweek == 0) {
- dayofweek = 7;
- }
- date.setDate(date.getDate() - dayofweek + 1);
- for(var i = 0; i <= 27; i++) {
- dates[i] = new Date(date)
- date.setDate(date.getDate() + 1);
- }
- return dates;
- },
- },*/
- OneMonth:{
- forward:function(){
- Calendar.Date.forward_month();
- },
- backward:function(){
- Calendar.Date.backward_month();
- },
- removeEvents:function(){
- $('#onemonthview .day.thisday').removeClass('thisday');
- $('#onemonthview .day .events').empty();
- },
- renderCal:function(){
- $("#datecontrol_date").val(Calendar.UI.formatMonthLong() + Calendar.space + Calendar.Date.current.getFullYear());
- var cal = Calendar.Date.getnumberofdays(Calendar.Date.current.getFullYear());
- var monthview_dayofweek = Calendar.Date.current.getDay();
- var monthview_dayofmonth = Calendar.Date.current.getDate();
- for(var i = monthview_dayofmonth; i > 1; i--) {
- if(monthview_dayofweek == 0) {
- monthview_dayofweek = 6;
- } else {
- monthview_dayofweek--;
- }
- }
- $("#onemonthview .week_5").hide();
- $("#onemonthview .week_6").hide();
- this.rows = monthview_dayofweek + cal[Calendar.Date.current.getMonth()];
- this.rows = this.rows / 7;
- this.rows = Math.ceil(this.rows);
- var dates = this.generateDates();
- var week = 1;
- var weekday = 0;
- var today = new Date();
- for(var i = 0; i <= 41; i++){
- var dayofmonth = dates[i].getDate();
- var month = dates[i].getMonth();
- var year = dates[i].getFullYear();
- $("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday] + " .dateinfo").html(dayofmonth + Calendar.space + Calendar.UI.formatMonthShort(month));
- $("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday]).attr('title', dayofmonth + "." + String(parseInt(month) + 1) + "." + year);
- $("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday]).droppable({
- drop: function() {
- Calendar.UI.moveevent(Calendar.UI.drageventid, this.title);
- Calendar.UI.loadEvents();
- }
- });
- if(dayofmonth == today.getDate() && month == today.getMonth() && year == today.getFullYear()){
- $("#onemonthview .week_" + week + " ." + Calendar.UI.weekdays[weekday]).addClass('thisday');
- }
- Calendar.UI.addDateInfo('#onemonthview .week_' + week + ' .' + Calendar.UI.weekdays[weekday], dates[i]);
- if(weekday == 6){
- weekday = 0;
- week++;
- }else{
- weekday++;
- }
- }
- if(this.rows == 4){
- for(var i = 1;i <= 6;i++){
- $("#onemonthview .week_" + String(i)).height("23%");
- }
- }
- if(this.rows == 5) {
- $("#onemonthview .week_5").show();
- for(var i = 1;i <= 6;i++){
- $("#onemonthview .week_" + String(i)).height("18%");
- }
- }
- if(this.rows == 6) {
- $("#onemonthview .week_5").show();
- $("#onemonthview .week_6").show();
- for(var i = 1;i <= 6;i++){
- $("#onemonthview .week_" + String(i)).height("14%");
- }
- }
- },
- showEvents:function(){
- var dates = this.generateDates();
- var weekdaynum = 0;
- var weeknum = 1;
- for(var i = 0; i <= 41; i++) {
- Calendar.UI.createEventsForDate(dates[i], weeknum);
- if(weekdaynum == 6){
- weekdaynum = 0;
- weeknum++;
- }else{
- weekdaynum++;
- }
- }
- },
- getEventContainer:function(week, weekday, when){
- return $("#onemonthview .week_" + week + " .day." + Calendar.UI.weekdays[weekday] + " .events");
- },
- createEventLabel:function(event){
- var time = '';
- if (!event['allday']){
- time = '<strong>' + Calendar.UI.formatTime(event['startdate']) + '</strong> ';
- }
- return $(document.createElement('p'))
- .html(time + event['description'])
- },
- generateDates:function(){
- var dates = new Array();
- var date = new Date(Calendar.Date.current)
- date.setDate(1);
- var dayofweek = date.getDay();
- if(dayofweek == 0) {
- dayofweek = 7;
- this.rows++;
- }
- if(Calendar.firstdayofweek > dayofweek){
- date.setDate(date.getDate() - dayofweek + Calendar.firstdayofweek - 7);
- }else{
- date.setDate(date.getDate() - dayofweek + Calendar.firstdayofweek);
- }
- for(var i = 0; i <= 41; i++) {
- dates[i] = new Date(date)
- date.setDate(date.getDate() + 1);
+ // imports
+ jQuery.fullCalendar.views.month.call(t, element, calendar);
+ var opt = t.opt;
+ var trigger = t.trigger;
+ var eventElementHandlers = t.eventElementHandlers;
+ var reportEventElement = t.reportEventElement;
+ var formatDate = calendar.formatDate;
+ var formatDates = calendar.formatDates;
+ var addDays = $.fullCalendar.addDays;
+ var cloneDate = $.fullCalendar.cloneDate;
+ function skipWeekend(date, inc, excl) {
+ inc = inc || 1;
+ while (!date.getDay() || (excl && date.getDay()==1 || !excl && date.getDay()==6)) {
+ addDays(date, inc);
+ }
+ return date;
+ }
+
+ // overrides
+ t.name='list';
+ t.render=render;
+ t.renderEvents=renderEvents;
+ t.setHeight=setHeight;
+ t.setWidth=setWidth;
+ t.clearEvents=clearEvents;
+
+ function setHeight(height, dateChanged) {
+ }
+
+ function setWidth(width) {
+ }
+
+ function clearEvents() {
+ this.reportEventClear();
+ }
+
+ // main
+ function sortEvent(a, b) {
+ return a.start - b.start;
+ }
+
+ function render(date, delta) {
+ if (!t.start){
+ t.start = addDays(cloneDate(date, true), -7);
+ t.end = addDays(cloneDate(date, true), 7);
+ }
+ if (delta) {
+ if (delta < 0){
+ addDays(t.start, -7);
+ if (!opt('weekends')) {
+ skipWeekend(t.start, delta < 0 ? -1 : 1);
}
- return dates;
- },
- },
- List:{
- removeEvents:function(){
- this.eventContainer = $('#listview #events').empty();
- this.startdate = new Date();
- this.enddate = new Date();
- this.enddate.setDate(this.enddate.getDate());
- },
- renderCal:function(){
- var today = new Date();
- $('#datecontrol_date').val(this.formatDate(Calendar.Date.current));
- },
- showEvents:function(){
- this.renderMoreBefore();
- this.renderMoreAfter();
- },
- formatDate:function(date){
- return Calendar.UI.formatDayShort(date.getDay())
- + Calendar.space
- + date.getDate()
- + Calendar.space
- + Calendar.UI.formatMonthShort(date.getMonth())
- + Calendar.space
- + date.getFullYear();
- },
- createDay:function(date) {
- return $(document.createElement('div'))
- .addClass('day')
- .html(this.formatDate(date));
- },
- renderMoreBefore:function(){
- var date = Calendar.UI.List.startdate;
- for(var i = 0; i <= 13; i++) {
- if (Calendar.UI.getEventsForDate(date)) {
- Calendar.UI.List.dayContainer=Calendar.UI.List.createDay(date);
- Calendar.UI.createEventsForDate(date, 0);
- Calendar.UI.List.eventContainer.prepend(Calendar.UI.List.dayContainer);
- }
- date.setDate(date.getDate()-1);
+ }else{
+ addDays(t.end, 7);
+ if (!opt('weekends')) {
+ skipWeekend(t.end, delta < 0 ? -1 : 1);
}
- var start = Calendar.UI.List.formatDate(date);
- $('#listview #more_before').html(String(Calendar.UI.more_before).replace('{startdate}', start));
- },
- renderMoreAfter:function(){
- var date = Calendar.UI.List.enddate;
- for(var i = 0; i <= 13; i++) {
- if (Calendar.UI.getEventsForDate(date)) {
- Calendar.UI.List.dayContainer=Calendar.UI.List.createDay(date);
- Calendar.UI.createEventsForDate(date, 0);
- Calendar.UI.List.eventContainer.append(Calendar.UI.List.dayContainer);
- }
- date.setDate(date.getDate()+1);
+ }
+ }
+ t.title = formatDates(
+ t.start,
+ t.end,
+ opt('titleFormat', 'week')
+ );
+ t.visStart = cloneDate(t.start);
+ t.visEnd = cloneDate(t.end);
+ }
+
+ function eventsOfThisDay(events, theDate) {
+ var start = cloneDate(theDate, true);
+ var end = addDays(cloneDate(start), 1);
+ var retArr = new Array();
+ for (i in events) {
+ var event_end = t.eventEnd(events[i]);
+ if (events[i].start < end && event_end >= start) {
+ retArr.push(events[i]);
+ }
+ }
+ return retArr;
+ }
+
+ function renderEvent(event) {
+ if (event.allDay) { //all day event
+ var time = opt('allDayText');
+ }
+ else {
+ var time = formatDates(event.start, event.end, opt('timeFormat', 'agenda'));
+ }
+ var classes = ['fc-event', 'fc-list-event'];
+ classes = classes.concat(event.className);
+ if (event.source) {
+ classes = classes.concat(event.source.className || []);
+ }
+ var html = '<tr>' +
+ '<td>&nbsp;</td>' +
+ '<td class="fc-list-time">' +
+ time +
+ '</td>' +
+ '<td>&nbsp;</td>' +
+ '<td class="fc-list-event">' +
+ '<span id="list' + event.id + '"' +
+ ' class="' + classes.join(' ') + '"' +
+ '>' +
+ '<span class="fc-event-title">' +
+ event.title +
+ '</span>' +
+ '</span>' +
+ '</td>' +
+ '</tr>';
+ return html;
+ }
+
+ function renderDay(date, events) {
+ var dayRows = $('<tr>' +
+ '<td colspan="4" class="fc-list-date">' +
+ '<span>' +
+ formatDate(date, opt('titleFormat', 'day')) +
+ '</span>' +
+ '</td>' +
+ '</tr>');
+ for (i in events) {
+ var event = events[i];
+ var eventElement = $(renderEvent(event));
+ triggerRes = trigger('eventRender', event, event, eventElement);
+ if (triggerRes === false) {
+ eventElement.remove();
+ }else{
+ if (triggerRes && triggerRes !== true) {
+ eventElement.remove();
+ eventElement = $(triggerRes);
}
- var end = Calendar.UI.List.formatDate(date);
- $('#listview #more_after').html(String(Calendar.UI.more_after).replace('{enddate}', end));
- },
- getEventContainer:function(week, weekday, when){
- return this.dayContainer;
- },
- createEventLabel:function(event){
- var time = '';
- if (!event['allday']){
- time = Calendar.UI.formatTime(event['startdate']) + ' - ' + Calendar.UI.formatTime(event['enddate']) + ' ';
+ $.merge(dayRows, eventElement);
+ eventElementHandlers(event, eventElement);
+ reportEventElement(event, eventElement);
+ }
+ }
+ return dayRows;
+ }
+
+ function renderEvents(events, modifiedEventId) {
+ events = events.sort(sortEvent);
+
+ var table = $('<table class="fc-list-table"></table>');
+ var total = events.length;
+ if (total > 0) {
+ var date = cloneDate(t.visStart);
+ while (date <= t.visEnd) {
+ var dayEvents = eventsOfThisDay(events, date);
+ if (dayEvents.length > 0) {
+ table.append(renderDay(date, dayEvents));
}
- return $(document.createElement('p'))
- .html(time + event['description'])
- },
+ date=addDays(date, 1);
+ }
}
+
+ this.element.html(table);
}
}
$(document).ready(function(){
- $('#listview #more_before').click(Calendar.UI.List.renderMoreBefore);
- $('#listview #more_after').click(Calendar.UI.List.renderMoreAfter);
- Calendar.UI.initscroll();
+ Calendar.UI.initScroll();
+ $('#calendar_holder').fullCalendar({
+ header: false,
+ firstDay: 1,
+ editable: true,
+ defaultView: defaultView,
+ timeFormat: {
+ agenda: agendatime,
+ '': defaulttime
+ },
+ titleFormat: {
+ list: 'yyyy/MMM/d dddd'
+ },
+ axisFormat: defaulttime,
+ monthNames: monthNames,
+ monthNamesShort: monthNamesShort,
+ dayNames: dayNames,
+ dayNamesShort: dayNamesShort,
+ allDayText: allDayText,
+ viewDisplay: function(view) {
+ $('#datecontrol_date').html(view.title);
+ $.get(OC.filePath('calendar', 'ajax', 'changeview.php') + "?v="+view.name);
+ },
+ selectable: true,
+ selectHelper: true,
+ select: Calendar.UI.newEvent,
+ eventClick: Calendar.UI.editEvent,
+ eventDrop: Calendar.UI.moveEvent,
+ eventResize: Calendar.UI.resizeEvent,
+ eventRender: function(event, element) {
+ element.tipsy({
+ className: 'tipsy-event',
+ opacity: 0.9,
+ gravity:$.fn.tipsy.autoBounds(150, 's'),
+ fade:true,
+ delayIn: 400,
+ html:true,
+ title:function() {
+ return Calendar.UI.getEventPopupText(event);
+ }
+ });
+ },
+ eventSources: eventSources
+ });
+ $('#oneweekview_radio').click(function(){
+ $('#calendar_holder').fullCalendar('changeView', 'agendaWeek');
+ });
+ $('#onemonthview_radio').click(function(){
+ $('#calendar_holder').fullCalendar('changeView', 'month');
+ });
+ $('#listview_radio').click(function(){
+ $('#calendar_holder').fullCalendar('changeView', 'list');
+ });
+ $('#today_input').click(function(){
+ $('#calendar_holder').fullCalendar('today');
+ });
+ $('#datecontrol_left').click(function(){
+ $('#calendar_holder').fullCalendar('prev');
+ });
+ $('#datecontrol_right').click(function(){
+ $('#calendar_holder').fullCalendar('next');
+ });
});
-//event vars
-Calendar.UI.loadEvents();
diff --git a/apps/calendar/js/geo.js b/apps/calendar/js/geo.js
new file mode 100755
index 00000000000..acea17c0269
--- /dev/null
+++ b/apps/calendar/js/geo.js
@@ -0,0 +1,20 @@
+/**
+ * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+if (navigator.geolocation) {
+ navigator.geolocation.getCurrentPosition(function(position) {
+ $.getJSON(OC.filePath('calendar', 'ajax', 'guesstimezone.php?lat=' + position.coords.latitude + '&long=' + position.coords.longitude + ''),
+ function(data){
+ if (data.status == 'success'){
+ $('#notification').html(data.message);
+ $('#notification').slideDown();
+ window.setTimeout(function(){$('#notification').slideUp();}, 5000);
+ }else{
+ console.log('Can\'t set new timezone.');
+ }
+ });
+ });
+} \ No newline at end of file
diff --git a/apps/calendar/l10n/xgettextfiles b/apps/calendar/l10n/xgettextfiles
index 4cc636436b4..27b8e457193 100644
--- a/apps/calendar/l10n/xgettextfiles
+++ b/apps/calendar/l10n/xgettextfiles
@@ -1,7 +1,11 @@
../appinfo/app.php
+../lib/object.php
../templates/calendar.php
+../templates/part.choosecalendar.php
+../templates/part.choosecalendar.rowfields.php
+../templates/part.editcalendar.php
../templates/part.editevent.php
-../templates/part.eventinfo.php
+../templates/part.eventform.php
+../templates/part.import.php
../templates/part.newevent.php
-../templates/part.choosecalendar.php
-../js/calendar.js
+../templates/settings.php \ No newline at end of file
diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php
new file mode 100644
index 00000000000..b023d531aa5
--- /dev/null
+++ b/apps/calendar/lib/app.php
@@ -0,0 +1,82 @@
+<?php
+/**
+ * Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+/**
+ * This class manages our app actions
+ */
+OC_Calendar_App::$l10n = new OC_L10N('calendar');
+class OC_Calendar_App{
+ public static $l10n;
+
+ public static function getCalendar($id){
+ $calendar = OC_Calendar_Calendar::find( $id );
+ if( $calendar === false || $calendar['userid'] != OC_User::getUser()){
+ OC_JSON::error(array('data' => array('message' => self::$l10n->t('Wrong calendar'))));
+ exit();
+ }
+ return $calendar;
+ }
+
+ public static function getEventObject($id){
+ $event_object = OC_Calendar_Object::find( $id );
+ if( $event_object === false ){
+ OC_JSON::error();
+ exit();
+ }
+
+ self::getCalendar( $event_object['calendarid'] );//access check
+ return $event_object;
+ }
+
+ public static function getVCalendar($id){
+ $event_object = self::getEventObject( $id );
+
+ $vcalendar = OC_VObject::parse($event_object['calendardata']);
+ // Check if the vcalendar is valid
+ if(is_null($vcalendar)){
+ OC_JSON::error();
+ exit();
+ }
+ return $vcalendar;
+ }
+
+ public static function isNotModified($vevent, $lastmodified)
+ {
+ $last_modified = $vevent->__get('LAST-MODIFIED');
+ if($last_modified && $lastmodified != $last_modified->getDateTime()->format('U')){
+ OC_JSON::error(array('modified'=>true));
+ exit;
+ }
+ }
+
+ public static function getCategoryOptions()
+ {
+ return array(
+ self::$l10n->t('Birthday'),
+ self::$l10n->t('Business'),
+ self::$l10n->t('Call'),
+ self::$l10n->t('Clients'),
+ self::$l10n->t('Deliverer'),
+ self::$l10n->t('Holidays'),
+ self::$l10n->t('Ideas'),
+ self::$l10n->t('Journey'),
+ self::$l10n->t('Jubilee'),
+ self::$l10n->t('Meeting'),
+ self::$l10n->t('Other'),
+ self::$l10n->t('Personal'),
+ self::$l10n->t('Projects'),
+ self::$l10n->t('Questions'),
+ self::$l10n->t('Work'),
+ );
+ }
+
+ public static function getRepeatOptions()
+ {
+ OC_Calendar_Object::getRepeatOptions(self::$l10n);
+ }
+}
diff --git a/apps/calendar/lib/calendar.php b/apps/calendar/lib/calendar.php
index c19c0e73c08..ea60526a5bd 100644
--- a/apps/calendar/lib/calendar.php
+++ b/apps/calendar/lib/calendar.php
@@ -82,7 +82,7 @@ class OC_Calendar_Calendar{
* @param integer $id
* @return associative array
*/
- public static function findCalendar($id){
+ public static function find($id){
$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_calendars WHERE id = ?' );
$result = $stmt->execute(array($id));
@@ -111,7 +111,7 @@ class OC_Calendar_Calendar{
$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*calendar_calendars (userid,displayname,uri,ctag,calendarorder,calendarcolor,timezone,components) VALUES(?,?,?,?,?,?,?,?)' );
$result = $stmt->execute(array($userid,$name,$uri,1,$order,$color,$timezone,$components));
- return OC_DB::insertid();
+ return OC_DB::insertid('*PREFIX*calendar_calendar');
}
/**
@@ -131,7 +131,7 @@ class OC_Calendar_Calendar{
$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*calendar_calendars (userid,displayname,uri,ctag,calendarorder,calendarcolor,timezone,components) VALUES(?,?,?,?,?,?,?,?)' );
$result = $stmt->execute(array($userid,$name,$uri,1,$order,$color,$timezone,$components));
- return OC_DB::insertid();
+ return OC_DB::insertid('*PREFIX*calendar_calendars');
}
/**
@@ -148,7 +148,7 @@ class OC_Calendar_Calendar{
*/
public static function editCalendar($id,$name=null,$components=null,$timezone=null,$order=null,$color=null){
// Need these ones for checking uri
- $calendar = self::findCalendar($id);
+ $calendar = self::find($id);
// Keep old stuff
if(is_null($name)) $name = $calendar['name'];
@@ -240,4 +240,12 @@ class OC_Calendar_Calendar{
'ecc255', // dark yellow
);
}
+ public static function getEventSourceInfo($calendar){
+ return array(
+ 'url' => 'ajax/events.php?calendar_id='.$calendar['id'],
+ 'backgroundColor' => '#'.$calendar['calendarcolor'],
+ 'borderColor' => '#888',
+ 'textColor' => 'black',
+ );
+ }
}
diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php
index 0c3e497d4f2..58fe60611ce 100644
--- a/apps/calendar/lib/object.php
+++ b/apps/calendar/lib/object.php
@@ -31,6 +31,36 @@ class OC_Calendar_Object{
}
/**
+ * @brief Returns all objects of a calendar between $start and $end
+ * @param integer $id
+ * @param DateTime $start
+ * @param DateTime $end
+ * @return array
+ *
+ * The objects are associative arrays. You'll find the original vObject
+ * in ['calendardata']
+ */
+ public static function allInPeriod($id, $start, $end){
+ $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE calendarid = ?'
+ .' AND ((startdate >= ? AND startdate <= ? AND repeating = 0)'
+ .' OR (enddate >= ? AND enddate <= ? AND repeating = 0)'
+ .' OR (startdate <= ? AND repeating = 1))' );
+ $start = self::getUTCforMDB($start);
+ $end = self::getUTCforMDB($end);
+ $result = $stmt->execute(array($id,
+ $start, $end,
+ $start, $end,
+ $end));
+
+ $calendarobjects = array();
+ while( $row = $result->fetchRow()){
+ $calendarobjects[] = $row;
+ }
+
+ return $calendarobjects;
+ }
+
+ /**
* @brief Returns an object
* @param integer $id
* @return associative array
@@ -62,7 +92,7 @@ class OC_Calendar_Object{
* @return insertid
*/
public static function add($id,$data){
- $object = self::parse($data);
+ $object = OC_VObject::parse($data);
list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
if(is_null($uid)){
@@ -78,7 +108,7 @@ class OC_Calendar_Object{
OC_Calendar_Calendar::touchCalendar($id);
- return OC_DB::insertid();
+ return OC_DB::insertid('*PREFIX*calendar_objects');
}
/**
@@ -89,7 +119,7 @@ class OC_Calendar_Object{
* @return insertid
*/
public static function addFromDAVData($id,$uri,$data){
- $object = self::parse($data);
+ $object = OC_VObject::parse($data);
list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*calendar_objects (calendarid,objecttype,startdate,enddate,repeating,summary,calendardata,uri,lastmodified) VALUES(?,?,?,?,?,?,?,?,?)' );
@@ -97,7 +127,7 @@ class OC_Calendar_Object{
OC_Calendar_Calendar::touchCalendar($id);
- return OC_DB::insertid();
+ return OC_DB::insertid('*PREFIX*calendar_objects');
}
/**
@@ -109,7 +139,7 @@ class OC_Calendar_Object{
public static function edit($id, $data){
$oldobject = self::find($id);
- $object = self::parse($data);
+ $object = OC_VObject::parse($data);
list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
$stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_objects SET objecttype=?,startdate=?,enddate=?,repeating=?,summary=?,calendardata=?, lastmodified = ? WHERE id = ?' );
@@ -130,7 +160,7 @@ class OC_Calendar_Object{
public static function editFromDAVData($cid,$uri,$data){
$oldobject = self::findWhereDAVDataIs($cid,$uri);
- $object = self::parse($data);
+ $object = OC_VObject::parse($data);
list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
$stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_objects SET objecttype=?,startdate=?,enddate=?,repeating=?,summary=?,calendardata=?, lastmodified = ? WHERE id = ?' );
@@ -198,7 +228,7 @@ class OC_Calendar_Object{
// Child to use
$children = 0;
$use = null;
- foreach($object->children as &$property){
+ foreach($object->children as $property){
if($property->name == 'VEVENT'){
$children++;
$thisone = true;
@@ -229,12 +259,12 @@ class OC_Calendar_Object{
// one VTODO per object)
break;
}
- } unset($property);
+ }
// find the data
if(!is_null($use)){
$return[0] = $use->name;
- foreach($use->children as &$property){
+ foreach($use->children as $property){
if($property->name == 'DTSTART'){
$return[1] = self::getUTCforMDB($property->getDateTime());
}
@@ -250,7 +280,7 @@ class OC_Calendar_Object{
elseif($property->name == 'UID'){
$return[5] = $property->value;
}
- } unset($property);
+ }
}
// More than one child means reoccuring!
@@ -272,20 +302,6 @@ class OC_Calendar_Object{
return date('Y-m-d H:i', $datetime->format('U') - $datetime->getOffset());
}
- /**
- * @brief Parses the VObject
- * @param string VObject as string
- * @returns Sabre_VObject or null
- */
- public static function parse($data){
- try {
- $calendar = Sabre_VObject_Reader::read($data);
- return $calendar;
- } catch (Exception $e) {
- return null;
- }
- }
-
public static function getDTEndFromVEvent($vevent)
{
if ($vevent->DTEND) {
@@ -351,7 +367,7 @@ class OC_Calendar_Object{
$errarr['title'] = 'true';
$errnum++;
}
- $calendar = OC_Calendar_Calendar::findCalendar($request['calendar']);
+ $calendar = OC_Calendar_Calendar::find($request['calendar']);
if($calendar['userid'] != OC_User::getUser()){
$errarr['cal'] = 'true';
$errnum++;
@@ -398,7 +414,7 @@ class OC_Calendar_Object{
$errarr['endbeforestart'] = 'true';
$errnum++;
}
- if($fromday == $today && $frommonth == $tomonth && $fromyear == $toyear){
+ if(!$allday && $fromday == $today && $frommonth == $tomonth && $fromyear == $toyear){
list($tohours, $tominutes) = explode(':', $request['totime']);
list($fromhours, $fromminutes) = explode(':', $request['fromtime']);
if($tohours < $fromhours){
@@ -427,22 +443,16 @@ class OC_Calendar_Object{
public static function createVCalendarFromRequest($request)
{
- $vcalendar = new Sabre_VObject_Component('VCALENDAR');
+ $vcalendar = new OC_VObject('VCALENDAR');
$vcalendar->add('PRODID', 'ownCloud Calendar');
$vcalendar->add('VERSION', '2.0');
- $now = new DateTime();
-
- $vevent = new Sabre_VObject_Component('VEVENT');
+ $vevent = new OC_VObject('VEVENT');
$vcalendar->add($vevent);
- $created = new Sabre_VObject_Element_DateTime('CREATED');
- $created->setDateTime($now, Sabre_VObject_Element_DateTime::UTC);
- $vevent->add($created);
-
- $uid = self::createUID();
- $vevent->add('UID',$uid);
+ $vevent->setDateTime('CREATED', 'now', Sabre_VObject_Element_DateTime::UTC);
+ $vevent->setUID();
return self::updateVCalendarFromRequest($request, $vcalendar);
}
@@ -450,12 +460,14 @@ class OC_Calendar_Object{
{
$title = $request["title"];
$location = $request["location"];
- $categories = isset($request["categories"]) ? $request["categories"] : null;
+ $categories = isset($request["categories"]) ? $request["categories"] : array();
$allday = isset($request["allday"]);
$from = $request["from"];
- $fromtime = $request["fromtime"];
$to = $request["to"];
- $totime = $request["totime"];
+ if (!$allday){
+ $fromtime = $request['fromtime'];
+ $totime = $request['totime'];
+ }
$description = $request["description"];
//$repeat = $request["repeat"];
/*switch($request["repeatfreq"]){
@@ -476,55 +488,32 @@ class OC_Calendar_Object{
}*/
$repeat = "false";
- $now = new DateTime();
- $vevent = $vcalendar->VEVENT[0];
-
- $last_modified = new Sabre_VObject_Element_DateTime('LAST-MODIFIED');
- $last_modified->setDateTime($now, Sabre_VObject_Element_DateTime::UTC);
- $vevent->__set('LAST-MODIFIED', $last_modified);
-
- $dtstamp = new Sabre_VObject_Element_DateTime('DTSTAMP');
- $dtstamp->setDateTime($now, Sabre_VObject_Element_DateTime::UTC);
- $vevent->DTSTAMP = $dtstamp;
+ $vevent = $vcalendar->VEVENT;
- $vevent->SUMMARY = $title;
+ $vevent->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC);
+ $vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC);
+ $vevent->setString('SUMMARY', $title);
$dtstart = new Sabre_VObject_Element_DateTime('DTSTART');
$dtend = new Sabre_VObject_Element_DateTime('DTEND');
if($allday){
$start = new DateTime($from);
$end = new DateTime($to.' +1 day');
- $dtstart->setDateTime($start, Sabre_VObject_Element_DateTime::DATE);
- $dtend->setDateTime($end, Sabre_VObject_Element_DateTime::DATE);
+ $vevent->setDateTime('DTSTART', $start, Sabre_VObject_Element_DateTime::DATE);
+ $vevent->setDateTime('DTEND', $end, Sabre_VObject_Element_DateTime::DATE);
}else{
- $timezone = OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone", "Europe/London");
+ $timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
$timezone = new DateTimeZone($timezone);
$start = new DateTime($from.' '.$fromtime, $timezone);
$end = new DateTime($to.' '.$totime, $timezone);
- $dtstart->setDateTime($start, Sabre_VObject_Element_DateTime::LOCALTZ);
- $dtend->setDateTime($end, Sabre_VObject_Element_DateTime::LOCALTZ);
+ $vevent->setDateTime('DTSTART', $start, Sabre_VObject_Element_DateTime::LOCALTZ);
+ $vevent->setDateTime('DTEND', $end, Sabre_VObject_Element_DateTime::LOCALTZ);
}
- $vevent->DTSTART = $dtstart;
- $vevent->DTEND = $dtend;
unset($vevent->DURATION);
- if($location != ""){
- $vevent->LOCATION = $location;
- }else{
- unset($vevent->LOCATION);
- }
-
- if($description != ""){
- $vevent->DESCRIPTION = $description;
- }else{
- unset($vevent->DESCRIPTION);
- }
-
- if(!empty($categories)){
- $vevent->CATEGORIES = join(',', $categories);
- }else{
- unset($vevent->CATEGORIES);
- }
+ $vevent->setString('LOCATION', $location);
+ $vevent->setString('DESCRIPTION', $description);
+ $vevent->setString('CATEGORIES', join(',', $categories));
/*if($repeat == "true"){
$vevent->RRULE = $repeat;
diff --git a/apps/calendar/lib/search.php b/apps/calendar/lib/search.php
new file mode 100644
index 00000000000..41faf49a519
--- /dev/null
+++ b/apps/calendar/lib/search.php
@@ -0,0 +1,26 @@
+<?php
+class OC_Search_Provider_Calendar extends OC_Search_Provider{
+ function search($query){
+ $calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1);
+ if(count($calendars)==0 || !OC_App::isEnabled('calendar')){
+ //return false;
+ }
+ $results=array();
+ $searchquery=array();
+ if(substr_count($query, ' ') > 0){
+ $searchquery = explode(' ', $query);
+ }else{
+ $searchquery[] = $query;
+ }
+ foreach($calendars as $calendar){
+ $objects = OC_Calendar_Object::all($calendar['id']);
+ foreach($objects as $object){
+ if(substr_count(strtolower($object['summary']), strtolower($query)) > 0){//$name,$text,$link,$type
+ $results[]=new OC_Search_Result($object['summary'],'','#','Cal.');
+ }
+ }
+ }
+ return $results;
+ }
+}
+new OC_Search_Provider_Calendar(); \ No newline at end of file
diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php
index 317bb17ddbc..2003b7efc49 100644..100755
--- a/apps/calendar/templates/calendar.php
+++ b/apps/calendar/templates/calendar.php
@@ -1,217 +1,50 @@
-<?php
-$hours24 = array(
- 'allday' => $l->t('All day'),
- 0 => '0',
- 1 => '1',
- 2 => '2',
- 3 => '3',
- 4 => '4',
- 5 => '5',
- 6 => '6',
- 7 => '7',
- 8 => '8',
- 9 => '9',
- 10 => '10',
- 11 => '11',
- 12 => '12',
- 13 => '13',
- 14 => '14',
- 15 => '15',
- 16 => '16',
- 17 => '17',
- 18 => '18',
- 19 => '19',
- 20 => '20',
- 21 => '21',
- 22 => '22',
- 23 => '23',
-);
-$hoursampm = array(
- 'allday' => $l->t('All day'),
- 0 => '12 a.m.',
- 1 => '1 a.m.',
- 2 => '2 a.m.',
- 3 => '3 a.m.',
- 4 => '4 a.m.',
- 5 => '5 a.m.',
- 6 => '6 a.m.',
- 7 => '7 a.m.',
- 8 => '8 a.m.',
- 9 => '9 a.m.',
- 10 => '10 a.m.',
- 11 => '11 a.m.',
- 12 => '12 p.m.',
- 13 => '1 p.m.',
- 14 => '2 p.m.',
- 15 => '3 p.m.',
- 16 => '4 p.m.',
- 17 => '5 p.m.',
- 18 => '6 p.m.',
- 19 => '7 p.m.',
- 20 => '8 p.m.',
- 21 => '9 p.m.',
- 22 => '10 p.m.',
- 23 => '11 p.m.',
-);
-if(OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'timeformat', "24") == "24"){
- $hours = $hours24;
-}else{
- $hours = $hoursampm;
-}
-$weekdaynames = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
-$dayforgenerator = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstdayofweek', "1");
-$weekdays = array();
-for($i = 0;$i <= 6; $i++){
- $weekdays[$i] = $weekdaynames[$dayforgenerator];
- if($dayforgenerator == 6){
- $dayforgenerator = 0;
- }else{
- $dayforgenerator++;
- }
-}
-$weekendjson = OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'weekend', '{"Monday":"false","Tuesday":"false","Wednesday":"false","Thursday":"false","Friday":"false","Saturday":"true","Sunday":"true"}');
-$weekend = json_decode($weekendjson, true);
-$weekenddays = array("sunday"=>$weekend["Sunday"], "monday"=>$weekend["Monday"], "tuesday"=>$weekend["Tuesday"], "wednesday"=>$weekend["Wednesday"], "thursday"=>$weekend["Thursday"], "friday"=>$weekend["Friday"], "saturday"=>$weekend["Saturday"]);
-?>
- <script type="text/javascript">
- <?php
- echo "var weekdays = new Array('".$weekdays[0]."','".$weekdays[1]."','".$weekdays[2]."','".$weekdays[3]."','".$weekdays[4]."','".$weekdays[5]."','".$weekdays[6]."');\n";
- ?>
- Calendar.UI.weekdays = weekdays;
- Calendar.UI.daylong = new Array("<?php echo $l -> t("Sunday");?>", "<?php echo $l -> t("Monday");?>", "<?php echo $l -> t("Tuesday");?>", "<?php echo $l -> t("Wednesday");?>", "<?php echo $l -> t("Thursday");?>", "<?php echo $l -> t("Friday");?>", "<?php echo $l -> t("Saturday");?>");
- Calendar.UI.dayshort = new Array("<?php echo $l -> t("Sun.");?>", "<?php echo $l -> t("Mon.");?>", "<?php echo $l -> t("Tue.");?>", "<?php echo $l -> t("Wed.");?>", "<?php echo $l -> t("Thu.");?>", "<?php echo $l -> t("Fri.");?>", "<?php echo $l -> t("Sat.");?>");
- Calendar.UI.monthlong = new Array("<?php echo $l -> t("January");?>", "<?php echo $l -> t("February");?>", "<?php echo $l -> t("March");?>", "<?php echo $l -> t("April");?>", "<?php echo $l -> t("May");?>", "<?php echo $l -> t("June");?>", "<?php echo $l -> t("July");?>", "<?php echo $l -> t("August");?>", "<?php echo $l -> t("September");?>", "<?php echo $l -> t("October");?>", "<?php echo $l -> t("November");?>", "<?php echo $l -> t("December");?>");
- Calendar.UI.monthshort = new Array("<?php echo $l -> t("Jan.");?>", "<?php echo $l -> t("Feb.");?>", "<?php echo $l -> t("Mar.");?>", "<?php echo $l -> t("Apr.");?>", "<?php echo $l -> t("May.");?>", "<?php echo $l -> t("Jun.");?>", "<?php echo $l -> t("Jul.");?>", "<?php echo $l -> t("Aug.");?>", "<?php echo $l -> t("Sep.");?>", "<?php echo $l -> t("Oct.");?>", "<?php echo $l -> t("Nov.");?>", "<?php echo $l -> t("Dec.");?>");
- Calendar.UI.cw_label = "<?php echo $l->t("Week");?>";
- Calendar.UI.cws_label = "<?php echo $l->t("Weeks");?>";
- Calendar.UI.more_before = String('<?php echo $l->t('More before {startdate}') ?>');
- Calendar.UI.more_after = String('<?php echo $l->t('More after {enddate}') ?>');
- Calendar.firstdayofweek = parseInt("<?php echo OC_Preferences::getValue( OC_User::getUser(), 'calendar', 'firstdayofweek', "1"); ?>");
- //use last view as default on the next
- Calendar.UI.setCurrentView("<?php echo OC_Preferences::getValue(OC_USER::getUser(), "calendar", "currentview", "onemonthview") ?>");
- var totalurl = "<?php echo OC_Helper::linkTo('calendar', 'caldav.php', null, true) . '/calendars'; ?>";
+ <script type='text/javascript'>
+ var defaultView = '<?php echo OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'currentview', 'month') ?>';
+ var eventSources = <?php echo json_encode($_['eventSources']) ?>;
+ var dayNames = <?php echo json_encode($l->tA(array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'))) ?>;
+ var dayNamesShort = <?php echo json_encode($l->tA(array('Sun.', 'Mon.', 'Tue.', 'Wed.', 'Thu.', 'Fri.', 'Sat.'))) ?>;
+ var monthNames = <?php echo json_encode($l->tA(array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'))) ?>;
+ var monthNamesShort = <?php echo json_encode($l->tA(array('Jan.', 'Feb.', 'Mar.', 'Apr.', 'May.', 'Jun.', 'Jul.', 'Aug.', 'Sep.', 'Oct.', 'Nov.', 'Dec.'))) ?>;
+ var agendatime = '<?php echo ((int) OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timeformat', '24') == 24 ? 'HH:mm' : 'hh:mm tt'); ?>{ - <?php echo ((int) OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timeformat', '24') == 24 ? 'HH:mm' : 'hh:mm tt'); ?>}';
+ var defaulttime = '<?php echo ((int) OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timeformat', '24') == 24 ? 'HH:mm' : 'hh:mm tt'); ?>';
+ var allDayText = '<?php echo $l->t('All day') ?>';
+ var missing_field = '<?php echo $l->t('Missing fields') ?>';
+ var missing_field_title = '<?php echo $l->t('Title') ?>';
+ var missing_field_calendar = '<?php echo $l->t('Calendar') ?>';
+ var missing_field_fromdate = '<?php echo $l->t('From Date') ?>';
+ var missing_field_fromtime = '<?php echo $l->t('From Time') ?>';
+ var missing_field_todate = '<?php echo $l->t('To Date') ?>';
+ var missing_field_totime = '<?php echo $l->t('To Time') ?>';
+ var missing_field_startsbeforeends = '<?php echo $l->t('The event ends before it starts') ?>';
+ var missing_field_dberror = '<?php echo $l->t('There was a database fail') ?>';
+ var totalurl = '<?php echo OC_Helper::linkTo('apps/calendar', 'caldav.php', null, true); ?>/calendars';
</script>
- <div id="sysbox"></div>
<div id="controls">
<div>
<form>
<div id="view">
- <!-- <input type="button" value="1 <?php echo $l->t('Day');?>" id="onedayview_radio" onclick="Calendar.UI.setCurrentView('onedayview');"/> -->
- <input type="button" value="<?php echo $l->t('Week');?>" id="oneweekview_radio" onclick="Calendar.UI.setCurrentView('oneweekview');"/>
- <!-- <input type="button" value="4 <?php echo $l->t('Weeks');?>" id="fourweeksview_radio" onclick="Calendar.UI.setCurrentView('fourweeksview');"/> -->
- <input type="button" value="<?php echo $l->t('Month');?>" id="onemonthview_radio" onclick="Calendar.UI.setCurrentView('onemonthview');"/>
- <input type="button" value="<?php echo $l->t('List');?>" id="listview_radio" onclick="Calendar.UI.setCurrentView('listview');"/>
+ <input type="button" value="<?php echo $l->t('Week');?>" id="oneweekview_radio"/>
+ <input type="button" value="<?php echo $l->t('Month');?>" id="onemonthview_radio"/>
+ <input type="button" value="<?php echo $l->t('List');?>" id="listview_radio"/>
</div>
</form>
<form>
<div id="choosecalendar">
- <input type="button" id="today_input" value="<?php echo $l->t("Today");?>" onclick="Calendar.UI.switch2Today();"/>
+ <input type="button" id="today_input" value="<?php echo $l->t("Today");?>"/>
<input type="button" id="choosecalendar_input" value="<?php echo $l->t("Calendars");?>" onclick="Calendar.UI.Calendar.overview();" />
</div>
</form>
<form>
<div id="datecontrol">
- <input type="button" value="&nbsp;&lt;&nbsp;" id="datecontrol_left" onclick="Calendar.UI.updateDate('backward');"/>
- <input id="datecontrol_date" type="button" value=""/>
- <input type="button" value="&nbsp;&gt;&nbsp;" id="datecontrol_right" onclick="Calendar.UI.updateDate('forward');"/>
+ <input type="button" value="&nbsp;&lt;&nbsp;" id="datecontrol_left"/>
+ <span class="button" id="datecontrol_date"></span>
+ <input type="button" value="&nbsp;&gt;&nbsp;" id="datecontrol_right"/>
</div>
</form>
</div>
</div>
+ <div id="notification" style="display:none;"></div>
<div id="calendar_holder">
- <div id="onedayview">
- <table>
- <thead>
- <tr>
- <th class="calendar_time"><?php echo $l->t("Time");?></th>
- <th id="onedayview_today" class="calendar_row" onclick="Calendar.UI.newEvent('#onedayview_today');"></th>
- </tr>
- </thead>
- <tbody>
-<?php foreach($hours as $time => $time_label): ?>
- <tr>
- <td class="calendar_time"><?php echo $time_label ?></td>
- <td class="calendar_row <?php echo $time ?>" onclick="Calendar.UI.newEvent('#onedayview_today', '<?php echo $time ?>');"></td>
- </tr>
-<?php endforeach; ?>
- </tbody>
- </table>
- </div>
- <div id="oneweekview">
- <table>
- <thead>
- <tr>
- <th class="calendar_time"><?php echo $l->t("Time");?></th>
-<?php foreach($weekdays as $weekdaynr => $weekday): ?>
- <th class="calendar_row <?php echo $weekday ?> <?php echo $weekenddays[$weekday] == "true" ? 'weekend_thead' : '' ?>" onclick="Calendar.UI.newEvent('#oneweekview th.<?php echo $weekday ?>');"></th>
-<?php endforeach; ?>
- </tr>
- </thead>
- <tbody>
-<?php foreach($hours as $time => $time_label): ?>
- <tr>
- <td class="calendar_time"><?php echo $time_label?></td>
-<?php foreach($weekdays as $weekdaynr => $weekday): ?>
- <td class="<?php echo $weekday ?> <?php echo $time ?> calendar_row <?php echo $weekenddays[$weekday] == "true" ? 'weekend_row' : '' ?>" onclick="Calendar.UI.newEvent('#oneweekview th.<?php echo $weekday ?>', '<?php echo $time ?>');"></td>
-<?php endforeach; ?>
- </tr>
-<?php endforeach; ?>
- </tbody>
- </table>
- </div>
- <div id="fourweeksview">
- <table>
- <thead>
- <tr>
- <th class="calendar_row calw"><?php echo $l -> t("Week");?></th>
-<?php foreach($weekdays as $weekdaynr => $weekday): ?>
- <th class="calendar_row <?php echo $weekdaynr > 4 ? 'weekend_thead' : '' ?>"><?php echo $l->t(ucfirst($weekday)) ?></th>
-<?php endforeach; ?>
- </tr>
- </thead>
- <tbody>
-<?php foreach(range(1, 4) as $week): ?>
- <tr class="week_<?php echo $week ?>">
- <td class="calw"></td>
-<?php foreach($weekdays as $weekdaynr => $weekday): ?>
- <td class="day <?php echo $weekday ?> <?php echo $weekdaynr > 4 ? 'weekend' : '' ?>" onclick="Calendar.UI.newEvent('#fourweeksview .week_<?php echo $week ?> .<?php echo $weekday ?>')">
- <div class="dateinfo"></div>
- <div class="events"></div>
- </td>
-<?php endforeach; ?>
- </tr>
-<?php endforeach; ?>
- </tbody>
- </table>
- </div>
- <div id="onemonthview">
- <table>
- <thead>
- <tr>
-<?php foreach($weekdays as $weekdaynr => $weekday): ?>
- <th class="calendar_row <?php echo $weekenddays[$weekday] == "true" ? 'weekend_thead' : '' ?> <?php echo $weekday ?>"><?php echo $l->t(ucfirst($weekday));?></th>
-<?php endforeach; ?>
- </tr>
- </thead>
- <tbody>
-<?php foreach(range(1, 6) as $week): ?>
- <tr class="week_<?php echo $week ?>">
-<?php foreach($weekdays as $weekdaynr => $weekday): ?>
- <td class="day <?php echo $weekday ?> <?php echo $weekenddays[$weekday] == "true" ? 'weekend' : '' ?>" onclick="Calendar.UI.newEvent('#onemonthview .week_<?php echo $week ?> .<?php echo $weekday ?>')">
- <div class="dateinfo"></div>
- <div class="events"></div>
- </td>
-<?php endforeach; ?>
- </tr>
-<?php endforeach; ?>
- </tbody>
- </table>
- </div>
- <div id="listview">
- <div id="more_before"></div>
- <div id="events"></div>
- <div id="more_after"></div>
- </div>
</div>
<!-- Dialogs -->
<div id="dialog_holder"></div>
diff --git a/apps/calendar/templates/part.choosecalendar.rowfields.php b/apps/calendar/templates/part.choosecalendar.rowfields.php
index db0c71252bb..a789be45a43 100644
--- a/apps/calendar/templates/part.choosecalendar.rowfields.php
+++ b/apps/calendar/templates/part.choosecalendar.rowfields.php
@@ -1,4 +1,4 @@
<?php
echo "<td width=\"20px\"><input id=\"active_" . $_['calendar']["id"] . "\" type=\"checkbox\" onClick=\"Calendar.UI.Calendar.activation(this, " . $_['calendar']["id"] . ")\"" . ($_['calendar']["active"] ? ' checked="checked"' : '') . "></td>";
echo "<td><label for=\"active_" . $_['calendar']["id"] . "\">" . $_['calendar']["displayname"] . "</label></td>";
- echo "<td width=\"20px\"><a href=\"#\" onclick=\"Calendar.UI.showCalDAVUrl('" . OC_User::getUser() . "', '" . $_['calendar']["uri"] . "');\" title=\"" . $l->t("CalDav Link") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/public.svg\"></a></td><td width=\"20px\"><a href=\"export.php?calid=" . $_['calendar']["id"] . "\" title=\"" . $l->t("Download") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/download.svg\"></a></td><td width=\"20px\"><a href=\"#\" title=\"" . $l->t("Edit") . "\" class=\"action\" onclick=\"Calendar.UI.Calendar.edit(this, " . $_['calendar']["id"] . ");\"><img class=\"svg action\" src=\"../../core/img/actions/rename.svg\"></a></td><td width=\"20px\"><a href=\"#\" onclick=\"Calendar.UI.deleteCalendar('" . $_['calendar']["id"] . "');\" title=\"" . $l->t("Delete") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/delete.svg\"></a></td>";
+ echo "<td width=\"20px\"><a href=\"#\" onclick=\"Calendar.UI.showCalDAVUrl('" . OC_User::getUser() . "', '" . $_['calendar']["uri"] . "');\" title=\"" . $l->t("CalDav Link") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/public.svg\"></a></td><td width=\"20px\"><a href=\"export.php?calid=" . $_['calendar']["id"] . "\" title=\"" . $l->t("Download") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/download.svg\"></a></td><td width=\"20px\"><a href=\"#\" title=\"" . $l->t("Edit") . "\" class=\"action\" onclick=\"Calendar.UI.Calendar.edit(this, " . $_['calendar']["id"] . ");\"><img class=\"svg action\" src=\"../../core/img/actions/rename.svg\"></a></td><td width=\"20px\"><a href=\"#\" onclick=\"Calendar.UI.Calendar.deleteCalendar('" . $_['calendar']["id"] . "');\" title=\"" . $l->t("Delete") . "\" class=\"action\"><img class=\"svg action\" src=\"../../core/img/actions/delete.svg\"></a></td>";
diff --git a/apps/calendar/templates/part.editevent.php b/apps/calendar/templates/part.editevent.php
index ae969f2dc3b..b3acfc4a072 100644
--- a/apps/calendar/templates/part.editevent.php
+++ b/apps/calendar/templates/part.editevent.php
@@ -1,6 +1,7 @@
<div id="event" title="<?php echo $l->t("Edit an event");?>">
<form id="event_form">
<input type="hidden" name="id" value="<?php echo $_['id'] ?>">
+ <input type="hidden" name="lastmodified" value="<?php echo $_['lastmodified'] ?>">
<?php echo $this->inc("part.eventform"); ?>
<div style="width: 100%;text-align: center;color: #FF1D1D;" id="errorbox"></div>
<span id="actions">
diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php
index 8588b9168f7..dfa5fb8c78a 100644
--- a/apps/calendar/templates/part.eventform.php
+++ b/apps/calendar/templates/part.eventform.php
@@ -13,9 +13,7 @@
<select id="category" name="categories[]" multiple="multiple" title="<?php echo $l->t("Select category") ?>">
<?php
if (!isset($_['categories'])) {$_['categories'] = array();}
- foreach($_['category_options'] as $category){
- echo '<option value="' . $category . '"' . (in_array($category, $_['categories']) ? ' selected="selected"' : '') . '>' . $category . '</option>';
- }
+ echo html_select_options($_['category_options'], $_['categories'], array('combine'=>true));
?>
</select></td>
<th width="75px">&nbsp;&nbsp;&nbsp;<?php echo $l->t("Calendar");?>:</th>
@@ -23,9 +21,7 @@
<select style="width:140px;" name="calendar">
<?php
if (!isset($_['calendar'])) {$_['calendar'] = false;}
- foreach($_['calendar_options'] as $calendar){
- echo '<option value="' . $calendar['id'] . '"' . ($_['calendar'] == $calendar['id'] ? ' selected="selected"' : '') . '>' . $calendar['displayname'] . '</option>';
- }
+ echo html_select_options($_['calendar_options'], $_['calendar'], array('value'=>'id', 'label'=>'displayname'));
?>
</select></td>
</tr>
@@ -66,9 +62,7 @@
<select name="repeat" style="width:350px;">
<?php
if (isset($_['repeat_options'])) {
- foreach($_['repeat_options'] as $id => $label){
- echo '<option value="' . $id . '"' . ($_['repeat'] == $id ? ' selected="selected"' : '') . '>' . $label . '</option>';
- }
+ echo html_select_options($_['repeat_options'], $_['repeat']);
}
?>
</select></td>
diff --git a/apps/contacts/ajax/addcard.php b/apps/contacts/ajax/addcard.php
index 0cecd3bdc06..9d782246a0a 100644
--- a/apps/contacts/ajax/addcard.php
+++ b/apps/contacts/ajax/addcard.php
@@ -23,26 +23,20 @@
// Init owncloud
require_once('../../../lib/base.php');
-$aid = $_POST['id'];
-$l10n = new OC_L10N('contacts');
-
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
-$addressbook = OC_Contacts_Addressbook::find( $aid );
-if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your addressbook.')))); // Same here (as with the contact error). Could this error be improved?
- exit();
-}
+$aid = $_POST['id'];
+$addressbook = OC_Contacts_App::getAddressbook( $aid );
$fn = $_POST['fn'];
$values = $_POST['value'];
$parameters = $_POST['parameters'];
-$vcard = new Sabre_VObject_Component('VCARD');
-$vcard->add(new Sabre_VObject_Property('FN',$fn));
-$vcard->add(new Sabre_VObject_Property('UID',OC_Contacts_VCard::createUID()));
+$vcard = new OC_VObject('VCARD');
+$vcard->setUID();
+$vcard->setString('FN',$fn);
// Data to add ...
$add = array('TEL', 'EMAIL', 'ORG');
@@ -64,15 +58,8 @@ foreach( $add as $propname){
else{
$prop_parameters = array();
}
- OC_Contacts_VCard::addVCardProperty($vcard, $propname, $value, $prop_parameters);
+ $vcard->addProperty($propname, $value, $prop_parameters);
}
$id = OC_Contacts_VCard::add($aid,$vcard->serialize());
-$details = OC_Contacts_VCard::structureContact($vcard);
-$name = $details['FN'][0]['value'];
-$tmpl = new OC_Template('contacts','part.details');
-$tmpl->assign('details',$details);
-$tmpl->assign('id',$id);
-$page = $tmpl->fetchPage();
-
-OC_JSON::success(array('data' => array( 'id' => $id, 'name' => $name, 'page' => $page )));
+OC_Contacts_App::renderDetails($id, $vcard);
diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php
index 101cfabbe84..98877805b46 100644
--- a/apps/contacts/ajax/addproperty.php
+++ b/apps/contacts/ajax/addproperty.php
@@ -23,40 +23,20 @@
// Init owncloud
require_once('../../../lib/base.php');
-$id = $_POST['id'];
-$l10n = new OC_L10N('contacts');
-
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
-$card = OC_Contacts_VCard::find( $id );
-if( $card === false ){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('Contact could not be found.'))));
- exit();
-}
-
-$addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] );
-if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your contact.'))));
- exit();
-}
-
-$vcard = OC_Contacts_VCard::parse($card['carddata']);
-// Check if the card is valid
-if(is_null($vcard)){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('vCard could not be read.'))));
- exit();
-}
+$id = $_POST['id'];
+$vcard = OC_Contacts_App::getContactVCard( $id );
$name = $_POST['name'];
$value = $_POST['value'];
-$parameters = isset($_POST['parameteres'])?$_POST['parameters']:array();
+$parameters = isset($_POST['parameters'])?$_POST['parameters']:array();
-$property = OC_Contacts_VCard::addVCardProperty($vcard, $name, $value, $parameters);
+$property = $vcard->addProperty($name, $value, $parameters);
$line = count($vcard->children) - 1;
-$checksum = md5($property->serialize());
OC_Contacts_VCard::edit($id,$vcard->serialize());
diff --git a/apps/contacts/ajax/deletebook.php b/apps/contacts/ajax/deletebook.php
index c13217ef2e2..3ede17ab886 100644
--- a/apps/contacts/ajax/deletebook.php
+++ b/apps/contacts/ajax/deletebook.php
@@ -23,19 +23,12 @@
// Init owncloud
require_once('../../../lib/base.php');
-$id = $_GET['id'];
-
-$l10n = new OC_L10N('contacts');
-
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
-$addressbook = OC_Contacts_Addressbook::find( $id );
-if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your contact.'))));
- exit();
-}
+$id = $_GET['id'];
+$addressbook = OC_Contacts_App::getAddressbook( $id );
OC_Contacts_Addressbook::delete($id);
OC_JSON::success(array('data' => array( 'id' => $id )));
diff --git a/apps/contacts/ajax/deletecard.php b/apps/contacts/ajax/deletecard.php
index a0a6b8c3ea8..e26dfd6ebfe 100644
--- a/apps/contacts/ajax/deletecard.php
+++ b/apps/contacts/ajax/deletecard.php
@@ -23,25 +23,12 @@
// Init owncloud
require_once('../../../lib/base.php');
-$id = $_GET['id'];
-
-$l10n = new OC_L10N('contacts');
-
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
-$card = OC_Contacts_VCard::find( $id );
-if( $card === false ){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('Contact could not be found.'))));
- exit();
-}
-
-$addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] );
-if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your contact.'))));
- exit();
-}
+$id = $_GET['id'];
+$card = OC_Contacts_App::getContactObject( $id );
OC_Contacts_VCard::delete($id);
OC_JSON::success(array('data' => array( 'id' => $id )));
diff --git a/apps/contacts/ajax/deleteproperty.php b/apps/contacts/ajax/deleteproperty.php
index 0a3a3c293a0..f69735e61c6 100644
--- a/apps/contacts/ajax/deleteproperty.php
+++ b/apps/contacts/ajax/deleteproperty.php
@@ -23,45 +23,15 @@
// Init owncloud
require_once('../../../lib/base.php');
-$id = $_GET['id'];
-$checksum = $_GET['checksum'];
-
-
-$l10n = new OC_L10N('contacts');
-
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
-$card = OC_Contacts_VCard::find( $id );
-if( $card === false ){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('Contact could not be found.'))));
- exit();
-}
-
-$addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] );
-if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your contact.'))));
- exit();
-}
-
-$vcard = OC_Contacts_VCard::parse($card['carddata']);
-// Check if the card is valid
-if(is_null($vcard)){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('vCard could not be read.'))));
- exit();
-}
+$id = $_GET['id'];
+$checksum = $_GET['checksum'];
-$line = null;
-for($i=0;$i<count($vcard->children);$i++){
- if(md5($vcard->children[$i]->serialize()) == $checksum ){
- $line = $i;
- }
-}
-if(is_null($line)){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('Information about vCard is incorrect. Please reload the page.'))));
- exit();
-}
+$vcard = OC_Contacts_App::getContactVCard( $id );
+$line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum);
unset($vcard->children[$line]);
diff --git a/apps/contacts/ajax/getdetails.php b/apps/contacts/ajax/getdetails.php
index 0e76de61afb..8cc0f9cbb0f 100644
--- a/apps/contacts/ajax/getdetails.php
+++ b/apps/contacts/ajax/getdetails.php
@@ -23,38 +23,11 @@
// Init owncloud
require_once('../../../lib/base.php');
-$id = $_GET['id'];
-
-$l10n = new OC_L10N('contacts');
-
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
+$id = $_GET['id'];
+$vcard = OC_Contacts_App::getContactVCard( $id );
-$card = OC_Contacts_VCard::find( $id );
-if( $card === false ){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('Contact could not be found.'))));
- exit();
-}
-
-$addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] );
-if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your contact.'))));
- exit();
-}
-
-$vcard = OC_Contacts_VCard::parse($card['carddata']);
-// Check if the card is valid
-if(is_null($vcard)){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('vCard could not be read.'))));
- exit();
-}
-
-$details = OC_Contacts_VCard::structureContact($vcard);
-$tmpl = new OC_Template('contacts','part.details');
-$tmpl->assign('details',$details);
-$tmpl->assign('id',$id);
-$page = $tmpl->fetchPage();
-
-OC_JSON::success(array('data' => array( 'id' => $id, 'page' => $page )));
+OC_Contacts_App::renderDetails($id, $vcard);
diff --git a/apps/contacts/ajax/setproperty.php b/apps/contacts/ajax/setproperty.php
index 18e00872473..bcc4c161cc0 100644
--- a/apps/contacts/ajax/setproperty.php
+++ b/apps/contacts/ajax/setproperty.php
@@ -23,53 +23,28 @@
// Init owncloud
require_once('../../../lib/base.php');
-$id = $_POST['id'];
-$checksum = $_POST['checksum'];
-$l10n = new OC_L10N('contacts');
-
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
-$card = OC_Contacts_VCard::find( $id );
-if( $card === false ){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('Contact could not be found.'))));
- exit();
-}
-
-$addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] );
-if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your contact.'))));
- exit();
-}
-
-$vcard = OC_Contacts_VCard::parse($card['carddata']);
-// Check if the card is valid
-if(is_null($vcard)){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('vCard could not be read.'))));
- exit();
-}
+$id = $_POST['id'];
+$checksum = $_POST['checksum'];
-$line = null;
-for($i=0;$i<count($vcard->children);$i++){
- if(md5($vcard->children[$i]->serialize()) == $checksum ){
- $line = $i;
- }
-}
-if(is_null($line)){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('Information about vCard is incorrect. Please reload the page.'))));
- exit();
-}
+$vcard = OC_Contacts_App::getContactVCard( $id );
+$line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum);
// Set the value
$value = $_POST['value'];
if(is_array($value)){
- $value = OC_Contacts_VCard::escapeSemicolons($value);
+ $value = OC_VObject::escapeSemicolons($value);
}
$vcard->children[$line]->setValue($value);
// Add parameters
$postparameters = isset($_POST['parameters'])?$_POST['parameters']:array();
+if ($vcard->children[$line]->name == 'TEL' && !array_key_exists('TYPE', $postparameters)){
+ $postparameters['TYPE']='';
+}
for($i=0;$i<count($vcard->children[$line]->parameters);$i++){
$name = $vcard->children[$line]->parameters[$i]->name;
if(array_key_exists($name,$postparameters)){
@@ -77,7 +52,14 @@ for($i=0;$i<count($vcard->children[$line]->parameters);$i++){
unset($vcard->children[$line]->parameters[$i]);
}
else{
- $vcard->children[$line]->parameters[$i]->value = $postparameters[$name];
+ unset($vcard->children[$line][$name]);
+ $values = $postparameters[$name];
+ if (!is_array($values)){
+ $values = array($values);
+ }
+ foreach($values as $value){
+ $vcard->children[$line]->add($name, $value);
+ }
}
unset($postparameters[$name]);
}
@@ -94,7 +76,17 @@ $checksum = md5($vcard->children[$line]->serialize());
OC_Contacts_VCard::edit($id,$vcard->serialize());
-$tmpl = new OC_Template('contacts','part.property');
+$adr_types = OC_Contacts_App::getTypesOfProperty('ADR');
+$phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
+
+if ($vcard->children[$line]->name == 'FN'){
+ $tmpl = new OC_Template('contacts','part.property.FN');
+}
+else{
+ $tmpl = new OC_Template('contacts','part.property');
+}
+$tmpl->assign('adr_types',$adr_types);
+$tmpl->assign('phone_types',$phone_types);
$tmpl->assign('property',OC_Contacts_VCard::structureProperty($vcard->children[$line],$line));
$page = $tmpl->fetchPage();
diff --git a/apps/contacts/ajax/showaddcard.php b/apps/contacts/ajax/showaddcard.php
index 2f534f0fe2d..54592c89c0d 100644
--- a/apps/contacts/ajax/showaddcard.php
+++ b/apps/contacts/ajax/showaddcard.php
@@ -23,15 +23,18 @@
// Init owncloud
require_once('../../../lib/base.php');
-$l10n = new OC_L10N('contacts');
-
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
+$adr_types = OC_Contacts_App::getTypesOfProperty('ADR');
+$phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
+
$addressbooks = OC_Contacts_Addressbook::all(OC_USER::getUser());
$tmpl = new OC_Template('contacts','part.addcardform');
$tmpl->assign('addressbooks',$addressbooks);
+$tmpl->assign('adr_types',$adr_types);
+$tmpl->assign('phone_types',$phone_types);
$page = $tmpl->fetchPage();
OC_JSON::success(array('data' => array( 'page' => $page )));
diff --git a/apps/contacts/ajax/showaddproperty.php b/apps/contacts/ajax/showaddproperty.php
index f87cd05359b..30eb7634f80 100644
--- a/apps/contacts/ajax/showaddproperty.php
+++ b/apps/contacts/ajax/showaddproperty.php
@@ -23,24 +23,12 @@
// Init owncloud
require_once('../../../lib/base.php');
-$id = $_GET['id'];
-$l10n = new OC_L10N('contacts');
-
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
-$card = OC_Contacts_VCard::find( $id );
-if( $card === false ){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('Contact could not be found.'))));
- exit();
-}
-
-$addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] );
-if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your contact.'))));
- exit();
-}
+$id = $_GET['id'];
+$card = OC_Contacts_App::getContactObject( $id );
$tmpl = new OC_Template('contacts','part.addpropertyform');
$tmpl->assign('id',$id);
diff --git a/apps/contacts/ajax/showsetproperty.php b/apps/contacts/ajax/showsetproperty.php
index 6188f4773c3..e23fa21c56b 100644
--- a/apps/contacts/ajax/showsetproperty.php
+++ b/apps/contacts/ajax/showsetproperty.php
@@ -23,49 +23,26 @@
// Init owncloud
require_once('../../../lib/base.php');
-$id = $_GET['id'];
-$checksum = $_GET['checksum'];
-$l10n = new OC_L10N('contacts');
-
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
-$card = OC_Contacts_VCard::find( $id );
-if( $card === false ){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('Contact could not be found.'))));
- exit();
-}
-
-$addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] );
-if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your contact.'))));
- exit();
-}
+$id = $_GET['id'];
+$checksum = $_GET['checksum'];
-$vcard = OC_Contacts_VCard::parse($card['carddata']);
-// Check if the card is valid
-if(is_null($vcard)){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('vCard could not be read.'))));
- exit();
-}
+$vcard = OC_Contacts_App::getContactVCard( $id );
-$line = null;
-for($i=0;$i<count($vcard->children);$i++){
- if(md5($vcard->children[$i]->serialize()) == $checksum ){
- $line = $i;
- }
-}
-if(is_null($line)){
- OC_JSON::error(array('data' => array( 'message' => $l10n->t('Information about vCard is incorrect. Please reload the page.'))));
- exit();
-}
+$line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum);
+$adr_types = OC_Contacts_App::getTypesOfProperty('ADR');
+$phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
$tmpl = new OC_Template('contacts','part.setpropertyform');
$tmpl->assign('id',$id);
$tmpl->assign('checksum',$checksum);
$tmpl->assign('property',OC_Contacts_VCard::structureProperty($vcard->children[$line]));
+$tmpl->assign('adr_types',$adr_types);
+$tmpl->assign('phone_types',$phone_types);
$page = $tmpl->fetchPage();
OC_JSON::success(array('data' => array( 'page' => $page )));
diff --git a/apps/contacts/appinfo/app.php b/apps/contacts/appinfo/app.php
index fc7b3769c53..524cc640bc9 100644
--- a/apps/contacts/appinfo/app.php
+++ b/apps/contacts/appinfo/app.php
@@ -1,5 +1,6 @@
<?php
+OC::$CLASSPATH['OC_Contacts_App'] = 'apps/contacts/lib/app.php';
OC::$CLASSPATH['OC_Contacts_Addressbook'] = 'apps/contacts/lib/addressbook.php';
OC::$CLASSPATH['OC_Contacts_VCard'] = 'apps/contacts/lib/vcard.php';
OC::$CLASSPATH['OC_Contacts_Hooks'] = 'apps/contacts/lib/hooks.php';
diff --git a/apps/contacts/css/formtastic.css b/apps/contacts/css/formtastic.css
index 629c220732b..fede92b61ca 100644
--- a/apps/contacts/css/formtastic.css
+++ b/apps/contacts/css/formtastic.css
@@ -94,16 +94,14 @@ This stylesheet forms part of the Formtastic Rails Plugin
/* INPUTS
--------------------------------------------------------------------------------------------------*/
.formtastic .inputs {
- overflow:hidden; /* clear containing floats */
-}
-
-.formtastic .input {
- overflow:hidden; /* clear containing floats */
padding:0.5em 0; /* padding and negative margin juggling is for Firefox */
margin-top:-0.5em;
margin-bottom:1em;
}
+.formtastic .input {
+}
+
/* LEFT ALIGNED LABELS
--------------------------------------------------------------------------------------------------*/
diff --git a/apps/contacts/css/styles.css b/apps/contacts/css/styles.css
index 68f843b7aaf..f351589fe12 100644
--- a/apps/contacts/css/styles.css
+++ b/apps/contacts/css/styles.css
@@ -3,16 +3,22 @@
#contacts_deletecard {position:absolute;top:15px;right:0;}
#contacts_details_list { list-style:none; }
-#contacts_details_list li { overflow:hidden; }
-#contacts_details_list li p.contacts_property_name { width:25%; float:left;text-align:right;padding-right:0.3em; }
-#contacts_details_list li p.contacts_property_data, #contacts_details_list li ul.contacts_property_data { width:72%; overflow:hidden; }
-#contacts_addproperty, #contacts_addproperty_button { margin-left:25%; }
+#contacts_details_list li { overflow:visible; }
+#contacts_details_list li p.contacts_property_name { width:25%; float:left;text-align:right;padding-right:0.3em;color:#666; }
+#contacts_details_list li p.contacts_property_data, #contacts_details_list li ul.contacts_property_data { width:72%;float:left; }
+#contacts_setproperty_button { margin-left:25%; }
-.contacts_property_data ul, .contacts_property_data ol { list-style:none; }
+.contacts_property_data ul, ol.contacts_property_data { list-style:none; }
.contacts_property_data li { overflow: hidden; }
.contacts_property_data li label { width:20%; float:left; text-align:right;padding-right:0.3em; }
+.contacts_property_data input { float:left; }
.contacts_property_data li input { width:70%;overflow:hidden; }
+.chzn-container { margin:3px 0 0; }
+.chzn-container .chzn-choices { border-radius: 0.5em; }
+.chzn-container.chzn-container-active .chzn-choices { border-bottom-left-radius: 0;border-bottom-right-radius: 0; }
+.chzn-container .chzn-drop { border-bottom-left-radius: 0.5em;border-bottom-right-radius: 0.5em; }
+
/* Form setup ----------------------------------------------------------------*/
/* .forme {} */
/* .forme ul, .forme ol { list-style:none; } */
diff --git a/apps/contacts/index.php b/apps/contacts/index.php
index 7e93d6183ed..58ddc74f532 100644
--- a/apps/contacts/index.php
+++ b/apps/contacts/index.php
@@ -66,17 +66,23 @@ foreach( $openaddressbooks as $addressbook ){
}
usort($contacts,'contacts_namesort');
-$details = array();
-if( !is_null($id) || count($contacts)){
+$details = array();
+if( !is_null($id)/* || count($contacts)*/){
if(is_null($id)) $id = $contacts[0]['id'];
- $contact = OC_Contacts_VCard::find($id);
- $vcard = OC_Contacts_VCard::parse($contact['carddata']);
+ $vcard = OC_Contacts_App::getContactVCard($id);
$details = OC_Contacts_VCard::structureContact($vcard);
}
+$property_types = OC_Contacts_App::getAddPropertyOptions();
+$adr_types = OC_Contacts_App::getTypesOfProperty('ADR');
+$phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
+
// Process the template
$tmpl = new OC_Template( 'contacts', 'index', 'user' );
+$tmpl->assign('property_types',$property_types);
+$tmpl->assign('adr_types',$adr_types);
+$tmpl->assign('phone_types',$phone_types);
$tmpl->assign('addressbooks', $addressbooks);
$tmpl->assign('contacts', $contacts);
$tmpl->assign('details', $details );
diff --git a/apps/contacts/js/interface.js b/apps/contacts/js/interface.js
index 9270297f322..eb81e872682 100644
--- a/apps/contacts/js/interface.js
+++ b/apps/contacts/js/interface.js
@@ -56,14 +56,15 @@ $(document).ready(function(){
$('#contacts_addpropertyform #contacts_fieldpart').remove();
$('#contacts_addpropertyform #contacts_generic').remove();
if($(this).val() == 'ADR'){
- $('#contacts_addresspart').clone().insertBefore($('#contacts_addpropertyform input[type="submit"]'));
+ $('#contacts_addresspart').clone().insertAfter($('#contacts_addpropertyform .contacts_property_name'));
}
else if($(this).val() == 'TEL'){
- $('#contacts_phonepart').clone().insertBefore($('#contacts_addpropertyform input[type="submit"]'));
+ $('#contacts_phonepart').clone().insertAfter($('#contacts_addpropertyform .contacts_property_name'));
}
else{
- $('#contacts_generic').clone().insertBefore($('#contacts_addpropertyform input[type="submit"]'));
+ $('#contacts_generic').clone().insertAfter($('#contacts_addpropertyform .contacts_property_name'));
}
+ $('#contacts_addpropertyform .contacts_property_data select').chosen();
});
$('#contacts_addpropertyform input[type="submit"]').live('click',function(){
@@ -82,7 +83,8 @@ $(document).ready(function(){
$.getJSON('ajax/showaddcard.php',{},function(jsondata){
if(jsondata.status == 'success'){
$('#rightcontent').data('id','');
- $('#rightcontent').html(jsondata.data.page);
+ $('#rightcontent').html(jsondata.data.page)
+ .find('select').chosen();
}
else{
alert(jsondata.data.message);
@@ -108,10 +110,11 @@ $(document).ready(function(){
$('.contacts_property [data-use="edit"]').live('click',function(){
var id = $('#rightcontent').data('id');
- var checksum = $(this).parents('li').first().data('checksum');
+ var checksum = $(this).parents('.contacts_property').first().data('checksum');
$.getJSON('ajax/showsetproperty.php',{'id': id, 'checksum': checksum },function(jsondata){
if(jsondata.status == 'success'){
- $('.contacts_property[data-checksum="'+checksum+'"]').html(jsondata.data.page);
+ $('.contacts_property[data-checksum="'+checksum+'"]').html(jsondata.data.page)
+ .find('select').chosen();
}
else{
alert(jsondata.data.message);
@@ -148,10 +151,12 @@ $(document).ready(function(){
$('.contacts_property').live('mouseenter',function(){
- $(this).find('span').show();
+ $(this).find('span[data-use]').show();
});
$('.contacts_property').live('mouseleave',function(){
- $(this).find('span').hide();
+ $(this).find('span[data-use]').hide();
});
+
+ $('#contacts_addcardform select').chosen();
});
diff --git a/apps/contacts/lib/addressbook.php b/apps/contacts/lib/addressbook.php
index 2e869d7de3b..87477ed7ed4 100644
--- a/apps/contacts/lib/addressbook.php
+++ b/apps/contacts/lib/addressbook.php
@@ -96,7 +96,7 @@ class OC_Contacts_Addressbook{
$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_addressbooks (userid,displayname,uri,description,ctag) VALUES(?,?,?,?,?)' );
$result = $stmt->execute(array($userid,$name,$uri,$description,1));
- return OC_DB::insertid();
+ return OC_DB::insertid('*PREFIX*contacts_addressbooks');
}
/**
@@ -113,7 +113,7 @@ class OC_Contacts_Addressbook{
$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_addressbooks (userid,displayname,uri,description,ctag) VALUES(?,?,?,?,?)' );
$result = $stmt->execute(array($userid,$name,$uri,$description,1));
- return OC_DB::insertid();
+ return OC_DB::insertid('*PREFIX*contacts_addressbooks');
}
/**
diff --git a/apps/contacts/lib/app.php b/apps/contacts/lib/app.php
new file mode 100644
index 00000000000..79e00920a65
--- /dev/null
+++ b/apps/contacts/lib/app.php
@@ -0,0 +1,122 @@
+<?php
+/**
+ * Copyright (c) 2011 Bart Visscher bartv@thisnet.nl
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+/**
+ * This class manages our app actions
+ */
+OC_Contacts_App::$l10n = new OC_L10N('contacts');
+class OC_Contacts_App{
+ public static $l10n;
+
+ /**
+ * Render templates/part.details to json output
+ * @param int $id of contact
+ * @param Sabre_VObject_Component $vcard to render
+ */
+ public static function renderDetails($id, $vcard){
+ $property_types = self::getAddPropertyOptions();
+ $adr_types = self::getTypesOfProperty('ADR');
+ $phone_types = self::getTypesOfProperty('TEL');
+
+ $details = OC_Contacts_VCard::structureContact($vcard);
+ $name = $details['FN'][0]['value'];
+ $tmpl = new OC_Template('contacts','part.details');
+ $tmpl->assign('details',$details);
+ $tmpl->assign('id',$id);
+ $tmpl->assign('property_types',$property_types);
+ $tmpl->assign('adr_types',$adr_types);
+ $tmpl->assign('phone_types',$phone_types);
+ $page = $tmpl->fetchPage();
+
+ OC_JSON::success(array('data' => array( 'id' => $id, 'name' => $name, 'page' => $page )));
+ }
+
+ public static function getAddressbook($id){
+ $addressbook = OC_Contacts_Addressbook::find( $id );
+ if( $addressbook === false || $addressbook['userid'] != OC_User::getUser()){
+ OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('This is not your addressbook.')))); // Same here (as with the contact error). Could this error be improved?
+ exit();
+ }
+ return $addressbook;
+ }
+
+ public static function getContactObject($id){
+ $card = OC_Contacts_VCard::find( $id );
+ if( $card === false ){
+ OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('Contact could not be found.'))));
+ exit();
+ }
+
+ self::getAddressbook( $card['addressbookid'] );
+ return $card;
+ }
+
+ public static function getContactVCard($id){
+ $card = self::getContactObject( $id );
+
+ $vcard = OC_VObject::parse($card['carddata']);
+ // Check if the card is valid
+ if(is_null($vcard)){
+ OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('vCard could not be read.'))));
+ exit();
+ }
+ return $vcard;
+ }
+
+ public static function getPropertyLineByChecksum($vcard, $checksum){
+ $line = null;
+ for($i=0;$i<count($vcard->children);$i++){
+ if(md5($vcard->children[$i]->serialize()) == $checksum ){
+ $line = $i;
+ }
+ }
+ if(is_null($line)){
+ OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('Information about vCard is incorrect. Please reload the page.'))));
+ exit();
+ }
+ return $line;
+ }
+
+ /**
+ * @return array of vcard prop => label
+ */
+ public static function getAddPropertyOptions(){
+ $l10n = self::$l10n;
+ return array(
+ 'ADR' => $l10n->t('Address'),
+ 'TEL' => $l10n->t('Telephone'),
+ 'EMAIL' => $l10n->t('Email'),
+ 'ORG' => $l10n->t('Organization'),
+ );
+ }
+
+ /**
+ * @return types for property $prop
+ */
+ public static function getTypesOfProperty($prop){
+ $l = self::$l10n;
+ switch($prop){
+ case 'ADR':
+ return array(
+ 'WORK' => $l->t('Work'),
+ 'HOME' => $l->t('Home'),
+ );
+ case 'TEL':
+ return array(
+ 'HOME' => $l->t('Home'),
+ 'CELL' => $l->t('Mobile'),
+ 'WORK' => $l->t('Work'),
+ 'TEXT' => $l->t('Text'),
+ 'VOICE' => $l->t('Voice'),
+ 'FAX' => $l->t('Fax'),
+ 'VIDEO' => $l->t('Video'),
+ 'PAGER' => $l->t('Pager'),
+ );
+ }
+ }
+}
diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php
index 74bc0f92f1b..a573f40f7d9 100644
--- a/apps/contacts/lib/vcard.php
+++ b/apps/contacts/lib/vcard.php
@@ -91,24 +91,24 @@ class OC_Contacts_VCard{
*/
public static function add($id,$data){
$fn = null;
- $uri = null;
- $card = self::parse($data);
+ $card = OC_VObject::parse($data);
if(!is_null($card)){
- foreach($card->children as $property){
- if($property->name == 'FN'){
- $fn = $property->value;
- }
- elseif(is_null($uri) && $property->name == 'UID' ){
- $uri = $property->value.'.vcf';
- }
- }
- if(is_null($uri)){
- $uid = self::createUID();
- $uri = $uid.'.vcf';
- $card->add(new Sabre_VObject_Property('UID',$uid));
+ $fn = $card->getAsString('FN');
+ $uid = $card->getAsString('UID');
+ if(is_null($uid)){
+ $card->setUID();
+ $uid = $card->getAsString('UID');
$data = $card->serialize();
};
+ $uri = $uid.'.vcf';
+ // VCARD must have a version
+ $version = $card->getAsString('VERSION');
+ // Add version if needed
+ if(is_null($version)){
+ $card->add(new Sabre_VObject_Property('VERSION','3.0'));
+ $data = $card->serialize();
+ }
}
else{
// that's hard. Creating a UID and not saving it
@@ -121,7 +121,7 @@ class OC_Contacts_VCard{
OC_Contacts_Addressbook::touch($id);
- return OC_DB::insertid();
+ return OC_DB::insertid('*PREFIX*contacts_cards');
}
/**
@@ -133,7 +133,7 @@ class OC_Contacts_VCard{
*/
public static function addFromDAVData($id,$uri,$data){
$fn = null;
- $card = self::parse($data);
+ $card = OC_VObject::parse($data);
if(!is_null($card)){
foreach($card->children as $property){
if($property->name == 'FN'){
@@ -147,7 +147,7 @@ class OC_Contacts_VCard{
OC_Contacts_Addressbook::touch($id);
- return OC_DB::insertid();
+ return OC_DB::insertid('*PREFIX*contacts_cards');
}
/**
@@ -160,7 +160,7 @@ class OC_Contacts_VCard{
$oldcard = self::find($id);
$fn = null;
- $card = self::parse($data);
+ $card = OC_VObject::parse($data);
if(!is_null($card)){
foreach($card->children as $property){
if($property->name == 'FN'){
@@ -188,7 +188,7 @@ class OC_Contacts_VCard{
$oldcard = self::findWhereDAVDataIs($aid,$uri);
$fn = null;
- $card = self::parse($data);
+ $card = OC_VObject::parse($data);
if(!is_null($card)){
foreach($card->children as $property){
if($property->name == 'FN'){
@@ -239,61 +239,6 @@ class OC_Contacts_VCard{
}
/**
- * @brief Escapes semicolons
- * @param string $value
- * @return string
- */
- public static function escapeSemicolons($value){
- foreach($value as &$i ){
- $i = implode("\\\\;", explode(';', $i));
- }
- return implode(';',$value);
- }
-
- /**
- * @brief Creates an array out of a multivalue property
- * @param string $value
- * @return array
- */
- public static function unescapeSemicolons($value){
- $array = explode(';',$value);
- for($i=0;$i<count($array);$i++){
- if(substr($array[$i],-2,2)=="\\\\"){
- if(isset($array[$i+1])){
- $array[$i] = substr($array[$i],0,count($array[$i])-2).';'.$array[$i+1];
- unset($array[$i+1]);
- }
- else{
- $array[$i] = substr($array[$i],0,count($array[$i])-2).';';
- }
- $i = $i - 1;
- }
- }
- return $array;
- }
-
- /**
- * @brief Add property to vcard object
- * @param object $vcard
- * @param object $name of property
- * @param object $value of property
- * @param object $paramerters of property
- */
- public static function addVCardProperty($vcard, $name, $value, $parameters=array()){
- if(is_array($value)){
- $value = OC_Contacts_VCard::escapeSemicolons($value);
- }
- $property = new Sabre_VObject_Property( $name, $value );
- $parameternames = array_keys($parameters);
- foreach($parameternames as $i){
- $property->parameters[] = new Sabre_VObject_Parameter($i,$parameters[$i]);
- }
-
- $vcard->add($property);
- return $property;
- }
-
- /**
* @brief Data structure of vCard
* @param object $property
* @return associative array
@@ -329,7 +274,7 @@ class OC_Contacts_VCard{
$value = $property->value;
$value = htmlspecialchars($value);
if($property->name == 'ADR' || $property->name == 'N'){
- $value = self::unescapeSemicolons($value);
+ $value = OC_VObject::unescapeSemicolons($value);
}
$temp = array(
'name' => $property->name,
@@ -342,24 +287,18 @@ class OC_Contacts_VCard{
$parameter->name = 'PREF';
$parameter->value = '1';
}
- $temp['parameters'][$parameter->name] = $parameter->value;
+ if ($property->name == 'TEL' && $parameter->name == 'TYPE'){
+ if (isset($temp['parameters'][$parameter->name])){
+ $temp['parameters'][$parameter->name][] = $parameter->value;
+ }
+ else{
+ $temp['parameters'][$parameter->name] = array($parameter->value);
+ }
+ }
+ else{
+ $temp['parameters'][$parameter->name] = $parameter->value;
+ }
}
return $temp;
}
-
- /**
- * @brief Parses a vcard file
- * @param string vCard
- * @return Sabre_VObject or null
- *
- * Will retun the vobject if sabre DAV is able to parse the file.
- */
- public static function parse($data){
- try {
- $card = Sabre_VObject_Reader::read($data);
- return $card;
- } catch (Exception $e) {
- return null;
- }
- }
}
diff --git a/apps/contacts/photo.php b/apps/contacts/photo.php
index 5178fe7a078..60dd81140bf 100644
--- a/apps/contacts/photo.php
+++ b/apps/contacts/photo.php
@@ -41,7 +41,7 @@ if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
exit();
}
-$content = OC_Contacts_VCard::parse($card['carddata']);
+$content = OC_VObject::parse($card['carddata']);
// invalid vcard
if( is_null($content)){
diff --git a/apps/contacts/templates/index.php b/apps/contacts/templates/index.php
index 630dca41b2e..649c4807dd5 100644
--- a/apps/contacts/templates/index.php
+++ b/apps/contacts/templates/index.php
@@ -15,5 +15,12 @@ OC_Util::addStyle('contacts','formtastic');
</ul>
</div>
<div id="rightcontent" class="rightcontent" data-id="<?php echo $_['id']; ?>">
- <?php echo $this->inc("part.addcardform"); ?>
+ <?php
+ if ($_['id']){
+ echo $this->inc("part.details");
+ }
+ else{
+ echo $this->inc("part.addcardform");
+ }
+ ?>
</div>
diff --git a/apps/contacts/templates/part.addcardform.php b/apps/contacts/templates/part.addcardform.php
index 8e482cc4eba..627053547ad 100644
--- a/apps/contacts/templates/part.addcardform.php
+++ b/apps/contacts/templates/part.addcardform.php
@@ -7,9 +7,7 @@
<li class="input stringish">
<label class="label" for="id"><?php echo $l->t('Group'); ?></label>
<select name="id" size="1">
- <?php foreach($_['addressbooks'] as $addressbook): ?>
- <option value="<?php echo $addressbook['id']; ?>"><?php echo $addressbook['displayname']; ?></option>
- <?php endforeach; ?>
+ <?php echo html_select_options($_['addressbooks'], null, array('value'=>'id', 'label'=>'displayname')); ?>
</select>
</li>
</ol>
@@ -19,7 +17,7 @@
<ol>
<li class="input stringish">
<label class="label" for="fn"><?php echo $l->t('Name'); ?></label>
- <input type="text" name="fn" value=""><br>
+ <input id="fn" type="text" name="fn" value=""><br>
</li>
<li class="input stringish">
<label class="label" for="org"><?php echo $l->t('Organization'); ?></label>
@@ -45,15 +43,8 @@
</li>
<li class="fragment">
<label for="tel_type"><?php echo $l->t('Type'); ?></label>
- <select id="TEL" name="parameters[TEL][TYPE]" size="1">
- <option value="home"><?php echo $l->t('Home'); ?></option>
- <option value="cell" selected="selected"><?php echo $l->t('Mobile'); ?></option>
- <option value="work"><?php echo $l->t('Work'); ?></option>
- <option value="text"><?php echo $l->t('Text'); ?></option>
- <option value="voice"><?php echo $l->t('Voice'); ?></option>
- <option value="fax"><?php echo $l->t('Fax'); ?></option>
- <option value="video"><?php echo $l->t('Video'); ?></option>
- <option value="pager"><?php echo $l->t('Pager'); ?></option>
+ <select id="TEL" name="parameters[TEL][TYPE][]" multiple="multiple">
+ <?php echo html_select_options($_['phone_types'], 'CELL') ?>
</select>
</li>
</ol>
@@ -67,8 +58,7 @@
<li class="input">
<label class="label" for="adr_type"><?php echo $l->t('Type'); ?></label>
<select id="adr_type" name="parameters[ADR][TYPE]" size="1">
- <option value="work"><?php echo $l->t('Work'); ?></option>
- <option value="home" selected="selected"><?php echo $l->t('Home'); ?></option>
+ <?php echo html_select_options($_['adr_types'], 'HOME') ?>
</select>
</li>
<li class="input stringish">
@@ -81,19 +71,19 @@
</li>
<li class="input stringish">
<label class="label" for="adr_street"><?php echo $l->t('Street'); ?></label>
- <input type="text" for="adr_street" name="value[ADR][2]" value="">
+ <input type="text" id="adr_street" name="value[ADR][2]" value="">
</li>
<li class="input stringish">
<label class="label" for="adr_city"><?php echo $l->t('City'); ?></label>
- <input type="text" for="adr_city" name="value[ADR][3]" value="">
+ <input type="text" id="adr_city" name="value[ADR][3]" value="">
</li>
<li class="input stringish">
<label class="label" for="adr_region"><?php echo $l->t('Region'); ?></label>
- <input type="text" for="adr_region" name="value[ADR][4]" value="">
+ <input type="text" id="adr_region" name="value[ADR][4]" value="">
</li>
<li class="input stringish">
<label class="label" for="adr_zipcode"><?php echo $l->t('Zipcode'); ?></label>
- <input type="text" for="adr_zipcode" name="value[ADR][5]" value="">
+ <input type="text" id="adr_zipcode" name="value[ADR][5]" value="">
</li>
<li class="input stringish">
<label class="label" for="adr_country"><?php echo $l->t('Country'); ?></label>
diff --git a/apps/contacts/templates/part.details.php b/apps/contacts/templates/part.details.php
index e9fa8356e8b..afad0b7f64c 100644
--- a/apps/contacts/templates/part.details.php
+++ b/apps/contacts/templates/part.details.php
@@ -1,5 +1,5 @@
<?php if(array_key_exists('FN',$_['details'])): ?>
- <p id="contacts_details_name"><?php echo $_['details']['FN'][0]['value']; ?></p>
+ <?php echo $this->inc('part.property.FN', array('property' => $_['details']['FN'][0])); ?>
<img class="svg action" id="contacts_deletecard" src="<?php echo image_path('', 'actions/delete.svg'); ?>" title="<?php echo $l->t('Delete contact');?>" />
<?php if(isset($_['details']['PHOTO'])): // Emails first ?>
@@ -27,24 +27,21 @@
<input type="hidden" name="id" value="<?php echo $_['id']; ?>">
<p class="contacts_property_name">
<select name="name" size="1">
- <option value="ADR"><?php echo $l->t('Address'); ?></option>
- <option value="TEL"><?php echo $l->t('Telephone'); ?></option>
- <option value="EMAIL" selected="selected"><?php echo $l->t('Email'); ?></option>
- <option value="ORG"><?php echo $l->t('Organization'); ?></option>
+ <?php echo html_select_options($_['property_types'], 'EMAIL') ?>
</select>
+ <br>
+ <input id="contacts_addproperty_button" type="submit" value="<?php echo $l->t('Add'); ?>">
</p>
<p class="contacts_property_data" id="contacts_generic">
<input type="text" name="value" value="">
- </p><br>
- <input id="contacts_addproperty_button" type="submit" value="<?php echo $l->t('Add'); ?>">
+ </p>
</form>
<div id="contacts_addcontactsparts" style="display:none;">
<ul class="contacts_property_data" id="contacts_addresspart">
<li>
<label for="adr_type"><?php echo $l->t('Type'); ?></label>
<select id="adr_type" name="parameters[TYPE]" size="1">
- <option value="work"><?php echo $l->t('Work'); ?></option>
- <option value="home" selected="selected"><?php echo $l->t('Home'); ?></option>
+ <?php echo html_select_options($_['adr_types'], 'HOME') ?>
</select>
</li>
<li>
@@ -78,15 +75,8 @@
</ul>
<p class="contacts_property_data" id="contacts_phonepart">
<input type="text" name="value" value="">
- <select name="parameters[TYPE]" size="1">
- <option value="home"><?php echo $l->t('Home'); ?></option>
- <option value="cell" selected="selected"><?php echo $l->t('Mobile'); ?></option>
- <option value="work"><?php echo $l->t('Work'); ?></option>
- <option value="text"><?php echo $l->t('Text'); ?></option>
- <option value="voice"><?php echo $l->t('Voice'); ?></option>
- <option value="fax"><?php echo $l->t('Fax'); ?></option>
- <option value="video"><?php echo $l->t('Video'); ?></option>
- <option value="pager"><?php echo $l->t('Pager'); ?></option>
+ <select name="parameters[TYPE][]" multiple="multiple" data-placeholder="<?php echo $l->t('Type') ?>">
+ <?php echo html_select_options($_['phone_types'], 'CELL') ?>
</select>
</p>
<p class="contacts_property_data" id="contacts_generic">
diff --git a/apps/contacts/templates/part.property.FN.php b/apps/contacts/templates/part.property.FN.php
new file mode 100644
index 00000000000..83cef94e303
--- /dev/null
+++ b/apps/contacts/templates/part.property.FN.php
@@ -0,0 +1,9 @@
+ <p id="contacts_details_name" class="contacts_property" data-checksum="<?php echo $_['property']['checksum']; ?>">
+ <?php echo $_['property']['value']; ?>
+ <span style="display:none;" data-use="edit"><img class="svg action" src="<?php echo image_path('', 'actions/rename.svg'); ?>" /></span>
+ </p>
+<?php if (!isset($_['details'])): ?>
+<script>
+$('#leftcontent li.active a').text('<?php echo $_['property']['value']; ?>');
+</script>
+<?php endif ?>
diff --git a/apps/contacts/templates/part.property.php b/apps/contacts/templates/part.property.php
index 4bc3a4d85f8..d930a9ca99d 100644
--- a/apps/contacts/templates/part.property.php
+++ b/apps/contacts/templates/part.property.php
@@ -20,11 +20,23 @@
<span style="display:none;" data-use="delete"><img class="svg action" src="<?php echo image_path('', 'actions/delete.svg'); ?>" /></span>
</p>
<?php elseif($_['property']['name'] == 'TEL'): ?>
- <p class="contacts_property_name"><?php echo $l->t('Phone'); ?></p>
+ <p class="contacts_property_name"><?php echo (isset($_['property']['parameters']['PREF']) && $_['property']['parameters']['PREF']) ? $l->t('Preferred').' ' : '' ?><?php echo $l->t('Phone'); ?></p>
<p class="contacts_property_data">
<?php echo $_['property']['value']; ?>
- <?php if(isset($_['property']['parameters']['TYPE'])): ?>
- (<?php echo $l->t(ucwords(str_replace('cell','mobile',strtolower($_['property']['parameters']['TYPE'])))); ?>)
+ <?php if(isset($_['property']['parameters']['TYPE']) && !empty($_['property']['parameters']['TYPE'])): ?>
+<?php
+ $types = array();
+ foreach($_['property']['parameters']['TYPE'] as $type):
+ if (isset($_['phone_types'][strtoupper($type)])){
+ $types[]=$_['phone_types'][strtoupper($type)];
+ }
+ else{
+ $types[]=$l->t(ucwords(strtolower($type)));
+ }
+ endforeach;
+ $label = join(' ', $types);
+?>
+ (<?php echo $label; ?>)
<?php endif; ?>
<span style="display:none;" data-use="edit"><img class="svg action" src="<?php echo image_path('', 'actions/rename.svg'); ?>" /></span>
<span style="display:none;" data-use="delete"><img class="svg action" src="<?php echo image_path('', 'actions/delete.svg'); ?>" /></span>
@@ -34,7 +46,16 @@
<?php echo $l->t('Address'); ?>
<?php if(isset($_['property']['parameters']['TYPE'])): ?>
<br>
- (<?php echo $l->t(ucwords($_['property']['parameters']['TYPE'])); ?>)
+<?php
+ $type = $_['property']['parameters']['TYPE'];
+ if (isset($_['adr_types'][strtoupper($type)])){
+ $label=$_['adr_types'][strtoupper($type)];
+ }
+ else{
+ $label=$l->t(ucwords(strtolower($type)));
+ }
+?>
+ (<?php echo $label; ?>)
<?php endif; ?>
</p>
<p class="contacts_property_data">
diff --git a/apps/contacts/templates/part.setpropertyform.php b/apps/contacts/templates/part.setpropertyform.php
index eb8a67a8aa5..8635d7db1ce 100644
--- a/apps/contacts/templates/part.setpropertyform.php
+++ b/apps/contacts/templates/part.setpropertyform.php
@@ -1,10 +1,17 @@
-<li class="contacts_property_edit" data-checksum="<?php echo $_['property']['checksum']; ?>">
<form id="contacts_setpropertyform">
<input type="hidden" name="checksum" value="<?php echo $_['property']['checksum']; ?>">
<input type="hidden" name="id" value="<?php echo $_['id']; ?>">
- <?php if($_['property']['name']=='ADR'): ?>
+ <?php if($_['property']['name']=='FN'): ?>
+ <p class="contacts_property_data"><input id="fn" type="text" name="value" value="<?php echo $_['property']['value']; ?>"></p>
+ <?php elseif($_['property']['name']=='ADR'): ?>
<p class="contacts_property_name"><label for="adr_pobox"><?php echo $l->t('Address'); ?></label></p>
<ol class="contacts_property_data" id="contacts_addresspart">
+ <li class="input">
+ <label class="label" for="adr_type"><?php echo $l->t('Type'); ?></label>
+ <select id="adr_type" name="parameters[TYPE]" size="1">
+ <?php echo html_select_options($_['adr_types'], strtoupper($_['property']['parameters']['TYPE'])) ?>
+ </select>
+ </li>
<li>
<label for="adr_pobox"><?php echo $l->t('PO Box'); ?></label>
<input id="adr_pobox" type="text" name="value[0]" value="<?php echo $_['property']['value'][0] ?>">
@@ -36,7 +43,10 @@
</ol>
<?php elseif($_['property']['name']=='TEL'): ?>
<p class="contacts_property_name"><label for="tel"><?php echo $l->t('Phone'); ?></label></p>
- <p class="contacts_property_data"><input id="tel" type="phone" name="value" value="<?php echo $_['property']['value']; ?>"></p>
+ <p class="contacts_property_data"><input id="tel" type="phone" name="value" value="<?php echo $_['property']['value'] ?>">
+ <select id="tel_type<?php echo $_['property']['checksum'] ?>" name="parameters[TYPE][]" multiple="multiple" data-placeholder="<?php echo $l->t('Type') ?>">
+ <?php echo html_select_options($_['phone_types'], isset($_['property']['parameters']['TYPE'])?$_['property']['parameters']['TYPE']:'') ?>
+ </select></p>
<?php elseif($_['property']['name']=='EMAIL'): ?>
<p class="contacts_property_name"><label for="email"><?php echo $l->t('Email'); ?></label></p>
<p class="contacts_property_data"><input id="email" type="text" name="value" value="<?php echo $_['property']['value']; ?>"></p>
@@ -44,6 +54,5 @@
<p class="contacts_property_name"><label for="org"><?php echo $l->t('Organization'); ?></label></p>
<p class="contacts_property_data"><input id="org" type="text" name="value" value="<?php echo $_['property']['value']; ?>"></p>
<?php endif; ?>
- <input id="contacts_setproperty_button" type="submit" value="<?php echo $l->t('Edit'); ?>">
+ <input id="contacts_setproperty_button" type="submit" value="<?php echo $l->t('Update'); ?>">
</form>
-</li>
diff --git a/apps/external/ajax/seturls.php b/apps/external/ajax/seturls.php
index c8e97754544..e994385a199 100644
--- a/apps/external/ajax/seturls.php
+++ b/apps/external/ajax/seturls.php
@@ -8,16 +8,16 @@
require_once('../../../lib/base.php');
OC_Util::checkAdminUser();
-if(isset($_POST['s1name'])) OC_Config::setValue( 'external-site1name', $_POST['s1name'] );
-if(isset($_POST['s1url'])) OC_Config::setValue( 'external-site1url', $_POST['s1url'] );
-if(isset($_POST['s2name'])) OC_Config::setValue( 'external-site2name', $_POST['s2name'] );
-if(isset($_POST['s2url'])) OC_Config::setValue( 'external-site2url', $_POST['s2url'] );
-if(isset($_POST['s3name'])) OC_Config::setValue( 'external-site3name', $_POST['s3name'] );
-if(isset($_POST['s3url'])) OC_Config::setValue( 'external-site3url', $_POST['s3url'] );
-if(isset($_POST['s4name'])) OC_Config::setValue( 'external-site4name', $_POST['s4name'] );
-if(isset($_POST['s4url'])) OC_Config::setValue( 'external-site4url', $_POST['s4url'] );
-if(isset($_POST['s5name'])) OC_Config::setValue( 'external-site5name', $_POST['s5name'] );
-if(isset($_POST['s5url'])) OC_Config::setValue( 'external-site5url', $_POST['s5url'] );
+if(isset($_POST['s1name'])) OC_Appconfig::setValue( 'external','site1name', $_POST['s1name'] );
+if(isset($_POST['s1url'])) OC_Appconfig::setValue( 'external','site1url', $_POST['s1url'] );
+if(isset($_POST['s2name'])) OC_Appconfig::setValue( 'external','site2name', $_POST['s2name'] );
+if(isset($_POST['s2url'])) OC_Appconfig::setValue( 'external','site2url', $_POST['s2url'] );
+if(isset($_POST['s3name'])) OC_Appconfig::setValue( 'external','site3name', $_POST['s3name'] );
+if(isset($_POST['s3url'])) OC_Appconfig::setValue( 'external','site3url', $_POST['s3url'] );
+if(isset($_POST['s4name'])) OC_Appconfig::setValue( 'external','site4name', $_POST['s4name'] );
+if(isset($_POST['s4url'])) OC_Appconfig::setValue( 'external','site4url', $_POST['s4url'] );
+if(isset($_POST['s5name'])) OC_Appconfig::setValue( 'external','site5name', $_POST['s5name'] );
+if(isset($_POST['s5url'])) OC_Appconfig::setValue( 'external','site5url', $_POST['s5url'] );
echo 'true';
diff --git a/apps/external/appinfo/app.php b/apps/external/appinfo/app.php
index df14954d86f..0f536cbf418 100644
--- a/apps/external/appinfo/app.php
+++ b/apps/external/appinfo/app.php
@@ -25,13 +25,13 @@ OC_APP::registerAdmin('external','settings');
OC_App::register( array( 'order' => 70, 'id' => 'external', 'name' => 'External' ));
-if(OC_Config::getValue( "external-site1name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index1', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=1', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Config::getValue( "external-site1name", '' )));
+if(OC_Appconfig::getValue( "external","site1name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index1', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=1', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Appconfig::getValue( "external","site1name", '' )));
-if(OC_Config::getValue( "external-site2name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index2', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=2', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Config::getValue( "external-site2name", '' )));
+if(OC_Appconfig::getValue( "external","site2name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index2', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=2', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Appconfig::getValue( "external","site2name", '' )));
-if(OC_Config::getValue( "external-site3name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index3', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=3', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Config::getValue( "external-site3name", '' )));
+if(OC_Appconfig::getValue( "external","site3name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index3', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=3', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Appconfig::getValue( "external","site3name", '' )));
-if(OC_Config::getValue( "external-site4name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index4', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=4', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Config::getValue( "external-site4name", '' )));
+if(OC_Appconfig::getValue( "external","site4name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index4', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=4', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Appconfig::getValue( "external","site4name", '' )));
-if(OC_Config::getValue( "external-site5name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index5', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=5', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Config::getValue( "external-site5name", '' )));
+if(OC_Appconfig::getValue( "external","site5name", '' )<>'') OC_App::addNavigationEntry( array( 'id' => 'external_index5', 'order' => 80, 'href' => OC_Helper::linkTo( 'external', 'index.php' ).'?id=5', 'icon' => OC_Helper::imagePath( 'external', 'external.png' ), 'name' => OC_Appconfig::getValue( "external","site5name", '' )));
diff --git a/apps/external/index.php b/apps/external/index.php
index 116e16d9096..86b19abc10e 100644
--- a/apps/external/index.php
+++ b/apps/external/index.php
@@ -35,7 +35,7 @@ if(isset($_GET['id'])){
$id=$_GET['id'];
$id = (int) $id;
- $url=OC_Config::getValue( "external-site".$id."url", '' );
+ $url=OC_Appconfig::getValue( "external","site".$id."url", '' );
OC_App::setActiveNavigationEntry( 'external_index'.$id );
$tmpl = new OC_Template( 'external', 'frame', 'user' );
diff --git a/apps/external/settings.php b/apps/external/settings.php
index ad33c16e1bf..3e0c3425128 100644
--- a/apps/external/settings.php
+++ b/apps/external/settings.php
@@ -6,17 +6,17 @@ OC_Util::addScript( "external", "admin" );
$tmpl = new OC_Template( 'external', 'settings');
- $tmpl->assign('s1name',OC_Config::getValue( "external-site1name", '' ));
- $tmpl->assign('s2name',OC_Config::getValue( "external-site2name", '' ));
- $tmpl->assign('s3name',OC_Config::getValue( "external-site3name", '' ));
- $tmpl->assign('s4name',OC_Config::getValue( "external-site4name", '' ));
- $tmpl->assign('s5name',OC_Config::getValue( "external-site5name", '' ));
+ $tmpl->assign('s1name',OC_Appconfig::getValue( "external","site1name", '' ));
+ $tmpl->assign('s2name',OC_Appconfig::getValue( "external","site2name", '' ));
+ $tmpl->assign('s3name',OC_Appconfig::getValue( "external","site3name", '' ));
+ $tmpl->assign('s4name',OC_Appconfig::getValue( "external","site4name", '' ));
+ $tmpl->assign('s5name',OC_Appconfig::getValue( "external","site5name", '' ));
- $tmpl->assign('s1url',OC_Config::getValue( "external-site1url", '' ));
- $tmpl->assign('s2url',OC_Config::getValue( "external-site2url", '' ));
- $tmpl->assign('s3url',OC_Config::getValue( "external-site3url", '' ));
- $tmpl->assign('s4url',OC_Config::getValue( "external-site4url", '' ));
- $tmpl->assign('s5url',OC_Config::getValue( "external-site5url", '' ));
+ $tmpl->assign('s1url',OC_Appconfig::getValue( "external","site1url", '' ));
+ $tmpl->assign('s2url',OC_Appconfig::getValue( "external","site2url", '' ));
+ $tmpl->assign('s3url',OC_Appconfig::getValue( "external","site3url", '' ));
+ $tmpl->assign('s4url',OC_Appconfig::getValue( "external","site4url", '' ));
+ $tmpl->assign('s5url',OC_Appconfig::getValue( "external","site5url", '' ));
return $tmpl->fetchPage();
?>
diff --git a/apps/files_imageviewer/css/jquery.fancybox-1.3.4.css b/apps/files_imageviewer/css/jquery.fancybox-1.3.4.css
index 030497750b2..1dfd9b95d35 100644
--- a/apps/files_imageviewer/css/jquery.fancybox-1.3.4.css
+++ b/apps/files_imageviewer/css/jquery.fancybox-1.3.4.css
@@ -35,7 +35,7 @@
left: 0;
width: 40px;
height: 480px;
- background-image: url('../img/fancybox/fancybox.png');
+ background-image: url('../img/fancybox.png');
}
#fancybox-overlay {
@@ -282,7 +282,7 @@
#fancybox-title-over {
padding: 10px;
- background-image: url('../img/fancybox/fancy_title_over.png');
+ background-image: url('../img/fancy_title_over.png');
display: block;
}
@@ -306,7 +306,7 @@
#fancybox-title-float-left {
padding: 0 0 0 15px;
- background: url('../img/fancybox/fancybox.png') -40px -90px no-repeat;
+ background: url('../img/fancybox.png') -40px -90px no-repeat;
}
#fancybox-title-float-main {
@@ -314,25 +314,25 @@
line-height: 29px;
font-weight: bold;
padding: 0 0 3px 0;
- background: url('../img/fancybox/fancybox-x.png') 0px -40px;
+ background: url('../img/fancybox-x.png') 0px -40px;
}
#fancybox-title-float-right {
padding: 0 0 0 15px;
- background: url('../img/fancybox/fancybox.png') -55px -90px no-repeat;
+ background: url('../img/fancybox.png') -55px -90px no-repeat;
}
/* IE6 */
-.fancybox-ie6 #fancybox-close { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_close.png', sizingMethod='scale'); }
+.fancybox-ie6 #fancybox-close { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_close.png', sizingMethod='scale'); }
-.fancybox-ie6 #fancybox-left-ico { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_nav_left.png', sizingMethod='scale'); }
-.fancybox-ie6 #fancybox-right-ico { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_nav_right.png', sizingMethod='scale'); }
+.fancybox-ie6 #fancybox-left-ico { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_nav_left.png', sizingMethod='scale'); }
+.fancybox-ie6 #fancybox-right-ico { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_nav_right.png', sizingMethod='scale'); }
-.fancybox-ie6 #fancybox-title-over { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_over.png', sizingMethod='scale'); zoom: 1; }
-.fancybox-ie6 #fancybox-title-float-left { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_left.png', sizingMethod='scale'); }
-.fancybox-ie6 #fancybox-title-float-main { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_main.png', sizingMethod='scale'); }
-.fancybox-ie6 #fancybox-title-float-right { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_right.png', sizingMethod='scale'); }
+.fancybox-ie6 #fancybox-title-over { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_title_over.png', sizingMethod='scale'); zoom: 1; }
+.fancybox-ie6 #fancybox-title-float-left { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_title_left.png', sizingMethod='scale'); }
+.fancybox-ie6 #fancybox-title-float-main { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_title_main.png', sizingMethod='scale'); }
+.fancybox-ie6 #fancybox-title-float-right { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_title_right.png', sizingMethod='scale'); }
.fancybox-ie6 #fancybox-bg-w, .fancybox-ie6 #fancybox-bg-e, .fancybox-ie6 #fancybox-left, .fancybox-ie6 #fancybox-right, #fancybox-hide-sel-frame {
height: expression(this.parentNode.clientHeight + "px");
@@ -343,17 +343,17 @@
top: expression( (-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px');
}
-#fancybox-loading.fancybox-ie6 div { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_loading.png', sizingMethod='scale'); }
+#fancybox-loading.fancybox-ie6 div { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_loading.png', sizingMethod='scale'); }
/* IE6, IE7, IE8 */
.fancybox-ie .fancybox-bg { background: transparent !important; }
-.fancybox-ie #fancybox-bg-n { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_n.png', sizingMethod='scale'); }
-.fancybox-ie #fancybox-bg-ne { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_ne.png', sizingMethod='scale'); }
-.fancybox-ie #fancybox-bg-e { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_e.png', sizingMethod='scale'); }
-.fancybox-ie #fancybox-bg-se { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_se.png', sizingMethod='scale'); }
-.fancybox-ie #fancybox-bg-s { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_s.png', sizingMethod='scale'); }
-.fancybox-ie #fancybox-bg-sw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_sw.png', sizingMethod='scale'); }
-.fancybox-ie #fancybox-bg-w { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_w.png', sizingMethod='scale'); }
-.fancybox-ie #fancybox-bg-nw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_nw.png', sizingMethod='scale'); }
+.fancybox-ie #fancybox-bg-n { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_shadow_n.png', sizingMethod='scale'); }
+.fancybox-ie #fancybox-bg-ne { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_shadow_ne.png', sizingMethod='scale'); }
+.fancybox-ie #fancybox-bg-e { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_shadow_e.png', sizingMethod='scale'); }
+.fancybox-ie #fancybox-bg-se { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_shadow_se.png', sizingMethod='scale'); }
+.fancybox-ie #fancybox-bg-s { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_shadow_s.png', sizingMethod='scale'); }
+.fancybox-ie #fancybox-bg-sw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_shadow_sw.png', sizingMethod='scale'); }
+.fancybox-ie #fancybox-bg-w { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_shadow_w.png', sizingMethod='scale'); }
+.fancybox-ie #fancybox-bg-nw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/fancy_shadow_nw.png', sizingMethod='scale'); }
diff --git a/apps/files_sharing/ajax/getitem.php b/apps/files_sharing/ajax/getitem.php
index 075ec043eac..51fda6aed40 100644
--- a/apps/files_sharing/ajax/getitem.php
+++ b/apps/files_sharing/ajax/getitem.php
@@ -1,5 +1,5 @@
<?php
-$RUNTIME_NOAPPS = true;
+//$RUNTIME_NOAPPS = true;
require_once('../../../lib/base.php');
OC_JSON::checkAppEnabled('files_sharing');
@@ -19,6 +19,7 @@ $source = dirname($source);
while ($source != "" && $source != "/" && $source != "." && $source != $userDirectory) {
if ($values = OC_Share::getMySharedItem($source)) {
$values = array_values($values);
+ $users = array();
$parentUsers = array();
for ($i = 0; $i < count($values); $i++) {
if ($values[$i]['uid_shared_with'] == OC_Share::PUBLICLINK) {
diff --git a/apps/files_sharing/ajax/setpermissions.php b/apps/files_sharing/ajax/setpermissions.php
index 7ee8f0e57bd..200202c704c 100644
--- a/apps/files_sharing/ajax/setpermissions.php
+++ b/apps/files_sharing/ajax/setpermissions.php
@@ -1,5 +1,5 @@
<?php
-$RUNTIME_NOAPPS = true;
+//$RUNTIME_NOAPPS = true;
require_once('../../../lib/base.php');
OC_JSON::checkAppEnabled('files_sharing');
diff --git a/apps/files_sharing/ajax/share.php b/apps/files_sharing/ajax/share.php
index d1f50994317..9b10260da5a 100644
--- a/apps/files_sharing/ajax/share.php
+++ b/apps/files_sharing/ajax/share.php
@@ -1,5 +1,5 @@
<?php
-$RUNTIME_NOAPPS = true;
+//$RUNTIME_NOAPPS = true;
require_once('../../../lib/base.php');
OC_JSON::checkAppEnabled('files_sharing');
diff --git a/apps/files_sharing/ajax/unshare.php b/apps/files_sharing/ajax/unshare.php
index a19a85cfda3..d8a72a00efe 100644
--- a/apps/files_sharing/ajax/unshare.php
+++ b/apps/files_sharing/ajax/unshare.php
@@ -1,5 +1,5 @@
<?php
-$RUNTIME_NOAPPS = true;
+//$RUNTIME_NOAPPS = true;
require_once('../../../lib/base.php');
OC_JSON::checkAppEnabled('files_sharing');
diff --git a/apps/files_sharing/ajax/userautocomplete.php b/apps/files_sharing/ajax/userautocomplete.php
index 21516c3d091..9d971fb62af 100644
--- a/apps/files_sharing/ajax/userautocomplete.php
+++ b/apps/files_sharing/ajax/userautocomplete.php
@@ -1,5 +1,5 @@
<?php
-$RUNTIME_NOAPPS = true;
+//$RUNTIME_NOAPPS = true;
require_once('../../../lib/base.php');
diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js
index c0fc91e92ad..4457dddbe15 100644
--- a/apps/files_sharing/js/share.js
+++ b/apps/files_sharing/js/share.js
@@ -10,7 +10,7 @@ $(document).ready(function() {
type: 'GET',
url: OC.linkTo('files_sharing', 'ajax/getitem.php'),
dataType: 'json',
- data: 'source='+file,
+ data: {source: file},
async: false,
success: function(users) {
if (users) {
@@ -46,6 +46,7 @@ $(document).ready(function() {
$('.share').click(function(event) {
event.preventDefault();
+ event.stopPropagation();
var filenames = getSelectedFiles('name');
var length = filenames.length;
var files = '';
@@ -184,8 +185,8 @@ function createDropdown(filename, files) {
html += '<input id="link" style="display:none; width:90%;" />';
html += '</div>';
if (filename) {
- $('tr[data-file="'+filename+'"]').addClass('mouseOver');
- $(html).appendTo($('tr[data-file="'+filename+'"] td.filename'));
+ $('tr').filterAttr('data-file',filename).addClass('mouseOver');
+ $(html).appendTo($('tr').filterAttr('data-file',filename).find('td.filename'));
} else {
$(html).appendTo($('thead .share'));
}
@@ -223,7 +224,7 @@ function addUser(uid_shared_with, permissions, parentFolder) {
var user = '<li data-uid_shared_with="'+uid_shared_with+'">';
user += '<a href="" class="unshare" style="display:none;"><img class="svg" alt="Unshare" src="'+OC.imagePath('core','actions/delete')+'"/></a>';
user += uid_shared_with;
- user += '<input type="checkbox" name="permissions" id="'+uid_shared_with+'" class="permissions" "+checked+" />';
+ user += '<input type="checkbox" name="permissions" id="'+uid_shared_with+'" class="permissions" '+checked+' />';
user += '<label for="'+uid_shared_with+'" '+style+'>can edit</label>';
user += '</li>';
}
diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php
index faf4e68d9b1..d78e273bf38 100644
--- a/apps/files_sharing/sharedstorage.php
+++ b/apps/files_sharing/sharedstorage.php
@@ -285,7 +285,9 @@ class OC_Filestorage_Shared extends OC_Filestorage {
}
public function is_writeable($path) {
- if ($path == "" || $path == "/" || OC_Share::getPermissions($this->datadir.$path) & OC_Share::WRITE) {
+ if($path == "" || $path == "/"){
+ return false;
+ }elseif (OC_Share::getPermissions($this->datadir.$path) & OC_Share::WRITE) {
return true;
} else {
return false;
diff --git a/apps/gallery/ajax/createAlbum.php b/apps/gallery/ajax/createAlbum.php
index 610f761b72a..9413b54718a 100644
--- a/apps/gallery/ajax/createAlbum.php
+++ b/apps/gallery/ajax/createAlbum.php
@@ -3,8 +3,7 @@ require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('gallery');
-$stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_albums ("uid_owner", "album_name") VALUES ("'.OC_User::getUser().'", "'.$_GET['album_name'].'")');
-$stmt->execute(array());
+OC_Gallery_Album::create(OC_User::getUser(), $_GET['album_name']);
OC_JSON::success(array('name' => $_GET['album_name']));
diff --git a/apps/gallery/ajax/getAlbums.php b/apps/gallery/ajax/getAlbums.php
index 98d92c5f31a..7454b18edab 100644
--- a/apps/gallery/ajax/getAlbums.php
+++ b/apps/gallery/ajax/getAlbums.php
@@ -4,13 +4,12 @@ OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('gallery');
$a = array();
-$stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner LIKE ?');
-$result = $stmt->execute(array(OC_User::getUser()));
+$result = OC_Gallery_Album::find(OC_User::getUser());
while ($r = $result->fetchRow()) {
$album_name = $r['album_name'];
- $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos WHERE album_id = ?');
- $tmp_res = $stmt->execute(array($r['album_id']));
+ $tmp_res = OC_Gallery_Photo::find($r['album_id']);
+
$a[] = array('name' => $album_name, 'numOfItems' => min($tmp_res->numRows(), 10), 'bgPath' => OC::$WEBROOT.'/data/'.OC_User::getUser().'/gallery/'.$album_name.'.png');
}
diff --git a/apps/gallery/ajax/getCovers.php b/apps/gallery/ajax/getCovers.php
index b9c7558a53c..db7c8e9fcde 100644
--- a/apps/gallery/ajax/getCovers.php
+++ b/apps/gallery/ajax/getCovers.php
@@ -18,7 +18,7 @@ function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height, $tgtImg, $
default:
exit();
}
- if(!$myImage) exit();
+ if(!$myImage) exit();
$ratio_orig = $width_orig/$height_orig;
if ($thumbnail_width/$thumbnail_height > $ratio_orig) {
@@ -44,15 +44,19 @@ function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height, $tgtImg, $
$box_size = 200;
$album_name= $_GET['album_name'];
-$stmt = OC_DB::prepare('SELECT `file_path` FROM *PREFIX*gallery_photos,*PREFIX*gallery_albums WHERE *PREFIX*gallery_albums.`uid_owner` = ? AND `album_name` = ? AND *PREFIX*gallery_photos.`album_id` = *PREFIX*gallery_albums.`album_id`');
-$result = $stmt->execute(array(OC_User::getUser(), $album_name));
+$result = OC_Gallery_Photo::findForAlbum(OC_User::getUser(), $album_name);
$numOfItems = min($result->numRows(),10);
-$targetImg = imagecreatetruecolor($numOfItems*$box_size, $box_size);
+if ($numOfItems){
+ $targetImg = imagecreatetruecolor($numOfItems*$box_size, $box_size);
+}
+else{
+ $targetImg = imagecreatetruecolor($box_size, $box_size);
+}
$counter = 0;
while (($i = $result->fetchRow()) && $counter < $numOfItems) {
- $imagePath = OC::$CONFIG_DATADIRECTORY . $i['file_path'];
+ $imagePath = OC_Filesystem::getLocalFile($i['file_path']);
if(file_exists($imagePath))
{
CroppedThumbnail($imagePath, $box_size, $box_size, $targetImg, $counter*$box_size);
@@ -65,7 +69,7 @@ header('Content-Type: image/png');
$offset = 3600 * 24;
// calc the string in GMT not localtime and add the offset
header("Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT");
-header('Cache-Control: max-age=3600, must-revalidate');
+header('Cache-Control: max-age='.$offset.', must-revalidate');
header('Pragma: public');
imagepng($targetImg);
diff --git a/apps/gallery/ajax/scanForAlbums.php b/apps/gallery/ajax/scanForAlbums.php
index bdd591d0422..f603cbb4971 100644
--- a/apps/gallery/ajax/scanForAlbums.php
+++ b/apps/gallery/ajax/scanForAlbums.php
@@ -3,10 +3,8 @@
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('gallery');
-require_once('../lib_scanner.php');
-OC_GALLERY_SCANNER::cleanUp();
-OC_JSON::success(array('albums' => OC_GALLERY_SCANNER::scan('')));
-//OC_JSON::success(array('albums' => array(array('name' => 'test', 'imagesCount' => 1, 'images' => array('dupa')))));
+OC_Gallery_Scanner::cleanUp();
+OC_JSON::success(array('albums' => OC_Gallery_Scanner::scan('')));
?>
diff --git a/apps/gallery/ajax/thumbnail.php b/apps/gallery/ajax/thumbnail.php
index a1416452932..d937691fa03 100644
--- a/apps/gallery/ajax/thumbnail.php
+++ b/apps/gallery/ajax/thumbnail.php
@@ -49,12 +49,19 @@ function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height) { //$imgSr
$box_size = 200;
$img = $_GET['img'];
-$tmp = OC::$CONFIG_DATADIRECTORY . $img;
+$imagePath = OC_Filesystem::getLocalFile($img);
-if(file_exists($tmp))
+if(file_exists($imagePath))
{
- header('Content-Type: image/png');
- $image = CroppedThumbnail($tmp, $box_size, $box_size);
+ $image = CroppedThumbnail($imagePath, $box_size, $box_size);
+
+ header('Content-Type: image/png');
+ $offset = 3600 * 24;
+ // calc the string in GMT not localtime and add the offset
+ header("Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT");
+ header('Cache-Control: max-age='.$offset.', must-revalidate');
+ header('Pragma: public');
+
imagepng($image);
imagedestroy($image);
-} \ No newline at end of file
+}
diff --git a/apps/gallery/appinfo/app.php b/apps/gallery/appinfo/app.php
index 8f855c470e5..2b1ab857afc 100644
--- a/apps/gallery/appinfo/app.php
+++ b/apps/gallery/appinfo/app.php
@@ -1,4 +1,8 @@
<?php
+OC::$CLASSPATH['OC_Gallery_Album'] = 'apps/gallery/lib/album.php';
+OC::$CLASSPATH['OC_Gallery_Photo'] = 'apps/gallery/lib/photo.php';
+OC::$CLASSPATH['OC_Gallery_Scanner'] = 'apps/gallery/lib/scanner.php';
+
OC_App::register(array(
'order' => 20,
'id' => 'gallery',
diff --git a/apps/gallery/css/styles.css b/apps/gallery/css/styles.css
index 03b179138e6..e23d822fec7 100644
--- a/apps/gallery/css/styles.css
+++ b/apps/gallery/css/styles.css
@@ -1,13 +1,22 @@
div#gallery_list {
margin: 90pt 20pt;
}
+div#gallery_list.leftcontent {
+ padding-top: 15px;
+ margin: 0;
+ text-align: center;
+}
div#gallery_album_box {
width: 200px;
text-align: center;
border: 0;
- float: left;
+ display: inline-block;
margin: 5pt;
+ vertical-align: top;
+}
+.leftcontent div#gallery_album_box {
+ margin: 5px;
}
div#gallery_album_box h1 {
@@ -21,3 +30,6 @@ div#gallery_album_cover {
border: solid 1px black;
}
+#gallery_images {
+padding:10px 5px;
+}
diff --git a/apps/gallery/index.php b/apps/gallery/index.php
index cb567e3c8f6..0cd795bac01 100644
--- a/apps/gallery/index.php
+++ b/apps/gallery/index.php
@@ -13,8 +13,7 @@ if (!file_exists(OC_Config::getValue("datadirectory").'/'. OC_User::getUser() .'
}
if (!isset($_GET['view'])) {
- $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner = ?');
- $result = $stmt->execute(array(OC_User::getUser()));
+ $result = OC_Gallery_Album::find(OC_User::getUser());
$r = array();
while ($row = $result->fetchRow())
@@ -24,9 +23,7 @@ if (!isset($_GET['view'])) {
$tmpl->assign('r', $r);
$tmpl->printPage();
} else {
- $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos, *PREFIX*gallery_albums WHERE uid_owner = ? AND album_name = ? AND *PREFIX*gallery_albums.album_id = *PREFIX*gallery_photos.album_id');
-
- $result = $stmt->execute(array(OC_User::getUser(), $_GET['view']));
+ $result = OC_Gallery_Photo::findForAlbum(OC_User::getUser(), $_GET['view']);
$photos = array();
while ($p = $result->fetchRow())
diff --git a/apps/gallery/js/albums.js b/apps/gallery/js/albums.js
index a8e317159d5..387cc611d5f 100644
--- a/apps/gallery/js/albums.js
+++ b/apps/gallery/js/albums.js
@@ -69,7 +69,7 @@ Albums={
if (albumMetadata == undefined) {
return;
}
- var x = Math.min(Math.floor((e.clientX - this.offsetLeft)/(this.offsetWidth/albumMetadata.numOfCovers)), albumMetadata.numOfCovers-1);
+ var x = Math.min(Math.floor((e.layerX - this.offsetLeft)/(this.offsetWidth/albumMetadata.numOfCovers)), albumMetadata.numOfCovers-1);
x *= this.offsetWidth;
$(this).css('background-position', -x+'px 0');
});
diff --git a/apps/gallery/lib/album.php b/apps/gallery/lib/album.php
new file mode 100644
index 00000000000..6ddfe46de3d
--- /dev/null
+++ b/apps/gallery/lib/album.php
@@ -0,0 +1,18 @@
+<?php
+
+class OC_Gallery_Album{
+ public static function create($owner, $name){
+ $stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_albums (uid_owner, album_name) VALUES (?, ?)');
+ $stmt->execute(array($owner, $name));
+ }
+ public static function find($owner, $name=null){
+ $sql = 'SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner = ?';
+ $args = array($owner);
+ if (!is_null($name)){
+ $sql .= ' AND album_name = ?';
+ $args[] = $name;
+ }
+ $stmt = OC_DB::prepare($sql);
+ return $stmt->execute($args);
+ }
+}
diff --git a/apps/gallery/lib/photo.php b/apps/gallery/lib/photo.php
new file mode 100644
index 00000000000..97d159935f5
--- /dev/null
+++ b/apps/gallery/lib/photo.php
@@ -0,0 +1,28 @@
+<?php
+
+class OC_Gallery_Photo{
+ public static function create($albumId, $img){
+ $stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_photos (album_id, file_path) VALUES (?, ?)');
+ $stmt->execute(array($albumId, $img));
+ }
+ public static function find($albumId, $img=null){
+ $sql = 'SELECT * FROM *PREFIX*gallery_photos WHERE album_id = ?';
+ $args = array($albumId);
+ $args = array($albumId);
+ if (!is_null($img)){
+ $sql .= ' AND file_path = ?';
+ $args[] = $img;
+ }
+ $stmt = OC_DB::prepare($sql);
+ return $stmt->execute($args);
+ }
+ public static function findForAlbum($owner, $album_name){
+ $stmt = OC_DB::prepare('SELECT *'
+ .' FROM *PREFIX*gallery_photos photos,'
+ .' *PREFIX*gallery_albums albums'
+ .' WHERE albums.uid_owner = ?'
+ .' AND albums.album_name = ?'
+ .' AND photos.album_id = albums.album_id');
+ return $stmt->execute(array($owner, $album_name));
+ }
+}
diff --git a/apps/gallery/lib_scanner.php b/apps/gallery/lib/scanner.php
index f72d54777a7..ef210327966 100644
--- a/apps/gallery/lib_scanner.php
+++ b/apps/gallery/lib/scanner.php
@@ -1,9 +1,9 @@
<?php
require_once('base.php'); // base lib
-require_once('lib/images_utils.php');
+require_once('images_utils.php');
-class OC_GALLERY_SCANNER {
+class OC_Gallery_Scanner {
public static function scan($root) {
$albums = array();
@@ -36,22 +36,18 @@ class OC_GALLERY_SCANNER {
}
$current_album['imagesCount'] = count($current_album['images']);
$albums[] = $current_album;
- $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner LIKE ? AND album_name LIKE ?');
- $result = $stmt->execute(array(OC_User::getUser(), $current_album['name']));
+
+ $result = OC_Gallery_Album::find(OC_User::getUser(), $current_album['name']);
if ($result->numRows() == 0 && count($current_album['images'])) {
- $stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_albums (uid_owner, album_name) VALUES (?, ?)');
- $stmt->execute(array(OC_User::getUser(), $current_album['name']));
+ OC_Gallery_Album::create(OC_User::getUser(), $current_album['name']);
+ $result = OC_Gallery_Album::find(OC_User::getUser(), $current_album['name']);
}
- $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner LIKE ? AND album_name LIKE ?');
- $result = $stmt->execute(array(OC_User::getUser(), $current_album['name']));
- $albumId = $result->fetchAll();
- $albumId = $albumId[0]['album_id'];
+ $albumId = $result->fetchRow();
+ $albumId = $albumId['album_id'];
foreach ($current_album['images'] as $img) {
- $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos WHERE album_id = ? AND file_path LIKE ?');
- $result = $stmt->execute(array($albumId, $img));
+ $result = OC_Gallery_Photo::find($albumId, $img);
if ($result->numRows() == 0) {
- $stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_photos (album_id, file_path) VALUES (?, ?)');
- $stmt->execute(array($albumId, $img));
+ OC_Gallery_Photo::create($albumId, $img);
}
}
if (count($current_album['images'])) {
diff --git a/apps/gallery/templates/view_album.php b/apps/gallery/templates/view_album.php
index 230e2a5c21d..ae43e2fc557 100644
--- a/apps/gallery/templates/view_album.php
+++ b/apps/gallery/templates/view_album.php
@@ -1,5 +1,6 @@
<?php
OC_Util::addStyle('gallery', 'styles');
+OC_Util::addScript('gallery', 'albums');
OC_Util::addScript('gallery', 'album_cover');
OC_Util::addScript('files_imageviewer', 'jquery.mousewheel-3.0.4.pack');
OC_Util::addScript('files_imageviewer', 'jquery.fancybox-1.3.4.pack');
@@ -16,13 +17,16 @@ OC_Util::addStyle( 'files_imageviewer', 'jquery.fancybox-1.3.4' );
<div id="controls">
<a href="?"><input type="button" value="Back" /></a><br/>
</div>
-<div id="gallery_list">
+
+<div id="gallery_list" class="leftcontent">
+</div>
+
+<div id="gallery_images" class="rightcontent">
<?php
foreach ($_['photos'] as $a) {
?>
-<a rel="images" href="../../files/ajax/download.php?files=<?php echo $a; ?>"><img src="ajax/thumbnail.php?img=<?php echo $a ?>"></a>
+<a rel="images" href="../../files/download.php?file=<?php echo urlencode($a); ?>"><img src="ajax/thumbnail.php?img=<?php echo urlencode($a) ?>"></a>
<?php
}
?>
-
</div>
diff --git a/apps/media/css/music.css b/apps/media/css/music.css
index 67d56075194..a6738058be3 100644
--- a/apps/media/css/music.css
+++ b/apps/media/css/music.css
@@ -31,7 +31,8 @@ div.jp-volume-bar-value { background:#ccc; width:0; height:0.4em; }
#collection li { padding-right:10px; }
#searchresults input.play, #searchresults input.add { float:left; height:1em; width:1em; }
#collection tr.collapsed td.album, #collection tr.collapsed td.title { color:#ddd; }
-a.expander { float:right; padding:0 1em; }
+td.artist img, td.artist a, td.album img, td.album a { float: left; }
+td.artist a.expander, td.album a.expander { float:right; padding:0 1em; }
tr.active td { background-color:#eee; font-weight:bold; }
tr td { border-top:1px solid #eee; height:2.2em; }
tr .artist img { vertical-align:middle; }
diff --git a/apps/media/lib_ampache.php b/apps/media/lib_ampache.php
index 0ad84d66809..bc1f853047f 100644
--- a/apps/media/lib_ampache.php
+++ b/apps/media/lib_ampache.php
@@ -128,7 +128,7 @@ class OC_MEDIA_AMPACHE{
$albums=count(OC_MEDIA_COLLECTION::getAlbums($artist['artist_id']));
$songs=count(OC_MEDIA_COLLECTION::getSongs($artist['artist_id']));
$id=$artist['artist_id'];
- $name=utf8_decode(htmlentities($artist['artist_name']));
+ $name=htmlentities($artist['artist_name'], ENT_COMPAT, 'UTF-8');
echo("\t<artist id='$id'>\n");
echo("\t\t<name>$name</name>\n");
echo("\t\t<albums>$albums</albums>\n");
@@ -142,10 +142,10 @@ class OC_MEDIA_AMPACHE{
if(!$artistName){
$artistName=OC_MEDIA_COLLECTION::getArtistName($album['album_artist']);
}
- $artistName=utf8_decode(htmlentities($artistName));
+ $artistName=htmlentities($artistName, ENT_COMPAT, 'UTF-8');
$songs=count(OC_MEDIA_COLLECTION::getSongs($album['album_artist'],$album['album_id']));
$id=$album['album_id'];
- $name=utf8_decode(htmlentities($album['album_name']));
+ $name=htmlentities($album['album_name'], ENT_COMPAT, 'UTF-8');
$artist=$album['album_artist'];
echo("\t<album id='$id'>\n");
echo("\t\t<name>$name</name>\n");
@@ -163,10 +163,10 @@ class OC_MEDIA_AMPACHE{
if(!$albumName){
$albumName=OC_MEDIA_COLLECTION::getAlbumName($song['song_album']);
}
- $artistName=utf8_decode(htmlentities($artistName));
- $albumName=utf8_decode(htmlentities($albumName));
+ $artistName=htmlentities($artistName, ENT_COMPAT, 'UTF-8');
+ $albumName=htmlentities($albumName, ENT_COMPAT, 'UTF-8');
$id=$song['song_id'];
- $name=utf8_decode(htmlentities($song['song_name']));
+ $name=htmlentities($song['song_name'], ENT_COMPAT, 'UTF-8');
$artist=$song['song_artist'];
$album=$song['song_album'];
echo("\t<song id='$id'>\n");
diff --git a/apps/media/lib_collection.php b/apps/media/lib_collection.php
index 571cb7e6850..caa3ac3f479 100644
--- a/apps/media/lib_collection.php
+++ b/apps/media/lib_collection.php
@@ -267,7 +267,7 @@ class OC_MEDIA_COLLECTION{
$query=self::$queries['addsong'];
}
$query->execute(array($name,$artist,$album,$path,$uid,$length,$track,$size));
- $songId=OC_DB::insertid();
+ $songId=OC_DB::insertid('*PREFIX*media_songs');
// self::setLastUpdated();
return self::getSongId($name,$artist,$album);
}
diff --git a/apps/media/lib_scanner.php b/apps/media/lib_scanner.php
index ef63cea45df..c2bea2d836d 100644
--- a/apps/media/lib_scanner.php
+++ b/apps/media/lib_scanner.php
@@ -93,6 +93,7 @@ class OC_MEDIA_SCANNER{
}
if(!self::$getID3){
self::$getID3=@new getID3();
+ self::$getID3->encoding='UTF-8';
}
$data=@self::$getID3->analyze($file);
getid3_lib::CopyTagsToComments($data);
@@ -105,21 +106,18 @@ class OC_MEDIA_SCANNER{
$artist='unknown';
}else{
$artist=stripslashes($data['comments']['artist'][0]);
- $artist=utf8_encode($artist);
}
if(!isset($data['comments']['album'])){
OC_Log::write('media',"error reading album tag in '$file'",OC_Log::WARN);
$album='unknown';
}else{
$album=stripslashes($data['comments']['album'][0]);
- $album=utf8_encode($album);
}
if(!isset($data['comments']['title'])){
OC_Log::write('media',"error reading title tag in '$file'",OC_Log::WARN);
$title='unknown';
}else{
$title=stripslashes($data['comments']['title'][0]);
- $title=utf8_encode($title);
}
$size=$data['filesize'];
$track=(isset($data['comments']['track']))?$data['comments']['track'][0]:0;
@@ -150,4 +148,4 @@ class OC_MEDIA_SCANNER{
$ext=substr($filename,strrpos($filename,'.')+1);
return $ext=='mp3' || $ext=='flac' || $ext=='m4a' || $ext=='ogg' || $ext=='oga';
}
-} \ No newline at end of file
+}
diff --git a/apps/remoteStorage/compat.php b/apps/remoteStorage/WebDAV.php
index 445257320c6..e048d19e8f2 100644
--- a/apps/remoteStorage/compat.php
+++ b/apps/remoteStorage/WebDAV.php
@@ -52,14 +52,11 @@ if(isset($_SERVER['HTTP_ORIGIN'])) {
$path = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["SCRIPT_NAME"]));
$pathParts = explode('/', $path);
// for webdav:
-// 0/ 1 / 2 / 3 / 4 / 5 / 6 / 7
-// /$ownCloudUser/remoteStorage/webdav/$userHost/$userName/$dataScope/$key
-// for oauth:
-// 0/ 1 / 2 / 3 / 4
-// /$ownCloudUser/remoteStorage/oauth/auth
+// 0/ 1 / 2 / 3...
+// /$ownCloudUser/remoteStorage/$category/
-if(count($pathParts) >= 8 && $pathParts[0] == '' && $pathParts[2] == 'remoteStorage' && $pathParts[3] == 'webdav') {
- list($dummy0, $ownCloudUser, $dummy2, $dummy3, $userHost, $userName, $dataScope) = $pathParts;
+if(count($pathParts) >= 3 && $pathParts[0] == '') {
+ list($dummy, $ownCloudUser, $dummy2, $category) = $pathParts;
OC_Util::setupFS($ownCloudUser);
@@ -68,10 +65,10 @@ if(count($pathParts) >= 8 && $pathParts[0] == '' && $pathParts[2] == 'remoteStor
$server = new Sabre_DAV_Server($publicDir);
// Path to our script
- $server->setBaseUri(OC::$WEBROOT."/apps/remoteStorage/compat.php/$ownCloudUser");
+ $server->setBaseUri(OC::$WEBROOT."/apps/remoteStorage/WebDAV.php/$ownCloudUser");
// Auth backend
- $authBackend = new OC_Connector_Sabre_Auth_ro_oauth(OC_remoteStorage::getValidTokens($ownCloudUser, $userName.'@'.$userHost, $dataScope));
+ $authBackend = new OC_Connector_Sabre_Auth_ro_oauth(OC_remoteStorage::getValidTokens($ownCloudUser, $category));
$authPlugin = new Sabre_DAV_Auth_Plugin($authBackend,'ownCloud');//should use $validTokens here
$server->addPlugin($authPlugin);
@@ -83,41 +80,6 @@ if(count($pathParts) >= 8 && $pathParts[0] == '' && $pathParts[2] == 'remoteStor
// And off we go!
$server->exec();
-} else if(count($pathParts) >= 4 && $pathParts[0] == '' && $pathParts[2] == 'remoteStorage' && $pathParts[3] == 'oauth2' && $pathParts[4] = 'auth') {
- if(isset($_POST['allow'])) {
- //TODO: input checking. these explodes may fail to produces the desired arrays:
- $ownCloudUser = $pathParts[1];
- foreach($_GET as $k => $v) {
- if($k=='user_address'){
- $userAddress=$v;
- } else if($k=='redirect_uri'){
- $appUrl=$v;
- } else if($k=='scope'){
- $dataScope=$v;
- }
- }
- if(OC_User::getUser() == $ownCloudUser) {
- //TODO: check if this can be faked by editing the cookie in firebug!
- $token=OC_remoteStorage::createDataScope($appUrl, $userAddress, $dataScope);
- header('Location: '.$_GET['redirect_uri'].'#access_token='.$token.'&token_type=remoteStorage');
- } else {
- if((isset($_SERVER['HTTPS'])) && ($_SERVER['HTTPS'])) {
- $url = "https://";
- } else {
- $url = "http://";
- }
- $url .= $_SERVER['SERVER_NAME'];
- $url .= substr($_SERVER['SCRIPT_NAME'], 0, -strlen('apps/remoteStorage/compat.php'));
- die('Please '
- .'<input type="submit" onclick="'
- ."window.open('$url','Close me!','height=600,width=300');"
- .'" value="log in">'
- .', close the pop-up, and '
- .'<form method="POST"><input name="allow" type="submit" value="Try again"></form>');
- }
- } else {
- echo '<form method="POST"><input name="allow" type="submit" value="Allow this web app to store stuff on your owncloud."></form>';
- }
} else {
- die('not webdav and not oauth. dont know what to do '.var_export($pathParts, true));
+ die('not the right address format '.var_export($pathParts, true));
}
diff --git a/apps/remoteStorage/appinfo/database.xml b/apps/remoteStorage/appinfo/database.xml
index b4e1ac7d8af..00ee4942744 100644
--- a/apps/remoteStorage/appinfo/database.xml
+++ b/apps/remoteStorage/appinfo/database.xml
@@ -29,14 +29,7 @@
<length>64</length>
</field>
<field>
- <name>dataScope</name>
- <type>text</type>
- <default></default>
- <notnull>true</notnull>
- <length>64</length>
- </field>
- <field>
- <name>userAddress</name>
+ <name>category</name>
<type>text</type>
<default></default>
<notnull>true</notnull>
diff --git a/apps/remoteStorage/appinfo/info.xml b/apps/remoteStorage/appinfo/info.xml
index a20c6ff4cd4..8179ca99112 100644
--- a/apps/remoteStorage/appinfo/info.xml
+++ b/apps/remoteStorage/appinfo/info.xml
@@ -3,7 +3,7 @@
<id>remoteStorage</id>
<name>remoteStorage compatibility</name>
<description>Enables your users to use ownCloud as their remote storage for unhosted applications.</description>
- <version>0.1</version>
+ <version>0.2</version>
<licence>AGPL</licence>
<author>Michiel de Jong</author>
<require>2</require>
diff --git a/apps/remoteStorage/auth.php b/apps/remoteStorage/auth.php
new file mode 100644
index 00000000000..85421ba3d88
--- /dev/null
+++ b/apps/remoteStorage/auth.php
@@ -0,0 +1,100 @@
+<?php
+
+/**
+* ownCloud
+*
+* Original:
+* @author Frank Karlitschek
+* @copyright 2010 Frank Karlitschek karlitschek@kde.org
+*
+* Adapted:
+* @author Michiel de Jong, 2011
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library 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 this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+
+// Do not load FS ...
+$RUNTIME_NOSETUPFS = true;
+
+require_once('../../lib/base.php');
+OC_Util::checkAppEnabled('remoteStorage');
+require_once('Sabre/autoload.php');
+require_once('lib_remoteStorage.php');
+require_once('oauth_ro_auth.php');
+
+ini_set('default_charset', 'UTF-8');
+#ini_set('error_reporting', '');
+@ob_clean();
+
+//allow use as remote storage for other websites
+if(isset($_SERVER['HTTP_ORIGIN'])) {
+ header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
+ header('Access-Control-Max-Age: 3600');
+ header('Access-Control-Allow-Methods: OPTIONS, GET, PUT, DELETE, PROPFIND');
+ header('Access-Control-Allow-Headers: Authorization, Content-Type');
+} else {
+ header('Access-Control-Allow-Origin: *');
+}
+
+$path = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["SCRIPT_NAME"]));
+$pathParts = explode('/', $path);
+// for webdav:
+// 0/ 1 / 2 / 3 / 4 / 5 / 6 / 7
+// /$ownCloudUser/remoteStorage/webdav/$userHost/$userName/$dataScope/$key
+// for oauth:
+// 0/ 1 / 2 / 3 / 4
+// /$ownCloudUser/remoteStorage/oauth/auth
+
+if(count($pathParts) == 2 && $pathParts[0] == '') {
+ //TODO: input checking. these explodes may fail to produces the desired arrays:
+ $subPathParts = explode('?', $pathParts[1]);
+ $ownCloudUser = $subPathParts[0];
+ foreach($_GET as $k => $v) {
+ if($k=='user_address'){
+ $userAddress=$v;
+ } else if($k=='redirect_uri'){
+ $appUrl=$v;
+ } else if($k=='scope'){
+ $category=$v;
+ }
+ }
+ $currUser = OC_User::getUser();
+ if($currUser == $ownCloudUser) {
+ if(isset($_POST['allow'])) {
+ //TODO: check if this can be faked by editing the cookie in firebug!
+ $token=OC_remoteStorage::createCategory($appUrl, $category);
+ header('Location: '.$_GET['redirect_uri'].'#access_token='.$token.'&token_type=bearer');
+ } else {
+ echo '<form method="POST"><input name="allow" type="submit" value="Allow this web app to store stuff on your owncloud."></form>';
+ }
+ } else {
+ if((isset($_SERVER['HTTPS'])) && ($_SERVER['HTTPS'])) {
+ $url = "https://";
+ } else {
+ $url = "http://";
+ }
+ $url .= $_SERVER['SERVER_NAME'];
+ $url .= substr($_SERVER['SCRIPT_NAME'], 0, -strlen('apps/remoteStorage/compat.php'));
+ die('You are '.($currUser?'logged in as '.$currUser.' instead of '.$ownCloudUser:'not logged in').'. Please '
+ .'<input type="submit" onclick="'
+ ."window.open('$url','Close me!','height=600,width=300');"
+ .'" value="log in">'
+ .', close the pop-up, and '
+ .'<form method="POST"><input name="allow" type="submit" value="Click here"></form>');
+ }
+} else {
+ die('please use auth.php/username?params. '.var_export($pathParts, true));
+}
diff --git a/apps/remoteStorage/lib_remoteStorage.php b/apps/remoteStorage/lib_remoteStorage.php
index f10a72870a4..4f19310904e 100644
--- a/apps/remoteStorage/lib_remoteStorage.php
+++ b/apps/remoteStorage/lib_remoteStorage.php
@@ -1,38 +1,25 @@
<?php
class OC_remoteStorage {
- public static function getValidTokens($ownCloudUser, $userAddress, $dataScope) {
- $query=OC_DB::prepare("SELECT token,appUrl FROM *PREFIX*authtoken WHERE user=? AND userAddress=? AND dataScope=? LIMIT 100");
- $result=$query->execute(array($ownCloudUser,$userAddress,$dataScope));
- if( PEAR::isError($result)) {
- $entry = 'DB Error: "'.$result->getMessage().'"<br />';
- $entry .= 'Offending command was: '.$result->getDebugInfo().'<br />';
- OC_Log::write('removeStorage',$entry,OC_Log::ERROR);
- die( $entry );
- }
+ public static function getValidTokens($ownCloudUser, $category) {
+ $query=OC_DB::prepare("SELECT token,appUrl FROM *PREFIX*authtoken WHERE user=? AND category=? LIMIT 100");
+ $result=$query->execute(array($ownCloudUser,$category));
$ret = array();
while($row=$result->fetchRow()){
- $ret[$row['token']]=$userAddress;
+ $ret[$row['token']]=true;
}
return $ret;
}
public static function getAllTokens() {
$user=OC_User::getUser();
- $query=OC_DB::prepare("SELECT token,appUrl,userAddress,dataScope FROM *PREFIX*authtoken WHERE user=? LIMIT 100");
+ $query=OC_DB::prepare("SELECT token,appUrl,category FROM *PREFIX*authtoken WHERE user=? LIMIT 100");
$result=$query->execute(array($user));
- if( PEAR::isError($result)) {
- $entry = 'DB Error: "'.$result->getMessage().'"<br />';
- $entry .= 'Offending command was: '.$result->getDebugInfo().'<br />';
- OC_Log::write('removeStorage',$entry,OC_Log::ERROR);
- die( $entry );
- }
$ret = array();
while($row=$result->fetchRow()){
$ret[$row['token']] = array(
'appUrl' => $row['appurl'],
- 'userAddress' => $row['useraddress'],
- 'dataScope' => $row['datascope'],
+ 'category' => $row['category'],
);
}
return $ret;
@@ -42,37 +29,24 @@ class OC_remoteStorage {
$user=OC_User::getUser();
$query=OC_DB::prepare("DELETE FROM *PREFIX*authtoken WHERE token=? AND user=?");
$result=$query->execute(array($token,$user));
- if( PEAR::isError($result)) {
- $entry = 'DB Error: "'.$result->getMessage().'"<br />';
- $entry .= 'Offending command was: '.$result->getDebugInfo().'<br />';
- OC_Log::write('removeStorage',$entry,OC_Log::ERROR);
- die( $entry );
- }
}
- private static function addToken($token, $appUrl, $userAddress, $dataScope){
+ private static function addToken($token, $appUrl, $category){
$user=OC_User::getUser();
- $query=OC_DB::prepare("INSERT INTO *PREFIX*authtoken (`token`,`appUrl`,`user`,`userAddress`,`dataScope`) VALUES(?,?,?,?,?)");
- $result=$query->execute(array($token,$appUrl,$user,$userAddress,$dataScope));
- if( PEAR::isError($result)) {
- $entry = 'DB Error: "'.$result->getMessage().'"<br />';
- $entry .= 'Offending command was: '.$result->getDebugInfo().'<br />';
- OC_Log::write('removeStorage',$entry,OC_Log::ERROR);
- die( $entry );
- }
+ $query=OC_DB::prepare("INSERT INTO *PREFIX*authtoken (`token`,`appUrl`,`user`,`category`) VALUES(?,?,?,?)");
+ $result=$query->execute(array($token,$appUrl,$user,$category));
}
- public static function createDataScope($appUrl, $userAddress, $dataScope){
+ public static function createCategory($appUrl, $category) {
$token=uniqid();
- self::addToken($token, $appUrl, $userAddress, $dataScope);
- //TODO: input checking on $userAddress and $dataScope
- list($userName, $userHost) = explode('@', $userAddress);
+ self::addToken($token, $appUrl, $category);
+ //TODO: input checking on $category
OC_Util::setupFS(OC_User::getUser());
- $scopePathParts = array('remoteStorage', 'webdav', $userHost, $userName, $dataScope);
+ $scopePathParts = array('remoteStorage', $category);
for($i=0;$i<=count($scopePathParts);$i++){
$thisPath = '/'.implode('/', array_slice($scopePathParts, 0, $i));
if(!OC_Filesystem::file_exists($thisPath)) {
OC_Filesystem::mkdir($thisPath);
}
}
- return $token;
+ return base64_encode('remoteStorage:'.$token);
}
}
diff --git a/apps/remoteStorage/oauth_ro_auth.php b/apps/remoteStorage/oauth_ro_auth.php
index b785d85fead..5403fbe20c9 100644
--- a/apps/remoteStorage/oauth_ro_auth.php
+++ b/apps/remoteStorage/oauth_ro_auth.php
@@ -13,6 +13,7 @@
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
*/
+
class OC_Connector_Sabre_Auth_ro_oauth extends Sabre_DAV_Auth_Backend_AbstractBasic {
private $validTokens;
@@ -52,7 +53,7 @@ die('not getting in with "'.$username.'"/"'.$password.'"!');
$auth->setRealm($realm);
$userpass = $auth->getUserPass();
if (!$userpass) {
- if(in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD', 'OPTIONS'))) {
+ if(in_array($_SERVER['REQUEST_METHOD'], array('OPTIONS'))) {
$userpass = array('', '');
} else {
$auth->requireLogin();
diff --git a/apps/user_ldap/appinfo/app.php b/apps/user_ldap/appinfo/app.php
index 7906241f79b..3261708f590 100644
--- a/apps/user_ldap/appinfo/app.php
+++ b/apps/user_ldap/appinfo/app.php
@@ -26,7 +26,10 @@ require_once('apps/user_ldap/user_ldap.php');
OC_APP::registerAdmin('user_ldap','settings');
// define LDAP_DEFAULT_PORT
-define("OC_USER_BACKEND_LDAP_DEFAULT_PORT", 389);
+define('OC_USER_BACKEND_LDAP_DEFAULT_PORT', 389);
+
+// define OC_USER_BACKEND_LDAP_DEFAULT_DISPLAY_NAME
+define('OC_USER_BACKEND_LDAP_DEFAULT_DISPLAY_NAME', 'uid');
// register user backend
OC_User::useBackend( "LDAP" );
diff --git a/apps/user_ldap/settings.php b/apps/user_ldap/settings.php
index 8dbd3c0462b..1f2d8ed9af3 100644
--- a/apps/user_ldap/settings.php
+++ b/apps/user_ldap/settings.php
@@ -20,11 +20,21 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
-$params = array('ldap_host', 'ldap_port', 'ldap_dn', 'ldap_password', 'ldap_base', 'ldap_filter');
+$params = array('ldap_host', 'ldap_port', 'ldap_dn', 'ldap_password', 'ldap_base', 'ldap_filter', 'ldap_display_name', 'ldap_tls', 'ldap_nocase');
-foreach($params as $param){
- if(isset($_POST[$param])){
- OC_Appconfig::setValue('user_ldap', $param, $_POST[$param]);
+if ($_POST) {
+ foreach($params as $param){
+ if(isset($_POST[$param])){
+ OC_Appconfig::setValue('user_ldap', $param, $_POST[$param]);
+ }
+ elseif('ldap_tls' == $param) {
+ // unchecked checkboxes are not included in the post paramters
+ OC_Appconfig::setValue('user_ldap', $param, 0);
+ }
+ elseif('ldap_nocase' == $param) {
+ OC_Appconfig::setValue('user_ldap', $param, 0);
+ }
+
}
}
@@ -38,4 +48,7 @@ foreach($params as $param){
// ldap_port has a default value
$tmpl->assign( 'ldap_port', OC_Appconfig::getValue('user_ldap', 'ldap_port', OC_USER_BACKEND_LDAP_DEFAULT_PORT));
+// ldap_display_name has a default value
+$tmpl->assign( 'ldap_display_name', OC_Appconfig::getValue('user_ldap', 'ldap_display_name', OC_USER_BACKEND_LDAP_DEFAULT_DISPLAY_NAME));
+
return $tmpl->fetchPage();
diff --git a/apps/user_ldap/templates/settings.php b/apps/user_ldap/templates/settings.php
index 32e1b29dafb..2abb0b47291 100644
--- a/apps/user_ldap/templates/settings.php
+++ b/apps/user_ldap/templates/settings.php
@@ -1,12 +1,17 @@
<form id="ldap" action="#" method="post">
<fieldset class="personalblock">
<legend><strong>LDAP</strong></legend>
- <p><label for="ldap_host">Host<input type="text" id="ldap_host" name="ldap_host" value="<?php echo $_['ldap_host']; ?>"></label>
- <label for="ldap_port">Port</label><input type="text" id="ldap_port" name="ldap_port" value="<?php echo $_['ldap_port']; ?>" /></p>
- <p><label for="ldap_dn">Name</label><input type="text" id="ldap_dn" name="ldap_dn" value="<?php echo $_['ldap_dn']; ?>" />
- <label for="ldap_password">Password</label><input type="password" id="ldap_password" name="ldap_password" value="<?php echo $_['ldap_password']; ?>" /></p>
- <p><label for="ldap_base">Base</label><input type="text" id="ldap_base" name="ldap_base" value="<?php echo $_['ldap_base']; ?>" />
- <label for="ldap_filter">Filter (use %uid placeholder)</label><input type="text" id="ldap_filter" name="ldap_filter" value="<?php echo $_['ldap_filter']; ?>" /></p>
+ <p><label for="ldap_host"><?php echo $l->t('Host');?><input type="text" id="ldap_host" name="ldap_host" value="<?php echo $_['ldap_host']; ?>"></label>
+ <label for="ldap_port"><?php echo $l->t('Port');?></label><input type="text" id="ldap_port" name="ldap_port" value="<?php echo $_['ldap_port']; ?>" /></p>
+ <p><label for="ldap_dn"><?php echo $l->t('Name');?></label><input type="text" id="ldap_dn" name="ldap_dn" value="<?php echo $_['ldap_dn']; ?>" />
+ <label for="ldap_password"><?php echo $l->t('Password');?></label><input type="password" id="ldap_password" name="ldap_password" value="<?php echo $_['ldap_password']; ?>" />
+ <small><?php echo $l->t('Leave both empty for anonymous bind for search, then bind with users credentials.');?></small></p>
+ <p><label for="ldap_base"><?php echo $l->t('Base');?></label><input type="text" id="ldap_base" name="ldap_base" value="<?php echo $_['ldap_base']; ?>" />
+ <label for="ldap_filter"><?php echo $l->t('Filter (use %%uid placeholder)');?></label><input type="text" id="ldap_filter" name="ldap_filter" value="<?php echo $_['ldap_filter']; ?>" /></p>
+ <p><label for="ldap_display_name"><?php echo $l->t('Display Name Field');?></label><input type="text" id="ldap_display_name" name="ldap_display_name" value="<?php echo $_['ldap_display_name']; ?>" />
+ <small><?php echo $l->t('Currently the display name field needs to be the same you matched %%uid against in the filter above, because ownCloud doesn\'t distinguish between user id and user name.');?></small></p>
+ <p><input type="checkbox" id="ldap_tls" name="ldap_tls" value="1"<?php if ($_['ldap_tls']) echo ' checked'; ?>><label for="ldap_tls"><?php echo $l->t('Use TLS');?></label></p>
+ <p><input type="checkbox" id="ldap_nocase" name="ldap_nocase" value="1"<?php if ($_['ldap_nocase']) echo ' checked'; ?>><label for="ldap_nocase"><?php echo $l->t('Case insensitve LDAP server (Windows)');?></label></p>
<input type="submit" value="Save" />
</fieldset>
</form>
diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php
index 1154efc17b1..106240e74b8 100644
--- a/apps/user_ldap/user_ldap.php
+++ b/apps/user_ldap/user_ldap.php
@@ -33,6 +33,9 @@ class OC_USER_LDAP extends OC_User_Backend {
protected $ldap_password;
protected $ldap_base;
protected $ldap_filter;
+ protected $ldap_tls;
+ protected $ldap_nocase;
+ protected $ldap_display_name;
function __construct() {
$this->ldap_host = OC_Appconfig::getValue('user_ldap', 'ldap_host','');
@@ -41,13 +44,16 @@ class OC_USER_LDAP extends OC_User_Backend {
$this->ldap_password = OC_Appconfig::getValue('user_ldap', 'ldap_password','');
$this->ldap_base = OC_Appconfig::getValue('user_ldap', 'ldap_base','');
$this->ldap_filter = OC_Appconfig::getValue('user_ldap', 'ldap_filter','');
+ $this->ldap_tls = OC_Appconfig::getValue('user_ldap', 'ldap_tls', 0);
+ $this->ldap_nocase = OC_Appconfig::getValue('user_ldap', 'ldap_nocase', 0);
+ $this->ldap_display_name = OC_Appconfig::getValue('user_ldap', 'ldap_display_name', OC_USER_BACKEND_LDAP_DEFAULT_DISPLAY_NAME);
if( !empty($this->ldap_host)
&& !empty($this->ldap_port)
- && !empty($this->ldap_dn)
- && !empty($this->ldap_password)
+ && ((!empty($this->ldap_dn) && !empty($this->ldap_password)) || (empty($this->ldap_dn) && empty($this->ldap_password)))
&& !empty($this->ldap_base)
&& !empty($this->ldap_filter)
+ && !empty($this->ldap_display_name)
)
{
$this->configured = true;
@@ -63,9 +69,10 @@ class OC_USER_LDAP extends OC_User_Backend {
private function getDs() {
if(!$this->ds) {
$this->ds = ldap_connect( $this->ldap_host, $this->ldap_port );
- if(ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3))
- if(ldap_set_option($this->ds, LDAP_OPT_REFERRALS, 0))
- ldap_start_tls($this->ds);
+ if(ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3))
+ if(ldap_set_option($this->ds, LDAP_OPT_REFERRALS, 0))
+ if($this->ldap_tls)
+ ldap_start_tls($this->ds);
}
// login
@@ -88,15 +95,16 @@ class OC_USER_LDAP extends OC_User_Backend {
return false;
// get dn
- $filter = str_replace("%uid", $uid, $this->ldap_filter);
+ $filter = str_replace('%uid', $uid, $this->ldap_filter);
$sr = ldap_search( $this->getDs(), $this->ldap_base, $filter );
$entries = ldap_get_entries( $this->getDs(), $sr );
- if( $entries["count"] == 0 )
+ if( $entries['count'] == 0 )
return false;
- return $entries[0]["dn"];
+ return $entries[0]['dn'];
}
+
public function checkPassword( $uid, $password ) {
if(!$this->configured){
return false;
@@ -107,7 +115,28 @@ class OC_USER_LDAP extends OC_User_Backend {
if (!@ldap_bind( $this->getDs(), $dn, $password ))
return false;
- return $uid;
+
+ if($this->ldap_nocase) {
+ $filter = str_replace('%uid', $uid, $this->ldap_filter);
+ $sr = ldap_search( $this->getDs(), $this->ldap_base, $filter );
+ $entries = ldap_get_entries( $this->getDs(), $sr );
+ if( $entries['count'] == 1 ) {
+ foreach($entries as $row) {
+ $ldap_display_name = strtolower($this->ldap_display_name);
+ if(isset($row[$ldap_display_name])) {
+ return $row[$ldap_display_name][0];
+ }
+ }
+ }
+ else {
+ return $uid;
+ }
+
+ }
+ else {
+ return $uid;
+ }
+
}
public function userExists( $uid ) {
@@ -117,6 +146,37 @@ class OC_USER_LDAP extends OC_User_Backend {
$dn = $this->getDn($uid);
return !empty($dn);
}
+
+ public function getUsers()
+ {
+ if(!$this->configured)
+ return false;
+
+ // connect to server
+ $ds = $this->getDs();
+ if( !$ds )
+ return false;
+
+ // get users
+ $filter = 'objectClass=person';
+ $sr = ldap_search( $this->getDs(), $this->ldap_base, $filter );
+ $entries = ldap_get_entries( $this->getDs(), $sr );
+ if( $entries['count'] == 0 )
+ return false;
+ else {
+ $users = array();
+ foreach($entries as $row) {
+ // TODO ldap_get_entries() seems to lower all keys => needs review
+ $ldap_display_name = strtolower($this->ldap_display_name);
+ if(isset($row[$ldap_display_name])) {
+ $users[] = $row[$ldap_display_name][0];
+ }
+ }
+ // TODO language specific sorting of user names
+ sort($users);
+ return $users;
+ }
+ }
}
diff --git a/apps/user_webfinger/webfinger.php b/apps/user_webfinger/webfinger.php
index afb53689682..d695a833f31 100644
--- a/apps/user_webfinger/webfinger.php
+++ b/apps/user_webfinger/webfinger.php
@@ -4,7 +4,14 @@ if($_SERVER['SCRIPT_NAME'] == '/.well-known/webfinger.php') {
} else {
header('Please-first: activate');
}
-header("Content-Type: application/xml+xrd");
+// header("Content-Type: application/xml+xrd");
+
+// calculate the documentroot
+// modified version of the one in lib/base.php that takes the .well-known symlink into account
+$DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']);
+$SERVERROOT=str_replace("\\",'/',dirname(dirname(dirname(dirname(__FILE__)))));
+$SUBURI=substr(realpath($_SERVER["SCRIPT_FILENAME"]),strlen($SERVERROOT));
+$WEBROOT=substr($SUBURI,0,-34);
if($_GET['q']) {
$bits = explode('@', $_GET['q']);
@@ -15,10 +22,20 @@ if($_GET['q']) {
if(substr($userName, 0, 5) == 'acct:') {
$userName = substr($userName, 5);
}
+if($_SERVER['HTTPS']) {
+ $baseAddress = 'https://'.$_SERVER['SERVER_NAME'].'/apps/remoteStorage/';
+} else {
+ $baseAddress = 'http://'.$_SERVER['SERVER_NAME'].'/apps/remoteStorage/';
+}
echo "<";
?>
?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0" xmlns:hm="http://host-meta.net/xrd/1.0">
<hm:Host xmlns="http://host-meta.net/xrd/1.0"><?php echo $_SERVER['SERVER_NAME'] ?></hm:Host>
- <Link rel="http://unhosted.org/spec/dav/0.1" href="http<?php echo ($_SERVER['HTTPS']?'s':''); ?>://<?php echo $_SERVER['SERVER_NAME'] ?>/apps/remoteStorage/compat.php/<?php echo $userName ?>/remoteStorage/" />
+ <Link
+ rel="remoteStorage"
+ template="<?php echo $baseAddress ?>WebDAV.php/<?php echo $userName ?>/remoteStorage/{category}/"
+ api="WebDAV"
+ auth="<?php echo $baseAddress; ?>auth.php/<?php echo $userName ?>"
+ ></Link>
</XRD>
diff --git a/core/css/styles.css b/core/css/styles.css
index 0f591859f3a..d1c648383c0 100644
--- a/core/css/styles.css
+++ b/core/css/styles.css
@@ -32,14 +32,14 @@ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#35537a', end
/* INPUTS */
input[type="text"], input[type="password"] { cursor:text; }
-input, select, .button, #quota, div.jp-progress, .pager li a { font-size:1em; width:10em; margin:.3em; padding:.6em .5em .4em; background:#fff; color:#333; border:1px solid #ddd; -moz-box-shadow:0 1px 1px #fff, 0 2px 0 #bbb inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; outline:none; }
+input, select, button, .button, #quota, div.jp-progress, .pager li a { font-size:1em; width:10em; margin:.3em; padding:.6em .5em .4em; background:#fff; color:#333; border:1px solid #ddd; -moz-box-shadow:0 1px 1px #fff, 0 2px 0 #bbb inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; box-shadow:0 1px 1px #fff, 0 1px 0 #bbb inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; outline:none; }
input[type="text"], input[type="password"], input[type="search"] { background:#f8f8f8; color:#555; cursor:text; }
input[type="text"], input[type="password"], input[type="search"] { -webkit-appearance:textfield; -moz-appearance:textfield; -webkit-box-sizing:content-box; -moz-box-sizing:content-box; box-sizing:content-box; }
input[type="text"]:hover, input[type="text"]:focus, input[type="text"]:active,
input[type="password"]:hover, input[type="password"]:focus, input[type="password"]:active,
.searchbox input[type="search"]:hover, .searchbox input[type="search"]:focus, .searchbox input[type="search"]:active { background-color:#fff; color:#333; opacity:1; }
-input[type="submit"], input[type="button"], .button, #quota, div.jp-progress, .pager li a { width:auto; padding:.4em; border:1px solid #ddd; font-weight:bold; cursor:pointer; background:#f8f8f8; color:#555; text-shadow:#fff 0 1px 0; -moz-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; }
+input[type="submit"], input[type="button"], button, .button, #quota, div.jp-progress, .pager li a { width:auto; padding:.4em; border:1px solid #ddd; font-weight:bold; cursor:pointer; background:#f8f8f8; color:#555; text-shadow:#fff 0 1px 0; -moz-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -webkit-box-shadow:0 1px 1px #fff, 0 1px 1px #fff inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; }
input[type="submit"]:hover, input[type="submit"]:focus, input[type="button"]:hover, input[type="button"]:focus, .button:hover { background:#fff; color:#333; }
input[type="checkbox"] { width:auto; }
#quota { cursor:default; }
diff --git a/core/img/actions/upload.png b/core/img/actions/upload.png
new file mode 100644
index 00000000000..5744aad75a8
--- /dev/null
+++ b/core/img/actions/upload.png
Binary files differ
diff --git a/core/img/actions/upload.svg b/core/img/actions/upload.svg
new file mode 100644
index 00000000000..91333bb681e
--- /dev/null
+++ b/core/img/actions/upload.svg
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="16"
+ height="16"
+ id="svg3875"
+ version="1.1"
+ inkscape:version="0.48.1 r9760"
+ sodipodi:docname="download.svg"
+ inkscape:export-filename="/home/jancborchardt/owncloud/core/img/actions/play.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs3877" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="17.921875"
+ inkscape:cx="-5.3403178"
+ inkscape:cy="10.148736"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:window-width="1280"
+ inkscape:window-height="776"
+ inkscape:window-x="0"
+ inkscape:window-y="24"
+ inkscape:window-maximized="1">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3883"
+ empspacing="5"
+ visible="true"
+ enabled="true"
+ snapvisiblegridlinesonly="true" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata3880">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1036.3622)">
+ <path
+ style="fill:#000000;fill-opacity:1;stroke:none"
+ d="m 10,1051.3622 -4,0 -1,-7 -4,0 7,-7 7,7 -4,0 z"
+ id="path3086"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccccccc" />
+ </g>
+</svg>
diff --git a/core/js/jquery-tipsy.js b/core/js/jquery-tipsy.js
index 9567ed3bacc..ef4bbfd87a1 100644
--- a/core/js/jquery-tipsy.js
+++ b/core/js/jquery-tipsy.js
@@ -31,6 +31,10 @@
height: this.$element[0].offsetHeight
});
+ if (this.options.className) {
+ $tip.addClass(maybeCall(this.options.className, this.$element[0]));
+ }
+
var actualWidth = $tip[0].offsetWidth,
actualHeight = $tip[0].offsetHeight,
gravity = maybeCall(this.options.gravity, this.$element[0]);
@@ -61,9 +65,6 @@
$tip.css(tp).addClass('tipsy-' + gravity);
$tip.find('.tipsy-arrow')[0].className = 'tipsy-arrow tipsy-arrow-' + gravity.charAt(0);
- if (this.options.className) {
- $tip.addClass(maybeCall(this.options.className, this.$element[0]));
- }
if (this.options.fade) {
$tip.stop().css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: this.options.opacity});
diff --git a/core/js/js.js b/core/js/js.js
index 9e814ca0729..5846d289880 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -365,7 +365,7 @@ $(document).ready(function(){
$('.jp-controls .jp-previous').tipsy({gravity:'nw', fade:true, live:true});
$('.jp-controls .jp-next').tipsy({gravity:'n', fade:true, live:true});
$('.password .action').tipsy({gravity:'se', fade:true, live:true});
- $('.file_upload_button_wrapper').tipsy({gravity:'e', fade:true});
+ $('.file_upload_button_wrapper').tipsy({gravity:'w', fade:true});
$('.selectedActions a.delete').tipsy({gravity: 'se', fade:true, live:true});
$('.selectedActions a').tipsy({gravity:'s', fade:true, live:true});
$('#headerSize').tipsy({gravity:'s', fade:true, live:true});
@@ -401,3 +401,10 @@ if (!Array.prototype.map){
return res;
};
}
+
+/**
+ * Filter Jquery selector by attribute value
+ **/
+$.fn.filterAttr = function(attr_name, attr_value) {
+ return this.filter(function() { return $(this).attr(attr_name) === attr_value; });
+};
diff --git a/core/lostpassword/index.php b/core/lostpassword/index.php
index de0d393ec78..ede94dab2d7 100644
--- a/core/lostpassword/index.php
+++ b/core/lostpassword/index.php
@@ -14,7 +14,7 @@ if (isset($_POST['user'])) {
if (OC_User::userExists($_POST['user'])) {
$token = sha1($_POST['user']+uniqId());
OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', $token);
- $email = OC_Preferences::getValue($_POST['user'], 'lostpassword', 'email', '');
+ $email = OC_Preferences::getValue($_POST['user'], 'settings', 'email', '');
if (!empty($email)) {
$link = OC_Helper::linkTo('core/lostpassword', 'resetpassword.php', null, true).'?user='.$_POST['user'].'&token='.$token;
$tmpl = new OC_Template('core/lostpassword', 'email');
diff --git a/files/ajax/newfile.php b/files/ajax/newfile.php
new file mode 100644
index 00000000000..5c4f49a3675
--- /dev/null
+++ b/files/ajax/newfile.php
@@ -0,0 +1,27 @@
+<?php
+
+// Init owncloud
+require_once('../../lib/base.php');
+
+OC_JSON::checkLoggedIn();
+
+// Get the params
+$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
+$filename = isset( $_GET['filename'] ) ? $_GET['filename'] : '';
+$content = isset( $_GET['content'] ) ? $_GET['content'] : '';
+
+if($filename == '') {
+ OC_JSON::error(array("data" => array( "message" => "Empty Filename" )));
+ exit();
+}
+
+if(OC_Files::newFile($dir, $filename, 'file')) {
+ if($content){
+ OC_Filesystem::file_put_contents($dir.'/'.$filename,$content);
+ }
+ OC_JSON::success(array("data" => array('content'=>$content)));
+ exit();
+}
+
+
+OC_JSON::error(array("data" => array( "message" => "Error when creating the file" ))); \ No newline at end of file
diff --git a/files/css/files.css b/files/css/files.css
index ac1f523f862..22f4810d0a6 100644
--- a/files/css/files.css
+++ b/files/css/files.css
@@ -3,15 +3,22 @@
See the COPYING-README file. */
/* FILE MENU */
-.actions { padding:.3em; float:left; }
-.actions input { margin:0; }
+.actions { padding:.3em; float:left; height:2em; }
+.actions input, .actions button, .actions .button { margin:0; }
#file_menu { right:0; position:absolute; top:0; }
#file_menu a { display:block; float:left; background-image:none; text-decoration:none; }
-.file_upload_form, #file_newfolder_form { display:inline; float: left; margin-left:.5em; }
+.file_upload_form, #file_newfolder_form { display:inline; float: left; margin-left:0; }
#fileSelector, #file_upload_submit, #file_newfolder_submit { display:none; }
.file_upload_wrapper, #file_newfolder_name { background-repeat:no-repeat; background-position:.5em .5em; padding-left:2em; }
-.file_upload_wrapper { font-weight:bold; display:-moz-inline-box; /* fallback for older firefox versions*/ display:inline-block; padding-left:0; overflow:hidden; position:relative; margin:.1em .1em .1em 0em;}
+.file_upload_wrapper { font-weight:bold; display:-moz-inline-box; /* fallback for older firefox versions*/ display:inline-block; padding-left:0; overflow:hidden; position:relative; margin:0;}
.file_upload_wrapper .file_upload_button_wrapper { position:absolute; top:0; left:0; width:100%; height:100%; cursor:pointer; z-index:1000; }
+#new { float:left; border-top-right-radius:0; border-bottom-right-radius:0; margin:0 0 0 1em; border-right:none; z-index:1010; height:1.3em; }
+#new.active { border-bottom-left-radius:0; border-bottom:none; background:#f8f8f8 }
+#new>a{ padding-left:1em; padding-right:1em; }
+#new>ul { display:none; position:fixed; text-align:left; padding:.5em; background:#f8f8f8; margin-top:0.075em; border:1px solid #ddd; min-width:7em; margin-left:-.5em; z-index:-1; }
+#new>ul>li { margin:.3em; padding-left:2em; background-repeat:no-repeat; cursor:pointer; padding-bottom:0.1em }
+#new>ul>li>p { cursor:pointer; }
+#new>ul>li>input { padding:0.3em; margin:-0.3em; }
#file_newfolder_name { background-image:url('../../core/img/places/folder.svg'); font-weight:normal; width:7em; }
.file_upload_start, .file_upload_filename { font-size:1em; }
@@ -19,7 +26,9 @@
.file_upload_target { display:none; }
.file_upload_start { opacity:0; filter:alpha(opacity=0); z-index:1; position:absolute; left:0; top:0; width:100%; cursor:pointer;}
-.file_upload_filename { z-index:100; cursor:pointer;}
+.file_upload_filename.active { border-bottom-right-radius:0 }
+.file_upload_filename { z-index:100; cursor:pointer; border-top-left-radius:0; border-bottom-left-radius:0; padding:.3em; }
+
.file_upload_form, .file_upload_wrapper, .file_upload_start, .file_upload_filename, #file_upload_submit { cursor:pointer; }
diff --git a/files/index.php b/files/index.php
index 8bb5b618d87..7e156130d8e 100644
--- a/files/index.php
+++ b/files/index.php
@@ -89,10 +89,15 @@ $upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'
$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size'));
$maxUploadFilesize = min($upload_max_filesize, $post_max_size);
+$freeSpace=OC_Filesystem::free_space('/');
+$freeSpace=max($freeSpace,0);
+$maxUploadFilesize = min($maxUploadFilesize ,$freeSpace);
+
$tmpl = new OC_Template( "files", "index", "user" );
$tmpl->assign( "fileList", $list->fetchPage() );
$tmpl->assign( "breadcrumb", $breadcrumbNav->fetchPage() );
$tmpl->assign( 'dir', $dir);
+$tmpl->assign( 'readonly', !OC_Filesystem::is_writeable($dir));
$tmpl->assign( "files", $files );
$tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize);
$tmpl->assign( 'uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize));
diff --git a/files/js/fileactions.js b/files/js/fileactions.js
index f95c5e84dc1..9e2688e82c1 100644
--- a/files/js/fileactions.js
+++ b/files/js/fileactions.js
@@ -56,7 +56,7 @@ FileActions={
$('#fileList .action').remove();
var actions=FileActions.get(FileActions.getCurrentMimeType(),FileActions.getCurrentType());
var file=FileActions.getCurrentFile();
- if($('tr[data-file="'+file+'"]').data('renaming')){
+ if($('tr').filterAttr('data-file',file).data('renaming')){
return;
}
var defaultAction=FileActions.getDefault(FileActions.getCurrentMimeType(),FileActions.getCurrentType());
diff --git a/files/js/filelist.js b/files/js/filelist.js
index 863a3385d15..16f73ed58d6 100644
--- a/files/js/filelist.js
+++ b/files/js/filelist.js
@@ -4,7 +4,7 @@ FileList={
},
addFile:function(name,size,lastModified,loading){
var img=(loading)?OC.imagePath('core', 'loading.gif'):OC.imagePath('core', 'filetypes/file.png');
- var html='<tr data-file="'+name+'" data-type="file" data-size="'+size+'">';
+ var html='<tr data-type="file" data-size="'+size+'">';
if(name.indexOf('.')!=-1){
var basename=name.substr(0,name.lastIndexOf('.'));
var extention=name.substr(name.lastIndexOf('.'));
@@ -29,16 +29,21 @@ FileList={
html+='<td class="filesize" title="'+humanFileSize(size)+'" style="color:rgb('+sizeColor+','+sizeColor+','+sizeColor+')">'+simpleSize+'</td>';
html+='<td class="date"><span class="modified" title="'+formatDate(lastModified)+'" style="color:rgb('+modifiedColor+','+modifiedColor+','+modifiedColor+')">'+relative_modified_date(lastModified.getTime() / 1000)+'</span></td>';
html+='</tr>';
- FileList.insertElement(name,'file',$(html));
+ FileList.insertElement(name,'file',$(html).attr('data-file',name));
if(loading){
- $('tr[data-file="'+name+'"]').data('loading',true);
+ $('tr').filterAttr('data-file',name).data('loading',true);
}else{
- $('tr[data-file="'+name+'"] td.filename').draggable(dragOptions);
+ $('tr').filterAttr('data-file',name).find('td.filename').draggable(dragOptions);
}
},
addDir:function(name,size,lastModified){
- var html='<tr data-file="'+name+'" data-type="dir" data-size="'+size+'">';
- html+='<td class="filename" style="background-image:url('+OC.imagePath('core', 'filetypes/folder.png')+')"><input type="checkbox" /><a class="name" href="index.php?dir='+$('#dir').val()+'/'+name+'">'+name+'</a></td>';
+ html = $('<tr></tr>').attr({ "data-type": "dir", "data-size": size, "data-file": name});
+ td = $('<td></td>').attr({"class": "filename", "style": 'background-image:url('+OC.imagePath('core', 'filetypes/folder.png')+')' });
+ td.append('<input type="checkbox" />');
+ var link_elem = $('<a></a>').attr({ "class": "name", "href": "index.php?dir="+ encodeURIComponent($('#dir').val()+'/'+name) });
+ link_elem.append($('<span></span>').addClass('nametext').text(name));
+ td.append(link_elem);
+ html.append(td);
if(size!='Pending'){
simpleSize=simpleFileSize(size);
}else{
@@ -47,13 +52,15 @@ FileList={
sizeColor = Math.round(200-Math.pow((size/(1024*1024)),2));
lastModifiedTime=Math.round(lastModified.getTime() / 1000);
modifiedColor=Math.round((Math.round((new Date()).getTime() / 1000)-lastModifiedTime)/60/60/24*5);
- html+='<td class="filesize" title="'+humanFileSize(size)+'" style="color:rgb('+sizeColor+','+sizeColor+','+sizeColor+')">'+simpleSize+'</td>';
- html+='<td class="date"><span class="modified" title="'+formatDate(lastModified)+'" style="color:rgb('+modifiedColor+','+modifiedColor+','+modifiedColor+')">'+relative_modified_date(lastModified.getTime() / 1000)+'</span></td>';
- html+='</tr>';
+ td = $('<td></td>').attr({ "class": "filesize", "title": humanFileSize(size), "style": 'color:rgb('+sizeColor+','+sizeColor+','+sizeColor+')'}).text(simpleSize);
+ html.append(td);
- FileList.insertElement(name,'dir',$(html));
- $('tr[data-file="'+name+'"] td.filename').draggable(dragOptions);
- $('tr[data-file="'+name+'"] td.filename').droppable(folderDropOptions);
+ td = $('<td></td>').attr({ "class": "date" });
+ td.append($('<span></span>').attr({ "class": "modified", "title": formatDate(lastModified), "style": 'color:rgb('+modifiedColor+','+modifiedColor+','+modifiedColor+')' }).text( relative_modified_date(lastModified.getTime() / 1000) ));
+ html.append(td);
+ FileList.insertElement(name,'dir',html);
+ $('tr').filterAttr('data-file',name).find('td.filename').draggable(dragOptions);
+ $('tr').filterAttr('data-file',name).find('td.filename').droppable(folderDropOptions);
},
refresh:function(data) {
result = jQuery.parseJSON(data.responseText);
@@ -64,8 +71,8 @@ FileList={
resetFileActionPanel();
},
remove:function(name){
- $('tr[data-file="'+name+'"] td.filename').draggable('destroy');
- $('tr[data-file="'+name+'"]').remove();
+ $('tr').filterAttr('data-file',name).find('td.filename').draggable('destroy');
+ $('tr').filterAttr('data-file',name).remove();
if($('tr[data-file]').length==0){
$('#emptyfolder').show();
$('.file_upload_filename').addClass('highlight');
@@ -101,7 +108,7 @@ FileList={
$('.file_upload_filename').removeClass('highlight');
},
loadingDone:function(name){
- var tr=$('tr[data-file="'+name+'"]');
+ var tr=$('tr').filterAttr('data-file',name);
tr.data('loading',false);
var mime=tr.data('mime');
tr.attr('data-mime',mime);
@@ -111,14 +118,14 @@ FileList={
tr.find('td.filename').draggable(dragOptions);
},
isLoading:function(name){
- return $('tr[data-file="'+name+'"]').data('loading');
+ return $('tr').filterAttr('data-file',name).data('loading');
},
rename:function(name){
- var tr=$('tr[data-file="'+name+'"]');
+ var tr=$('tr').filterAttr('data-file',name);
tr.data('renaming',true);
var td=tr.children('td.filename');
- var input=$('<input value="'+name+'" class="filename"></input>');
- var form=$('<form action="#"></form>')
+ var input=$('<input class="filename"></input>').val(name);
+ var form=$('<form></form>')
form.append(input);
td.children('a.name').text('');
td.children('a.name').append(form)
@@ -127,7 +134,6 @@ FileList={
event.stopPropagation();
event.preventDefault();
var newname=input.val();
- tr.data('renaming',false);
tr.attr('data-file',newname);
td.children('a.name').empty();
if(newname.indexOf('.')>0){
@@ -141,12 +147,12 @@ FileList={
if(newname.indexOf('.')>0){
span.append($('<span class="extention">'+newname.substr(newname.lastIndexOf('.'))+'</span>'));
}
- $.ajax({
- url: 'ajax/rename.php',
- data: "dir="+$('#dir').val()+"&newname="+encodeURIComponent(newname)+"&file="+encodeURIComponent(name)
+ $.get(OC.filePath('files','ajax','rename.php'), { dir : $('#dir').val(), newname: newname, file: name },function(){
+ tr.data('renaming',false);
});
+ return false;
});
- form.click(function(event){
+ input.click(function(event){
event.stopPropagation();
event.preventDefault();
});
@@ -165,9 +171,10 @@ FileList={
files=[files];
}
$.each(files,function(index,file){
- $('tr[data-file="'+file+'"]').hide();
- $('tr[data-file="'+file+'"]').find('input[type="checkbox"]').removeAttr('checked');
- $('tr[data-file="'+file+'"]').removeClass('selected');
+ var files = $('tr').filterAttr('data-file',file);
+ files.hide();
+ files.find('input[type="checkbox"]').removeAttr('checked');
+ files.removeClass('selected');
});
procesSelection();
FileList.deleteCanceled=false;
@@ -208,7 +215,7 @@ $(document).ready(function(){
if($('#notification').data('deletefile'))
{
$.each(FileList.deleteFiles,function(index,file){
- $('tr[data-file="'+file+'"]').show();
+ $('tr').filterAttr('data-file',file).show();
// alert(file);
});
FileList.deleteCanceled=true;
diff --git a/files/js/files.js b/files/js/files.js
index 902c5e54934..5a528f5122c 100644
--- a/files/js/files.js
+++ b/files/js/files.js
@@ -1,4 +1,9 @@
$(document).ready(function() {
+ $('#fileList tr').each(function(){
+ //little hack to set unescape filenames in attribute
+ $(this).attr('data-file',decodeURIComponent($(this).attr('data-file')));
+ });
+
if($('tr[data-file]').length==0){
$('.file_upload_filename').addClass('highlight');
}
@@ -9,8 +14,8 @@ $(document).ready(function() {
$('#fileList tr td.filename').draggable(dragOptions);
$('#fileList tr[data-type="dir"] td.filename').droppable(folderDropOptions);
$('div.crumb').droppable(crumbDropOptions);
- $('#plugins>ul>li:first-child').data('dir','');
- $('#plugins>ul>li:first-child').droppable(crumbDropOptions);
+ $('ul#apps>li:first-child').data('dir','');
+ $('ul#apps>li:first-child').droppable(crumbDropOptions);
// Triggers invisible file input
$('.file_upload_button_wrapper').live('click', function() {
@@ -64,8 +69,10 @@ $(document).ready(function() {
}
procesSelection();
} else {
- var filename=$(this).parent().parent().data('file');
- if(!FileList.isLoading(filename)){
+ var filename=$(this).parent().parent().attr('data-file');
+ var tr=$('tr').filterAttr('data-file',filename);
+ var renaming=tr.data('renaming')
+ if(!renaming && !FileList.isLoading(filename)){
var mime=$(this).parent().parent().data('mime');
var type=$(this).parent().parent().data('type');
var action=FileActions.getDefault(mime,type);
@@ -158,7 +165,7 @@ $(document).ready(function() {
});
$('.file_upload_start').live('change',function(){
- var form=$(this).parent().parent();
+ var form=$(this).closest('form');
var uploadId=form.attr('data-upload-id');
var files=this.files;
var target=form.children('iframe');
@@ -185,9 +192,9 @@ $(document).ready(function() {
if(response[0] != undefined && response[0].status == 'success'){
for(var i=0;i<response.length;i++){
var file=response[i];
- $('tr[data-file="'+file.name+'"]').data('mime',file.mime);
+ $('tr').filterAttr('data-file',file.name).data('mime',file.mime);
if(size=='Pending'){
- $('tr[data-file='+file.name+'] td.filesize').text(file.size);
+ $('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size);
}
FileList.loadingDone(file.name);
}
@@ -255,32 +262,82 @@ $(document).ready(function() {
text=text.substr(0,text.length-6)+'...';
crumb.text(text);
}
+
+ $(window).click(function(){
+ $('#new>ul').hide();
+ $('#new').removeClass('active');
+ $('button.file_upload_filename').removeClass('active');
+ $('#new li').each(function(i,element){
+ if($(element).children('p').length==0){
+ $(element).children('input').remove();
+ $(element).append('<p>'+$(element).data('text')+'</p>');
+ }
+ });
+ });
+ $('#new').click(function(event){
+ event.stopPropagation();
+ });
+ $('#new>a').click(function(){
+ $('#new>ul').toggle();
+ $('#new').toggleClass('active');
+ $('button.file_upload_filename').toggleClass('active');
+ });
+ $('#new li').click(function(){
+ if($(this).children('p').length==0){
+ return;
+ }
+
+ $('#new li').each(function(i,element){
+ if($(element).children('p').length==0){
+ $(element).children('input').remove();
+ $(element).append('<p>'+$(element).data('text')+'</p>');
+ }
+ });
+
+ var type=$(this).data('type');
+ var text=$(this).children('p').text();
+ $(this).data('text',text);
+ $(this).children('p').remove();
+ var input=$('<input>');
+ $(this).append(input);
+ input.focus();
+ input.change(function(){
+ var name=$(this).val();
+ switch(type){
+ case 'file':
+ $.ajax({
+ url: OC.filePath('files','ajax','newfile.php'),
+ data: "dir="+encodeURIComponent($('#dir').val())+"&filename="+encodeURIComponent(name)+'&content=%20%0A',
+ complete: function(data){boolOperationFinished(data, function(){
+ var date=new Date();
+ FileList.addFile(name,0,date);
+ var tr=$('tr').filterAttr('data-file',name);
+ tr.data('mime','text/plain');
+ getMimeIcon('text/plain',function(path){
+ tr.find('td.filename').attr('style','background-image:url('+path+')');
+ });
+ });}
+ });
+ break;
+ case 'folder':
+ $.ajax({
+ url: OC.filePath('files','ajax','newfolder.php'),
+ data: "dir="+encodeURIComponent($('#dir').val())+"&foldername="+encodeURIComponent(name),
+ complete: function(data){boolOperationFinished(data, function(){
+ var date=new Date();
+ FileList.addDir(name,0,date);
+ });}
+ });
+ break;
+ }
+ var li=$(this).parent();
+ $(this).remove();
+ li.append('<p>'+li.data('text')+'</p>');
+ $('#new>a').click();
+ });
+ });
});
-var adjustNewFolderSize = function() {
- if($('#file_newfolder_name').val() != '') {
- splitSize($('#file_newfolder_name'),$('#file_newfolder_submit'));
- $('#file_newfolder_name').unbind('keyup', adjustNewFolderSize);
- };
-}
-
-function splitSize(existingEl, appearingEl) {
- nw = parseInt($(existingEl).css('width')) - parseInt($(appearingEl).css('width'));
- $(existingEl).css('width', nw + 'px');
- $(appearingEl).fadeIn(250);
-}
-
-function unsplitSize(stayingEl, vanishingEl) {
- nw = parseInt($(stayingEl).css('width')) + parseInt($(vanishingEl).css('width'));
- $(stayingEl).css('width', nw + 'px');
- $(vanishingEl).fadeOut(250);
-}
-
-function resetFileActionPanel() {
- $('#file_action_panel form').css({"display":"none"});
- $('#file_action_panel').attr('activeAction', false);
-}
-
function boolOperationFinished(data, callback) {
result = jQuery.parseJSON(data.responseText);
if(result.status == 'success'){
@@ -343,7 +400,7 @@ var folderDropOptions={
url: 'ajax/move.php',
data: "dir="+dir+"&file="+file+'&target='+dir+'/'+target,
complete: function(data){boolOperationFinished(data, function(){
- var el=$('#fileList tr[data-file="'+file+'"] td.filename');
+ var el = $('#fileList tr').filterAttr('data-file',file).find('td.filename');
el.draggable('destroy');
FileList.remove(file);
});}
@@ -445,7 +502,7 @@ function getSelectedFiles(property){
var files=[];
elements.each(function(i,element){
var file={
- name:$(element).data('file'),
+ name:$(element).attr('data-file'),
mime:$(element).data('mime'),
type:$(element).data('type'),
size:$(element).data('size'),
diff --git a/files/templates/index.php b/files/templates/index.php
index a63f6e62b63..c4acab25cc4 100644
--- a/files/templates/index.php
+++ b/files/templates/index.php
@@ -1,35 +1,37 @@
<div id="controls">
<?php echo($_['breadcrumb']); ?>
- <?php if (!isset($_['readonly']) || !$_['readonly']) {?>
- <div class="actions">
- <form data-upload-id='1' class="file_upload_form" action="ajax/upload.php" method="post" enctype="multipart/form-data" target="file_upload_target_1">
- <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $_['uploadMaxFilesize'] ?>" id="max_upload">
- <input type="hidden" class="max_human_file_size" value="(max <?php echo $_['uploadMaxHumanFilesize']; ?>)">
- <input type="hidden" name="dir" value="<?php echo $_['dir'] ?>" id="dir">
+ <?php if (!isset($_['readonly']) || !$_['readonly']):?>
+ <div class="actions">
+ <div id='new' class='button'>
+ <a>
+ <?php echo $l->t('New');?>
+ </a>
+ <ul class="popup popupTop">
+ <li style="background-image:url('<?php echo mimetype_icon('text/plain') ?>')" data-type='file'><p><?php echo $l->t('Text file');?></p></li>
+ <li style="background-image:url('<?php echo mimetype_icon('dir') ?>')" data-type='folder'><p><?php echo $l->t('Folder');?></p></li>
+ <!-- <li style="background-image:url('<?php echo mimetype_icon('dir') ?>')" data-type='web'><p><?php echo $l->t('From the web');?></p></li> -->
+ </ul>
+ </div>
<div class="file_upload_wrapper svg">
- <input type="submit" class="file_upload_filename" value="<?php echo $l->t('Upload'); ?>"/>
- <input class="file_upload_start" type="file" name='files[]'/>
- <a href="#" class="file_upload_button_wrapper" onclick="return false;" title="<?php echo 'max. '.$_['uploadMaxHumanFilesize'] ?>"></a>
+ <form data-upload-id='1' class="file_upload_form" action="ajax/upload.php" method="post" enctype="multipart/form-data" target="file_upload_target_1">
+ <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $_['uploadMaxFilesize'] ?>" id="max_upload">
+ <input type="hidden" class="max_human_file_size" value="(max <?php echo $_['uploadMaxHumanFilesize']; ?>)">
+ <input type="hidden" name="dir" value="<?php echo $_['dir'] ?>" id="dir">
+ <button class="file_upload_filename"><img class='svg action' alt="Upload" src="<?php echo image_path("core", "actions/upload.svg"); ?>" /></button>
+ <input class="file_upload_start" type="file" name='files[]'/>
+ <a href="#" class="file_upload_button_wrapper" onclick="return false;" title="<?php echo $l->t('Upload'); echo ' max. '.$_['uploadMaxHumanFilesize'] ?>"></a>
+ <iframe name="file_upload_target_1" class='file_upload_target' src=""></iframe>
+ </form>
</div>
- <iframe name="file_upload_target_1" class='file_upload_target' src=""></iframe>
- </form>
- <form id="file_newfolder_form">
- <input class="svg" type="text" name="file_newfolder_name" id="file_newfolder_name" value="" placeholder="<?php echo $l->t('New Folder')?>" />
- </form>
- </div>
- <div id="file_action_panel">
- </div>
+ </div>
+ <div id="file_action_panel"></div>
+ <?php endif;?>
</div>
-<?php
-}
-?>
<div id='notification'></div>
-<?php
-if (isset($_['files'])) {
- if (!count($_['files'])) { ?>
-<div id="emptyfolder"><?php echo $l->t('Nothing in here. Upload something!')?></div>
-<?php }}?>
+<?php if (isset($_['files']) and ! $_['readonly'] and count($_['files'])==0):?>
+ <div id="emptyfolder"><?php echo $l->t('Nothing in here. Upload something!')?></div>
+<?php endif; ?>
<table>
<thead>
@@ -46,7 +48,7 @@ if (isset($_['files'])) {
<th id="headerDate"><span id="modified"><?php echo $l->t( 'Modified' ); ?></span><span class="selectedActions"><a href="" title="Delete" class="delete"><img class="svg" alt="<?php echo $l->t('Delete')?>" src="<?php echo image_path("core", "actions/delete.svg"); ?>" /></a></span></th>
</tr>
</thead>
- <tbody id="fileList">
+ <tbody id="fileList" data-readonly="<?php echo $_['readonly'];?>">
<?php echo($_['fileList']); ?>
</tbody>
</table>
diff --git a/files/templates/part.list.php b/files/templates/part.list.php
index 6bf5efe2fb2..46830ba3a37 100644
--- a/files/templates/part.list.php
+++ b/files/templates/part.list.php
@@ -5,7 +5,7 @@
$relative_modified_date = relative_modified_date($file['mtime']);
$relative_date_color = round((time()-$file['mtime'])/60/60/24*14); // the older the file, the brighter the shade of grey; days*14
if($relative_date_color>200) $relative_date_color = 200; ?>
- <tr data-file="<?php echo $file['name'];?>" data-type="<?php echo ($file['type'] == 'dir')?'dir':'file'?>" data-mime="<?php echo $file['mime']?>" data-size='<?php echo $file['size'];?>'>
+ <tr data-file="<?php echo str_replace('+','%20',urlencode($file['name']));?>" data-type="<?php echo ($file['type'] == 'dir')?'dir':'file'?>" data-mime="<?php echo $file['mime']?>" data-size='<?php echo $file['size'];?>'>
<td class="filename svg" style="background-image:url(<?php if($file['type'] == 'dir') echo mimetype_icon('dir'); else echo mimetype_icon($file['mime']); ?>)">
<?php if(!isset($_['readonly']) || !$_['readonly']) { ?><input type="checkbox" /><?php } ?>
<a class="name" href="<?php if($file['type'] == 'dir') echo $_['baseURL'].$file['directory'].'/'.$file['name']; else echo $_['downloadURL'].urlencode($file['directory']).'/'.urlencode($file['name']); ?>" title="">
diff --git a/index.php b/index.php
index 558733e1cda..2d759d68d7d 100644
--- a/index.php
+++ b/index.php
@@ -88,7 +88,7 @@ else {
if(defined("DEBUG") && DEBUG) {
OC_Log::write('core','Setting remember login to cookie',OC_Log::DEBUG);
}
- $token = md5($_POST["user"].time());
+ $token = md5($_POST["user"].time().$_POST['password']);
OC_Preferences::setValue($_POST['user'], 'login', 'token', $token);
OC_User::setMagicInCookie($_POST["user"], $token);
}
diff --git a/l10n/templates/calendar.pot b/l10n/templates/calendar.pot
index 66cc90a4bfd..56fce2285ec 100644
--- a/l10n/templates/calendar.pot
+++ b/l10n/templates/calendar.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-09-24 23:05+0200\n"
+"POT-Creation-Date: 2011-10-22 13:05+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -17,318 +17,180 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
-#: ajax/createcalendar.php:18 ajax/settimezone.php:19
-#: ajax/updatecalendar.php:18
-msgid "Authentication error"
-msgstr ""
-
-#: ajax/editeventform.php:25
+#: ajax/editeventform.php:26
msgid "Wrong calendar"
msgstr ""
-#: ajax/settimezone.php:27
+#: ajax/settimezone.php:22
msgid "Timezone changed"
msgstr ""
-#: ajax/settimezone.php:29
+#: ajax/settimezone.php:24
msgid "Invalid request"
msgstr ""
-#: appinfo/app.php:19 templates/part.eventform.php:27
-#: templates/part.eventinfo.php:18
+#: appinfo/app.php:21 templates/calendar.php:11
+#: templates/part.eventform.php:21
msgid "Calendar"
msgstr ""
-#: lib/object.php:292
+#: js/calendar.js:153
+msgid "ddd d MMMM[ yyyy]{ -[ddd d] MMMM yyyy}"
+msgstr ""
+
+#: js/calendar.js:155
+msgid "ddd d MMMM[ yyyy] HH:mm{ -[ ddd d MMMM yyyy] HH:mm}"
+msgstr ""
+
+#: lib/object.php:344
msgid "Birthday"
msgstr ""
-#: lib/object.php:293
+#: lib/object.php:345
msgid "Business"
msgstr ""
-#: lib/object.php:294
+#: lib/object.php:346
msgid "Call"
msgstr ""
-#: lib/object.php:295
+#: lib/object.php:347
msgid "Clients"
msgstr ""
-#: lib/object.php:296
+#: lib/object.php:348
msgid "Deliverer"
msgstr ""
-#: lib/object.php:297
+#: lib/object.php:349
msgid "Holidays"
msgstr ""
-#: lib/object.php:298
+#: lib/object.php:350
msgid "Ideas"
msgstr ""
-#: lib/object.php:299
+#: lib/object.php:351
msgid "Journey"
msgstr ""
-#: lib/object.php:300
+#: lib/object.php:352
msgid "Jubilee"
msgstr ""
-#: lib/object.php:301
+#: lib/object.php:353
msgid "Meeting"
msgstr ""
-#: lib/object.php:302
+#: lib/object.php:354
msgid "Other"
msgstr ""
-#: lib/object.php:303
+#: lib/object.php:355
msgid "Personal"
msgstr ""
-#: lib/object.php:304
+#: lib/object.php:356
msgid "Projects"
msgstr ""
-#: lib/object.php:305
+#: lib/object.php:357
msgid "Questions"
msgstr ""
-#: lib/object.php:306
+#: lib/object.php:358
msgid "Work"
msgstr ""
-#: lib/object.php:313
+#: lib/object.php:365
msgid "Does not repeat"
msgstr ""
-#: lib/object.php:314
+#: lib/object.php:366
msgid "Daily"
msgstr ""
-#: lib/object.php:315
+#: lib/object.php:367
msgid "Weekly"
msgstr ""
-#: lib/object.php:316
+#: lib/object.php:368
msgid "Every Weekday"
msgstr ""
-#: lib/object.php:317
+#: lib/object.php:369
msgid "Bi-Weekly"
msgstr ""
-#: lib/object.php:318
+#: lib/object.php:370
msgid "Monthly"
msgstr ""
-#: lib/object.php:319
+#: lib/object.php:371
msgid "Yearly"
msgstr ""
-#: lib/object.php:337
+#: lib/object.php:389
msgid "Not an array"
msgstr ""
-#: templates/calendar.php:3
+#: templates/calendar.php:8
msgid "All day"
msgstr ""
-#: templates/calendar.php:32
-msgid "Sunday"
-msgstr ""
-
-#: templates/calendar.php:32
-msgid "Monday"
-msgstr ""
-
-#: templates/calendar.php:32
-msgid "Tuesday"
-msgstr ""
-
-#: templates/calendar.php:32
-msgid "Wednesday"
-msgstr ""
-
-#: templates/calendar.php:32
-msgid "Thursday"
-msgstr ""
-
-#: templates/calendar.php:32
-msgid "Friday"
-msgstr ""
-
-#: templates/calendar.php:32
-msgid "Saturday"
-msgstr ""
-
-#: templates/calendar.php:33
-msgid "Sun."
-msgstr ""
-
-#: templates/calendar.php:33
-msgid "Mon."
-msgstr ""
-
-#: templates/calendar.php:33
-msgid "Tue."
-msgstr ""
-
-#: templates/calendar.php:33
-msgid "Wed."
-msgstr ""
-
-#: templates/calendar.php:33
-msgid "Thu."
-msgstr ""
-
-#: templates/calendar.php:33
-msgid "Fri."
-msgstr ""
-
-#: templates/calendar.php:33
-msgid "Sat."
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "January"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "February"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "March"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "April"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "May"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "June"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "July"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "August"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "September"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "October"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "November"
-msgstr ""
-
-#: templates/calendar.php:34
-msgid "December"
-msgstr ""
-
-#: templates/calendar.php:35
-msgid "Jan."
-msgstr ""
-
-#: templates/calendar.php:35
-msgid "Feb."
-msgstr ""
-
-#: templates/calendar.php:35
-msgid "Mar."
-msgstr ""
-
-#: templates/calendar.php:35
-msgid "Apr."
-msgstr ""
-
-#: templates/calendar.php:35
-msgid "May."
+#: templates/calendar.php:9
+msgid "Missing fields"
msgstr ""
-#: templates/calendar.php:35
-msgid "Jun."
+#: templates/calendar.php:10 templates/part.eventform.php:3
+msgid "Title"
msgstr ""
-#: templates/calendar.php:35
-msgid "Jul."
+#: templates/calendar.php:12
+msgid "From Date"
msgstr ""
-#: templates/calendar.php:35
-msgid "Aug."
+#: templates/calendar.php:13
+msgid "From Time"
msgstr ""
-#: templates/calendar.php:35
-msgid "Sep."
+#: templates/calendar.php:14
+msgid "To Date"
msgstr ""
-#: templates/calendar.php:35
-msgid "Oct."
+#: templates/calendar.php:15
+msgid "To Time"
msgstr ""
-#: templates/calendar.php:35
-msgid "Nov."
+#: templates/calendar.php:16
+msgid "The event ends before it starts"
msgstr ""
-#: templates/calendar.php:35
-msgid "Dec."
+#: templates/calendar.php:17
+msgid "There was a database fail"
msgstr ""
-#: templates/calendar.php:36 templates/calendar.php:50
-#: templates/calendar.php:116
+#: templates/calendar.php:23
msgid "Week"
msgstr ""
-#: templates/calendar.php:37 templates/calendar.php:51
-msgid "Weeks"
-msgstr ""
-
-#: templates/calendar.php:38
-msgid "More before {startdate}"
-msgstr ""
-
-#: templates/calendar.php:39
-msgid "More after {enddate}"
-msgstr ""
-
-#: templates/calendar.php:49
-msgid "Day"
-msgstr ""
-
-#: templates/calendar.php:52
+#: templates/calendar.php:24
msgid "Month"
msgstr ""
-#: templates/calendar.php:53
+#: templates/calendar.php:25
msgid "List"
msgstr ""
-#: templates/calendar.php:58
+#: templates/calendar.php:30
msgid "Today"
msgstr ""
-#: templates/calendar.php:59
+#: templates/calendar.php:31
msgid "Calendars"
msgstr ""
-#: templates/calendar.php:76 templates/calendar.php:94
-msgid "Time"
-msgstr ""
-
-#: templates/calendar.php:169
+#: templates/calendar.php:48
msgid "There was a fail, while parsing the file."
msgstr ""
@@ -350,7 +212,6 @@ msgid "Download"
msgstr ""
#: templates/part.choosecalendar.rowfields.php:4
-#: templates/part.eventinfo.php:64
msgid "Edit"
msgstr ""
@@ -367,7 +228,7 @@ msgstr ""
msgid "Edit calendar"
msgstr ""
-#: templates/part.editcalendar.php:12
+#: templates/part.editcalendar.php:12 templates/part.import.php:29
msgid "Displayname"
msgstr ""
@@ -375,88 +236,135 @@ msgstr ""
msgid "Active"
msgstr ""
-#: templates/part.editcalendar.php:29 templates/part.eventform.php:88
-#: templates/part.eventinfo.php:58
-msgid "Description"
-msgstr ""
-
-#: templates/part.editcalendar.php:35
+#: templates/part.editcalendar.php:29
msgid "Calendar color"
msgstr ""
-#: templates/part.editcalendar.php:41
+#: templates/part.editcalendar.php:42
msgid "Save"
msgstr ""
-#: templates/part.editcalendar.php:41 templates/part.editevent.php:7
+#: templates/part.editcalendar.php:42 templates/part.editevent.php:7
#: templates/part.newevent.php:6
msgid "Submit"
msgstr ""
-#: templates/part.editcalendar.php:42
+#: templates/part.editcalendar.php:43
msgid "Cancel"
msgstr ""
-#: templates/part.editevent.php:1 templates/part.eventinfo.php:1
+#: templates/part.editevent.php:1
msgid "Edit an event"
msgstr ""
-#: templates/part.eventform.php:3 templates/part.eventinfo.php:4
-msgid "Title"
+#: templates/part.editevent.php:9
+msgid "Export"
msgstr ""
#: templates/part.eventform.php:5
msgid "Title of the Event"
msgstr ""
-#: templates/part.eventform.php:9 templates/part.eventinfo.php:9
-msgid "Location"
-msgstr ""
-
#: templates/part.eventform.php:11
-msgid "Location of the Event"
-msgstr ""
-
-#: templates/part.eventform.php:17 templates/part.eventinfo.php:16
msgid "Category"
msgstr ""
-#: templates/part.eventform.php:19
+#: templates/part.eventform.php:13
msgid "Select category"
msgstr ""
-#: templates/part.eventform.php:45 templates/part.eventinfo.php:28
+#: templates/part.eventform.php:39
msgid "All Day Event"
msgstr ""
-#: templates/part.eventform.php:49 templates/part.eventinfo.php:31
+#: templates/part.eventform.php:43
msgid "From"
msgstr ""
-#: templates/part.eventform.php:57 templates/part.eventinfo.php:38
+#: templates/part.eventform.php:51
msgid "To"
msgstr ""
-#: templates/part.eventform.php:65 templates/part.eventinfo.php:44
+#: templates/part.eventform.php:59
+msgid "Advanced options"
+msgstr ""
+
+#: templates/part.eventform.php:64
msgid "Repeat"
msgstr ""
-#: templates/part.eventform.php:81 templates/part.eventinfo.php:51
+#: templates/part.eventform.php:80
msgid "Attendees"
msgstr ""
+#: templates/part.eventform.php:87
+msgid "Location"
+msgstr ""
+
#: templates/part.eventform.php:89
+msgid "Location of the Event"
+msgstr ""
+
+#: templates/part.eventform.php:95
+msgid "Description"
+msgstr ""
+
+#: templates/part.eventform.php:96
msgid "Description of the Event"
msgstr ""
-#: templates/part.eventinfo.php:63
-msgid "Close"
+#: templates/part.import.php:1
+msgid "Import Ical File"
+msgstr ""
+
+#: templates/part.import.php:4
+msgid "How to import the new calendar?"
+msgstr ""
+
+#: templates/part.import.php:6
+msgid "Import into an existing calendar"
+msgstr ""
+
+#: templates/part.import.php:7
+msgid "Import into a new calendar"
+msgstr ""
+
+#: templates/part.import.php:10
+msgid "Please choose the calendar"
+msgstr ""
+
+#: templates/part.import.php:20 templates/part.import.php:37
+msgid "Import"
+msgstr ""
+
+#: templates/part.import.php:22 templates/part.import.php:39
+msgid "Back"
+msgstr ""
+
+#: templates/part.import.php:25
+msgid "Please fill out the form"
msgstr ""
#: templates/part.newevent.php:1
msgid "Create a new event"
msgstr ""
-#: templates/settings.php:11
+#: templates/settings.php:13
msgid "Timezone"
msgstr ""
+
+#: templates/settings.php:32
+msgid "Timeformat"
+msgstr ""
+
+#: templates/settings.php:34
+msgid "24h"
+msgstr ""
+
+#: templates/settings.php:35
+msgid "12h"
+msgstr ""
+
+#: templates/settings.php:41
+msgid "Calendar CalDAV syncing address:"
+msgstr ""
diff --git a/lib/app.php b/lib/app.php
index 30ebcf032b3..b1aa8ba354d 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -100,11 +100,11 @@ class OC_App{
}
/**
- * @brief enables an app
+ * @brief disables an app
* @param $app app
* @returns true/false
*
- * This function set an app as enabled in appconfig.
+ * This function set an app as disabled in appconfig.
*/
public static function disable( $app ){
OC_Appconfig::setValue( $app, 'enabled', 'no' );
@@ -223,7 +223,7 @@ class OC_App{
// admin apps menu
$settings[] = array( "id" => "core_apps", "order" => 3, "href" => OC_Helper::linkTo( "settings", "apps.php?installed" ), "name" => $l->t("Apps"), "icon" => OC_Helper::imagePath( "settings", "apps.svg" ));
// admin log menu
- $settings[] = array( "id" => "core_log", "order" => 4, "href" => OC_Helper::linkTo( "settings", "log.php" ), "name" => $l->t("Log"), "icon" => OC_Helper::imagePath( "log", "apps.svg" ));
+ $settings[] = array( "id" => "core_log", "order" => 4, "href" => OC_Helper::linkTo( "settings", "log.php" ), "name" => $l->t("Log"), "icon" => OC_Helper::imagePath( "settings", "log.svg" ));
$settings[]=array( "id" => "admin", "order" => 1000, "href" => OC_Helper::linkTo( "settings", "admin.php" ), "name" => $l->t("Admin"), "icon" => OC_Helper::imagePath( "settings", "admin.svg" ));
}
diff --git a/lib/base.php b/lib/base.php
index d5fff1e0a74..700236c96c6 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -77,6 +77,9 @@ class OC{
// set some stuff
//ob_start();
error_reporting(E_ALL | E_STRICT);
+ if (defined('DEBUG') && DEBUG){
+ ini_set('display_errors', 1);
+ }
date_default_timezone_set('Europe/Berlin');
ini_set('arg_separator.output','&amp;');
@@ -89,6 +92,14 @@ class OC{
$_SERVER['PHP_AUTH_PW'] = strip_tags($password);
}
+ //set http auth headers for apache+php-cgi work around if variable gets renamed by apache
+ if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && preg_match('/Basic\s+(.*)$/i', $_SERVER['REDIRECT_HTTP_AUTHORIZATION'], $matches))
+ {
+ list($name, $password) = explode(':', base64_decode($matches[1]));
+ $_SERVER['PHP_AUTH_USER'] = strip_tags($name);
+ $_SERVER['PHP_AUTH_PW'] = strip_tags($password);
+ }
+
// calculate the documentroot
OC::$DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']);
OC::$SERVERROOT=str_replace("\\",'/',substr(__FILE__,0,-13));
diff --git a/lib/config.php b/lib/config.php
index 2c82036257f..8d03271b3ea 100644
--- a/lib/config.php
+++ b/lib/config.php
@@ -94,7 +94,6 @@ class OC_Config{
// Write changes
self::writeData();
-
return true;
}
diff --git a/lib/connector/sabre/file.php b/lib/connector/sabre/file.php
index b049f39c171..98661dbb184 100644
--- a/lib/connector/sabre/file.php
+++ b/lib/connector/sabre/file.php
@@ -29,7 +29,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
*/
public function get() {
- return OC_Filesystem::file_get_contents($this->path);
+ return OC_Filesystem::fopen($this->path,'r');
}
diff --git a/lib/db.php b/lib/db.php
index 421b08c2320..bcfe320665f 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -224,6 +224,7 @@ class OC_DB {
/**
* @brief gets last value of autoincrement
+ * @param $table string The optional table name (will replace *PREFIX*) and add sequence suffix
* @returns id
*
* MDB2 lastInsertID()
@@ -231,9 +232,14 @@ class OC_DB {
* Call this method right after the insert command or other functions may
* cause trouble!
*/
- public static function insertid(){
+ public static function insertid($table=null){
self::connect();
- return self::$connection->lastInsertId();
+ if($table !== null){
+ $prefix = OC_Config::getValue( "dbtableprefix", "oc_" );
+ $suffix = OC_Config::getValue( "dbsequencesuffix", "_id_seq" );
+ $table = str_replace( '*PREFIX*', $prefix, $table );
+ }
+ return self::$connection->lastInsertId($table.$suffix);
}
/**
@@ -486,7 +492,7 @@ class PDOStatementWrapper{
}
/**
- * make exucute return the result instead of a bool
+ * make execute return the result instead of a bool
*/
public function execute($input=array()){
$this->lastArguments=$input;
diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php
index 01523b6b0b3..9e29f85071a 100644
--- a/lib/filestorage/local.php
+++ b/lib/filestorage/local.php
@@ -84,6 +84,11 @@ class OC_Filestorage_Local extends OC_Filestorage{
return $return;
}
public function rename($path1,$path2){
+ if(! $this->file_exists($path1)){
+ OC_Log::write('core','unable to rename, file does not exists : '.$path1,OC_Log::ERROR);
+ return false;
+ }
+
if($return=rename($this->datadir.$path1,$this->datadir.$path2)){
$this->clearFolderSizeCache($path1);
$this->clearFolderSizeCache($path2);
diff --git a/lib/helper.php b/lib/helper.php
index 5b3e394cafd..24d436225b7 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -160,24 +160,25 @@ class OC_Helper {
*/
public static function computerFileSize( $str ){
$bytes = 0;
+ $str=strtolower($str);
$bytes_array = array(
- 'B' => 1,
- 'K' => 1024,
- 'KB' => 1024,
- 'MB' => 1024 * 1024,
- 'M' => 1024 * 1024,
- 'GB' => 1024 * 1024 * 1024,
- 'G' => 1024 * 1024 * 1024,
- 'TB' => 1024 * 1024 * 1024 * 1024,
- 'T' => 1024 * 1024 * 1024 * 1024,
- 'PB' => 1024 * 1024 * 1024 * 1024 * 1024,
- 'P' => 1024 * 1024 * 1024 * 1024 * 1024,
+ 'b' => 1,
+ 'k' => 1024,
+ 'kb' => 1024,
+ 'mb' => 1024 * 1024,
+ 'm' => 1024 * 1024,
+ 'gb' => 1024 * 1024 * 1024,
+ 'g' => 1024 * 1024 * 1024,
+ 'tb' => 1024 * 1024 * 1024 * 1024,
+ 't' => 1024 * 1024 * 1024 * 1024,
+ 'pb' => 1024 * 1024 * 1024 * 1024 * 1024,
+ 'p' => 1024 * 1024 * 1024 * 1024 * 1024,
);
$bytes = floatval($str);
- if (preg_match('#([KMGTP]?B?)$#si', $str, $matches) && !empty($bytes_array[$matches[1]])) {
+ if (preg_match('#([kmgtp]?b?)$#si', $str, $matches) && !empty($bytes_array[$matches[1]])) {
$bytes *= $bytes_array[$matches[1]];
}
diff --git a/lib/hook.php b/lib/hook.php
index b069a7da6c0..83a16106bf0 100644
--- a/lib/hook.php
+++ b/lib/hook.php
@@ -20,7 +20,7 @@ class OC_Hook{
* TODO: write example
*/
static public function connect( $signalclass, $signalname, $slotclass, $slotname ){
- // Cerate the data structure
+ // Create the data structure
if( !array_key_exists( $signalclass, self::$registered )){
self::$registered[$signalclass] = array();
}
diff --git a/lib/l10n.php b/lib/l10n.php
index 54331d44ae4..a5544eb3a27 100644
--- a/lib/l10n.php
+++ b/lib/l10n.php
@@ -110,6 +110,22 @@ class OC_L10N{
}
/**
+ * @brief Translating
+ * @param $textArray The text array we need a translation for
+ * @returns Translation or the same text
+ *
+ * Returns the translation. If no translation is found, $textArray will be
+ * returned.
+ */
+ public function tA($textArray){
+ $result = array();
+ foreach($textArray as $key => $text){
+ $result[$key] = $this->t($text);
+ }
+ return $result;
+ }
+
+ /**
* @brief getTranslations
* @returns Fetch all translations
*
diff --git a/lib/log.php b/lib/log.php
index 98333be54fe..446ddd48848 100644
--- a/lib/log.php
+++ b/lib/log.php
@@ -59,6 +59,9 @@ class OC_Log{
return array();
}
$fh=fopen($logFile,'r');
+ if($fh === false){ // Unable to read log file!
+ return array();
+ }
while(!feof($fh)){
$line=fgets($fh);
if($line){
diff --git a/lib/ocsclient.php b/lib/ocsclient.php
index 654c5e0527b..072fd236fee 100644
--- a/lib/ocsclient.php
+++ b/lib/ocsclient.php
@@ -108,6 +108,7 @@ class OC_OCSClient{
$xml=@file_get_contents($url);
if($xml==FALSE){
+ OC_Log::write('core','Unable to parse OCS content',OC_Log::FATAL);
return NULL;
}
$data=simplexml_load_string($xml);
@@ -143,6 +144,7 @@ class OC_OCSClient{
$kbe=array();
$xml=@file_get_contents($url);
if($xml==FALSE){
+ OC_Log::write('core','Unable to parse knowledgebase content',OC_Log::FATAL);
return NULL;
}
$data=simplexml_load_string($xml);
diff --git a/lib/setup.php b/lib/setup.php
index 2dcedb9b820..8afe0070e9b 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -77,12 +77,14 @@ class OC_Setup {
OC_Config::setValue('datadirectory', $datadir);
OC_Config::setValue('dbtype', $dbtype);
OC_Config::setValue('version',implode('.',OC_Util::getVersion()));
+ OC_Config::setValue('installedat',microtime(true));
+ OC_Config::setValue('lastupdatedat',microtime(true));
if($dbtype == 'mysql') {
$dbuser = $options['dbuser'];
$dbpass = $options['dbpass'];
$dbname = $options['dbname'];
$dbhost = $options['dbhost'];
- $dbtableprefix = OC_Config::getValue('dbtableprefix','oc_');
+ $dbtableprefix = $options['dbtableprefix'];
OC_Config::setValue('dbname', $dbname);
OC_Config::setValue('dbhost', $dbhost);
OC_Config::setValue('dbtableprefix', $dbtableprefix);
@@ -135,7 +137,7 @@ class OC_Setup {
$dbpass = $options['dbpass'];
$dbname = $options['dbname'];
$dbhost = $options['dbhost'];
- $dbtableprefix = OC_Config::getValue('dbtableprefix','oc_');
+ $dbtableprefix = $options['dbtableprefix'];
OC_CONFIG::setValue('dbname', $dbname);
OC_CONFIG::setValue('dbhost', $dbhost);
OC_CONFIG::setValue('dbtableprefix', $dbtableprefix);
diff --git a/lib/template.php b/lib/template.php
index 440b62003e7..881d2a27b1e 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -98,6 +98,33 @@ function relative_modified_date($timestamp) {
else { return $l->t('years ago'); }
}
+function html_select_options($options, $selected, $params=array()) {
+ if (!is_array($selected)){
+ $selected=array($selected);
+ }
+ if (isset($params['combine']) && $params['combine']){
+ $options = array_combine($options, $options);
+ }
+ $value_name = $label_name = false;
+ if (isset($params['value'])){
+ $value_name = $params['value'];
+ }
+ if (isset($params['label'])){
+ $label_name = $params['label'];
+ }
+ $html = '';
+ foreach($options as $value => $label){
+ if ($value_name && is_array($label)){
+ $value = $label[$value_name];
+ }
+ if ($label_name && is_array($label)){
+ $label = $label[$label_name];
+ }
+ $select = in_array($value, $selected) ? ' selected="selected"' : '';
+ $html .= '<option value="' . $value . '"' . $select . '>' . $label . '</option>'."\n";
+ }
+ return $html;
+}
/**
* This class provides the templates for owncloud.
diff --git a/lib/updater.php b/lib/updater.php
new file mode 100644
index 00000000000..cc4a4602539
--- /dev/null
+++ b/lib/updater.php
@@ -0,0 +1,81 @@
+<?php
+/**
+ * ownCloud
+ *
+ * @author Frank Karlitschek
+ * @copyright 2010 Frank Karlitschek karlitschek@kde.org
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library 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 this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/**
+ * Class that handels autoupdating of ownCloud
+ */
+class OC_Updater{
+
+ /**
+ * Check if a new version is available
+ */
+ public static function check(){
+ OC_Config::setValue('lastupdatedat',microtime(true));
+
+ $updaterurl='http://apps.owncloud.com/updater.php';
+ $version=OC_Util::getVersion();
+ $version['installed']=OC_Config::getValue( "installedat");
+ $version['updated']=OC_Config::getValue( "lastupdatedat");
+ $version['updatechannel']='stable';
+ $versionstring=implode('x',$version);
+
+ //fetch xml data from updater
+ $url=$updaterurl.'?version='.$versionstring;
+ $xml=@file_get_contents($url);
+ if($xml==FALSE){
+ return array();
+ }
+ $data=@simplexml_load_string($xml);
+
+ $tmp=array();
+ $tmp['version'] = $data->version;
+ $tmp['versionstring'] = $data->versionstring;
+ $tmp['url'] = $data->url;
+ $tmp['web'] = $data->web;
+
+ return $tmp;
+ }
+
+ public static function ShowUpdatingHint(){
+ $data=OC_Updater::check();
+ if(isset($data['version']) and $data['version']<>'') {
+ $txt='<span style="color:#AA0000; font-weight:bold;">'.$data['versionstring'].' is available. Please click <a href="'.$data['web'].'">here</a> for more information</span>';
+ }else{
+ $txt='Your ownCloud is up to date';
+ }
+ return($txt);
+ }
+
+ /**
+ * do ownCloud update
+ */
+ public static function doUpdate(){
+
+ //update ownCloud core
+
+ //update all apps
+
+ //update version in config
+
+ }
+}
+?>
diff --git a/lib/util.php b/lib/util.php
index 14313569a1d..0f79948bc24 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -180,7 +180,6 @@ class OC_Util {
}
$CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
$CONFIG_DBNAME = OC_Config::getValue( "dbname", "owncloud" );
- $serverUser=OC_Util::checkWebserverUser();
//common hint for all file permissons error messages
$permissionsHint="Permissions can usually be fixed by giving the webserver write access to the ownCloud directory";
@@ -239,21 +238,6 @@ class OC_Util {
OC_Template::printGuestPage("", "login", $parameters);
}
- /**
- * Try to get the username the httpd server runs on, used in hints
- */
- public static function checkWebserverUser(){
- if(is_callable('posix_getuid')){
- $serverUser=posix_getpwuid(posix_getuid());
- $serverUser='\''.$serverUser['name'].'\'';
- }elseif(exec('whoami')){
- $serverUser=exec('whoami');
- }else{
- $serverUser='\'www-data\' for ubuntu/debian'; //TODO: try to detect the distro and give a guess based on that
- }
- return $serverUser;
- }
-
/**
* Check if the app is enabled, send json error msg if not
diff --git a/lib/vobject.php b/lib/vobject.php
new file mode 100644
index 00000000000..e3479fc6d36
--- /dev/null
+++ b/lib/vobject.php
@@ -0,0 +1,207 @@
+<?php
+/**
+ * ownCloud
+ *
+ * @author Bart Visscher
+ * @copyright 2011 Bart Visscher bartv@thisnet.nl
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library 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 this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/**
+ * This class provides a streamlined interface to the Sabre VObject classes
+ */
+class OC_VObject{
+ /** @var Sabre_VObject_Component */
+ protected $vobject;
+
+ /**
+ * @returns Sabre_VObject_Component
+ */
+ public function getVObject(){
+ return $this->vobject;
+ }
+
+ /**
+ * @brief Parses the VObject
+ * @param string VObject as string
+ * @returns Sabre_VObject or null
+ */
+ public static function parse($data){
+ try {
+ Sabre_VObject_Reader::$elementMap['LAST-MODIFIED'] = 'Sabre_VObject_Element_DateTime';
+ $vobject = Sabre_VObject_Reader::read($data);
+ if ($vobject instanceof Sabre_VObject_Component){
+ $vobject = new OC_VObject($vobject);
+ }
+ return $vobject;
+ } catch (Exception $e) {
+ OC_Log::write('vobject', $e->getMessage(), OC_Log::ERROR);
+ return null;
+ }
+ }
+
+ /**
+ * @brief Escapes semicolons
+ * @param string $value
+ * @return string
+ */
+ public static function escapeSemicolons($value){
+ foreach($value as &$i ){
+ $i = implode("\\\\;", explode(';', $i));
+ }
+ return implode(';',$value);
+ }
+
+ /**
+ * @brief Creates an array out of a multivalue property
+ * @param string $value
+ * @return array
+ */
+ public static function unescapeSemicolons($value){
+ $array = explode(';',$value);
+ for($i=0;$i<count($array);$i++){
+ if(substr($array[$i],-2,2)=="\\\\"){
+ if(isset($array[$i+1])){
+ $array[$i] = substr($array[$i],0,count($array[$i])-2).';'.$array[$i+1];
+ unset($array[$i+1]);
+ }
+ else{
+ $array[$i] = substr($array[$i],0,count($array[$i])-2).';';
+ }
+ $i = $i - 1;
+ }
+ }
+ return $array;
+ }
+
+ /**
+ * Constuctor
+ * @param Sabre_VObject_Component or string
+ */
+ public function __construct($vobject_or_name){
+ if (is_object($vobject_or_name)){
+ $this->vobject = $vobject_or_name;
+ } else {
+ $this->vobject = new Sabre_VObject_Component($vobject_or_name);
+ }
+ }
+
+ public function add($item, $itemValue = null){
+ if ($item instanceof OC_VObject){
+ $item = $item->getVObject();
+ }
+ $this->vobject->add($item, $itemValue);
+ }
+
+ /**
+ * @brief Add property to vobject
+ * @param object $name of property
+ * @param object $value of property
+ * @param object $parameters of property
+ * @returns Sabre_VObject_Property newly created
+ */
+ public function addProperty($name, $value, $parameters=array()){
+ if(is_array($value)){
+ $value = OC_VObject::escapeSemicolons($value);
+ }
+ $property = new Sabre_VObject_Property( $name, $value );
+ foreach($parameters as $name => $value){
+ $property->parameters[] = new Sabre_VObject_Parameter($name, $value);
+ }
+
+ $this->vobject->add($property);
+ return $property;
+ }
+
+ public function setUID(){
+ $uid = substr(md5(rand().time()),0,10);
+ $this->vobject->add('UID',$uid);
+ }
+
+ public function setString($name, $string){
+ if ($string != ''){
+ $string = strtr($string, array("\r\n"=>"\n"));
+ $this->vobject->__set($name, $string);
+ }else{
+ $this->vobject->__unset($name);
+ }
+ }
+
+ /**
+ * Sets or unsets the Date and Time for a property.
+ * When $datetime is set to 'now', use the current time
+ * When $datetime is null, unset the property
+ *
+ * @param string property name
+ * @param DateTime $datetime
+ * @param int $dateType
+ * @return void
+ */
+ public function setDateTime($name, $datetime, $dateType=Sabre_VObject_Element_DateTime::LOCALTZ){
+ if ($datetime == 'now'){
+ $datetime = new DateTime();
+ }
+ if ($datetime instanceof DateTime){
+ $datetime_element = new Sabre_VObject_Element_DateTime($name);
+ $datetime_element->setDateTime($datetime, $dateType);
+ $this->vobject->__set($name, $datetime_element);
+ }else{
+ $this->vobject->__unset($name);
+ }
+ }
+
+ public function getAsString($name){
+ return $this->vobject->__isset($name) ?
+ $this->vobject->__get($name)->value :
+ '';
+ }
+
+ public function getAsArray($name){
+ $values = array();
+ if ($this->vobject->__isset($name)){
+ $values = explode(',', $this->getAsString($name));
+ $values = array_map('trim', $values);
+ }
+ return $values;
+ }
+
+ public function &__get($name){
+ if ($name == 'children'){
+ return $this->vobject->children;
+ }
+ $return = $this->vobject->__get($name);
+ if ($return instanceof Sabre_VObject_Component){
+ $return = new OC_VObject($return);
+ }
+ return $return;
+ }
+
+ public function __set($name, $value){
+ return $this->vobject->__set($name, $value);
+ }
+
+ public function __unset($name){
+ return $this->vobject->__unset($name);
+ }
+
+ public function __isset($name){
+ return $this->vobject->__isset($name);
+ }
+
+ public function __call($function,$arguments){
+ return call_user_func_array(array($this->vobject, $function), $arguments);
+ }
+}
diff --git a/settings/ajax/setquota.php b/settings/ajax/setquota.php
index edbf5b74516..5c07285cfca 100644
--- a/settings/ajax/setquota.php
+++ b/settings/ajax/setquota.php
@@ -10,6 +10,6 @@ $quota= OC_Helper::computerFileSize($_POST["quota"]);
// Return Success story
OC_Preferences::setValue($username,'files','quota',$quota);
-OC_JSON::success(array("data" => array( "username" => $username ,'quota'=>$quota)));
+OC_JSON::success(array("data" => array( "username" => $username ,'quota'=>OC_Helper::humanFileSize($quota))));
?>
diff --git a/settings/apps.php b/settings/apps.php
index 27b4c17f9e6..12a7bf77202 100644
--- a/settings/apps.php
+++ b/settings/apps.php
@@ -43,6 +43,14 @@ foreach($registeredApps as $app){
}
}
+function app_sort($a, $b){
+ if ($a['active'] != $b['active']){
+ return $b['active'] - $a['active'];
+ }
+ return strcmp($a['name'], $b['name']);
+}
+usort($apps, 'app_sort');
+
// dissabled for now
// $catagoryNames=OC_OCSClient::getCategories();
// if(is_array($catagoryNames)){
diff --git a/settings/js/users.js b/settings/js/users.js
index 684fee21c64..4fea52e4a1f 100644
--- a/settings/js/users.js
+++ b/settings/js/users.js
@@ -101,8 +101,11 @@ $(document).ready(function(){
if($(this).val().length>0){
$.post(
OC.filePath('settings','ajax','setquota.php'),
- {username:uid,quota:$(this).val()},
- function(result){}
+ {username:uid,quota:$(this).val()},
+ function(result){
+ img.parent().children('span').text(result.data.quota)
+ $(this).parent().attr('data-quota',result.data.quota);
+ }
);
input.blur();
}else{
diff --git a/settings/templates/help.php b/settings/templates/help.php
index 4e3cdd7b908..754bf8b6376 100644
--- a/settings/templates/help.php
+++ b/settings/templates/help.php
@@ -9,7 +9,10 @@
<?php
$url=OC_Helper::linkTo( "settings", "help.php" ).'?page=';
$pageNavi=OC_Util::getPageNavi($_['pagecount'],$_['page'],$url);
- $pageNavi->printPage();
+ if($pageNavi)
+ {
+ $pageNavi->printPage();
+ }
?>
</diV>
<?php if(is_null($_["kbe"])):?>
diff --git a/settings/templates/personal.php b/settings/templates/personal.php
index 54487165f3c..8c5de5ccf2a 100644
--- a/settings/templates/personal.php
+++ b/settings/templates/personal.php
@@ -50,7 +50,9 @@
};?>
<p class="personalblock">
- <strong>ownCloud</strong> <?php echo(OC_Util::getVersionString()); ?>, <a href="http://gitorious.org/owncloud" target="_blank">source code</a> licensed freely under <a href="http://www.gnu.org/licenses/agpl-3.0.html" target="_blank">AGPL</a>
+ <strong>ownCloud</strong> <?php echo(OC_Util::getVersionString()); ?><br />
+ <?php echo(OC_Updater::ShowUpdatingHint()); ?><br />
+ <a href="http://gitorious.org/owncloud" target="_blank">source code</a> licensed freely under <a href="http://www.gnu.org/licenses/agpl-3.0.html" target="_blank">AGPL</a>
</p>