diff -r 94af07c8f2f3 -r 88c954d2846c plugins/gallery/browser.php --- a/plugins/gallery/browser.php Wed Jul 25 16:43:47 2007 -0400 +++ b/plugins/gallery/browser.php Wed Jul 25 18:15:14 2007 -0400 @@ -163,8 +163,9 @@ $breadcrumb_urlcache = ''; // CSS for gallery browser - $template->add_header(''); - $template->add_header(''); + // Moved to search.php + //$template->add_header(''); + //$template->add_header(''); $header = $template->getHeader(); @@ -226,6 +227,45 @@ // 1) The folder doesn't exist // 2) The folder exists but doesn't have any images in it + if ( sizeof($folders) < 1 ) + { + // Nothing in the root folder + + $first_row['folder_id'] = 'NULL'; + if ( $session->user_level >= USER_LEVEL_ADMIN && isset($_POST['create_folder']) && isset($first_row['folder_id']) ) + { + if ( empty($_POST['create_folder']) ) + { + $f_errors[] = 'Please enter a folder name.'; + } + if ( $_POST['create_folder'] == '_id' ) + { + $f_errors[] = 'The name "_id" is reserved for internal functions and cannot be used on any image or folder.'; + } + if ( count($f_errors) < 1 ) + { + $q = $db->sql_query('INSERT INTO '.table_prefix.'gallery(img_title, is_folder, folder_parent) VALUES(\'' . $db->escape($_POST['create_folder']) . '\', 1, ' . $first_row['folder_id'] . ');'); + if ( !$q ) + $db->_die(); + redirect(makeUrl($paths->fullpage), 'Folder created', 'The folder "' . htmlspecialchars($_POST['create_folder']) . '" has been created. Redirecting to last viewed folder...', 2); + } + } + + $html = ''; + if ( $session->user_level >= USER_LEVEL_ADMIN ) + { + $html .= '

Upload an image

'; + $html .= '
Create new folder'; + $html .= '
'; + $html .= '
'; + $html .= ' '; + $html .= '
'; + $html .= '
 

'; + } + + die_friendly('No images', '

No images have been uploaded to the gallery yet.

' . $html); + } + /* $folders_old = $folders; $folders = array( @@ -303,8 +343,16 @@ $f_errors = array(); - if ( $session->user_level >= USER_LEVEL_ADMIN && isset($_POST['create_folder']) && isset($first_row['folder_id']) ) + if ( $session->user_level >= USER_LEVEL_ADMIN && isset($_POST['create_folder']) ) { + if ( !isset($first_row['folder_id']) ) + { + $first_row['folder_id'] =& $first_row['img_id']; + } + if ( !isset($first_row['folder_id']) ) + { + $f_errors[] = 'Internal error getting parent folder ID'; + } if ( empty($_POST['create_folder']) ) { $f_errors[] = 'Please enter a folder name.'; @@ -435,7 +483,7 @@ $per_page = $rows_in_browser * 5; - $html = paginate($img_query, '{img_id}', $db->numrows($img_query), makeUrl($paths->fullpage, 'start=%s', true), $start, $per_page, $callers, '', '
'); + $html = paginate($img_query, '{img_id}', $db->numrows($img_query), makeUrl($paths->fullpage, 'sort=' . $sort_column . '&order=' . $sort_order . '&start=%s', true), $start, $per_page, $callers, '', '
'); echo $html; if ( $session->user_level >= USER_LEVEL_ADMIN )