acf
This commit is contained in:
87
plugins/fields/acffaq/acffaq.php
Normal file
87
plugins/fields/acffaq/acffaq.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?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\Form\Form;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
|
||||
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 PlgFieldsACFFAQ extends ACF_Field
|
||||
{
|
||||
/**
|
||||
* Override the field type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $overrideType = 'FAQ';
|
||||
|
||||
/**
|
||||
* The form event. Load additional parameters when available into the field form.
|
||||
* Only when the type of the form is of interest.
|
||||
*
|
||||
* @param JForm $form The form
|
||||
* @param stdClass $data The data
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function onContentPrepareForm(Form $form, $data)
|
||||
{
|
||||
$data = (object) $data;
|
||||
|
||||
// Make sure we are manipulating the right field.
|
||||
if (isset($data->type) && $data->type != $this->_name)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the configuration for the templates.
|
||||
*
|
||||
* These are handed over to Javascript and
|
||||
* whenever we click on a preset, these values
|
||||
* are set to each setting on the backend.
|
||||
*/
|
||||
if (Factory::getApplication()->isClient('administrator'))
|
||||
{
|
||||
Text::script('ACF_FIELD_PREVIEWER');
|
||||
Text::script('ACF_FIELD_PREVIEWER_INFO_ICON_TITLE');
|
||||
|
||||
// Include presets
|
||||
include 'fields/helper.php';
|
||||
|
||||
$script = 'window.ACFFAQPresetsData = ' . json_encode($presets) . ';';
|
||||
Factory::getDocument()->addScriptDeclaration($script);
|
||||
HTMLHelper::script('plg_system_nrframework/tffieldsvaluesapplier.js', ['relative' => true, 'version' => 'auto']);
|
||||
HTMLHelper::script('plg_fields_acffaq/faq.js', ['relative' => true, 'version' => 'auto']);
|
||||
|
||||
$script = 'window.ACFFieldsPreviewerData = ' . json_encode([
|
||||
'fullscreenActions' => true,
|
||||
'responsiveControls' => true
|
||||
]) . ';';
|
||||
Factory::getDocument()->addScriptDeclaration($script);
|
||||
HTMLHelper::script('plg_fields_acffaq/previewer.js', ['relative' => true, 'version' => 'auto']);
|
||||
}
|
||||
|
||||
|
||||
return parent::onContentPrepareForm($form, $data);
|
||||
}
|
||||
}
|
||||
26
plugins/fields/acffaq/acffaq.xml
Normal file
26
plugins/fields/acffaq/acffaq.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<extension type="plugin" version="3.7.0" group="fields" method="upgrade">
|
||||
<name>ACF_FAQ</name>
|
||||
<description>ACF_FAQ_DESC</description>
|
||||
<author>Tassos Marinos</author>
|
||||
<creationDate>April 2023</creationDate>
|
||||
<copyright>Copyright (C) 2023 Tassos Marinos. All rights reserved.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>info@tassos.gr</authorEmail>
|
||||
<authorUrl>www.tassos.gr</authorUrl>
|
||||
<version>1.0</version>
|
||||
<scriptfile>script.install.php</scriptfile>
|
||||
<files>
|
||||
<filename plugin="acffaq">acffaq.php</filename>
|
||||
<filename>script.install.helper.php</filename>
|
||||
<filename>version.php</filename>
|
||||
<folder>fields</folder>
|
||||
<folder>language</folder>
|
||||
<folder>params</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<media folder="media" destination="plg_fields_acffaq">
|
||||
<folder>js</folder>
|
||||
<folder>img</folder>
|
||||
</media>
|
||||
</extension>
|
||||
57
plugins/fields/acffaq/fields/faq.php
Normal file
57
plugins/fields/acffaq/fields/faq.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Form\Field\SubformField;
|
||||
|
||||
class JFormFieldFAQ extends SubformField
|
||||
{
|
||||
/**
|
||||
* Method to attach a JForm object to the field.
|
||||
*
|
||||
* @param SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object.
|
||||
* @param mixed $value The form field value to validate.
|
||||
* @param string $group The field name group control value.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 3.6
|
||||
*/
|
||||
public function setup(SimpleXMLElement $element, $value, $group = null)
|
||||
{
|
||||
if (!parent::setup($element, $value, $group))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$xml = <<<XML
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form>
|
||||
<field
|
||||
name="value"
|
||||
type="subform"
|
||||
hiddenLabel="true"
|
||||
multiple="true"
|
||||
layout="joomla.form.field.subform.repeatable-table"
|
||||
formsource="/plugins/fields/acffaq/fields/value.xml"
|
||||
default='{"faq":{}}'
|
||||
/>
|
||||
</form>
|
||||
XML;
|
||||
$this->formsource = $xml;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getInput()
|
||||
{
|
||||
return '<div class="tf-subform-hide-label">' . parent::getInput() . '</div>';
|
||||
}
|
||||
}
|
||||
34
plugins/fields/acffaq/fields/faqschematoggle.php
Normal file
34
plugins/fields/acffaq/fields/faqschematoggle.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once JPATH_PLUGINS . '/system/nrframework/fields/nrtoggle.php';
|
||||
|
||||
use NRFramework\Extension;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
class JFormFieldFAQSchemaToggle extends JFormFieldNRToggle
|
||||
{
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*/
|
||||
public function getInput()
|
||||
{
|
||||
// If GSD Pro is not installed and activated abort
|
||||
if (!Extension::isInstalled('gsd', 'plugin') || !Extension::isPro('plg_system_gsd'))
|
||||
{
|
||||
return '<div class="alert alert-warning">' . Text::_('ACF_FAQ_SCHEMA_GSD_MISSING') . '</div>';
|
||||
}
|
||||
|
||||
return parent::getInput();
|
||||
}
|
||||
}
|
||||
100
plugins/fields/acffaq/fields/helper.php
Normal file
100
plugins/fields/acffaq/fields/helper.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
$presets = [
|
||||
1 => [
|
||||
'separator' => [
|
||||
'type' => 'nrtoggle',
|
||||
'value' => true
|
||||
],
|
||||
'show_toggle_icon' => [
|
||||
'type' => 'nrtoggle',
|
||||
'value' => true
|
||||
],
|
||||
'icon' => [
|
||||
'type' => 'radio',
|
||||
'value' => 'arrow'
|
||||
],
|
||||
'icon_position' => [
|
||||
'type' => 'radio',
|
||||
'value' => 'right'
|
||||
],
|
||||
],
|
||||
2 => [
|
||||
'separator' => [
|
||||
'type' => 'nrtoggle',
|
||||
'value' => true
|
||||
],
|
||||
'show_toggle_icon' => [
|
||||
'type' => 'nrtoggle',
|
||||
'value' => true
|
||||
],
|
||||
'icon' => [
|
||||
'type' => 'radio',
|
||||
'value' => 'plus_minus'
|
||||
],
|
||||
'icon_position' => [
|
||||
'type' => 'radio',
|
||||
'value' => 'left'
|
||||
],
|
||||
],
|
||||
3 => [
|
||||
'initial_state' => [
|
||||
'type' => 'list',
|
||||
'value' => 'all-open'
|
||||
],
|
||||
'keep_one_question_open' => [
|
||||
'type' => 'nrtoggle',
|
||||
'value' => false
|
||||
],
|
||||
'separator' => [
|
||||
'type' => 'nrtoggle',
|
||||
'value' => true
|
||||
],
|
||||
'show_toggle_icon' => [
|
||||
'type' => 'nrtoggle',
|
||||
'value' => false
|
||||
]
|
||||
],
|
||||
4 => [
|
||||
'separator' => [
|
||||
'type' => 'nrtoggle',
|
||||
'value' => false
|
||||
],
|
||||
'background_color' => [
|
||||
'type' => 'text',
|
||||
'value' => '#fff'
|
||||
],
|
||||
'item_padding' => [
|
||||
'type' => 'number',
|
||||
'responsive' => true,
|
||||
'dimensions' => true,
|
||||
'value' => 20
|
||||
],
|
||||
'item_gap' => [
|
||||
'type' => 'number',
|
||||
'responsive' => true,
|
||||
'value' => 14
|
||||
],
|
||||
'show_toggle_icon' => [
|
||||
'type' => 'nrtoggle',
|
||||
'value' => true
|
||||
],
|
||||
'icon' => [
|
||||
'type' => 'radio',
|
||||
'value' => 'arrow'
|
||||
],
|
||||
'icon_position' => [
|
||||
'type' => 'radio',
|
||||
'value' => 'right'
|
||||
],
|
||||
]
|
||||
];
|
||||
19
plugins/fields/acffaq/fields/value.xml
Normal file
19
plugins/fields/acffaq/fields/value.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fieldset>
|
||||
<field name="question" type="tfeditor"
|
||||
label="ACF_FAQ_QUESTION"
|
||||
hint="ACF_FAQ_QUESTION_HINT"
|
||||
class="span12 full-width w-100"
|
||||
rows="10"
|
||||
filter="raw"
|
||||
/>
|
||||
<field name="answer" type="tfeditor"
|
||||
label="ACF_FAQ_ANSWER"
|
||||
hint="ACF_FAQ_ANSWER_HINT"
|
||||
class="span12 full-width w-100"
|
||||
rows="10"
|
||||
filter="raw"
|
||||
/>
|
||||
</fieldset>
|
||||
</form>
|
||||
@ -0,0 +1,57 @@
|
||||
; @package Advanced Custom Fields
|
||||
; @version 2.8.8 Pro
|
||||
;
|
||||
; @author Tassos Marinos - http://www.tassos.gr/joomla-extensions
|
||||
; @copyright Copyright (c) 2020 Tassos Marinos. All rights reserved.
|
||||
; @license http://www.tassos.gr
|
||||
|
||||
PLG_FIELDS_ACFFAQ_LABEL="ACF - FAQ"
|
||||
ACF_FAQ="Fields - ACF FAQ"
|
||||
ACF_FAQ_VALUE_DESC="Enter your questions and answers to display a FAQ section."
|
||||
ACF_FAQ_DESC="Add a Frequently Asked Questions section to your site."
|
||||
ACF_FAQ_TEMPLATE_SELECTOR="Template Selector"
|
||||
ACF_FAQ_TEMPLATE="Template"
|
||||
ACF_FAQ_TEMPLATE_DESC="Select the FAQ template."
|
||||
ACF_FAQ_FAQ="FAQ"
|
||||
ACF_FAQ_SHOW_TOGGLE_ICON="Show Toggle Icon"
|
||||
ACF_FAQ_SHOW_TOGGLE_ICON_DESC="Enable to make the question answer show/hide via an icon."
|
||||
ACF_FAQ_INITIAL_STATE="Initial State"
|
||||
ACF_FAQ_INITIAL_STATE_DESC="Select the initial state of the FAQ."
|
||||
ACF_FAQ_INITIAL_STATE_FIRST_OPEN="Show first question as open"
|
||||
ACF_FAQ_INITIAL_STATE_ALL_OPEN="Show all questions as open"
|
||||
ACF_FAQ_INITIAL_STATE_ALL_CLOSED="Show all questions as closed"
|
||||
ACF_FAQ_COLUMNS="Columns"
|
||||
ACF_FAQ_COLUMNS_DESC="Define in how many columns to show the FAQ."
|
||||
ACF_FAQ_ITEM_GAP="Item Gap"
|
||||
ACF_FAQ_ITEM_GAP_DESC="Define the item gap between the FAQ items."
|
||||
ACF_FAQ_COLUMN_GAP="Column Gap"
|
||||
ACF_FAQ_COLUMN_GAP_DESC="Define the column gap between the FAQ columns."
|
||||
ACF_FAQ_ITEM="FAQ Item"
|
||||
ACF_FAQ_ITEM_BACKGROUND_COLOR="Background Color"
|
||||
ACF_FAQ_ITEM_BACKGROUND_COLOR_DESC="Set the FAQ item background color."
|
||||
ACF_FAQ_QUESTION_TEXT_COLOR="Question Text Color"
|
||||
ACF_FAQ_QUESTION_TEXT_COLOR_DESC="Set the FAQ question text color."
|
||||
ACF_FAQ_ANSWER_TEXT_COLOR="Answer Text Color"
|
||||
ACF_FAQ_ANSWER_TEXT_COLOR_DESC="Set the FAQ answer text color."
|
||||
ACF_FAQ_BORDER_RADIUS_DESC="Set the FAQ item border radius."
|
||||
ACF_FAQ_ITEM_PADDING="Padding"
|
||||
ACF_FAQ_ITEM_PADDING_DESC="Set the FAQ item padding."
|
||||
ACF_FAQ_ICON="Icon"
|
||||
ACF_FAQ_ICON_DESC="Select the toggle icon."
|
||||
ACF_FAQ_ICON_POSITION="Icon Position"
|
||||
ACF_FAQ_ICON_POSITION_DESC="Set the icon position. Whether to display it on the left or right side of the question."
|
||||
ACF_FAQ_QUESTION="Question"
|
||||
ACF_FAQ_QUESTION_HINT="Type a question"
|
||||
ACF_FAQ_ANSWER="Answer"
|
||||
ACF_FAQ_ANSWER_HINT="Type an answer"
|
||||
ACF_FAQ_QUESTION_FONT_SIZE_DESC="Set the question font size."
|
||||
ACF_FAQ_ANSWER_FONT_SIZE_DESC="Set the answer font size."
|
||||
ACF_FAQ_GENERATE_FAQ="Generate FAQ Schema"
|
||||
ACF_FAQ_GENERATE_FAQ_DESC="Enable to generate FAQ Schema for your questions and answers."
|
||||
ACF_FAQ_SCHEMA_GSD_MISSING="The Pro version of the <a href='https://www.tassos.gr/joomla-extensions/google-structured-data-markup' target='_blank'>Google Structured Data</a> extension is required to generate the FAQ Schema."
|
||||
ACF_FAQ_KEEP_ONE_QUESTION_OPEN="Keep One Question Open"
|
||||
ACF_FAQ_KEEP_ONE_QUESTION_OPEN_DESC="Enable to only keep one question open at a time."
|
||||
ACF_FAQ_SEPARATOR="Separator"
|
||||
ACF_FAQ_SEPARATOR_DESC="Enable to add a horizontal separator between FAQ items."
|
||||
ACF_FAQ_SEPARATOR_COLOR="Separator Color"
|
||||
ACF_FAQ_SEPARATOR_COLOR_DESC="Set the color of the separator."
|
||||
@ -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) 2020 Tassos Marinos. All rights reserved.
|
||||
; @license http://www.tassos.gr
|
||||
|
||||
ACF_FAQ="Fields - ACF FAQ"
|
||||
ACF_FAQ_DESC="Add a Frequently Asked Questions section to your site."
|
||||
@ -0,0 +1,57 @@
|
||||
; @package Advanced Custom Fields
|
||||
; @version 2.8.8 Pro
|
||||
;
|
||||
; @author Tassos Marinos - http://www.tassos.gr/joomla-extensions
|
||||
; @copyright Copyright (c) 2020 Tassos Marinos. All rights reserved.
|
||||
; @license http://www.tassos.gr
|
||||
|
||||
PLG_FIELDS_ACFFAQ_LABEL="ACF - FAQ"
|
||||
ACF_FAQ="Campos - ACF FAQ"
|
||||
ACF_FAQ_VALUE_DESC="Ingrese sus preguntas y respuestas para mostrar una sección de preguntas frecuentes."
|
||||
ACF_FAQ_DESC="Agregue una sección de Preguntas frecuentes a su sitio."
|
||||
ACF_FAQ_TEMPLATE_SELECTOR="Selector de Plantillas"
|
||||
ACF_FAQ_TEMPLATE="Plantilla"
|
||||
ACF_FAQ_TEMPLATE_DESC="Seleccione la plantila de FAQ"
|
||||
ACF_FAQ_FAQ="FAQ"
|
||||
ACF_FAQ_SHOW_TOGGLE_ICON="Mostrar Icono de Alternar"
|
||||
ACF_FAQ_SHOW_TOGGLE_ICON_DESC="Habilite para que la respuesta a la pregunta se muestre/oculte a través de un icono."
|
||||
ACF_FAQ_INITIAL_STATE="Estado Inicial"
|
||||
ACF_FAQ_INITIAL_STATE_DESC="Seleccione el estado inicial de las preguntas frecuentes FAQ."
|
||||
ACF_FAQ_INITIAL_STATE_FIRST_OPEN="Mostrar la primera pregunta como abierta"
|
||||
ACF_FAQ_INITIAL_STATE_ALL_OPEN="Mostrar todas las preguntas como abiertas"
|
||||
ACF_FAQ_INITIAL_STATE_ALL_CLOSED="Mostrar todas las preguntas como cerradas"
|
||||
ACF_FAQ_COLUMNS="Columnas"
|
||||
ACF_FAQ_COLUMNS_DESC="Defina en cuántas columnas mostrar las preguntas frecuentes."
|
||||
ACF_FAQ_ITEM_GAP="Espaciado de Elementos"
|
||||
ACF_FAQ_ITEM_GAP_DESC="Defina el espaciado entre los elementos de las preguntas frecuentes."
|
||||
ACF_FAQ_COLUMN_GAP="Espaciado de Columnas"
|
||||
ACF_FAQ_COLUMN_GAP_DESC="Defina el espacio de columna entre las columnas de preguntas frecuentes."
|
||||
ACF_FAQ_ITEM="Elementos FAQ"
|
||||
ACF_FAQ_ITEM_BACKGROUND_COLOR="Color de Fondo"
|
||||
ACF_FAQ_ITEM_BACKGROUND_COLOR_DESC="Establezca el color de fondo del elemento de preguntas frecuentes."
|
||||
ACF_FAQ_QUESTION_TEXT_COLOR="Color del texto de la pregunta"
|
||||
ACF_FAQ_QUESTION_TEXT_COLOR_DESC="Establezca el color del texto de la pregunta de preguntas frecuentes."
|
||||
ACF_FAQ_ANSWER_TEXT_COLOR="Color Texto de Respuesta"
|
||||
ACF_FAQ_ANSWER_TEXT_COLOR_DESC="Establezca el color del texto de la respuesta a las preguntas frecuentes."
|
||||
ACF_FAQ_BORDER_RADIUS_DESC="Establezca el radio del borde del elemento de preguntas frecuentes."
|
||||
ACF_FAQ_ITEM_PADDING="Relleno"
|
||||
ACF_FAQ_ITEM_PADDING_DESC="Establezca el relleno del elemento de preguntas frecuentes."
|
||||
ACF_FAQ_ICON="Icono"
|
||||
ACF_FAQ_ICON_DESC="Seleccione el icono de alternancia."
|
||||
ACF_FAQ_ICON_POSITION="Posición del Icono"
|
||||
ACF_FAQ_ICON_POSITION_DESC="Establecer la posición del icono. Ya sea para mostrarlo en el lado izquierdo o derecho de la pregunta."
|
||||
ACF_FAQ_QUESTION="Pregunta"
|
||||
ACF_FAQ_QUESTION_HINT="Escriba una pregunta"
|
||||
ACF_FAQ_ANSWER="Respuesta"
|
||||
ACF_FAQ_ANSWER_HINT="Escriba una respuesta"
|
||||
ACF_FAQ_QUESTION_FONT_SIZE_DESC="Establezca el tamaño de fuente de la pregunta."
|
||||
ACF_FAQ_ANSWER_FONT_SIZE_DESC="Establezca el tamaño de fuente de la respuesta."
|
||||
ACF_FAQ_GENERATE_FAQ="Generar Esquema de FAQ"
|
||||
ACF_FAQ_GENERATE_FAQ_DESC="Habilite para generar un esquema de preguntas frecuentes para sus preguntas y respuestas."
|
||||
ACF_FAQ_SCHEMA_GSD_MISSING="La versión Pro de la extensión <a href='https://www.tassos.gr/joomla-extensions/google-structured-data-markup' target='_blank'>Google Structured Data</a> es necesaria para generar el Esquema FAQ."
|
||||
ACF_FAQ_KEEP_ONE_QUESTION_OPEN="Mantenga una pregunta abierta"
|
||||
ACF_FAQ_KEEP_ONE_QUESTION_OPEN_DESC="Habilite para mantener solo una pregunta abierta a la vez."
|
||||
ACF_FAQ_SEPARATOR="Separador"
|
||||
ACF_FAQ_SEPARATOR_DESC="Habilite para agregar un separador horizontal entre los elementos de preguntas frecuentes."
|
||||
ACF_FAQ_SEPARATOR_COLOR="Color del Separador"
|
||||
ACF_FAQ_SEPARATOR_COLOR_DESC="Establezca el color del separador."
|
||||
@ -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) 2020 Tassos Marinos. All rights reserved.
|
||||
; @license http://www.tassos.gr
|
||||
|
||||
ACF_FAQ="Campos - ACF FAQ"
|
||||
ACF_FAQ_DESC="Agregue una sección de Preguntas frecuentes a su sitio."
|
||||
194
plugins/fields/acffaq/params/acffaq.xml
Normal file
194
plugins/fields/acffaq/params/acffaq.xml
Normal file
@ -0,0 +1,194 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form>
|
||||
<fields name="fieldparams" addfieldpath="plugins/fields/acffaq/fields">
|
||||
<fieldset name="fieldparams">
|
||||
<!-- Template Selector -->
|
||||
<field name="a" type="spacer" class="acf" label="ACF_FAQ_TEMPLATE_SELECTOR" />
|
||||
<field name="template" type="NRImagesSelector"
|
||||
images="/media/plg_fields_acffaq/img/templates"
|
||||
class="acf-faq-template-selector no-padding"
|
||||
width="900px"
|
||||
columns="4"
|
||||
default="1"
|
||||
label="ACF_FAQ_TEMPLATE"
|
||||
description="ACF_FAQ_TEMPLATE_DESC"
|
||||
key_type="filename"
|
||||
/>
|
||||
|
||||
<!-- FAQ -->
|
||||
<field name="b" type="spacer" class="acf" label="ACF_FAQ_FAQ" />
|
||||
<field name="initial_state" type="list"
|
||||
label="ACF_FAQ_INITIAL_STATE"
|
||||
description="ACF_FAQ_INITIAL_STATE_DESC"
|
||||
default="first-open"
|
||||
>
|
||||
<option value="first-open">ACF_FAQ_INITIAL_STATE_FIRST_OPEN</option>
|
||||
<option value="all-open">ACF_FAQ_INITIAL_STATE_ALL_OPEN</option>
|
||||
<option value="all-closed">ACF_FAQ_INITIAL_STATE_ALL_CLOSED</option>
|
||||
</field>
|
||||
<field name="keep_one_question_open" type="NRToggle"
|
||||
label="ACF_FAQ_KEEP_ONE_QUESTION_OPEN"
|
||||
description="ACF_FAQ_KEEP_ONE_QUESTION_OPEN_DESC"
|
||||
checked="true"
|
||||
/>
|
||||
<field name="columns" type="number"
|
||||
label="ACF_FAQ_COLUMNS"
|
||||
description="ACF_FAQ_COLUMNS_DESC"
|
||||
class="input-small"
|
||||
default="1"
|
||||
hint="3"
|
||||
min="1"
|
||||
max="6"
|
||||
/>
|
||||
<field name="item_gap_control" type="NRResponsiveControl"
|
||||
label="ACF_FAQ_ITEM_GAP"
|
||||
description="ACF_FAQ_ITEM_GAP_DESC">
|
||||
<subform>
|
||||
<field name="item_gap" type="nrnumber"
|
||||
class="input-small"
|
||||
default="20"
|
||||
hint="10"
|
||||
min="1"
|
||||
addon="px" />
|
||||
</subform>
|
||||
</field>
|
||||
<field name="column_gap_control" type="NRResponsiveControl"
|
||||
label="ACF_FAQ_COLUMN_GAP"
|
||||
description="ACF_FAQ_COLUMN_GAP_DESC"
|
||||
showon="columns!:1">
|
||||
<subform>
|
||||
<field name="column_gap" type="nrnumber"
|
||||
class="input-small"
|
||||
default="20"
|
||||
hint="10"
|
||||
min="1"
|
||||
addon="px" />
|
||||
</subform>
|
||||
</field>
|
||||
<field name="separator" type="NRToggle"
|
||||
label="ACF_FAQ_SEPARATOR"
|
||||
description="ACF_FAQ_SEPARATOR_DESC"
|
||||
checked="true"
|
||||
/>
|
||||
<field name="separator_color" type="color"
|
||||
label="ACF_FAQ_SEPARATOR_COLOR"
|
||||
description="ACF_FAQ_SEPARATOR_COLOR_DESC"
|
||||
keywords="transparent,none"
|
||||
format="rgba"
|
||||
position="bottom"
|
||||
default="#dedede"
|
||||
showon="separator:1"
|
||||
/>
|
||||
|
||||
<!-- Item -->
|
||||
<field name="c" type="spacer" class="acf" label="ACF_FAQ_ITEM" />
|
||||
<field name="background_color" type="color"
|
||||
label="ACF_FAQ_ITEM_BACKGROUND_COLOR"
|
||||
description="ACF_FAQ_ITEM_BACKGROUND_COLOR_DESC"
|
||||
keywords="transparent,none"
|
||||
format="rgba"
|
||||
position="bottom"
|
||||
/>
|
||||
<field name="border_radius_control" type="NRResponsiveControl"
|
||||
label="NR_BORDER_RADIUS"
|
||||
description="ACF_FAQ_ITEM_BORDER_RADIUS_DESC">
|
||||
<subform>
|
||||
<field
|
||||
name="item_border_radius"
|
||||
type="TFBorderRadiusControl" />
|
||||
</subform>
|
||||
</field>
|
||||
<field name="padding_control" type="NRResponsiveControl"
|
||||
label="ACF_FAQ_ITEM_PADDING"
|
||||
description="ACF_FAQ_ITEM_PADDING_DESC">
|
||||
<subform>
|
||||
<field
|
||||
name="item_padding"
|
||||
type="TFDimensionControl" />
|
||||
</subform>
|
||||
</field>
|
||||
|
||||
<!-- Question -->
|
||||
<field name="d" type="spacer" class="acf" label="ACF_FAQ_QUESTION" />
|
||||
<field name="question_text_color" type="color"
|
||||
label="ACF_FAQ_QUESTION_TEXT_COLOR"
|
||||
description="ACF_FAQ_QUESTION_TEXT_COLOR_DESC"
|
||||
keywords="transparent,none"
|
||||
format="rgba"
|
||||
position="bottom"
|
||||
/>
|
||||
<field name="question_font_size_control" type="NRResponsiveControl"
|
||||
label="NR_FONT_SIZE"
|
||||
default='{"desktop": {"question_font_size": 16}}'
|
||||
description="ACF_FAQ_QUESTION_FONT_SIZE_DESC">
|
||||
<subform>
|
||||
<field
|
||||
name="question_font_size"
|
||||
type="nrnumber"
|
||||
hint="16"
|
||||
class="input-small"
|
||||
addon="px" />
|
||||
</subform>
|
||||
</field>
|
||||
|
||||
<!-- Answer -->
|
||||
<field name="e" type="spacer" class="acf" label="ACF_FAQ_ANSWER" />
|
||||
<field name="answer_text_color" type="color"
|
||||
label="ACF_FAQ_ANSWER_TEXT_COLOR"
|
||||
description="ACF_FAQ_ANSWER_TEXT_COLOR_DESC"
|
||||
keywords="transparent,none"
|
||||
format="rgba"
|
||||
position="bottom"
|
||||
/>
|
||||
<field name="answer_font_size_control" type="NRResponsiveControl"
|
||||
label="NR_FONT_SIZE"
|
||||
default='{"desktop": {"answer_font_size": 16}}'
|
||||
description="ACF_FAQ_ANSWER_FONT_SIZE_DESC">
|
||||
<subform>
|
||||
<field
|
||||
name="answer_font_size"
|
||||
type="nrnumber"
|
||||
hint="16"
|
||||
class="input-small"
|
||||
addon="px" />
|
||||
</subform>
|
||||
</field>
|
||||
|
||||
<!-- Icon -->
|
||||
<field name="f" type="spacer" class="acf" label="ACF_FAQ_ICON" />
|
||||
<field name="show_toggle_icon" type="NRToggle"
|
||||
label="ACF_FAQ_SHOW_TOGGLE_ICON"
|
||||
description="ACF_FAQ_SHOW_TOGGLE_ICON_DESC"
|
||||
showon="template!:2"
|
||||
checked="true"
|
||||
/>
|
||||
<field name="icon" type="NRImagesSelector"
|
||||
images="/media/plg_fields_acffaq/img/icons"
|
||||
class="acf-faq-icon-selector row-flex-direction-row"
|
||||
columns="4"
|
||||
default="arrow"
|
||||
label="ACF_FAQ_ICON"
|
||||
description="ACF_FAQ_ICON_DESC"
|
||||
key_type="filename"
|
||||
showon="show_toggle_icon:1"
|
||||
/>
|
||||
<field name="icon_position" type="radio"
|
||||
label="ACF_FAQ_ICON_POSITION"
|
||||
description="ACF_FAQ_ICON_POSITION_DESC"
|
||||
class="btn-group btn-group-yesno"
|
||||
showon="show_toggle_icon:1[AND]template!:2"
|
||||
default="right">
|
||||
<option value="left">NR_LEFT</option>
|
||||
<option value="right">NR_RIGHT</option>
|
||||
</field>
|
||||
|
||||
<!-- FAQ Structured Data -->
|
||||
<field name="g" type="spacer" class="acf" label="ACF_FAQ_GENERATE_FAQ" />
|
||||
<field name="generate_faq" type="FAQSchemaToggle"
|
||||
label="ACF_FAQ_GENERATE_FAQ"
|
||||
description="ACF_FAQ_GENERATE_FAQ_DESC"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
|
||||
691
plugins/fields/acffaq/script.install.helper.php
Normal file
691
plugins/fields/acffaq/script.install.helper.php
Normal file
@ -0,0 +1,691 @@
|
||||
<?php
|
||||
/**
|
||||
* Installer Script Helper
|
||||
*
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2016 Tassos Marinos All Rights Reserved
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Installer\Installer;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\Filesystem\File;
|
||||
use Joomla\Filesystem\Folder;
|
||||
|
||||
class PlgFieldsAcffaqInstallerScriptHelper
|
||||
{
|
||||
public $name = '';
|
||||
public $alias = '';
|
||||
public $extname = '';
|
||||
public $extension_type = '';
|
||||
public $plugin_folder = 'system';
|
||||
public $module_position = 'status';
|
||||
public $client_id = 1;
|
||||
public $install_type = 'install';
|
||||
public $show_message = true;
|
||||
public $autopublish = true;
|
||||
public $db = null;
|
||||
public $app = null;
|
||||
public $installedVersion;
|
||||
|
||||
public function __construct(&$params)
|
||||
{
|
||||
$this->extname = $this->extname ?: $this->alias;
|
||||
$this->db = Factory::getDbo();
|
||||
$this->app = Factory::getApplication();
|
||||
$this->installedVersion = $this->getVersion($this->getInstalledXMLFile());
|
||||
}
|
||||
|
||||
/**
|
||||
* Preflight event
|
||||
*
|
||||
* @param string
|
||||
* @param JAdapterInstance
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function preflight($route, $adapter)
|
||||
{
|
||||
if (!in_array($route, array('install', 'update')))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Factory::getLanguage()->load('plg_system_novaraininstaller', JPATH_PLUGINS . '/system/novaraininstaller');
|
||||
|
||||
if ($this->show_message && $this->isInstalled())
|
||||
{
|
||||
$this->install_type = 'update';
|
||||
}
|
||||
|
||||
if ($this->onBeforeInstall() === false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Preflight event
|
||||
*
|
||||
* @param string
|
||||
* @param JAdapterInstance
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function postflight($route, $adapter)
|
||||
{
|
||||
Factory::getLanguage()->load($this->getPrefix() . '_' . $this->extname, $this->getMainFolder());
|
||||
|
||||
if (!in_array($route, array('install', 'update')))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->onAfterInstall() === false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($route == 'install' && $this->autopublish)
|
||||
{
|
||||
$this->publishExtension();
|
||||
}
|
||||
|
||||
if ($this->show_message)
|
||||
{
|
||||
$this->addInstalledMessage();
|
||||
}
|
||||
|
||||
Factory::getCache()->clean('com_plugins');
|
||||
Factory::getCache()->clean('_system');
|
||||
}
|
||||
|
||||
public function isInstalled()
|
||||
{
|
||||
if (!is_file($this->getInstalledXMLFile()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$query = $this->db->getQuery(true)
|
||||
->select('extension_id')
|
||||
->from('#__extensions')
|
||||
->where($this->db->quoteName('type') . ' = ' . $this->db->quote($this->extension_type))
|
||||
->where($this->db->quoteName('element') . ' = ' . $this->db->quote($this->getElementName()));
|
||||
$this->db->setQuery($query, 0, 1);
|
||||
$result = $this->db->loadResult();
|
||||
|
||||
return empty($result) ? false : true;
|
||||
}
|
||||
|
||||
public function getMainFolder()
|
||||
{
|
||||
switch ($this->extension_type)
|
||||
{
|
||||
case 'plugin' :
|
||||
return JPATH_SITE . '/plugins/' . $this->plugin_folder . '/' . $this->extname;
|
||||
|
||||
case 'component' :
|
||||
return JPATH_ADMINISTRATOR . '/components/com_' . $this->extname;
|
||||
|
||||
case 'module' :
|
||||
return JPATH_ADMINISTRATOR . '/modules/mod_' . $this->extname;
|
||||
|
||||
case 'library' :
|
||||
return JPATH_SITE . '/libraries/' . $this->extname;
|
||||
}
|
||||
}
|
||||
|
||||
public function getInstalledXMLFile()
|
||||
{
|
||||
return $this->getXMLFile($this->getMainFolder());
|
||||
}
|
||||
|
||||
public function getCurrentXMLFile()
|
||||
{
|
||||
return $this->getXMLFile(__DIR__);
|
||||
}
|
||||
|
||||
public function getXMLFile($folder)
|
||||
{
|
||||
switch ($this->extension_type)
|
||||
{
|
||||
case 'module' :
|
||||
return $folder . '/mod_' . $this->extname . '.xml';
|
||||
default :
|
||||
return $folder . '/' . $this->extname . '.xml';
|
||||
}
|
||||
}
|
||||
|
||||
public function foldersExist($folders = array())
|
||||
{
|
||||
foreach ($folders as $folder)
|
||||
{
|
||||
if (is_dir($folder))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function publishExtension()
|
||||
{
|
||||
switch ($this->extension_type)
|
||||
{
|
||||
case 'plugin' :
|
||||
$this->publishPlugin();
|
||||
|
||||
case 'module' :
|
||||
$this->publishModule();
|
||||
}
|
||||
}
|
||||
|
||||
public function publishPlugin()
|
||||
{
|
||||
$query = $this->db->getQuery(true)
|
||||
->update('#__extensions')
|
||||
->set($this->db->quoteName('enabled') . ' = 1')
|
||||
->where($this->db->quoteName('type') . ' = ' . $this->db->quote('plugin'))
|
||||
->where($this->db->quoteName('element') . ' = ' . $this->db->quote($this->extname))
|
||||
->where($this->db->quoteName('folder') . ' = ' . $this->db->quote($this->plugin_folder));
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
}
|
||||
|
||||
public function publishModule()
|
||||
{
|
||||
// Get module id
|
||||
$query = $this->db->getQuery(true)
|
||||
->select('id')
|
||||
->from('#__modules')
|
||||
->where($this->db->quoteName('module') . ' = ' . $this->db->quote('mod_' . $this->extname))
|
||||
->where($this->db->quoteName('client_id') . ' = ' . (int) $this->client_id);
|
||||
$this->db->setQuery($query, 0, 1);
|
||||
$id = $this->db->loadResult();
|
||||
|
||||
if (!$id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// check if module is already in the modules_menu table (meaning is is already saved)
|
||||
$query->clear()
|
||||
->select('moduleid')
|
||||
->from('#__modules_menu')
|
||||
->where($this->db->quoteName('moduleid') . ' = ' . (int) $id);
|
||||
$this->db->setQuery($query, 0, 1);
|
||||
$exists = $this->db->loadResult();
|
||||
|
||||
if ($exists)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get highest ordering number in position
|
||||
$query->clear()
|
||||
->select('ordering')
|
||||
->from('#__modules')
|
||||
->where($this->db->quoteName('position') . ' = ' . $this->db->quote($this->module_position))
|
||||
->where($this->db->quoteName('client_id') . ' = ' . (int) $this->client_id)
|
||||
->order('ordering DESC');
|
||||
$this->db->setQuery($query, 0, 1);
|
||||
$ordering = $this->db->loadResult();
|
||||
$ordering++;
|
||||
|
||||
// publish module and set ordering number
|
||||
$query->clear()
|
||||
->update('#__modules')
|
||||
->set($this->db->quoteName('published') . ' = 1')
|
||||
->set($this->db->quoteName('ordering') . ' = ' . (int) $ordering)
|
||||
->set($this->db->quoteName('position') . ' = ' . $this->db->quote($this->module_position))
|
||||
->where($this->db->quoteName('id') . ' = ' . (int) $id);
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
|
||||
// add module to the modules_menu table
|
||||
$query->clear()
|
||||
->insert('#__modules_menu')
|
||||
->columns(array($this->db->quoteName('moduleid'), $this->db->quoteName('menuid')))
|
||||
->values((int) $id . ', 0');
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
}
|
||||
|
||||
public function addInstalledMessage()
|
||||
{
|
||||
Factory::getApplication()->enqueueMessage(
|
||||
Text::sprintf(
|
||||
Text::_($this->install_type == 'update' ? 'NRI_THE_EXTENSION_HAS_BEEN_UPDATED_SUCCESSFULLY' : 'NRI_THE_EXTENSION_HAS_BEEN_INSTALLED_SUCCESSFULLY'),
|
||||
'<strong>' . Text::_($this->name) . '</strong>',
|
||||
'<strong>' . $this->getVersion() . '</strong>',
|
||||
$this->getFullType()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getPrefix()
|
||||
{
|
||||
switch ($this->extension_type)
|
||||
{
|
||||
case 'plugin';
|
||||
return Text::_('plg_' . strtolower($this->plugin_folder));
|
||||
|
||||
case 'component':
|
||||
return Text::_('com');
|
||||
|
||||
case 'module':
|
||||
return Text::_('mod');
|
||||
|
||||
case 'library':
|
||||
return Text::_('lib');
|
||||
|
||||
default:
|
||||
return $this->extension_type;
|
||||
}
|
||||
}
|
||||
|
||||
public function getElementName($type = null, $extname = null)
|
||||
{
|
||||
$type = is_null($type) ? $this->extension_type : $type;
|
||||
$extname = is_null($extname) ? $this->extname : $extname;
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
case 'component' :
|
||||
return 'com_' . $extname;
|
||||
|
||||
case 'module' :
|
||||
return 'mod_' . $extname;
|
||||
|
||||
case 'plugin' :
|
||||
default:
|
||||
return $extname;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFullType()
|
||||
{
|
||||
return Text::_('NRI_' . strtoupper($this->getPrefix()));
|
||||
}
|
||||
|
||||
public function isPro()
|
||||
{
|
||||
$versionFile = __DIR__ . "/version.php";
|
||||
|
||||
// If version file does not exist we assume a PRO version
|
||||
if (!is_file($versionFile))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Load version file
|
||||
require_once $versionFile;
|
||||
return (bool) $NR_PRO;
|
||||
}
|
||||
|
||||
public function getVersion($file = '')
|
||||
{
|
||||
$file = $file ?: $this->getCurrentXMLFile();
|
||||
|
||||
if (!is_file($file))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$xml = Installer::parseXMLInstallFile($file);
|
||||
|
||||
if (!$xml || !isset($xml['version']))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return $xml['version'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks wether the extension can be installed or not
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canInstall()
|
||||
{
|
||||
// The extension is not installed yet. Accept Install.
|
||||
if (!$installed_version = $this->getVersion($this->getInstalledXMLFile()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Path to extension's version file
|
||||
$versionFile = $this->getMainFolder() . "/version.php";
|
||||
$NR_PRO = true;
|
||||
|
||||
// If version file does not exist we assume we have a PRO version installed
|
||||
if (file_exists($versionFile))
|
||||
{
|
||||
require_once($versionFile);
|
||||
}
|
||||
|
||||
// The free version is installed. Accept install.
|
||||
if (!(bool)$NR_PRO)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Current package is a PRO version. Accept install.
|
||||
if ($this->isPro())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// User is trying to update from PRO version to FREE. Do not accept install.
|
||||
Factory::getLanguage()->load($this->getPrefix() . '_' . $this->extname, __DIR__);
|
||||
|
||||
Factory::getApplication()->enqueueMessage(
|
||||
Text::_('NRI_ERROR_PRO_TO_FREE'), 'error'
|
||||
);
|
||||
|
||||
Factory::getApplication()->enqueueMessage(
|
||||
html_entity_decode(
|
||||
Text::sprintf(
|
||||
'NRI_ERROR_UNINSTALL_FIRST',
|
||||
'<a href="http://www.tassos.gr/joomla-extensions/' . $this->getUrlAlias() . '" target="_blank">',
|
||||
'</a>',
|
||||
Text::_($this->name)
|
||||
)
|
||||
), 'error'
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL alias of the extension.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getUrlAlias()
|
||||
{
|
||||
$alias = $this->alias;
|
||||
|
||||
switch ($alias)
|
||||
{
|
||||
case 'smilepack':
|
||||
$alias = 'smile-pack';
|
||||
break;
|
||||
case 'convertforms':
|
||||
$alias = 'convert-forms';
|
||||
break;
|
||||
case 'rstbox':
|
||||
$alias = 'engagebox';
|
||||
break;
|
||||
case 'gsd':
|
||||
$alias = 'google-structured-data';
|
||||
break;
|
||||
}
|
||||
|
||||
// ACF
|
||||
if ($this->plugin_folder === 'fields' && ($alias === 'acf' || $this->startsWith($alias, 'acf')))
|
||||
{
|
||||
$alias = 'advanced-custom-fields';
|
||||
}
|
||||
|
||||
return $alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether string starts with substring.
|
||||
*
|
||||
* @param string $string
|
||||
* @param string $query
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function startsWith($string, $query)
|
||||
{
|
||||
return substr($string, 0, strlen($query)) === $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if current version is newer than the installed one
|
||||
* Used for Novarain Framework
|
||||
*
|
||||
* @return boolean [description]
|
||||
*/
|
||||
public function isNewer()
|
||||
{
|
||||
if (!$installed_version = $this->getVersion($this->getInstalledXMLFile()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
$package_version = $this->getVersion();
|
||||
|
||||
return version_compare($installed_version, $package_version, '<=');
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method triggered before installation
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function onBeforeInstall()
|
||||
{
|
||||
if (!$this->canInstall())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method triggered after installation
|
||||
*/
|
||||
public function onAfterInstall()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete files
|
||||
*
|
||||
* @param array $folders
|
||||
*/
|
||||
public function deleteFiles($files = array())
|
||||
{
|
||||
foreach ($files as $key => $file)
|
||||
{
|
||||
if (!is_file($file))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
File::delete($file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes folders
|
||||
*
|
||||
* @param array $folders
|
||||
*/
|
||||
public function deleteFolders($folders = array())
|
||||
{
|
||||
foreach ($folders as $folder)
|
||||
{
|
||||
if (!is_dir($folder))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Folder::delete($folder);
|
||||
}
|
||||
}
|
||||
|
||||
public function dropIndex($table, $index)
|
||||
{
|
||||
$db = $this->db;
|
||||
|
||||
// Check if index exists first
|
||||
$query = 'SHOW INDEX FROM ' . $db->quoteName('#__' . $table) . ' WHERE KEY_NAME = ' . $db->quote($index);
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
if (!$db->loadResult())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove index
|
||||
$query = 'ALTER TABLE ' . $db->quoteName('#__' . $table) . ' DROP INDEX ' . $db->quoteName($index);
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
}
|
||||
|
||||
public function dropUnwantedTables($tables) {
|
||||
|
||||
if (!$tables) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($tables as $table) {
|
||||
$query = "DROP TABLE IF EXISTS #__".$this->db->escape($table);
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
}
|
||||
}
|
||||
|
||||
public function dropUnwantedColumns($table, $columns) {
|
||||
|
||||
if (!$columns || !$table) {
|
||||
return;
|
||||
}
|
||||
|
||||
$db = $this->db;
|
||||
|
||||
// Check if columns exists in database
|
||||
function qt($n) {
|
||||
return(Factory::getDBO()->quote($n));
|
||||
}
|
||||
|
||||
$query = 'SHOW COLUMNS FROM #__'.$table.' WHERE Field IN ('.implode(",", array_map("qt", $columns)).')';
|
||||
$db->setQuery($query);
|
||||
$rows = $db->loadColumn(0);
|
||||
|
||||
// Abort if we don't have any rows
|
||||
if (!$rows) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Let's remove the columns
|
||||
$q = "";
|
||||
foreach ($rows as $key => $column) {
|
||||
$comma = (($key+1) < count($rows)) ? "," : "";
|
||||
$q .= "drop ".$this->db->escape($column).$comma;
|
||||
}
|
||||
|
||||
$query = "alter table #__".$table." $q";
|
||||
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
}
|
||||
|
||||
public function fetch($table, $columns = "*", $where = null, $singlerow = false) {
|
||||
if (!$table) {
|
||||
return;
|
||||
}
|
||||
|
||||
$db = $this->db;
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query
|
||||
->select($columns)
|
||||
->from("#__$table");
|
||||
|
||||
if (isset($where)) {
|
||||
$query->where("$where");
|
||||
}
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return ($singlerow) ? $db->loadObject() : $db->loadObjectList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the Novarain Framework
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function loadFramework()
|
||||
{
|
||||
if (is_file(JPATH_PLUGINS . '/system/nrframework/autoload.php'))
|
||||
{
|
||||
include_once JPATH_PLUGINS . '/system/nrframework/autoload.php';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-orders plugin after passed array of plugins
|
||||
*
|
||||
* @param string $plugin Plugin element name
|
||||
* @param array $lowerPluginOrder Array of plugin element names
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function pluginOrderAfter($lowerPluginOrder)
|
||||
{
|
||||
|
||||
if (!is_array($lowerPluginOrder) || !count($lowerPluginOrder))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$db = $this->db;
|
||||
|
||||
// Get plugins max order
|
||||
$query = $db->getQuery(true);
|
||||
$query
|
||||
->select($db->quoteName('b.ordering'))
|
||||
->from($db->quoteName('#__extensions', 'b'))
|
||||
->where($db->quoteName('b.element') . ' IN ("'.implode("\",\"",$lowerPluginOrder).'")')
|
||||
->order('b.ordering desc');
|
||||
|
||||
$db->setQuery($query);
|
||||
$maxOrder = $db->loadResult();
|
||||
|
||||
if (is_null($maxOrder))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get plugin details
|
||||
$query
|
||||
->clear()
|
||||
->select(array($db->quoteName('extension_id'), $db->quoteName('ordering')))
|
||||
->from($db->quoteName('#__extensions'))
|
||||
->where($db->quoteName('element') . ' = ' . $db->quote($this->alias));
|
||||
|
||||
$db->setQuery($query);
|
||||
$pluginInfo = $db->loadObject();
|
||||
|
||||
if (!isset($pluginInfo->ordering) || $pluginInfo->ordering > $maxOrder)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the new plugin order
|
||||
$object = new stdClass();
|
||||
$object->extension_id = $pluginInfo->extension_id;
|
||||
$object->ordering = ($maxOrder + 1);
|
||||
|
||||
try {
|
||||
$db->updateObject('#__extensions', $object, 'extension_id');
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
23
plugins/fields/acffaq/script.install.php
Normal file
23
plugins/fields/acffaq/script.install.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Advanced Custom Fields
|
||||
* @version 2.8.8 Pro
|
||||
*
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2020 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 PlgFieldsACFFAQInstallerScript extends PlgFieldsACFFAQInstallerScriptHelper
|
||||
{
|
||||
public $alias = 'acffaq';
|
||||
public $extension_type = 'plugin';
|
||||
public $plugin_folder = "fields";
|
||||
public $show_message = false;
|
||||
}
|
||||
71
plugins/fields/acffaq/tmpl/acffaq.php
Normal file
71
plugins/fields/acffaq/tmpl/acffaq.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?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;
|
||||
|
||||
if (!$value = $field->value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_string($value) && !$value = json_decode($value, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($value['value']) && !is_array($value['value']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare the value
|
||||
$value = array_values($value['value']);
|
||||
$value = array_filter($value, function($item) {
|
||||
return !empty($item['question']) && !empty($item['answer']);
|
||||
});
|
||||
|
||||
$payload = [
|
||||
'value' => $value,
|
||||
'css_class' => ' template_' . $fieldParams->get('template'),
|
||||
'keep_one_question_open' => $fieldParams->get('keep_one_question_open', '0') === '1',
|
||||
'columns' => (int) $fieldParams->get('columns', 1),
|
||||
'item_gap' => $fieldParams->get('item_gap_control.item_gap', 20),
|
||||
'column_gap' => $fieldParams->get('column_gap_control.column_gap', 20),
|
||||
'item_background_color' => $fieldParams->get('background_color'),
|
||||
'item_border_radius' => $fieldParams->get('border_radius_control.item_border_radius'),
|
||||
'item_padding' => $fieldParams->get('padding_control.item_padding'),
|
||||
'question_font_size' => $fieldParams->get('question_font_size_control.question_font_size'),
|
||||
'question_text_color' => $fieldParams->get('question_text_color'),
|
||||
'answer_font_size' => $fieldParams->get('answer_font_size_control.answer_font_size'),
|
||||
'answer_text_color' => $fieldParams->get('answer_text_color'),
|
||||
'answer_padding' => $fieldParams->get('answer_padding_control.answer_padding'),
|
||||
'generate_faq' => $fieldParams->get('generate_faq', '0') === '1',
|
||||
'separator' => $fieldParams->get('separator', '0') === '1',
|
||||
'separator_color' => $fieldParams->get('separator_color'),
|
||||
'initial_state' => $fieldParams->get('initial_state', 'first-open')
|
||||
];
|
||||
|
||||
// Set custom layout
|
||||
if ($field->params->get('acf_layout_override'))
|
||||
{
|
||||
$payload['layout'] = $field->params->get('acf_layout_override');
|
||||
}
|
||||
|
||||
$show_toggle_icon = $fieldParams->get('show_toggle_icon', '1') === '1';
|
||||
$payload['show_toggle_icon'] = $show_toggle_icon;
|
||||
if ($show_toggle_icon)
|
||||
{
|
||||
$payload['icon'] = $fieldParams->get('icon', 'arrow');
|
||||
$payload['icon_position'] = $fieldParams->get('icon_position', 'right');
|
||||
}
|
||||
|
||||
echo \NRFramework\Widgets\Helper::render('FAQ', $payload);
|
||||
16
plugins/fields/acffaq/version.php
Normal file
16
plugins/fields/acffaq/version.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Advanced Custom Fields
|
||||
* @version 2.8.8 Pro
|
||||
*
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2020 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted Access');
|
||||
$NR_PRO = "1";
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user