1
0

Provider.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Georg Ehrke <oc.list@georgehrke.com>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  8. * @author Olivier Paroz <github@oparoz.com>
  9. * @author Robin Appelman <robin@icewind.nl>
  10. * @author Roeland Jago Douma <roeland@famdouma.nl>
  11. *
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. namespace OC\Preview;
  28. use OCP\Preview\IProvider;
  29. abstract class Provider implements IProvider {
  30. private $options;
  31. /**
  32. * Constructor
  33. *
  34. * @param array $options
  35. */
  36. public function __construct(array $options = []) {
  37. $this->options = $options;
  38. }
  39. /**
  40. * @return string Regex with the mimetypes that are supported by this provider
  41. */
  42. abstract public function getMimeType();
  43. /**
  44. * Check if a preview can be generated for $path
  45. *
  46. * @param \OCP\Files\FileInfo $file
  47. * @return bool
  48. */
  49. public function isAvailable(\OCP\Files\FileInfo $file) {
  50. return true;
  51. }
  52. /**
  53. * Generates thumbnail which fits in $maxX and $maxY and keeps the aspect ratio, for file at path $path
  54. *
  55. * @param string $path Path of file
  56. * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
  57. * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
  58. * @param bool $scalingup Disable/Enable upscaling of previews
  59. * @param \OC\Files\View $fileview fileview object of user folder
  60. * @return bool|\OCP\IImage false if no preview was generated
  61. */
  62. abstract public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview);
  63. }