You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.3 KiB

3 years ago
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Andrew Brown <andrew@casabrown.com>
  6. * @author Bart Visscher <bartv@thisnet.nl>
  7. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  8. * @author Jakob Sack <mail@jakobsack.de>
  9. * @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
  10. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  11. * @author Morris Jobke <hey@morrisjobke.de>
  12. * @author Roeland Jago Douma <roeland@famdouma.nl>
  13. *
  14. * @license AGPL-3.0
  15. *
  16. * This code is free software: you can redistribute it and/or modify
  17. * it under the terms of the GNU Affero General Public License, version 3,
  18. * as published by the Free Software Foundation.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU Affero General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU Affero General Public License, version 3,
  26. * along with this program. If not, see <http://www.gnu.org/licenses/>
  27. *
  28. */
  29. namespace OC\Search\Provider;
  30. use OC\Files\Filesystem;
  31. /**
  32. * Provide search results from the 'files' app
  33. * @deprecated 20.0.0
  34. */
  35. class File extends \OCP\Search\Provider {
  36. /**
  37. * Search for files and folders matching the given query
  38. * @param string $query
  39. * @return \OCP\Search\Result[]
  40. * @deprecated 20.0.0
  41. */
  42. public function search($query) {
  43. $files = Filesystem::search($query);
  44. $results = [];
  45. // edit results
  46. foreach ($files as $fileData) {
  47. // skip versions
  48. if (strpos($fileData['path'], '_versions') === 0) {
  49. continue;
  50. }
  51. // skip top-level folder
  52. if ($fileData['name'] === 'files' && $fileData['parent'] === -1) {
  53. continue;
  54. }
  55. // create audio result
  56. if ($fileData['mimepart'] === 'audio') {
  57. $result = new \OC\Search\Result\Audio($fileData);
  58. }
  59. // create image result
  60. elseif ($fileData['mimepart'] === 'image') {
  61. $result = new \OC\Search\Result\Image($fileData);
  62. }
  63. // create folder result
  64. elseif ($fileData['mimetype'] === 'httpd/unix-directory') {
  65. $result = new \OC\Search\Result\Folder($fileData);
  66. }
  67. // or create file result
  68. else {
  69. $result = new \OC\Search\Result\File($fileData);
  70. }
  71. // add to results
  72. $results[] = $result;
  73. }
  74. // return
  75. return $results;
  76. }
  77. }