コード例 #1
0
ファイル: article.php プロジェクト: s-a-r-id/geograph-project
}
if (!$smarty->is_cached($template, $cacheid)) {
    if (count($page)) {
        $CONF['global_thumb_limit'] *= 2;
        $CONF['post_thumb_limit'] *= 2;
        $smarty->assign($page);
        if (!empty($page['extract'])) {
            $smarty->assign('meta_description', "User contributed article about, " . $page['extract']);
        }
        if (!empty($page['gridsquare_id'])) {
            $square = new GridSquare();
            $square->loadFromId($page['gridsquare_id']);
            $smarty->assign('grid_reference', $square->grid_reference);
            require_once 'geograph/conversions.class.php';
            $conv = new Conversions();
            list($lat, $long) = $conv->gridsquare_to_wgs84($square);
            $smarty->assign('lat', $lat);
            $smarty->assign('long', $long);
        }
        if (preg_match('/\\bgeograph\\b/i', $page['category_name'])) {
            $db->Execute("set @last=0");
            $users = $db->getAll("select realname,modifier,update_time,if(approved = @last,1,0) as same,@last := approved \r\n\t\t\tfrom article_revisions \r\n\t\t\tleft join user on (article_revisions.modifier = user.user_id)\r\n\t\t\twhere article_id = {$page['article_id']}");
            $arr = array();
            foreach ($users as $idx => $row) {
                if ($row['same'] == 1 && $row['modifier'] != $page['user_id'] && !isset($arr[$row['modifier']])) {
                    $arr[$row['modifier']] = "<a href=\"/profile/{$row['modifier']}\">" . htmlentities2($row['realname']) . "</a>";
                }
            }
            $str = preg_replace('/, ([^\\,]*?)$/', ' and $1', implode(', ', $arr));
            $smarty->assign('moreCredits', $str);
        }
コード例 #2
0
ファイル: compare.php プロジェクト: s-a-r-id/geograph-project
    $pair = $db->getRow("\r\n\t\tSELECT p.compare_pair_id,gridimage_id1,gridimage_id2\r\n\t\tFROM compare_pair p\r\n\t\tLEFT JOIN compare_done d ON (p.compare_pair_id = d.compare_pair_id AND {$where})\r\n\t\tWHERE status != 'rejected' AND d.compare_pair_id IS NULL", $a);
}
if (!empty($pair['compare_pair_id'])) {
    $smarty->assign('pair_id', $pair['compare_pair_id']);
    $token = new Token();
    $token->setValue("p", $pair['compare_pair_id']);
    $smarty->assign('token', $token->getToken());
    require_once 'geograph/conversions.class.php';
    $conv = new Conversions();
    $image1 = new GridImage($pair['gridimage_id1']);
    if ($image1->moderation_status != 'rejected') {
        $rastermap1 = new RasterMap($image1->grid_square);
        if ($image1->view_direction > -1) {
            $smarty->assign('view_direction1', $image1->view_direction % 90 == 0 ? strtoupper(heading_string($image1->view_direction)) : ucwords(heading_string($image1->view_direction)));
        }
        list($lat, $long) = $conv->gridsquare_to_wgs84($image1->grid_square);
        $smarty->assign('lat1', $lat);
        $smarty->assign('long1', $long);
        list($latdm, $longdm) = $conv->wgs84_to_friendly($lat, $long);
        $smarty->assign('latdm1', $latdm);
        $smarty->assign('longdm1', $longdm);
        $smarty->assign_by_ref('image1', $image1);
        $smarty->assign_by_ref('rastermap1', $rastermap1);
    }
    $image2 = new GridImage($pair['gridimage_id2']);
    if ($image2->moderation_status != 'rejected') {
        $rastermap2 = new RasterMap($image2->grid_square);
        if ($image2->view_direction > -1) {
            $smarty->assign('view_direction2', $image2->view_direction % 90 == 0 ? strtoupper(heading_string($image2->view_direction)) : ucwords(heading_string($image2->view_direction)));
        }
        list($lat, $long) = $conv->gridsquare_to_wgs84($image2->grid_square);
コード例 #3
0
    }
    $sql = "SELECT *\nFROM `geobb_topics`\nINNER JOIN geobb_posts ON ({$sql_join})\n{$sql_where}\nORDER BY {$sql_order}\nLIMIT 30";
    $recordSet =& $db->Execute($sql);
    while (!$recordSet->EOF) {
        $item = new FeedItem();
        $item->title = $recordSet->fields['topic_title'];
        //htmlspecialchars is called on link so dont use &amp;
        $item->link = "http://{$_SERVER['HTTP_HOST']}/discuss/?action=vthread&topic={$recordSet->fields['topic_id']}";
        $description = preg_replace('/^<i>[^<]+<\\/i>([\\n\\r]*<br>)?([\\n\\r]*<br>)?([\\n\\r]*<br>)?/', '', $recordSet->fields['post_text']);
        if (strlen($description) > 160) {
            $description = substr($description, 0, 157) . "...";
        }
        $item->description = GeographLinks($description);
        $item->date = strtotime($recordSet->fields['post_time']);
        //$item->source = "http://{$_SERVER['HTTP_HOST']}/discuss/";
        $item->author = $recordSet->fields['poster_name'];
        if ($format == 'KML' || $format == 'GeoRSS' || $format == 'GPX') {
            $gridsquare = new GridSquare();
            $grid_ok = $gridsquare->setGridRef($recordSet->fields['topic_title']);
            if ($grid_ok) {
                list($item->lat, $item->long) = $conv->gridsquare_to_wgs84($gridsquare);
            }
        }
        $rss->addItem($item);
        $recordSet->MoveNext();
    }
}
customExpiresHeader(3600, true);
//we cache it for an hour anyway!
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
$rss->saveFeed($format, $rssfile);
コード例 #4
0
ファイル: kml.php プロジェクト: s-a-r-id/geograph-project
 }
 $version42plus = false;
 if ($_GET['new']) {
     $version42plus = true;
 }
 //if (check version) {
 //	$version42plus = true;
 //}
 //when this image was modified
 $mtime = strtotime($image->upd_timestamp);
 customCacheControl($mtime, $image->gridimage_id . '|' . $version42plus);
 customExpiresHeader(3600 * 24 * 48, true);
 require_once 'geograph/conversions.class.php';
 $conv = new Conversions();
 //because we not loading from the search cache need to recalculate this
 list($image->wgs84_lat, $image->wgs84_long) = $conv->gridsquare_to_wgs84($image->grid_square);
 $kml = new kmlFile();
 $kml->atom = true;
 $stylefile = "http://{$CONF['KML_HOST']}/kml/style.kmz";
 $kml->filename = "Geograph" . $image->gridimage_id . ".kml";
 $point = new kmlPoint($image->wgs84_lat, $image->wgs84_long);
 $placemark = $kml->addChild(new kmlPlacemark_Photo('id' . $image->gridimage_id, $image->grid_reference . " : " . $image->title, $point));
 $placemark->useHoverStyle();
 $placemark->useCredit($image->realname, "http://{$_SERVER['HTTP_HOST']}/photo/" . $image->gridimage_id);
 $linkTag = "<a href=\"http://{$_SERVER['HTTP_HOST']}/photo/" . $image->gridimage_id . "\">";
 $details = $image->getThumbnail(120, 120, 2);
 $thumb = $details['server'] . $details['url'];
 $thumbTag = $details['html'];
 $description = $linkTag . $thumbTag . "</a><br/>" . GeographLinks($image->comment) . " (" . $linkTag . "view full size</a>)" . "<br/><br/> &copy; Copyright <a title=\"view user profile\" href=\"http://" . $_SERVER['HTTP_HOST'] . $image->profile_link . "\">" . $image->realname . "</a> and licensed for reuse under this <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-sa/2.0/\">Creative Commons Licence</a><br/><br/>";
 $placemark->setItemCDATA('description', $description);
 //yes that is uppercase S!
