mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-14 05:31:42 +00:00
filename can be passed to addItem()
This commit is contained in:
parent
48613b5897
commit
11942c825d
|
@ -46,6 +46,18 @@ class SeedDMS_Download_Mgr {
|
||||||
*/
|
*/
|
||||||
protected $extracols;
|
protected $extracols;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array $rawcontents list of content used instead of document content
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
protected $rawcontents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array $filenames filename used in archive
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
protected $filnames;
|
||||||
|
|
||||||
function __construct($tmpdir = '') {
|
function __construct($tmpdir = '') {
|
||||||
$this->tmpdir = $tmpdir;
|
$this->tmpdir = $tmpdir;
|
||||||
$this->items = array();
|
$this->items = array();
|
||||||
|
@ -59,10 +71,11 @@ class SeedDMS_Download_Mgr {
|
||||||
$this->extraheader = $extraheader;
|
$this->extraheader = $extraheader;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
public function addItem($item, $extracols=array(), $rawcontent='') { /* {{{ */
|
public function addItem($item, $extracols=array(), $rawcontent='', $filename='') { /* {{{ */
|
||||||
$this->items[$item->getID()] = $item;
|
$this->items[$item->getID()] = $item;
|
||||||
$this->extracols[$item->getID()] = $extracols;
|
$this->extracols[$item->getID()] = $extracols;
|
||||||
$this->rawcontents[$item->getID()] = $rawcontent;
|
$this->rawcontents[$item->getID()] = $rawcontent;
|
||||||
|
$this->filenames[$item->getID()] = $filename;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
public function createToc($file) { /* {{{ */
|
public function createToc($file) { /* {{{ */
|
||||||
|
@ -190,6 +203,9 @@ class SeedDMS_Download_Mgr {
|
||||||
foreach($this->items as $item) {
|
foreach($this->items as $item) {
|
||||||
$document = $item->getDocument();
|
$document = $item->getDocument();
|
||||||
$dms = $document->_dms;
|
$dms = $document->_dms;
|
||||||
|
if($this->filenames[$item->getID()]) {
|
||||||
|
$filename = $this->filenames[$item->getID()];
|
||||||
|
} else {
|
||||||
$ext = pathinfo($document->getName(), PATHINFO_EXTENSION);
|
$ext = pathinfo($document->getName(), PATHINFO_EXTENSION);
|
||||||
$oext = pathinfo($item->getOriginalFileName(), PATHINFO_EXTENSION);
|
$oext = pathinfo($item->getOriginalFileName(), PATHINFO_EXTENSION);
|
||||||
if($ext == $oext)
|
if($ext == $oext)
|
||||||
|
@ -197,7 +213,9 @@ class SeedDMS_Download_Mgr {
|
||||||
else {
|
else {
|
||||||
$filename = preg_replace('/[^A-Za-z0-9_-]/', '_', $document->getName()).'.'.$oext;
|
$filename = preg_replace('/[^A-Za-z0-9_-]/', '_', $document->getName()).'.'.$oext;
|
||||||
}
|
}
|
||||||
$filename = $prefixdir."/".$document->getID().'-'.$item->getVersion().'-'.$filename; //$lc->getOriginalFileName();
|
$filename = $document->getID().'-'.$item->getVersion().'-'.$filename; //$lc->getOriginalFileName();
|
||||||
|
}
|
||||||
|
$filename = $prefixdir."/".$filename;
|
||||||
if($this->rawcontents[$item->getID()]) {
|
if($this->rawcontents[$item->getID()]) {
|
||||||
$zip->addFromString(utf8_decode($filename), $this->rawcontents[$item->getID()]);
|
$zip->addFromString(utf8_decode($filename), $this->rawcontents[$item->getID()]);
|
||||||
} else
|
} else
|
||||||
|
|
Loading…
Reference in New Issue
Block a user