This commit is contained in:
2024-12-31 11:07:09 +01:00
parent df7915205d
commit e089172b15
1916 changed files with 165422 additions and 271 deletions

View File

@ -0,0 +1,236 @@
<?php
/**
* @package Advanced Custom Fields
* @version 2.8.8 Pro
*
* @author Tassos Marinos <info@tassos.gr>
* @link http://www.tassos.gr
* @copyright Copyright © 2020 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\HTML\HTMLHelper;
use NRFramework\Countries;
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 PlgFieldsACFTelephone extends ACF_Field
{
/**
* Field's Class
*
* @var string
*/
protected $class = 'input-xlarge w-100';
/**
* Field's Hint Description
*
* @var string
*/
protected $hint = '+123 456 789';
/**
* 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)
{
$value = $option->getValue();
if (is_string($value) && json_decode($value, true))
{
$value = json_decode($value, true);
}
if (is_array($value))
{
$countryCode = isset($value['code']) ? $value['code'] : '';
$phoneNumber = isset($value['value']) ? $value['value'] : '';
if ($phoneNumber)
{
$calling_code = Countries::getCallingCodeByCountryCode($countryCode);
$calling_code = $calling_code !== '' ? '+' . $calling_code : '';
$value = $calling_code . $phoneNumber;
}
else
{
$value = '';
}
}
$option->setLabel($value);
}
return $options;
}
/**
* 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;
}
$inputmask = $field->fieldparams->get('tel_mask', '');
// Set custom class and type
$fieldNode->setAttribute('class', $this->class);
$fieldNode->setAttribute('type', 'tftel');
// Get the Input Mask entered on Field settings
$fieldNode->setAttribute('inputmask', $inputmask);
$fieldValue = isset($field->value) ? $field->value : $field->default_value;
$fieldValue = json_decode($fieldValue, true) ? json_decode($fieldValue, true) : $fieldValue;
$countryCodeSelectorEnabled = $field->fieldparams->get('enable_country_selector', '0') === '1';
/**
* This is required the first the field has enabled Country Code Selector,
* and the field was previously just a phone number (saved as string -- without having selected a country code).
*
* We make it required so that the user is forced to select a country code.
*/
if ($countryCodeSelectorEnabled && is_scalar($fieldValue) && !empty($fieldValue))
{
$fieldNode->setAttribute('required', true);
}
$fieldValue = is_array($fieldValue) && isset($fieldValue['value']) ? $fieldValue['value'] : $fieldValue;
if ($countryCodeSelectorEnabled)
{
$fieldNode->setAttribute('type', 'TFPhoneControl');
$fieldNode->setAttribute('class', $this->class . ' form-control');
$default_country_option = $field->fieldparams->get('default_country_option', 'detect');
$code = '';
switch ($default_country_option)
{
case 'custom':
$code = $field->fieldparams->get('default_country_custom', '');
break;
case 'detect':
$code = \NRFramework\Helpers\Geo::getVisitorCountryCode();
break;
default:
$code = $field->fieldparams->get('default_country', '');
break;
}
$fieldNode->setAttribute('default', json_encode([
'code' => $code ? strtoupper($code) : '',
'value' => $fieldValue
]));
}
// Load input mask script
if ($inputmask)
{
if (!$countryCodeSelectorEnabled)
{
$fieldNode->setAttribute('class', 'acf-input-mask');
}
$fieldNode->setAttribute('input_class', 'acf-input-mask');
$fieldNode->setAttribute('data-imask', $inputmask);
HTMLHelper::script('plg_system_nrframework/vendor/inputmask.min.js', ['relative' => true, 'version' => 'auto']);
HTMLHelper::script('plg_fields_acftelephone/script.js', ['relative' => true, 'version' => 'auto']);
}
return $fieldNode;
}
/**
* Prepares the field value for the (front-end) layout
*
* @param string $context The context.
* @param stdclass $item The item.
* @param stdclass $field The field.
*
* @return string
*/
public function onCustomFieldsPrepareField($context, $item, $field)
{
// Check if the field should be processed by us
if (!$this->isTypeSupported($field->type))
{
return parent::onCustomFieldsPrepareField($context, $item, $field);
}
$value = $field->value;
if (is_string($value) && json_decode($value, true))
{
$value = json_decode($value, true);
}
if (is_array($value))
{
$countryCode = isset($value['code']) ? $value['code'] : '';
$phoneNumber = isset($value['value']) ? $value['value'] : '';
if ($phoneNumber)
{
$calling_code = Countries::getCallingCodeByCountryCode($countryCode);
$calling_code = $calling_code !== '' ? '+' . $calling_code : '';
$value = $calling_code . $phoneNumber;
}
else
{
$value = '';
}
}
$field->value = $value;
return parent::onCustomFieldsPrepareField($context, $item, $field);
}
}

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<extension type="plugin" version="3.7.0" group="fields" method="upgrade">
<name>ACF_TELEPHONE</name>
<description>ACF_TELEPHONE_DESC</description>
<author>Tassos Marinos</author>
<creationDate>October 2018</creationDate>
<copyright>Copyright (C) 2019 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="acftelephone">acftelephone.php</filename>
<filename>script.install.helper.php</filename>
<filename>version.php</filename>
<folder>language</folder>
<folder>params</folder>
<folder>tmpl</folder>
</files>
<media folder="media" destination="plg_fields_acftelephone">
<folder>js</folder>
</media>
</extension>