コード例 #5
0
 function assignToSmarty($smarty)
 {
     global $CONF;
     $taken = $this->getFormattedTakenDate();
     //get the grid references
     $this->getSubjectGridref(true);
     $this->getPhotographerGridref(true);
     //remove grid reference from title
     $this->bigtitle = trim(preg_replace("/^{$this->grid_reference}/", '', $this->title));
     $this->bigtitle = preg_replace('/(?<![\\.])\\.$/', '', $this->bigtitle);
     $rid = $this->grid_square->reference_index;
     $gridrefpref = $CONF['gridrefname'][$rid];
     $smarty->assign('page_title', $this->bigtitle . ":: {$gridrefpref}{$this->grid_reference}");
     $smarty->assign('image_taken', $taken);
     $smarty->assign('ismoderator', $ismoderator);
     $smarty->assign_by_ref('image', $this);
     //get a token to show a suroudding geograph map
     $mosaic = new GeographMapMosaic();
     $smarty->assign('map_token', $mosaic->getGridSquareToken($this->grid_square));
     //find a possible place within 25km
     $place = $this->grid_square->findNearestPlace(75000);
     $smarty->assign_by_ref('place', $place);
     if (empty($this->comment)) {
         $smarty->assign('meta_description', "{$this->grid_reference} :: {$this->bigtitle}, " . strip_tags(smarty_function_place(array('place' => $place))));
     } else {
         $smarty->assign('meta_description', $this->comment);
     }
     if (!empty($CONF['forums'])) {
         //let's find posts in the gridref discussion forum
         $this->grid_square->assignDiscussionToSmarty($smarty);
     }
     //count the number of photos in this square
     $smarty->assign('square_count', $this->grid_square->imagecount);
     //lets add an overview map too
     $overview = new GeographMapMosaic('largeoverview');
     $overview->setCentre($this->grid_square->x, $this->grid_square->y);
     //does call setAlignedOrigin
     $overview->assignToSmarty($smarty, 'overview');
     $smarty->assign('marker', $overview->getSquarePoint($this->grid_square));
     require_once 'geograph/conversions.class.php';
     $conv = new Conversions();
     list($lat, $long) = $conv->gridsquare_to_wgs84($this->grid_square);
     $smarty->assign('lat', $lat);
     $smarty->assign('long', $long);
     list($latdm, $longdm) = $conv->wgs84_to_friendly($lat, $long);
     $smarty->assign('latdm', $latdm);
     $smarty->assign('longdm', $longdm);
     //lets add an rastermap too
     $rastermap = new RasterMap($this->grid_square, false);
     $rastermap->addLatLong($lat, $long);
     if (!empty($this->viewpoint_northings)) {
         $rastermap->addViewpoint($this->viewpoint_refindex, $this->viewpoint_eastings, $this->viewpoint_northings, $this->viewpoint_grlen, $this->view_direction);
     } elseif (isset($this->view_direction) && strlen($this->view_direction) && $this->view_direction != -1) {
         $rastermap->addViewDirection($this->view_direction);
     }
     $smarty->assign_by_ref('rastermap', $rastermap);
     $smarty->assign('x', $this->grid_square->x);
     $smarty->assign('y', $this->grid_square->y);
     if ($this->view_direction > -1) {
         $smarty->assign('view_direction', $this->view_direction % 90 == 0 ? strtoupper(heading_string($this->view_direction)) : ucwords(heading_string($this->view_direction)));
     }
     $level = $this->grid_square->imagecount > 1 ? 6 : 5;
     $smarty->assign('sitemap', getSitemapFilepath($level, $this->grid_square));
 }