Esempio n. 1
0
 public function testSimplePath()
 {
     $Corrector = new GoogleMaps(array(49.44, 49.441, 49.442, 49.443, 49.444, 49.445, 49.446, 49.447, 49.448, 49.449, 49.45), array(7.76, 7.761, 7.762, 7.763, 7.764, 7.765, 7.766, 7.767, 7.768, 7.769, 7.77));
     if ($Corrector->canHandleData()) {
         $Corrector->correctElevation();
         $this->assertEquals(array(238, 238, 238, 238, 238, 237, 237, 237, 237, 237, 263), $Corrector->getCorrectedElevation());
     } else {
         $this->markTestSkipped('Datasciencetoolkit was not available.');
     }
 }
 public function __construct(array $param_required, array $param_optional = array(null), $output = null)
 {
     parent::__construct();
     if (isset($param_required['location']) && isset($param_required['radius'])) {
         $this->parameters['required']['location'] = $param_required['location'];
         //dodać weryfikację
         $this->parameters['required']['radius'] = $param_required['radius'];
         //dodać weryfikację
     } else {
         throw new LunchboxException('Nieprawidłowe zainicjowanie metody ' . __METHOD__ . '. Brak wymaganego parametru "location" i\\lub "radius".');
     }
     $this->parameters['optional']['keyword'] = $param_optional['keyword'];
     $this->parameters['optional']['language'] = $param_optional['language'];
     //dodać weryfikację
     $this->parameters['optional']['minPrice'] = $param_optional['minPrice'];
     //dodać weryfikację
     $this->parameters['optional']['maxPrice'] = $param_optional['maxPrice'];
     //dodać weryfikację
     $this->parameters['optional']['name'] = $param_optional['name'];
     $this->parameters['optional']['openNow'] = isset($param_optional['openNow']) ? true : null;
     $this->parameters['optional']['rankBy'] = $param_optional['rankBy'];
     //dodać weryfikację
     $this->parameters['optional']['types'] = $param_optional['types'];
     //dodać weryfikację
     $this->parameters['optional']['pageToken'] = $param_optional['pageToken'];
     $this->parameters['optional']['zagatSelected'] = isset($param_optional['zagatSelected']) ? true : null;
     if (isset($output)) {
         $this->output = $output;
     }
 }
    public function Field($properties = array())
    {
        Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.min.js');
        Requirements::javascript('geoform/javascript/jquery.geocomplete.js');
        if (GoogleMaps::getApiKey()) {
            Requirements::javascript('//maps.googleapis.com/maps/api/js?sensor=false&libraries=places&language=' . i18n::get_tinymce_lang() . '&key=' . GoogleMaps::getApiKey());
        } else {
            Requirements::javascript('//maps.googleapis.com/maps/api/js?sensor=false&libraries=places&language=' . i18n::get_tinymce_lang());
        }
        $name = $this->getName();
        $this->fieldAddress->setPlaceholder(_t('GeoLocationField.ADDRESSPLACEHOLDER', 'Address'));
        // set caption if required
        $js = <<<JS
(function(\$){
    \$(function(){
        \$("#{$name}-Address").geocomplete().bind("geocode:result", function(event, result){
            \$("#{$name}-Latitude").val(result.geometry.location.lat());
            \$("#{$name}-Longditude").val(result.geometry.location.lng());
        });
    });
})(jQuery);
JS;
        Requirements::customScript($js, 'BootstrapGeoLocationField_Js_' . $this->ID());
        $css = <<<CSS
/* make the location suggest dropdown appear above dialog */
.pac-container {
    z-index: 2000 !important;
}
CSS;
        Requirements::customCSS($css, 'BootstrapGeoLocationField_Css_' . $this->ID());
        return $this->fieldLatitude->Field() . $this->fieldLongditude->Field() . '<div class="row">' . '<div class="col-sm-12">' . $this->fieldAddress->Field() . '</div>' . '</div>';
    }
 /**
  * Generate module
  */
 protected function compile()
 {
     // load Google Maps JavaScript
     $arrParams = $this->anystores_signedIn ? array('signed_in' => 'true') : array();
     GoogleMaps::includeJs($arrParams);
     $GLOBALS['TL_JAVASCRIPT']['anystores'] = 'system/modules/anyStores/assets/js/anystores.js';
     $GLOBALS['TL_JAVASCRIPT']['markerclusterer'] = 'system/modules/anyStores/assets/js/markerclusterer/src/markerclusterer_compiled.js';
     // map height
     $this->Template->mapHeight = deserialize($this->anystores_mapheight);
     $this->Template->anystores_token = FrontendAjax::generateRequestToken($this->id);
 }
