com web/php: Show "headsup" (tips) on how many UGs are in my country: include/layout.inc
| From: | Paul Dragoonis | 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-22210@lists.php.net to get a copy of this message | ||
Commit: 8283d5a3ffa870b5d94f83632b20d9413dbb316f
Author: Hannes Magnusson <bjori@mongodb.com> Wed, 22 Jan 2014 16:39:01 -0800
Parents: 4430fdb4cb0b460c9a5d3d9e231d30abf655dd74
Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=8283d5a3ffa870b5d94f83632b20d9413dbb316f
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";