Permalink
Browse files

Update Exif

  • Loading branch information...
1 parent 47331a1 commit 01c7533dcd02ebbbd6794594a743ed5f39c4bb14 @cdujeu cdujeu committed Jun 1, 2016
Showing with 69 additions and 19 deletions.
  1. +63 −0 core/src/plugins/meta.exif/ExifXmlMessage.php
  2. +6 −19 core/src/plugins/meta.exif/class.ExifMetaManager.php
@@ -0,0 +1,63 @@
+<?php
+/*
+ * Copyright 2007-2016 Abstrium <contact (at) pydio.com>
+ * 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 <http://www.gnu.org/licenses/>.
+ *
+ * The latest code can be found at <https://pydio.com/>.
+ */
+
+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 .= "<exifSection name='$section'>";
+ foreach ($data as $key => $value) {
+ $buffer .= "<exifTag name=\"$key\">". Utils::xmlEntities($value)."</exifTag>";
+ }
+ $buffer .= "</exifSection>";
+ }
+ return $buffer;
+
+ }
+
+ public function jsonSerializableKey()
+ {
+ return "exif";
+ }
+
+ public function jsonSerializableData()
+ {
+ return $this->data;
+ }
+
+}
@@ -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("<exifSection name='$section'>");
- foreach ($data as $key => $value) {
- print("<exifTag name=\"$key\">". Utils::xmlEntities($value)."</exifTag>");
- }
- print("</exifSection>");
- }
- 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);
}

0 comments on commit 01c7533

Please sign in to comment.