Hi!
I designed my gallerie with different categories and subcategories:
cat0
->cat0.1
=>album1
=>album2
->cat0.2
->cat0.2.1
=>album1
=>album2
->cat0.2.2
->cat0.3
->cat0.4
cat2
->cat1.1
...
a.s.o.
if i start adding files with the batch-upload function, i get the cat and album overview like this:
-> cat0.1
=>album1
=>album1 (from another cat)
-> cat0.2
=> album2
=> album2 (from another cat)
it's absolutely compley, in which album i have to save my files.
that's why i'd like to sort it like this:
-> cat 0 (without parent cat)
-> cat0.1
=>album1
=>album2
->cat0.2
=>ablum1
=>album2
what information do i need additionally from the database and what do i have to change in the searchnew.php?
i hope, you can help, i think this is the concerned code:
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2006 Coppermine Dev Team
v1.1 originally written by Gregory DEMAR
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
********************************************
Coppermine version: 1.4.4
$Source: /cvsroot/coppermine/stable/searchnew.php,v $
$Revision: 1.18 $
$Author: gaugau $
$Date: 2006/02/24 13:30:07 $
**********************************************/
define('IN_COPPERMINE', true);
define('SEARCHNEW_PHP', true);
require('include/init.inc.php');
if (!GALLERY_ADMIN_MODE) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
/**
* Local functions definition
*/
/**
* albumselect()
*
* return the HTML code for a listbox with name $id that contains the list
* of all albums
*
* @param string $id the name of the listbox
* @return the HTML code
*/
function albumselect($id = "album") {
// frogfoot re-wrote this function to present the list in categorized, sorted and nicely formatted order
global $CONFIG, $lang_search_new_php, $cpg_udb;
static $select = "";
// Reset counter
$list_count = 0;
if ($select == "") {
$result = cpg_db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = 0");
while ($row = mysql_fetch_array($result)) {
// Add to multi-dim array for later sorting
$listArray[$list_count]['cat'] = $lang_search_new_php['albums_no_category'];
$listArray[$list_count]['aid'] = $row['aid'];
$listArray[$list_count]['title'] = $row['title'];
$list_count++;
}
mysql_free_result($result);
$result = cpg_db_query("SELECT DISTINCT a.aid as aid, a.title as title, c.name as cname FROM {$CONFIG['TABLE_ALBUMS']} as a, {$CONFIG['TABLE_CATEGORIES']} as c WHERE a.category = c.cid AND a.category < '" . FIRST_USER_CAT . "'");
while ($row = mysql_fetch_array($result)) {
// Add to multi-dim array for later sorting
$listArray[$list_count]['cat'] = $row['cname'];
$listArray[$list_count]['aid'] = $row['aid'];
$listArray[$list_count]['title'] = $row['title'];
$list_count++;
}
mysql_free_result($result);
//if (defined('UDB_INTEGRATION')) {
$sql = $cpg_udb->get_batch_add_album_list();
/*} else {
$sql = "SELECT aid, CONCAT('(', user_name, ') ', title) AS title " . "FROM {$CONFIG['TABLE_ALBUMS']} AS a " . "INNER JOIN {$CONFIG['TABLE_USERS']} AS u ON category = (" . FIRST_USER_CAT . " + user_id)";
}*/
$result = cpg_db_query($sql);
while ($row = mysql_fetch_array($result)) {
// Add to multi-dim array for later sorting
$listArray[$list_count]['cat'] = $lang_search_new_php['personal_albums'];
$listArray[$list_count]['aid'] = $row['aid'];
$listArray[$list_count]['title'] = $row['title'];
$list_count++;
}
mysql_free_result($result);
$select = '<option value="0">' . $lang_search_new_php['select_album'] . "</option>\n";
// Sort the pulldown options by category and album name
$listArray = array_csort($listArray,'cat','title');
// Create the nicely sorted and formatted drop down list
$alb_cat = '';
foreach ($listArray as $val) {
if ($val['cat'] != $alb_cat) {
if ($alb_cat) $select .= "</optgroup>\n";
$select .= '<optgroup label="' . $val['cat'] . '">' . "\n";
$alb_cat = $val['cat'];
}
$select .= '<option value="' . $val['aid'] . '"' . ($val['aid'] == $sel_album ? ' selected' : '') . '> ' . $val['title'] . "</option>\n";
}
if ($alb_cat) $select .= "</optgroup>\n";
}
return "\n<select name=\"$id\" class=\"listbox\">\n$select</select>\n";
}