nicht getestet - aber probiere mal:
Modul "Download List" Input:
Code: Alles auswählen
?>
<?php
/***********************************************
* CONTENIDO MODUL - INPUT
*
* Modulname : Download List
* Author(s) : Stefan Seifarth <info@polycoder.de>
* Copyright : www.polycoder.de / www.htcm.de
* Created : 2006-01-07
* Modified : 2006-11-06
************************************************/
cInclude ("classes", "class.upload.php");
// get all directories from database
$dllist_collection = new UploadCollection ();
$dllist_collection->select("","dirname","dirname ASC");
$arr_found_dirs = array();
$arr_dirs = array();
while ( $dllist_item = $dllist_collection->next() ) {
$arr_found_dirs[] = $dllist_item->get("dirname");
}
$i = 0;
foreach ($arr_found_dirs as $str_dir) {
$arr_current_dir = explode("/",$str_dir );
array_pop($arr_current_dir);
$depth = count($arr_current_dir);
if ( $depth == 0 ) {
$arr_dirs[$i]["name"] = str_replace("/", "", $cfgClient[$client]["upload"]);
} else {
$arr_dirs[$i]["name"] = $arr_current_dir[$depth-1];
}
$arr_dirs[$i]["depth"] = $depth;
$arr_dirs[$i]["path"] = $str_dir;
$arr_dirs[$i]["indent"] = "";
for ($z = 1; $z <= $depth; $z ++) {
# 3 blanks for every level
$arr_dirs[$i]["indent"] .= " ";
}
$i++;
}
// print out directory selectbox
$str_predefined = trim("CMS_VALUE[110]");
print mi18n("Verzeichnis für Downloads auswählen") . ":\n<br>";
print '<select name="CMS_VAR[110]">' . "\n";
// output of all found directories
foreach ( $arr_dirs as $arr_dir ) {
$str_selected = "";
if ( $str_predefined == $arr_dir["path"] ) $str_selected = ' selected="selected"';
print '<option value="' . $arr_dir["path"] . '"' . $str_selected . '>' . $arr_dir["indent"] . $arr_dir["name"] . '</option>' . "\n";
}
print '</select>' . "\n";
print '<br><br>' . "\n";
// print out fileextensions
print mi18n("sichtbare Dateiendungen<br>(leergelassen = alle Dateien, mehrere Dateitypen durch Komma abtrennen )") . ":\n<br>";
print '<input type="text" name="CMS_VAR[111]" value="CMS_VALUE[111]">' . "<br><br>\n";
// print out fileextensions
print mi18n("Dateifilter<br>(leergelassen = alle Dateien, Filter wie unter Windows nutzen: ?datei*)") . ":\n<br>";
print '<input type="text" name="CMS_VAR[113]" value="CMS_VALUE[113]">' . "<br><br>\n";
// print out download article
print mi18n("Artikel idart für Downloadzähler<br>(leergelassen = Download ohne Zähler)") . ":\n<br>";
print '<input type="text" name="CMS_VAR[112]" value="CMS_VALUE[112]">' . "\n";
?>
<?php
Modul "Download List" Output:
Code: Alles auswählen
<?php
/***********************************************
* 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-06
************************************************/
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) {
// replace special chars for wildcards
$dllist_filenamefilter = str_replace("%","\%", $dllist_filenamefilter);
$dllist_filenamefilter = str_replace("_","\_", $dllist_filenamefilter);
$dllist_filenamefilter = str_replace("*","%", $dllist_filenamefilter);
$dllist_filenamefilter = str_replace("?","_", $dllist_filenamefilter);
$str_where_filenamefilter = ' filename LIKE "' . mysql_escape_string($dllist_filenamefilter) . '" AND ';
}
// get list of all files
$dllist_collection = new UploadCollection ();
$dllist_collection->select($str_where_filenamefilter . $str_where_filetype . " dirname = '" . $dllist_path . "'","","filename ASC");
// 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("Dateiname") );
$tpl->set("s","HEAD_FILETYPE", mi18n("Dateityp") );
$tpl->set("s","HEAD_FILESIZE", mi18n("Größe") );
$tpl->set("s","HEAD_COUNTER", mi18n("Downloads") );
// run file list
$image_id = 0;
while ($dllist_item = $dllist_collection->next() ) {
$image_id++;
// icon for file
$obj_icon->setSrc( uplGetFileIcon($dllist_item->get("filename")) );
$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");
$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;
}
// 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") );
}
// 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->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);
?>