/** * Given index of a mosaic image, and a pixel position on that image handle a zoom * If the zoom level is 2, this needs to perform a redirect to the gridsquare page * otherwise, it reconfigures the instance for the zoomed in map * @access public */ function zoomIn($i, $j, $x, $y) { //so where did we click? list($clickx, $clicky) = $this->getClickCoordinates($i, $j, $x, $y); $zoomindex = array_search($this->pixels_per_km, $this->scales); if ($zoomindex === FALSE) { $zoomindex = 0; } $zoomindex++; if ($zoomindex > count($this->scales) || $this->pixels_per_km > 40) { //we're going to zoom into a grid square $square = new GridSquare(); if ($square->loadFromPosition($clickx, $clicky)) { $images = $square->getImages(false, '', 'order by moderation_status+0 desc,seq_no limit 2'); //if the image count is 1, we'll go straight to the image if (count($images) == 1) { $url = "http://" . $_SERVER['HTTP_HOST'] . '/photo/' . $images[0]->gridimage_id; } else { //lets go to the grid reference $url = "http://" . $_SERVER['HTTP_HOST'] . '/gridref/' . $square->grid_reference; } } else { require_once 'geograph/conversions.class.php'; $conv = new Conversions(); list($gr, $len) = $conv->internal_to_gridref($clickx, $clicky, 0); $url = "http://" . $_SERVER['HTTP_HOST'] . '/gridref/' . $gr; } header("Location:{$url}"); exit; } else { $scale = $this->scales[$zoomindex]; } //store the clicked position to make a better estimate at the required grid $this->old_centrex = $clickx; $this->old_centrey = $clicky; //size of new map in km $mapw = $this->image_w / $scale; $maph = $this->image_h / $scale; //here's the perfect origin $bestoriginx = $clickx - $mapw / 2; $bestoriginy = $clicky - $maph / 2; $this->setScale($scale); $this->setMosaicFactor(2); $this->setAlignedOrigin($bestoriginx, $bestoriginy); }
if ($gridref || $forum == $CONF['forum_gridsquare'] && ($gridref = $topicName)) { require_once 'geograph/gridimage.class.php'; require_once 'geograph/gridsquare.class.php'; $smarty = new GeographPage(); $square = new GridSquare(); $grid_ok = $square->setGridRef($gridref); if ($grid_ok) { //find a possible place within 25km $smarty->assign('place', $square->findNearestPlace(75000)); if ($square->imagecount) { //todo use smarty caching //what style should we use? $style = $USER->getStyle(); $smarty->assign('maincontentclass', 'content_photo' . $style); $smarty->assign('backgroundcolor', $style); $images = $square->getImages(); $smarty->assign_by_ref('images', $images); } $smarty->assign('gridref', $gridref); $gridThumbs = $smarty->fetch("_discuss_gridref_cell.tpl"); } } } $numRows = $topicData[5]; $topicDesc = 0; $topic_reverse = ''; $srt = 'ASC'; if (isset($themeDesc) and in_array($topic, $themeDesc)) { $topicDesc = 1; $topic_reverse = "<img src=\"{$static_url}/img/topic_reverse.gif\" align=middle border=0 alt=\"\"> "; $srt = 'DESC';
$breakdown[$i]['link'] = "/gridref/{$square->grid_reference}?{$_GET['by']}={$row[0]}" . $extra; } $i++; } } $smarty->assign('by', $_GET['by']); if (!empty($breakdown_title)) { $smarty->assign_by_ref('breakdown_title', $breakdown_title); } if (count($breakdown)) { $smarty->assign_by_ref('breakdown', $breakdown); $smarty->assign('breakdown_count', count($breakdown)); } } else { //todo ideally here we only want to forward teh user_id IF they have images in the square, or a mod, for greater cachablity, but the chicken and the egg thingy.... $images = $square->getImages($inc_all_user, $custom_where, 'order by ftf desc,gridimage_id'); $square->totalimagecount = count($images); foreach ($images as $img) { $img->grid_reference = $square->grid_reference; } //otherwise, lets gether the info we need to display some thumbs if ($square->totalimagecount) { $smarty->assign_by_ref('images', $images); } } $smarty->assign('totalimagecount', $square->totalimagecount); if ($square->totalimagecount < 10 || $USER->registered && !empty($_GET['big'])) { $smarty->assign('thumbw', 213); $smarty->assign('thumbh', 160); } else { $smarty->assign('thumbw', 120);
function handleGridref($more = false) { $square = new GridSquare(); $grid_given = true; $grid_ok = $square->setByFullGridRef($this->params[0]); $_GET['key'] = $this->params[1]; ini_set('memory_limit', '64M'); $image = new GridImage(); if ($grid_ok) { $this->beginResponse(); if ($square->imagecount) { if (!empty($_GET['limit']) || !empty($_GET['offset'])) { $offset = @intval($_GET['offset']); $limit = empty($_GET['limit']) ? 20 : intval($_GET['limit']); $order = "order by null limit {$offset},{$limit}"; } else { $order = "order by null"; } $images = $square->getImages(false, '', $order); $count = count($images); if ($this->output == 'json') { require_once '3rdparty/JSON.php'; $json = new Services_JSON(); $whitelist = array('gridimage_id' => 1, 'seq_no' => 1, 'user_id' => 1, 'ftf' => 1, 'moderation_status' => 1, 'title' => 1, 'comment' => 1, 'submitted' => 1, 'realname' => 1, 'nateastings' => 1, 'natnorthings' => 1, 'natgrlen' => 1, 'imageclass' => 1, 'imagetaken' => 1, 'upd_timestamp' => 1, 'viewpoint_eastings' => 1, 'viewpoint_northings' => 1, 'viewpoint_grlen' => 1, 'view_direction' => 1, 'use6fig' => 1, 'credit_realname' => 1, 'profile_link' => 1); #$whitelist = array('gridimage_id'=>1, 'seq_no'=>1, 'user_id'=>1, 'ftf'=>1, 'moderation_status'=>1, 'title'=>1, 'comment'=>1, 'submitted'=>1, 'realname'=>1, 'tags'=>1, 'nateastings'=>1, 'natnorthings'=>1, 'natgrlen'=>1, 'imageclass'=>1, 'imagetaken'=>1, 'upd_timestamp'=>1, 'viewpoint_eastings'=>1, 'viewpoint_northings'=>1, 'viewpoint_grlen'=>1, 'view_direction'=>1, 'use6fig'=>1, 'credit_realname'=>1, 'profile_link'=>1); #FIXME title1,title2,comment1,comment2 foreach ($images as $i => $image) { foreach ($image as $k => $v) { if (empty($v) || empty($whitelist[$k])) { unset($images[$i]->{$k}); } } $images[$i]->thumbnail = $image->getThumbnail(120, 120, true); } print $json->encode($images); } else { echo '<status state="ok" count="' . $count . '"/>'; #FIXME title1,title2,comment1,comment2 foreach ($images as $i => $image) { if ($image->moderation_status == 'geograph' || $image->moderation_status == 'accepted') { echo " <image url=\"http://{$_SERVER['HTTP_HOST']}/photo/{$image->gridimage_id}\">"; echo ' <title>' . utf8_encode(htmlentities($image->title)) . '</title>'; echo " <user profile=\"http://{$_SERVER['HTTP_HOST']}{$image->profile_link}\">" . utf8_encode(htmlentities($image->realname)) . '</user>'; echo ' ' . preg_replace('/alt=".*?" /', '', $image->getThumbnail(120, 120)); if ($more) { echo '<taken>' . htmlentities($image->imagetaken) . '</taken>'; echo '<submitted>' . htmlentities($image->submitted) . '</submitted>'; echo '<category>' . utf8_encode(htmlentities2($image->imageclass)) . '</category>'; echo '<comment><![CDATA[' . utf8_encode(htmlentities2($image->comment)) . ']]></comment>'; echo '<view_direction>' . htmlentities($image->view_direction) . '</view_direction>'; } echo ' <location grid="' . $square->reference_index . '" eastings="' . $image->nateastings . '" northings="' . $image->natnorthings . '" figures="' . $image->natgrlen . '"/>'; echo '</image>'; } } } } else { if ($this->output == 'json') { print "{error: '0 results'}"; } else { echo '<status state="ok" count="0"/>'; } } $this->endResponse(); } else { $this->error("Invalid grid reference " . $this->params[0]); } }