diff -Naur fgallery-2.4.1-1/fgallery/fim_photos.php fgallery-2.4.1-2/fgallery/fim_photos.php --- fgallery-2.4.1-1/fgallery/fim_photos.php 2009-02-17 14:37:37.000000000 +0500 +++ fgallery-2.4.1-2/fgallery/fim_photos.php 2009-02-17 14:40:29.000000000 +0500 @@ -1,13 +1,9 @@ - +is_404 = false;?> - -
diff -Naur fgallery-2.4.1-1/fgallery/functions/fim_functions.php fgallery-2.4.1-2/fgallery/functions/fim_functions.php --- fgallery-2.4.1-1/fgallery/functions/fim_functions.php 2009-02-17 14:37:37.000000000 +0500 +++ fgallery-2.4.1-2/fgallery/functions/fim_functions.php 2009-02-17 14:40:18.000000000 +0500 @@ -177,7 +177,7 @@ $query_string = $_SERVER['QUERY_STRING']; $image = fim_query_one_image($_GET['image']); $title = ($image->title!="") ? "$title" : "Image"; - // $back_link = get_url("album/$image->cat"); + $back_link = get_url("album/$image->cat"); $folder = get_bloginfo('wpurl')."/wp-content/fgallery/".fim_get_folder($image->cat); $gdsize = getimagesize($folder.rawurlencode($image->image)); $gdwidth = ($gdsize[0] <= 600 ? $gdsize[0] : 600); @@ -344,7 +344,7 @@ $table_comments = $table_prefix."fim_comments"; return $wpdb->get_results("SELECT * FROM $table_comments WHERE image_id = $image_id ORDER BY date DESC"); } -// Get prev image link +// Get next image link function fim_get_next_image_link($curr_id, $curr_cat, $fimpage) { global $wpdb, $table_prefix; @@ -352,28 +352,45 @@ $order = get_option('fim_image_order'); $type = get_option('fim_image_order_type'); - - $sql = "SELECT id FROM $table_image WHERE id > '$curr_id' AND cat = '$curr_cat' ORDER BY $order $type LIMIT 0,1"; + if($type == 'desc') { + $arrow = '<='; + $arrow_id = '<'; + $mm = 'MAX'; + } else { + $arrow = '>='; + $arrow_id = '>'; + $mm = 'MIN'; + } + $sql = "SELECT * FROM $table_image WHERE $order $arrow (SELECT $order FROM $table_image WHERE id = $curr_id) AND id = (SELECT $mm(id) FROM $table_image WHERE id $arrow_id $curr_id AND cat = $curr_cat) ORDER BY $order $type LIMIT 0, 1"; $link = $wpdb->get_row($sql); if($link) //return "".__('Next »', 'fgallery').""; - return "".__('Next »', 'fgallery').""; + return "".__('Next »', 'fgallery').""; else - return __('Next »' , 'fgallery'); + return __('Next »'."", 'fgallery'); } -// Get next image link +// Get prev image link function fim_get_prev_image_link($curr_id, $curr_cat, $fimpage) { global $wpdb, $table_prefix; $table_image = $table_prefix."fim_images"; $order = get_option('fim_image_order'); $type = get_option('fim_image_order_type'); - $sql = "SELECT id FROM $table_image WHERE id < '$curr_id' AND cat = '$curr_cat' ORDER BY $order $type LIMIT 0,1"; + if($type == 'desc') { + $arrow = '>='; + $arrow_id = '>'; + $mm = 'MIN'; + } else { + $arrow = '<='; + $arrow_id = '<'; + $mm = 'MAX'; + } + $sql = "SELECT * FROM $table_image WHERE $order $arrow (SELECT $order FROM $table_image WHERE id = $curr_id) AND id = (SELECT $mm(id) FROM $table_image WHERE id $arrow_id $curr_id AND cat = $curr_cat) ORDER BY $order $type LIMIT 0, 1"; $link = $wpdb->get_row($sql); if($link) //return "".__('« Prev', 'fgallery').""; - return "".__('« Prev', 'fgallery').""; + return "".__('« Prev', 'fgallery').""; else return __('« Prev', 'fgallery'); @@ -494,7 +511,7 @@ $order_by = get_option('fim_image_order'); $order_type = get_option('fim_image_order_type'); - return $wpdb->get_results("SELECT * FROM $table_image WHERE cat = '$catid' AND status <> 'exclude' ORDER BY `$table_image`.`$order_by` $order_type"); + return $wpdb->get_results("SELECT * FROM $table_image WHERE cat = '$catid' AND status <> 'exclude' ORDER BY `$table_image`.`$order_by` $order_type, `$table_image`.`id` $order_type"); } // Get all galleries function fim_query_cats($status = 'public')