CMS MADE SIMPLE FORGE

plFileHandler

 

[#7563] don't display multi files

avatar
Created By: jean-christophe ghio (jissey)
Date Submitted: Sun Feb 05 12:04:10 -0500 2012

Assigned To: Pierre-Luc Germain (plger)
Version: plFileHandler 0.6
CMSMS Version: 1.10.2
Severity: None
Resolution: None
State: Open
Summary:
don't display multi files
Detailed Description:
hi, and thanks for this great job,
when' Allow multiple files', only one file is displayed in the template.
I do this hack in action_default.php :
if($currentvalue){
$fichier = explode(',', $currentvalue);
$html_file = array();
	foreach($fichier as $fic) {
		if(!$absolute_paths){
			$burl = $gCms->config['uploads_url'];
			$fic = $burl.(substr($fic,0,1)=='/'?'':'/').$fic;
			$fic = str_replace($burl.'/'.$burl, $burl.'/', $fic);
		}
		$extension = strtolower(substr(strrchr($fic, "."), 1));
		if(in_array($extension, array('jpeg','jpg','gif','png'))){
			$parts = explode('/',$fic);
			$parts[count($parts)-1] = 'thumb_'.$parts[count($parts)-1];
			$thumburl = implode('/',$parts);
			if(file_exists($this->get_path_from_url($thumburl))){
				$pic = '<img src="'.$thumburl.'" alt=""/>';
			}else{
				$pic = '<img src="'.$this->GetFileIcon($fic).'" alt=""/>';
			}
		}else{
			$pic = '<img src="'.$this->GetFileIcon($fic).'" alt=""/>';
		}
		$html_file[] = $pic."<p>".basename($fic)."</p>";
	}
}
...
$this->smarty->assign('current_name', $html_file);

and another hack in plFileHandler.js
	do_return: function(returnValue, pictoshow){
		if(this.returnInputId && returnValue){
			document.getElementById(this.returnInputId).value = returnValue;
			var fileobj = document.getElementById(this.returnInputId+'_currentfile');
			if(fileobj && pictoshow){
			fileobj.innerHTML = '';
			fichier = returnValue.split(','); //ajout jcg
			for(var i= 0; i < fichier.length; i++) {
				var thepic = document.createElement('img');
				thepic.src = pictoshow;
fileobj.appendChild(thepic); //jcg attention le pic est toujours le meme.
revient bon à l'affichage suivant.
				var thep = document.createElement('p');
				thep.innerHTML = fichier[i].split('/').pop();
				fileobj.appendChild(thep);
			}
			}
		}
		this.hide();
	},
needs to be improved


History