acf
This commit is contained in:
64
plugins/fields/acfaddress/acfaddress.php
Normal file
64
plugins/fields/acfaddress/acfaddress.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?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;
|
||||
|
||||
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 PlgFieldsACFAddress extends ACF_Field
|
||||
{
|
||||
/**
|
||||
* Update the label of the field in filters.
|
||||
*
|
||||
* @param \Bluecoder\Component\Jfilters\Administrator\Model\Filter\Option\Collection $options
|
||||
*
|
||||
* @return \Bluecoder\Component\Jfilters\Administrator\Model\Filter\Option\Collection
|
||||
*/
|
||||
public function onJFiltersOptionsAfterCreation(\Bluecoder\Component\Jfilters\Administrator\Model\Filter\Option\Collection $options)
|
||||
{
|
||||
// Make sure it is a field of that type
|
||||
if ($options->getFilterItem()->getAttributes()->get('type') !== $this->_name)
|
||||
{
|
||||
return $options;
|
||||
}
|
||||
|
||||
foreach ($options as $option)
|
||||
{
|
||||
$data = $option->getData();
|
||||
$data = is_string($data->value) && json_decode($data->value, true) ? json_decode($data->value, true) : false;
|
||||
|
||||
if (!$data)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$address = isset($data['address']['address']) ? $data['address']['address'] : '';
|
||||
|
||||
if (!$address)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$option->setLabel($address);
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
25
plugins/fields/acfaddress/acfaddress.xml
Normal file
25
plugins/fields/acfaddress/acfaddress.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<extension type="plugin" version="3.7.0" group="fields" method="upgrade">
|
||||
<name>ACF_ADDRESS</name>
|
||||
<description>ACF_ADDRESS_DESC</description>
|
||||
<author>Tassos Marinos</author>
|
||||
<creationDate>December 2022</creationDate>
|
||||
<copyright>Copyright (C) 2022 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="acfaddress">acfaddress.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>
|
||||
<media folder="media" destination="plg_fields_acfaddress">
|
||||
<folder>img</folder>
|
||||
</media>
|
||||
</extension>
|
||||
63
plugins/fields/acfaddress/fields/acfaddress.php
Normal file
63
plugins/fields/acfaddress/fields/acfaddress.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?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\TextField;
|
||||
|
||||
class JFormFieldACFAddress extends TextField
|
||||
{
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*/
|
||||
public function getInput()
|
||||
{
|
||||
// Setup properties
|
||||
$zoom = $this->element['zoom'] ? (int) $this->element['zoom'] : 4;
|
||||
$marker_image = !empty($this->element['marker_image']) ? (string) $this->element['marker_image'] : null;
|
||||
$value = is_string($this->value) ? (json_decode($this->value) ? json_decode($this->value, true) : null) : json_decode(json_encode($this->value), true);
|
||||
$address = isset($value['address']) ? $value['address'] : [];
|
||||
$show_map = (string) $this->element['show_map'];
|
||||
$autocomplete = (string) $this->element['autocomplete'];
|
||||
$coordinates = '';
|
||||
|
||||
if (isset($address['latitude']) && !empty($address['latitude']) && isset($address['longitude']) && !empty($address['longitude']))
|
||||
{
|
||||
$coordinates = $address['latitude'] . ',' . $address['longitude'];
|
||||
}
|
||||
|
||||
$payload = [
|
||||
'width' => 600,
|
||||
'height' => 400,
|
||||
'required' => $this->required,
|
||||
'name' => $this->name,
|
||||
'id' => $this->id,
|
||||
'zoom' => $zoom,
|
||||
'markerImage' => $marker_image,
|
||||
'show_map' => $show_map === '0' ? false : $show_map,
|
||||
'autocomplete' => $autocomplete === '1',
|
||||
'value' => $coordinates,
|
||||
'address' => $address
|
||||
];
|
||||
|
||||
$showAddressDetails = isset($this->element['address_details_info']) ? (string) $this->element['address_details_info'] : false;
|
||||
if ($showAddressDetails)
|
||||
{
|
||||
// Make it an array
|
||||
$showAddressDetails = array_map('trim', explode(',', $showAddressDetails));
|
||||
// Set all values of each array key to true
|
||||
$showAddressDetails = array_fill_keys($showAddressDetails, true);
|
||||
$payload['_showAddressDetails'] = $showAddressDetails;
|
||||
}
|
||||
|
||||
return \NRFramework\Widgets\Helper::render('MapAddressEditor', $payload);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
; @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_ACFADDRESS_LABEL="ACF - Adressen Autovervollständigung"
|
||||
ACF_ADDRESS="Fields - ACF Adressen Autovervollständigung"
|
||||
ACF_ADDRESS_DESC="Zeigt eine Karte mit den Standortdetails wie Adresse, Stadt, Bundesland, Land usw. an."
|
||||
ACF_ADDRESS_VALUE_DESC="Wählen Sie einen Ort auf der Karte, geben Sie eine Adresse oder Koordinaten in das Suchfeld ein."
|
||||
ACF_ADDRESS_ZOOM="Zoom"
|
||||
ACF_ADDRESS_ZOOM_DESC="Zoom-Stufe einstellen"
|
||||
ACF_ADDRESS_WIDTH="Breite"
|
||||
ACF_ADDRESS_WIDTH_DESC=""
|
||||
ACF_ADDRESS_HEIGHT="Höhe"
|
||||
ACF_ADDRESS_HEIGHT_DESC=""
|
||||
ACF_ADDRESS_ADDRESS="Adresse"
|
||||
ACF_ADDRESS_ADDRESS_DESC="Eine Adresse oder Koordinaten für die Suche eingeben"
|
||||
ACF_ADDRESS_SHOW_MAP="Zeige Karte"
|
||||
ACF_ADDRESS_SHOW_MAP_DESC="Festlegen, ob und wo die Karte angezeigt werden soll.<br><br><strong>Backend</strong>: Zeigt Sie die Karte nur an, wenn das Feld in einem Artikel, Kontakt usw. bearbeiten wurde...<br><strong>Frontend</strong>: Zeigt die Karte nur an, wenn das Feld im Frontend Ihrer Website anzeigt wird, z. B. in einem Artikel, Kontakt usw....<br><strong>Beide</strong>: Zeigt die Karte sowohl bei der Bearbeitung des benutzerdefinierten Feldes in einem Artikel, Kontakt usw. als auch bei der Anzeige des Feldes im Frontend Ihrer Website an, z. B. beim Anzeigen eines Artikels."
|
||||
ACF_ADDRESS_MARKER_IMAGE="Marker Bild"
|
||||
ACF_ADDRESS_MARKER_IMAGE_DESC="Ersetzt Sie den Standard-Marker durch ein Bild Ihrer Wahl."
|
||||
ACF_ADDRESS_DETAILS_LAYOUT="Layout"
|
||||
ACF_ADDRESS_DETAILS_LAYOUT_DESC="Wählen Sie das zu verwendende Layout, Standard oder benutzerdefiniert.<br><br><strong>Standard:</strong> Die Karte und darunter alle ausgewählten Adressdetails anzeigen.<br><strong>Benutzerdefiniert:</strong> Verwenden Sie Smart Tags, um ein benutzerdefiniertes Layout anzuzeigen. Unterstützt auch HTML-Code."
|
||||
ACF_ADDRESS_MAP_LOCATION="Standort"
|
||||
ACF_ADDRESS_MAP_LOCATION_DESC="Legt fest, ob die Karte über oder unter den Adressdetails angezeigt werden soll."
|
||||
ACF_ADDRESS_ABOVE="über der Adresse"
|
||||
ACF_ADDRESS_BELOW="unter der Adresse"
|
||||
ACF_ADDRESS_DETAILS_CUSTOM="Benutzerdefiniertes Layout"
|
||||
ACF_ADDRESS_DETAILS_CUSTOM_DESC="Legen Sie das benutzerdefinierte Layout für die Adressdetails fest. Unterstützt auch HTML-Code. <br><br>Erlaubte Smart Tags:<br>{address.map}<br>{address.address} - {address.address.label}<br>{address.latitude} - {address.latitude.label}<br>{address.longitude} - {address.longitude.label}<br>{address.country} - {address.country.label}<br>{address.country_code} - {address.country_code.label}<br>{address.city} - {address.city.label}<br>{address.county} - {address.county.label}<br>{address.postal_code} - {address.postal_code.label}<br>{address.state} - {address.state.label}<br>{address.municipality} - {address.municipality.label}<br>{address.town} - {address.town.label}<br>{address.road} - {address.road.label}"
|
||||
ACF_ADDRESS_DETAILS_INFO="Adressdetails"
|
||||
ACF_ADDRESS_DETAILS_INFO_DESC="Legen Sie fest, welche Adressdetails angezeigt werden sollen."
|
||||
ACF_ADDRESS_AUTOCOMPLETE="Adress-Autovervollständigung"
|
||||
ACF_ADDRESS_AUTOCOMPLETE_DESC="Legen Sie fest, ob die automatische Vervollständigung von Adressen aktiviert werden soll und ob bei der Eingabe einer Adresse automatisch Orte vorgeschlagen werden sollen."
|
||||
@ -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_ADDRESS="Felder – Automatische Vervollständigung der ACF-Adresse"
|
||||
ACF_ADDRESS_DESC="Zeigen Sie eine Karte an mit Standortdetails wie Adresse, Stadt, Bundesland, Land, etc.."
|
||||
@ -0,0 +1,35 @@
|
||||
; @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_ACFADDRESS_LABEL="ACF - Address Autocomplete"
|
||||
; ACF_ADDRESS="Fields - ACF Address Autocomplete"
|
||||
; ACF_ADDRESS_DESC="Display a map with the location details such as address, city, state, country, etc..."
|
||||
; ACF_ADDRESS_VALUE_DESC="Pick a location from the map, enter an address or coordinates in the search field."
|
||||
; ACF_ADDRESS_ZOOM="Zoom"
|
||||
; ACF_ADDRESS_ZOOM_DESC="Set the map zoom."
|
||||
ACF_ADDRESS_WIDTH="Μήκος"
|
||||
ACF_ADDRESS_WIDTH_DESC=""
|
||||
ACF_ADDRESS_HEIGHT="Ύψος"
|
||||
ACF_ADDRESS_HEIGHT_DESC=""
|
||||
ACF_ADDRESS_ADDRESS="Διέθυνση"
|
||||
; ACF_ADDRESS_ADDRESS_DESC="Enter an address or coordinates to search"
|
||||
ACF_ADDRESS_SHOW_MAP="Εμφάνιση Χάρτη"
|
||||
; ACF_ADDRESS_SHOW_MAP_DESC="Set whether and where to show the map.<br><br><strong>Back-end</strong>: Show the map only when editing the field in an article, contact, etc...<br><strong>Front-end</strong>: Show the map only when viewing the field on the front-end of your site such as in an article, contact, etc...<br><strong>Both</strong>: Show the map both when editing the custom field in an article, contact, etc... as well as when viewing the field on the front-end of your site such as when viewing an article."
|
||||
; ACF_ADDRESS_MARKER_IMAGE="Marker Image"
|
||||
; ACF_ADDRESS_MARKER_IMAGE_DESC="Replace the default marker image by uploading an image of your choice."
|
||||
; ACF_ADDRESS_DETAILS_LAYOUT="Layout"
|
||||
; ACF_ADDRESS_DETAILS_LAYOUT_DESC="Select which layout to use, default or custom.<br><br><strong>Default:</strong> Show a map and below all selected address details.<br><strong>Custom:</strong> Use Smart Tags to display a custom layout. Also supports HTML code."
|
||||
; ACF_ADDRESS_MAP_LOCATION="Map Location"
|
||||
; ACF_ADDRESS_MAP_LOCATION_DESC="Set whether to display the map above or below the address details."
|
||||
; ACF_ADDRESS_ABOVE="Above Address"
|
||||
; ACF_ADDRESS_BELOW="Below Address"
|
||||
; ACF_ADDRESS_DETAILS_CUSTOM="Custom Layout"
|
||||
; ACF_ADDRESS_DETAILS_CUSTOM_DESC="Set the Custom Layout for the address details. Also supports HTML code.<br><br>Allowed Smart Tags:<br>{address.map}<br>{address.address} - {address.address.label}<br>{address.latitude} - {address.latitude.label}<br>{address.longitude} - {address.longitude.label}<br>{address.country} - {address.country.label}<br>{address.country_code} - {address.country_code.label}<br>{address.city} - {address.city.label}<br>{address.county} - {address.county.label}<br>{address.postal_code} - {address.postal_code.label}<br>{address.state} - {address.state.label}<br>{address.municipality} - {address.municipality.label}<br>{address.town} - {address.town.label}<br>{address.road} - {address.road.label}"
|
||||
; ACF_ADDRESS_DETAILS_INFO="Address Details"
|
||||
; ACF_ADDRESS_DETAILS_INFO_DESC="Set which address details to show."
|
||||
; ACF_ADDRESS_AUTOCOMPLETE="Address Autocomplete"
|
||||
; ACF_ADDRESS_AUTOCOMPLETE_DESC="Set whether to enable address autocomplete and automatically suggest places as you type an address."
|
||||
@ -0,0 +1,35 @@
|
||||
; @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_ACFADDRESS_LABEL="ACF - Address Autocomplete"
|
||||
ACF_ADDRESS="Fields - ACF Address Autocomplete"
|
||||
ACF_ADDRESS_DESC="Display a map with the location details such as address, city, state, country, etc..."
|
||||
ACF_ADDRESS_VALUE_DESC="Pick a location from the map, enter an address or coordinates in the search field."
|
||||
ACF_ADDRESS_ZOOM="Zoom"
|
||||
ACF_ADDRESS_ZOOM_DESC="Set the map zoom."
|
||||
ACF_ADDRESS_WIDTH="Width"
|
||||
ACF_ADDRESS_WIDTH_DESC=""
|
||||
ACF_ADDRESS_HEIGHT="Height"
|
||||
ACF_ADDRESS_HEIGHT_DESC=""
|
||||
ACF_ADDRESS_ADDRESS="Address"
|
||||
ACF_ADDRESS_ADDRESS_DESC="Enter an address or coordinates to search"
|
||||
ACF_ADDRESS_SHOW_MAP="Show Map"
|
||||
ACF_ADDRESS_SHOW_MAP_DESC="Set whether and where to show the map.<br /><br /><strong>Back-end</strong>: Show the map only when editing the field in an article, contact, etc...<br /><strong>Front-end</strong>: Show the map only when viewing the field on the front-end of your site such as in an article, contact, etc...<br /><strong>Both</strong>: Show the map both when editing the custom field in an article, contact, etc... as well as when viewing the field on the front-end of your site such as when viewing an article."
|
||||
ACF_ADDRESS_MARKER_IMAGE="Marker Image"
|
||||
ACF_ADDRESS_MARKER_IMAGE_DESC="Replace the default marker image by uploading an image of your choice."
|
||||
ACF_ADDRESS_DETAILS_LAYOUT="Layout"
|
||||
ACF_ADDRESS_DETAILS_LAYOUT_DESC="Select which layout to use, default or custom.<br /><br /><strong>Default:</strong> Show a map and below all selected address details.<br /><strong>Custom:</strong> Use Smart Tags to display a custom layout. Also supports HTML code."
|
||||
ACF_ADDRESS_MAP_LOCATION="Map Location"
|
||||
ACF_ADDRESS_MAP_LOCATION_DESC="Set whether to display the map above or below the address details."
|
||||
ACF_ADDRESS_ABOVE="Above Address"
|
||||
ACF_ADDRESS_BELOW="Below Address"
|
||||
ACF_ADDRESS_DETAILS_CUSTOM="Custom Layout"
|
||||
ACF_ADDRESS_DETAILS_CUSTOM_DESC="Set the Custom Layout for the address details. Also supports HTML code.<br /><br />Allowed Smart Tags:<br />{address.map}<br />{address.address} - {address.address.label}<br />{address.latitude} - {address.latitude.label}<br />{address.longitude} - {address.longitude.label}<br />{address.country} - {address.country.label}<br />{address.country_code} - {address.country_code.label}<br />{address.city} - {address.city.label}<br />{address.county} - {address.county.label}<br />{address.postal_code} - {address.postal_code.label}<br />{address.state} - {address.state.label}<br />{address.municipality} - {address.municipality.label}<br />{address.town} - {address.town.label}<br />{address.road} - {address.road.label}"
|
||||
ACF_ADDRESS_DETAILS_INFO="Address Details"
|
||||
ACF_ADDRESS_DETAILS_INFO_DESC="Set which address details to show."
|
||||
ACF_ADDRESS_AUTOCOMPLETE="Enable Autocomplete"
|
||||
ACF_ADDRESS_AUTOCOMPLETE_DESC="Set whether to enable address autocomplete and automatically suggest places as you type an address."
|
||||
@ -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_ADDRESS="Fields - ACF Address Autocomplete"
|
||||
ACF_ADDRESS_DESC="Display a map with the location details such as address, city, state, country, etc..."
|
||||
@ -0,0 +1,35 @@
|
||||
; @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_ACFADDRESS_LABEL="ACF - Dirección Autocompletar"
|
||||
ACF_ADDRESS="Campos - ACF Dirección Autocompletar"
|
||||
ACF_ADDRESS_DESC="Muestra un mapa con los detalles de la ubicación, como dirección, ciudad, estado, país, etc."
|
||||
ACF_ADDRESS_VALUE_DESC="Elija una ubicación del mapa, ingrese una dirección o coordenadas en el campo de búsqueda."
|
||||
ACF_ADDRESS_ZOOM="Zoom"
|
||||
ACF_ADDRESS_ZOOM_DESC="Establezca el zoom del mapa."
|
||||
ACF_ADDRESS_WIDTH="Ancho"
|
||||
ACF_ADDRESS_WIDTH_DESC=""
|
||||
ACF_ADDRESS_HEIGHT="Altura"
|
||||
ACF_ADDRESS_HEIGHT_DESC=""
|
||||
ACF_ADDRESS_ADDRESS="Dirección"
|
||||
ACF_ADDRESS_ADDRESS_DESC="Introduzca una dirección o coordenadas para buscar"
|
||||
ACF_ADDRESS_SHOW_MAP="Mostrar Mapa"
|
||||
ACF_ADDRESS_SHOW_MAP_DESC="Establezca si mostrar el mapa y dónde.<br><br><strong>Back-end</strong>:Mostrar el mapa solo al editar el campo en un artículo, contacto, etc...<br><strong>Front-end</strong>:Muestre el mapa solo cuando vea el campo en el front-end de su sitio, como en un artículo, contacto, etc.<br><strong>Both</strong>: Muestre el mapa tanto cuando edite el campo personalizado en un artículo, contacto, etc... como cuando vea el campo en el front-end de su sitio, como cuando vea un artículo."
|
||||
ACF_ADDRESS_MARKER_IMAGE="Imagen de Marcador"
|
||||
ACF_ADDRESS_MARKER_IMAGE_DESC="Reemplace la imagen del marcador predeterminado cargando una imagen de su elección."
|
||||
ACF_ADDRESS_DETAILS_LAYOUT="Disposición"
|
||||
ACF_ADDRESS_DETAILS_LAYOUT_DESC="Seleccione qué diseño usar, predeterminado o personalizado.<br><br><strong>Defecto:</strong> Muestra un mapa y debajo todos los detalles de la dirección seleccionada.<br><strong>Personalizado:</strong> Use etiquetas inteligentes para mostrar un diseño personalizado. También admite código HTML."
|
||||
ACF_ADDRESS_MAP_LOCATION="Ubicación del Mapa"
|
||||
ACF_ADDRESS_MAP_LOCATION_DESC="Establezca si mostrar el mapa encima o debajo de los detalles de la dirección."
|
||||
ACF_ADDRESS_ABOVE="Sobre Dirección"
|
||||
ACF_ADDRESS_BELOW="Bajo Dirección"
|
||||
ACF_ADDRESS_DETAILS_CUSTOM="Diseño personalizado"
|
||||
ACF_ADDRESS_DETAILS_CUSTOM_DESC="Configure el diseño personalizado para los detalles de la dirección. También admite código HTML.<br><br>Etiquetas inteligentes permitidas:<br>{address.map}<br>{address.address} - {address.address.label}<br>{address.latitude} - {address.latitude.label}<br>{address.longitude} - {address.longitude.label}<br>{address.country} - {address.country.label}<br>{address.country_code} - {address.country_code.label}<br>{address.city} - {address.city.label}<br>{address.county} - {address.county.label}<br>{address.postal_code} - {address.postal_code.label}<br>{address.state} - {address.state.label}<br>{address.municipality} - {address.municipality.label}<br>{address.town} - {address.town.label}<br>{address.road} - {address.road.label}"
|
||||
ACF_ADDRESS_DETAILS_INFO="Detalles de Dirección"
|
||||
ACF_ADDRESS_DETAILS_INFO_DESC="Establezca qué detalles de la dirección mostrar."
|
||||
ACF_ADDRESS_AUTOCOMPLETE="Autocompletar Dirección"
|
||||
ACF_ADDRESS_AUTOCOMPLETE_DESC="Establezca si desea habilitar el autocompletado de direcciones y sugerir lugares automáticamente a medida que escribe una dirección."
|
||||
@ -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_ADDRESS="Campos - ACF Dirección Autocompletar"
|
||||
ACF_ADDRESS_DESC="Muestra un mapa con los detalles de la ubicación, como dirección, ciudad, estado, país, etc."
|
||||
101
plugins/fields/acfaddress/params/acfaddress.xml
Normal file
101
plugins/fields/acfaddress/params/acfaddress.xml
Normal file
@ -0,0 +1,101 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form>
|
||||
<fields name="fieldparams">
|
||||
<fieldset name="fieldparams">
|
||||
<field name="address_details_info" type="checkboxes"
|
||||
label="ACF_ADDRESS_DETAILS_INFO"
|
||||
description="ACF_ADDRESS_DETAILS_INFO_DESC"
|
||||
class="nrf-checkboxes-field-columns"
|
||||
default="address,country,city,postal_code"
|
||||
>
|
||||
<option value="address">NR_ADDRESS</option>
|
||||
<option value="country">NR_COUNTRY</option>
|
||||
<option value="city">NR_CITY</option>
|
||||
<option value="postal_code">NR_POSTAL_CODE</option>
|
||||
<option value="latitude">NR_LATITUDE</option>
|
||||
<option value="longitude">NR_LONGITUDE</option>
|
||||
<option value="country_code">NR_COUNTRY_CODE</option>
|
||||
<option value="county">NR_COUNTY</option>
|
||||
<option value="state">NR_STATE</option>
|
||||
<option value="municipality">NR_MUNICIPALITY</option>
|
||||
<option value="town">NR_TOWN</option>
|
||||
<option value="road">NR_ROAD</option>
|
||||
</field>
|
||||
<field name="autocomplete" type="radio"
|
||||
label="ACF_ADDRESS_AUTOCOMPLETE"
|
||||
description="ACF_ADDRESS_AUTOCOMPLETE_DESC"
|
||||
class="btn-group btn-group-yesno"
|
||||
default="1">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="layout_type" type="radio"
|
||||
label="ACF_ADDRESS_DETAILS_LAYOUT"
|
||||
description="ACF_ADDRESS_DETAILS_LAYOUT_DESC"
|
||||
class="btn-group btn-group-yesno"
|
||||
default="default">
|
||||
<option value="default">JDEFAULT</option>
|
||||
<option value="custom">NR_CUSTOM</option>
|
||||
</field>
|
||||
<field name="map_location" type="radio"
|
||||
label="ACF_ADDRESS_MAP_LOCATION"
|
||||
description="ACF_ADDRESS_MAP_LOCATION_DESC"
|
||||
class="btn-group btn-group-yesno"
|
||||
showon="show_map!:0[AND]layout_type:default"
|
||||
default="below">
|
||||
<option value="above">ACF_ADDRESS_ABOVE</option>
|
||||
<option value="below">ACF_ADDRESS_BELOW</option>
|
||||
</field>
|
||||
<field name="custom_layout" type="editor"
|
||||
label="ACF_ADDRESS_DETAILS_CUSTOM"
|
||||
description="ACF_ADDRESS_DETAILS_CUSTOM_DESC"
|
||||
showon="layout_type:custom"
|
||||
editor="codemirror"
|
||||
filter="raw"
|
||||
default="{address.address.label}: {address.address}"
|
||||
/>
|
||||
<field type="spacer" name="label"
|
||||
label="NR_MAP"
|
||||
class="acf"
|
||||
/>
|
||||
<field name="show_map" type="radio"
|
||||
label="ACF_ADDRESS_SHOW_MAP"
|
||||
description="ACF_ADDRESS_SHOW_MAP_DESC"
|
||||
class="btn-group btn-group-yesno"
|
||||
default="0">
|
||||
<option value="0">JNO</option>
|
||||
<option value="backend">NR_BACKEND</option>
|
||||
<option value="frontend">NR_FRONTEND</option>
|
||||
<option value="both">NR_BOTH</option>
|
||||
</field>
|
||||
<field name="width" type="text"
|
||||
label="ACF_ADDRESS_WIDTH"
|
||||
description="ACF_ADDRESS_WIDTH_DESC"
|
||||
default="400px"
|
||||
showon="show_map!:0"
|
||||
/>
|
||||
<field name="height" type="text"
|
||||
label="ACF_ADDRESS_HEIGHT"
|
||||
description="ACF_ADDRESS_HEIGHT_DESC"
|
||||
default="350px"
|
||||
showon="show_map!:0"
|
||||
/>
|
||||
<field name="zoom" type="nrnumber"
|
||||
label="ACF_ADDRESS_ZOOM"
|
||||
description="ACF_ADDRESS_ZOOM_DESC"
|
||||
default="4"
|
||||
min="0"
|
||||
showon="show_map!:0"
|
||||
/>
|
||||
<field name="marker_image" type="media"
|
||||
directory="acfosm"
|
||||
default="media/plg_fields_acfaddress/img/marker.png"
|
||||
preview_width="32"
|
||||
label="ACF_ADDRESS_MARKER_IMAGE"
|
||||
description="ACF_ADDRESS_MARKER_IMAGE_DESC"
|
||||
showon="show_map!:0"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
|
||||
691
plugins/fields/acfaddress/script.install.helper.php
Normal file
691
plugins/fields/acfaddress/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 PlgFieldsAcfaddressInstallerScriptHelper
|
||||
{
|
||||
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/acfaddress/script.install.php
Normal file
23
plugins/fields/acfaddress/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 PlgFieldsACFAddressInstallerScript extends PlgFieldsACFAddressInstallerScriptHelper
|
||||
{
|
||||
public $alias = 'acfaddress';
|
||||
public $extension_type = 'plugin';
|
||||
public $plugin_folder = "fields";
|
||||
public $show_message = false;
|
||||
}
|
||||
33
plugins/fields/acfaddress/tmpl/acfaddress.php
Normal file
33
plugins/fields/acfaddress/tmpl/acfaddress.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?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;
|
||||
|
||||
$value = $field->value;
|
||||
|
||||
if (is_string($value) && !$value = json_decode($value, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$payload = $value + $fieldParams->flatten();
|
||||
$payload['value'] = !empty($payload['address']['latitude']) && !empty($payload['address']['longitude']) ? $payload['address']['latitude'] . ',' . $payload['address']['longitude'] : null;
|
||||
$payload['show_map'] = $payload['show_map'] === '0' ? false : $payload['show_map'];
|
||||
$payload['showAddressDetails'] = $fieldParams->get('address_details_info', []);
|
||||
|
||||
// Set custom layout
|
||||
if ($field->params->get('acf_layout_override'))
|
||||
{
|
||||
$payload['layout'] = $field->params->get('acf_layout_override');
|
||||
}
|
||||
|
||||
echo \NRFramework\Widgets\Helper::render('MapAddress', $payload);
|
||||
16
plugins/fields/acfaddress/version.php
Normal file
16
plugins/fields/acfaddress/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