function handlePhoto() { $gridimage_id = intval($this->params[0]); $_GET['key'] = $this->params[1]; $image = new GridImage(); if ($image->loadFromId($gridimage_id, 1)) { #FIXME title1,title2,comment1,comment2 if ($image->moderation_status == 'geograph' || $image->moderation_status == 'accepted') { $this->beginResponse(); if ($this->output == 'json') { require_once '3rdparty/JSON.php'; $json = new Services_JSON(); $obj = new EmptyClass(); $obj->title = $image->title; $obj->grid_reference = $image->grid_reference; $obj->profile_link = $image->profile_link; $obj->realname = $image->realname; $details = $image->getThumbnail(120, 120, 2); $obj->imgserver = $details['server']; $obj->thumbnail = $details['url']; $obj->image = $image->_getFullpath(); $obj->sizeinfo = $image->_getFullSize(); $obj->sizeinfo[3] = "0"; $obj->taken = $image->imagetaken; $obj->submitted = strtotime($image->submitted); $obj->category = $image->category; $obj->comment = $image->comment; $obj->wgs84_lat = $image->wgs84_lat; $obj->wgs84_long = $image->wgs84_long; print $json->encode($obj); } else { echo '<status state="ok"/>'; echo '<title>' . xmlentities($image->title) . '</title>'; echo '<gridref>' . htmlentities($image->grid_reference) . '</gridref>'; echo "<user profile=\"http://{$_SERVER['HTTP_HOST']}{$image->profile_link}\">" . xmlentities($image->realname) . '</user>'; echo preg_replace('/alt=".*?" /', '', $image->getFull()); $details = $image->getThumbnail(120, 120, 2); echo '<thumbnail>' . $details['server'] . $details['url'] . '</thumbnail>'; echo '<taken>' . htmlentities($image->imagetaken) . '</taken>'; echo '<submitted>' . htmlentities($image->submitted) . '</submitted>'; echo '<category>' . xmlentities($image->imageclass) . '</category>'; echo '<comment><![CDATA[' . xmlentities($image->comment) . ']]></comment>'; $size = $image->_getFullSize(); //uses cached_size if (!empty($size[4])) { echo "<original width=\"{$size[4]}\" height=\"{$size[5]}\"/>"; } } $this->endResponse(); } else { $this->error("Image {$gridimage_id} unavailable ({$image->moderation_status})"); } } else { $this->error("Invalid image id {$gridimage_id}"); } }