Skip to content

Commit

Permalink
add XML output
Browse files Browse the repository at this point in the history
just as the JSON output added in e3187cd
  • Loading branch information
ssp committed Mar 5, 2014
1 parent 80ac14e commit 88ce026
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
51 changes: 51 additions & 0 deletions Classes/ViewHelpers/XMLViewHelper.php
@@ -0,0 +1,51 @@
<?php
/*******************************************************************************
* Copyright notice
*
* Copyright 2014 Sven-S. Porst <ssp-web@earthlingsoft.net>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/


/**
* View Helper to return the passed array, string or number as JSON.
*/
class Tx_Pazpar2_ViewHelpers_XMLViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {


/**
* Registers own arguments.
*/
public function initializeArguments() {
parent::initializeArguments();
$this->registerArgument('data', 'array', 'The data to output as XML', TRUE);
}


/**
* @return string
*/
public function render() {
return \TYPO3\CMS\Core\Utility\GeneralUtility::array2xml($this->arguments['data']);
}

}

?>
15 changes: 15 additions & 0 deletions Configuration/TypoScript/setup.txt
Expand Up @@ -168,3 +168,18 @@ tx_pazpar2_json {
}
}


# TYPO3 page type for XML download in the ugly structure created
# by t3lib_div::xml2array and re-converted to XML by t3lib_div::array2xml.
# To be used with query parameters:
# * type=1380124799
# * tx_pazpar2_pazpar2%5Bformat%5D=json
tx_pazpar2_xml = PAGE
tx_pazpar2_xml {
typeNum = 1394012954
10 < tt_content.list.20.pazpar2_pazpar2
config {
disableAllHeaderCode = 1
additionalHeaders = Content-type:text/xml;charset=utf-8
}
}
2 changes: 2 additions & 0 deletions Resources/Private/Templates/Pazpar2/Index.xml
@@ -0,0 +1,2 @@
{namespace pz2=Tx_Pazpar2_ViewHelpers}
<pz2:XML data="{results:query.results, stat:query.latestStatReply}"/>

0 comments on commit 88ce026

Please sign in to comment.