Esempio n. 5
0
function GoogleMapsLocalizedPageName(&$specialPageArray, $code)
{
    # The localized title of the special page is among the messages of the
    # extension:
    GoogleMaps::loadMessages();
    $text = wfMsg('googlemaps');
    # Convert from title in text form to DBKey and put it into the alias array:
    $title = Title::newFromText($text);
    $specialPageArray['GoogleMaps'][] = $title->getDBKey();
    return true;
}
Esempio n. 6
0
 function execute($params)
 {
     global $wgRequest, $wgOut, $wgTitle, $wgUser;
     global $wgContLang, $wgProxyKey, $wgParser;
     $article = $wgRequest->getText('article', $params);
     $map = $wgRequest->getText('map', $params);
     $wgOut->disable();
     header("Cache-Control: no-cache, must-revalidate");
     header("Content-type: application/vnd.google-earth.kml+xml");
     header('Content-Disposition: attachment; filename="' . $article . '.kml"');
     $title = Title::newFromText($article);
     /* Wikia change begin - @author: Sebastian Marzjan */
     /* fogbugz BugID #18043 */
     if ($title instanceof Title) {
         /* Wikia change end */
         $revision = Revision::newFromTitle($title);
         /* Wikia change begin - @author: Sebastian Marzjan */
         /* fogbugz BugID #18043 */
         if (!$revision instanceof Revision) {
             $errorMessage = 'SpecialGoogleMapsKML.php ' . __LINE__ . ' - no revision for ' . $article . ' / ' . $title->getArticleID();
             Wikia::log(__METHOD__, false, $errorMessage);
             echo "No article revisions found by the name of {$article}";
             return false;
         }
         /* Wikia change end */
         $mapOptions = GoogleMaps::getMapSettings($title, array('icons' => 'http://maps.google.com/mapfiles/kml/pal4/{label}.png', 'icon' => 'icon57'));
         $exporter = new GoogleMapsKmlExporter($wgContLang, str_replace('{label}', $mapOptions['icon'], $mapOptions['icons']));
         $wgParser->mOptions = ParserOptions::newFromUser($wgUser);
         $wgParser->mOptions->setEditSection(false);
         $wgParser->mTitle = $wgTitle;
         $wgParser->clearState();
         $localParser = new Parser();
         $localParser->mTitle = $title;
         $localParser->mOptions = $wgParser->mOptions;
         if (preg_match_all("/<googlemap( .*?|)>(.*?)<\\/googlemap>/s", $revision->getText(), $matches)) {
             $exporter->addFileHeader();
             for ($i = 0; $i < count($matches[2]); $i++) {
                 $attrs = Sanitizer::decodeTagAttributes($matches[1][$i]);
                 $mapOptions['version'] = isset($attrs['version']) ? $attrs['version'] : "0";
                 $exporter->addHeader(isset($attrs['title']) ? $attrs['title'] : "Map #" . ($i + 1));
                 GoogleMaps::renderContent($matches[2][$i], $wgParser, $localParser, $exporter, $mapOptions);
                 $exporter->addTrailer();
             }
             $exporter->addFileTrailer();
             echo $exporter->render();
         } else {
             echo "No maps in {$article}!";
         }
     } else {
         echo "No article found by the name of {$article}";
     }
 }
 public function testTimezoneFromCoordsDifferentGoogleResponses()
 {
     $mock = $this->getMockBuilder('GoogleApi')->setMethods(array('getError', 'get'))->getMock();
     /** @var GoogleMaps $googleMaps */
     $googleMaps = new GoogleMaps("", $mock);
     $mock->expects($this->at(0))->method('get')->with("timezone/json", array('location' => '0,1', 'timestamp' => '2015-12-26 21:56:00 UTC'))->willReturn('{"dstOffset" : 0,
               "rawOffset" : 36000,
               "status" : "OK",
               "timeZoneId" : "Australia/Hobart",
               "timeZoneName" : "Australian Eastern Standard Time"}');
     $this->assertEquals('Australia/Hobart', $googleMaps->timezoneFromCoords(0, 1, "2015-12-26 21:56:00 UTC"));
     // google doesn't recognise the request
     $googleMaps = new GoogleMaps("", $mock);
     $mock->expects($this->at(0))->method('get')->with("timezone/json", array('location' => '10,20', 'timestamp' => '2015-12-27 21:56:00 UTC'))->willReturn(include 'data/input/googleApi404.php');
     $this->assertEquals(null, $googleMaps->timezoneFromCoords(10, 20, "2015-12-27 21:56:00 UTC"));
     $this->assertEquals(include 'data/input/googleApi404.php', $googleMaps->getError());
     // can't connect, so we get a false/null or error message.
     $googleMaps = new GoogleMaps("", $mock);
     $mock->method('getError')->willReturnOnConsecutiveCalls("API ERROR MESSAGE", "API ERROR MESSAGE 2");
     $mock->expects($this->at(0))->method('get')->with("timezone/json", array('location' => '30,40', 'timestamp' => '2015-12-28 21:56:00 UTC'))->willReturn(false);
     $this->assertEquals(null, $googleMaps->timezoneFromCoords(30, 40, "2015-12-28 21:56:00 UTC"));
     $this->assertEquals("API ERROR MESSAGE", $googleMaps->getError());
     $googleMaps = new GoogleMaps("", $mock);
     $mock->expects($this->at(0))->method('get')->with("timezone/json", array('location' => '50,60', 'timestamp' => '2015-12-29 21:56:00 UTC'))->willReturn(null);
     $this->assertEquals(null, $googleMaps->timezoneFromCoords(50, 60, "2015-12-29 21:56:00 UTC"));
     $this->assertEquals("API ERROR MESSAGE 2", $googleMaps->getError());
     // We get JSON, but it's an error message
     $googleMaps = new GoogleMaps("", $mock);
     $mock->expects($this->at(0))->method('get')->willReturn('{"errorMessage" : "The provided API key is invalid.",
               "status" : "REQUEST_DENIED"}');
     $this->assertEquals(null, $googleMaps->timezoneFromCoords(10, 20, "2015-12-27 21:56:00 UTC"));
     $this->assertEquals("The provided API key is invalid.", $googleMaps->getError());
     // We get JSON, but it's nothing we expect
     $googleMaps = new GoogleMaps("", $mock);
     $mock->expects($this->at(0))->method('get')->willReturn('{"blah" : "di blah.","di" : "blah"}');
     $this->assertEquals(null, $googleMaps->timezoneFromCoords(10, 20, "2015-12-27 21:56:00 UTC"));
     $this->assertEquals('Unknown JSON returned by Google API, {"blah" : "di blah.","di" : "blah"}', $googleMaps->getError());
 }
 public function save(Doctrine_Connection $conn = null)
 {
     if (sfConfig::get('app_rt_address_geo_coords_enabled', false)) {
         $coords = GoogleMaps::getCoords(array($this->address_1, $this->address_2, $this->town, $this->state, $this->country, $this->postcode));
         if (is_array($coords)) {
             $this->setLatitude($coords['latitude']);
             $this->setLongitude($coords['longitude']);
         } else {
             $this->setLatitude(0.0);
             $this->setLongitude(0.0);
         }
     }
     parent::save($conn);
 }
