Endless Downloadliste
Verfasst: Fr 18. Feb 2005, 19:46
Hallo,
Nachdem ich mit der Downloadliste nicht ganz zufrieden war, hab ich mal eine neue programmiert
Features:
-> unbegrenzte Anzahl an Downloads
-> Mehrmandantenfähig
-> Ausgabe mit fileSize und Dateityp Icon
-> Eingabe eines Linktextes
Wichtig:
Ihr braucht die Erweiterung aus diesem Thread:
http://contenido.org/forum/viewtopic.php?t=3590
Ist zwar noch nicht viel getestet, klappt bei mir aber einwandfrei. Contenido 4.4.4
Viel Spaß damit:
Input:
Output:
In der function uplGetFileIcon bitte an eure Filetypen anpassen, bzw. die Bilder erstellen.
lg
Wenzel
Nachdem ich mit der Downloadliste nicht ganz zufrieden war, hab ich mal eine neue programmiert

Features:
-> unbegrenzte Anzahl an Downloads
-> Mehrmandantenfähig
-> Ausgabe mit fileSize und Dateityp Icon
-> Eingabe eines Linktextes
Wichtig:
Ihr braucht die Erweiterung aus diesem Thread:
http://contenido.org/forum/viewtopic.php?t=3590
Ist zwar noch nicht viel getestet, klappt bei mir aber einwandfrei. Contenido 4.4.4
Viel Spaß damit:
Input:
Code: Alles auswählen
/***********************************************
* CONTENIDO MODUL - INPUT
*
* Endless Unique Downloadlist
*
* Author: Wenzel Wondra <wondra@it-studio.com>
* Copyright: (c)2005 IT Studio Hendrich & Wondra OEG
* Created: 17-02-2005
* Modified: 18-02-2005
************************************************/
$query = "SELECT * FROM ".$cfg["tab"]["upl"]." WHERE idclient='$client' AND filetype IN ('pdf', 'tif', 'zip', 'doc')";
$db->query($query);
while ($db->next_record()){
$medias[] = array('idupl'=> $db->f('idupl'), 'filename' =>$db->f('filename'));
}
echo '<table><tr><td class="text_medium"><b>Datei</b></td><td class="text_medium"><b>Linktext</b></td>';
$CMS_VALUE = array_unique($CMS_VALUE);
for ($i=0; $i <= count($CMS_VALUE); $i+=2){
echo "<tr><td>";
echo '<select name="CMS_VAR['.$i.']">';
echo "<option value='0'>-- kein --</option>\n";
foreach ($medias as $media){
($CMS_VALUE[$i] == $media['idupl'] ) ? $sel = " selected='selected' " : $sel = "";
echo "<option value='". $media['idupl']."' $sel >".$media['filename']."</option>\n";
}
echo "</select>";
echo '</td><td><input type="text" value="'. $CMS_VALUE[($i+1)] .'" name="CMS_VAR['.($i+1).']" />';
echo "</td></tr>";
}
echo "</table>";
unset($medias);
Output:
Code: Alles auswählen
<?PHP
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Endless Unique Downloadlist
*
* Author: Wenzel Wondra <wondra@it-studio.com>
* Copyright: (c)2005 IT Studio Hendrich & Wondra OEG
* Includes three functions from Contenido 4.5.2_cvs (functions.upl.php)
* Created: 17-02-2005
* Modified: 18-02-2005
************************************************/
$db2 = new DB_Contenido;
echo "<h1>Downloads:</h1>\n";
if ($edit)
echo "Liste wird nur in der Preview und im Frontend dargestellt!!";
for ($i=0; $i < count($CMS_VALUE); $i+=2){
if ($CMS_VALUE[$i] != 0){
$sql = "SELECT * FROM " . $cfg['tab']['upl']. " WHERE idupl= $CMS_VALUE[$i]";
$db2->query($sql);
$db2->next_record();
$data_local= $cfgClient[$client]["upl"]["path"]. $db2->f('dirname'). $db2->f('filename');
$data_http= $cfgClient[$client]["upl"]["htmlpath"]. $db2->f('dirname'). $db2->f('filename');
echo "<p class='download'>\n";
echo "<img src=".uplGetFileIcon($data_local)." alt=". getFileExtension($data_local)." /> ";
echo "<a href='$data_http'>".$CMS_VALUE[($i+1)]." (Dateigröße ". human_readable_size(filesize($data_local)).")</a>";
echo "</p>\n";
}
}
unset($data_local);
unset($data_http);
/*****************************************
* File : $RCSfile: functions.upl.php,v $
* Project : Contenido
* Descr : Upload functions*
* Author : $Author: timo.hummel $*
* Created : 28.12.2003
* Modified : $Date: 2004/06/01 16:39:27 $
*
* © four for business AG, www.4fb.de
*
* $Id: functions.upl.php,v 1.16.2.2 2004/06/01 16:39:27 timo.hummel Exp $
******************************************/
function getFileExtension($filename)
{
$dotposition = strrpos($filename, ".");
if ($dotposition !== false)
{
return (strtolower(substr($filename, $dotposition + 1)));
} else {
return false;
}
}
function human_readable_size( $number )
{
$base = 1024;
$suffixes = array( " B", " KB", " MB", " GB", " TB", " PB", " EB" );
$usesuf = 0;
$n = (float) $number; //Appears to be necessary to avoid rounding
while( $n >= $base )
{
$n /= (float) $base;
$usesuf++;
}
$places = 2 - floor( log10( $n ) );
$places = max( $places, 0 );
$retval = number_format( $n, $places, ".", "" ) . $suffixes[$usesuf];
return $retval;
}
/**
* Returns the icon for a file type
* Edited for Contenido 4.4.4
* @param $file Filename to retrieve the extension for
*
* @return Icon for the file type
*
*/
function uplGetFileIcon ($file)
{
global $cfg;
switch (getFileExtension($file))
{
case "sxi":
case "sti":
case "pps":
case "pot":
case "kpr":
case "ppt": $icon = "ppt.gif";
break;
case "doc":
case "dot":
case "sxw":
case "stw":
case "sdw":
case "kwd": $icon = "upl_text.gif";
break;
case "xls":
case "sxc":
case "stc":
case "xlw":
case "xlt":
case "csv":
case "ksp":
case "sdc": $icon = "excel.gif";
break;
case "txt":
case "rtf": $icon = "txt.gif";
break;
case "gif": $icon = "gif.gif";
break;
case "png": $icon = "png.gif";
break;
case "jpeg":
case "jpg": $icon = "jpg.gif";
break;
case "html":
case "htm": $icon = "html.gif";
break;
case "lha":
case "rar":
case "arj":
case "bz2":
case "bz":
case "gz":
case "tar":
case "tbz2":
case "tbz":
case "tgz":
case "zip": $icon = "zip.gif";
break;
case "pdf": $icon = "pdf.gif";
break;
case "avi":
case "mpeg":
case 'mpg':
case 'asf':
case 'wmv':
$icon = "avi.gif"; break;
case "mov":
case "3gp":
case "mp4":
case 'mpeg4':
$icon = "mov.gif"; break;
case "rm" :
case "ram" : $icon = "real.gif"; break;
default: $icon = "upl_unknown.gif";
}
return $cfg['path']['contenido_fullhtml'] . $cfg["path"]["images"]. $icon;
}
?>
In der function uplGetFileIcon bitte an eure Filetypen anpassen, bzw. die Bilder erstellen.
lg
Wenzel