From b662ece7f84d66d0e021ca418e348aeacbf910dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Thu, 8 Dec 2016 17:57:04 -0500 Subject: [PATCH] Added Google Maps Plugin with a map to show extra field coordinates markers - Refs BT#11371 --- main/inc/lib/template.lib.php | 1 + plugin/google_maps/lang/english.php | 3 +- plugin/google_maps/lang/french.php | 3 +- plugin/google_maps/lang/spanish.php | 1 + .../src/GoogleMapsPluginPlugin.php | 4 +- plugin/google_maps/src/map_coordinates.php | 46 +++++++++++++++++ plugin/google_maps/view/map_coordinates.tpl | 50 +++++++++++++++++++ 7 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 plugin/google_maps/src/map_coordinates.php create mode 100644 plugin/google_maps/view/map_coordinates.tpl diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index 9898baad1b..ace99ef1a7 100755 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -137,6 +137,7 @@ class Template $this->twig->addFilter('img', new Twig_Filter_Function('Template::get_image')); $this->twig->addFilter('format_date', new Twig_Filter_Function('Template::format_date')); $this->twig->addFilter('api_get_local_time', new Twig_Filter_Function('api_get_local_time')); + $this->twig->addFilter('user_info', new Twig_Filter_Function('api_get_user_info')); /* $lexer = new Twig_Lexer($this->twig, array( diff --git a/plugin/google_maps/lang/english.php b/plugin/google_maps/lang/english.php index 686a68a821..26fa4c8196 100644 --- a/plugin/google_maps/lang/english.php +++ b/plugin/google_maps/lang/english.php @@ -1,4 +1,5 @@ @@ -14,7 +15,8 @@ class GoogleMapsPlugin extends Plugin { $parameters = array( 'enable_api' => 'boolean', - 'api_key' => 'text' + 'api_key' => 'text', + 'extra_field_name' => 'text' ); parent::__construct('1.0', 'José Loguercio Silva', $parameters); diff --git a/plugin/google_maps/src/map_coordinates.php b/plugin/google_maps/src/map_coordinates.php new file mode 100644 index 0000000000..b10e7b91c3 --- /dev/null +++ b/plugin/google_maps/src/map_coordinates.php @@ -0,0 +1,46 @@ + + * @package chamilo.plugin.google_maps + */ + + +$cidReset = true; + +require_once __DIR__.'/../../../main/inc/global.inc.php'; + +api_protect_admin_script(); + +$plugin = GoogleMapsPlugin::create(); + +$apiIsEnable = $plugin->get('enable_api') === 'true'; +$extraFieldName = $plugin->get('extra_field_name'); + +if ($apiIsEnable) { + $gmapsApiKey = $plugin->get('api_key'); + $htmlHeadXtra[] = ''; +} + +$em = Database::getManager(); + +$extraField = $em->getRepository('ChamiloCoreBundle:ExtraField'); +$extraField = $extraField->findOneBy(['variable' => $extraFieldName]); + +$extraFieldValues = $em->getRepository('ChamiloCoreBundle:ExtraFieldValues'); +$extraFieldValues = $extraFieldValues->findBy(['field' => $extraField->getId()]); + +$templateName = get_lang('UsersCoordinatesMap'); + +$tpl = new Template($templateName); + +$tpl->assign('extra_field_values', $extraFieldValues); + +$content = $tpl->fetch('google_maps/view/map_coordinates.tpl'); + +$tpl->assign('header', $templateName); +$tpl->assign('content', $content); +$tpl->display_one_col_template(); + diff --git a/plugin/google_maps/view/map_coordinates.tpl b/plugin/google_maps/view/map_coordinates.tpl new file mode 100644 index 0000000000..1816b4cadd --- /dev/null +++ b/plugin/google_maps/view/map_coordinates.tpl @@ -0,0 +1,50 @@ +
+ +
+ \ No newline at end of file