Esempio n. 9
0
 public function execute()
 {
     if ($this->page->pathinfo[2] == "image") {
         $this->show_static_map();
         return;
     }
     $google_map = new GoogleMaps($this->db);
     $google_map->add_route($this->origin, $this->destination);
     $steps = $google_map->route_description;
     $distance = $google_map->route_distance;
     $duration = $google_map->route_duration;
     $hours = $duration / 3600;
     $minutes = $duration % 3600 / 60;
     $this->output->open_tag("route");
     $this->output->add_tag("origin", $this->origin);
     $this->output->add_tag("destination", $this->destination);
     $this->output->add_tag("distance", sprintf("%2.1f km", $distance / 1000));
     $this->output->add_tag("duration", sprintf("%d:%2d", $hours, $minutes));
     foreach ($steps as $step) {
         $this->output->add_tag("step", $step["description"], array("distance" => $step["distance"], "duration" => $step["duration"]));
     }
     $this->output->close_tag();
 }
Esempio n. 10
0
 function addMarker($pLat, $pLon, $pIcon, $pTitle, $pTitleLink, $pCaption, $pMaxContent, $pIsLine)
 {
     $this->mMarkerCount++;
     $this->mOutput .= "<Placemark>\n<name>";
     $this->mOutput .= $pTitle ? $pTitle : "point {$this->mMarkerCount}";
     $this->mOutput .= "</name>";
     $this->mOutput .= "<Style><Icon><href>";
     $this->mOutput .= $pIcon ? $this->mIcons[$pIcon] : $this->mIcon;
     $this->mOutput .= "</href></Icon></Style>\n";
     $this->mOutput .= "<Point><coordinates>{$pLon}, {$pLat}, 0</coordinates></Point>\n";
     if (is_string($pCaption) && $pCaption) {
         $this->mOutput .= '<description><![CDATA[' . GoogleMaps::fixBlockDirection(GoogleMaps::fixTidy($pCaption), $this->mLanguage->isRTL()) . ']]></description>';
     } elseif (is_array($pCaption)) {
         // TODO tabs and max content
     }
     $this->mOutput .= "</Placemark>\n";
 }
Esempio n. 11
0
 public function GoogleMaps($x = false, $y = false, $zoom = false, $w = false, $h = false)
 {
     if ($x) {
         self::$x_centro = $x;
     }
     if ($y) {
         self::$y_centro = $y;
     }
     if ($zoom) {
         self::$zoom = $zoom;
     }
     if ($w) {
         self::$width = $w;
     }
     if ($h) {
         self::$height = $h;
     }
     $this->marcadores = array();
     $this->nm = 0;
 }
 function execute($params)
 {
     global $wgRequest, $wgOut, $wgUser;
     global $wgContLang, $wgProxyKey, $wgParser;
     $article = $wgRequest->getText('article', $params);
     $map = $wgRequest->getText('map', $params);
     $wgOut->disable();
     header("Cache-Control: no-cache, must-revalidate");
     header("Content-type: application/vnd.google-earth.kml+xml");
     header('Content-Disposition: attachment; filename="' . $article . '.kml"');
     $title = Title::newFromText($article);
     if ($title) {
         $revision = Revision::newFromTitle($title);
         $mapOptions = GoogleMaps::getMapSettings($title, array('icons' => 'http://maps.google.com/mapfiles/kml/pal4/{label}.png', 'icon' => 'icon57'));
         $exporter = new GoogleMapsKmlExporter($wgContLang, str_replace('{label}', $mapOptions['icon'], $mapOptions['icons']));
         $popts = ParserOptions::newFromUser($wgUser);
         $popts->setEditSection(false);
         $wgParser->startExternalParse($this->getTitle(), $popts, OT_WIKI, true);
         $localParser = new Parser();
         $localParser->startExternalParse($this->getTitle(), $popts, OT_WIKI, true);
         if (preg_match_all("/<googlemap( .*?|)>(.*?)<\\/googlemap>/s", $revision->getText(), $matches)) {
             $exporter->addFileHeader();
             for ($i = 0; $i < count($matches[2]); $i++) {
                 $attrs = Sanitizer::decodeTagAttributes($matches[1][$i]);
                 $mapOptions['version'] = isset($attrs['version']) ? $attrs['version'] : "0";
                 $exporter->addHeader(isset($attrs['title']) ? $attrs['title'] : "Map #" . ($i + 1));
                 GoogleMaps::renderContent($matches[2][$i], $wgParser, $localParser, $exporter, $mapOptions);
                 $exporter->addTrailer();
             }
             $exporter->addFileTrailer();
             echo $exporter->render();
         } else {
             echo "No maps in {$article}!";
         }
     } else {
         echo "No article found by the name of {$article}";
     }
 }
Esempio n. 13
0
 function __construct($parameters_required, array $parameters_optional = array(null), $output = null)
 {
     parent::__construct();
     if (\is_array($parameters_required)) {
         if (isset($parameters_required['placeid'])) {
             $this->parameters['required']['placeid'] = $parameters_required['placeid'];
         } elseif (isset($parameters_required['reference'])) {
             $this->parameters['required']['reference'] = $parameters_required['reference'];
         } else {
             throw new LunchboxException('Nieprawidłowe zainicjowanie metody ' . __METHOD__ . '. Brak wymaganych parametrów "placeid" lub "reference".');
         }
     } elseif (\is_string($parameters_required)) {
         $this->parameters['required']['placeid'] = $parameters_required;
     } else {
         throw new LunchboxException('Nieprawidłowe zainicjowanie metody ' . __METHOD__ . '. Nieprawidłowy format wymaganego parametru.');
     }
     $this->parameters['optional']['extensions'] = $parameters_optional['bounds'];
     $this->parameters['optional']['language'] = $parameters_optional['language'];
     //dodać weryfikację
     if (isset($output)) {
         $this->output = $output;
     }
 }
Esempio n. 14
0
 public function getPlaceQueryAutoComplete()
 {
     $d = \GoogleMaps::load('placequeryautocomplete')->setParamByKey('input', 'Pizza near Lon')->setParamByKey('language', 'gb')->getResponseByKey('predictions.place_id');
     dd($d);
 }
Esempio n. 15
0
 /**
  * Creates a new marker on the google map.
  *
  * @param $pLat numeric - the latitude for the marker
  * @param $pLon numeric - the longitude of the marker
  * @param $pIcon string - the identifier of the icon to use
  * @param $pTitle string - the title for the marker
  * @param $pCaption string - the caption for the marker
  * @param $pColor string - the color of the polyline (really just used to know if we're in
  *   a polyline or not and should draw markers without captions)
  * @param $pTabs [string] - array of tabs for the marker formatted as javascript for constructing
  *   GInfoWindowTab objects
  *
  * @return string - the javascript for adding the tabs to the map
  **/
 function addMarker($pLat, $pLon, $pIcon, $pTitle, $pTitleLink, $pCaption, $pMaxContent, $pIsLine)
 {
     $title = GoogleMaps::fixStringDirection($pTitle, $this->mLanguage->isRTL());
     if (is_string($pCaption)) {
         $captionNoNewlines = preg_replace('/[\\r\\n]+/', ' ', $pCaption);
     }
     $options = array();
     // choose the appropriate icon for the marker
     $options['icon'] = $pIcon ? "mapIcons['{$pIcon}']" : "GME_DEFAULT_ICON";
     $options['clickable'] = $title || (is_string($pCaption) ? $captionNoNewlines : count($pCaption)) ? "true" : "false";
     if (!($pIsLine && $options['clickable'] == "false")) {
         $this->mOutput .= " marker = new GMarker(new GLatLng({$pLat}, {$pLon}), { ";
         if ($title) {
             $this->mOutput .= " 'title': '" . addslashes($title) . "', ";
         }
         $this->mOutput .= " 'icon': {$options['icon']}, ";
         $this->mOutput .= " 'clickable': {$options['clickable']} ";
         $this->mOutput .= "});";
     }
     if ($pMaxContent) {
         $this->mOutput .= " marker.maxContent = '" . addslashes($pMaxContent) . "';";
     }
     if (is_string($pCaption)) {
         // if there's a caption, set it
         $this->mOutput .= " marker.caption = '';";
         if ($title) {
             $this->mOutput .= " marker.title = '" . addslashes($title) . "';";
             $this->mOutput .= " marker.title_link = '" . addslashes($pTitleLink) . "';";
         }
         if ($captionNoNewlines) {
             $this->mOutput .= " marker.caption += '" . addslashes(GoogleMaps::fixBlockDirection(GoogleMaps::fixTidy($captionNoNewlines), $this->mLanguage->isRTL())) . "';";
         }
         // if there's tabs add them to the marker
     } elseif (is_array($pCaption) && count($pCaption)) {
         // dump the tabs from the previous marker
         $tabs = array();
         foreach ($pCaption as $t) {
             $tabs[] = "new GInfoWindowTab('" . addslashes(GoogleMaps::fixStringDirection($t['title'], $this->mLanguage->isRTL())) . "', '" . addslashes(preg_replace('/[\\r\\n]+/', ' ', GoogleMaps::fixBlockDirection(GoogleMaps::fixTidy($t['gm-caption']), $this->mLanguage->isRTL()))) . "')";
         }
         $this->mOutput .= " marker.tabs = [ " . implode(',', $tabs) . " ]; ";
     }
     // add the marker to the map
     $this->mOutput .= " map.addOverlay(marker);";
 }
<?php

if (defined('GOOGLE_MAPS_API_KEY')) {
    GoogleMaps::setApiKey(GOOGLE_MAPS_API_KEY);
}
 public static function setApiKey($key)
 {
     self::$API_KEY = $key;
 }
 public function indexHome(Request $request)
 {
     $response = '';
     return view('index', compact('response'));
     //https://developers.google.com/maps/premium/optimize-web-services
     $response1 = \GoogleMaps::load('distancematrix')->setEndpoint('json')->setParam(['origins' => 'Groningen|Nederland', 'destinations' => 'Amsterdam|Nederland', 'mode' => 'driving'])->get();
     //->getEndpoint();
     //->get();
     //echo($response1);
     //return $response1;
     //dc(json_decode($response1));
     return response()->json(json_decode($response1), 200);
     return response($response1, 200)->header('Content-Type', 'application/json');
     return response()->json('tet', 200);
     return "view";
     return view('maps', compact('response'));
     //dc($response);
     dc(Permission::with('roles')->get()->pluck('name')->all());
     //dc(Auth::getPermissions());
     $test = Auth::check();
     dc(Auth::check());
     if (Auth::check()) {
         dc('not in');
     } else {
         dc('not logged in');
     }
     dc($test);
     //$user = Auth::loginUsingId(13);
     $user = Auth::user();
     //dc($user::getPermissions());
     dc($user->name);
     dc($user->roles()->get()->pluck('name')->all());
     //dc($user->roles()->permissions());
     $userRoles = $user->roles()->with('permissions')->get();
     dc($userRoles[0]->permissions->pluck('name')->all());
     //dc($user->hasRole('managerx'));
     $component_name = "Bookmarks";
     $references = Reference::with(['translation', 'referencetype', 'updated_by_user'])->whereHas('components', function ($component) use($component_name) {
         // ...1 subquery to filter the photos by related tags' name
         $component->where('name', '' . $component_name . '');
     })->get();
     foreach ($references as $key => $reference) {
         if ($user->can('view_bookmark_reference_' . $reference->id . '')) {
             dc($reference->id . ' - ' . $reference->translation->name);
         }
     }
     //$role->givePermissionTo($permission);
     //dc($references[0]->translation->name);
     return "view";
     //@can('edit_formxx')
     if ($user->can('edit_form')) {
         dc('can edit form');
     } else {
         dc('can\'t edit form');
     }
     if (Gate::denies('update', 'asdf')) {
         //abort(403);
     }
     //dc($user->hasPermission('managerx'));
     return view('welcome');
     dd('public index');
     //$references = Sitemap::with([
     //    'references.componentsTest',
     //    'references.translation'])->where('id',36);
     //dc($references->get());
     //return "view";
     $this->sitemap->initWebPage();
     $navigation = $this->sitemap->getWebpageNavigation();
     $sitemap = $this->sitemap->getWebpageContent();
     //dc($navigation[1]);
     $breadcrumb = $this->sitemap->getBreadcrumbArray();
     $breadcrumbHTML = $this->sitemap->getBreadcrumbHTML();
     //dc($breadcrumbHTML);
     $sitemapList = $this->sitemap->getWebPageSitemapList();
     $pagination = $sitemapList instanceof LengthAwarePaginator;
     //dc($sitemapList);
     if (!is_null($sitemapList)) {
         foreach ($sitemapList as $key => $sitemapListItem) {
             //if ($key == 0){
             $this->sitemap->groupMediaTranslationCollectionByFieldName($sitemapListItem->translation);
             //}
         }
     }
     $this->sitemap->groupMediaTranslationCollectionByFieldName($sitemap->translation);
     //dc($sitemap);
     //$template = Sitemap::with('template')->findOrFail($id)->template;
     //dc($sitemap->references);
     //dc($sitemapList);
     //dc($sitemapList[0]->translation->media['intro']);
     //foreach ($sitemapList[0]->translation->media['intro'] as $key => $image){
     //    dc($key);
     //}
     //$this->sitemap->groupMediaCollectionByFieldName($sitemap->translations);
     //dc($test);
     //dc($navigation[0]);
     foreach ($navigation[0] as $key => $nav) {
         //    dc($nav->translation->name.' - '.$nav->selected.' - '.$nav->hasChildren);
     }
     return view('index', compact('sitemap', 'navigation', 'breadcrumb', 'breadcrumbHTML', 'sitemapList', 'pagination'));
     //dc($breadcrumb[0]->template->name);
     $test = '';
     foreach ($breadcrumb as $key => $breadcrumbItem) {
         //    $test .= ($breadcrumbItem->translation->name.' - ');
     }
     dc($breadcrumb);
     dc($sitemap->translation->name);
     /*
     foreach($navigation  as $key => $nav){
     	foreach($nav  as $key1 => $nav1){
     		dc($nav1->translation->name.' - '.$nav1->selected.' - '.$nav1->no_sitemap_parents);
     		//dc($nav1->selected);
     		//dc($nav1->no_sitemap_parents);
     	}
     	dc('end');
     }
     */
     return "view";
     //dc($test);
     //dc($breadcrumb);
     //dc($navigation);
     //dc($sitemapList);
     /*
      * GOED
      $
     */
     //$navigation[0][0]->setAttribute('selected',true);
     //dc($navigation[0][1]->getAttributes());
     //dc($navigation[0][1]);
     //dc($navigation[0][1]->selected);
     /*
     		foreach ($navigation[2] as $key => $nav){
     			dc($nav->translation->name);
     			dc($nav->selected);
     			dc($nav->no_sitemap_parents);
     
     		}
     foreach ($navigation as $key => $nav){
     	dc($nav);
     }
     dc($navigation);
     */
     //$test = $this->sitemap->getOnlineSitemapsTranslationByParentIdAndSitemapCategory(40);
     //dc($test[0]->categoriesTest);
     //foreach ($test[0]->categoriesTest as $cat){
     //    dc($cat->translation->name);
     //}
     //dc($breadcrumb[0]->translation->slug);
     return view('index', compact('sitemap', 'navigation', 'breadcrumb', 'sitemapList'));
     return "view";
     //dc($request->path());
     //dc($request);
     //dc($request->path());
     if ($request->path() != "/") {
         //dc($requestUriArray);
         $sitemap = $this->sitemap->getSitemapByUrl();
         dc($sitemap->id);
         $navigation = $this->sitemap->getNavigation();
         $breadcrumb = $this->sitemap->getBreadcrumb();
         //return "view";
         //dc($sitemap);
         dc($breadcrumb);
         dc('test');
     } else {
         $sitemapId = 1;
         $sitemap = $this->sitemap->getSitemapForIndex($sitemapId);
     }
     return "view";
     //return view('index-amp',compact('sitemap','testComposer'));
     return view('index', compact('sitemap', 'navigation', 'breadcrumb'));
     //todo post_type nodig, JA DUS VOOR POST REQUEST
     $id = $request->route()->parameter('id') ? $request->route()->parameter('id') : null;
     //$post_type = $request->route()->parameter('post_type') ? $request->route()->parameter('post_type') : null;
     //if (is_null($post_type)){
     //    $template = Sitemap::with('template')->findOrFail($id)->template;
     //    $post_type = Sitemap::with('template')->findOrFail($id)->template->db_table_name;
     //}
     $id = 1;
     $template = Sitemap::with('template')->findOrFail($id)->template;
     //todo
     $allowedParentSitemaps = $this->sitemap->getAllowedParentSitemapsByTemplate($template);
     $sitemap_list = $this->sitemap->getParentSitemapList($allowedParentSitemaps);
     $enabledLocales = $this->sitemap->getEnabledLocales();
     $sitemap = $this->sitemap->getSelectedSitemap($id, $template);
     $sitemap = $this->sitemap->setSelectedReferencesBySitemap($sitemap);
     $this->sitemap->groupMediaCollectionByFieldName($sitemap->translations);
     //kan weg geen templates wijzigen
     $template_list = Template::lists('name', 'id');
     $template = $sitemap->template;
     //dc($template);
     $status_list = collect(['online' => 'Online', 'pending_review' => 'Wacht op review', 'concept' => 'Concept']);
     //dc($sitemap);
     $post_type = $template->slug;
     //voor PostRequest
     return view('index', compact('sitemap', 'post_type', 'template', 'enabledLocales', 'template_list', 'sitemap_list', 'status_list'));
     //return view('admin.sitemap.edit',compact('sitemap','post_type','template','enabledLocales','template_list','sitemap_list','status_list'));
 }
 /**
  * Validates PostCodeLocation against GoogleMaps Serverside
  * 
  * @return String
  */
 public function validate($validator)
 {
     $name = $this->name;
     $addressField = $this->fieldAddress;
     $latitudeField = $this->fieldLatitude;
     $longditudeField = $this->fieldLongditude;
     $addressField->setValue($_POST[$name]['Address']);
     $latitudeField->setValue($_POST[$name]['Latitude']);
     $longditudeField->setValue($_POST[$name]['Longditude']);
     // Result was unique
     if ($latitudeField->Value() != '' && is_numeric($latitudeField->Value()) && $longditudeField->Value() != '' && is_numeric($longditudeField->Value())) {
         return true;
     }
     if (trim($addressField->Value()) == '') {
         if (!$validator->fieldIsRequired($this->name)) {
             return true;
         } else {
             $validator->validationError($name, _t('GeoLocationField.VALIDATION', 'Please enter an accurate address!'), "validation");
             return false;
         }
     }
     // fetch result from google (serverside)
     $myAddress = trim($addressField->Value());
     // Update to v3 API
     $googleUrl = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($myAddress) . '&language=' . i18n::get_tinymce_lang();
     if (GoogleMaps::getApiKey()) {
         $googleUrl .= '&key=' . GoogleMaps::getApiKey();
     }
     $result = json_decode(file_get_contents($googleUrl), true);
     // if result unique
     if ($result['status'] == 'OK' && count($result['results']) == 1) {
         $latitudeField->setValue($result['results'][0]['geometry']['location']['lat']);
         $longditudeField->setValue($result['results'][0]['geometry']['location']['lng']);
         return true;
     } else {
         $tmpCounter = 0;
         $tmpLocality = null;
         for ($i = 0; $i < count($result['results']); $i++) {
             // check if type is locality political
             if ($result['results'][$i]['types'][0] == 'locality' && $result['results'][$i]['types'][1] == 'political') {
                 $tmpLocality = $i;
                 $tmpCounter++;
             }
         }
         if ($tmpCounter == 1) {
             $latitudeField->setValue($result['results'][$tmpLocality]['geometry']['location']['lat']);
             $longditudeField->setValue($result['results'][$tmpLocality]['geometry']['location']['lng']);
             return true;
         } else {
             // result not unique
             $validator->validationError($name, _t('GeoLocationField.VALIDATIONUNIQUE', 'The address is not unique, please specify.'), "validation");
             return false;
         }
     }
 }
    public function Field($properties = array())
    {
        Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.min.js');
        if (GoogleMaps::getApiKey()) {
            Requirements::javascript('//maps.googleapis.com/maps/api/js?sensor=false&libraries=places&language=' . i18n::get_tinymce_lang() . '&key=' . GoogleMaps::getApiKey());
        } else {
            Requirements::javascript('//maps.googleapis.com/maps/api/js?sensor=false&libraries=places&language=' . i18n::get_tinymce_lang());
        }
        $name = $this->getName();
        $this->fieldPostcode->setPlaceholder(_t('PostCodeLocationField.ZIPCODEPLACEHOLDER', 'ZIP/Postcode'));
        $this->fieldCountry->setPlaceholder(_t('PostCodeLocationField.CITYCOUNTRYPLACEHOLDER', 'City/Country'));
        // set caption if required
        $js = <<<JS
jQuery(document).ready(function() {
    // bind PostCodeLocationChanged to Postcode and Country Fields
    jQuery('#{$name}-Postcode').keyup({$name}PostCodeLocationChanged);
    jQuery('#{$name}-Country').keyup({$name}PostCodeLocationChanged);
});

var {$name}PostcodeTypeTimer = null;

// react on typing
function {$name}PostCodeLocationChanged(){
    // check typeTimer and delete
    if({$name}PostcodeTypeTimer){
        clearTimeout({$name}PostcodeTypeTimer);
    }
                        
    // trim Postcode value
    var postcode = jQuery('#{$name}-Postcode').val().replace(/\\s+\$/,"").replace(/^\\s+/,"");
    // trim Country value
    var country = jQuery('#{$name}-Country').val().replace(/\\s+\$/,"").replace(/^\\s+/,"");
    
    // Postcode or Country at least more than 2 digits and not placeholster is stristr of value
    if(postcode.length >= 2 || country.length >= 2){
        {$name}PostcodeTypeTimer = setTimeout('{$name}PostCodeLocationFetch()', 500); // execute googlemaps request after 1/2 second of not typing
    }
}

var {$name}PostcodeGeocoder = null;

// fetch google data and update lat, lng
function {$name}PostCodeLocationFetch(){
    // clear Lat + Lng
    jQuery('#{$name}-Latitude').val('');
    jQuery('#{$name}-Longditude').val('');
    
    // trim Postcode value
    var postcode = jQuery('#{$name}-Postcode').val().replace(/\\s+\$/,"").replace(/^\\s+/,"");
    // trim Country value
    var country = jQuery('#{$name}-Country').val().replace(/\\s+\$/,"").replace(/^\\s+/,"");
    
    // create request
    var Request = {
        address: postcode+', '+country
    };
    
    // create geocoder
    {$name}PostcodeGeocoder = new google.maps.Geocoder();
    {$name}PostcodeGeocoder.geocode(Request, {$name}PostcodeGeocoderCallback);
}

function {$name}PostcodeGeocoderCallback(Response, Status){
    // Status OK
    if(Status == 'OK'){
        if(Response.length == 1){
            jQuery('#{$name}-Latitude').val(Response[0]['geometry']['location'].lat());
            jQuery('#{$name}-Longditude').val(Response[0]['geometry']['location'].lng());
            //alert(\$('#{$name}-Latitude').val()+','+\$('#{$name}-Longditude').val());
        }else{
            // check if there is only one locality, while all others are places of interest
            var id = PostcodeIsSingleLocality(Response);
            if(id != null){
                jQuery('#{$name}-Latitude').val(Response[id]['geometry']['location'].lat());
                jQuery('#{$name}-Longditude').val(Response[id]['geometry']['location'].lng());
            }
        }
    }
}

function PostcodeIsSingleLocality(Response){
    // check if Response has only one locality->Political
    var counter = 0;
    var locality = null;
    for(var i=0; i<Response.length; i++){
        // check if type is locality political
        if(Response[i]['types'][0] == 'locality' && Response[i]['types'][1] == 'political'){
            locality = i;
            counter++;
        }
    }
    
    return (counter == 1) ? locality : null;
}
JS;
        Requirements::customScript($js, 'BootstrapPostCodeLocationField_Css_' . $this->ID());
        return $this->fieldLatitude->Field() . $this->fieldLongditude->Field() . '<div class="row">' . '<div class="col-sm-6">' . $this->fieldPostcode->Field() . '</div>' . '<div class="col-sm-6">' . $this->fieldCountry->Field() . '</div>' . '</div>';
    }
