acf
This commit is contained in:
63
plugins/system/acf/ACF/Helpers/Field.php
Normal file
63
plugins/system/acf/ACF/Helpers/Field.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2023 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
namespace ACF\Helpers;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
class Field
|
||||
{
|
||||
/**
|
||||
* Returns the widget for which the ACF custom field is based upon.
|
||||
*
|
||||
* @param string $type
|
||||
* @param object $field_options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function isWidgetBased($type = '', $field_options = [])
|
||||
{
|
||||
if (!$type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$widget_name = self::getWidgetName($type);
|
||||
|
||||
$widget = \NRFramework\Widgets\Helper::find($widget_name);
|
||||
|
||||
if ($widget === 'Map' && !is_null($field_options->fieldparams))
|
||||
{
|
||||
return !empty($field_options->fieldparams['provider']) ? $field_options->fieldparams['provider'] : $widget;
|
||||
}
|
||||
|
||||
return $widget;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the widget name of an ACF custom field.
|
||||
*
|
||||
* @param string @type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getWidgetName($type = '')
|
||||
{
|
||||
// Remove the "acf" prefix
|
||||
$type = str_replace('acf', '', $type);
|
||||
|
||||
// Map for any ACF fields that do not automatically translate to a Widget
|
||||
$map = [
|
||||
'address' => 'MapAddress'
|
||||
];
|
||||
|
||||
// Transform a field type to its corresponding widget from the map
|
||||
return isset($map[$type]) ? $map[$type] : $type;
|
||||
}
|
||||
}
|
||||
189
plugins/system/acf/ACF/Helpers/Fields/Address.php
Normal file
189
plugins/system/acf/ACF/Helpers/Fields/Address.php
Normal file
@ -0,0 +1,189 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2021 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
namespace ACF\Helpers\Fields;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use YOOtheme\Builder\Joomla\Fields\Type\FieldsType;
|
||||
use YOOtheme\Str;
|
||||
|
||||
class Address
|
||||
{
|
||||
/**
|
||||
* Returns the YooTheme type.
|
||||
*
|
||||
* If this accepts one image:
|
||||
* - Tells YooTheme to use the default type for the dropdown mapping option.
|
||||
*
|
||||
* If this accepts multiple images:
|
||||
* - Tells YooTheme to only return the value of this field in the dropdown mapping option.
|
||||
*
|
||||
* @param object $field
|
||||
* @param object $source
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getYooType($field = [], $source = [])
|
||||
{
|
||||
$fields = [
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'latitude',
|
||||
'metadata' => [
|
||||
'label' => 'Latitude'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'longitude',
|
||||
'metadata' => [
|
||||
'label' => 'Longitude'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'value',
|
||||
'metadata' => [
|
||||
'label' => 'Coordinates'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'address',
|
||||
'metadata' => [
|
||||
'label' => 'Address'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'postal_code',
|
||||
'metadata' => [
|
||||
'label' => 'Postal Code'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'country_code',
|
||||
'metadata' => [
|
||||
'label' => 'Country Code'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'country',
|
||||
'metadata' => [
|
||||
'label' => 'Country'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'state',
|
||||
'metadata' => [
|
||||
'label' => 'State'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'municipality',
|
||||
'metadata' => [
|
||||
'label' => 'Municipality'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'town',
|
||||
'metadata' => [
|
||||
'label' => 'Town'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'city',
|
||||
'metadata' => [
|
||||
'label' => 'City'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'road',
|
||||
'metadata' => [
|
||||
'label' => 'Road'
|
||||
],
|
||||
]
|
||||
];
|
||||
$name = Str::camelCase(['Field', $field->name], true);
|
||||
$source->objectType($name, compact('fields'));
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the field value to an appropriate value that YooTheme can understand.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function yooResolve($item, $args, $ctx, $info)
|
||||
{
|
||||
$name = str_replace('String', '', strtr($info->fieldName, '_', '-'));
|
||||
|
||||
// Check if it's a subform field
|
||||
$subfield = clone \ACF\Helpers\Yoo::getSubfield($args['field_id'], $args['context']);
|
||||
|
||||
// When we have a subform field, the $item is an array of values
|
||||
if (!$subfield || !is_array($item))
|
||||
{
|
||||
if (!isset($item->id) || !($field = FieldsType::getField($name, $item, $args['context'])))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set rawvalue
|
||||
$subfield->rawvalue = isset($item["field{$args['field_id']}"]) ? json_encode($item["field{$args['field_id']}"]) : '';
|
||||
|
||||
// Use the subform field
|
||||
$field = $subfield;
|
||||
}
|
||||
|
||||
$value = $field->rawvalue;
|
||||
|
||||
if (is_string($value))
|
||||
{
|
||||
if (!$value = json_decode($value, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_array($value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$lat = isset($value['address']['latitude']) ? $value['address']['latitude'] : null;
|
||||
$lng = isset($value['address']['longitude']) ? $value['address']['longitude'] : null;
|
||||
|
||||
return [
|
||||
'latitude' => $lat,
|
||||
'longitude' => $lng,
|
||||
'value' => $lat && $lng ? implode(',', [$lat, $lng]) : null,
|
||||
'address' => isset($value['address']['address']) ? $value['address']['address'] : null,
|
||||
'postal_code' => isset($value['address']['postal_code']) ? $value['address']['postal_code'] : null,
|
||||
'country_code' => isset($value['address']['country_code']) ? $value['address']['country_code'] : null,
|
||||
'country' => isset($value['address']['country']) ? $value['address']['country'] : null,
|
||||
'state' => isset($value['address']['state']) ? $value['address']['state'] : null,
|
||||
'municipality' => isset($value['address']['municipality']) ? $value['address']['municipality'] : null,
|
||||
'town' => isset($value['address']['town']) ? $value['address']['town'] : null,
|
||||
'city' => isset($value['address']['city']) ? $value['address']['city'] : null,
|
||||
'road' => isset($value['address']['road']) ? $value['address']['road'] : null
|
||||
];
|
||||
}
|
||||
}
|
||||
172
plugins/system/acf/ACF/Helpers/Fields/Articles.php
Normal file
172
plugins/system/acf/ACF/Helpers/Fields/Articles.php
Normal file
@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2021 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
namespace ACF\Helpers\Fields;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use YOOtheme\Builder\Joomla\Fields\Type\FieldsType;
|
||||
use YOOtheme\Builder\Joomla\Source\ArticleHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
|
||||
class Articles
|
||||
{
|
||||
/**
|
||||
* Returns the YooTheme type.
|
||||
*
|
||||
* If this accepts one image:
|
||||
* - Tells YooTheme to use the default type for the dropdown mapping option.
|
||||
*
|
||||
* If this accepts multiple images:
|
||||
* - Tells YooTheme to only return the value of this field in the dropdown mapping option.
|
||||
*
|
||||
* @param object $field
|
||||
* @param object $source
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getYooType($field = [], $source = [])
|
||||
{
|
||||
if ($field->only_use_in_subform === 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$max_articles = (int) $field->fieldparams->get('max_articles', 0);
|
||||
$multiple = $max_articles === 0 || $max_articles > 1;
|
||||
return $multiple ? ['listOf' => 'Article'] : 'Article';
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the field value to an appropriate value that YooTheme can understand.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function yooResolve($item, $args, $ctx, $info)
|
||||
{
|
||||
$name = str_replace('String', '', strtr($info->fieldName, '_', '-'));
|
||||
|
||||
// Check if it's a subform field
|
||||
$subfield = clone \ACF\Helpers\Yoo::getSubfield($args['field_id'], $args['context']);
|
||||
|
||||
// When we have a subform field, the $item is an array of values
|
||||
if (!$subfield || !is_array($item))
|
||||
{
|
||||
if (!isset($item->id) || !($field = FieldsType::getField($name, $item, $args['context'])))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set rawvalue
|
||||
$subfield->rawvalue = isset($item["field{$args['field_id']}"]) ? $item["field{$args['field_id']}"] : '';
|
||||
|
||||
// Use the subform field
|
||||
$field = $subfield;
|
||||
}
|
||||
|
||||
$ids = $field->rawvalue;
|
||||
|
||||
$max_articles = 0;
|
||||
$multiple = true;
|
||||
|
||||
// Handle Linked Articles
|
||||
$field_type = $field->fieldparams->get('articles_type', 'default');
|
||||
if ($field_type === 'linked')
|
||||
{
|
||||
|
||||
if (in_array($ids, ['1', 'true']))
|
||||
{
|
||||
$ids = self::getLinkedArticlesIDs($item->id, $field);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$max_articles = (int) $field->fieldparams->get('max_articles', 0);
|
||||
$multiple = $max_articles === 0 || $max_articles > 1;
|
||||
}
|
||||
|
||||
if (is_scalar($ids))
|
||||
{
|
||||
$ids = [(int) $ids];
|
||||
}
|
||||
|
||||
if (!is_array($ids))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$value = ArticleHelper::get($ids);
|
||||
|
||||
if ($field->only_use_in_subform === 1)
|
||||
{
|
||||
$data = array_values(array_map(function($article) {
|
||||
return $article->title;
|
||||
}, $value));
|
||||
|
||||
return implode(', ', $data);
|
||||
}
|
||||
|
||||
if ($multiple)
|
||||
{
|
||||
return array_values(array_map(function ($value) {
|
||||
return is_scalar($value) ? compact('value') : $value;
|
||||
}, $value));
|
||||
}
|
||||
else
|
||||
{
|
||||
return array_shift($value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function getLinkedArticlesIDs($item_id = null, $field = [])
|
||||
{
|
||||
if (!$acf_articles = array_filter($field->fieldparams->get('articles_fields', [])))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Grab all linked articles
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query->select('a.id')
|
||||
->from($db->quoteName('#__fields_values', 'fv'))
|
||||
->join('LEFT', $db->quoteName('#__content', 'a') . ' ON a.id = fv.item_id')
|
||||
->where($db->quoteName('fv.field_id') . ' IN (' . implode(',', $acf_articles) . ')')
|
||||
->where($db->quoteName('fv.value') . ' = ' . $db->q($item_id));
|
||||
|
||||
// Filter results
|
||||
require_once JPATH_PLUGINS . '/fields/acfarticles/fields/acfarticlesfilters.php';
|
||||
$payload = $field->fieldparams;
|
||||
$filters = new \ACFArticlesFilters($query, $payload);
|
||||
$query = $filters->apply();
|
||||
|
||||
// Set query
|
||||
$db->setQuery($query);
|
||||
|
||||
// Get articles
|
||||
if (!$articles = $db->loadAssocList())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Return article IDs
|
||||
$articles = array_map(function($article) {
|
||||
return $article['id'];
|
||||
}, $articles);
|
||||
|
||||
return $articles;
|
||||
}
|
||||
|
||||
}
|
||||
93
plugins/system/acf/ACF/Helpers/Fields/Chainedfields.php
Normal file
93
plugins/system/acf/ACF/Helpers/Fields/Chainedfields.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2021 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
namespace ACF\Helpers\Fields;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use YOOtheme\Builder\Joomla\Fields\Type\FieldsType;
|
||||
use YOOtheme\Str;
|
||||
|
||||
class Chainedfields
|
||||
{
|
||||
/**
|
||||
* Returns the YooTheme type.
|
||||
*
|
||||
* If this accepts one image:
|
||||
* - Tells YooTheme to use the default type for the dropdown mapping option.
|
||||
*
|
||||
* If this accepts multiple images:
|
||||
* - Tells YooTheme to only return the value of this field in the dropdown mapping option.
|
||||
*
|
||||
* @param object $field
|
||||
* @param object $source
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getYooType($field = [], $source = [])
|
||||
{
|
||||
$fields = [
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'value',
|
||||
'metadata' => [
|
||||
'label' => 'Choices'
|
||||
],
|
||||
]
|
||||
];
|
||||
$name = Str::camelCase(['Field', $field->name], true);
|
||||
$source->objectType($name, compact('fields'));
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the field value to an appropriate value that YooTheme can understand.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function yooResolve($item, $args, $ctx, $info)
|
||||
{
|
||||
$name = str_replace('String', '', strtr($info->fieldName, '_', '-'));
|
||||
|
||||
// Check if it's a subform field
|
||||
$subfield = clone \ACF\Helpers\Yoo::getSubfield($args['field_id'], $args['context']);
|
||||
|
||||
// When we have a subform field, the $item is an array of values
|
||||
if (!$subfield || !is_array($item))
|
||||
{
|
||||
if (!isset($item->id) || !($field = FieldsType::getField($name, $item, $args['context'])))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set rawvalue
|
||||
$subfield->rawvalue = isset($item["field{$args['field_id']}"]) ? $item["field{$args['field_id']}"] : null;
|
||||
|
||||
// Use the subform field
|
||||
$field = $subfield;
|
||||
}
|
||||
|
||||
if (!$value = $field->rawvalue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_array($value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
return [
|
||||
'value' => implode(', ', $value)
|
||||
];
|
||||
}
|
||||
}
|
||||
139
plugins/system/acf/ACF/Helpers/Fields/Country.php
Normal file
139
plugins/system/acf/ACF/Helpers/Fields/Country.php
Normal file
@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2021 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
namespace ACF\Helpers\Fields;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use YOOtheme\Builder\Joomla\Fields\Type\FieldsType;
|
||||
use YOOtheme\Str;
|
||||
|
||||
class Country
|
||||
{
|
||||
/**
|
||||
* Returns the YooTheme type.
|
||||
*
|
||||
* @param object $field
|
||||
* @param object $source
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getYooType($field = [], $source = [])
|
||||
{
|
||||
$multiple_selection = $field->fieldparams->get('multiple_selection', '0') === '1';
|
||||
if (!$multiple_selection)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$fields = [
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'code',
|
||||
'metadata' => [
|
||||
'label' => 'Country Code'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'name',
|
||||
'metadata' => [
|
||||
'label' => 'Country Name'
|
||||
],
|
||||
]
|
||||
];
|
||||
$name = Str::camelCase(['Field', $field->name], true);
|
||||
$source->objectType($name, compact('fields'));
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the field value to an appropriate value that YooTheme can understand.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function yooResolve($item, $args, $ctx, $info)
|
||||
{
|
||||
$name = str_replace('String', '', strtr($info->fieldName, '_', '-'));
|
||||
|
||||
// Check if it's a subform field
|
||||
$subfield = clone \ACF\Helpers\Yoo::getSubfield($args['field_id'], $args['context']);
|
||||
|
||||
// When we have a subform field, the $item is an array of values
|
||||
if (!$subfield || !is_array($item))
|
||||
{
|
||||
if (!isset($item->id) || !($field = FieldsType::getField($name, $item, $args['context'])))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set rawvalue
|
||||
$subfield->rawvalue = isset($item["field{$args['field_id']}"]) ? $item["field{$args['field_id']}"] : '';
|
||||
|
||||
// Use the subform field
|
||||
$field = $subfield;
|
||||
}
|
||||
|
||||
$value = $field->rawvalue;
|
||||
|
||||
$multiple_selection = $field->fieldparams->get('multiple_selection', '0') === '1';
|
||||
|
||||
if ($multiple_selection)
|
||||
{
|
||||
if (!is_array($value))
|
||||
{
|
||||
$value = [$value];
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => implode(',', $value),
|
||||
'name' => implode(',', self::getNames($value))
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
// If it's an array, try to grab the first item.
|
||||
if (is_array($value))
|
||||
{
|
||||
$value = array_values($value);
|
||||
$value = isset($value[0]) ? $value[0] : $value;
|
||||
}
|
||||
|
||||
if (!is_string($value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$display_mode = $field->fieldparams->get('countrydisplay', 'name');
|
||||
|
||||
if ($display_mode === 'code')
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (!$country = \NRFramework\Countries::getCountry($value))
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
return $country['name'];
|
||||
}
|
||||
}
|
||||
|
||||
public static function getNames($items = [])
|
||||
{
|
||||
return array_map(function ($value) {
|
||||
$country = \NRFramework\Countries::getCountry($value);
|
||||
return isset($country['name']) ? $country['name'] : $value['code'];
|
||||
}, $items);
|
||||
}
|
||||
}
|
||||
58
plugins/system/acf/ACF/Helpers/Fields/Downloadbutton.php
Normal file
58
plugins/system/acf/ACF/Helpers/Fields/Downloadbutton.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2021 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
namespace ACF\Helpers\Fields;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use YOOtheme\Builder\Joomla\Fields\Type\FieldsType;
|
||||
|
||||
class Downloadbutton
|
||||
{
|
||||
/**
|
||||
* Transforms the field value to an appropriate value that YooTheme can understand.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function yooResolve($item, $args, $ctx, $info)
|
||||
{
|
||||
$name = str_replace('String', '', strtr($info->fieldName, '_', '-'));
|
||||
|
||||
// Check if it's a subform field
|
||||
$subfield = clone \ACF\Helpers\Yoo::getSubfield($args['field_id'], $args['context']);
|
||||
|
||||
// When we have a subform field, the $item is an array of values
|
||||
if (!$subfield || !is_array($item))
|
||||
{
|
||||
if (!isset($item->id) || !($field = FieldsType::getField($name, $item, $args['context'])))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set rawvalue
|
||||
$subfield->rawvalue = isset($item["field{$args['field_id']}"]) ? $item["field{$args['field_id']}"] : '';
|
||||
|
||||
// Use the subform field
|
||||
$field = $subfield;
|
||||
}
|
||||
|
||||
$filename = $field->rawvalue;
|
||||
|
||||
if (!is_string($filename))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$directory = $field->fieldparams->get('directory');
|
||||
|
||||
return implode(DIRECTORY_SEPARATOR, [$directory, $filename]);
|
||||
}
|
||||
}
|
||||
107
plugins/system/acf/ACF/Helpers/Fields/Faq.php
Normal file
107
plugins/system/acf/ACF/Helpers/Fields/Faq.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2021 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
namespace ACF\Helpers\Fields;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use YOOtheme\Builder\Joomla\Fields\Type\FieldsType;
|
||||
use YOOtheme\Str;
|
||||
|
||||
class Faq
|
||||
{
|
||||
/**
|
||||
* Returns the YooTheme type.
|
||||
*
|
||||
* @param object $field
|
||||
* @param object $source
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getYooType($field = [], $source = [])
|
||||
{
|
||||
$fields = [
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'question',
|
||||
'metadata' => [
|
||||
'label' => 'Question'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'answer',
|
||||
'metadata' => [
|
||||
'label' => 'Answer'
|
||||
],
|
||||
],
|
||||
];
|
||||
$name = Str::camelCase(['Field', $field->name], true);
|
||||
$source->objectType($name, compact('fields'));
|
||||
|
||||
return ['listOf' => $name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the field value to an appropriate value that YooTheme can understand.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function yooResolve($item, $args, $ctx, $info)
|
||||
{
|
||||
$name = str_replace('String', '', strtr($info->fieldName, '_', '-'));
|
||||
|
||||
// Check if it's a subform field
|
||||
$subfield = clone \ACF\Helpers\Yoo::getSubfield($args['field_id'], $args['context']);
|
||||
|
||||
// When we have a subform field, the $item is an array of values
|
||||
if (!$subfield || !is_array($item))
|
||||
{
|
||||
if (!isset($item->id) || !($field = FieldsType::getField($name, $item, $args['context'])))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set rawvalue
|
||||
$subfield->rawvalue = isset($item["field{$args['field_id']}"]) ? $item["field{$args['field_id']}"] : '';
|
||||
|
||||
// Use the subform field
|
||||
$field = $subfield;
|
||||
}
|
||||
|
||||
$value = $field->rawvalue;
|
||||
|
||||
if (is_string($value))
|
||||
{
|
||||
if (!$value = json_decode($value, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_array($value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($value['value']) || !is_array($value['value']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$value = array_values($value['value']);
|
||||
$value = array_filter($value, function($item) {
|
||||
return !empty($item['question']) && !empty($item['answer']);
|
||||
});
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
388
plugins/system/acf/ACF/Helpers/Fields/Gallery.php
Normal file
388
plugins/system/acf/ACF/Helpers/Fields/Gallery.php
Normal file
@ -0,0 +1,388 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2021 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
namespace ACF\Helpers\Fields;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Helper\TagsHelper;
|
||||
use YOOtheme\Builder\Joomla\Fields\Type\FieldsType;
|
||||
use YOOtheme\Str;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
|
||||
class Gallery
|
||||
{
|
||||
public static function deleteFilesFromItem($item_id = '')
|
||||
{
|
||||
if (!$item_id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
self::deleteGalleryFiles($item_id);
|
||||
|
||||
if (version_compare(JVERSION, '4', '>='))
|
||||
{
|
||||
self::deleteGalleryFilesInSubform($item_id);
|
||||
}
|
||||
}
|
||||
|
||||
protected static function deleteGalleryFiles($item_id = '')
|
||||
{
|
||||
if (!$item_id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('fv.value')
|
||||
->from('#__fields_values AS fv')
|
||||
->join('LEFT', '#__fields AS f ON fv.field_id = f.id')
|
||||
->where('fv.item_id = ' . $db->quote($item_id))
|
||||
->where('f.type = ' . $db->quote('acfgallery'));
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
$fieldsValues = $db->loadAssocList();
|
||||
|
||||
if (!$fieldsValues)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($fieldsValues as $value)
|
||||
{
|
||||
$files = json_decode($value['value'], true);
|
||||
|
||||
if (!$files)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($files['items']) || !is_array($files['items']) || !count($files['items']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($files['items'] as $file)
|
||||
{
|
||||
self::deleteGalleryItem('source', $file);
|
||||
self::deleteGalleryItem('image', $file);
|
||||
self::deleteGalleryItem('thumbnail', $file);
|
||||
self::deleteGalleryItem('slideshow', $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static function deleteGalleryFilesInSubform($item_id = '')
|
||||
{
|
||||
if (!$item_id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$db = Factory::getDbo();
|
||||
|
||||
// Get all ACF File Upload custom field IDs
|
||||
$query = $db->getQuery(true)
|
||||
->select('distinct f.id')
|
||||
->from('#__fields as f')
|
||||
->join('LEFT', '#__fields_values AS fv ON fv.field_id = f.id')
|
||||
->where('fv.item_id = ' . (int) $item_id)
|
||||
->where('f.type = ' . $db->quote('acfgallery'));
|
||||
$db->setQuery($query);
|
||||
$fileupload_ids = array_keys($db->loadAssocList('id'));
|
||||
|
||||
if (!$fileupload_ids)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get all Subform custom fields
|
||||
$query->clear()
|
||||
->select('f.id as field_id, fv.item_id as item_id, fv.value as value')
|
||||
->from('#__fields as f')
|
||||
->join('LEFT', '#__fields_values AS fv ON fv.field_id = f.id')
|
||||
->where('fv.item_id = ' . (int) $item_id)
|
||||
->where('f.type = ' . $db->quote('subform'));
|
||||
$db->setQuery($query);
|
||||
$subform_fields = $db->loadAssocList();
|
||||
|
||||
foreach ($subform_fields as $subform_field)
|
||||
{
|
||||
if (!$subform_field_items = json_decode($subform_field['value'], true))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($subform_field_items as $row => &$row_items)
|
||||
{
|
||||
if (!is_array($row_items))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($row_items as $field_name => &$field_value)
|
||||
{
|
||||
// Get the field id
|
||||
$field_id = str_replace('field', '', $field_name);
|
||||
|
||||
// Check if its a gallery field
|
||||
if (!in_array($field_id, $fileupload_ids))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!is_array($field_value))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($field_value['items']) || !is_array($field_value['items']) || !count($field_value['items']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($field_value['items'] as $file)
|
||||
{
|
||||
self::deleteGalleryItem('source', $file);
|
||||
self::deleteGalleryItem('image', $file);
|
||||
self::deleteGalleryItem('thumbnail', $file);
|
||||
self::deleteGalleryItem('slideshow', $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function deleteGalleryItem($key, $item)
|
||||
{
|
||||
if (isset($item[$key]) && !empty($item[$key]))
|
||||
{
|
||||
// Original file path
|
||||
$path = implode(DIRECTORY_SEPARATOR, [JPATH_SITE, $item[$key]]);
|
||||
|
||||
if (!file_exists($path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
unlink($path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the YooTheme type.
|
||||
*
|
||||
* If this accepts one image:
|
||||
* - Tells YooTheme to use the default type for the dropdown mapping option.
|
||||
*
|
||||
* If this accepts multiple images:
|
||||
* - Tells YooTheme to only return the value of this field in the dropdown mapping option.
|
||||
*
|
||||
* @param object $field
|
||||
* @param object $source
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getYooType($field = [], $source = [])
|
||||
{
|
||||
$fields = [
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'thumb',
|
||||
'metadata' => [
|
||||
'label' => 'Thumbnail Image URL'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'value',
|
||||
'metadata' => [
|
||||
'label' => 'Full Image URL'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'source',
|
||||
'metadata' => [
|
||||
'label' => 'Source Image URL'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'caption',
|
||||
'metadata' => [
|
||||
'label' => 'Caption'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'alt',
|
||||
'metadata' => [
|
||||
'label' => 'Alt'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'tags',
|
||||
'metadata' => [
|
||||
'label' => 'Tags'
|
||||
],
|
||||
]
|
||||
];
|
||||
$name = Str::camelCase(['Field', $field->name], true);
|
||||
$source->objectType($name, compact('fields'));
|
||||
|
||||
$limit_files = (int) $field->fieldparams->get('limit_files', 0);
|
||||
if ($limit_files === 1)
|
||||
{
|
||||
return $name;
|
||||
}
|
||||
|
||||
return ['listOf' => $name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the field value to an appropriate value that YooTheme can understand.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function yooResolve($item, $args, $ctx, $info)
|
||||
{
|
||||
$name = str_replace('String', '', strtr($info->fieldName, '_', '-'));
|
||||
|
||||
// Check if it's a subform field
|
||||
$subfield = clone \ACF\Helpers\Yoo::getSubfield($args['field_id'], $args['context']);
|
||||
|
||||
// When we have a subform field, the $item is an array of values
|
||||
if (!$subfield || !is_array($item))
|
||||
{
|
||||
if (!isset($item->id) || !($field = FieldsType::getField($name, $item, $args['context'])))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set rawvalue
|
||||
$subfield->rawvalue = isset($item["field{$args['field_id']}"]) ? json_encode($item["field{$args['field_id']}"]) : '';
|
||||
|
||||
// Use the subform field
|
||||
$field = $subfield;
|
||||
}
|
||||
|
||||
$value = $field->rawvalue;
|
||||
|
||||
if (is_string($value))
|
||||
{
|
||||
if (!$value = json_decode($value, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_array($value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($value['items']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$tagsHelper = new TagsHelper();
|
||||
|
||||
// Apply ordering
|
||||
$ordering = $field->fieldparams->get('ordering', 'default');
|
||||
self::randomize($value['items'], $ordering);
|
||||
|
||||
$limit_files = (int) $field->fieldparams->get('limit_files', 0);
|
||||
if ($limit_files === 1)
|
||||
{
|
||||
$uploaded_data = array_values($value['items']);
|
||||
|
||||
$tags = isset($uploaded_data[0]['tags']) && is_array($uploaded_data[0]['tags']) ? $tagsHelper->getTagNames($uploaded_data[0]['tags']) : [];
|
||||
|
||||
return [
|
||||
'caption' => isset($uploaded_data[0]['caption']) ? $uploaded_data[0]['caption'] : '',
|
||||
'source' => isset($uploaded_data[0]['source']) ? $uploaded_data[0]['source'] : '',
|
||||
'thumb' => isset($uploaded_data[0]['thumbnail']) ? $uploaded_data[0]['thumbnail'] : '',
|
||||
'alt' => isset($uploaded_data[0]['alt']) ? $uploaded_data[0]['alt'] : '',
|
||||
'value' => isset($uploaded_data[0]['image']) ? $uploaded_data[0]['image'] : '',
|
||||
'tags' => implode(', ', $tags)
|
||||
];
|
||||
}
|
||||
|
||||
$data = array_values(array_map(function($item) use ($tagsHelper) {
|
||||
$tags = isset($item['tags']) && is_array($item['tags']) ? $tagsHelper->getTagNames($item['tags']) : [];
|
||||
|
||||
return [
|
||||
'value' => $item['image'],
|
||||
'thumb' => $item['thumbnail'],
|
||||
'source' => isset($item['source']) ? $item['source'] : '',
|
||||
'alt' => isset($item['alt']) ? $item['alt'] : '',
|
||||
'caption' => $item['caption'],
|
||||
'tags' => implode(', ', $tags)
|
||||
];
|
||||
}, $value['items']));
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function randomize(&$data = [], $ordering = 'default')
|
||||
{
|
||||
if (!is_array($data))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch ($ordering)
|
||||
{
|
||||
case 'random':
|
||||
shuffle($data);
|
||||
break;
|
||||
case 'alphabetical':
|
||||
usort($data, [__CLASS__, 'compareByThumbnailASC']);
|
||||
break;
|
||||
case 'reverse_alphabetical':
|
||||
usort($data, [__CLASS__, 'compareByThumbnailDESC']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares thumbnail file names in ASC order
|
||||
*
|
||||
* @param array $a
|
||||
* @param array $b
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function compareByThumbnailASC($a, $b)
|
||||
{
|
||||
return strcmp(basename($a['thumbnail']), basename($b['thumbnail']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares thumbnail file names in DESC order
|
||||
*
|
||||
* @param array $a
|
||||
* @param array $b
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function compareByThumbnailDESC($a, $b)
|
||||
{
|
||||
return strcmp(basename($b['thumbnail']), basename($a['thumbnail']));
|
||||
}
|
||||
}
|
||||
136
plugins/system/acf/ACF/Helpers/Fields/Map.php
Normal file
136
plugins/system/acf/ACF/Helpers/Fields/Map.php
Normal file
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2021 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
namespace ACF\Helpers\Fields;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use YOOtheme\Builder\Joomla\Fields\Type\FieldsType;
|
||||
use YOOtheme\Str;
|
||||
|
||||
class Map
|
||||
{
|
||||
/**
|
||||
* Returns the YooTheme type.
|
||||
*
|
||||
* @param object $field
|
||||
* @param object $source
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getYooType($field = [], $source = [])
|
||||
{
|
||||
$fields = [
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'address',
|
||||
'metadata' => [
|
||||
'label' => Text::_('NR_MARKER_ADDRESS')
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'coordinates',
|
||||
'metadata' => [
|
||||
'label' => Text::_('NR_MARKER_COORDINATES')
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'latitude',
|
||||
'metadata' => [
|
||||
'label' => Text::_('NR_MARKER_LATITUDE')
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'longitude',
|
||||
'metadata' => [
|
||||
'label' => Text::_('NR_MARKER_LONGITUDE')
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'label',
|
||||
'metadata' => [
|
||||
'label' => Text::_('NR_MARKER_LABEL')
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'description',
|
||||
'metadata' => [
|
||||
'label' => Text::_('NR_MARKER_DESCRIPTION')
|
||||
],
|
||||
],
|
||||
];
|
||||
$name = Str::camelCase(['Field', $field->name], true);
|
||||
$source->objectType($name, compact('fields'));
|
||||
|
||||
return ['listOf' => $name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the field value to an appropriate value that YooTheme can understand.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function yooResolve($item, $args, $ctx, $info)
|
||||
{
|
||||
$name = str_replace('String', '', strtr($info->fieldName, '_', '-'));
|
||||
|
||||
// Check if it's a subform field
|
||||
$subfield = clone \ACF\Helpers\Yoo::getSubfield($args['field_id'], $args['context']);
|
||||
|
||||
// When we have a subform field, the $item is an array of values
|
||||
if (!$subfield || !is_array($item))
|
||||
{
|
||||
if (!isset($item->id) || !($field = FieldsType::getField($name, $item, $args['context'])))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set rawvalue
|
||||
$subfield->rawvalue = isset($item["field{$args['field_id']}"]) ? $item["field{$args['field_id']}"] : '';
|
||||
|
||||
// Use the subform field
|
||||
$field = $subfield;
|
||||
}
|
||||
|
||||
$value = $field->rawvalue;
|
||||
|
||||
if (is_string($value))
|
||||
{
|
||||
if (!$value = json_decode($value, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_array($value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($value as $key => &$v)
|
||||
{
|
||||
if (!isset($v['latitude']) || !isset($v['longitude']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$v['coordinates'] = $v['latitude'] . ',' . $v['longitude'];
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
66
plugins/system/acf/ACF/Helpers/Fields/Osm.php
Normal file
66
plugins/system/acf/ACF/Helpers/Fields/Osm.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2021 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
namespace ACF\Helpers\Fields;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use YOOtheme\Builder\Joomla\Fields\Type\FieldsType;
|
||||
|
||||
class Osm
|
||||
{
|
||||
/**
|
||||
* Transforms the field value to an appropriate value that YooTheme can understand.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function yooResolve($item, $args, $ctx, $info)
|
||||
{
|
||||
$name = str_replace('String', '', strtr($info->fieldName, '_', '-'));
|
||||
|
||||
// Check if it's a subform field
|
||||
$subfield = clone \ACF\Helpers\Yoo::getSubfield($args['field_id'], $args['context']);
|
||||
|
||||
// When we have a subform field, the $item is an array of values
|
||||
if (!$subfield || !is_array($item))
|
||||
{
|
||||
if (!isset($item->id) || !($field = FieldsType::getField($name, $item, $args['context'])))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set rawvalue
|
||||
$subfield->rawvalue = isset($item["field{$args['field_id']}"]) ? json_encode($item["field{$args['field_id']}"]) : '';
|
||||
|
||||
// Use the subform field
|
||||
$field = $subfield;
|
||||
}
|
||||
|
||||
$value = $field->rawvalue;
|
||||
|
||||
if (!is_string($value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$value = json_decode($value, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($value['coordinates']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
return $value['coordinates'];
|
||||
}
|
||||
}
|
||||
65
plugins/system/acf/ACF/Helpers/Fields/Php.php
Normal file
65
plugins/system/acf/ACF/Helpers/Fields/Php.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2021 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
namespace ACF\Helpers\Fields;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use YOOtheme\Builder\Joomla\Fields\Type\FieldsType;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
class Php
|
||||
{
|
||||
/**
|
||||
* Transforms the field value to an appropriate value that YooTheme can understand.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function yooResolve($item, $args, $ctx, $info)
|
||||
{
|
||||
$name = str_replace('String', '', strtr($info->fieldName, '_', '-'));
|
||||
|
||||
// Check if it's a subform field
|
||||
$subfield = clone \ACF\Helpers\Yoo::getSubfield($args['field_id'], $args['context']);
|
||||
|
||||
// When we have a subform field, the $item is an array of values
|
||||
if (!$subfield || !is_array($item))
|
||||
{
|
||||
if (!isset($item->id) || !($field = FieldsType::getField($name, $item, $args['context'])))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set rawvalue
|
||||
$subfield->rawvalue = isset($item["field{$args['field_id']}"]) ? $item["field{$args['field_id']}"] : '';
|
||||
|
||||
// Use the subform field
|
||||
$field = $subfield;
|
||||
}
|
||||
|
||||
if (!$value = $field->rawvalue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get plugin params
|
||||
$plugin = PluginHelper::getPlugin('fields', 'acfphp');
|
||||
$params = new Registry($plugin->params);
|
||||
|
||||
// Enable buffer output
|
||||
$executer = new \NRFramework\Executer($value);
|
||||
|
||||
return $executer
|
||||
->setForbiddenPHPFunctions($params->get('forbidden_php_functions'))
|
||||
->run();
|
||||
}
|
||||
}
|
||||
58
plugins/system/acf/ACF/Helpers/Fields/Soundcloud.php
Normal file
58
plugins/system/acf/ACF/Helpers/Fields/Soundcloud.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2021 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
namespace ACF\Helpers\Fields;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use YOOtheme\Builder\Joomla\Fields\Type\FieldsType;
|
||||
|
||||
class Soundcloud
|
||||
{
|
||||
/**
|
||||
* Transforms the field value to an appropriate value that YooTheme can understand.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function yooResolve($item, $args, $ctx, $info)
|
||||
{
|
||||
$name = str_replace('String', '', strtr($info->fieldName, '_', '-'));
|
||||
|
||||
// Check if it's a subform field
|
||||
$subfield = clone \ACF\Helpers\Yoo::getSubfield($args['field_id'], $args['context']);
|
||||
|
||||
// When we have a subform field, the $item is an array of values
|
||||
if (!$subfield || !is_array($item))
|
||||
{
|
||||
if (!isset($item->id) || !($field = FieldsType::getField($name, $item, $args['context'])))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set rawvalue
|
||||
$subfield->rawvalue = isset($item["field{$args['field_id']}"]) ? $item["field{$args['field_id']}"] : '';
|
||||
|
||||
// Use the subform field
|
||||
$field = $subfield;
|
||||
}
|
||||
|
||||
$value = $field->rawvalue;
|
||||
|
||||
$value = is_string($value) ? json_decode($value, true) : $value;
|
||||
|
||||
if (!is_array($value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
return isset($value['id']) ? $value['id'] : null;
|
||||
}
|
||||
}
|
||||
141
plugins/system/acf/ACF/Helpers/Fields/Telephone.php
Normal file
141
plugins/system/acf/ACF/Helpers/Fields/Telephone.php
Normal file
@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2021 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
namespace ACF\Helpers\Fields;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use YOOtheme\Builder\Joomla\Fields\Type\FieldsType;
|
||||
use YOOtheme\Str;
|
||||
|
||||
class Telephone
|
||||
{
|
||||
/**
|
||||
* Returns the YooTheme type.
|
||||
*
|
||||
* If this accepts one image:
|
||||
* - Tells YooTheme to use the default type for the dropdown mapping option.
|
||||
*
|
||||
* If this accepts multiple images:
|
||||
* - Tells YooTheme to only return the value of this field in the dropdown mapping option.
|
||||
*
|
||||
* @param object $field
|
||||
* @param object $source
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getYooType($field = [], $source = [])
|
||||
{
|
||||
$fields = [
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'phone_number',
|
||||
'metadata' => [
|
||||
'label' => 'Phone Number'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'calling_code',
|
||||
'metadata' => [
|
||||
'label' => 'Calling Code'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'country_code',
|
||||
'metadata' => [
|
||||
'label' => 'Country Code'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'country_name',
|
||||
'metadata' => [
|
||||
'label' => 'Country Name'
|
||||
],
|
||||
]
|
||||
];
|
||||
$name = Str::camelCase(['Field', $field->name], true);
|
||||
$source->objectType($name, compact('fields'));
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the field value to an appropriate value that YooTheme can understand.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function yooResolve($item, $args, $ctx, $info)
|
||||
{
|
||||
// var_dump($info->rootValue['parent']->children[0]);
|
||||
$name = str_replace('String', '', strtr($info->fieldName, '_', '-'));
|
||||
|
||||
// Check if it's a subform field
|
||||
$subfield = clone \ACF\Helpers\Yoo::getSubfield($args['field_id'], $args['context']);
|
||||
|
||||
// When we have a subform field, the $item is an array of values
|
||||
if (!$subfield || !is_array($item))
|
||||
{
|
||||
if (!isset($item->id) || !($field = FieldsType::getField($name, $item, $args['context'])))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set rawvalue
|
||||
$subfield->rawvalue = isset($item["field{$args['field_id']}"]) ? $item["field{$args['field_id']}"] : '';
|
||||
|
||||
// Use the subform field
|
||||
$field = $subfield;
|
||||
}
|
||||
|
||||
$value = $field->rawvalue;
|
||||
|
||||
if (is_string($value) && json_decode($value, true))
|
||||
{
|
||||
$value = json_decode($value, true);
|
||||
}
|
||||
|
||||
$countryCode = '';
|
||||
$callingCode = '';
|
||||
|
||||
if (is_array($value))
|
||||
{
|
||||
$countryCode = isset($value['code']) ? $value['code'] : '';
|
||||
$phoneNumber = isset($value['value']) ? $value['value'] : '';
|
||||
|
||||
if ($phoneNumber)
|
||||
{
|
||||
$callingCode = \NRFramework\Countries::getCallingCodeByCountryCode($countryCode);
|
||||
$callingCode = $callingCode !== '' ? '+' . $callingCode : '';
|
||||
|
||||
$value = $callingCode . $phoneNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
$value = '';
|
||||
}
|
||||
}
|
||||
|
||||
if (!$value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
return [
|
||||
'phone_number' => $value,
|
||||
'calling_code' => $callingCode,
|
||||
'country_code' => $countryCode,
|
||||
'country_name' => ($countryCode ? \NRFramework\Countries::toCountryName($countryCode) : '')
|
||||
];
|
||||
}
|
||||
}
|
||||
300
plugins/system/acf/ACF/Helpers/Fields/Upload.php
Normal file
300
plugins/system/acf/ACF/Helpers/Fields/Upload.php
Normal file
@ -0,0 +1,300 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2021 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
namespace ACF\Helpers\Fields;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use YOOtheme\Builder\Joomla\Fields\Type\FieldsType;
|
||||
use YOOtheme\Str;
|
||||
use Joomla\CMS\Factory;
|
||||
|
||||
class Upload
|
||||
{
|
||||
|
||||
public static function deleteFilesFromItem($item_id = '')
|
||||
{
|
||||
if (!$item_id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
self::deleteFileUploadFiles($item_id);
|
||||
|
||||
if (version_compare(JVERSION, '4', '>='))
|
||||
{
|
||||
self::deleteFileUploadFilesInSubform($item_id);
|
||||
}
|
||||
}
|
||||
|
||||
protected static function deleteFileUploadFiles($item_id = '')
|
||||
{
|
||||
if (!$item_id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('fv.value')
|
||||
->from('#__fields_values AS fv')
|
||||
->join('LEFT', '#__fields AS f ON fv.field_id = f.id')
|
||||
->where('fv.item_id = ' . $db->quote($item_id))
|
||||
->where('f.type = ' . $db->quote('acfupload'));
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
$fieldsValues = $db->loadAssocList();
|
||||
|
||||
if (!$fieldsValues)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($fieldsValues as $value)
|
||||
{
|
||||
$files = json_decode($value['value'], true);
|
||||
|
||||
if (!$files)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
$filePath = implode(DIRECTORY_SEPARATOR, [JPATH_ROOT, $file['value']]);
|
||||
|
||||
if (!file_exists($filePath))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
unlink($filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static function deleteFileUploadFilesInSubform($item_id = '')
|
||||
{
|
||||
if (!$item_id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$db = Factory::getDbo();
|
||||
|
||||
// Get all ACF File Upload custom field IDs
|
||||
$query = $db->getQuery(true)
|
||||
->select('distinct f.id')
|
||||
->from('#__fields as f')
|
||||
->join('LEFT', '#__fields_values AS fv ON fv.field_id = f.id')
|
||||
->where('fv.item_id = ' . (int) $item_id)
|
||||
->where('f.type = ' . $db->quote('acfupload'));
|
||||
$db->setQuery($query);
|
||||
$fileupload_ids = array_keys($db->loadAssocList('id'));
|
||||
|
||||
if (!$fileupload_ids)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get all Subform custom fields
|
||||
$query->clear()
|
||||
->select('f.id as field_id, fv.item_id as item_id, fv.value as value')
|
||||
->from('#__fields as f')
|
||||
->join('LEFT', '#__fields_values AS fv ON fv.field_id = f.id')
|
||||
->where('fv.item_id = ' . (int) $item_id)
|
||||
->where('f.type = ' . $db->quote('subform'));
|
||||
$db->setQuery($query);
|
||||
$subform_fields = $db->loadAssocList();
|
||||
|
||||
foreach ($subform_fields as $subform_field)
|
||||
{
|
||||
if (!$subform_field_items = json_decode($subform_field['value'], true))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($subform_field_items as $row => &$row_items)
|
||||
{
|
||||
if (!is_array($row_items))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($row_items as $field_name => &$field_value)
|
||||
{
|
||||
// Get the field id
|
||||
$field_id = str_replace('field', '', $field_name);
|
||||
|
||||
// Check if its a gallery field
|
||||
if (!in_array($field_id, $fileupload_ids))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!is_array($field_value))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($field_value as $file)
|
||||
{
|
||||
$filePath = implode(DIRECTORY_SEPARATOR, [JPATH_ROOT, $file['value']]);
|
||||
|
||||
if (!file_exists($filePath))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
unlink($filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the YooTheme type.
|
||||
*
|
||||
* If this accepts one image:
|
||||
* - Tells YooTheme to use the default type for the dropdown mapping option.
|
||||
*
|
||||
* If this accepts multiple images:
|
||||
* - Tells YooTheme to only return the value of this field in the dropdown mapping option.
|
||||
*
|
||||
* @param object $field
|
||||
* @param object $source
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getYooType($field = [], $source = [])
|
||||
{
|
||||
$limit_files = (int) $field->fieldparams->get('limit_files', 0);
|
||||
|
||||
$fields = [
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'value',
|
||||
'metadata' => [
|
||||
'label' => 'File URL'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'title',
|
||||
'metadata' => [
|
||||
'label' => 'Title'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'description',
|
||||
'metadata' => [
|
||||
'label' => 'Description'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'filesize',
|
||||
'metadata' => [
|
||||
'label' => 'File size'
|
||||
],
|
||||
],
|
||||
];
|
||||
$name = Str::camelCase(['Field', $field->name], true);
|
||||
$source->objectType($name, compact('fields'));
|
||||
|
||||
if ($limit_files === 1)
|
||||
{
|
||||
return $name;
|
||||
}
|
||||
|
||||
return ['listOf' => $name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the field value to an appropriate value that YooTheme can understand.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function yooResolve($item, $args, $ctx, $info)
|
||||
{
|
||||
$name = str_replace('String', '', strtr($info->fieldName, '_', '-'));
|
||||
|
||||
// Check if it's a subform field
|
||||
$subfield = clone \ACF\Helpers\Yoo::getSubfield($args['field_id'], $args['context']);
|
||||
|
||||
// When we have a subform field, the $item is an array of values
|
||||
if (!$subfield || !is_array($item))
|
||||
{
|
||||
if (!isset($item->id) || !($field = FieldsType::getField($name, $item, $args['context'])))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set rawvalue
|
||||
$subfield->rawvalue = isset($item["field{$args['field_id']}"]) ? json_encode($item["field{$args['field_id']}"]) : '';
|
||||
|
||||
// Use the subform field
|
||||
$field = $subfield;
|
||||
}
|
||||
|
||||
$value = $field->rawvalue;
|
||||
|
||||
$value = is_string($value) ? json_decode($value, true) ?? $value : $value;
|
||||
|
||||
if (!is_array($value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$value = array_values($value);
|
||||
|
||||
if (is_array($value))
|
||||
{
|
||||
// Fix new lines in description
|
||||
foreach ($value as $key => &$val)
|
||||
{
|
||||
if (isset($val['description']))
|
||||
{
|
||||
$val['description'] = nl2br($val['description']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($value as $key => &$val)
|
||||
{
|
||||
$val['filesize'] = '';
|
||||
|
||||
$path = implode(DIRECTORY_SEPARATOR, [JPATH_ROOT, $val['value']]);
|
||||
if (file_exists($path))
|
||||
{
|
||||
$val['filesize'] = filesize($path);
|
||||
$val['filesize'] = sprintf("%4.2f MB", $val['filesize'] / 1024 / 1024);
|
||||
}
|
||||
|
||||
if (isset($val['value']))
|
||||
{
|
||||
$val['value'] = $val['value'];
|
||||
}
|
||||
}
|
||||
|
||||
$limit_files = (int) $field->fieldparams->get('limit_files', 0);
|
||||
if ($limit_files === 1 && is_array($value) && count($value) === 1)
|
||||
{
|
||||
return $value[0];
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
106
plugins/system/acf/ACF/Helpers/Fields/Url.php
Normal file
106
plugins/system/acf/ACF/Helpers/Fields/Url.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2021 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
namespace ACF\Helpers\Fields;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use YOOtheme\Builder\Joomla\Fields\Type\FieldsType;
|
||||
use YOOtheme\Str;
|
||||
|
||||
class Url
|
||||
{
|
||||
/**
|
||||
* Returns the YooTheme type.
|
||||
*
|
||||
* If this accepts one image:
|
||||
* - Tells YooTheme to use the default type for the dropdown mapping option.
|
||||
*
|
||||
* If this accepts multiple images:
|
||||
* - Tells YooTheme to only return the value of this field in the dropdown mapping option.
|
||||
*
|
||||
* @param object $field
|
||||
* @param object $source
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getYooType($field = [], $source = [])
|
||||
{
|
||||
$fields = [
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'url',
|
||||
'metadata' => [
|
||||
'label' => 'URL'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'text',
|
||||
'metadata' => [
|
||||
'label' => 'Label'
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'String',
|
||||
'name' => 'target',
|
||||
'metadata' => [
|
||||
'label' => 'Target'
|
||||
],
|
||||
]
|
||||
];
|
||||
$name = Str::camelCase(['Field', $field->name], true);
|
||||
$source->objectType($name, compact('fields'));
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms the field value to an appropriate value that YooTheme can understand.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function yooResolve($item, $args, $ctx, $info)
|
||||
{
|
||||
// var_dump($info->rootValue['parent']->children[0]);
|
||||
$name = str_replace('String', '', strtr($info->fieldName, '_', '-'));
|
||||
|
||||
// Check if it's a subform field
|
||||
$subfield = clone \ACF\Helpers\Yoo::getSubfield($args['field_id'], $args['context']);
|
||||
|
||||
// When we have a subform field, the $item is an array of values
|
||||
if (!$subfield || !is_array($item))
|
||||
{
|
||||
if (!isset($item->id) || !($field = FieldsType::getField($name, $item, $args['context'])))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set rawvalue
|
||||
$subfield->rawvalue = isset($item["field{$args['field_id']}"]) ? $item["field{$args['field_id']}"] : '';
|
||||
|
||||
// Use the subform field
|
||||
$field = $subfield;
|
||||
}
|
||||
|
||||
$value = $field->rawvalue;
|
||||
|
||||
if (is_string($value))
|
||||
{
|
||||
if (!$value = json_decode($value, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
0
plugins/system/acf/ACF/Helpers/Fields/index.php
Normal file
0
plugins/system/acf/ACF/Helpers/Fields/index.php
Normal file
48
plugins/system/acf/ACF/Helpers/Previewer.php
Normal file
48
plugins/system/acf/ACF/Helpers/Previewer.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2021 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
namespace ACF\Helpers;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
class Previewer
|
||||
{
|
||||
/**
|
||||
* Returns the field previewer data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getFieldPreviewData($field = '')
|
||||
{
|
||||
if (empty($field))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get path to file
|
||||
$file = implode(DIRECTORY_SEPARATOR, [self::getJsonDirectory(), $field . '.json']);
|
||||
|
||||
if (!file_exists($file))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
return file_get_contents($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path to the fields previewer JSON directory.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getJsonDirectory()
|
||||
{
|
||||
return implode(DIRECTORY_SEPARATOR, [JPATH_SITE, 'media', 'plg_system_acf', 'data', 'previewer']);
|
||||
}
|
||||
}
|
||||
87
plugins/system/acf/ACF/Helpers/Yoo.php
Normal file
87
plugins/system/acf/ACF/Helpers/Yoo.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2021 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
namespace ACF\Helpers;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use NRFramework\Functions;
|
||||
use YOOtheme\Builder\Joomla\Fields\FieldsHelper;
|
||||
use YOOtheme\Application as YooApplication;
|
||||
use YOOtheme\Event;
|
||||
|
||||
class Yoo
|
||||
{
|
||||
public static function initFieldParser()
|
||||
{
|
||||
// Ensure YOOtheme Pro is ready
|
||||
if (!class_exists(YooApplication::class, false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Event::on('source.com_fields.field', function($config, $field, $source, $context) {
|
||||
// If it's not an ACF Field, return current config
|
||||
if (substr($field->type, 0, 3) !== 'acf')
|
||||
{
|
||||
return $config;
|
||||
}
|
||||
|
||||
// Get the helper class of the field
|
||||
$helperClass = '\ACF\Helpers\Fields\\' . ucfirst(substr($field->type, 3));
|
||||
|
||||
// If it does not exist, return current config
|
||||
if (!class_exists($helperClass))
|
||||
{
|
||||
return $config;
|
||||
}
|
||||
|
||||
// If the method does not have a resolve method, return current config
|
||||
if (!method_exists($helperClass, 'yooResolve'))
|
||||
{
|
||||
return $config;
|
||||
}
|
||||
|
||||
$payload = [
|
||||
'extensions' => [
|
||||
'call' => [
|
||||
'func' => $helperClass . '::yooResolve',
|
||||
'args' => ['context' => $context, 'field_id' => $field->id]
|
||||
]
|
||||
],
|
||||
] + $config;
|
||||
|
||||
// Get and set the type
|
||||
$type = method_exists($helperClass, 'getYooType') ? $helperClass::getYooType($field, $source) : '';
|
||||
if (!empty($type))
|
||||
{
|
||||
$payload['type'] = $type;
|
||||
}
|
||||
|
||||
return $payload;
|
||||
});
|
||||
}
|
||||
|
||||
public static function getSubfield($id, $context)
|
||||
{
|
||||
static $fields = [];
|
||||
|
||||
if (!isset($fields[$context]))
|
||||
{
|
||||
$fields[$context] = [];
|
||||
|
||||
foreach (FieldsHelper::getFields($context, null, true) as $field)
|
||||
{
|
||||
$fields[$context][$field->id] = $field;
|
||||
}
|
||||
}
|
||||
|
||||
return !empty($fields[$context][$id]) ? $fields[$context][$id] : null;
|
||||
}
|
||||
}
|
||||
0
plugins/system/acf/ACF/Helpers/index.php
Normal file
0
plugins/system/acf/ACF/Helpers/index.php
Normal file
58
plugins/system/acf/ACF/Item.php
Normal file
58
plugins/system/acf/ACF/Item.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2021 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
namespace ACF;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
|
||||
class Item
|
||||
{
|
||||
/**
|
||||
* Determines whether we're copying an item.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isCopying()
|
||||
{
|
||||
return self::isBatchCopying() || self::isSavingAsCopy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether we're batch copying an item.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isBatchCopying()
|
||||
{
|
||||
$input = Factory::getApplication()->input;
|
||||
$task = $input->getCmd('task', '');
|
||||
$batchOptions = $input->post->get('batch', [], 'array');
|
||||
$cid = $input->post->get('cid', [], 'array');
|
||||
$isCopy = isset($batchOptions['move_copy']) && $batchOptions['move_copy'] === 'c';
|
||||
|
||||
return $task === 'batch' && is_array($cid) && count($cid) && $isCopy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether we're copying an item using the "Save as Copy" button.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isSavingAsCopy()
|
||||
{
|
||||
$input = Factory::getApplication()->input;
|
||||
$task = $input->getCmd('task', '');
|
||||
$id = $input->getInt('id', 0);
|
||||
$isCopying = $task === 'save2copy' && $id;
|
||||
|
||||
return $isCopying;
|
||||
}
|
||||
}
|
||||
148
plugins/system/acf/ACF/Previewer/Countdown.php
Normal file
148
plugins/system/acf/ACF/Previewer/Countdown.php
Normal file
@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2021 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
namespace ACF\Previewer;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
class Countdown extends Field
|
||||
{
|
||||
/**
|
||||
* The field framework widget name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $field = 'Countdown';
|
||||
|
||||
/**
|
||||
* The theme used.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $theme;
|
||||
|
||||
public function __construct($data = [], $payload = [])
|
||||
{
|
||||
parent::__construct($data, $payload);
|
||||
|
||||
// Set theme
|
||||
$this->theme = $this->getTheme();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the field.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function onSetup()
|
||||
{
|
||||
$this->payload = [
|
||||
// Field values
|
||||
'countdown_type' => 'evergreen',
|
||||
'timezone' => 'server',
|
||||
'dynamic_days' => '1',
|
||||
'dynamic_hours' => '12',
|
||||
'dynamic_minutes' => '59',
|
||||
'dynamic_seconds' => '59',
|
||||
|
||||
// Countdown End Action
|
||||
'finish_text' => $this->fieldParams->get('finish_text', ''),
|
||||
'redirect_url' => $this->fieldParams->get('redirect_url', ''),
|
||||
'countdown_action' => 'restart',
|
||||
|
||||
// Preset
|
||||
'theme' => $this->theme,
|
||||
'format' => $this->fieldParams->get('format', ''),
|
||||
|
||||
// Unit Display
|
||||
'days' => $this->fieldParams->get('days') === '1',
|
||||
'days_label' => $this->fieldParams->get('days_label'),
|
||||
'hours' => $this->fieldParams->get('hours') === '1',
|
||||
'hours_label' => $this->fieldParams->get('hours_label'),
|
||||
'minutes' => $this->fieldParams->get('minutes') === '1',
|
||||
'minutes_label' => $this->fieldParams->get('minutes_label'),
|
||||
'seconds' => $this->fieldParams->get('seconds') === '1',
|
||||
'seconds_label' => $this->fieldParams->get('seconds_label'),
|
||||
'separator' => $this->fieldParams->get('separator') === '1',
|
||||
'double_zeroes_format' => $this->fieldParams->get('double_zeroes_format') === '1',
|
||||
|
||||
// Unit Item
|
||||
'item_size' => $this->fieldParams->get('item_size_responsive.item_size'),
|
||||
'item_padding' => $this->fieldParams->get('item_padding_control.item_padding'),
|
||||
'gap' => $this->fieldParams->get('item_gap.gap'),
|
||||
'item_border_style' => $this->fieldParams->get('border.style'),
|
||||
'item_border_width' => $this->fieldParams->get('border.width'),
|
||||
'item_border_color' => $this->fieldParams->get('border.color'),
|
||||
'item_background_color' => $this->fieldParams->get('item_background_color'),
|
||||
'item_border_radius' => $this->fieldParams->get('item_border_radius_control.item_border_radius'),
|
||||
|
||||
// Unit Digits Container
|
||||
'digits_wrapper_min_width' => $this->fieldParams->get('digits_wrapper_custom_width') === '1' ? $this->fieldParams->get('digits_wrapper_min_width') : null,
|
||||
'digits_wrapper_padding' => $this->fieldParams->get('digits_wrapper_padding_control.digits_wrapper_padding'),
|
||||
'digits_wrapper_border_radius' => $this->fieldParams->get('digits_wrapper_border_radius_control.digits_wrapper_border_radius'),
|
||||
'digits_wrapper_background_color' => $this->fieldParams->get('digits_wrapper_background_color'),
|
||||
|
||||
// Unit Digit
|
||||
'digits_font_size' => $this->fieldParams->get('digits_font_size_control.digits_font_size'),
|
||||
'digits_font_weight' => $this->fieldParams->get('digits_font_weight'),
|
||||
'digit_min_width' => $this->fieldParams->get('digits_custom_width') === '1' ? $this->fieldParams->get('digits_min_width') : null,
|
||||
'digits_padding' => $this->fieldParams->get('digits_padding_control.digits_padding'),
|
||||
'digit_border_radius' => $this->fieldParams->get('digits_border_radius_control.digits_border_radius'),
|
||||
'digits_gap' => $this->fieldParams->get('digits_gap_control.digits_gap'),
|
||||
'digit_background_color' => $this->fieldParams->get('digit_background_color'),
|
||||
'digit_text_color' => $this->fieldParams->get('digit_text_color'),
|
||||
|
||||
// Unit Label
|
||||
'label_font_size' => $this->fieldParams->get('label_font_size_control.label_font_size'),
|
||||
'label_font_weight' => $this->fieldParams->get('label_font_weight'),
|
||||
'unit_label_margin_top' => $this->fieldParams->get('unit_label_margin_top'),
|
||||
'unit_label_text_color' => $this->fieldParams->get('unit_label_text_color'),
|
||||
];
|
||||
|
||||
$this->widget = new \NRFramework\Widgets\Countdown(json_decode(json_encode($this->payload), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all assets used by this field.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getAssets()
|
||||
{
|
||||
$exclude_breakpoints = [];
|
||||
|
||||
// If we are not viewing the fullscreen previewer,
|
||||
// then get the widget's Custom CSS of the desktop
|
||||
// due to the IFrame having small width and triggering the tablet/mobile CSS breakpoints
|
||||
if (!$this->data->get('fullscreen'))
|
||||
{
|
||||
$exclude_breakpoints = ['tablet', 'mobile'];
|
||||
}
|
||||
|
||||
return [
|
||||
'css' => \NRFramework\Widgets\Countdown::getCSS($this->theme),
|
||||
'js' => \NRFramework\Widgets\Countdown::getJS(),
|
||||
'custom_css' => $this->widget->getWidgetCSS($exclude_breakpoints)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the theme.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getTheme()
|
||||
{
|
||||
$preset_source = $this->fieldParams->get('preset_source', 'preset');
|
||||
$preset = $this->fieldParams->get('preset', '1');
|
||||
|
||||
// Determine theme
|
||||
return $preset_source === 'custom' ? 'custom' : ($preset === '8' ? 'oneline' : 'default');
|
||||
}
|
||||
}
|
||||
103
plugins/system/acf/ACF/Previewer/FAQ.php
Normal file
103
plugins/system/acf/ACF/Previewer/FAQ.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2021 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
namespace ACF\Previewer;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
class FAQ extends Field
|
||||
{
|
||||
/**
|
||||
* The field framework widget name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $field = 'FAQ';
|
||||
|
||||
/**
|
||||
* Render the field.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function onSetup()
|
||||
{
|
||||
$value = [
|
||||
[
|
||||
'question' => 'Who should use EngageBox?',
|
||||
'answer' => 'EngageBox is the most powerful popup engine in the Joomla! market used by marketing agencies, bloggers, eCommerce websites, and all small businesses. If you want to grow your email list, improve your website conversions, and reduce cart abandonment, then you need EngageBox.'
|
||||
],
|
||||
[
|
||||
'question' => 'What\'s required to use EngageBox?',
|
||||
'answer' => 'EngageBox can be used in both Joomla 3 and Joomla 4. In detail, you will need an up-to-date version of Joomla 3.8.0 or higher, PHP 7.0.0 or higher, and MySQL 5 or higher.'
|
||||
],
|
||||
[
|
||||
'question' => 'Do I need coding skills to use EngageBox?',
|
||||
'answer' => 'Absolutely not! You can create and customize beautiful popups without any coding knowledge. We made it extremely user-friendly, so you can build a high-converting popup without hiring a developer.'
|
||||
],
|
||||
[
|
||||
'question' => 'What type of conversions can I expect?',
|
||||
'answer' => 'It will make a significant difference. Game-changing! Our average user sees over 500% increase in sales, customers base and growth in general.'
|
||||
],
|
||||
[
|
||||
'question' => 'What if a visitor has a pop-up adblocker enabled?',
|
||||
'answer' => 'Will still work! EngageBox produces popups in a way which can\'t be blocked by the browser’s pop-up blocking feature or 3rd party extensions such as AdBlock or uBlock.'
|
||||
],
|
||||
];
|
||||
|
||||
$this->payload = [
|
||||
'value' => $value,
|
||||
'css_class' => ' template_' . $this->fieldParams->get('template'),
|
||||
'columns' => (int) $this->fieldParams->get('columns', 1),
|
||||
'item_gap' => $this->fieldParams->get('item_gap_control.item_gap', 20),
|
||||
'column_gap' => $this->fieldParams->get('column_gap_control.column_gap', 20),
|
||||
'item_background_color' => $this->fieldParams->get('background_color'),
|
||||
'item_border_radius' => $this->fieldParams->get('border_radius_control.item_border_radius'),
|
||||
'item_padding' => $this->fieldParams->get('padding_control.item_padding'),
|
||||
'question_font_size' => $this->fieldParams->get('question_font_size_control.question_font_size'),
|
||||
'question_text_color' => $this->fieldParams->get('question_text_color'),
|
||||
'answer_font_size' => $this->fieldParams->get('answer_font_size_control.answer_font_size'),
|
||||
'answer_text_color' => $this->fieldParams->get('answer_text_color'),
|
||||
'generate_faq' => $this->fieldParams->get('generate_faq', '0') === '1',
|
||||
'keep_one_question_open' => $this->fieldParams->get('keep_one_question_open', '0') === '1',
|
||||
'separator' => $this->fieldParams->get('separator', '0') === '1',
|
||||
'separator_color' => $this->fieldParams->get('separator_color'),
|
||||
'initial_state' => $this->fieldParams->get('initial_state', 'first-open')
|
||||
];
|
||||
|
||||
$show_toggle_icon = $this->fieldParams->get('show_toggle_icon', '1') === '1';
|
||||
$this->payload['show_toggle_icon'] = $show_toggle_icon;
|
||||
if ($show_toggle_icon)
|
||||
{
|
||||
$this->payload['icon'] = $this->fieldParams->get('icon', 'arrow');
|
||||
$this->payload['icon_position'] = $this->fieldParams->get('icon_position', 'right');
|
||||
}
|
||||
|
||||
$this->widget = new \NRFramework\Widgets\FAQ(json_decode(json_encode($this->payload), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds some extra CSS to the previewer's body.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getFieldPreviewerCSS()
|
||||
{
|
||||
if ((int) $this->fieldParams->get('template') !== 4)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
return '
|
||||
body {
|
||||
background: #EBEBEB !important;
|
||||
padding: 20px !important;
|
||||
}
|
||||
';
|
||||
}
|
||||
}
|
||||
235
plugins/system/acf/ACF/Previewer/Field.php
Normal file
235
plugins/system/acf/ACF/Previewer/Field.php
Normal file
@ -0,0 +1,235 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2021 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
namespace ACF\Previewer;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\Registry\Registry;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
|
||||
class Field
|
||||
{
|
||||
/**
|
||||
* The field framework widget name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $field = '';
|
||||
|
||||
/**
|
||||
* Field Editor Form Data.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $data = [];
|
||||
|
||||
/**
|
||||
* Field Params.
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $fieldParams = [];
|
||||
|
||||
/**
|
||||
* The field payload used to render the field.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $payload;
|
||||
|
||||
/**
|
||||
* The Framework Widget.
|
||||
*
|
||||
* @var Widget
|
||||
*/
|
||||
protected $widget = null;
|
||||
|
||||
public function __construct($data = [], $payload = [])
|
||||
{
|
||||
$this->data = new Registry($data);
|
||||
|
||||
$fieldParams = isset($data['fieldparams']) ? $data['fieldparams'] : [];
|
||||
$this->fieldParams = new Registry($fieldParams);
|
||||
|
||||
if ($payload)
|
||||
{
|
||||
$this->payload = $payload;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the field's JSON data for previewer to render it.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function saveJSON()
|
||||
{
|
||||
// Get path to file
|
||||
$file = implode(DIRECTORY_SEPARATOR, [\ACF\Helpers\Previewer::getJsonDirectory(), $this->data->get('type') . '.json']);
|
||||
|
||||
// Save JSON file
|
||||
file_put_contents($file, $this->getHTML());
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the field.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
if (method_exists($this, 'onSetup'))
|
||||
{
|
||||
$this->onSetup();
|
||||
}
|
||||
|
||||
$this->saveJSON();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the field.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return $this->widget->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Field HTML output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getHTML()
|
||||
{
|
||||
return '<html><head>' . $this->getHead() . '</head><body>' . $this->render() . '</body></html>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the head of the preview HTML.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getHead()
|
||||
{
|
||||
if (!$assets = $this->getAssets())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add Reset CSS
|
||||
$head = '<style>' . $this->getResetCSS() . '</style>';
|
||||
|
||||
// Add Custom CSS
|
||||
if (isset($assets['custom_css']) && !empty($assets['custom_css']))
|
||||
{
|
||||
$head .= '<style>' . $assets['custom_css'] . '</style>';
|
||||
}
|
||||
|
||||
$base_url = Uri::root();
|
||||
|
||||
// Add CSS
|
||||
if (isset($assets['css']) && is_array($assets['css']) && count($assets['css']))
|
||||
{
|
||||
foreach ($assets['css'] as $css)
|
||||
{
|
||||
$css = str_replace('plg_system_nrframework/', 'plg_system_nrframework/css/', $css);
|
||||
|
||||
$link = $base_url . 'media/' . $css;
|
||||
|
||||
$head .= '<link href="' . $link . '" rel="stylesheet" />';
|
||||
}
|
||||
}
|
||||
|
||||
// Add Core JS
|
||||
$head .= '<script src="' . $base_url . 'media/system/js/core.js"></script>';
|
||||
|
||||
// Add JS
|
||||
if (isset($assets['js']) && is_array($assets['js']) && count($assets['js']))
|
||||
{
|
||||
foreach ($assets['js'] as $js)
|
||||
{
|
||||
$js = str_replace('plg_system_nrframework/', 'plg_system_nrframework/js/', $js);
|
||||
|
||||
$link = $base_url . 'media/' . $js;
|
||||
|
||||
$head .= '<script src="' . $link . '"></script>';
|
||||
}
|
||||
}
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the field reset CSS.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getResetCSS()
|
||||
{
|
||||
$reset_css = '
|
||||
body {
|
||||
border: 0 !important;
|
||||
background: #fff !important;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
overflow-x: hidden !important;
|
||||
font-family: Arial;
|
||||
font-size: 16px;
|
||||
}
|
||||
';
|
||||
|
||||
return $reset_css . $this->getFieldPreviewerCSS();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds some extra CSS to the previewer's body.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getFieldPreviewerCSS()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* The CSS/JS assets that are required for the field to run.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getAssets()
|
||||
{
|
||||
return [
|
||||
'css' => $this->getFieldCSS(),
|
||||
'js' => $this->getFieldJS(),
|
||||
'custom_css' => $this->widget->getOption('css_vars') . $this->widget->getOption('custom_css')
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the field CSS files.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getFieldCSS()
|
||||
{
|
||||
return $this->widget && method_exists($this->widget, 'getCSS') ? $this->widget->getCSS() : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the field JS files.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getFieldJS()
|
||||
{
|
||||
return $this->widget && method_exists($this->widget, 'getJS') ? $this->widget->getJS() : [];
|
||||
}
|
||||
}
|
||||
0
plugins/system/acf/ACF/index.php
Normal file
0
plugins/system/acf/ACF/index.php
Normal file
Reference in New Issue
Block a user