View File

@ -0,0 +1,26 @@
; @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_ACFTELEPHONE_LABEL="ACF - Telephone"
ACF_TELEPHONE="Fields - ACF Telephone"
ACF_TELEPHONE_DESC="Ensure a valid telephone number in a predefined format in the back-end and display it in the front-end."
ACF_TELEPHONE_VALUE_DESC="Enter a Telephone Number."
ACF_TELEPHONE_MASK="Telephone Mask"
ACF_TELEPHONE_MASK_DESC="Help user with the input by ensuring a predefined format. <br><br><b>Syntax:</b><br>9: Numeric (0-9)<br>a: Alphabetical (a-z or A-Z)<br>A: Uppercase alphabetical (A-Z)<br>*: Alphanumeric (0-9, a-z, or A-Z)<br>&: Uppercase alphanumeric (0-9 or A-Z)<br><br><b>Examples</b>:<br>Phone: +1 (999)-9999<br>Date: 99/99/9999<br>Zip Code: 99999?-9999"
ACF_TELEPHONE_CLICK_TO_CALL="Click-to-Call Link"
ACF_TELEPHONE_CLICK_TO_CALL_DESC="Enable to create a clickable telephone link for your users."
ACF_TELEPHONE_DISPLAY_COUNTRY_CODE_SELECTOR="Display Country Code Selector"
ACF_TELEPHONE_DISPLAY_COUNTRY_CODE_SELECTOR_DESC="Enable to display a country code selector where users can select their country and display its calling code."
ACF_TELEPHONE_COUNTRY_CODE="Country Code"
ACF_TELEPHONE_COUNTRY_CODE_DESC="Enter a 2-letter ISO 3166 country code. Eg: GR or US"
ACF_TELEPHONE_DEFAULT_COUNTRY_CODE="Default Country Code"
ACF_TELEPHONE_DEFAULT_COUNTRY_CODE_DESC="Select whether the default country code will be automatically detected by the visitor's location or a custom country will be used.<br><br><strong>Detect Visitor Country</strong> requires the TGeoIP plugin to be installed."
ACF_TELEPHONE_SELECT_COUNTRY="Select Country"
ACF_TELEPHONE_SELECT_COUNTRY_DESC="Select which will be the default country on the country code selector."
ACF_TELEPHONE_SET_COUNTRY_CODE="Set Country Code"
ACF_TELEPHONE_FIELD_COUNTRY_DETECT="Detect Visitor Country"
ACF_TELEPHONE_FIELD_COUNTRY_DETECT_DESC="If enabled, the field will try to detect and prefill the visitor's country. Requires the TGeoIP plugin to be installed."

View File

@ -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_TELEPHONE="Fields - ACF Telephone"
ACF_TELEPHONE_DESC="Ensure a valid telephone number in a predefined format in the back-end and display it in the front-end."

View File

