mirror of
				https://git.code.sf.net/p/seeddms/code
				synced 2025-10-31 05:11:27 +00:00 
			
		
		
		
	Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
		
						commit
						8e6828e36d
					
				|  | @ -6,7 +6,9 @@ Header set X-Content-Type-Options: "nosniff" | |||
| </IfModule> | ||||
| 
 | ||||
| RewriteEngine On | ||||
| RewriteRule ^favicon.ico$ views/bootstrap/images/favicon.svg [L] | ||||
| #RewriteRule "^favicon\.ico$" "-" [L] | ||||
| #RewriteRule "^(favicon\.ico)$" %{HTTP_HOST}/views/bootstrap/images/favicon.svg [L,NC] | ||||
| RewriteRule "(favicon\.ico)" /views/bootstrap/images/favicon.svg [L,NC] | ||||
| 
 | ||||
| # Store the current location in an environment variable CWD to use | ||||
| # mod_rewrite in .htaccess files without knowing the RewriteBase | ||||
|  |  | |||
|  | @ -16,10 +16,10 @@ application/msword | |||
|   catdoc %s | ||||
| 
 | ||||
| application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | ||||
|   xlsx2csv %s | ||||
|   xlsx2csv -d tab %s | ||||
| 
 | ||||
| application/vnd.ms-excel | ||||
|   xls2csv %s | ||||
|   xls2csv -d tab %s | ||||
| 
 | ||||
| text/html | ||||
|   html2text %s | ||||
|  | @ -48,7 +48,7 @@ text/rtf | |||
| image/png | ||||
| image/jpg | ||||
| image/jpeg | ||||
|   convert -f pdf -density 300 '%f' '%o' | ||||
|   convert -density 300 '%f' 'pdf:%o' | ||||
| 
 | ||||
| application/vnd.ms-powerpoint | ||||
| application/vnd.openxmlformats-officedocument.presentationml.presentation | ||||
|  | @ -71,16 +71,22 @@ It basically instructs you to comment out the line | |||
| 
 | ||||
| in /etc/ImageMagick-6/policy.xml | ||||
| 
 | ||||
| convert determines the format of the converted image from the extension of | ||||
| the output filename. SeedDMS usually sets a propper extension when running | ||||
| the command, but nevertheless it is good practice to explicitly set the output | ||||
| format by prefixing the output filename with 'png:'. This is of course always | ||||
| needed if the output goes to stdout. | ||||
| 
 | ||||
| image/jpg | ||||
| image/jpeg | ||||
| image/png | ||||
|   convert -resize %wx '%f' '%o' | ||||
|   convert -resize %wx '%f' 'png:%o' | ||||
| 
 | ||||
| application/pdf | ||||
|   gs -dBATCH -dNOPAUSE -sDEVICE=png16m -dPDFFitPage -r72x72 -sOutputFile=- -dFirstPage=1 -dLastPage=1 -q '%f' | convert -resize %wx png:- '%o' | ||||
| 
 | ||||
| text/plain | ||||
|   a2ps -1 -a1 -R -B -o - '%f' | gs -dBATCH -dNOPAUSE -sDEVICE=png16m -dFirstPage=1 -dLastPage=1 -dPDFFitPage -r72x72 -sOutputFile=- -q - | convert -resize %wx png:- '%o' | ||||
|   a2ps -1 -a1 -R -B -o - '%f' | gs -dBATCH -dNOPAUSE -sDEVICE=png16m -dFirstPage=1 -dLastPage=1 -dPDFFitPage -r72x72 -sOutputFile=- -q - | convert -resize %wx png:- 'png:%o' | ||||
| 
 | ||||
| application/msword | ||||
| application/vnd.oasis.opendocument.spreadsheet | ||||
|  | @ -93,5 +99,5 @@ application/vnd.ms-powerpoint | |||
| text/csv | ||||
| application/csv | ||||
| application/vnd.wordperfect | ||||
|   unoconv -d document -e PageRange=1 -f pdf --stdout -v '%f' | gs -dBATCH -dNOPAUSE -sDEVICE=pngalpha -dPDFFitPage -r72x72 -sOutputFile=- -dFirstPage=1 -dLastPage=1 -q - | convert -resize %wx png:- '%o' | ||||
|   unoconv -d document -e PageRange=1 -f pdf --stdout -v '%f' | gs -dBATCH -dNOPAUSE -sDEVICE=pngalpha -dPDFFitPage -r72x72 -sOutputFile=- -dFirstPage=1 -dLastPage=1 -q - | convert -resize %wx png:- 'png:%o' | ||||
| 
 | ||||
