Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Update Exif
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Jun 1, 2016
1 parent 47331a1 commit 01c7533
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 19 deletions.
63 changes: 63 additions & 0 deletions core/src/plugins/meta.exif/ExifXmlMessage.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;
}

}
25 changes: 6 additions & 19 deletions core/src/plugins/meta.exif/class.ExifMetaManager.php
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

}

Expand Down

0 comments on commit 01c7533

Please sign in to comment.