/** * @author derek@plogger.org * @return string html list of thumbnails */ function plogger_get_thumbnail_nav() { global $config; if (empty($config["enable_thumb_nav"])) { return ''; } // return if thumbnail nav turned off $image_list = $GLOBALS["image_list"]; $array_length = count($image_list); // store array length $curr = $GLOBALS["current_picture"]; $pos_array = array_keys($image_list, $curr["id"]); $curr_pos = $pos_array[0]; $range = isset($config["thumb_nav_range"]) ? $config["thumb_nav_range"] : 0; if ($range == 0) { // if length is 0, use all thumbs // get_picture_by_id modified to take arrays, so pass the whole array $thumb_pic_array = get_picture_by_id($image_list); } else { // else, add a thumb each side of current for each value of $config['thumb_nav_range'] $thumb_nav_array = array($curr['id']); for ($i = 1; $i < $range + 1; $i++) { // use unshift() to add to the beginning, push() to add to the end // check that we haven't run out of images below: that (current image - offset) >= 0 if ($curr_pos - $i >= 0) { unset($newpic); // php has problems with reassigning via iteration $newpic = $image_list[$curr_pos - $i]; if (!empty($newpic)) { array_unshift($thumb_nav_array, $newpic); } } else { // grab from the end of the array unset($newpic); // php has problems with reassigning via iteration $newpic = $image_list[$array_length + ($curr_pos - $i)]; // adding a negative value, don't fret if (!empty($newpic)) { array_unshift($thumb_nav_array, $newpic); } } // check that we haven't run out of images above: (current image + offset) <= (total images) if ($array_length - 1 >= $curr_pos + $i) { unset($newpic); // php has problems with reassigning via iteration $newpic = $image_list[$curr_pos + $i]; if (!empty($newpic)) { array_push($thumb_nav_array, $newpic); } } else { // grab from the beginning of the array unset($newpic); // php has problems with reassigning via iteration $newpic = $image_list[$curr_pos + $i - $array_length]; if (!empty($newpic)) { array_push($thumb_nav_array, $newpic); } } } $thumb_pic_array = array(); foreach ($thumb_nav_array as $thumb_nav_value) { array_push($thumb_pic_array, get_picture_by_id($thumb_nav_value)); } } return plogger_format_thumb_nav($thumb_pic_array); }
/** * @author derek@plogger.org * @return string html list of thumbnails */ function plogger_get_thumbnail_nav() { global $config, $thumbnail_config; if ($thumbnail_config[THUMB_NAV]['disabled'] == 1) { return ''; } // Return if thumbnail nav disabled $thumb_pic_array = array(); $image_list = $GLOBALS['image_list']; $array_length = count($image_list); // Store array length $curr = $GLOBALS['current_picture']; $curr_pos = array_search($curr['id'], $image_list); $range = isset($config['thumb_nav_range']) ? $config['thumb_nav_range'] : 0; // If length is 0, use all thumbs if ($range == 0) { // get_picture_by_id modified to take arrays, so pass the whole array $thumb_nav_array = $image_list; // Else, add a thumb each side of current for each value of $config['thumb_nav_range'] } else { $thumb_nav_array = array($curr['id']); $count = 1; for ($i = 1; $i < $range; $i++) { // If we're at or over our range, break the loop if ($count >= $range) { break; } // Use unshift() to add to the beginning, push() to add to the end // Check that we have images on each side if ($curr_pos - $i >= 0) { // Add a previous picture if (!empty($image_list[$curr_pos - $i])) { array_unshift($thumb_nav_array, $image_list[$curr_pos - $i]); } $count++; } if ($array_length - 1 >= $curr_pos + $i) { // Add a next picture if (!empty($image_list[$curr_pos + $i])) { array_push($thumb_nav_array, $image_list[$curr_pos + $i]); } $count++; } } // Check our range again and use array_shift to remove a single previous picture // Should only be a single digit over in case of odd numbered range if (count($thumb_nav_array) > $range) { array_shift($thumb_nav_array); } } foreach ($thumb_nav_array as $thumb_nav_value) { $thumb_pic_array[] = get_picture_by_id($thumb_nav_value); } return plogger_format_thumb_nav($thumb_pic_array); }