-
Notifications
You must be signed in to change notification settings - Fork 17
/
contacts-snippet.php
54 lines (54 loc) · 2.59 KB
/
contacts-snippet.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
$comms_url = "https://raw.githubusercontent.com/ffruhr/website-stuff/master/communities/communities.json";
$comms_json = file_get_contents($comms_url);
$comms_arr = json_decode($comms_json,TRUE);
asort($comms_arr);
echo "<table>\n";
echo "<tr><td style=\"font-weight: bold; width: 230px;\">Stadt/Community</td>\n";
echo " <td style=\"font-weight: bold; width: 50px;\">Karte</td>\n";
echo " <td style=\"font-weight: bold;\">Ansprechpartner</td>\n";
echo " <td style=\"font-weight: bold;\">Domäne</td>\n";
echo " <td style=\"font-weight: bold;\">Firmware</td>\n";
echo "</tr>\n";
foreach($comms_arr as $community_arr) { // run through communities
$community = new stdClass();
$community = json_decode(json_encode($community_arr), FALSE);
if($community->name == "Template") continue; // ignore the template
echo "<tr>\n";
if($community->url) { // if url is present
echo " <td valign=\"top\" style=\"padding-left: 10px;\"><a href=\"$community->url\" target=\"_new\">• $community->name</a>"; // link community name
} else {
echo " <td valign=\"top\" style=\"padding-left: 10px;\">• $community->name"; // else print plaintext
}
if($community->prefix) echo " ($community->prefix)"; // print prefix if present
echo "</td>\n";
if($community->map) { // if map url is present
echo " <td valign=\"top\" align=\"center\"><a href=\"$community->map\" target=\"_new\"><img src=\"http://freifunk-ruhrgebiet.de/wp-content/uploads/2014/08/location-map.png\" width=\"15\"/></a></td>\n"; // print map icon
} else {
echo " <td valign=\"top\"> </td>\n";
}
if($community->contacts) { // if contacts present
echo "<td>\n";
foreach($community->contacts as $contact) { // run through contacts
echo "<a href=\"mailto:$contact->mail\">"; // link name with mail
if($contact->firstname) echo "$contact->firstname "; // if present print firstname
if($contact->nickname) echo "'$contact->nickname' "; // if present print nickname
if($contact->lastname) echo "$contact->lastname"; // if present print lastname
echo "</a><br />\n";
}
echo "</td>\n";
} else {
echo "<td> </td>\n";
}
if($community->Domaene) { // if Domaene is present
echo " <td valign=\"top\" style=\"padding-left: 10px;\">$community->Domaene</td>"; // add Domaene name
} else {
echo " <td valign=\"top\"> </td>\n";
}
if($community->Firmware) { // if Firmware url is present
echo " <td valign=\"top\" align=\"center\"><a href=\"$community->Firmware\" target=\"_new\"><img src=\"http://freifunk-ruhrgebiet.de/wp-content/uploads/2014/08/location-map.png\" width=\"15\"/></a></td>\n"; // print map icon
} else {
echo " <td valign=\"top\"> </td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";