本文整理汇总了PHP中zipfile::addFromString方法的典型用法代码示例。如果您正苦于以下问题:PHP zipfile::addFromString方法的具体用法?PHP zipfile::addFromString怎么用?PHP zipfile::addFromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zipfile
的用法示例。
在下文中一共展示了zipfile::addFromString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getKML
public function getKML($url, $download = false, $file = "")
{
// Create KMZ archieve
if ($file == "") {
$file = $this->dirtmp . "/tme" . $this->nomeTemp . ".kmz";
}
$this->nomeArquivo = $file;
if (!file_exists($file)) {
include dirname(__FILE__) . "/../kmlmapserver/classes/zip.class.php";
$zip = new zipfile();
// Add balloon logo to archieve (300 x 30 px)
$zip->addFile($this->logoline, 'files/balloonlogo.png');
// KML header
$kml = "<?xml version='1.0' encoding='UTF-8'?>" . PHP_EOL . "<kml xmlns='http://www.opengis.net/kml/2.2' xmlns:atom='http://www.w3.org/2005/Atom'>" . PHP_EOL . " <Document>" . PHP_EOL . " <atom:author>" . PHP_EOL . " <atom:name>Thematic Mapping Engine</atom:name>" . PHP_EOL . " </atom:author>" . PHP_EOL . " <atom:link href='http://thematicmapping.org' rel='related' />" . PHP_EOL . " <name>{$this->mapTitle}</name>" . PHP_EOL . " <open>1</open>" . PHP_EOL . " <Snippet maxLines='1'>{$this->mapSource}</Snippet>" . PHP_EOL . " <description><![CDATA[ {$this->mapDescription} <p>{$this->mapSource}</p>{$this->engine} ]]></description>" . PHP_EOL;
// Add style for indicator balloon
$kmlStyles = " <Style id='balloonStyle'>" . PHP_EOL . " <BalloonStyle>" . PHP_EOL . " <text><![CDATA[" . PHP_EOL . " <a href='http://thematicmapping.org'><img src='http://thematicmapping.org/engine/files/balloonlogo.png'></a>" . PHP_EOL . " <p><b><font size='+2'>\$[name]</font></b></p>" . PHP_EOL . " <p>\$[description]</p>" . PHP_EOL . " ]]></text>" . PHP_EOL . " </BalloonStyle>" . PHP_EOL . " </Style>" . PHP_EOL . " <styleUrl>#balloonStyle</styleUrl>" . PHP_EOL;
if ($this->colourType == 'scale') {
// Need to run before getColourValue / getColourLegend / makeClasses
self::makeColourScale();
if ($this->classification != 'unclassed') {
self::makeClasses($this->classification, $this->numClasses);
}
// Add colour legend to KMZ archieve
if ($this->showLegend) {
$imgLegenda = self::getColourLegend();
$zip->addFile($imgLegenda, 'files/legend.png');
}
$kmlSingleColour = '';
// Colours needs to be defined for each feature
//$kmlColour = self::rgb2bgr($this->noDataColour); // Not in use, only so the variable has a value
} else {
$kmlSingleColour = '<color>' . self::rgb2bgr($this->colour) . '</color>';
//$kmlColour = self::rgb2bgr($this->colour);
}
// Add style for value placemarks
if ($this->showLabel) {
$kmlStyles .= " <Style id='labelPlacemark'>" . PHP_EOL . " <IconStyle>" . PHP_EOL . " <scale>0.0</scale>" . PHP_EOL . " </IconStyle>" . PHP_EOL . " <LabelStyle>" . PHP_EOL . " <scale>1</scale>" . PHP_EOL . " </LabelStyle>" . PHP_EOL . " </Style>" . PHP_EOL;
}
// Define shared styles and legend
$kmlStyles .= " <Style id='sharedStyle'>" . PHP_EOL;
switch ($this->mapType) {
case "choropleth":
case "prism":
$kmlStyles .= " <PolyStyle>" . PHP_EOL . " <fill>1</fill>" . PHP_EOL . " <outline>1</outline>" . PHP_EOL . " {$kmlSingleColour}" . PHP_EOL . " </PolyStyle>" . PHP_EOL . " <LineStyle>" . PHP_EOL . " <color>cc000000</color>" . PHP_EOL . " </LineStyle>" . PHP_EOL;
break;
case "bar":
if ($this->outlinecolor == "") {
$outline = 0;
} else {
$outline = 1;
}
$kmlStyles .= " <PolyStyle>" . PHP_EOL . " <fill>1</fill>" . PHP_EOL . " <outline>" . $outline . "</outline>" . PHP_EOL . " {$kmlSingleColour}" . PHP_EOL . " </PolyStyle>" . PHP_EOL;
if ($this->outlinecolor != "") {
$kmlStyles .= "<LineStyle>" . PHP_EOL . " <color>" . $this->outlinecolor . "</color>" . PHP_EOL . " </LineStyle>" . PHP_EOL;
}
break;
// Proportional symbol
// Proportional symbol
case "symbol":
switch ($this->symbolType) {
case 'image':
$zip->addFile("files/{$this->symbolShape}.png", 'files/symbol.png');
$kmlStyles .= " <IconStyle>" . PHP_EOL . " {$kmlSingleColour}" . PHP_EOL . " <Icon>" . PHP_EOL . " <href>" . $url . "/symbol.png</href>" . PHP_EOL . " </Icon>" . PHP_EOL . " </IconStyle>" . PHP_EOL;
break;
case 'polygon':
if ($this->symbolShape == 'square') {
$this->symbolVertices = 4;
}
$kmlStyles .= " <PolyStyle>" . PHP_EOL . " {$kmlSingleColour}" . PHP_EOL . " <fill>1</fill>" . PHP_EOL . " <outline>1</outline>" . PHP_EOL . " </PolyStyle>" . PHP_EOL . " <LineStyle>" . PHP_EOL . " <color>cc000000</color>" . PHP_EOL . " </LineStyle>" . PHP_EOL;
break;
case 'collada':
if ($this->colourType == 'scale') {
// Limit number of collada objects (one for each colour)
if ($this->classification == 'unclassed') {
self::makeClasses('equal', 12);
}
foreach ($this->classColours as $class => $classColour) {
$colladaColour = self::rgb2collada($classColour);
// Read collada model
$filename = "files/{$this->symbolShape}.dae";
$handle = fopen($filename, "r");
$collada = fread($handle, filesize($filename));
fclose($handle);
// Search and replace colour
$pos = strpos($collada, '<effect id="material0-effect" name="material0-effect">');
$pos = strpos($collada, "<diffuse>", $pos);
$pos = strpos($collada, "<color>", $pos);
$collada = substr_replace($collada, $colladaColour, $pos + 7, 28);
// Add collada object to kmz archieve
$zip->addFromString("files/object{$class}.dae", $collada);
}
} else {
$colladaColour = self::rgb2collada($this->colour);
// Read collada model
$filename = "files/{$this->symbolShape}.dae";
$handle = fopen($filename, "r");
$collada = fread($handle, filesize($filename));
fclose($handle);
// Search and replace colour
$pos = strpos($collada, '<effect id="material0-effect" name="material0-effect">');
//.........这里部分代码省略.........