function &GetImageParameters($inputarray) { $base_url = "CISOROOT=" . $inputarray["CISOROOT"] . "&CISOPTR=" . $inputarray["CISOPTR"]; if (isset($inputarray['CISOSHOW'])) { $base_url .= "&CISOSHOW=" . $inputarray['CISOSHOW']; } global $dmrec, $querystr, $stat; $dmrec = isset($_GET["REC"]) ? $_GET["REC"] : 1; $dmrotate = isset($_GET["DMROTATE"]) ? $_GET["DMROTATE"] : "0"; $res = array(); $res["image_cisoroot"] = $inputarray["CISOROOT"]; $res["image_cisoptr"] = $inputarray["CISOPTR"]; $res["image_cisoshow"] = $inputarray["CISOSHOW"]; $rc = dmGetImageInfo($inputarray["CISOROOT"], $inputarray["CISOPTR"], $absfn, $ext, $imgwidth, $imgheight); if ($rc == -1) { print "<!-- No permission to access this item -->\n"; $res["image_src"] = -1; return $res; } $irc = 0; $types = explode(',', S_ALLOWED_ZOOM_IMAGE_TYPES); for ($i = 0; $i < count($types); $i++) { if ($ext == trim($types[$i])) { $irc = 1; break; } } if ($irc == 1) { /* Read the collection default parameters */ dmGetCollectionImageSettings($inputarray["CISOROOT"], $enabled, $minjpegdim, $step, $maxderivedimg, $viewer, $docviewer, $compareviewer, $slideshowviewer); $numsteps = count($step); $dmwidth = $inputarray["DMWIDTH"] != "" ? $inputarray["DMWIDTH"] : $viewer["width"]; $dmheight = $inputarray["DMHEIGHT"] != "" ? $inputarray["DMHEIGHT"] : $viewer["height"]; $dmscale = $inputarray["DMSCALE"] != "" ? $inputarray["DMSCALE"] : $viewer["scale"]; $width = $dmwidth; if ($width <= 0) { $width = DEFAULTWIDTH; } elseif ($width > MAXWIDTH) { $width = MAXWIDTH; } if ($dmheight == "A" && $dmscale == "W") { $height = $imgheight * $width / $imgwidth; } else { $height = $dmheight; if ($height <= 0) { $height = DEFAULTHEIGHT; } elseif ($height > MAXHEIGHT) { $height = MAXHEIGHT; } } if ($inputarray["DMX"] == "") { $oldx = 0; } else { $oldx = $inputarray["DMX"]; if ($oldx < 0) { $oldx = 0; } } if ($inputarray["DMY"] == "") { $oldy = 0; } else { $oldy = $inputarray["DMY"]; if ($oldy < 0) { $oldy = 0; } } if ($dmscale == "F") { for ($k = 0; $k < $numsteps; $k++) { if ($step[$k] * $imgwidth / 100 > $width || $step[$k] * $imgheight / 100 > $height) { break; } } $k--; if ($k < 0) { $k = 0; } $scale = $step[$k]; } elseif ($dmscale == "W") { $scale = $width * 100.0 / $imgwidth; } else { $scale = $dmscale; if ($scale <= 0) { $scale = 100; } } if ($scale > MAXSCALE) { $scale = MAXSCALE; } $nextscaleup = NextScale($scale, $step, $numsteps, 1); $nextscaledown = NextScale($scale, $step, $numsteps, 0); if ($inputarray["DMROTATE"] == 90) { $clickx = $width - $inputarray["y"]; $clicky = $inputarray["x"]; } elseif ($inputarray["DMROTATE"] == 180) { $clickx = $width - $inputarray["x"]; $clicky = $height - $inputarray["y"]; } elseif ($inputarray["DMROTATE"] == 270) { $clickx = $inputarray["y"]; $clicky = $width - $inputarray["x"]; } else { $clickx = $inputarray["x"]; $clicky = $inputarray["y"]; } $dmoldscale = $inputarray["DMOLDSCALE"]; $dmfull = $inputarray["DMFULL"]; $dmtext = $inputarray["DMTEXT"]; if ($dmtext != "") { $dmtext = str_replace(" ", "%20", $dmtext); $dmtext = str_replace("'", "%27", $dmtext); } if ($clickx != "") { if ($dmoldscale == "") { $oldscale = $nextscaledown; } else { $oldscale = $dmoldscale; } $offsetx = $clickx; if ($offsetx < 0) { $offsetx = 0; } $offsety = $clicky; if ($offsety < 0) { $offsety = 0; } if ($dmfull == "1") { $offsetx = $offsetx - $width / 2; $offsety = $offsety - $height / 2; } else { if (isset($dmoldscale[0]) && $dmoldscale[0] != "") { $offsetx = (int) ($scale / $oldscale * $offsetx) - $width / 2; $offsety = (int) ($scale / $oldscale * $offsety) - $height / 2; } else { $offsetx = (int) ($scale / $oldscale * ($offsetx - $width / 2)); $offsety = (int) ($scale / $oldscale * ($offsety - $height / 2)); } } $oldx = $oldx + $offsetx; if ($oldx + $width > $scale * $imgwidth / 100) { $oldx = (int) ($scale * $imgwidth / 100) - $width; } if ($oldx < 0) { $oldx = 0; } $oldy = $oldy + $offsety; if ($oldy + $height > $scale * $imgheight / 100) { $oldy = (int) ($scale * $imgheight / 100) - $height; } if ($oldy < 0) { $oldy = 0; } } /* Zoom in */ if ($nextscaleup > $scale) { if ($scale * $imgwidth / 100 < $width) { $min = (int) ($scale * $imgwidth) / 100; } else { $min = $width; } $tempx = (int) ($nextscaleup / $scale * ($oldx + $min / 2)) - $width / 2; if ($tempx + $width > $nextscaleup * $imgwidth / 100) { $tempx = (int) ($nextscaleup * $imgwidth / 100) - $width; } if ($tempx < 0) { $tempx = 0; } if ($scale * $imgheight / 100 < $height) { $min = (int) ($scale * $imgheight) / 100; } else { $min = $height; } $tempy = (int) ($nextscaleup / $scale * ($oldy + $min / 2)) - $height / 2; if ($tempy + $height > $nextscaleup * $imgheight / 100) { $tempy = (int) ($nextscaleup * $imgheight / 100) - $width; } if ($tempy < 0) { $tempy = 0; } $res["image_zoomin_link"] = zoom_link($inputarray["CISOROOT"], $inputarray["CISOPTR"], $nextscaleup, $width, $height, $tempx, $tempy, $dmtext, $dmrec, $dmrotate); } else { $res["image_zoomin_link"] = ""; } /* Zoom out */ if ($scale * $imgwidth / 100 < $width) { $min = (int) ($scale * $imgwidth) / 100; } else { $min = $width; } $tempx = (int) ($nextscaledown / $scale * ($oldx + $min / 2)) - $width / 2; if ($tempx + $width > $nextscaledown * $imgwidth / 100) { $tempx = (int) ($nextscaledown * $imgwidth / 100) - $width; } if ($tempx < 0) { $tempx = 0; } if ($scale * $imgheight / 100 < $height) { $min = (int) ($scale * $imgheight) / 100; } else { $min = $height; } $tempy = (int) ($nextscaledown / $scale * ($oldy + $min / 2)) - $height / 2; if ($tempy + $height > $nextscaledown * $imgheight / 100) { $tempy = (int) ($nextscaledown * $imgheight / 100) - $height; } if ($tempy < 0) { $tempy = 0; } if ($nextscaledown < $scale) { $res["image_zoomout_link"] = zoom_link($inputarray["CISOROOT"], $inputarray["CISOPTR"], $nextscaledown, $width, $height, $tempx, $tempy, $dmtext, $dmrec, $dmrotate); } else { $res["image_zoomout_link"] = ""; } /* Scale percentage box */ $temppct = sprintf("%.1f", $scale); $res["image_pct_display"] = $temppct; /* Zoom steps */ $steps = array(); foreach ($step as $current_step) { $steps[$current_step] = array('level' => $current_step, 'url' => zoom_link($inputarray["CISOROOT"], $inputarray["CISOPTR"], $current_step, $width, $height, $tempx, $tempy, $dmtext, $dmrec, $dmrotate)); } ksort($steps, SORT_NUMERIC); $res['steps'] = $steps; $res["current_zoom"] = $scale; /* Full res */ if ($scale * $imgwidth / 100 < $width) { $min = (int) ($scale * $imgwidth) / 100; } else { $min = $width; } $tempx = (int) (100.0 / $scale * ($oldx + $min / 2)) - $width / 2; if ($tempx + $width > 100 * $imgwidth / 100) { $tempx = (int) (100 * $imgwidth / 100) - $width; } if ($tempx < 0) { $tempx = 0; } if ($scale * $imgheight / 100 < $height) { $min = (int) ($scale * $imgheight) / 100; } else { $min = $height; } $tempy = (int) (100.0 / $scale * ($oldy + $min / 2)) - $height / 2; if ($tempy + $height > 100.0 * $imgheight / 100) { $tempy = (int) (100 * $imgheight / 100) - $width; } if ($tempy < 0) { $tempy = 0; } $res["image_full_link"] = $base_url . "&DMSCALE=100&DMWIDTH=" . $width . "&DMHEIGHT=" . $height . "&DMX=" . $tempx . "&DMY=" . $tempy . "&DMTEXT=" . str_replace('%2520', '%20', urlencode($dmtext)) . "&REC=" . $dmrec . "&DMROTATE=" . $dmrotate; /* Fit in window */ for ($k = 0; $k < $numsteps; $k++) { if ($step[$k] * $imgwidth / 100 > $width || $step[$k] * $imgheight / 100 > $height) { break; } } $k--; if ($k < 0) { $k = 0; } $res["image_fit_link"] = $base_url . "&DMSCALE=" . $step[$k] . "&DMWIDTH=" . $width . "&DMHEIGHT=" . $height . "&DMTEXT=" . str_replace('%2520', '%20', urlencode($dmtext)) . "&REC=" . $dmrec . "&DMROTATE=" . $dmrotate; /* Full width */ $tempscale = $width * 100.0 / $imgwidth; $temppct = sprintf("%.5f", $tempscale); $res["image_width_link"] = $base_url . "&DMSCALE=" . $temppct . "&DMWIDTH=" . $width . "&DMHEIGHT=" . $height . "&DMTEXT=" . str_replace('%2520', '%20', urlencode($dmtext)) . "&REC=" . $dmrec . "&DMROTATE=" . $dmrotate; $res["image_scale"] = $nextscaleup; $res["image_width"] = $width; $res["image_height"] = $height; if ($scale == $nextscaleup) { $res["image_full"] = "1"; } else { $res["image_full"] = "0"; } if ($scale * $imgwidth / 100 < $width) { $min = (int) ($scale * $imgwidth) / 100; } else { $min = $width; } $tempx = (int) ($nextscaleup / $scale * ($oldx + $min / 2)) - $width / 2; if ($tempx + $width > $nextscaleup * $imgwidth / 100) { $tempx = (int) ($nextscaleup * $imgwidth / 100) - $width; } if ($tempx < 0) { $tempx = 0; } if ($scale * $imgheight / 100 < $height) { $min = (int) ($scale * $imgheight) / 100; } else { $min = $height; } $tempy = (int) ($nextscaleup / $scale * ($oldy + $min / 2)) - $height / 2; if ($tempy < 0) { $tempy = 0; } $res["image_x"] = $tempx; $res["image_y"] = $tempy; $res["image_text"] = $dmtext; $temppct = sprintf("%.5f", $scale); $res["image_src"] = "/cgi-bin/getimage.exe?" . $base_url . "&DMSCALE=" . $temppct . "&DMWIDTH=" . $width . "&DMHEIGHT=" . $height . "&DMX=" . $oldx . "&DMY=" . $oldy . "&DMTEXT=" . str_replace('%2520', '%20', urlencode($dmtext)) . "&REC=" . $dmrec . "&DMROTATE=" . $dmrotate; if ($imgwidth < $imgheight) { $scalet = MAXTHUMBDIM * 100.0 / $imgheight; } else { $scalet = MAXTHUMBDIM * 100.0 / $imgwidth; } $thumbw = (int) ($scalet * $imgwidth / 100.0); $thumbh = (int) ($scalet * $imgheight / 100.0); $tx = (int) ($scalet / $scale * $oldx); $ty = (int) ($scalet / $scale * $oldy); $tw = (int) ($scalet / $scale * $width); $th = (int) ($scalet / $scale * $height); if ($tw > $thumbw) { $tw = $thumbw; } if ($th > $thumbh) { $th = $thumbh; } $temppct = sprintf("%.5f", $scalet); $res["image_oldscale"] = $temppct; $temppct = sprintf("%.5f", $scale); $res["image_currentscale"] = $temppct; $temppct = sprintf("%.5f", $scalet); $res["image_guide_src"] = "/cgi-bin/getimage.exe?" . $base_url . "&DMSCALE=" . $temppct . "&DMWIDTH=" . $thumbw . "&DMHEIGHT=" . $thumbh . "&DMX=0&DMY=0" . "&DMBOUND=" . $tx . "," . $ty . "," . $tw . "," . $th . "&REC=" . $dmrec . "&DMROTATE=" . $dmrotate; $res["image_thumbnail_width"] = $thumbw; /* Rotate functions */ if ($dmrotate == "360") { $dmrotate = "0"; } $rleft = $dmrotate + 90; $rright = ($dmrotate + 270) % 360; $res["image_rotateleft_link"] = stripUrlVar($querystr, 'DMROTATE') . "&DMROTATE=" . $rleft; $res["image_rotateright_link"] = stripUrlVar($querystr, 'DMROTATE') . "&DMROTATE=" . $rright; } else { $res["image_src"] = -1; } return $res; }
?> </li> <?php } ?> <li class="next"> <?php if ($currentpage == $totalpages) { ?> Next <?php } else { ?> <?php if ($currentpage == $d) { $next_url = $self . '?' . htmlentities(stripUrlVar($querystr, 'CISOSTART')) . '&CISOSTART=' . ($start[0] + $increase) . ',' . ($start[1] + $maxrecs); } else { $next_url = $self . '?' . htmlentities(stripUrlVar($querystr, 'CISOSTART')) . '&CISOSTART=' . $start[0] . ',' . ($start[1] + $maxrecs); } ?> <a href="<?php echo $next_url; ?> ">Next</a> <?php } ?> </li> </ul> <?php }
function sortCarrot($f, $g) { $ret = ''; global $sortby, $self, $querystr; if (isset($_GET["CISOSORT"])) { $so = explode('|', $_GET["CISOSORT"]); if (isset($so[1])) { if ($so[0] == $f && $so[1] == "f") { $ret = ' <a href="' . $self . '?' . stripUrlVar($querystr, 'CISOSORT') . '&CISOSORT=' . $f . '|r" title="' . L_ALT_REVERSE_SORT . $g . '"><img src="/cdm4/images/up_arrow.gif" width="9" height="9" border="0" alt="" /> ' . $g . ':</a>'; } if ($so[0] == $f && $so[1] == "r") { $ret = ' <a href="' . $self . '?' . stripUrlVar($querystr, 'CISOSORT') . '&CISOSORT=' . $f . '|f" title="' . L_ALT_FORWARD_SORT . $g . '"><img src="/cdm4/images/down_arrow.gif" width="9" height="9" border="0" alt="" /> ' . $g . ':</a>'; } elseif ($so[0] != $f) { $ret = ' <a href="' . $self . '?' . stripUrlVar($querystr, 'CISOSORT') . '&CISOSORT=' . $f . '|f" title="' . L_ALT_FORWARD_SORT . $g . '"> ' . $g . ':</a>'; } } } else { if (count($sortby) != 0) { if ($sortby[0] == $f) { $ret = ' <a href="' . $self . '?' . stripUrlVar($querystr, 'CISOSORT') . '&CISOSORT=' . $f . '|r" title="' . L_ALT_REVERSE_SORT . $g . '"><img src="/cdm4/images/up_arrow.gif" width="9" height="9" border="0" alt="" /> ' . $g . ':</a>'; } elseif ($sortby[0] != $f) { $ret = ' <a href="' . $self . '?' . stripUrlVar($querystr, 'CISOSORT') . '&CISOSORT=' . $f . '|f" title="' . L_ALT_FORWARD_SORT . $g . '"> ' . $g . ':</a>'; } } } return $ret; }