| Server IP : 54.36.91.62 / Your IP : 216.73.217.112 Web Server : Apache System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : coopiak ( 151928) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/coopiak/plats-individuels/lyon/components/com_community/libraries/fields/ |
Upload File : |
<?php
/**
* @copyright (C) 2013 iJoomla, Inc. - All rights reserved.
* @license GNU General Public License, version 2 (http://www.gnu.org/licenses/gpl-2.0.html)
* @author iJoomla.com <webmaster@ijoomla.com>
* @url https://www.jomsocial.com/license-agreement
* The PHP code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript *are NOT GPL, and are released under the IJOOMLA Proprietary Use License v1.0
* More info at https://www.jomsocial.com/license-agreement
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
require_once(COMMUNITY_COM_PATH.'/libraries/fields/profilefield.php');
class CFieldsLocation extends CProfileField
{
public function getFieldData($field)
{
$fieldValue = json_decode(html_entity_decode($field['value']), true);
if (empty($field['value'])) {
return $field['value'];
}
return $fieldValue['name'] . (!empty($fieldValue['desc']) ? ' ('.$fieldValue['desc'].')' : '');
}
public function getFieldHTML($field, $required)
{
$params = new CParameter($field->params);
$readonly = $params->get('readonly') && !COwnerHelper::isCommunityAdmin() ? ' readonly=""' : '';
$required = ($field->required == 1) ? ' data-required="true"' : '';
$style = $this->getStyle() ? ' style="' .$this->getStyle() . '"' : '';
// reformat value
$fieldName = '';
$fieldDesc = '';
$fieldLat = '';
$fieldLng = '';
try {
$fieldValue = new JRegistry(htmlspecialchars_decode($field->value));
$fieldName = $fieldValue->get('name');
$fieldDesc = $fieldValue->get('desc');
$fieldLat = $fieldValue->get('lat');
$fieldLng = $fieldValue->get('lng');
} catch (Exception $e) {
$app = JFactory::getApplication();
$app->enqueueMessage('Field location value error. Id: '. $field->id, 'error');
}
$html = '<div class="joms-location__wrapper">';
$html .= '<input type="text" value="' . htmlspecialchars($fieldName) . '" id="field' . $field->id . '" name="field' . $field->id . '[name]" class="joms-input joms-input--location" autocomplete="off" '. $readonly . $required . $style .' />';
$html .= '<input type="hidden" class="js-desc" name="field' . $field->id . '[desc]" value="' . htmlspecialchars($fieldDesc) . '" />';
$html .= '<input type="hidden" class="js-lat" name="field' . $field->id . '[lat]" value="' . htmlspecialchars($fieldLat) . '" />';
$html .= '<input type="hidden" class="js-lng" name="field' . $field->id . '[lng]" value="' . htmlspecialchars($fieldLng) . '" />';
$html .= '<div class="joms-location__description" data-tips="' . JText::_('COM_COMMUNITY_LOCATION_FIELD_DESCRIPTION', true) . '">' . ( $fieldDesc ? htmlspecialchars($fieldDesc) : JText::_('COM_COMMUNITY_LOCATION_FIELD_DESCRIPTION') ) . '</div>';
$html .= '<div class="joms-location__dropdown">';
$html .= '<div class="joms-location__loading"><img src="' . JURI::root(true) . '/components/com_community/assets/ajax-loader.gif" alt="loader"></div>';
$html .= '<div class="joms-location__result">';
$html .= '<div class="joms-location__header">' . JText::_('COM_COMMUNITY_SELECT_YOUR_LOCATION') . '</div>';
$html .= '<div class="joms-location__map"></div>';
$html .= '<div class="joms-location__list"></div>';
$html .= '<div class="joms-location__close">×</div>';
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
$config = CFactory::getConfig();
$document = JFactory::getDocument();
$document->addScriptDeclaration("joms_maps_api = '" . $config->get('maps_api', '') . "';");
if ($config->get('maps_api', '') == "googlemap") {
if (!$config->get('googleapikey', '')) {
$html = JText::_("COM_COMMUNITY_FIELD_NO_API_KEY", true);
} else {
$document->addScriptDeclaration("joms_gmap_key = '" . $config->get('googleapikey', '') . "';");
}
} else {
$path = JURI::root() . 'components/com_community/assets/source/js/utils/openstreet.js';
$document->addScript($path);
//test;
}
return $html;
}
public function isValid($value, $required)
{
$config = CFactory::getConfig();
if (!$config->get('googleapikey', '')) {
return true;
}
if ($required) {
if (empty($value)) {
return false;
}
$value = json_decode($value, true);
$name = trim($value['name']);
if (empty($name)) {
return false;
}
}
return true;
}
public function formatdata($value)
{
if ($value) {
$finalvalue = array(
'name' => $value['name'],
'desc' => isset($value['desc']) ? $value['desc'] : '',
'lat' => isset($value['lat']) ? $value['lat'] : '',
'lng' => isset($value['lng']) ? $value['lng'] : ''
);
} else {
$finalvalue = array();
}
return json_encode($finalvalue);
}
}