From dfde04291eae31765b2cb858e1d1260b60d75329 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 26 Nov 2014 11:14:17 +0100 Subject: [PATCH 1/3] Move share interfaces to own files so they can be autoloaded --- lib/public/share.php | 83 --------------------- lib/public/share_backend.php | 68 +++++++++++++++++ lib/public/share_backend_collection.php | 29 +++++++ lib/public/share_backend_file_dependent.php | 31 ++++++++ tests/lib/share/backend.php | 2 - 5 files changed, 128 insertions(+), 85 deletions(-) create mode 100644 lib/public/share_backend.php create mode 100644 lib/public/share_backend_collection.php create mode 100644 lib/public/share_backend_file_dependent.php diff --git a/lib/public/share.php b/lib/public/share.php index 333e0a2697..b3ece8fab9 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -342,86 +342,3 @@ class Share extends \OC\Share\Constants { return \OC\Share\Share::isResharingAllowed(); } } - -/** - * Interface that apps must implement to share content. - */ -interface Share_Backend { - - /** - * Check if this $itemSource exist for the user - * @param string $itemSource - * @param string $uidOwner Owner of the item - * @return boolean|null Source - * - * Return false if the item does not exist for the user - */ - public function isValidSource($itemSource, $uidOwner); - - /** - * Get a unique name of the item for the specified user - * @param string $itemSource - * @param string|false $shareWith User the item is being shared with - * @param array|null $exclude List of similar item names already existing as shared items @deprecated since version OC7 - * @return string Target name - * - * This function needs to verify that the user does not already have an item with this name. - * If it does generate a new name e.g. name_# - */ - public function generateTarget($itemSource, $shareWith, $exclude = null); - - /** - * Converts the shared item sources back into the item in the specified format - * @param array $items Shared items - * @param int $format - * @return TODO - * - * The items array is a 3-dimensional array with the item_source as the - * first key and the share id as the second key to an array with the share - * info. - * - * The key/value pairs included in the share info depend on the function originally called: - * If called by getItem(s)Shared: id, item_type, item, item_source, - * share_type, share_with, permissions, stime, file_source - * - * If called by getItem(s)SharedWith: id, item_type, item, item_source, - * item_target, share_type, share_with, permissions, stime, file_source, - * file_target - * - * This function allows the backend to control the output of shared items with custom formats. - * It is only called through calls to the public getItem(s)Shared(With) functions. - */ - public function formatItems($items, $format, $parameters = null); - -} - -/** - * Interface for share backends that share content that is dependent on files. - * Extends the Share_Backend interface. - */ -interface Share_Backend_File_Dependent extends Share_Backend { - - /** - * Get the file path of the item - * @param string $itemSource - * @param string $uidOwner User that is the owner of shared item - * @return string|false - */ - public function getFilePath($itemSource, $uidOwner); - -} - -/** - * Interface for collections of of items implemented by another share backend. - * Extends the Share_Backend interface. - */ -interface Share_Backend_Collection extends Share_Backend { - - /** - * Get the sources of the children of the item - * @param string $itemSource - * @return array Returns an array of children each inside an array with the keys: source, target, and file_path if applicable - */ - public function getChildren($itemSource); - -} diff --git a/lib/public/share_backend.php b/lib/public/share_backend.php new file mode 100644 index 0000000000..6ab234aecf --- /dev/null +++ b/lib/public/share_backend.php @@ -0,0 +1,68 @@ + + * 2014 Bjoern Schiessle + * + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +// use OCP namespace for all classes that are considered public. +// This means that they should be used by apps instead of the internal ownCloud classes +namespace OCP; + +/** + * Interface that apps must implement to share content. + */ +interface Share_Backend { + + /** + * Check if this $itemSource exist for the user + * @param string $itemSource + * @param string $uidOwner Owner of the item + * @return boolean|null Source + * + * Return false if the item does not exist for the user + */ + public function isValidSource($itemSource, $uidOwner); + + /** + * Get a unique name of the item for the specified user + * @param string $itemSource + * @param string|false $shareWith User the item is being shared with + * @param array|null $exclude List of similar item names already existing as shared items @deprecated since version OC7 + * @return string Target name + * + * This function needs to verify that the user does not already have an item with this name. + * If it does generate a new name e.g. name_# + */ + public function generateTarget($itemSource, $shareWith, $exclude = null); + + /** + * Converts the shared item sources back into the item in the specified format + * @param array $items Shared items + * @param int $format + * @return TODO + * + * The items array is a 3-dimensional array with the item_source as the + * first key and the share id as the second key to an array with the share + * info. + * + * The key/value pairs included in the share info depend on the function originally called: + * If called by getItem(s)Shared: id, item_type, item, item_source, + * share_type, share_with, permissions, stime, file_source + * + * If called by getItem(s)SharedWith: id, item_type, item, item_source, + * item_target, share_type, share_with, permissions, stime, file_source, + * file_target + * + * This function allows the backend to control the output of shared items with custom formats. + * It is only called through calls to the public getItem(s)Shared(With) functions. + */ + public function formatItems($items, $format, $parameters = null); + +} diff --git a/lib/public/share_backend_collection.php b/lib/public/share_backend_collection.php new file mode 100644 index 0000000000..0292222c74 --- /dev/null +++ b/lib/public/share_backend_collection.php @@ -0,0 +1,29 @@ + + * 2014 Bjoern Schiessle + * + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +// use OCP namespace for all classes that are considered public. +// This means that they should be used by apps instead of the internal ownCloud classes +namespace OCP; + +/** + * Interface for collections of of items implemented by another share backend. + * Extends the Share_Backend interface. + */ +interface Share_Backend_Collection extends Share_Backend { + /** + * Get the sources of the children of the item + * @param string $itemSource + * @return array Returns an array of children each inside an array with the keys: source, target, and file_path if applicable + */ + public function getChildren($itemSource); +} diff --git a/lib/public/share_backend_file_dependent.php b/lib/public/share_backend_file_dependent.php new file mode 100644 index 0000000000..b666e50400 --- /dev/null +++ b/lib/public/share_backend_file_dependent.php @@ -0,0 +1,31 @@ + + * 2014 Bjoern Schiessle + * + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +// use OCP namespace for all classes that are considered public. +// This means that they should be used by apps instead of the internal ownCloud classes +namespace OCP; + +/** + * Interface for share backends that share content that is dependent on files. + * Extends the Share_Backend interface. + */ +interface Share_Backend_File_Dependent extends Share_Backend { + /** + * Get the file path of the item + * @param string $itemSource + * @param string $uidOwner User that is the owner of shared item + * @return string|false + */ + public function getFilePath($itemSource, $uidOwner); + +} diff --git a/tests/lib/share/backend.php b/tests/lib/share/backend.php index 61b8f262a4..0795826694 100644 --- a/tests/lib/share/backend.php +++ b/tests/lib/share/backend.php @@ -19,8 +19,6 @@ * License along with this library. If not, see . */ -OC::$CLASSPATH['OCP\Share_Backend']='lib/public/share.php'; - class Test_Share_Backend implements OCP\Share_Backend { const FORMAT_SOURCE = 0; From 7b8824a4e3b7e0c1484540991ab7b3f5d99afe98 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 26 Nov 2014 11:18:27 +0100 Subject: [PATCH 2/3] Move iHomeStorage to own file --- lib/public/files/ihomestorage.php | 24 ++++++++++++++++++++++++ lib/public/files/storage.php | 4 ---- 2 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 lib/public/files/ihomestorage.php diff --git a/lib/public/files/ihomestorage.php b/lib/public/files/ihomestorage.php new file mode 100644 index 0000000000..717ef94675 --- /dev/null +++ b/lib/public/files/ihomestorage.php @@ -0,0 +1,24 @@ + Date: Wed, 26 Nov 2014 11:36:06 +0100 Subject: [PATCH 3/3] Move NaturalSort_DefaultCollator to its own file --- lib/private/naturalsort.php | 11 ----------- lib/private/naturalsort_defaultcollator.php | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 lib/private/naturalsort_defaultcollator.php diff --git a/lib/private/naturalsort.php b/lib/private/naturalsort.php index eb00f99a67..6e259630f7 100644 --- a/lib/private/naturalsort.php +++ b/lib/private/naturalsort.php @@ -9,16 +9,6 @@ namespace OC; -class NaturalSort_DefaultCollator { - - public function compare($a, $b) { - if ($a === $b) { - return 0; - } - return ($a < $b) ? -1 : 1; - } -} - class NaturalSort { private static $instance; private $collator; @@ -114,4 +104,3 @@ class NaturalSort { return self::$instance; } } - diff --git a/lib/private/naturalsort_defaultcollator.php b/lib/private/naturalsort_defaultcollator.php new file mode 100644 index 0000000000..e1007f8d7b --- /dev/null +++ b/lib/private/naturalsort_defaultcollator.php @@ -0,0 +1,19 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + * + */ + +namespace OC; + +class NaturalSort_DefaultCollator { + public function compare($a, $b) { + if ($a === $b) { + return 0; + } + return ($a < $b) ? -1 : 1; + } +}