ich habe das Modul um eine Sortierung (Dateiname, Medienname, Erstellungsdatum, Änderungsdatum, Absteigen, Aufsteigend, Zufällig) in der Templatekonfiguration ergänzt, wobei leider "Medienname" und "Zufällig" noch nicht funktionert. wer hierfür einen Lösung hat. Bitte posten!
Im Template kann man nun auch anzeigen lassen, ob überhaupt eine Downloadliste angezeigt werden soll:
Code: Alles auswählen
<?php
$Downloadzeigen="CMS_VALUE[8822]";
$Downloadsortierungnach="CMS_VALUE[8823]";
$Downloadsortierung="CMS_VALUE[8824]";
if ($Downloadzeigen== "") {
} else {
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname : Download List
* Author(s) : Stefan Seifarth <info@polycoder.de>
* Copyright : www.polycoder.de / www.htcm.de
* Created : 2006-01-07
* Modified : 2006-11-07
************************************************/
cInclude ("classes", "class.upload.php");
cInclude ("classes", "class.properties.php");
cInclude ("classes", "class.htmlelements.php");
cInclude ("includes", "functions.upl.php");
// template defined vars
$dllist_path = "CMS_VALUE[110]";
$dllist_extensions = trim("CMS_VALUE[111]");
$dllist_idart = trim("CMS_VALUE[112]");
$dllist_filenamefilter = trim("CMS_VALUE[113]");
// add filetype condition
$str_where_filetype = "";
if ( strlen ($dllist_extensions) > 0) {
$arr_extensions = explode (",",$dllist_extensions);
$arr_where = array();
foreach ($arr_extensions as $str_extension) {
$arr_where[] = "filetype ='" . trim($str_extension) . "'";
}
$str_where_filetype = ' ( ' . implode( " OR ", $arr_where ) . ' ) AND ';
}
// add filename filter condition
$str_where_filenamefilter = "";
if ( strlen ($dllist_filenamefilter) > 0) {
$arr_filenamefilter = explode(";", $dllist_filenamefilter);
$arr_where = array();
foreach ($arr_filenamefilter as $str_filenamefilter) {
$str_filenamefilter = trim($str_filenamefilter);
// replace special chars for wildcards
$str_filenamefilter = str_replace("%","\%", $str_filenamefilter);
$str_filenamefilter = str_replace("_","\_", $str_filenamefilter);
$str_filenamefilter = str_replace("*","%", $str_filenamefilter);
$str_filenamefilter = str_replace("?","_", $str_filenamefilter);
$arr_where[] = ' filename LIKE "' . mysql_escape_string($str_filenamefilter) . '"';
}
$str_where_filenamefilter = ' ( ' . implode( " OR ", $arr_where ) . ' ) AND ';
}
// get list of all files
$dllist_collection = new UploadCollection ();
// $dllist_collection->select($str_where_filenamefilter . $str_where_filetype . " dirname = '" . $dllist_path . "'","","filename DESC");
$dllist_collection->select($str_where_filenamefilter . $str_where_filetype . " dirname = '" . $dllist_path . "'","","$Downloadsortierungnach $Downloadsortierung");
// initialize needed objects
$obj_file_properties = new PropertyCollection();
$obj_icon = new cHTMLImage();
$obj_description = new cHTMLDIV();
// reset template
$tpl = new Template();
$tpl->reset();
// add head description
$tpl->set("s","HEAD_NAME", mi18n("file-name") );
$tpl->set("s","HEAD_FILETYPE", mi18n("file-typ") );
$tpl->set("s","HEAD_FILESIZE", mi18n("size") );
$tpl->set("s","HEAD_COUNTER", mi18n("<h3>downloads</h3>"));
$tpl->set("s","SUMMARY", mi18n("Table of Files and Folder for Download") );
$tpl->set("s","CAPTION", mi18n("downloadlist") );
$tpl->set("s","BACK", mi18n("« back") );
$tpl->set("s","HEAD_FILECREATED", mi18n("Created") );
$tpl->set("s","HEAD_FILEMODIFIED", mi18n("Last edit") );
// run file list
$image_id = 0;
$filetypname = mi18n("file-type ");
while ($dllist_item = $dllist_collection->next() ) {
$image_id++;
// icon for file
$obj_icon->setSrc( uplGetFileIcon($dllist_item->get("filename")) );
$obj_icon->updateAttributes(array ("alt" => "$filetypname"));
$obj_icon->setID("dlIco".$image_id);
// file description
$str_file_description = "";
if (strlen($dllist_item->get("description"))> 0) {
$obj_description->setContent($dllist_item->get("description"));
$obj_description->setClass("fileDescription");
$obj_description->removeAttribute("id");
$obj_description->removeAttribute("class");
$str_file_description = $obj_description->toHTML();
}
// filename
$str_file_name = $dllist_item->get("filename");
$str_file_name_property = $obj_file_properties->getValue("upload", $dllist_item->get("dirname").$dllist_item->get("filename"), "file", "medianame");
if (strlen($str_file_name_property) > 0) {
$str_file_name = $str_file_name_property;
}
// VL Medienname auslesen ab 4.8.8
$query= "SELECT medianame,description FROM " . $cfg["tab"]["upl_meta"] . " WHERE idupl = " . $dllist_item->get("idupl");
$result = mysql_query($query);
$medianame = "";
if ($row= mysql_fetch_array($result)) {
$medianame = $row['medianame'];
$file_description = $row['description'];
}
if (strlen($medianame) > 0) {
$str_file_name = htmlspecialchars(urldecode($medianame));
}
$medianame_old = "";
$medianame_old = $obj_file_properties->getValue("upload", $dllist_item->get("dirname").$dllist_item->get("filename"), "file", "medianame");
if (strlen($medianame_old) > 0) {
$str_file_name = $medianame_old;
}
// filecounter
$str_file_counter = "0";
$str_file_counter_property = $obj_file_properties->getValue("upload", $dllist_item->get("dirname").$dllist_item->get("filename"), "file", "counter");
if ( strlen ($str_file_counter_property) > 0 ) {
$str_file_counter = $str_file_counter_property;
}
// file url
$str_file_url = $cfgClient[$client]["upl"]["htmlpath"] . $dllist_item->get("dirname") . $dllist_item->get("filename");
if ( isset($dllist_idart) && !empty($dllist_idart) && (int)$dllist_idart > 0 ) {
$str_file_url = $sess->url("front_content.php?idart=" . $dllist_idart . "&changelang=" . $lang . "&client=" . $client . "&sse_idupl=" . $dllist_item->get("idupl") );
}
// file time
$str_file_modified = "";
$str_file_created = "";
if ( file_exists($cfgClient[$client]["upl"]["path"] . $dllist_item->get("dirname") . $dllist_item->get("filename")) ) {
// $str_file_modified = date("d.m.Y H:i", filemtime($cfgClient[$client]["upl"]["path"] . $dllist_item->get("dirname") . $dllist_item->get("filename") ));
// $str_file_created = date("d.m.Y H:i", filectime($cfgClient[$client]["upl"]["path"] . $dllist_item->get("dirname") . $dllist_item->get("filename") ));
$str_file_modified = date("d.m.Y", filemtime($cfgClient[$client]["upl"]["path"] . $dllist_item->get("dirname") . $dllist_item->get("filename") ));
$str_file_created = date("d.m.Y", filectime($cfgClient[$client]["upl"]["path"] . $dllist_item->get("dirname") . $dllist_item->get("filename") ));
}
// fill template
$tpl->set("d", "FILE_ICON", $obj_icon->toHTML() . ' ');
$tpl->set("d", "FILE_NAME", $str_file_name );
$tpl->set("d", "FILE_TYPE", $dllist_item->get("filetype") );
$tpl->set("d", "FILE_SIZE", human_readable_size($dllist_item->get("size")) );
$tpl->set("d", "FILE_COUNTER", $str_file_counter );
$tpl->set("d", "FILE_DESCRIPTION", $str_file_description );
$tpl->set("d", "FILE_URL", $str_file_url );
$tpl->set("d", "FILE_INFO1", mi18n("is a") );
$tpl->set("d", "FILE_INFO2", mi18n("-file and") );
$tpl->set("d", "FILE_INFO3", mi18n("large") );
$tpl->set("d", "FILE_TYPE_INFO", mi18n("Info: File-Type") );
$tpl->set("d", "FILE_SIZE_INFO", mi18n("File-Size") );
$tpl->set("d", "FILE_COUNTER_INFO", mi18n("Downloads") );
$tpl->set("d", "FILE_INFO0", mi18n("Please click to open / save") );
$tpl->set("d", "FILE_FILECREATED", mi18n("Created") );
$tpl->set("d", "FILE_FILEMODIFIED", mi18n("Last edit") );
$tpl->set("d", "FILE_CREATED", $str_file_created);
$tpl->set("d", "FILE_MODIFIED", $str_file_modified );
$tpl->set("d", "FILE_DATE", $str_filetime_modified );
$tpl->set("d", "xxx", mi18n("xx") );
$tpl->next();
}
// set template
$str_template_name = "download_list.html";
if ( isset($dllist_idart) && !empty($dllist_idart) && (int)$dllist_idart > 0 ) {
$str_template_name = "download_list_counter.html";
}
// print template
print $tpl->generate($cfgClient[$client]["tpl"]["path"] . $str_template_name, 1, 0);
};