From 01c7533dcd02ebbbd6794594a743ed5f39c4bb14 Mon Sep 17 00:00:00 2001 From: cdujeu Date: Wed, 1 Jun 2016 08:59:06 +0200 Subject: [PATCH] Update Exif --- core/src/plugins/meta.exif/ExifXmlMessage.php | 63 +++++++++++++++++++ .../meta.exif/class.ExifMetaManager.php | 25 ++------ 2 files changed, 69 insertions(+), 19 deletions(-) create mode 100644 core/src/plugins/meta.exif/ExifXmlMessage.php diff --git a/core/src/plugins/meta.exif/ExifXmlMessage.php b/core/src/plugins/meta.exif/ExifXmlMessage.php new file mode 100644 index 0000000000..a50279e386 --- /dev/null +++ b/core/src/plugins/meta.exif/ExifXmlMessage.php @@ -0,0 +1,63 @@ + + * This file is part of Pydio. + * + * Pydio is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Pydio 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 Pydio. If not, see . + * + * The latest code can be found at . + */ + +use Pydio\Core\Utils\Utils; + +defined('AJXP_EXEC') or die('Access not allowed'); + + +class ExifXmlMessage implements \Pydio\Core\Http\Response\XMLSerializableResponseChunk, \Pydio\Core\Http\Response\JSONSerializableResponseChunk +{ + protected $data; + + public function __construct($filteredData) + { + $this->data = $filteredData; + } + + /** + * @return string + */ + public function toXML() + { + $buffer = ""; + foreach ($this->data as $section => $data) { + $buffer .= ""; + foreach ($data as $key => $value) { + $buffer .= "". Utils::xmlEntities($value).""; + } + $buffer .= ""; + } + return $buffer; + + } + + public function jsonSerializableKey() + { + return "exif"; + } + + public function jsonSerializableData() + { + return $this->data; + } + +} \ No newline at end of file diff --git a/core/src/plugins/meta.exif/class.ExifMetaManager.php b/core/src/plugins/meta.exif/class.ExifMetaManager.php index 471f2a2bf9..d3785ade61 100644 --- a/core/src/plugins/meta.exif/class.ExifMetaManager.php +++ b/core/src/plugins/meta.exif/class.ExifMetaManager.php @@ -107,8 +107,9 @@ protected function getMetaDefinition() return $result; } - public function extractExif($actionName, $httpVars, $fileVars) + public function extractExif(\Psr\Http\Message\ServerRequestInterface $requestInterface, \Psr\Http\Message\ResponseInterface &$responseInterface) { + $httpVars = $requestInterface->getParsedBody(); $repo = $this->accessDriver->repository; $userSelection = new UserSelection($this->accessDriver->repository, $httpVars); $repo->detectStreamWrapper(true); @@ -145,24 +146,10 @@ public function extractExif($actionName, $httpVars, $fileVars) } } - if($format == "xml"){ - - XMLWriter::header("metadata", array("file" => $selectedNode->getPath(), "type" => "EXIF")); - foreach ($filteredData as $section => $data) { - print(""); - foreach ($data as $key => $value) { - print("". Utils::xmlEntities($value).""); - } - print(""); - } - XMLWriter::close("metadata"); - - }else{ - - HTMLWriter::charsetHeader("application/json"); - echo json_encode($filteredData); - - } + require_once "ExifXmlMessage.php"; + $x = new \Pydio\Core\Http\Response\SerializableResponseStream(); + $x->addChunk(new ExifXmlMessage($filteredData)); + $responseInterface = $responseInterface->withBody($x); }