/** * Returns a map graph object for the implementations by country * * This function returns a {@link google_charts_map_graph} object that can be used * to display a world map with countries highlighted by the number of registered * implementations we know about. * * Use this function in the following way * <code> * $graph = moodle_implementation_map_graph(); * echo "<p><img src='$graph' alt='Unable to display the graph sorry' /></p> * </code> * * The graph is printable by the __toString method so you are able to use it * directly in an output statement sych as echo. * * @global object * @global array * @return google_charts_map_graph */ function moodle_implementation_map_graph() { global $CFG, $DB; $graph = new google_charts_map_graph(); $graph->set_chart_title("Total known sites"); $filename = 'implementations_map_graph.' . STATS_CACHE_FILE_NAME_ID . '.png'; if (!$graph->set_filename($filename)) { // There is an error setting the filename probably that we were unable // to create the stats directory in moodledata } if ($graph->check_if_graph_exists()) { return $graph; } list($where, $params) = local_hub_stats_get_confirmed_sql(); $sql = "SELECT r.countrycode, COUNT(r.id) AS countrycount\n FROM {hub_site_directory} r\n WHERE {$where}\n GROUP BY r.countrycode\n ORDER BY countrycount DESC"; $countryresults = $DB->get_records_sql($sql, $params); $count = 0; while ($count < 40) { $country = array_shift($countryresults); $graph->add_value($country->countrycode, 100 - $count * 5); $count++; } foreach ($countryresults as $country) { $graph->add_value($country->countrycode, 5); } return $graph; }
$votesiteid = $uncool; $votemodifier = -1; } } if (isset($votesiteid) && isloggedin() && confirm_sesskey()) { $message = vote_for_site($votesiteid, $votemodifier); } $sites = get_sites_for_country($country); if ($sitevoting) { if ($sitevoting == 1) { $USER->sitevoting = true; } else { $USER->sitevoting = false; } } $graph = new google_charts_map_graph(); $graph->force_generation(true); $graph->set_chart_title($countries[$country] . " map"); $graph->set_default_colour('FFEAB3'); $filename = 'country.map.' . $country . '.png'; $graph->set_filename($filename); $graph->add_value($country, 100); $graph = html_writer::empty_tag('img', array('src' => new moodle_url($graph), 'alt' => $countries[$country] . " map", 'class' => 'countrymapimg')); $list = new stdClass(); $list->printanchors = true; $list->width = '100%'; if ($sites->privatesites > 0) { $list->heading = $countries[$country] . " <span style='font-size:0.6em;'>{$sites->totalsites} sites total ({$sites->privatesites} are private and are not shown)</span>{$graph}"; } else { $list->heading = $countries[$country] . " <span style='font-size:0.6em;'>{$sites->totalsites} sites total</span>{$graph}"; }