view views/Extractapp/ExportTabDelimited.php @ 116:0ef426b5a1b9 extractapp

replace delimit character from "tab" to "comma"
author Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
date Thu, 28 Sep 2017 17:43:13 +0200
parents b0cecc104639
children
line wrap: on
line source

<?php
/*
 * ExportTabDelimited.php
 * This file is part of Extraction-interface.
 *
 * Extraction-interface is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Extraction-interface 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Extraction-interface.  If not, see <http://www.gnu.org/licenses/>.
*/
/*! \file
 * This is the view for ExportTabDelimited.
*/

// --- initialize ---
$outputTableArray = $viewmodel['outputTableArray'];
$bookId = $viewmodel['bookId'];
$sectionid = $viewmodel['section_id'];
$bookName = $viewmodel['bookName'];
$sectionName = $viewmodel['sectionName'];
$bookMeta = $viewmodel['bookMeta'];



$count=1;
	foreach ( $outputTableArray as $trIndex =>$trValue ) {

        if ( $trIndex==0 ) {
			echo ",";
			echo "Book ID,";
			echo "Section ID,";
			echo "Book Name,";
			echo "Section Name,";
            echo "Book Year,";
            echo "Edition Year,";
			echo "Addres,";
			echo "Longitude,";	// longitude
			echo "Latitude,";	// latitude
			echo "Description,";	// description

		} else {
			echo $count++.",";
			echo $bookId.",";
			echo $sectionid.",";
			echo $bookName.",";
			echo $sectionName.",";
            echo $bookMeta->book_year.",";
            echo $bookMeta->edition_year.",";
			echo $bookMeta->place_name.",";
			echo $bookMeta->x.",";
			echo $bookMeta->y.",";
			echo $bookName."_".$sectionName.",";	// description for LGMap

		}
		if ( isset( $trValue["page"] ) ) {
			echo $trValue["page"].",";
		} else {
			echo ",";
		}

        foreach ( $outputTableArray[0][0] as $index => $value ) {
			if ( $index == "time" ) {
				if ( isset( $trValue[0][$index] ) ) {
					echo $trValue[0][$index].",";
					echo $trValue[0][$index].",";
				} else {
					echo ",";
					echo ",";
				}
			} else {
				if ( isset( $trValue[0][$index] ) ) {
					echo $trValue[0][$index].",";
				} else {
					echo ",";
				}
			}
		}
		if ( isset( $trValue["other"] ) ) {
			echo $trValue["other"].",";
		} else {
			echo ",";
		}
		if ( isset( $trValue["full"] ) ) {
			echo $trValue["full"].",";
		} else {
			echo ",";
		}
		echo "\n";
	}

?>