cvs: pearweb /public_html/map index.php

From: Date: Sun, 13 Jan 2008 20:54:41 +0000
Subject: cvs: pearweb /public_html/map index.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-cvs+get-50297@lists.php.net to get a copy of this message
dufuz Sun Jan 13 20:54:41 2008 UTC Modified files: /pearweb/public_html/map index.php Log: Request #10903 Search the map for specific developer Linked from each developers page if they have it set, additionally deal with if the user in question does not exist. Also made it so we don't try to access the google apis unless we have the info we need to really show a map. http://cvs.php.net/viewvc.cgi/pearweb/public_html/map/index.php?r1=1.12&r2=1.13&diff_format=u Index: pearweb/public_html/map/index.php diff -u pearweb/public_html/map/index.php:1.12 pearweb/public_html/map/index.php:1.13 --- pearweb/public_html/map/index.php:1.12 Sun Jan 6 00:49:00 2008 +++ pearweb/public_html/map/index.php Sun Jan 13 20:54:41 2008 @@ -15,14 +15,8 @@ * @author David Coallier <davidc@php.net> * @copyright Copyright (c) 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License - * @version $Id: index.php,v 1.12 2008/01/06 00:49:00 davidc Exp $ + * @version $Id: index.php,v 1.13 2008/01/13 20:54:41 dufuz Exp $ */ -$map = '<script type="text/javascript" language="javascript" src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=' . $_SERVER['Google_API_Key'] . '"></script>'; -response_header('PEAR Maps', false, $map); -?> - -<h1>PEAR Developer Locations</h1> -<?php $maps = array( 'world' => array('name' => 'World Map', @@ -66,45 +60,57 @@ 'thumb' => 'http://pear.cweiske.de/devmaps/peardev-australia.200.jpg', ), ); + +$data = array(); +$sql = " + SELECT u.latitude, u.longitude, u.name, u.handle + FROM users u + LEFT JOIN karma k ON u.handle = k.user + WHERE + u.latitude <> '' + AND + u.longitude <> '' + AND + k.level = 'pear.dev'"; + +if (isset($_GET['handle']) && !empty($_GET['handle'])) { + $sql .= ' + AND + u.handle = ?'; + $handle = htmlspecialchars($_GET['handle']); + $data[] = $handle; +} + +$infos = $dbh->getAll($sql, $data); +if (!empty($infos)) { + $map = '<script type="text/javascript" language="javascript" src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=' . $_SERVER['Google_API_Key'] . '"></script>'; + response_header('PEAR Maps', false, $map); ?> +<h1>PEAR Developer Locations</h1> + <p> The map below contains the locations of the PEAR developers who have added their location to their user profile. </p> <noscript> - <?php - print '<h1>Maps Links</h1>'; +<?php + echo '<h1>Maps Links</h1>'; foreach ($maps as $map) { echo '<a href="' . $map['link'] . '">' .'<img src="' . $map['thumb'] . '" alt="' . $map['name'] . '" width="200px"/>' .'</a>' . "\r\n"; } - print '<hr noshade="noshade"/>'; - ?> + echo '<hr noshade="noshade"/>'; +?> </noscript> - - <script language="javascript" type="text/javascript"> + <script language="javascript" type="text/javascript"> points = new Array(); - - <?php - $sql = " - SELECT u.latitude, u.longitude, u.name, u.handle - FROM users u - LEFT JOIN karma k ON u.handle = k.user - WHERE - u.latitude <> '' - AND - u.longitude <> '' - AND - k.level = 'pear.dev' - "; - - $infos = $dbh->getAll($sql); - foreach ($infos as $info) { - echo "points.push(['" . addslashes($info[0]) . "', '" . addslashes($info[1]) . "', '" . addslashes($info[2]) . "', '" . addslashes($info[3]) . "']);\n"; - } - ?> +?> +foreach ($infos as $info) { + echo " points.push(['" . addslashes($info[0]) . "', '" . addslashes($info[1]) . "', '" . addslashes($info[2]) . "', '" . addslashes($info[3]) . "']);\n"; +} +?> </script> <script language="javascript" type="text/javascript" src="../javascript/peardev_map.js"></script> @@ -112,6 +118,12 @@ id="peardev_map"> </div> <?php +} elseif (isset($_GET['handle']) && !empty($_GET['handle']) && empty($infos)) { + response_header('PEAR Maps'); + echo '<h1>PEAR Developer Locations</h1>'; + echo '<p>User <strong>' . $handle . '</strong> does not latitude & longitude set.</p>'; +} + if ($auth_user && empty($auth_user->latitude)) { echo "<p><strong>Tip:</strong> You can add your coordinates in your " . make_link("/account-edit.php?handle=" . $auth_user->handle, "profile") @@ -119,8 +131,11 @@ } ?> <?php -$showMap = '<script language="javascript" type="text/javascript"> +if (!empty($infos)) { + $showMap = '<script language="javascript" type="text/javascript"> showfullmap(); </script>'; - -response_footer(false, $showMap); + response_footer(false, $showMap); +} else { + response_footer(); +} \ No newline at end of file

« previous php.pear.cvs (#50297) next »