Commit: 8bb3bdedb0df38d6a4bf2d7b63a599dad757af64 Author: Hannes Magnusson <[email protected]> Wed, 22 Jan 2014 16:39:01 -0800 Parents: 6c4a1183e6fbf23d2430944bd313ad2d3cebed6f Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=8bb3bdedb0df38d6a4bf2d7b63a599dad757af64 Log: Show "headsup" (tips) on how many UGs are in my country Changed paths: M include/layout.inc Diff: diff --git a/include/layout.inc b/include/layout.inc index e7bfeb2..fdbf0fb 100644 --- a/include/layout.inc +++ b/include/layout.inc @@ -528,6 +528,10 @@ function site_header($title = '', $config = array()) $config["headsup"] = get_news_changes(); + if (!$config["headsup"]) { + $config["headsup"] = get_near_usergroups(); + } + $lang = language_convert($config["lang"]); $curr = $config["current"]; $classes = $config['classes']; @@ -567,6 +571,43 @@ function get_news_changes() return "<a href='{$link}'>{$title}</a>"; } } +function get_near_usergroups() +{ + global $COUNTRIES, $COUNTRY; + + if (!myphpnet_showug()) { + return false; + } + + $ugs = get_usergroups_in($COUNTRY); + $count = count($ugs); + if (!$count) { + return false; + } + + return sprintf("There %s %d <a href='/ug.php?cc=%s'>PHP User Group%c in %s</a>, are you a member of your local UG?", + $count == 1 ? "is" : "are", + $count, + $COUNTRY, + $count == 1 ? "" : "s", + $COUNTRIES[$COUNTRY] + ); + + +} +function get_usergroups_in($country) { + $filename = $_SERVER["DOCUMENT_ROOT"] . "/backend/usergroups.json"; + + $matches = array(); + $data = json_decode(file_get_contents($filename), true); + foreach($data["groups"] as $group) { + if (isset($group["ccc"]) && $group["ccc"] == $country) { + $matches[] = $group; + } + } + + return $matches; +} function news_toc($sections = null) { include dirname(__FILE__) . "/pregen-news.inc"; -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
