示例#1
0
function downloadZip($format = null){

	$app = \Slim\Slim::getInstance();
	$extension = array(
		'xml' => 'xml',
		'rdfxml' => 'xml',
		'jsonld' => 'json',
		'turtle' => 'ttl',
		'ntriples' => 'nt'
	);
	if(!array_key_exists($format, $extension)){
		$app->flash('error', '指定された出力形式が不正です。');
		throw new RuntimeException('指定された出力形式が不正です。');
	}
	$zip = new ZipArchive();
	$zipFileName = 'data.zip';
	$zipFilePath = $app->config( 'uploadPath' ) ;

	$check = $zip->open($zipFilePath.$zipFileName, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);
	if ($check !== true) {
		$app->flash('error', 'zipファイルの作成に失敗しました');
		throw new RuntimeException('zipファイルの作成に失敗しました');
	}

	if($format == 'xml'){
		$zip->addFromString('schema.xsd' , getSchema());
		$xml = new XMLConverter();
		$output = $xml->getXML();
	}else{
		$rdf = new RDFConverter();
		$rdf->parseGraph($format);
		$output = $rdf->output();
	}
	$zip->addFromString('convertedData.'  . $extension[$format] , $output);
	$zip->addFromString('header.xml' , dmdHeaderXML());
	$zip->addFromString('header.ttl' , dmdHeaderRDF());
	$zip->addFromString('mapping.json' , getMapping());

	$zip->close();

	$app->response->headers->set( 'Content-Type', 'application/zip; name="' . $zipFileName . '"' );
	$app->response->headers->set( 'Content-Disposition', 'attachment; filename="' . $zipFileName . '"' );
	$app->response->headers->set( 'Content-Length', filesize($zipFilePath.$zipFileName) );
	$app->response->write( file_get_contents($zipFilePath.$zipFileName));

	unlink($zipFilePath.$zipFileName);
}
<form method="post">
<input name="name" style="width:100%;padding: 30px; text-align: center; background: #fcfcfc; box-sizing: border-box;font-size: 20px; font-weight: bold" autofocus>
</form>
<?php 
if (isset($_POST['name'])) {
    $schema = getSchema(trim($_POST['name']));
    generateClass($schema);
    echo "<div style='width:100%;padding: 30px; text-align: center; background: green; box-sizing: border-box;font-size: 20px; font-weight: bold'>Done</div>";
}
function getSchema($name)
{
    $schema = new stdClass();
    $schema->name = $name;
    $schema->url = "http://schema.org/" . $name;
    $schema->properties = array();
    $yql_base_url = "http://query.yahooapis.com/v1/public/yql";
    $yql_query = "select * from html where url=\"http://schema.org/" . $name . "\" AND xpath=\"//div[@id='mainContent']\"";
    $yql_query_url = $yql_base_url . "?q=" . urlencode($yql_query);
    $yql_query_url .= "&format=json";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $yql_query_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $content = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    $jsonObject = json_decode($content);
    $result = $jsonObject->query->results;
    if ($jsonObject->query->count > 0) {
        if (is_array($result->div->table)) {
            $result->div->table = $result->div->table[0];
示例#3
0
     while($obj = db_fetch_object($result)) {
	     $layer_type = $obj->layer_type;
	 }
  }
  if(isset($_REQUEST['action'])){
    $table_cols = $col_info;
  } else {
      $table_cols = $cols;
  }
  return $layer_type;
}

if(isset($_REQUEST['action'])){
  $action = $_REQUEST['action'];
  $layer_tablename = $_REQUEST['layer_tablename'];
  $layer_type = getSchema($layer_tablename);
  $table_dtd = getDTD($table_cols,$layer_type,$layer_tablename);
  echo $table_dtd;

} else {
   /* POST */
  /* validate if file is selected or not */
  if ("" === $_FILES['uploadFile']['name']){
     die(return_error("Please select a file to upload"));
  }
  $pathinfo = pathinfo($_FILES['uploadFile']['name']);
  $user = $GLOBALS['user'];
  $layer_tablename = $_POST['layer_name'];

  $filepath = "upload/";
  $file_types = array("kml","kmz","gpx");