对ODF作了改进,让其能支持动态图片
This commit is contained in:
parent
86cdaf39ff
commit
21590fc4d8
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
require 'zip/PclZipProxy.php';
|
//require 'zip/PclZipProxy.php';
|
||||||
require 'zip/PhpZipProxy.php';
|
//require 'zip/PhpZipProxy.php';
|
||||||
require 'Segment.php';
|
require 'Segment.php';
|
||||||
class OdfException extends Exception
|
class OdfException extends Exception
|
||||||
{}
|
{}
|
||||||
|
@ -99,6 +99,19 @@ class Odf
|
||||||
$this->vars[$tag] = str_replace("\n", "<text:line-break/>", $value);
|
$this->vars[$tag] = str_replace("\n", "<text:line-break/>", $value);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
public function setVarsWithHTMLTable($key, $value, $encode = true, $charset = 'ISO-8859')
|
||||||
|
{
|
||||||
|
$tag= $this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT'];
|
||||||
|
if (strpos($this->contentXml, $tag) === false && strpos($this->stylesXml , $tag) === false) {
|
||||||
|
throw new OdfException("var $key not found in the document");
|
||||||
|
}
|
||||||
|
//$value = $encode ? htmlspecialchars($value) : $value;
|
||||||
|
$value = ($charset == 'ISO-8859') ? utf8_encode($value) : $value;
|
||||||
|
//$split=preg_split('/\<table(.*?)\>(.*?)\<\/table\>/m', $value);
|
||||||
|
|
||||||
|
$this->vars[$tag] = str_replace("\n", "<text:line-break/>", $value);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Assign a template variable as a picture
|
* Assign a template variable as a picture
|
||||||
*
|
*
|
||||||
|
@ -109,12 +122,13 @@ class Odf
|
||||||
*/
|
*/
|
||||||
public function setImage($key, $value)
|
public function setImage($key, $value)
|
||||||
{
|
{
|
||||||
$filename = strtok(strrchr($value, '/'), '/.');
|
|
||||||
$file = substr(strrchr($value, '/'), 1);
|
|
||||||
$size = @getimagesize($value);
|
$size = @getimagesize($value);
|
||||||
if ($size === false) {
|
if ($size === false) {
|
||||||
throw new OdfException("Invalid image");
|
throw new OdfException("Invalid image");
|
||||||
}
|
}
|
||||||
|
$filename=md5($value);;
|
||||||
|
$imgext=array('','.gif','.jpg','.png','.swf','.psd','.bmp','.tif','.tif','.jpc','.jp2','.jpx','.jb2','.swc','.iff','.wbmp','.xbm','.ico');
|
||||||
|
$file=$filename.$imgext[$size[2]];
|
||||||
list ($width, $height) = $size;
|
list ($width, $height) = $size;
|
||||||
$width *= self::PIXEL_TO_CM;
|
$width *= self::PIXEL_TO_CM;
|
||||||
$height *= self::PIXEL_TO_CM;
|
$height *= self::PIXEL_TO_CM;
|
||||||
|
@ -283,7 +297,9 @@ IMG;
|
||||||
throw new OdfException('Error during manifest file export');
|
throw new OdfException('Error during manifest file export');
|
||||||
}
|
}
|
||||||
foreach ($this->images as $imageKey => $imageValue) {
|
foreach ($this->images as $imageKey => $imageValue) {
|
||||||
$this->file->addFile($imageKey, 'Pictures/' . $imageValue);
|
//$this->file->addFile($imageKey, 'Pictures/' . $imageValue);
|
||||||
|
$this->file->addFromString('Pictures/' . $imageValue,file_get_contents($imageKey));
|
||||||
|
|
||||||
}
|
}
|
||||||
$this->file->close(); // seems to bug on windows CLI sometimes
|
$this->file->close(); // seems to bug on windows CLI sometimes
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue