Ejemplo n.º 1
0
 /**
  * Return the javascript to create an instance of the class defined in formJavascriptClass
  *
  * @param   array  $args  Array [0] => string table's form id to contain plugin
  *
  * @return bool
  */
 public function onLoadJavascriptInstance($args)
 {
     parent::onLoadJavascriptInstance($args);
     if (!is_object($this->getMapElement())) {
         return false;
     }
     $params = $this->getParams();
     list($latitude, $longitude) = $this->getSearchLatLon();
     $opts = $this->getElementJSOptions();
     $containerOverride = FArrayHelper::getValue($args, 0, '');
     if (strstr($containerOverride, 'visualization')) {
         $opts->ref = str_replace('visualization_', '', $containerOverride);
     }
     $opts->steps = (int) $params->get('radius_max', 100);
     $opts->unit = $params->get('radius_unit', 'km');
     $opts->value = $this->getValue();
     $opts->lat = $latitude;
     $opts->lon = $longitude;
     $preFilterDistance = $params->get('prefilter_distance', '');
     $opts->prefilter = $preFilterDistance === '' ? false : true;
     $opts->prefilterDone = (bool) $this->app->input->getBool('radius_prefilter', false);
     $opts->prefilterDistance = $preFilterDistance;
     $opts->myloc = $params->get('myloc', 1) == 1 ? true : false;
     $o = FabrikString::mapStrToCoords($params->get('geocode_default', ''));
     $opts->geocode_default_lat = $o->lat;
     $opts->geocode_default_long = $o->long;
     $opts->geocode_default_zoom = (int) $o->zoom;
     $opts->geoCodeAsType = $params->get('geocode_as_type', 1);
     $opts->renderOrder = $this->renderOrder;
     $opts->offset_y = (int) $params->get('window_offset_y', '0');
     $opts = json_encode($opts);
     $this->jsInstance = "new FbListRadius_search({$opts})";
     JText::script('PLG_LIST_RADIUS_SEARCH_CLEAR_CONFIRM');
     JText::script('PLG_LIST_RADIUS_SEARCH_GEOCODE_ERROR');
     return true;
 }
Ejemplo n.º 2
0
 /**
  * Draws the html form element
  *
  * @param   array  $data           To pre-populate element with
  * @param   int    $repeatCounter  Repeat group counter
  *
  * @return  string  elements html
  */
 public function render($data, $repeatCounter = 0)
 {
     $id = $this->getHTMLId($repeatCounter);
     $name = $this->getHTMLName($repeatCounter);
     $element = $this->getElement();
     $val = $this->getValue($data, $repeatCounter);
     $params = $this->getParams();
     $w = $params->get('fb_gm_mapwidth');
     $h = $params->get('fb_gm_mapheight');
     $str = '';
     if ($this->_useStaticMap()) {
         return $this->_staticMap($val, null, null, null, $repeatCounter, false, $data);
     } else {
         if ($element->hidden == '1') {
             return $this->getHiddenField($name, $data[$name], $id);
         }
         if (!$this->isEditable() && $val != '' || $this->isEditable()) {
             $layout = $this->getLayout('form');
             $layoutData = new stdClass();
             $layoutData->id = $id;
             $coords = FabrikString::mapStrToCoords($val);
             $layoutData->coords = $coords->coords;
             $layoutData->geoCodeEvent = $params->get('fb_gm_geocode_event', 'button');
             $layoutData->geocode = $params->get('fb_gm_geocode');
             $layoutData->editable = $this->isEditable();
             $layoutData->width = $w;
             $layoutData->height = $h;
             $layoutData->name = $name;
             $layoutData->label = $element->label;
             $layoutData->value = htmlspecialchars($val, ENT_QUOTES);
             $layoutData->dms = $this->_strToDMS($val);
             $layoutData->osref = "";
             $layoutData->staticmap = $params->get('fb_gm_staticmap');
             $layoutData->showdms = $params->get('fb_gm_latlng_dms');
             $layoutData->showlatlng = $params->get('fb_gm_latlng');
             $layoutData->showosref = $params->get('fb_gm_latlng_osref');
             return $layout->render($layoutData);
         } else {
             $str .= FText::_('PLG_ELEMENT_GOOGLEMAP_NO_LOCATION_SELECTED');
         }
         /*
          * $$$ hugh - not sure why we still do this.  If they want to show lat/lng details, they can use the
          * gm_latlng option.  Problem with showing this is we never change it, so it's misleading.
          */
         // $str .= $this->_microformat($val);
         return $str;
     }
 }