mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 15:32:13 +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;
|
||||
|
||||
/**
|
||||
* @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 = '') {
|
||||
$this->tmpdir = $tmpdir;
|
||||
$this->items = array();
|
||||
|
@ -59,10 +71,11 @@ class SeedDMS_Download_Mgr {
|
|||
$this->extraheader = $extraheader;
|
||||
} /* }}} */
|
||||
|
||||
public function addItem($item, $extracols=array(), $rawcontent='') { /* {{{ */
|
||||
public function addItem($item, $extracols=array(), $rawcontent='', $filename='') { /* {{{ */
|
||||
$this->items[$item->getID()] = $item;
|
||||
$this->extracols[$item->getID()] = $extracols;
|
||||
$this->rawcontents[$item->getID()] = $rawcontent;
|
||||
$this->filenames[$item->getID()] = $filename;
|
||||
} /* }}} */
|
||||
|
||||
public function createToc($file) { /* {{{ */
|
||||
|
@ -190,14 +203,19 @@ class SeedDMS_Download_Mgr {
|
|||
foreach($this->items as $item) {
|
||||
$document = $item->getDocument();
|
||||
$dms = $document->_dms;
|
||||
$ext = pathinfo($document->getName(), PATHINFO_EXTENSION);
|
||||
$oext = pathinfo($item->getOriginalFileName(), PATHINFO_EXTENSION);
|
||||
if($ext == $oext)
|
||||
$filename = preg_replace('/[^A-Za-z0-9_.-]/', '_', $document->getName());
|
||||
else {
|
||||
$filename = preg_replace('/[^A-Za-z0-9_-]/', '_', $document->getName()).'.'.$oext;
|
||||
if($this->filenames[$item->getID()]) {
|
||||
$filename = $this->filenames[$item->getID()];
|
||||
} else {
|
||||
$ext = pathinfo($document->getName(), PATHINFO_EXTENSION);
|
||||
$oext = pathinfo($item->getOriginalFileName(), PATHINFO_EXTENSION);
|
||||
if($ext == $oext)
|
||||
$filename = preg_replace('/[^A-Za-z0-9_.-]/', '_', $document->getName());
|
||||
else {
|
||||
$filename = preg_replace('/[^A-Za-z0-9_-]/', '_', $document->getName()).'.'.$oext;
|
||||
}
|
||||
$filename = $document->getID().'-'.$item->getVersion().'-'.$filename; //$lc->getOriginalFileName();
|
||||
}
|
||||
$filename = $prefixdir."/".$document->getID().'-'.$item->getVersion().'-'.$filename; //$lc->getOriginalFileName();
|
||||
$filename = $prefixdir."/".$filename;
|
||||
if($this->rawcontents[$item->getID()]) {
|
||||
$zip->addFromString(utf8_decode($filename), $this->rawcontents[$item->getID()]);
|
||||
} else
|
||||
|
|
Loading…
Reference in New Issue
Block a user