Seite 1 von 1

Dateiverwaltung: Erweiterung der Upload-Funktion

Verfasst: Di 23. Jan 2007, 14:53
von wogr
Hallo,
anbei meine Erweiterung der Upload-Funktion. So können bereits beim Upload Informationen zu den Dateien eingegeben werden.

Es ist allerdings kein Modul, sondern eine Quelltext-Modifikation.

Installation wie folgt:
1. in der Datei

/Contenido-4.6.15/contenido/includes/include.upl_files_overview.php

den untenstehenden Abschnitt ÜBER der Zeile "if ($action == "upl_modify_file")" einfügen.

Oben eventuell ergänzen:

Code: Alles auswählen

cInclude("classes", "class.ui.php");
cInclude("classes", "class.htmlelements.php");
cInclude("includes", "api/functions.frontend.list.php");
cInclude("classes", "class.properties.php");
cInclude("classes", "class.todo.php");

Code: Alles auswählen

/**
 * @author wogr
 * 2006-12-05
 * A modified version of the upload method, which lets the user set the "Keywords" and "Internal notes" right in the uploading-dialog.
 * 
 * Other files of interest: include.upl_files_upload.php. 
 */
if ($action == "upl_withinfo") {
	$position = 0;
	if (count($_FILES) == 1) {
		foreach ($_FILES['file']['name'] as $key => $value) {
			if (file_exists($_FILES['file']['tmp_name'][$key])) {
				$tmp_name = $_FILES['file']['tmp_name'][$key];
				$_cecIterator = $_cecRegistry->getIterator("Contenido.Upload.UploadPreprocess");
				if ($_cecIterator->count() > 0) {
					/* Copy file to a temporary location */
					move_uploaded_file($tmp_name, $cfg["path"]["contenido"] . $cfg["path"]["temp"] . $_FILES['file']['name'][$key]);
					$tmp_name = $cfg["path"]["contenido"] . $cfg["path"]["temp"] . $_FILES['file']['name'][$key];
					while ($chainEntry = $_cecIterator->next()) {
						$modified = $chainEntry->execute($tmp_name, $cfgClient[$client]['upl']['path'] . $path . uplCreateFriendlyName($_FILES['file']['name'][$key]));
						if ($modified !== false) {
							$tmp_name = $modified;
						}
					}
				}
				if (is_dbfs($qpath)) {
					$dbfs->writeFromFile($tmp_name, $qpath . uplCreateFriendlyName($_FILES['file']['name'][$key]));
					unlink($tmp_name);
				} else {
					if (is_uploaded_file($tmp_name)) {
						move_uploaded_file($tmp_name, $cfgClient[$client]['upl']['path'] . $path . uplCreateFriendlyName($_FILES['file']['name'][$key]));
					} else {
						rename($tmp_name, $cfgClient[$client]['upl']['path'] . $path . uplCreateFriendlyName($_FILES['file']['name'][$key]));
					}
				}
			}
			/*
			echo "<br>************************************<br>";
			*/
			$filename = uplCreateFriendlyName($_FILES['file']['name'][$key]);
			/*
			echo "</br> position : " . $position;
			echo "</br> client   : " . $client;
			echo "</br> qpath    : " . $qpath;
			echo "</br> filename : " . $filename;
			echo "</br> keywords : " . $keywords[$position];
			echo "</br> medianotes : " . $medianotes[$position];
			*/
			/*
				$uploads->select("idclient = '$client' AND dirname = '$qpath' AND filename='$filename'");
				if ($upload = $uploads->next()){
					$upload->set("description", "beschreibung");
					$upload->store();
						
				echo "</br> desc : ".$description;				
			*/
			$properties = new PropertyCollection;
			$properties->setValue("upload", $qpath . $filename, "file", "medianame", stripslashes($medianame[$position]));
			$properties->setValue("upload", $qpath . $filename, "file", "keywords", stripslashes($keywords[$position]));
			$properties->setValue("upload", $qpath . $filename, "file", "medianotes", stripslashes($medianotes[$position]));
			$position = $position +1;
		} // end for each	
	}
}
/* wogr end */

2. In der Datei
/Contenido-4.6.15/contenido/includes/include.upl_files_upload.php
die Aktion "action" wie folgt ändern:

Code: Alles auswählen

$form->setVar("action", "upl_withinfo");
Schön wäre hier eine Erweiterung um die Beschreibung, so dass diese auch bereits beim Upload eingegeben werden kann. Weitere Ergänzungen und Verbesserungen sind willkommen!

Verfasst: Di 23. Jan 2007, 17:21
von HerrB
Bitte noch das SQL-Statement für die Action ergänzen.

Gruß
HerrB