<?php
$igOption = new CBOption();
$igOption->setModule("gallery");
$igOption->getOptionList();
if(!empty($gid) && ereg("(^[1-9]?[0-9]*$)", $gid)) {
$id = $igOption->getSingleOption("gallery", $gid);
}
$columns = 3;
if (empty($id) || !ereg("(^[1-9]?[0-9]*$)", $id)) {
$galleryArray = $igOption->getMultipleOption("gallery");
if (!empty($galleryArray)) {
$multiple = false;
foreach($galleryArray as $k => $v) {
$galleryRelID[$v] = $k;
$galleryRelBID[$k] = $v;
if (!$multiple) {
$gBranchesWhere = "WHERE ";
} else {
$gBranchesWhere .= "OR ";
}
$gBranchesWhere .= "branchID = '$v' ";
$multiple = true;
}
$gBranchesQ = mysql_query("SELECT * FROM " . TABLE . "_mm_folder $gBranchesWhere");
while ($gBranches = mysql_fetch_object($gBranchesQ)) {
$galleryID[] = $galleryRelID[$gBranches->branchID];
$galleryBID[] = $gBranches->branchID;
$galleryName[] = $gBranches->name;
$galleryDesc[] = $gBranches->description;
$galleryDirectory[] = $gBranches->branchName;
}
$tpl->assign("branchListSet", "1");
}
} else {
/*
* Alle Unterkategorien herausfinden
*/
$gBranchesQ = mysql_query("SELECT * FROM " . TABLE . "_mm_folder WHERE parentID = '$id'");
while ($gBranches = mysql_fetch_object($gBranchesQ)) {
$galleryID[] = $galleryRelID[$gBranches->branchID];
$galleryBID[] = $gBranches->branchID;
$galleryName[] = $gBranches->name;
$galleryDesc[] = $gBranches->description;
$galleryDirectory[] = $gBranches->branchName;
$subCatsSet = true;
}
/*
* Daten über aktuelle Gallerie herausfinden und
* Ermittlung des Galleriepfades. Des weiteren
* wird geprüft, ob das Medienverzeichnis überhaupt
* das Kind einer Gallerie ist.
*/
$gActualBranch = mysql_fetch_object(mysql_query("SELECT * FROM ".TABLE."_mm_folder WHERE branchID = '$id'"));
$actualBranchArr['name'] = $gActualBranch->name;
$actualBranchArr['parent'] = $gActualBranch->parentID;
$actualBranchArr['bid'] = $gActualBranch->branchID;
$actualBranchArr['directory'] = $gActualBranch->branchName;
$actualBranchArr['desc'] = $gActualBranch->description;
$branchPathName[] = $gActualBranch->name;
$branchPathID[] = $gActualBranch->branchID;
$branchPathMultiple[] = "0";
if ($gActualBranch->parentID != "0" || $gActualBranch->parentID != "") {
$actualBranch = $gActualBranch->parentID;
while ($actualBranch != "0") {
$gActualBranch = mysql_fetch_object(mysql_query("SELECT parentID, branchID, name FROM " . TABLE . "_mm_folder WHERE branchID = '$actualBranch'"));
$branchPathName[] = $gActualBranch->name;
$branchPathID[] = $gActualBranch->branchID;
$actualBranch = $gActualBranch->parentID;
if($gActualBranch->module == "gallery") { }
if ($actualBranch == "") $actualBranch = "0";
}
$branchPathID = array_reverse($branchPathID);
$branchPathName = array_reverse($branchPathName);
}
/*
* Alle Dateien ermitteln, die im aktuellen Medienverzeichnis
* liegen und zu den erlaubten Typen gehören.
*/
$isGalleryChild = true;
if($isGalleryChild) {
$fileWhere = "WHERE branchID = '$id' ";
$allowedTypeArray = $igOption->getMultipleOption("allowedTypes");
if (!empty($allowedTypeArray)) {
$multiple = false;
$fileWhere .= "AND ( ";
foreach($allowedTypeArray as $k => $v) {
if ($multiple) {
$fileWhere .= "OR ";
}
$allowedTypeID[] = $v;
$fileWhere .= "typeID = '$v' ";
$multiple = true;
}
$fileWhere .= ") ";
}
$gFilesQ = mysql_query("SELECT filename, branchID, title, fileID FROM " . TABLE . "_mm_files $fileWhere");
$multiple = false;
$counter = 1;
while ($gFiles = mysql_fetch_object($gFilesQ)) {
$fileName[] = $gFiles->filename;
$fileTitle[] = $gFiles->title;
$fileBranch[] = $gFiles->branchID;
$fileID[] = $gFiles->fileID;
$fileCounter[] = $counter;
$multiple = true;
if ($counter == $columns) {
$counter = 1;
} else {
++$counter;
}
}
while ($counter <= $columns) {
$fileName[] = "";
$fileTitle[] = "";
$fileBranch[] = "";
$fileID[] = "";
$fileCounter[] = $counter;
++$counter;
}
if ($multiple) $tpl->assign("fileListSet", "1");
}
$tpl->assign("branchDetailsSet", "1");
if($subCatsSet) $tpl->assign("branchListSet", "1");
}
$branchListPath = array (
"ID" => $branchPathID,
"NAME" => $branchPathName,
"MULTIPLE" => $branchPathMultiple
);
$tpl->assign("branchListPath", $branchListPath);
$branchDetails = array ( "DESC" => $actualBranchArr[desc] );
$tpl->assign("actualBranchDetail", $branchDetails);
$branchListRow = array (
"ID" => $galleryBID,
"NAME" => $galleryName,
"DESC" => $galleryDesc
);
$tpl->assign("branchListRow", $branchListRow);
$fileListRow = array (
"ID" => $fileID,
"BID" => $fileBranch,
"NAME" => $fileName,
"TITLE" => $fileTitle,
"COLUMN" => $fileCounter,
"DIRECTORY" => $actualBranchArr['directory']
);
$tpl->assign("fileListRow", $fileListRow);
$tpl->display("gallery.template");
?>