acf
This commit is contained in:
119
plugins/fields/acfmap/acfmap.php
Normal file
119
plugins/fields/acfmap/acfmap.php
Normal file
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Advanced Custom Fields
|
||||
* @version 2.8.8 Pro
|
||||
*
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2019 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
JLoader::register('ACF_Field', JPATH_PLUGINS . '/system/acf/helper/plugin.php');
|
||||
|
||||
if (!class_exists('ACF_Field'))
|
||||
{
|
||||
Factory::getApplication()->enqueueMessage('Advanced Custom Fields System Plugin is missing', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
class PlgFieldsACFMap extends ACF_Field
|
||||
{
|
||||
/**
|
||||
* Transforms the field into a DOM XML element and appends it as a child on the given parent.
|
||||
*
|
||||
* @param stdClass $field The field.
|
||||
* @param DOMElement $parent The field node parent.
|
||||
* @param Form $form The form.
|
||||
*
|
||||
* @return DOMElement
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function onCustomFieldsPrepareDom($field, DOMElement $parent, Joomla\CMS\Form\Form $form)
|
||||
{
|
||||
if (!$fieldNode = parent::onCustomFieldsPrepareDom($field, $parent, $form))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$fieldNode->setAttribute('filter', 'raw');
|
||||
|
||||
return $fieldNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* The form event. Load additional parameters when available into the field form.
|
||||
* Only when the type of the form is of interest.
|
||||
*
|
||||
* @param Form $form The form
|
||||
* @param stdClass $data The data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
public function onContentPrepareForm(Joomla\CMS\Form\Form $form, $data)
|
||||
{
|
||||
// When editing a new and unsaved field the $data variable is passed as an array for a reason.
|
||||
$data = is_array($data) ? (object) $data : $data;
|
||||
|
||||
// Make sure we are manipulating the right field.
|
||||
if (!isset($data->type) || $data->type != $this->_name)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get provider
|
||||
$provider = isset($data->fieldparams['provider']) ? $data->fieldparams['provider'] : false;
|
||||
|
||||
// Abort if no provider is set
|
||||
if (!$provider)
|
||||
{
|
||||
return parent::onContentPrepareForm($form, $data);
|
||||
}
|
||||
|
||||
// For OSM, we only check its key when we want to use satellite
|
||||
if ($provider === 'OpenStreetMap')
|
||||
{
|
||||
$osm_maptype = isset($data->fieldparams['openstreetmap_maptype']) ? $data->fieldparams['openstreetmap_maptype'] : 'road';
|
||||
if ($osm_maptype === 'road')
|
||||
{
|
||||
return parent::onContentPrepareForm($form, $data);
|
||||
}
|
||||
}
|
||||
|
||||
$key = $this->params->get(strtolower($provider) . '_key');
|
||||
|
||||
// Display a warning message to set the API key if empty
|
||||
if (empty($key))
|
||||
{
|
||||
$extensionID = NRFramework\Functions::getExtensionID('acfmap', 'fields');
|
||||
$backEndURL = 'index.php?option=com_plugins&task=plugin.edit&extension_id=' . $extensionID;
|
||||
$url = Uri::base() . $backEndURL;
|
||||
|
||||
$provider_name = $provider;
|
||||
|
||||
switch (strtolower($provider))
|
||||
{
|
||||
case 'bingmap':
|
||||
$provider_name = 'Bing Maps';
|
||||
break;
|
||||
case 'googlemap':
|
||||
$provider_name = 'Google Maps';
|
||||
break;
|
||||
}
|
||||
|
||||
Factory::getApplication()->enqueueMessage(Text::sprintf('ACF_MAP_API_KEY_WARNING', $provider_name, $url), 'warning');
|
||||
}
|
||||
|
||||
return parent::onContentPrepareForm($form, $data);
|
||||
}
|
||||
}
|
||||
52
plugins/fields/acfmap/acfmap.xml
Normal file
52
plugins/fields/acfmap/acfmap.xml
Normal file
@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<extension type="plugin" version="3.7.0" group="fields" method="upgrade">
|
||||
<name>ACF_MAP</name>
|
||||
<description>ACF_MAP_DESC</description>
|
||||
<author>Tassos Marinos</author>
|
||||
<creationDate>May 2023</creationDate>
|
||||
<copyright>Copyright (C) 2023 Tassos Marinos. All rights reserved.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>info@tassos.gr</authorEmail>
|
||||
<authorUrl>www.tassos.gr</authorUrl>
|
||||
<version>1.0</version>
|
||||
<scriptfile>script.install.php</scriptfile>
|
||||
<files>
|
||||
<filename plugin="acfmap">acfmap.php</filename>
|
||||
<filename>script.install.helper.php</filename>
|
||||
<filename>version.php</filename>
|
||||
<folder>language</folder>
|
||||
<folder>params</folder>
|
||||
<folder>tmpl</folder>
|
||||
<folder>fields</folder>
|
||||
</files>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic" addfieldpath="/plugins/system/nrframework/fields">
|
||||
<field name="openstreetmap_key" type="nrtext"
|
||||
label="ACF_MAP_OPENSTREETMAP_APIKEY"
|
||||
description="ACF_MAP_OPENSTREETMAP_APIKEY_DESC"
|
||||
urltext="ACF_MAP_OPENSTREETMAP_APIKEY_GET"
|
||||
url="https://www.tassos.gr/joomla-extensions/advanced-custom-fields/docs/the-map-field#get_osm_arcgis_key"
|
||||
class="span5"
|
||||
/>
|
||||
<field name="googlemap_key" type="nrtext"
|
||||
label="ACF_MAP_GOOGLEMAP_APIKEY"
|
||||
description="ACF_MAP_GOOGLEMAP_APIKEY_DESC"
|
||||
urltext="ACF_MAP_GOOGLEMAP_APIKEY_GET"
|
||||
url="https://www.tassos.gr/joomla-extensions/advanced-custom-fields/docs/the-map-field#get_googlemap_key"
|
||||
class="span5"
|
||||
/>
|
||||
<field name="bingmap_key" type="nrtext"
|
||||
label="ACF_MAP_BINGMAP_APIKEY"
|
||||
description="ACF_MAP_BINGMAP_APIKEY_DESC"
|
||||
urltext="ACF_MAP_BINGMAP_APIKEY_GET"
|
||||
url="https://www.tassos.gr/joomla-extensions/advanced-custom-fields/docs/the-map-field#get_bingmap_key"
|
||||
class="span5"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
<media folder="media" destination="plg_fields_acfmap">
|
||||
<folder>img</folder>
|
||||
</media>
|
||||
</extension>
|
||||
66
plugins/fields/acfmap/fields/acfmap.php
Normal file
66
plugins/fields/acfmap/fields/acfmap.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2018 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Form\Field\HiddenField;
|
||||
|
||||
class JFormFieldACFMap extends HiddenField
|
||||
{
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*/
|
||||
public function getInput()
|
||||
{
|
||||
$this->class = 'tf-map-editor--value';
|
||||
|
||||
$value = is_string($this->value) && !empty($this->value) ? (json_decode($this->value) ? json_decode($this->value, true) : []) : [];
|
||||
|
||||
$show_sidebar = isset($this->element['show_sidebar']) ? (string) $this->element['show_sidebar'] === '1' : true;
|
||||
|
||||
$payload = [
|
||||
'readonly' => $this->readonly,
|
||||
'disabled' => $this->disabled,
|
||||
'name' => $this->name,
|
||||
'width' => 700,
|
||||
'required' => $this->required,
|
||||
'id' => $this->id,
|
||||
'showSidebar' => $show_sidebar,
|
||||
|
||||
|
||||
'scale' => (string) $this->element['scale'] !== '0' ? (string) $this->element['scale'] : false,
|
||||
'pro' => true,
|
||||
'maxMarkers' => isset($this->element['maximum_markers']) ? (int) $this->element['maximum_markers'] : 0,
|
||||
'markerImage' => (string) $this->element['markerImage'],
|
||||
|
||||
];
|
||||
|
||||
|
||||
|
||||
$default_coords = (string) $this->element['default_coords'];
|
||||
if ($default_coords)
|
||||
{
|
||||
$default_coords = array_map('trim', explode(',', $default_coords));
|
||||
if (count($default_coords) === 2)
|
||||
{
|
||||
$payload['lat'] = $default_coords[0];
|
||||
$payload['long'] = $default_coords[1];
|
||||
}
|
||||
}
|
||||
|
||||
if ($value)
|
||||
{
|
||||
$payload['value'] = $value;
|
||||
}
|
||||
|
||||
return \NRFramework\Widgets\Helper::render('MapEditor', $payload) . parent::getInput();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
; @package Advanced Custom Fields
|
||||
; @version 2.8.8 Pro
|
||||
;
|
||||
; @author Tassos Marinos - http://www.tassos.gr/joomla-extensions
|
||||
; @copyright Copyright (c) 2019 Tassos Marinos. All rights reserved.
|
||||
; @license http://www.tassos.gr
|
||||
|
||||
PLG_FIELDS_ACFMAP_LABEL="ACF - Map"
|
||||
ACF_MAP="Fields - ACF Map"
|
||||
ACF_MAP_DESC="Display an interactive map based on OpenStreetMap, Google Maps, or Bing Maps and add unlimited markers."
|
||||
ACF_MAP_VALUE_DESC="Pick a location from the map, enter an address or coordinates in the search field."
|
||||
ACF_MAP_WIDTH="Map Width"
|
||||
ACF_MAP_WIDTH_DESC=""
|
||||
ACF_MAP_HEIGHT="Map Height"
|
||||
ACF_MAP_HEIGHT_DESC=""
|
||||
ACF_MAP_ADDRESS="Address"
|
||||
ACF_MAP_ADDRESS_DESC="Enter an address or coordinates to search"
|
||||
ACF_MAP_DEFAULT_COORDS="Default Map Coordinates"
|
||||
ACF_MAP_DEFAULT_COORDS_DESC="Enter the default latitude and longitude coordinates separated by comma."
|
||||
ACF_MAP_SCALE="Map Scale"
|
||||
ACF_MAP_SCALE_DESC="Select the scale unit that appears at the bottom left side of the map."
|
||||
ACF_MAP_SCALE_METRIC="Metric"
|
||||
ACF_MAP_SCALE_IMPERIAL="Imperial"
|
||||
ACF_MAP_PROVIDER="Provider"
|
||||
ACF_MAP_PROVIDER_DESC="Select the map provider."
|
||||
ACF_MAP_OPENSTREETMAP="OpenStreetMap"
|
||||
ACF_MAP_GOOGLE_MAP="Google Map"
|
||||
ACF_MAP_BING_MAP="Bing Map"
|
||||
ACF_MAP_UNLIMITED_MARKERS="Unlimited Markers"
|
||||
ACF_MAP_UNLIMITED_MARKERS_DESC="The free version allows up to 1 map marker. Upgrade to Pro to unlock unlimited map markers."
|
||||
ACF_MAP_BINGMAP_APIKEY="Bing Maps API Key"
|
||||
ACF_MAP_BINGMAP_APIKEY_DESC="Set your Bing Maps API Key. <br><br>Click on the 'Get a Bing Maps API Key' link for instructions on how you can get one."
|
||||
ACF_MAP_BINGMAP_APIKEY_GET="Get a Bing Maps API Key"
|
||||
ACF_MAP_GOOGLEMAP_APIKEY="Google Maps API Key"
|
||||
ACF_MAP_GOOGLEMAP_APIKEY_DESC="Set your Google Maps API Key. <br><br>Click on the 'Get a Google Maps API Key' link for instructions on how you can get one."
|
||||
ACF_MAP_GOOGLEMAP_APIKEY_GET="Get a Google Maps API Key"
|
||||
ACF_MAP_API_KEY_WARNING="In order for %s to run, you will need to set your API Key. <a href="%s">Set API Key now</a>."
|
||||
ACF_MAP_TYPE="Map Type"
|
||||
ACF_MAP_TYPE_DESC="Select the map type."
|
||||
ACF_MAP_SATELLITE="Satellite"
|
||||
ACF_MAP_TERRAIN="Terrain"
|
||||
ACF_MAP_HYBRID="Hybrid"
|
||||
ACF_MAP_ROAD="Road"
|
||||
ACF_MAP_DARK_MODE="Dark mode"
|
||||
ACF_MAP_LIGHT_MODE="Light mode"
|
||||
ACF_MAP_BIRDSEYE="Birdseye"
|
||||
ACF_MAP_GRAYSCALE="Grayscale"
|
||||
ACF_MAP_ORDNANCESURVEY="Ordnance Survey"
|
||||
ACF_MAP_OPENSTREETMAP_APIKEY="OpenStreetMap ArcGIS API Key"
|
||||
ACF_MAP_OPENSTREETMAP_APIKEY_DESC="Set your ArcGIS Developer API Key required by the OpenStreetMap to show the map in satellite mode. <br><br>Click on the 'Get an ArcGIS Developer API Key' link for instructions on how you can get one."
|
||||
ACF_MAP_OPENSTREETMAP_APIKEY_GET="Get an ArcGIS Developer API Key"
|
||||
ACF_MAP_ZOOM_LEVEL="Zoom Level"
|
||||
ACF_MAP_ZOOM_LEVEL_DESC="Set the map zoom."
|
||||
ACF_MAP_MAP_CENTER="Map Center"
|
||||
ACF_MAP_MAP_CENTER_DESC="Set whether to set a fixed zoom for the map or let the map provider auto-zoom and center the map around the markers."
|
||||
ACF_MAP_PRESET_ZOOM="Preset Zoom"
|
||||
ACF_MAP_FIT_BOUNDS="Fit Bounds"
|
||||
ACF_MAP_SET_MAP_CENTER="Set Map Center"
|
||||
ACF_MAP_SET_MAP_CENTER_DESC="Define where to center the map. If no value is set, it defaults to the first marker added on the map."
|
||||
ACF_MAP_ENABLE_INFO_WINDOW="Enable Info Window"
|
||||
ACF_MAP_ENABLE_INFO_WINDOW_DESC="Set whether to display an info window whenever a map marker is clicked.<br />By default, it will show each map marker address, however, you can define a custom label and description for each map marker."
|
||||
ACF_MAP_MAXIMUM_MARKERS="Maximum Markers"
|
||||
ACF_MAP_MAXIMUM_MARKERS_DESC="Set the maximum number of markers that can be added on the map. Enter 0 for unlimited markers."
|
||||
ACF_MAP_MARKER_IMAGE="Marker Image"
|
||||
ACF_MAP_MARKER_IMAGE_DESC="Replace the default marker image by uploading an image of your choice."
|
||||
ACF_MAP_SHOW_SIDEBAR="Show Sidebar"
|
||||
ACF_MAP_SHOW_SIDEBAR_DESC="Set whether to show the sidebar on the left side of the map editor. The sidebar allows you to filter, edit, delete markers, as well as import locations."
|
||||
@ -0,0 +1,9 @@
|
||||
; @package Advanced Custom Fields
|
||||
; @version 2.8.8 Pro
|
||||
;
|
||||
; @author Tassos Marinos - http://www.tassos.gr/joomla-extensions
|
||||
; @copyright Copyright (c) 2019 Tassos Marinos. All rights reserved.
|
||||
; @license http://www.tassos.gr
|
||||
|
||||
ACF_MAP="Fields - ACF Map"
|
||||
ACF_MAP_DESC="Display an interactive map based on OpenStreetMap, Google Maps, or Bing Maps."
|
||||
@ -0,0 +1,67 @@
|
||||
; @package Advanced Custom Fields
|
||||
; @version 2.8.8 Pro
|
||||
;
|
||||
; @author Tassos Marinos - http://www.tassos.gr/joomla-extensions
|
||||
; @copyright Copyright (c) 2019 Tassos Marinos. All rights reserved.
|
||||
; @license http://www.tassos.gr
|
||||
|
||||
PLG_FIELDS_ACFMAP_LABEL="ACF - Mapa"
|
||||
ACF_MAP="Campos - ACF Mapas"
|
||||
ACF_MAP_DESC="Muestre un mapa interactivo basado en OpenStreetMap, Google Maps o Bing Maps y agregue marcadores ilimitados."
|
||||
ACF_MAP_VALUE_DESC="Elija una ubicación del mapa, ingrese una dirección o coordenadas en el campo de búsqueda."
|
||||
ACF_MAP_WIDTH="Ancho del Mapa"
|
||||
ACF_MAP_WIDTH_DESC=""
|
||||
ACF_MAP_HEIGHT="Altura del Mapa"
|
||||
ACF_MAP_HEIGHT_DESC=""
|
||||
ACF_MAP_ADDRESS="Dirección"
|
||||
ACF_MAP_ADDRESS_DESC="Introduzca una dirección o coordenadas para buscar"
|
||||
ACF_MAP_DEFAULT_COORDS="Coordenadas de Mapa Predeterminadas"
|
||||
ACF_MAP_DEFAULT_COORDS_DESC="Introduzca las coordenadas de latitud y longitud predeterminadas separadas por comas."
|
||||
ACF_MAP_SCALE="Escala del Mapa"
|
||||
ACF_MAP_SCALE_DESC="Seleccione la unidad de escala que aparece en la parte inferior izquierda del mapa."
|
||||
ACF_MAP_SCALE_METRIC="Métrica"
|
||||
ACF_MAP_SCALE_IMPERIAL="Imperial"
|
||||
ACF_MAP_PROVIDER="Proveedor"
|
||||
ACF_MAP_PROVIDER_DESC="Seleccione un proveedor de mapas."
|
||||
ACF_MAP_OPENSTREETMAP="OpenStreetMap"
|
||||
ACF_MAP_GOOGLE_MAP="Google Map"
|
||||
ACF_MAP_BING_MAP="Bing Map"
|
||||
ACF_MAP_UNLIMITED_MARKERS="Marcadores Ilimitados"
|
||||
ACF_MAP_UNLIMITED_MARKERS_DESC="La versión gratuita solo permite 1 marcador de mapa. Actualice a Pro para desbloquear marcadores de mapa ilimitados."
|
||||
ACF_MAP_BINGMAP_APIKEY="Clave API de Bing Maps"
|
||||
ACF_MAP_BINGMAP_APIKEY_DESC="Configure su clave API de Bing Maps. <br><br>Haga clic en el enlace 'Obtener una clave API de Bing Maps' para obtener instrucciones sobre cómo obtener una."
|
||||
ACF_MAP_BINGMAP_APIKEY_GET="Obtener una clave API de Bing Maps"
|
||||
ACF_MAP_GOOGLEMAP_APIKEY="Clave API de Google Maps"
|
||||
ACF_MAP_GOOGLEMAP_APIKEY_DESC="Configure su clave de API de Google Maps. <br><br>Haga clic en el enlace 'Obtener una clave API de Google Maps' para obtener instrucciones sobre cómo obtener una."
|
||||
ACF_MAP_GOOGLEMAP_APIKEY_GET="Obtener una clave API de Google Maps"
|
||||
ACF_MAP_API_KEY_WARNING="Para que %s se ejecute, deberá configurar su clave API. <a href=\"%s\">Establecer clave API ahora</a>."
|
||||
ACF_MAP_TYPE="Tipo de Mapa"
|
||||
ACF_MAP_TYPE_DESC="Seleccione el tipo de mapa"
|
||||
ACF_MAP_SATELLITE="Satelite"
|
||||
ACF_MAP_TERRAIN="Terreno"
|
||||
ACF_MAP_HYBRID="Hibrido"
|
||||
ACF_MAP_ROAD="Camino"
|
||||
ACF_MAP_DARK_MODE="Modo oscuro"
|
||||
ACF_MAP_LIGHT_MODE="Modo luminoso"
|
||||
ACF_MAP_BIRDSEYE="Ojo de pájaro"
|
||||
ACF_MAP_GRAYSCALE="Escala de grises"
|
||||
ACF_MAP_ORDNANCESURVEY="Encuesta de Artillería"
|
||||
ACF_MAP_OPENSTREETMAP_APIKEY="Clave API OpenStreetMap ArcGIS"
|
||||
ACF_MAP_OPENSTREETMAP_APIKEY_DESC="Configure su clave API del desarrollador de ArcGIS requerida por OpenStreetMap para mostrar el mapa en modo satélite. <br><br>Haga clic en el enlace 'Obtener una clave API de ArcGIS Developer' para obtener instrucciones sobre cómo obtener una."
|
||||
ACF_MAP_OPENSTREETMAP_APIKEY_GET="Obtener una clave API de ArcGIS Developer"
|
||||
ACF_MAP_ZOOM_LEVEL="Nivel de Zoom"
|
||||
ACF_MAP_ZOOM_LEVEL_DESC="Establecer el zoom del mapa"
|
||||
ACF_MAP_MAP_CENTER="Mapa Centrado"
|
||||
ACF_MAP_MAP_CENTER_DESC="Establezca si desea establecer un zoom fijo para el mapa o dejar que el proveedor del mapa haga zoom automáticamente y centre el mapa alrededor de los marcadores."
|
||||
ACF_MAP_PRESET_ZOOM="Zoom preestablecido"
|
||||
ACF_MAP_FIT_BOUNDS="Ajustar Límites"
|
||||
ACF_MAP_SET_MAP_CENTER="Establecer Centro del Mapa"
|
||||
ACF_MAP_SET_MAP_CENTER_DESC="Defina dónde centrar el mapa. Si no se establece ningún valor, el valor predeterminado es el primer marcador agregado en el mapa."
|
||||
ACF_MAP_ENABLE_INFO_WINDOW="Habilitar ventana de información"
|
||||
ACF_MAP_ENABLE_INFO_WINDOW_DESC="Establece si mostrar una ventana de información cada vez que se hace clic en un marcador de mapa.<br>De manera predeterminada, mostrará la dirección de cada marcador del mapa; sin embargo, puede definir una etiqueta personalizada y una descripción para cada marcador de mapa."
|
||||
ACF_MAP_MAXIMUM_MARKERS="Marcadores máximos"
|
||||
ACF_MAP_MAXIMUM_MARKERS_DESC="Establece el número máximo de marcadores que se pueden agregar en el mapa. Ingrese 0 para marcadores ilimitados."
|
||||
ACF_MAP_MARKER_IMAGE="Imagen del Marcador"
|
||||
ACF_MAP_MARKER_IMAGE_DESC="Reemplace la imagen del marcador predeterminado cargando una imagen de su elección."
|
||||
ACF_MAP_SHOW_SIDEBAR="Mostrar barra lateral"
|
||||
ACF_MAP_SHOW_SIDEBAR_DESC="Establecer si mostrar la barra lateral en el lado izquierdo del editor de mapas. La barra lateral te permite filtrar, editar, eliminar marcadores, así como importar ubicaciones."
|
||||
@ -0,0 +1,9 @@
|
||||
; @package Advanced Custom Fields
|
||||
; @version 2.8.8 Pro
|
||||
;
|
||||
; @author Tassos Marinos - http://www.tassos.gr/joomla-extensions
|
||||
; @copyright Copyright (c) 2019 Tassos Marinos. All rights reserved.
|
||||
; @license http://www.tassos.gr
|
||||
|
||||
ACF_MAP="Campos - ACF Map"
|
||||
ACF_MAP_DESC="Muestre un mapa interactivo basado en OpenStreetMap, Google Maps o Bing Maps."
|
||||
144
plugins/fields/acfmap/params/acfmap.xml
Normal file
144
plugins/fields/acfmap/params/acfmap.xml
Normal file
@ -0,0 +1,144 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form>
|
||||
<fields name="fieldparams">
|
||||
<fieldset name="fieldparams">
|
||||
<field name="provider" type="NRImagesSelector"
|
||||
images='[{"key": "OpenStreetMap", "label": "NR_OPENSTREETMAP", "url": "https://www.tassos.gr/images/apps/openstreetmap.png"}, {"key": "GoogleMap", "label": "NR_GOOGLEMAPS", "url": "https://www.tassos.gr/images/apps/google-maps.png"}, {"key": "BingMap", "label": "NR_BINGMAPS", "url": "https://www.tassos.gr/images/apps/bing-maps.png"}]'
|
||||
columns="3"
|
||||
default="OpenStreetMap"
|
||||
label="ACF_MAP_PROVIDER"
|
||||
description="ACF_MAP_PROVIDER_DESC"
|
||||
mode="links"
|
||||
image_width="100px"
|
||||
width="500px"
|
||||
/>
|
||||
|
||||
<field name="openstreetmap_maptype" type="list"
|
||||
label="ACF_MAP_TYPE"
|
||||
description="ACF_MAP_TYPE_DESC"
|
||||
default="road"
|
||||
showon="provider:OpenStreetMap">
|
||||
<option value="road">ACF_MAP_ROAD</option>
|
||||
<option value="satellite">ACF_MAP_SATELLITE</option>
|
||||
</field>
|
||||
<field name="googlemap_maptype" type="list"
|
||||
label="ACF_MAP_TYPE"
|
||||
description="ACF_MAP_TYPE_DESC"
|
||||
default="roadmap"
|
||||
showon="provider:GoogleMap">
|
||||
<option value="roadmap">ACF_MAP_ROAD</option>
|
||||
<option value="satellite">ACF_MAP_SATELLITE</option>
|
||||
<option value="terrain">ACF_MAP_TERRAIN</option>
|
||||
<option value="hybrid">ACF_MAP_HYBRID</option>
|
||||
</field>
|
||||
<field name="bingmap_maptype" type="list"
|
||||
label="ACF_MAP_TYPE"
|
||||
description="ACF_MAP_TYPE_DESC"
|
||||
default="road"
|
||||
showon="provider:BingMap">
|
||||
<option value="road">ACF_MAP_ROAD</option>
|
||||
<option value="aerial">ACF_MAP_SATELLITE</option>
|
||||
<option value="birdseye">ACF_MAP_BIRDSEYE</option>
|
||||
<option value="grayscale">ACF_MAP_GRAYSCALE</option>
|
||||
<option value="ordnanceSurvey">ACF_MAP_ORDNANCESURVEY</option>
|
||||
<option value="canvasDark">ACF_MAP_DARK_MODE</option>
|
||||
<option value="canvasLight">ACF_MAP_LIGHT_MODE</option>
|
||||
</field>
|
||||
<field name="scale" type="list"
|
||||
label="ACF_MAP_SCALE"
|
||||
description="ACF_MAP_SCALE_DESC"
|
||||
default="0">
|
||||
<option value="0">JDISABLED</option>
|
||||
<option value="metric">ACF_MAP_SCALE_METRIC</option>
|
||||
<option value="imperial">ACF_MAP_SCALE_IMPERIAL</option>
|
||||
</field>
|
||||
|
||||
|
||||
|
||||
<field type="spacer" name="label"
|
||||
label="NR_FRONTEND"
|
||||
class="acf"
|
||||
/>
|
||||
<field name="width_control" type="NRResponsiveControl"
|
||||
label="ACF_MAP_WIDTH"
|
||||
description="ACF_MAP_WIDTH_DESC">
|
||||
<subform>
|
||||
<field name="width" type="nrnumber"
|
||||
class="input-small"
|
||||
default="400"
|
||||
hint="400"
|
||||
min="1"
|
||||
addon="px"
|
||||
/>
|
||||
</subform>
|
||||
</field>
|
||||
<field name="height_control" type="NRResponsiveControl"
|
||||
label="ACF_MAP_HEIGHT"
|
||||
description="ACF_MAP_HEIGHT_DESC">
|
||||
<subform>
|
||||
<field name="height" type="nrnumber"
|
||||
class="input-small"
|
||||
default="350"
|
||||
hint="350"
|
||||
min="1"
|
||||
addon="px"
|
||||
/>
|
||||
</subform>
|
||||
</field>
|
||||
<field name="zoom_level" type="radio"
|
||||
label="ACF_MAP_MAP_CENTER"
|
||||
description="ACF_MAP_MAP_CENTER_DESC"
|
||||
default="fitbounds"
|
||||
class="btn-group btn-group-yesno">
|
||||
<option value="preset">NR_CUSTOM</option>
|
||||
<option value="fitbounds">ACF_MAP_FIT_BOUNDS</option>
|
||||
</field>
|
||||
<field name="map_center" type="TFAddressLookup"
|
||||
label="ACF_MAP_SET_MAP_CENTER"
|
||||
description="ACF_MAP_SET_MAP_CENTER_DESC"
|
||||
showon="zoom_level:preset"
|
||||
/>
|
||||
<field name="zoom" type="nrnumber"
|
||||
label="ACF_MAP_ZOOM_LEVEL"
|
||||
description="ACF_MAP_ZOOM_LEVEL_DESC"
|
||||
default="4"
|
||||
min="0"
|
||||
showon="zoom_level:preset"
|
||||
/>
|
||||
<field name="enable_info_window" type="NRToggle"
|
||||
label="ACF_MAP_ENABLE_INFO_WINDOW"
|
||||
description="ACF_MAP_ENABLE_INFO_WINDOW_DESC"
|
||||
checked="true"
|
||||
/>
|
||||
|
||||
<field name="maximum_markers" type="nrnumber"
|
||||
label="ACF_MAP_MAXIMUM_MARKERS"
|
||||
description="ACF_MAP_MAXIMUM_MARKERS_DESC"
|
||||
default="0"
|
||||
min="0"
|
||||
/>
|
||||
<field name="markerImage" type="media"
|
||||
preview_width="32"
|
||||
label="ACF_MAP_MARKER_IMAGE"
|
||||
description="ACF_MAP_MARKER_IMAGE_DESC"
|
||||
/>
|
||||
|
||||
|
||||
<field type="spacer" name="label2"
|
||||
label="NR_BACKEND"
|
||||
class="acf"
|
||||
/>
|
||||
<field name="show_sidebar" type="nrtoggle"
|
||||
label="ACF_MAP_SHOW_SIDEBAR"
|
||||
description="ACF_MAP_SHOW_SIDEBAR_DESC"
|
||||
checked="true"
|
||||
/>
|
||||
<field name="default_coords" type="text"
|
||||
label="ACF_MAP_DEFAULT_COORDS"
|
||||
description="ACF_MAP_DEFAULT_COORDS_DESC"
|
||||
hint="36.891319,27.283480"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
|
||||
691
plugins/fields/acfmap/script.install.helper.php
Normal file
691
plugins/fields/acfmap/script.install.helper.php
Normal file
@ -0,0 +1,691 @@
|
||||
<?php
|
||||
/**
|
||||
* Installer Script Helper
|
||||
*
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2016 Tassos Marinos All Rights Reserved
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Installer\Installer;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\Filesystem\File;
|
||||
use Joomla\Filesystem\Folder;
|
||||
|
||||
class PlgFieldsAcfmapInstallerScriptHelper
|
||||
{
|
||||
public $name = '';
|
||||
public $alias = '';
|
||||
public $extname = '';
|
||||
public $extension_type = '';
|
||||
public $plugin_folder = 'system';
|
||||
public $module_position = 'status';
|
||||
public $client_id = 1;
|
||||
public $install_type = 'install';
|
||||
public $show_message = true;
|
||||
public $autopublish = true;
|
||||
public $db = null;
|
||||
public $app = null;
|
||||
public $installedVersion;
|
||||
|
||||
public function __construct(&$params)
|
||||
{
|
||||
$this->extname = $this->extname ?: $this->alias;
|
||||
$this->db = Factory::getDbo();
|
||||
$this->app = Factory::getApplication();
|
||||
$this->installedVersion = $this->getVersion($this->getInstalledXMLFile());
|
||||
}
|
||||
|
||||
/**
|
||||
* Preflight event
|
||||
*
|
||||
* @param string
|
||||
* @param JAdapterInstance
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function preflight($route, $adapter)
|
||||
{
|
||||
if (!in_array($route, array('install', 'update')))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Factory::getLanguage()->load('plg_system_novaraininstaller', JPATH_PLUGINS . '/system/novaraininstaller');
|
||||
|
||||
if ($this->show_message && $this->isInstalled())
|
||||
{
|
||||
$this->install_type = 'update';
|
||||
}
|
||||
|
||||
if ($this->onBeforeInstall() === false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Preflight event
|
||||
*
|
||||
* @param string
|
||||
* @param JAdapterInstance
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function postflight($route, $adapter)
|
||||
{
|
||||
Factory::getLanguage()->load($this->getPrefix() . '_' . $this->extname, $this->getMainFolder());
|
||||
|
||||
if (!in_array($route, array('install', 'update')))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->onAfterInstall() === false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($route == 'install' && $this->autopublish)
|
||||
{
|
||||
$this->publishExtension();
|
||||
}
|
||||
|
||||
if ($this->show_message)
|
||||
{
|
||||
$this->addInstalledMessage();
|
||||
}
|
||||
|
||||
Factory::getCache()->clean('com_plugins');
|
||||
Factory::getCache()->clean('_system');
|
||||
}
|
||||
|
||||
public function isInstalled()
|
||||
{
|
||||
if (!is_file($this->getInstalledXMLFile()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$query = $this->db->getQuery(true)
|
||||
->select('extension_id')
|
||||
->from('#__extensions')
|
||||
->where($this->db->quoteName('type') . ' = ' . $this->db->quote($this->extension_type))
|
||||
->where($this->db->quoteName('element') . ' = ' . $this->db->quote($this->getElementName()));
|
||||
$this->db->setQuery($query, 0, 1);
|
||||
$result = $this->db->loadResult();
|
||||
|
||||
return empty($result) ? false : true;
|
||||
}
|
||||
|
||||
public function getMainFolder()
|
||||
{
|
||||
switch ($this->extension_type)
|
||||
{
|
||||
case 'plugin' :
|
||||
return JPATH_SITE . '/plugins/' . $this->plugin_folder . '/' . $this->extname;
|
||||
|
||||
case 'component' :
|
||||
return JPATH_ADMINISTRATOR . '/components/com_' . $this->extname;
|
||||
|
||||
case 'module' :
|
||||
return JPATH_ADMINISTRATOR . '/modules/mod_' . $this->extname;
|
||||
|
||||
case 'library' :
|
||||
return JPATH_SITE . '/libraries/' . $this->extname;
|
||||
}
|
||||
}
|
||||
|
||||
public function getInstalledXMLFile()
|
||||
{
|
||||
return $this->getXMLFile($this->getMainFolder());
|
||||
}
|
||||
|
||||
public function getCurrentXMLFile()
|
||||
{
|
||||
return $this->getXMLFile(__DIR__);
|
||||
}
|
||||
|
||||
public function getXMLFile($folder)
|
||||
{
|
||||
switch ($this->extension_type)
|
||||
{
|
||||
case 'module' :
|
||||
return $folder . '/mod_' . $this->extname . '.xml';
|
||||
default :
|
||||
return $folder . '/' . $this->extname . '.xml';
|
||||
}
|
||||
}
|
||||
|
||||
public function foldersExist($folders = array())
|
||||
{
|
||||
foreach ($folders as $folder)
|
||||
{
|
||||
if (is_dir($folder))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function publishExtension()
|
||||
{
|
||||
switch ($this->extension_type)
|
||||
{
|
||||
case 'plugin' :
|
||||
$this->publishPlugin();
|
||||
|
||||
case 'module' :
|
||||
$this->publishModule();
|
||||
}
|
||||
}
|
||||
|
||||
public function publishPlugin()
|
||||
{
|
||||
$query = $this->db->getQuery(true)
|
||||
->update('#__extensions')
|
||||
->set($this->db->quoteName('enabled') . ' = 1')
|
||||
->where($this->db->quoteName('type') . ' = ' . $this->db->quote('plugin'))
|
||||
->where($this->db->quoteName('element') . ' = ' . $this->db->quote($this->extname))
|
||||
->where($this->db->quoteName('folder') . ' = ' . $this->db->quote($this->plugin_folder));
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
}
|
||||
|
||||
public function publishModule()
|
||||
{
|
||||
// Get module id
|
||||
$query = $this->db->getQuery(true)
|
||||
->select('id')
|
||||
->from('#__modules')
|
||||
->where($this->db->quoteName('module') . ' = ' . $this->db->quote('mod_' . $this->extname))
|
||||
->where($this->db->quoteName('client_id') . ' = ' . (int) $this->client_id);
|
||||
$this->db->setQuery($query, 0, 1);
|
||||
$id = $this->db->loadResult();
|
||||
|
||||
if (!$id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// check if module is already in the modules_menu table (meaning is is already saved)
|
||||
$query->clear()
|
||||
->select('moduleid')
|
||||
->from('#__modules_menu')
|
||||
->where($this->db->quoteName('moduleid') . ' = ' . (int) $id);
|
||||
$this->db->setQuery($query, 0, 1);
|
||||
$exists = $this->db->loadResult();
|
||||
|
||||
if ($exists)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get highest ordering number in position
|
||||
$query->clear()
|
||||
->select('ordering')
|
||||
->from('#__modules')
|
||||
->where($this->db->quoteName('position') . ' = ' . $this->db->quote($this->module_position))
|
||||
->where($this->db->quoteName('client_id') . ' = ' . (int) $this->client_id)
|
||||
->order('ordering DESC');
|
||||
$this->db->setQuery($query, 0, 1);
|
||||
$ordering = $this->db->loadResult();
|
||||
$ordering++;
|
||||
|
||||
// publish module and set ordering number
|
||||
$query->clear()
|
||||
->update('#__modules')
|
||||
->set($this->db->quoteName('published') . ' = 1')
|
||||
->set($this->db->quoteName('ordering') . ' = ' . (int) $ordering)
|
||||
->set($this->db->quoteName('position') . ' = ' . $this->db->quote($this->module_position))
|
||||
->where($this->db->quoteName('id') . ' = ' . (int) $id);
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
|
||||
// add module to the modules_menu table
|
||||
$query->clear()
|
||||
->insert('#__modules_menu')
|
||||
->columns(array($this->db->quoteName('moduleid'), $this->db->quoteName('menuid')))
|
||||
->values((int) $id . ', 0');
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
}
|
||||
|
||||
public function addInstalledMessage()
|
||||
{
|
||||
Factory::getApplication()->enqueueMessage(
|
||||
Text::sprintf(
|
||||
Text::_($this->install_type == 'update' ? 'NRI_THE_EXTENSION_HAS_BEEN_UPDATED_SUCCESSFULLY' : 'NRI_THE_EXTENSION_HAS_BEEN_INSTALLED_SUCCESSFULLY'),
|
||||
'<strong>' . Text::_($this->name) . '</strong>',
|
||||
'<strong>' . $this->getVersion() . '</strong>',
|
||||
$this->getFullType()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getPrefix()
|
||||
{
|
||||
switch ($this->extension_type)
|
||||
{
|
||||
case 'plugin';
|
||||
return Text::_('plg_' . strtolower($this->plugin_folder));
|
||||
|
||||
case 'component':
|
||||
return Text::_('com');
|
||||
|
||||
case 'module':
|
||||
return Text::_('mod');
|
||||
|
||||
case 'library':
|
||||
return Text::_('lib');
|
||||
|
||||
default:
|
||||
return $this->extension_type;
|
||||
}
|
||||
}
|
||||
|
||||
public function getElementName($type = null, $extname = null)
|
||||
{
|
||||
$type = is_null($type) ? $this->extension_type : $type;
|
||||
$extname = is_null($extname) ? $this->extname : $extname;
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
case 'component' :
|
||||
return 'com_' . $extname;
|
||||
|
||||
case 'module' :
|
||||
return 'mod_' . $extname;
|
||||
|
||||
case 'plugin' :
|
||||
default:
|
||||
return $extname;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFullType()
|
||||
{
|
||||
return Text::_('NRI_' . strtoupper($this->getPrefix()));
|
||||
}
|
||||
|
||||
public function isPro()
|
||||
{
|
||||
$versionFile = __DIR__ . "/version.php";
|
||||
|
||||
// If version file does not exist we assume a PRO version
|
||||
if (!is_file($versionFile))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Load version file
|
||||
require_once $versionFile;
|
||||
return (bool) $NR_PRO;
|
||||
}
|
||||
|
||||
public function getVersion($file = '')
|
||||
{
|
||||
$file = $file ?: $this->getCurrentXMLFile();
|
||||
|
||||
if (!is_file($file))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$xml = Installer::parseXMLInstallFile($file);
|
||||
|
||||
if (!$xml || !isset($xml['version']))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return $xml['version'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks wether the extension can be installed or not
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canInstall()
|
||||
{
|
||||
// The extension is not installed yet. Accept Install.
|
||||
if (!$installed_version = $this->getVersion($this->getInstalledXMLFile()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Path to extension's version file
|
||||
$versionFile = $this->getMainFolder() . "/version.php";
|
||||
$NR_PRO = true;
|
||||
|
||||
// If version file does not exist we assume we have a PRO version installed
|
||||
if (file_exists($versionFile))
|
||||
{
|
||||
require_once($versionFile);
|
||||
}
|
||||
|
||||
// The free version is installed. Accept install.
|
||||
if (!(bool)$NR_PRO)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Current package is a PRO version. Accept install.
|
||||
if ($this->isPro())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// User is trying to update from PRO version to FREE. Do not accept install.
|
||||
Factory::getLanguage()->load($this->getPrefix() . '_' . $this->extname, __DIR__);
|
||||
|
||||
Factory::getApplication()->enqueueMessage(
|
||||
Text::_('NRI_ERROR_PRO_TO_FREE'), 'error'
|
||||
);
|
||||
|
||||
Factory::getApplication()->enqueueMessage(
|
||||
html_entity_decode(
|
||||
Text::sprintf(
|
||||
'NRI_ERROR_UNINSTALL_FIRST',
|
||||
'<a href="http://www.tassos.gr/joomla-extensions/' . $this->getUrlAlias() . '" target="_blank">',
|
||||
'</a>',
|
||||
Text::_($this->name)
|
||||
)
|
||||
), 'error'
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL alias of the extension.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getUrlAlias()
|
||||
{
|
||||
$alias = $this->alias;
|
||||
|
||||
switch ($alias)
|
||||
{
|
||||
case 'smilepack':
|
||||
$alias = 'smile-pack';
|
||||
break;
|
||||
case 'convertforms':
|
||||
$alias = 'convert-forms';
|
||||
break;
|
||||
case 'rstbox':
|
||||
$alias = 'engagebox';
|
||||
break;
|
||||
case 'gsd':
|
||||
$alias = 'google-structured-data';
|
||||
break;
|
||||
}
|
||||
|
||||
// ACF
|
||||
if ($this->plugin_folder === 'fields' && ($alias === 'acf' || $this->startsWith($alias, 'acf')))
|
||||
{
|
||||
$alias = 'advanced-custom-fields';
|
||||
}
|
||||
|
||||
return $alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether string starts with substring.
|
||||
*
|
||||
* @param string $string
|
||||
* @param string $query
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function startsWith($string, $query)
|
||||
{
|
||||
return substr($string, 0, strlen($query)) === $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if current version is newer than the installed one
|
||||
* Used for Novarain Framework
|
||||
*
|
||||
* @return boolean [description]
|
||||
*/
|
||||
public function isNewer()
|
||||
{
|
||||
if (!$installed_version = $this->getVersion($this->getInstalledXMLFile()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
$package_version = $this->getVersion();
|
||||
|
||||
return version_compare($installed_version, $package_version, '<=');
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method triggered before installation
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function onBeforeInstall()
|
||||
{
|
||||
if (!$this->canInstall())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method triggered after installation
|
||||
*/
|
||||
public function onAfterInstall()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete files
|
||||
*
|
||||
* @param array $folders
|
||||
*/
|
||||
public function deleteFiles($files = array())
|
||||
{
|
||||
foreach ($files as $key => $file)
|
||||
{
|
||||
if (!is_file($file))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
File::delete($file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes folders
|
||||
*
|
||||
* @param array $folders
|
||||
*/
|
||||
public function deleteFolders($folders = array())
|
||||
{
|
||||
foreach ($folders as $folder)
|
||||
{
|
||||
if (!is_dir($folder))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Folder::delete($folder);
|
||||
}
|
||||
}
|
||||
|
||||
public function dropIndex($table, $index)
|
||||
{
|
||||
$db = $this->db;
|
||||
|
||||
// Check if index exists first
|
||||
$query = 'SHOW INDEX FROM ' . $db->quoteName('#__' . $table) . ' WHERE KEY_NAME = ' . $db->quote($index);
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
if (!$db->loadResult())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove index
|
||||
$query = 'ALTER TABLE ' . $db->quoteName('#__' . $table) . ' DROP INDEX ' . $db->quoteName($index);
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
}
|
||||
|
||||
public function dropUnwantedTables($tables) {
|
||||
|
||||
if (!$tables) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($tables as $table) {
|
||||
$query = "DROP TABLE IF EXISTS #__".$this->db->escape($table);
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
}
|
||||
}
|
||||
|
||||
public function dropUnwantedColumns($table, $columns) {
|
||||
|
||||
if (!$columns || !$table) {
|
||||
return;
|
||||
}
|
||||
|
||||
$db = $this->db;
|
||||
|
||||
// Check if columns exists in database
|
||||
function qt($n) {
|
||||
return(Factory::getDBO()->quote($n));
|
||||
}
|
||||
|
||||
$query = 'SHOW COLUMNS FROM #__'.$table.' WHERE Field IN ('.implode(",", array_map("qt", $columns)).')';
|
||||
$db->setQuery($query);
|
||||
$rows = $db->loadColumn(0);
|
||||
|
||||
// Abort if we don't have any rows
|
||||
if (!$rows) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Let's remove the columns
|
||||
$q = "";
|
||||
foreach ($rows as $key => $column) {
|
||||
$comma = (($key+1) < count($rows)) ? "," : "";
|
||||
$q .= "drop ".$this->db->escape($column).$comma;
|
||||
}
|
||||
|
||||
$query = "alter table #__".$table." $q";
|
||||
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
}
|
||||
|
||||
public function fetch($table, $columns = "*", $where = null, $singlerow = false) {
|
||||
if (!$table) {
|
||||
return;
|
||||
}
|
||||
|
||||
$db = $this->db;
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query
|
||||
->select($columns)
|
||||
->from("#__$table");
|
||||
|
||||
if (isset($where)) {
|
||||
$query->where("$where");
|
||||
}
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return ($singlerow) ? $db->loadObject() : $db->loadObjectList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the Novarain Framework
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function loadFramework()
|
||||
{
|
||||
if (is_file(JPATH_PLUGINS . '/system/nrframework/autoload.php'))
|
||||
{
|
||||
include_once JPATH_PLUGINS . '/system/nrframework/autoload.php';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-orders plugin after passed array of plugins
|
||||
*
|
||||
* @param string $plugin Plugin element name
|
||||
* @param array $lowerPluginOrder Array of plugin element names
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function pluginOrderAfter($lowerPluginOrder)
|
||||
{
|
||||
|
||||
if (!is_array($lowerPluginOrder) || !count($lowerPluginOrder))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$db = $this->db;
|
||||
|
||||
// Get plugins max order
|
||||
$query = $db->getQuery(true);
|
||||
$query
|
||||
->select($db->quoteName('b.ordering'))
|
||||
->from($db->quoteName('#__extensions', 'b'))
|
||||
->where($db->quoteName('b.element') . ' IN ("'.implode("\",\"",$lowerPluginOrder).'")')
|
||||
->order('b.ordering desc');
|
||||
|
||||
$db->setQuery($query);
|
||||
$maxOrder = $db->loadResult();
|
||||
|
||||
if (is_null($maxOrder))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get plugin details
|
||||
$query
|
||||
->clear()
|
||||
->select(array($db->quoteName('extension_id'), $db->quoteName('ordering')))
|
||||
->from($db->quoteName('#__extensions'))
|
||||
->where($db->quoteName('element') . ' = ' . $db->quote($this->alias));
|
||||
|
||||
$db->setQuery($query);
|
||||
$pluginInfo = $db->loadObject();
|
||||
|
||||
if (!isset($pluginInfo->ordering) || $pluginInfo->ordering > $maxOrder)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the new plugin order
|
||||
$object = new stdClass();
|
||||
$object->extension_id = $pluginInfo->extension_id;
|
||||
$object->ordering = ($maxOrder + 1);
|
||||
|
||||
try {
|
||||
$db->updateObject('#__extensions', $object, 'extension_id');
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
23
plugins/fields/acfmap/script.install.php
Normal file
23
plugins/fields/acfmap/script.install.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Advanced Custom Fields
|
||||
* @version 2.8.8 Pro
|
||||
*
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2019 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
require_once __DIR__ . '/script.install.helper.php';
|
||||
|
||||
class PlgFieldsACFMapInstallerScript extends PlgFieldsACFMapInstallerScriptHelper
|
||||
{
|
||||
public $alias = 'acfmap';
|
||||
public $extension_type = 'plugin';
|
||||
public $plugin_folder = "fields";
|
||||
public $show_message = false;
|
||||
}
|
||||
62
plugins/fields/acfmap/tmpl/acfmap.php
Normal file
62
plugins/fields/acfmap/tmpl/acfmap.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Advanced Custom Fields
|
||||
* @version 2.8.8 Pro
|
||||
*
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2019 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
if (!$markers = $field->value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_string($markers) && !$markers = json_decode($markers, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get Plugin Params
|
||||
$plugin = PluginHelper::getPlugin('fields', 'acfmap');
|
||||
$params = new Registry($plugin->params);
|
||||
|
||||
// Find provider
|
||||
$provider = $fieldParams->get('provider', 'OpenStreetMap');
|
||||
$provider_key = $params->get(strtolower($provider) . '_key');
|
||||
$maptype = $fieldParams->get(strtolower($provider) . '_maptype');
|
||||
|
||||
$maptype = is_null($maptype) ? ($provider === 'GoogleMap' ? 'roadmap' : 'road') : $maptype;
|
||||
|
||||
$payload = $fieldParams->flatten();
|
||||
$payload = array_merge($payload, [
|
||||
'replaceSmartTags' => true,
|
||||
'provider_key' => $provider_key,
|
||||
'width' => $fieldParams->get('width_control.width'),
|
||||
'height' => $fieldParams->get('height_control.height'),
|
||||
'markers' => $markers,
|
||||
'map_center' => $fieldParams->get('map_center.coordinates'),
|
||||
'enable_info_window' => $fieldParams->get('enable_info_window', '0') !== '0' ? $fieldParams->get('enable_info_window', '0') : false,
|
||||
|
||||
|
||||
'pro' => true,
|
||||
'view' => $maptype,
|
||||
'scale' => $fieldParams->get('scale', '0') !== '0' ? $fieldParams->get('scale', '0') : false
|
||||
|
||||
]);
|
||||
|
||||
// Set custom layout
|
||||
if ($field->params->get('acf_layout_override'))
|
||||
{
|
||||
$payload['layout'] = $field->params->get('acf_layout_override');
|
||||
}
|
||||
|
||||
echo \NRFramework\Widgets\Helper::render($provider, $payload);
|
||||
16
plugins/fields/acfmap/version.php
Normal file
16
plugins/fields/acfmap/version.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Advanced Custom Fields
|
||||
* @version 2.8.8 Pro
|
||||
*
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2019 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted Access');
|
||||
$NR_PRO = "1";
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user