diff --git a/lib/preview.php b/lib/preview.php index b40ba191fb..266f7795f1 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -42,6 +42,9 @@ class Preview { private $scalingup; //preview images object + /** + * @var \OC_Image + */ private $preview; //preview providers @@ -624,4 +627,4 @@ class Preview { } return false; } -} \ No newline at end of file +} diff --git a/lib/previewmanager.php b/lib/previewmanager.php new file mode 100755 index 0000000000..ac9a866a75 --- /dev/null +++ b/lib/previewmanager.php @@ -0,0 +1,38 @@ +getPreview(); + } + + /** + * @brief returns true if the passed mime type is supported + * @param string $mimeType + * @return boolean + */ + function isMimeSupported($mimeType = '*') + { + return \OC\Preview::isMimeSupported($mimeType); + } +} diff --git a/lib/public/ipreview.php b/lib/public/ipreview.php new file mode 100644 index 0000000000..b01e7f5b53 --- /dev/null +++ b/lib/public/ipreview.php @@ -0,0 +1,35 @@ +registerService('ContactsManager', function($c){ return new ContactsManager(); }); + $this->registerService('Request', function($c){ + $params = array(); + + // we json decode the body only in case of content type json + if (isset($_SERVER['CONTENT_TYPE']) && stripos($_SERVER['CONTENT_TYPE'],'json') === true ) { + $params = json_decode(file_get_contents('php://input'), true); + $params = is_array($params) ? $params: array(); + } + + return new Request( + array( + 'get' => $_GET, + 'post' => $_POST, + 'files' => $_FILES, + 'server' => $_SERVER, + 'env' => $_ENV, + 'session' => $_SESSION, + 'cookies' => $_COOKIE, + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) + ? $_SERVER['REQUEST_METHOD'] + : null, + 'params' => $params, + 'urlParams' => $c['urlParams'] + ) + ); + }); + $this->registerService('PreviewManager', function($c){ + return new PreviewManager(); + }); } /** @@ -37,4 +67,14 @@ class Server extends SimpleContainer implements IServerContainer { { return $this->query('Request'); } + + /** + * Returns the preview manager which can create preview images for a given file + * + * @return \OCP\IPreview + */ + function getPreviewManager() + { + return $this->query('PreviewManager'); + } }