2011-11-02 14:07:49 +00:00
< ? php
//生成西部数据中心离线申请表
require_once ( 'fpdf/chinese-unicode.php' );
require_once ( 'fpdi/fpdi.php' );
2011-11-03 03:26:10 +00:00
class MetadataPDF extends PDF_Unicode
2011-11-02 14:07:49 +00:00
{
public $metadata ;
public $fontsize = 10 ;
function draw ()
{
$this -> init ();
$this -> drawTitlePage ();
$this -> drawContent ();
}
function init ()
{
2011-11-03 03:26:10 +00:00
//$this->AddUniGBhwFont('ugb','AdobeSongStd-Light-Acro');
//$this->AddUniGBhwFont('ugh','AdobeHeitiStd-Light');
$this -> AddUniGBhwFont ( 'uGB' );
$this -> AddFont ( 'uGB' );
2011-11-02 14:07:49 +00:00
}
function DrawTitlePage ()
{
$this -> AddPage ();
$this -> Image ( 'http://westdc.westgis.ac.cn/images/westdc_logo_white.gif' , 80 , 30 , 0 , 0 , '' , 'http://westdc.westgis.ac.cn/' );
2011-11-03 03:26:10 +00:00
$this -> SetFont ( 'uGB' , 'B' , 20 );
2011-11-02 14:07:49 +00:00
$this -> setXY ( 0 , 70 );
2013-11-10 15:08:12 +00:00
$this -> Cell ( 0 , 0 , 'Cold and Arid Regions Science Data Center' , 0 , 2 , 'C' , false , 'http://card.westgis.ac.cn/' );
2011-11-03 03:26:10 +00:00
$imgurl = 'http://' . $_SERVER [ 'SERVER_NAME' ] . '/service/bigthumb/uuid/' . $this -> metadata [ 'uuid' ];
$imgsize = getimagesize ( $imgurl );
2013-05-09 16:03:41 +00:00
if ( $this -> metadata [ 'filetype' ] && $imgsize )
2011-11-03 03:26:10 +00:00
{
if ( $imgsize [ 0 ] / $imgsize [ 1 ] > 200 / 180 )
$this -> Image ( $imgurl , 5 , 110 , 200 , 0 , $this -> metadata [ 'filetype' ]);
else
$this -> Image ( $imgurl , 100 - round ( 90.0 * $imgsize [ 0 ] / $imgsize [ 1 ]), 110 , 0 , 180 , $this -> metadata [ 'filetype' ]);
}
$this -> SetFont ( 'uGB' , 'B' , 20 );
$this -> setXY ( 0 , 80 );
2011-11-03 04:01:13 +00:00
$this -> multicell ( 0 , 10 , $this -> metadata [ 'title' ], 0 , 'C' );
2011-11-02 14:07:49 +00:00
//$this->setFont('Arial','',12);
$this -> ln ( 10 );
2011-11-03 03:26:10 +00:00
$this -> SetFont ( 'uGB' , 'B' , 12 );
2013-11-10 15:08:12 +00:00
$this -> Cell ( 0 , 0 , 'UUID: ' . $this -> metadata [ 'uuid' ], 0 , 2 , 'C' , false , 'http://card.westgis.ac.cn/data/' . $this -> metadata [ 'uuid' ]);
2011-11-02 14:07:49 +00:00
}
function DrawContent ()
{
$this -> addPage ();
2011-11-03 03:26:10 +00:00
$this -> setfont ( 'uGB' , '' , 12 );
2011-11-02 14:07:49 +00:00
//$this->setXY(15,80);
$this -> multicell ( 0 , 10 , $this -> metadata [ 'title' ], 0 , 'C' , 'http://' . $_SERVER [ 'SERVER_NAME' ] . '/data/' . $this -> metadata [ 'uuid' ]);
if ( $this -> metadata [ 'title_en' ])
{
//$this->setFont('times','',12);
$this -> multicell ( 0 , 5 , $this -> metadata [ 'title_en' ], 0 , 'C' , 'http://' . $_SERVER [ 'SERVER_NAME' ] . '/data/' . $this -> metadata [ 'uuid' ]);
}
$this -> ln ( 10 );
2011-11-03 03:26:10 +00:00
$this -> setfont ( 'uGB' , '' , 10 );
2011-11-02 14:07:49 +00:00
$this -> setFillColor ( 200 , 200 , 200 );
2013-11-10 15:08:12 +00:00
$this -> Cell ( 0 , 8 , ' Abstract' , 0 , 1 , 'L' , true );
2011-11-02 14:07:49 +00:00
//$this->write(5,$this->metadata['description']);
$this -> DrawTable ( $this -> metadata [ 'description' ]);
//todo: table in abstract
$this -> ln ( 5 );
2013-11-10 15:08:12 +00:00
$this -> Cell ( 0 , 8 , ' Keywords' , 0 , 1 , 'L' , true );
$this -> write ( 5 , 'Theme: ' . $this -> metadata [ 'keyword' ][ 'theme' ]);
2011-11-02 14:07:49 +00:00
$this -> ln ( 5 );
2013-11-10 15:08:12 +00:00
$this -> write ( 5 , 'Place: ' . $this -> metadata [ 'keyword' ][ 'place' ]);
2011-11-02 14:07:49 +00:00
$this -> ln ( 5 );
2013-11-10 15:08:12 +00:00
$this -> write ( 5 , 'Temporal: ' . $this -> metadata [ 'keyword' ][ 'temporal' ]);
2011-11-02 14:07:49 +00:00
$this -> ln ( 5 );
2013-11-10 15:08:12 +00:00
$this -> write ( 5 , 'Discipline: ' . $this -> metadata [ 'keyword' ][ 'discipline' ]);
2011-11-02 14:07:49 +00:00
$this -> ln ( 5 );
2013-11-10 15:08:12 +00:00
$this -> write ( 5 , 'Statrum: ' . $this -> metadata [ 'keyword' ][ 'stratum' ]);
2011-11-02 14:07:49 +00:00
$this -> ln ( 5 );
2013-11-10 15:08:12 +00:00
$this -> Cell ( 0 , 8 , ' ISO 19115 Category' , 0 , 1 , 'L' , true );
$this -> write ( 5 , 'Category: ' . $this -> metadata [ 'category' ]);
2011-11-02 14:07:49 +00:00
$this -> ln ( 5 );
2013-11-10 15:08:12 +00:00
$this -> Cell ( 0 , 8 , ' Detail' , 0 , 1 , 'L' , true );
2011-11-02 14:07:49 +00:00
if ( $this -> metadata [ 'rfdenom' ])
{
2013-11-10 15:08:12 +00:00
$this -> write ( 5 , 'Scale: ' . $this -> metadata [ 'rfdenom' ]);
2011-11-02 14:07:49 +00:00
$this -> ln ( 5 );
}
if ( $this -> metadata [ 'resolution' ])
{
2013-11-10 15:08:12 +00:00
$this -> write ( 5 , 'Resolution: ' . $this -> metadata [ 'resolution' ]);
2011-11-02 14:07:49 +00:00
$this -> ln ( 5 );
}
2013-11-10 15:08:12 +00:00
$this -> write ( 5 , 'Project: ' . $this -> metadata [ 'projection' ]);
2011-11-02 14:07:49 +00:00
$this -> ln ( 5 );
2013-11-10 15:08:12 +00:00
$this -> write ( 5 , 'Data Volume(MB): ' . $this -> metadata [ 'filesize' ]);
2011-11-02 14:07:49 +00:00
$this -> ln ( 5 );
2013-11-10 15:08:12 +00:00
$this -> write ( 5 , 'Data Format: ' . $this -> metadata [ 'fileformat' ]);
2011-11-02 14:07:49 +00:00
$this -> ln ( 5 );
2013-11-10 15:08:12 +00:00
$this -> Cell ( 0 , 8 , ' Position and Thumbnail' , 0 , 1 , 'L' , true );
2011-11-02 14:07:49 +00:00
$this -> ln ( 5 );
$x = $this -> getX (); $y = $this -> getY ();
$w = 50 * abs (( $this -> metadata [ 'north' ] - $this -> metadata [ 'south' ]) / ( $this -> metadata [ 'west' ] - $this -> metadata [ 'east' ]));
2013-05-09 15:39:41 +00:00
if ( $this -> metadata [ 'filetype' ]) $this -> Image ( 'http://' . $_SERVER [ 'SERVER_NAME' ] . '/service/thumb/uuid/' . $this -> metadata [ 'uuid' ], $x + 80 + $w , $y , 0 , 50 , $this -> metadata [ 'filetype' ]);
2011-11-02 14:07:49 +00:00
$this -> rect ( $x + 50 , $y , $w , 50 );
$this -> setXY ( $x + 55 , $y - 4 );
$this -> write ( 5 , 'N:' . $this -> metadata [ 'north' ]);
$this -> setXY ( $x + 40 , $y + 20 );
$this -> write ( 5 , 'W:' . $this -> metadata [ 'west' ]);
$this -> setXY ( $x + 50 + $w , $y + 20 );
$this -> write ( 5 , 'E:' . $this -> metadata [ 'east' ]);
$this -> setXY ( $x + 55 , $y + 50 );
$this -> write ( 5 , 'S:' . $this -> metadata [ 'south' ]);
$this -> ln ( 5 );
2013-11-10 15:08:12 +00:00
$this -> Cell ( 0 , 8 , ' Temporal Range' , 0 , 1 , 'L' , true );
$this -> write ( 5 , 'Start: ' . $this -> metadata [ 'timebegin' ]);
2011-11-02 14:07:49 +00:00
$this -> ln ( 5 );
2013-11-10 15:08:12 +00:00
$this -> write ( 5 , 'End: ' . $this -> metadata [ 'timeend' ]);
2011-11-02 14:07:49 +00:00
$this -> ln ( 5 );
2013-11-10 15:08:12 +00:00
$this -> Cell ( 0 , 8 , ' Citation' , 0 , 1 , 'L' , true );
2011-11-02 14:07:49 +00:00
$this -> write ( 5 , $this -> metadata [ 'citation' ]);
$this -> ln ( 5 );
2013-11-10 15:08:12 +00:00
$this -> Cell ( 0 , 8 , ' Recommended Publications' , 0 , 1 , 'L' , true );
2011-11-02 14:07:49 +00:00
$this -> write ( 5 , $this -> metadata [ 'reference' ]);
//$this->ln(5);
2013-11-10 15:08:12 +00:00
$this -> Cell ( 0 , 8 , ' DOI' , 0 , 1 , 'L' , true );
2011-11-02 14:07:49 +00:00
$this -> write ( 5 , $this -> metadata [ 'doi' ]);
$this -> ln ( 5 );
2013-11-10 15:08:12 +00:00
$this -> Cell ( 0 , 8 , ' Funding' , 0 , 1 , 'L' , true );
2011-11-02 14:07:49 +00:00
$this -> write ( 5 , $this -> metadata [ 'suppinfo' ]);
$this -> ln ( 5 );
2013-11-10 15:08:12 +00:00
$this -> Cell ( 0 , 8 , ' Limitation' , 0 , 1 , 'L' , true );
2011-11-02 14:07:49 +00:00
$this -> write ( 5 , $this -> metadata [ 'uselimits' ]);
2013-11-10 15:08:12 +00:00
$this -> Cell ( 0 , 8 , ' Online Resources' , 0 , 1 , 'L' , true );
2011-11-02 14:07:49 +00:00
foreach ( $this -> metadata [ 'resources' ] as $k => $r )
{
$this -> write ( 5 ,( $k + 1 ) . '. ' . $r [ 'name' ] . ' ' . $r [ 'linkage' ], $r [ 'linkage' ]);
$this -> ln ( 5 );
}
2013-11-10 15:08:12 +00:00
$this -> Cell ( 0 , 8 , ' Contacts' , 0 , 1 , 'L' , true );
$party_zh = array ( 'resourceProvider' => 'Resource Provider' , 'custodian' => 'Custodian' , 'owner' => 'Owner' , 'user' => 'User' , 'distributor' => 'Distributor' , 'originator' => 'Originator' , 'pointOfContact' => 'Point of Contact' , 'principalInvestigator' => 'Principal Investigator' , 'processor' => 'Process' , 'publisher' => 'Publisher' , 'author' => 'Author' );
2011-11-02 14:07:49 +00:00
foreach ( $this -> metadata [ 'contacts' ] as $k => $c )
{
$this -> write ( 5 ,( $k + 1 ) . '. ' . $party_zh [ $c [ 'role' ]]); $this -> ln ( 5 );
2013-11-10 15:08:12 +00:00
$this -> write ( 5 , $c [ 'individual' ] . ' Organization: ' . $c [ 'organisation' ]); $this -> ln ( 5 );
$this -> write ( 5 , 'Address: ' . $c [ 'country' ] . ' ' . $c [ 'administractive' ] . ' ' . $c [ 'city' ] . ' ' . $c [ 'delivery' ]); $this -> ln ( 5 );
$this -> write ( 5 , 'Zip code: ' . $c [ 'postal' ] . ' Phone: ' . $c [ 'phone' ] . ' Email: ' . $c [ 'email' ]);
2011-11-02 14:07:49 +00:00
$this -> ln ( 5 );
$this -> ln ( 5 );
}
}
function DrawTable ( $text )
{
2011-11-04 09:54:15 +00:00
$table = explode ( " { | " , $text );
2011-11-02 14:07:49 +00:00
$this -> write ( 5 , $table [ 0 ]);
2011-11-04 09:54:15 +00:00
$table1 = explode ( " |} " , $table [ 1 ]);
$table = explode ( " |- " , $table1 [ 0 ]);
2011-11-02 14:07:49 +00:00
$header = explode ( " ! " , str_replace ( array ( " \r \n " , " \n " , " \r " ), '' , $table [ 0 ]));
$data = array ();
foreach ( $table as $line => $tr )
{
if ( $line > 0 && ! empty ( $tr ))
{
2011-11-04 09:54:15 +00:00
$tr = substr ( trim ( $tr ), 1 );
2011-11-02 14:07:49 +00:00
$data [] = explode ( " || " , $tr );
}
}
//Header
foreach ( $header as $k => $col )
if ( $k > 0 ) $this -> Cell ( 40 , 7 , $col , 1 );
$this -> Ln ();
//Data
foreach ( $data as $row )
{
foreach ( $row as $col )
$this -> Cell ( 40 , 6 , $col , 1 );
$this -> Ln ();
}
$this -> write ( 5 , $table1 [ 1 ]);
}
function Footer ()
{
//Page footer
$this -> SetY ( - 15 );
$this -> SetFont ( 'Arial' , 'I' , 8 );
$this -> SetTextColor ( 128 );
if ( $this -> PageNo () > 1 ) $this -> Cell ( 0 , 10 , ' - ' . ( $this -> PageNo () - 1 ) . ' - ' , 0 , 0 , 'C' );
}
}
2011-11-03 03:26:10 +00:00
?>