@ -0,0 +1,26 @@
; @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_ACFTELEPHONE_LABEL="ACF - Teléfono"
ACF_TELEPHONE="Campos - ACF Teléfono"
ACF_TELEPHONE_DESC="Asegure un número de teléfono válido en un formato predefinido en el back-end y muéstrelo en el front-end."
ACF_TELEPHONE_VALUE_DESC="Introduzca un Número de Teléfono"
ACF_TELEPHONE_MASK="Máscara de Teléfono"
ACF_TELEPHONE_MASK_DESC="Ayude al usuario con la entrada asegurando un formato predefinido. <br><br><b>Sintaxis:</b><br>9: Numérico (0-9)<br>a: Alfabético (a-z o A-Z)<br>A: Mayúsculas alfabéticas (A-Z)<br>*: Alfanumérico (0-9, a-z, o A-Z)<br>&: Mayúsculas alfanuméricas (0-9 o A-Z)<br><br><b>Ejemplos</b>:<br>Teléfono: +1 (999)-9999<br>Fecha: 99/99/9999<br>Código Postal: 99999?-9999"
ACF_TELEPHONE_CLICK_TO_CALL="Enlace de Clic para llamar"
ACF_TELEPHONE_CLICK_TO_CALL_DESC="Habilite esta opción para crear un enlace telefónico en el que se pueda hacer clic para sus usuarios."
ACF_TELEPHONE_DISPLAY_COUNTRY_CODE_SELECTOR="Mostrar selector de código de país"
ACF_TELEPHONE_DISPLAY_COUNTRY_CODE_SELECTOR_DESC="Habilite para mostrar un selector de código de país donde los usuarios pueden seleccionar su país y mostrar su código de llamada."
ACF_TELEPHONE_COUNTRY_CODE="Código de país"
ACF_TELEPHONE_COUNTRY_CODE_DESC="Ingrese un código de país ISO 3166 de 2 letras. Por ejemplo: GR, US o ES"
ACF_TELEPHONE_DEFAULT_COUNTRY_CODE="Código de país predeterminado"
ACF_TELEPHONE_DEFAULT_COUNTRY_CODE_DESC="Seleccione si el código de país predeterminado será detectado automáticamente por la ubicación del visitante o si se utilizará un país personalizado. <br><br><strong>Detectar país del visitante</strong> requiere que esté instalado el complemento TGeoIP."
ACF_TELEPHONE_SELECT_COUNTRY="Seleccionar país"
ACF_TELEPHONE_SELECT_COUNTRY_DESC="Seleccione cuál será el país predeterminado en el selector de código de país."
ACF_TELEPHONE_SET_COUNTRY_CODE="Establecer código de país"
ACF_TELEPHONE_FIELD_COUNTRY_DETECT="Detectar país del visitante"
ACF_TELEPHONE_FIELD_COUNTRY_DETECT_DESC="Si está habilitado, el campo intentará detectar y completar previamente el país del visitante. Requiere la instalación del complemento TGeoIP."

View File

@ -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_TELEPHONE="Campos - ACF Teléfono"
ACF_TELEPHONE_DESC="Asegure un número de teléfono válido en un formato predefinido en el back-end y muéstrelo en el front-end."

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="fieldparams">
<fieldset name="fieldparams">
<field name="enable_country_selector" type="nrtoggle"
label="ACF_TELEPHONE_DISPLAY_COUNTRY_CODE_SELECTOR"
description="ACF_TELEPHONE_DISPLAY_COUNTRY_CODE_SELECTOR_DESC"
/>
<field name="default_country_option" type="list"
label="ACF_TELEPHONE_DEFAULT_COUNTRY_CODE"
description="ACF_TELEPHONE_DEFAULT_COUNTRY_CODE_DESC"
showon="enable_country_selector:1"
default="detect">
<option value="detect">ACF_TELEPHONE_FIELD_COUNTRY_DETECT</option>
<option value="select">ACF_TELEPHONE_SELECT_COUNTRY</option>
<option value="custom">ACF_TELEPHONE_SET_COUNTRY_CODE</option>
</field>
<field name="default_country" type="NR_Geo"
label="ACF_TELEPHONE_SELECT_COUNTRY"
description="ACF_TELEPHONE_SELECT_COUNTRY_DESC"
showon="enable_country_selector:1[AND]default_country_option:select"
/>
<field name="default_country_custom" type="text"
label="ACF_TELEPHONE_COUNTRY_CODE"
description="ACF_TELEPHONE_COUNTRY_CODE_DESC"
hint="GR"
showon="enable_country_selector:1[AND]default_country_option:custom"
/>
<field name="tel_mask" type="text"
label="ACF_TELEPHONE_MASK"
description="ACF_TELEPHONE_MASK_DESC"
hint="(999) 999-9999"
/>
<field name="click_to_call" type="nrtoggle"
label="ACF_TELEPHONE_CLICK_TO_CALL"
description="ACF_TELEPHONE_CLICK_TO_CALL_DESC"
checked="true"
/>
</fieldset>
</fields>
</form>

View 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 PlgFieldsAcftelephoneInstallerScriptHelper
{
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();
}
}
}

View 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 PlgFieldsACFTelephoneInstallerScript extends PlgFieldsACFTelephoneInstallerScriptHelper
{
public $alias = 'acftelephone';
public $extension_type = 'plugin';
public $plugin_folder = "fields";
public $show_message = false;
}

View File

@ -0,0 +1,36 @@
<?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;
if (!$telephone = htmlentities($field->value, ENT_COMPAT, 'UTF-8'))
{
return;
}
// Remove underscores
$telephone = str_replace('_', '', $telephone);
$click_to_call = (bool) $fieldParams->get('click_to_call', true);
$buffer = $telephone;
// Output
if ($click_to_call)
{
// Remove hyphens
$telephoneCode = str_replace('-', '', $telephone);
$buffer = '<a href="tel:' . $telephoneCode . '">' . $telephone . '</a>';
}
echo $buffer;

View 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";
?>