|  |  | |||
|  | @ -47,6 +47,10 @@ class SeedDMS_ConversionMgr { | |||
| 			return false; | ||||
| 	} | ||||
| 
 | ||||
| 	public function getServices() { | ||||
| 		return $this->services; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Convert a file | ||||
| 	 * | ||||
|  |  | |||
|  | @ -49,6 +49,18 @@ abstract class SeedDMS_ConversionServiceBase { | |||
| 		return 'Conversion service'; | ||||
| 	} | ||||
| 
 | ||||
| 	public function getAdditionalParams() { /* {{{ */ | ||||
| 		return []; | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	/** | ||||
| 	 * This method does the conversion | ||||
| 	 * | ||||
| 	 * It either returns the content of converted file (if $target is null) | ||||
| 	 * or writes the converted file into $target and returns true on success | ||||
| 	 * or false on error. | ||||
| 	 */ | ||||
| 	public function convert($infile, $target = null, $params = array()) { | ||||
| 		return false; | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -98,28 +98,95 @@ class SeedDMS_ConversionServiceExec extends SeedDMS_ConversionServiceBase { | |||
| 		$this->timeout = 5; | ||||
| 	} | ||||
| 
 | ||||
| 	public function getInfo() { | ||||
| 		return "Convert with command '".$this->cmd."'"; | ||||
| 	} | ||||
| 
 | ||||
| 	public function getAdditionalParams() { /* {{{ */ | ||||
| 		/* output format is an image and the command has a placeholder for the | ||||
| 		 * width of the converted image, then allow to set the width. | ||||
| 		 */ | ||||
| 		if(substr($this->to, 0, 6) == 'image/' && strpos($this->cmd, '%w') !== false) | ||||
| 			return [ | ||||
| 				['name'=>'width', 'type'=>'number', 'description'=>'Width of converted image'], | ||||
| 			]; | ||||
| 		return []; | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Convert by running an external command | ||||
| 	 * | ||||
| 	 * The command was set when calling the constructor. The command may | ||||
| 	 * either write a file or to stdout, depending on the placeholder '%o' | ||||
| 	 * either exists or not in the command. If $target is null, but the | ||||
| 	 * command writes to a file, it will create a temporary file, write | ||||
| 	 * ot it and read the content back to be returned by the method. | ||||
| 	 */ | ||||
| 	public function convert($infile, $target = null, $params = array()) { | ||||
| 		/* if no %f placeholder is found, we assume output to stdout */ | ||||
| 		$tostdout = strpos($this->cmd, '%o') === false; | ||||
| 
 | ||||
| 		$format = ''; | ||||
| 		switch($this->to) { | ||||
| 		case 'image/gif': | ||||
| 			$format = 'gif'; | ||||
| 			break; | ||||
| 		case 'image/jpg': | ||||
| 		case 'image/jpeg': | ||||
| 			$format = 'jpg'; | ||||
| 			break; | ||||
| 		case 'image/png': | ||||
| 			$format = 'png'; | ||||
| 			break; | ||||
| 		case 'application/pdf': | ||||
| 			$format = 'pdf'; | ||||
| 			break; | ||||
| 		} | ||||
| 		$start = microtime(true); | ||||
| 		if(!$target) | ||||
| 		$hastempfile = false; | ||||
| 		if(!$target && !$tostdout) { | ||||
| 			$tmpfile = tempnam(sys_get_temp_dir(), 'convert'); | ||||
| 		else | ||||
| 			/* Some programms (e.g. unoconv) need the output file to have the | ||||
| 			 * right extension. Without an extension it will add one by itself. | ||||
| 			 */ | ||||
| 			if($format) | ||||
| 				rename($tmpfile, $tmpfile .= '.'.$format); | ||||
| 			$hastempfile = true; | ||||
| 		} else | ||||
| 			$tmpfile = $target; | ||||
| 		$cmd = str_replace(array('%w', '%f', '%o', '%m'), array(isset($params['width']) ? $params['width'] : '', $infile, $tmpfile, $this->from), $this->cmd); | ||||
| 		/* %s was just added because the commands to convert to text/plain used | ||||
| 		 * it instead of %f for the input file | ||||
| 		 * %f = input file | ||||
| 		 * %o = output file | ||||
| 		 * %m = mime type | ||||
| 		 * %w = width | ||||
| 		 */ | ||||
| 		$cmd = str_replace(array('%w', '%f', '%s', '%if', '%o', '%m'), array(!empty($params['width']) ? (int) $params['width'] : '150', $infile, $infile, $format, $tmpfile, $this->from), $this->cmd); | ||||
| 		try { | ||||
| 			self::execWithTimeout($cmd, $this->timeout); | ||||
| 			$ret = self::execWithTimeout($cmd, $this->timeout); | ||||
| 		} catch(Exception $e) { | ||||
| 			if($hastempfile) | ||||
| 				unlink($tmpfile); | ||||
| 			return false; | ||||
| 		} | ||||
| 		$end = microtime(true); | ||||
| 		if($this->logger) { | ||||
| 			$this->logger->log('Conversion from '.$this->from.' to '.$this->to.' with cmd "'.$this->cmd.'" took '.($end-$start).' sec.', PEAR_LOG_INFO); | ||||
| 			$this->logger->log('Conversion from '.$this->from.' to '.$this->to.' with cmd "'.$this->cmd.'" took '.($end-$start).' sec.', PEAR_LOG_DEBUG); | ||||
| 		} | ||||
| 		if(!$target) { | ||||
| 			$content = file_get_contents($tmpfile); | ||||
| 			unlink($tmpfile); | ||||
| 			return $content; | ||||
| 		if($tostdout) { | ||||
| 			if(!$target) { | ||||
| 				return $ret['stdout']; | ||||
| 			} else { | ||||
| 				return file_put_contents($tmpfile, $ret['stdout']); | ||||
| 			} | ||||
| 		} else { | ||||
| 			return true; | ||||
| 			if(!$target) { | ||||
| 				$content = file_get_contents($tmpfile); | ||||
| 				unlink($tmpfile); | ||||
| 				return $content; | ||||
| 			} else { | ||||
| 				return true; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -34,12 +34,22 @@ class SeedDMS_ConversionServiceImageToImage extends SeedDMS_ConversionServiceBas | |||
| 		$this->timeout = 5; | ||||
| 	} | ||||
| 
 | ||||
| 	public function getInfo() { | ||||
| 		return "Convert with imagick php functions"; | ||||
| 	} | ||||
| 
 | ||||
| 	public function getAdditionalParams() { /* {{{ */ | ||||
| 		return [ | ||||
| 			['name'=>'width', 'type'=>'number', 'description'=>'Width of converted image'] | ||||
| 		]; | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	public function convert($infile, $target = null, $params = array()) { | ||||
| 		$start = microtime(true); | ||||
| 		$imagick = new Imagick(); | ||||
| 		if($imagick->readImage($infile)) { | ||||
| 			if(!empty($params['width'])) | ||||
| 				$imagick->scaleImage((int) $params['width'], 0); | ||||
| 				$imagick->scaleImage(min((int) $params['width'], $imagick->getImageWidth()), 0); | ||||
| 			$end = microtime(true); | ||||
| 			if($this->logger) { | ||||
| 				$this->logger->log('Conversion from '.$this->from.' to '.$this->to.' with image service took '.($end-$start).' sec.', PEAR_LOG_INFO); | ||||
|  |  | |||
|  | @ -34,6 +34,17 @@ class SeedDMS_ConversionServicePdfToImage extends SeedDMS_ConversionServiceBase | |||
| 		$this->timeout = 5; | ||||
| 	} | ||||
| 
 | ||||
| 	public function getInfo() { | ||||
| 		return "Convert with imagick php functions"; | ||||
| 	} | ||||
| 
 | ||||
| 	public function getAdditionalParams() { /* {{{ */ | ||||
| 		return [ | ||||
| 			['name'=>'width', 'type'=>'number', 'description'=>'Width of converted image'], | ||||
| 			['name'=>'page', 'type'=>'number', 'description'=>'Page of Pdf document'], | ||||
| 		]; | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	public function convert($infile, $target = null, $params = array()) { | ||||
| 		$start = microtime(true); | ||||
| 		$imagick = new Imagick(); | ||||
|  | @ -41,9 +52,12 @@ class SeedDMS_ConversionServicePdfToImage extends SeedDMS_ConversionServiceBase | |||
| 		 * A resolution of 72,72 will create a 596x842 image | ||||
| 		 */ | ||||
| 		$imagick->setResolution(36,36); | ||||
| 		if($imagick->readImage($infile.'[0]')) { | ||||
| 		$page = 0; | ||||
| 		if(!empty($params['page']) && intval($params['page']) > 0) | ||||
| 			$page = intval($params['page'])-1; | ||||
| 		if($imagick->readImage($infile.'['.$page.']')) { | ||||
| 			if(!empty($params['width'])) | ||||
| 				$imagick->scaleImage((int) $params['width'], 0); | ||||
| 				$imagick->scaleImage(min((int) $params['width'], $imagick->getImageWidth()), 0); | ||||
| 			$imagick->setImageFormat('png'); | ||||
| 			$end = microtime(true); | ||||
| 			if($this->logger) { | ||||
|  |  | |||
|  | @ -28,6 +28,10 @@ class SeedDMS_ConversionServiceTextToText extends SeedDMS_ConversionServiceBase | |||
| 		$this->to = $to; | ||||
| 	} | ||||
| 
 | ||||
| 	public function getInfo() { | ||||
| 		return "Pass through document contents"; | ||||
| 	} | ||||
| 
 | ||||
| 	public function convert($infile, $target = null, $params = array()) { | ||||
| 		if($target) { | ||||
| 			file_put_contents($target, file_get_contents($infile)); | ||||
|  |  | |||
|  | @ -15,6 +15,12 @@ if(!empty($settings->_converters['pdf'])) { | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| if(!empty($settings->_converters['fulltext'])) { | ||||
| 	foreach($settings->_converters['fulltext'] as $mimetype=>$cmd) { | ||||
| 		$conversionmgr->addService(new SeedDMS_ConversionServiceExec($mimetype, 'text/plain', $cmd))->setLogger($logger); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| $conversionmgr->addService(new SeedDMS_ConversionServicePdfToImage('application/pdf', 'image/png'))->setLogger($logger); | ||||
| 
 | ||||
| $conversionmgr->addService(new SeedDMS_ConversionServiceImageToImage('image/jpeg', 'image/png'))->setLogger($logger); | ||||
|  |  | |||
|  | @ -412,7 +412,7 @@ function add_log_line($msg="", $priority=null) { /* {{{ */ | |||
| 	elseif(!empty($_SERVER['REMOTE_ADDR'])) | ||||
| 		$ip = $_SERVER['REMOTE_ADDR']; | ||||
| 	if(!empty($_SERVER["REQUEST_URI"])) | ||||
| 		$scriptname = basename($_SERVER["REQUEST_URI"], ".php").' '; | ||||
| 		$scriptname = basename($_SERVER["REQUEST_URI"]).' '; | ||||
| 	else | ||||
| 		$scriptname = basename($_SERVER["SCRIPT_NAME"]).' '; | ||||
| 	if($user) | ||||
|  |  | |||
|  | @ -89,6 +89,13 @@ class SeedDMS_View_ExtensionMgr extends SeedDMS_Theme_Style { | |||
| 				}); | ||||
| 			}); | ||||
| 		}); | ||||
| 		/* This function is called after the list of installed extension is updated */ | ||||
| 		function filterList() { | ||||
| 			var value = $("#extensionfilter").val().toLowerCase(); | ||||
| 			$("#extensionlist tbody tr").filter(function() { | ||||
| 				$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1) | ||||
| 			}); | ||||
| 		} | ||||
| <?php | ||||
| 
 | ||||
| 		$this->printFileChooserJs(); | ||||
|  | @ -280,7 +287,7 @@ class SeedDMS_View_ExtensionMgr extends SeedDMS_Theme_Style { | |||
| 		<div class="tab-content"> | ||||
| 			<div class="tab-pane <?php if(!$currenttab || $currenttab == 'installed') echo 'active'; ?>" id="installed" role="tabpanel"> | ||||
| 			<input id="extensionfilter" class="form-control" type="text" placeholder="<?= getMLText('type_to_filter'); ?>"> | ||||
| 	<div class="ajax" data-view="ExtensionMgr" data-action="installedList"></div> | ||||
| 	<div class="ajax" data-view="ExtensionMgr" data-action="installedList" data-afterload="()=>{filterList();}"></div> | ||||
| <?php | ||||
| //		$this->installedList();
 | ||||
| ?>
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Uwe Steinmann
						Uwe Steinmann