<?php
// This file is part of Photos
// Copyright (c) 2001-2004 Alex King
// see LICENSE.txt for more information
class image_list {
/*******************************************************************
* class image_list
*
* Methods:
* image_list() - initialize variables
* set_defaults() - initialize variables
*
*/
var $items; // array of item id's
var $items_string; // comma delimited string of id's
var $count; // number of items in list - I don't think I need this
var $position; // begin list at this number
var $show_n; // show n number of items in list
var $items_shown; // array of ids of items shown - I don't think I need this
function image_list() {
$this->items = array();
$this->items_string = "";
$this->count = 0;
$this->position = 0;
$this->show_n = 10;
$this->items_shown = array();
$this->nav_command = "";
}
function set_defaults($input="") {
if ($input == "") {
$input = $this->items_string;
}
if (is_array($input)) {
$this->items = $input;
}
else {
$this->items = explode(",", $input);
}
$this->count = count($this->items);
$this->items_string = implode(",", $this->items);
return $this;
}
function get_items_shown($items="", $position="", $show_n="") {
if ($items == "") {
$items = $this->items;
}
if ($position == "") {
$position = $this->position;
}
if ($show_n == "") {
$show_n = $this->show_n;
}
$items_shown = array_slice($items, $position, $show_n);
return $items_shown;
}
function print_list_header() {
global $lang;
print("<table width=\"100%\" cellpadding=\"2\" cellspacing=\"1\">\n");
print(" <tr>\n");
print(" <td width=\"50%\">");
if ($this->count == 0) {
$shown_end_n = 0;
print($lang->str("found_photos_showing_n", array(0,0,0,0)));
}
else if (count($this->items) == 1 && $this->items[0] != "") {
print($lang->str("found_photo_showing_n"));
}
else if (count($this->items) > 1 && $this->items[0] != "") {
$shown_end_n = $this->position + $this->show_n;
if ($shown_end_n > $this->count) {
$shown_end_n = $this->count;
}
print($lang->str("found_photos_showing_n"
,array($this->count, ($this->position + 1), $shown_end_n, $this->count)
)
);
}
print(" </td>\n");
print(" <td align=\"right\">");
if ($this->position != 0) {
print("<a href=\"javascript:navigateList('first');\">".$lang->str("first")." ".$this->show_n."</a>");
print(" | ");
print("<a href=\"javascript:navigateList('back');\">".$lang->str("previous")."</a>");
print(" | ");
}
else {
print($lang->str("first")." | ".$lang->str("previous")." | ");
}
if (isset($shown_end_n) && $shown_end_n < $this->count) {
print("<a href=\"javascript:navigateList('next');\">".$lang->str("next")."</a>");
print(" | ");
print("<a href=\"javascript:navigateList('last');\">".$lang->str("last")." ".$this->show_n."</a>");
}
else {
print($lang->str("next")." | ".$lang->str("last"));
}
print(" </td>\n");
print(" </tr>\n");
print("</table>\n");
}
function print_list($preview_type = "thumbnail") {
global $lang;
if ($preview_type == "contact_sheet") {
print_contact_sheet($this->items_shown, "id_list");
}
else {
print("<table width=\"100%\" cellpadding=\"2\" cellspacing=\"1\">\n");
print(" <tr class=\"rowHeader\">\n");
print(" <td nowrap><b>".$lang->str("lh_preview")."</b></td>\n");
print(" <td nowrap><b>".$lang->str("lh_details")."</b></td>\n");
print(" <td nowrap><b>".$lang->str("lh_keywords")."</b></td>\n");
print(" <td nowrap><b>".$lang->str("lh_people")."</b></td>\n");
print(" <td nowrap><b>".$lang->str("lh_event")."</b></td>\n");
print(" <td nowrap><b>".$lang->str("lh_location")."</b></td>\n");
print(" <td nowrap><b>".$lang->str("lh_date")."</b></td>\n");
print(" <td width=\"1%\"><img src=\"images/icon_indoors.gif\" height=\"16\" width=\"16\" alt=\"".$lang->str("lh_in_outdoors")."\"></td>\n");
print(" <td width=\"1%\"><img src=\"images/icon_portfolio.gif\" height=\"16\" width=\"16\" alt=\"".$lang->str("lh_portfolio_shot")."\"></td>\n");
print(" <td width=\"1%\"><img src=\"images/icon_details.gif\" height=\"16\" width=\"16\" alt=\"".$lang->str("add_details")."\"></td>\n");
print(" <td width=\"1%\"><img src=\"images/icon_edit.gif\" height=\"16\" width=\"16\" alt=\"".$lang->str("edit")."\"></td>\n");
print(" </tr>\n");
if (empty($this->items[0])) {
print(" <tr class=\"rowOdd\">\n");
print(" <td colspan=\"10\">".$lang->str("no_photos_to_display")."</td>\n");
print(" </tr>\n");
}
else {
for ($i = 0; $i < count($this->items_shown); $i++) {
$temp_image = new image;
$temp_image = $temp_image->retrieve($this->items_shown[$i]);
if (($i + 1) % 2 == 1) {
print(" <tr class=\"rowOdd\" valign=\"top\">\n");
}
else {
print(" <tr class=\"rowEven\" valign=\"top\">\n");
}
if (!empty ($temp_image->thumbnail) && $preview_type == "thumbnail") {
print(" <td align=\"center\"><a href=\"index.php?screen=view&id=".$temp_image->id."\"><img src=\"image.php?id=".$temp_image->id."\" class=\"onePixelBorder\"></a></td>\n");
}
else {
print(" <td><a href=\"javascript:previewImage('".$temp_image->URL."',".$temp_image->orientation.");\">".$lang->str("lh_preview")."</a></td>\n");
}
$last_slash_pos = strrpos($temp_image->URL, "/") + 1;
$file_name = substr($temp_image->URL,$last_slash_pos);
$title = trim_add_elipsis($temp_image->title, 200);
$description = trim_add_elipsis($temp_image->description, 300);
print(" <td>\n");
print(" <table width=\"100%\" cellpadding=\"2\" cellspacing=\"0\">\n");
print(" <tr valign=\"top\">\n");
print(" <td width=\"1%\" align=\"right\"><b>".$lang->str("title")."</b></td>\n");
print(" <td colspan=\"3\"><a href=\"index.php?screen=view&id=".$temp_image->id."\">".html($title)."</a></td>\n");
print(" </tr>\n");
print(" <tr valign=\"top\">\n");
print(" <td width=\"1%\" align=\"right\"><b>".$lang->str("desc")."</b></td>\n");
print(" <td colspan=\"3\">".html($description)."</td>\n");
print(" </tr>\n");
print(" <tr valign=\"top\">\n");
print(" <td width=\"1%\" align=\"right\"><b>".$lang->str("id")."</b></td>\n");
print(" <td><a href=\"index.php?screen=view&id=".$temp_image->id."\">".$temp_image->id."</a></td>\n");
print(" <td width=\"1%\" align=\"right\"><b>".$lang->str("file")."</b></td>\n");
print(" <td><a href=\"".$temp_image->URL."\">".$file_name."</a></td>\n");
print(" </tr>\n");
print(" </table>\n");
print(" </td>\n");
print(" <td>".html($temp_image->keywords)."</td>\n");
$people = trim_add_elipsis($temp_image->people, 100);
print(" <td>".$people."</td>\n");
print(" <td>".$temp_image->event."</td>\n");
print(" <td>".$temp_image->location."<br>".$temp_image->state." ".$temp_image->country."</td>\n");
$dateentered = substr($temp_image->dateentered, 0, 4)."-".substr($temp_image->dateentered, 4, 2)."-".substr($temp_image->dateentered, 6, 2);
print(" <td>\n");
print(" <table width=\"100%\" cellpadding=\"2\" cellspacing=\"0\">\n");
print(" <tr valign=\"top\">\n");
print(" <td nowrap>\n");
print(" ".$lang->str("taken")."<br>\n".$temp_image->datetaken."\n");
print(" </td>\n");
print(" </tr>\n");
print(" <tr valign=\"top\">\n");
print(" <td nowrap>\n");
print(" ".$lang->str("modified")."<br>\n".$dateentered."\n");
print(" </td>\n");
print(" </tr>\n");
print(" </table>\n");
print(" </td>\n");
if ($temp_image->indoors == "Indoors") {
print(" <td><img src=\"images/icon_indoors.gif\" height=\"16\" width=\"16\" alt=\"".$lang->str("indoors")."\"></td>\n");
}
elseif ($temp_image->indoors == "Outdoors") {
print(" <td><img src=\"images/icon_outdoors.gif\" height=\"16\" width=\"16\" alt=\"".$lang->str("outdoors")."\"></td>\n");
}
else {
print(" <td></td>\n");
}
if ($temp_image->portfolio == 1) {
print(" <td><img src=\"images/icon_portfolio.gif\" height=\"16\" width=\"16\" alt=\"".$lang->str("lh_portfolio_shot")."\"></td>\n");
}
else {
print(" <td></td>\n");
}
if ($temp_image->needdetails == 1) {
print(" <td><a href=\"index.php?screen=entry&id=".$temp_image->id."\"><img src=\"images/icon_details.gif\" height=\"16\" width=\"16\" border=\"0\" alt=\"".$lang->str("add_details")."\"></a></td>\n");
}
else {
print(" <td></td>\n");
}
print(" <td><a href=\"index.php?screen=entry&id=".$temp_image->id."\"><img src=\"images/icon_edit.gif\" height=\"16\" width=\"16\" border=\"0\" alt=\"".$lang->str("edit")."\"></a></td>\n");
print(" </tr>\n");
}
}
print("</table>");
}
}
function navigate($nav_command) {
switch ($nav_command) {
case 'first':
$this->position = 0;
break;
case 'back':
$this->position = $this->position - $this->show_n;
break;
case 'next':
$this->position = $this->position + $this->show_n;
break;
case 'last':
$this->position = $this->count - $this->show_n;
break;
default:
$this->position = $this->position;
}
return $this;
}
}
?>