com web/php: Show "headsup" (tips) on how many UGs are in my country: include/layout.inc
| From: | Hannes Magnusson | Date: | Thu, 23 Jan 2014 00:39:01 +0000 |
| Subject: | com web/php: Show "headsup" (tips) on how many UGs are in my country: include/layout.inc | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-18206@lists.php.net to get a copy of this message | ||
Commit: 8bb3bdedb0df38d6a4bf2d7b63a599dad757af64
Author: Hannes Magnusson <bjori@mongodb.com> 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";