65 lines
1.6 KiB
PHP
65 lines
1.6 KiB
PHP
<?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();
|
|
}
|
|
} |