<?php

require 'AutoLoader.php';
//Bridge
$mapa = new GoogleMaps();
$mapa->exibirMapa();
echo '<hr />';
//Adapter
$relogio = new Relogio();
$relogio->hoje();
Esempio n. 22
0
File: api.php Progetto: Abbe98/ODOK
<?php

/*
 * Entry point for api
 *
 */
#dynamickml does not require a proper search. Just return the output.
if ($_GET['format'] == 'dynamickml') {
    include 'FormatDynamicKml.php';
    FormatDynamicKml::output();
} elseif ($_GET['format'] == 'googlemaps') {
    include 'FormatDynamicKml.php';
    GoogleMaps::output();
} else {
    include 'ApiMain.php';
    ApiMain::search();
}
 /**
  * Validates PostCodeLocation against GoogleMaps Serverside
  * 
  * @return String
  */
 public function validate($validator)
 {
     $name = $this->name;
     $postcodeField = $this->fieldPostcode;
     $countryField = $this->fieldCountry;
     $latitudeField = $this->fieldLatitude;
     $longditudeField = $this->fieldLongditude;
     $postcodeField->setValue($_POST[$name]['Postcode']);
     $countryField->setValue($_POST[$name]['Country']);
     $latitudeField->setValue($_POST[$name]['Latitude']);
     $longditudeField->setValue($_POST[$name]['Longditude']);
     // Result was unique
     if ($latitudeField->Value() != '' && is_numeric($latitudeField->Value()) && $longditudeField->Value() != '' && is_numeric($longditudeField->Value())) {
         return true;
     }
     // postcode and country are still placeholders
     if (trim($postcodeField->Value()) == '' || trim($countryField->Value()) == '') {
         $validator->validationError($name, _t('PostCodeLocationField.VALIDATIONJS', 'Please enter an accurate ZIP and City/Country.'), "validation");
         return false;
     }
     if (stristr(trim(_t('PostCodeLocationField.ZIPCODEPLACEHOLDER', 'ZIP/Postcode')), trim($postcodeField->Value())) && stristr(trim(_t('PostCodeLocationField.CITYCOUNTRYPLACEHOLDER', 'City/Country')), trim($countryField->Value()))) {
         $validator->validationError($name, _t('PostCodeLocationField.VALIDATIONJS', 'Please enter an accurate ZIP and City/Country.'), "validation");
         return false;
     }
     // fetch result from google (serverside)
     $myPostcode = stristr(trim(_t('PostCodeLocationField.ZIPCODEPLACEHOLDER', 'ZIP/Postcode')), trim($postcodeField->Value())) ? '' : trim($postcodeField->Value());
     $myCountry = stristr(trim(_t('PostCodeLocationField.CITYCOUNTRYPLACEHOLDER', 'City/Country')), trim($countryField->Value())) ? '' : trim($countryField->Value());
     // Update to v3 API
     $googleUrl = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($myPostcode . ', ' . $myCountry) . '&language=' . i18n::get_tinymce_lang();
     if (GoogleMaps::getApiKey()) {
         $googleUrl .= '&key=' . GoogleMaps::getApiKey();
     }
     $result = json_decode(file_get_contents($googleUrl), true);
     // if result unique
     if ($result['status'] == 'OK' && count($result['results']) == 1) {
         $latitudeField->setValue($result['results'][0]['geometry']['location']['lat']);
         $longditudeField->setValue($result['results'][0]['geometry']['location']['lng']);
         return true;
     } else {
         $tmpCounter = 0;
         $tmpLocality = null;
         for ($i = 0; $i < count($result['results']); $i++) {
             // check if type is locality political
             if ($result['results'][$i]['types'][0] == 'locality' && $result['results'][$i]['types'][1] == 'political') {
                 $tmpLocality = $i;
                 $tmpCounter++;
             }
         }
         if ($tmpCounter == 1) {
             $latitudeField->setValue($result['results'][$tmpLocality]['geometry']['location']['lat']);
             $longditudeField->setValue($result['results'][$tmpLocality]['geometry']['location']['lng']);
             return true;
         } else {
             // result not unique
             $validator->validationError($name, _t('PostCodeLocationField.VALIDATIONUNIQUEJS', 'ZIP and City/Country are not unique, please specify.'), "validation");
             return false;
         }
     }
 }
 public function __construct($adapter, $ssl, $clientId, $privateKey, $language = null)
 {
     $this->clientId = $clientId;
     $this->privateKey = $privateKey;
     parent::__construct($adapter, $ssl, $language);
 }