diff -r 0944c9354e9c -r 7c6e2e97aa08 plugins/gallery/browser.php --- a/plugins/gallery/browser.php Sat Aug 21 23:25:41 2010 -0400 +++ b/plugins/gallery/browser.php Sat Aug 21 23:32:06 2010 -0400 @@ -27,446 +27,447 @@ class SnaprFormatter { - - /** - * Main render method, called from pagination function - * @access private - */ - - function render($column_crap, $row, $row_crap = false) - { - global $db, $session, $paths, $template, $plugins; // Common objects - - $out = '
  • '; - - $title_safe = $row['img_title']; - $title_safe = htmlspecialchars($title_safe); - - if ( $row['is_folder'] == 1 ) - { - // It's a folder, show the icon - $f_url_particle = sanitize_page_id($row['img_title']); - $f_url_particle = htmlspecialchars($f_url_particle); - $image_link = makeUrl( $paths->fullpage . '/' . $f_url_particle ); - $image_url = scriptPath . '/plugins/gallery/folder.png'; - } - else - { - // It's an image, show a thumbnail - $image_link = makeUrlNS('Gallery', $row['img_id']); - $image_url = makeUrlNS('Special', 'GalleryFetcher/thumb/' . $row['img_id']); - } - - if ( isset($row['score']) ) - { - $row['score'] = number_format($row['score'], 2); - } - - $image_url_js = addslashes($image_link); - $jsclick = ( $session->user_level < USER_LEVEL_ADMIN ) ? ' onclick="window.location=\'' . $image_url_js . '\'"' : ''; - - $out .= ''; - - $out .= '
  • '; - - return $out; - } - + + /** + * Main render method, called from pagination function + * @access private + */ + + function render($column_crap, $row, $row_crap = false) + { + global $db, $session, $paths, $template, $plugins; // Common objects + + $out = '
  • '; + + $title_safe = $row['img_title']; + $title_safe = htmlspecialchars($title_safe); + + if ( $row['is_folder'] == 1 ) + { + // It's a folder, show the icon + $f_url_particle = sanitize_page_id($row['img_title']); + $f_url_particle = htmlspecialchars($f_url_particle); + $image_link = makeUrl( $paths->fullpage . '/' . $f_url_particle ); + $image_url = scriptPath . '/plugins/gallery/folder.png'; + } + else + { + // It's an image, show a thumbnail + $image_link = makeUrlNS('Gallery', $row['img_id']); + $image_url = makeUrlNS('Special', 'GalleryFetcher/thumb/' . $row['img_id']); + } + + if ( isset($row['score']) ) + { + $row['score'] = number_format($row['score'], 2); + } + + $image_url_js = addslashes($image_link); + $jsclick = ( $session->user_level < USER_LEVEL_ADMIN ) ? ' onclick="window.location=\'' . $image_url_js . '\'"' : ''; + + $out .= ''; + + $out .= '
  • '; + + return $out; + } + } function page_Special_Gallery() { - global $db, $session, $paths, $template, $plugins; // Common objects - - // die('
    ' . print_r(gallery_folder_hierarchy(), true) . '
    '); - - $sort_column = ( isset($_GET['sort']) && in_array($_GET['sort'], array('img_title', 'img_time_upload', 'img_time_mod')) ) ? $_GET['sort'] : 'img_title'; - $sort_order = ( isset($_GET['order']) && in_array($_GET['order'], array('ASC', 'DESC')) ) ? $_GET['order'] : 'ASC'; - - // Determine number of pictures per page - $template->load_theme(); - - $where = 'WHERE folder_parent IS NULL ' . "\n ORDER BY is_folder DESC, $sort_column $sort_order, img_title ASC"; - $parms = $paths->getAllParams(); - - $sql = "SELECT img_id, img_title, is_folder, 'NULL' AS folder_id FROM ".table_prefix."gallery $where;"; - - // Breadcrumb browser - $breadcrumbs = array(); - $breadcrumbs[] = 'Gallery index'; - - $breadcrumb_urlcache = ''; - - // CSS for gallery browser - // Moved to search.php - //$template->add_header(''); - //$template->add_header(''); - - $header = $template->getHeader(); - - if ( !empty($parms) ) - { - $parms = dirtify_page_id($parms); - if ( strstr($parms, '/') ) - { - $folders = explode('/', $parms); - } - else - { - $folders = array(0 => $parms); - } - foreach ( $folders as $i => $_crap ) - { - $folder =& $folders[$i]; - - $f_url = sanitize_page_id($folder); - $breadcrumb_urlcache .= '/' . $f_url; - $breadcrumb_url = makeUrlNS('Special', 'Gallery' . $breadcrumb_urlcache); - - $folder = str_replace('_', ' ', $folder); - - if ( $i == ( count($folders) - 1 ) ) - { - $breadcrumbs[] = htmlspecialchars($folder); - } - else - { - $breadcrumbs[] = '' . htmlspecialchars($folder) . ''; - } - } - unset($folder); - $folders = array_reverse($folders); - // This is one of the best MySQL tricks on the market. We're going to reverse-travel a folder path using LEFT JOIN and the incredible power of metacoded SQL - $sql = 'SELECT gm.img_id, gm.img_title, gm.is_folder, g0.img_title AS folder_name, g0.img_id AS folder_id FROM '.table_prefix.'gallery AS gm' . "\n " . 'LEFT JOIN '.table_prefix.'gallery AS g0' . "\n " . 'ON ( gm.folder_parent = g0.img_id )'; - $where = "\n " . 'WHERE g0.img_title=\'' . $db->escape($folders[0]) . '\''; - foreach ( $folders as $i => $folder ) - { - if ( $i == 0 ) - continue; - $i_dec = $i - 1; - $folder = $db->escape($folder); - $sql .= "\n LEFT JOIN ".table_prefix."gallery AS g{$i}\n ON ( g{$i}.img_id=g{$i_dec}.folder_parent AND g{$i}.img_title='$folder' )"; - $where .= "\n ".'AND g'.$i.'.img_id IS NOT NULL'; - } - $where .= "\n AND g{$i}.folder_parent IS NULL"; - $sql .= $where . "\n ORDER BY is_folder DESC, gm.$sort_column $sort_order, gm.img_title ASC" . ';'; - } - - $img_query = $db->sql_query($sql); - if ( !$img_query ) - $db->_die('The folder ID could not be selected.'); - - if ( $db->numrows() < 1 ) - { - // Nothing in this folder, for one of two reasons: - // 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( - 0 => $folders_old[0] - ); - $x = $folders_old; - unset($x[0]); - $folders = array_merge($folders, $x); - unset($x); - */ - // die('
    ' . print_r($folders, true) . '
    '); - - // This next query will try to determine if the folder itself exists - $sql = 'SELECT g0.img_id, g0.img_title FROM '.table_prefix.'gallery AS g0'; - $where = "\n " . 'WHERE g0.img_title=\'' . $db->escape($folders[0]) . '\''; - foreach ( $folders as $i => $folder ) - { - if ( $i == 0 ) - continue; - $i_dec = $i - 1; - $folder = $db->escape($folder); - $sql .= "\n LEFT JOIN ".table_prefix."gallery AS g{$i}\n ON ( g{$i}.img_id=g{$i_dec}.folder_parent AND g{$i}.img_title='$folder' )"; - $where .= "\n ".'AND g'.$i.'.img_id IS NOT NULL'; - } - $where .= "\n AND g{$i}.folder_parent IS NULL"; - $where .= "\n AND g0.is_folder=1"; - $sql .= $where . ';'; - - $nameq = $db->sql_query($sql); - if ( !$nameq ) - $db->_die(); - - if ( $db->numrows($nameq) < 1 ) - { - die_friendly('Folder not found', '

    The folder you requested doesn\'t exist. Please check the URL and try again, or return to the gallery index.

    '); - } - - $row = $db->fetchrow($nameq); - - // Generate title - $title = dirtify_page_id($row['img_title']); - $title = str_replace('_', ' ', $title); - $title = htmlspecialchars($title); - - $template->tpl_strings['PAGE_NAME'] = $title; - - $first_row = $row; - - if ( $db->numrows($img_query) > 0 ) - $db->sql_data_seek(0, $img_query); - - /* $folders = $folders_old; */ - } - else if ( !empty($parms) ) - { - $row = $db->fetchrow($img_query); - $first_row = $row; - - // Generate title - $title = htmlspecialchars($row['folder_name']); - - $template->tpl_strings['PAGE_NAME'] = $title; - - $db->sql_data_seek(0, $img_query); - } - else - { - $row = $db->fetchrow($img_query); - $first_row = $row; - - $template->tpl_strings['PAGE_NAME'] = 'Image Gallery'; - $breadcrumbs = array('Gallery index'); - - $db->sql_data_seek(0, $img_query); - } - - $f_errors = array(); - - if ( $session->user_level >= USER_LEVEL_ADMIN && isset($_POST['create_folder']) ) - { - if ( !isset($first_row['folder_id']) ) - { - //die('FALLING
    ' . print_r($first_row, true) . '
    '); - $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.'; - } - 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); - } - } - - echo $header; - - if ( count($f_errors) > 0 ) - { - echo '
    Error creating folder:
    '; - } - - // From here, this breadcrumb stuff is a piece of... sourdough French bread :-) *smacks lips* - echo ''; - - // "Edit all" link - if ( $row = $db->fetchrow($img_query) && $session->user_level >= USER_LEVEL_ADMIN ) - { - $img_list = array(); - $fol_list = array(); - $all_list = array(); - do - { - if ( $row === true && isset($first_row) ) - { - $row = $first_row; - } - // die('
    ' . var_dump($row) . $db->sql_backtrace() . '
    '); - if ( !$row['img_id'] ) - break; - $all_list[] = $row['img_id']; - if ( $row['is_folder'] == 1 ) - $fol_list[] = $row['img_id']; - else - $img_list[] = $row['img_id']; - } - while ( $row = $db->fetchrow($img_query) ); - - $all_list = implode(',', $all_list); - $fol_list = implode(',', $fol_list); - $img_list = implode(',', $img_list); - - if ( !empty($all_list) ) - { - echo '
    - Edit all in this folder: '; - if ( !empty($img_list) ) - { - $edit_link = makeUrlNS('Special', 'GalleryUpload', 'edit_img=' . $img_list, true); - echo "images "; - } - if ( !empty($fol_list) ) - { - $edit_link = makeUrlNS('Special', 'GalleryUpload', 'edit_img=' . $fol_list, true); - echo "folders "; - } - if ( !empty($img_list) && !empty($fol_list) ) - { - $edit_link = makeUrlNS('Special', 'GalleryUpload', 'edit_img=' . $all_list, true); - echo "both "; - } - // " Bypass stupid jEdit bug - echo '
    '; - } - } - - $url_sort_name_asc = makeUrl($paths->fullpage, 'sort=img_title&order=ASC', true); - $url_sort_name_desc = makeUrl($paths->fullpage, 'sort=img_title&order=DESC', true); - $url_sort_upl_asc = makeUrl($paths->fullpage, 'sort=img_time_upload&order=ASC', true); - $url_sort_mod_asc = makeUrl($paths->fullpage, 'sort=img_time_mod&order=ASC', true); - $url_sort_upl_desc = makeUrl($paths->fullpage, 'sort=img_time_upload&order=DESC', true); - $url_sort_mod_desc = makeUrl($paths->fullpage, 'sort=img_time_mod&order=DESC', true); - - // "Sort by" selector (pure CSS!) - echo '
    - Sort by... -
    - Image title (A-Z) (default) - Image title (Z-A) - Time first uploaded (newest first) - Time first uploaded (oldest first) - Date of last modification (newest first) - Date of last modification (oldest first) -
    -
    -
     
    '; - - if ( $db->numrows($img_query) > 0 ) + global $db, $session, $paths, $template, $plugins; // Common objects + + // die('
    ' . print_r(gallery_folder_hierarchy(), true) . '
    '); + + $sort_column = ( isset($_GET['sort']) && in_array($_GET['sort'], array('img_title', 'img_time_upload', 'img_time_mod')) ) ? $_GET['sort'] : 'img_title'; + $sort_order = ( isset($_GET['order']) && in_array($_GET['order'], array('ASC', 'DESC')) ) ? $_GET['order'] : 'ASC'; + + // Determine number of pictures per page + $template->load_theme(); + + $where = 'WHERE folder_parent IS NULL ' . "\n ORDER BY is_folder DESC, $sort_column $sort_order, img_title ASC"; + $parms = $paths->getAllParams(); + + $sql = "SELECT img_id, img_title, is_folder, 'NULL' AS folder_id FROM ".table_prefix."gallery $where;"; + + // Breadcrumb browser + $breadcrumbs = array(); + $breadcrumbs[] = 'Gallery index'; + + $breadcrumb_urlcache = ''; + + // CSS for gallery browser + // Moved to search.php + //$template->add_header(''); + //$template->add_header(''); + + $header = $template->getHeader(); + + $folders = $f_errors = array(); + if ( !empty($parms) ) + { + $parms = dirtify_page_id($parms); + if ( strstr($parms, '/') ) + { + $folders = explode('/', $parms); + } + else + { + $folders = array(0 => $parms); + } + foreach ( $folders as $i => $_crap ) + { + $folder =& $folders[$i]; + + $f_url = sanitize_page_id($folder); + $breadcrumb_urlcache .= '/' . $f_url; + $breadcrumb_url = makeUrlNS('Special', 'Gallery' . $breadcrumb_urlcache); + + $folder = str_replace('_', ' ', $folder); + + if ( $i == ( count($folders) - 1 ) ) + { + $breadcrumbs[] = htmlspecialchars($folder); + } + else + { + $breadcrumbs[] = '' . htmlspecialchars($folder) . ''; + } + } + unset($folder); + $folders = array_reverse($folders); + // This is one of the best MySQL tricks on the market. We're going to reverse-travel a folder path using LEFT JOIN and the incredible power of metacoded SQL + $sql = 'SELECT gm.img_id, gm.img_title, gm.is_folder, g0.img_title AS folder_name, g0.img_id AS folder_id FROM '.table_prefix.'gallery AS gm' . "\n " . 'LEFT JOIN '.table_prefix.'gallery AS g0' . "\n " . 'ON ( gm.folder_parent = g0.img_id )'; + $where = "\n " . 'WHERE g0.img_title=\'' . $db->escape($folders[0]) . '\''; + foreach ( $folders as $i => $folder ) + { + if ( $i == 0 ) + continue; + $i_dec = $i - 1; + $folder = $db->escape($folder); + $sql .= "\n LEFT JOIN ".table_prefix."gallery AS g{$i}\n ON ( g{$i}.img_id=g{$i_dec}.folder_parent AND g{$i}.img_title='$folder' )"; + $where .= "\n ".'AND g'.$i.'.img_id IS NOT NULL'; + } + $where .= "\n AND g{$i}.folder_parent IS NULL"; + $sql .= $where . "\n ORDER BY is_folder DESC, gm.$sort_column $sort_order, gm.img_title ASC" . ';'; + } + + $img_query = $db->sql_query($sql); + if ( !$img_query ) + $db->_die('The folder ID could not be selected.'); + + if ( $db->numrows() < 1 ) + { + // Nothing in this folder, for one of two reasons: + // 1) The folder doesn't exist + // 2) The folder exists but doesn't have any images in it + + if ( count($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, img_author) VALUES(\'' . $db->escape($_POST['create_folder']) . '\', 1, ' . $first_row['folder_id'] . ', ' . $session->user_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( + 0 => $folders_old[0] + ); + $x = $folders_old; + unset($x[0]); + $folders = array_merge($folders, $x); + unset($x); + */ + // die('
    ' . print_r($folders, true) . '
    '); + + // This next query will try to determine if the folder itself exists + $sql = 'SELECT g0.img_id, g0.img_title FROM '.table_prefix.'gallery AS g0'; + $where = "\n " . 'WHERE g0.img_title=\'' . $db->escape($folders[0]) . '\''; + foreach ( $folders as $i => $folder ) + { + if ( $i == 0 ) + continue; + $i_dec = $i - 1; + $folder = $db->escape($folder); + $sql .= "\n LEFT JOIN ".table_prefix."gallery AS g{$i}\n ON ( g{$i}.img_id=g{$i_dec}.folder_parent AND g{$i}.img_title='$folder' )"; + $where .= "\n ".'AND g'.$i.'.img_id IS NOT NULL'; + } + $where .= "\n AND g{$i}.folder_parent IS NULL"; + $where .= "\n AND g0.is_folder=1"; + $sql .= $where . ';'; + + $nameq = $db->sql_query($sql); + if ( !$nameq ) + $db->_die(); + + if ( $db->numrows($nameq) < 1 ) + { + die_friendly('Folder not found', '

    The folder you requested doesn\'t exist. Please check the URL and try again, or return to the gallery index.

    '); + } + + $row = $db->fetchrow($nameq); + + // Generate title + $title = dirtify_page_id($row['img_title']); + $title = str_replace('_', ' ', $title); + $title = htmlspecialchars($title); + + $template->tpl_strings['PAGE_NAME'] = $title; + + $first_row = $row; + + if ( $db->numrows($img_query) > 0 ) + $db->sql_data_seek(0, $img_query); + + /* $folders = $folders_old; */ + } + else if ( !empty($parms) ) + { + $row = $db->fetchrow($img_query); + $first_row = $row; + + // Generate title + $title = htmlspecialchars($row['folder_name']); + + $template->tpl_strings['PAGE_NAME'] = $title; + + $db->sql_data_seek(0, $img_query); + } + else + { + $row = $db->fetchrow($img_query); + $first_row = $row; + + $template->tpl_strings['PAGE_NAME'] = 'Image Gallery'; + $breadcrumbs = array('Gallery index'); + + $db->sql_data_seek(0, $img_query); + } + + $f_errors = array(); + + if ( $session->user_level >= USER_LEVEL_ADMIN && isset($_POST['create_folder']) ) + { + if ( !isset($first_row['folder_id']) ) + { + //die('FALLING
    ' . print_r($first_row, true) . '
    '); + $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.'; + } + 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, img_author) VALUES(\'' . $db->escape($_POST['create_folder']) . '\', 1, ' . $first_row['folder_id'] . ', ' . $session->user_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); + } + } + + echo $header; + + if ( count($f_errors) > 0 ) + { + echo '
    Error creating folder:
    '; + } + + // From here, this breadcrumb stuff is a piece of... sourdough French bread :-) *smacks lips* + echo ''; + + // "Edit all" link + if ( $row = $db->fetchrow($img_query) && $session->user_level >= USER_LEVEL_ADMIN ) + { + $img_list = array(); + $fol_list = array(); + $all_list = array(); + do + { + if ( $row === true && isset($first_row) ) + { + $row = $first_row; + } + // die('
    ' . var_dump($row) . $db->sql_backtrace() . '
    '); + if ( !$row['img_id'] ) + break; + $all_list[] = $row['img_id']; + if ( $row['is_folder'] == 1 ) + $fol_list[] = $row['img_id']; + else + $img_list[] = $row['img_id']; + } + while ( $row = $db->fetchrow($img_query) ); + + $all_list = implode(',', $all_list); + $fol_list = implode(',', $fol_list); + $img_list = implode(',', $img_list); + + if ( !empty($all_list) ) + { + echo '
    + Edit all in this folder: '; + if ( !empty($img_list) ) + { + $edit_link = makeUrlNS('Special', 'GalleryUpload', 'edit_img=' . $img_list, true); + echo "images "; + } + if ( !empty($fol_list) ) + { + $edit_link = makeUrlNS('Special', 'GalleryUpload', 'edit_img=' . $fol_list, true); + echo "folders "; + } + if ( !empty($img_list) && !empty($fol_list) ) + { + $edit_link = makeUrlNS('Special', 'GalleryUpload', 'edit_img=' . $all_list, true); + echo "both "; + } + // " Bypass stupid jEdit bug + echo '
    '; + } + } + + $url_sort_name_asc = makeUrl($paths->fullpage, 'sort=img_title&order=ASC', true); + $url_sort_name_desc = makeUrl($paths->fullpage, 'sort=img_title&order=DESC', true); + $url_sort_upl_asc = makeUrl($paths->fullpage, 'sort=img_time_upload&order=ASC', true); + $url_sort_mod_asc = makeUrl($paths->fullpage, 'sort=img_time_mod&order=ASC', true); + $url_sort_upl_desc = makeUrl($paths->fullpage, 'sort=img_time_upload&order=DESC', true); + $url_sort_mod_desc = makeUrl($paths->fullpage, 'sort=img_time_mod&order=DESC', true); + + // "Sort by" selector (pure CSS!) + echo '
    + Sort by... +
    + Image title (A-Z) (default) + Image title (Z-A) + Time first uploaded (newest first) + Time first uploaded (oldest first) + Date of last modification (newest first) + Date of last modification (oldest first) +
    +
    +
     
    '; + + if ( $db->numrows($img_query) > 0 ) $db->sql_data_seek(0, $img_query); - - // - // Main fetcher - // - - $renderer = new SnaprFormatter(); - $callers = array( - 'img_id' => array($renderer, 'render') - ); - - $renderer->icons_per_row = 5; - - $start = 0; - if ( isset($_GET['start']) && preg_match('/^[0-9]+$/', $_GET['start']) ) - { - $start = intval($_GET['start']); - } - - $per_page = 25; - - $html = paginate($img_query, '{img_id}', $db->numrows($img_query), makeUrl($paths->fullpage, 'sort=' . $sort_column . '&order=' . $sort_order . '&start=%s', false), $start, $per_page, $callers, ''); - if ( empty($html) ) - { - echo '

    No images

    '; - } - else - { + + // + // Main fetcher + // + + $renderer = new SnaprFormatter(); + $callers = array( + 'img_id' => array($renderer, 'render') + ); + + $renderer->icons_per_row = 5; + + $start = 0; + if ( isset($_GET['start']) && preg_match('/^[0-9]+$/', $_GET['start']) ) + { + $start = intval($_GET['start']); + } + + $per_page = 25; + + $html = paginate($img_query, '{img_id}', $db->numrows($img_query), makeUrl($paths->fullpage, 'sort=' . $sort_column . '&order=' . $sort_order . '&start=%s', false), $start, $per_page, $callers, ''); + if ( empty($html) ) + { + echo '

    No images

    '; + } + else + { echo $html; - } - - if ( $session->user_level >= USER_LEVEL_ADMIN ) - { - echo '
    Create new folder'; - echo '
    '; - echo '
    '; - echo ' '; - echo '
    '; - echo '
     

    '; - } - - $template->footer(); - + } + + if ( $session->user_level >= USER_LEVEL_ADMIN ) + { + echo '
    Create new folder'; + echo '
    '; + echo '
    '; + echo ' '; + echo '
    '; + echo '
     

    '; + } + + $template->footer(); + } ?>