first commit
This commit is contained in:
113
plugins/system/nrframework/fields/acymailing.php
Normal file
113
plugins/system/nrframework/fields/acymailing.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use NRFramework\Extension;
|
||||
|
||||
JFormHelper::loadFieldClass('groupedlist');
|
||||
|
||||
class JFormFieldAcymailing extends JFormFieldGroupedList
|
||||
{
|
||||
/**
|
||||
* Method to get the field option groups.
|
||||
*
|
||||
* @return array The field option objects as a nested array in groups.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getGroups()
|
||||
{
|
||||
$groups = [];
|
||||
$lists = [];
|
||||
|
||||
if ($acymailing_5_is_installed = Extension::isInstalled('com_acymailing'))
|
||||
{
|
||||
$lists['5'] = $this->getAcym5Lists();
|
||||
}
|
||||
|
||||
if ($acymailing_6_is_installed = Extension::isInstalled('com_acym'))
|
||||
{
|
||||
$lists['6'] = $this->getAcym6Lists();
|
||||
}
|
||||
|
||||
foreach ($lists as $group_key => $group)
|
||||
{
|
||||
if (!is_array($group))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($group as $list)
|
||||
{
|
||||
$groupLabel = 'AcyMailing ' . ($group_key == '5' ? $group_key : '');
|
||||
$groups[$groupLabel][] = JHtml::_('select.option', $list->id, $list->name);
|
||||
}
|
||||
}
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get AcyMailing 6 lists
|
||||
*
|
||||
* @return mixed Array on success, null on failure
|
||||
*/
|
||||
private function getAcym6Lists()
|
||||
{
|
||||
if (!@include_once(JPATH_ADMINISTRATOR . '/components/com_acym/helpers/helper.php'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$lists = acym_get('class.list')->getAll();
|
||||
|
||||
if (!is_array($lists))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add 6: prefix to each list id.
|
||||
foreach ($lists as $key => &$list)
|
||||
{
|
||||
$list->id = '6:' . $list->id;
|
||||
}
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get AcyMailing 5 lists
|
||||
*
|
||||
* @return mixed Array on success, null on failure
|
||||
*/
|
||||
private function getAcym5Lists()
|
||||
{
|
||||
if (!@include_once(JPATH_ADMINISTRATOR . '/components/com_acymailing/helpers/helper.php'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$lists = acymailing_get('class.list')->getLists();
|
||||
|
||||
if (!is_array($lists))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// The getGroups method expects the id property
|
||||
foreach ($lists as $key => $list)
|
||||
{
|
||||
$list->id = $list->listid;
|
||||
}
|
||||
|
||||
return $lists;
|
||||
}
|
||||
}
|
||||
167
plugins/system/nrframework/fields/ajaxify.php
Normal file
167
plugins/system/nrframework/fields/ajaxify.php
Normal file
@@ -0,0 +1,167 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\Registry\Registry;
|
||||
use NRFramework\HTML;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/*
|
||||
* Creates an AJAX-based dropdown
|
||||
* https://select2.org/
|
||||
*/
|
||||
abstract class JFormFieldAjaxify extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* Textbox placeholder
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $placeholder = 'Select Items';
|
||||
|
||||
/**
|
||||
* AJAX rows limit
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $limit = 50;
|
||||
|
||||
/**
|
||||
* Method to render the input field
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
if ($this->value && is_string($this->value))
|
||||
{
|
||||
$this->value = \NRFramework\Functions::makeArray($this->value);
|
||||
}
|
||||
|
||||
$placeholder = (string) $this->element['placeholder'];
|
||||
$this->placeholder = empty($placeholder) ? $this->placeholder : $placeholder;
|
||||
|
||||
HTML::stylesheet('plg_system_nrframework/select2.css');
|
||||
HTML::script('plg_system_nrframework/vendor/select2.min.js');
|
||||
HTML::script('plg_system_nrframework/ajaxify.js');
|
||||
|
||||
$this->class .= ' input-xxlarge select2 tf-select-ajaxify';
|
||||
|
||||
return '<div class="tf-ajaxify-wrapper" data-placeholder="' . htmlspecialchars(JText::_($this->placeholder)) . '" data-ajax-endpoint="' . $this->getAjaxEndpoint() . '">' . parent::getInput() . '</div>';
|
||||
}
|
||||
|
||||
protected function getAjaxEndpoint()
|
||||
{
|
||||
$reflector = new ReflectionClass($this);
|
||||
$filename = $reflector->getFileName();
|
||||
$file = JFile::stripExt(basename($filename));
|
||||
|
||||
$token = JSession::getFormToken();
|
||||
|
||||
$field_attributes = (array) $this->element->attributes();
|
||||
|
||||
$data = [
|
||||
'task' => 'include',
|
||||
'file' => $file,
|
||||
'path' => 'plugins/system/nrframework/fields/',
|
||||
'class' => get_called_class(),
|
||||
$token => 1,
|
||||
'field_attributes' => $field_attributes['@attributes']
|
||||
];
|
||||
|
||||
return JURI::base() . '?option=com_ajax&format=raw&plugin=nrframework&' . http_build_query($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns data object used by the AJAX request
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function onAjax($options)
|
||||
{
|
||||
$this->options = new Registry($options);
|
||||
|
||||
// Reinitialize Field
|
||||
$this->element = (array) $this->options->get('field_attributes');
|
||||
$this->init();
|
||||
|
||||
$this->limit = $this->options->get('limit', $this->limit);
|
||||
$this->page = $this->options->get('page', 1);
|
||||
$this->search_term = $this->options->get('term');
|
||||
|
||||
$rows = $this->getItems();
|
||||
|
||||
$hasMoreRecords = false;
|
||||
|
||||
if ($this->limit > 0)
|
||||
{
|
||||
$total = $this->getItemsTotal();
|
||||
$hasMoreRecords = ($this->page * $this->limit) < $total;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'results' => $rows,
|
||||
'pagination' => ['more' => $hasMoreRecords]
|
||||
];
|
||||
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load selected options
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = $this->value;
|
||||
|
||||
if (empty($options))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// In case the value is previously saved in a comma separated format.
|
||||
if (!is_array($options))
|
||||
{
|
||||
$options = explode(',', $options);
|
||||
}
|
||||
|
||||
if (!method_exists($this, 'validateOptions'))
|
||||
{
|
||||
return $options;
|
||||
}
|
||||
|
||||
// Remove empty and null items
|
||||
$options = array_filter($options);
|
||||
|
||||
try
|
||||
{
|
||||
return $this->validateOptions($options);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
echo $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by the onAjax method and must return an array of arrays
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function getItems();
|
||||
|
||||
abstract protected function getItemsTotal();
|
||||
}
|
||||
66
plugins/system/nrframework/fields/akeebasubs.php
Normal file
66
plugins/system/nrframework/fields/akeebasubs.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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
//
|
||||
defined('_JEXEC') or die;
|
||||
jimport('joomla.form.helper');
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
class JFormFieldAkeebaSubs extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
*
|
||||
* @return array An array of JHtml options.
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
if (!NRFramework\Extension::isInstalled('akeebasubs'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$lists = $this->getLevels();
|
||||
|
||||
if (!count($lists))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$options = array();
|
||||
|
||||
foreach ($lists as $option)
|
||||
{
|
||||
$options[] = JHTML::_('select.option', $option->id, $option->name);
|
||||
}
|
||||
|
||||
return array_merge(parent::getOptions(), $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all Akeeba Subscription Levels
|
||||
*
|
||||
* @return array Subscription Levels
|
||||
*/
|
||||
private function getLevels()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('l.akeebasubs_level_id as id, l.title AS name, l.enabled as published')
|
||||
->from('#__akeebasubs_levels AS l')
|
||||
->where('l.enabled > -1')
|
||||
->order('l.title, l.akeebasubs_level_id');
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
}
|
||||
66
plugins/system/nrframework/fields/assignmentselection.php
Normal file
66
plugins/system/nrframework/fields/assignmentselection.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
|
||||
*/
|
||||
|
||||
defined('JPATH_PLATFORM') or die;
|
||||
|
||||
use NRFramework\HTML;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
class JFormFieldAssignmentSelection extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* Assignment options
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options = array(
|
||||
0 => 'JDISABLED',
|
||||
1 => 'NR_INCLUDE',
|
||||
2 => 'NR_EXCLUDE'
|
||||
);
|
||||
|
||||
/**
|
||||
* Return options list to field
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
foreach ($this->options as $key => $value)
|
||||
{
|
||||
$options[] = JHTML::_('select.option', $key, JText::_($value));
|
||||
}
|
||||
|
||||
return array_merge(parent::getOptions(), $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup field with predefined classes and load its media files
|
||||
*
|
||||
* @param SimpleXMLElement $element
|
||||
* @param String $value
|
||||
* @param String $group
|
||||
*
|
||||
* @return SimpleXMLElement
|
||||
*/
|
||||
public function setup(SimpleXMLElement $element, $value, $group = NULL)
|
||||
{
|
||||
$return = parent::setup($element, $value, $group);
|
||||
|
||||
JHtml::_('jquery.framework');
|
||||
|
||||
HTML::script('plg_system_nrframework/assignmentselection.js');
|
||||
HTML::stylesheet('plg_system_nrframework/assignmentselection.css');
|
||||
|
||||
$this->class = 'assignmentselection chzn-color-state';
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
88
plugins/system/nrframework/fields/block.php
Normal file
88
plugins/system/nrframework/fields/block.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once dirname(__DIR__) . '/helpers/field.php';
|
||||
|
||||
###### Note ######
|
||||
# This field is deprecated. Use NR_Well instead
|
||||
###### Note ######
|
||||
|
||||
class JFormFieldNR_Block extends NRFormField
|
||||
{
|
||||
/**
|
||||
* The field type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'nr_block';
|
||||
|
||||
protected function getLabel()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to render the input field
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
JHtml::stylesheet('plg_system_nrframework/fields.css', false, true);
|
||||
|
||||
$title = $this->get('label');
|
||||
$description = $this->get('description');
|
||||
$class = $this->get('class');
|
||||
$showclose = $this->get('showclose', 0);
|
||||
$start = $this->get('start', 0);
|
||||
$end = $this->get('end', 0);
|
||||
$info = $this->get("html", null);
|
||||
|
||||
if ($info)
|
||||
{
|
||||
$info = str_replace("{{", "<", $info);
|
||||
$info = str_replace("}}", ">", $info);
|
||||
}
|
||||
|
||||
$html = array();
|
||||
|
||||
if ($start || !$end)
|
||||
{
|
||||
$html[] = '</div>';
|
||||
|
||||
if (strpos($class, 'alert') !== false)
|
||||
{
|
||||
$html[] = '<div class="alert ' . $class . '">';
|
||||
}
|
||||
else
|
||||
{
|
||||
$html[] = '<div class="well nr-well' . $class . '">';
|
||||
}
|
||||
if ($title)
|
||||
{
|
||||
$html[] = '<h4>' . $this->prepareText($title) . '</h4>';
|
||||
}
|
||||
if ($description)
|
||||
{
|
||||
$html[] = '<div class="well-desc">' . $this->prepareText($description) . $info . '</div>';
|
||||
}
|
||||
$html[] = '<div><div>';
|
||||
}
|
||||
|
||||
if (!$start && !$end)
|
||||
{
|
||||
$html[] = '</div>';
|
||||
}
|
||||
|
||||
return '</div>' . implode('', $html);
|
||||
}
|
||||
}
|
||||
68
plugins/system/nrframework/fields/comparator.php
Normal file
68
plugins/system/nrframework/fields/comparator.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Tassos.gr <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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
class JFormFieldComparator extends JFormFieldList
|
||||
{
|
||||
private $defaults = [
|
||||
'includes' => 'NR_IS',
|
||||
'not_includes' => 'NR_IS_NOT'
|
||||
];
|
||||
|
||||
/**
|
||||
* Method to get the field input markup for a generic list.
|
||||
* Use the multiple attribute to enable multiselect.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$this->required = true;
|
||||
$this->class .= ' comparator';
|
||||
|
||||
return parent::getInput();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the label.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getLabel()
|
||||
{
|
||||
if (!isset($this->element['label']))
|
||||
{
|
||||
$this->element['label'] = 'NR_MATCH';
|
||||
}
|
||||
|
||||
return parent::getLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the options.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
if (!$options = parent::getOptions())
|
||||
{
|
||||
$options = $this->defaults;
|
||||
|
||||
foreach ($options as $key => &$value)
|
||||
{
|
||||
$value = JText::_($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
208
plugins/system/nrframework/fields/componentitems.php
Normal file
208
plugins/system/nrframework/fields/componentitems.php
Normal file
@@ -0,0 +1,208 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
require_once __DIR__ . '/ajaxify.php';
|
||||
|
||||
/*
|
||||
* Creates an AJAX-based dropdown
|
||||
* https://select2.org/
|
||||
*/
|
||||
class JFormFieldComponentItems extends JFormFieldAjaxify
|
||||
{
|
||||
/**
|
||||
* Single items table name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'content';
|
||||
|
||||
/**
|
||||
* Primary key column of the single items table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $column_id = 'id';
|
||||
|
||||
/**
|
||||
* The title column of the single items table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $column_title = 'title';
|
||||
|
||||
/**
|
||||
* The state column of the single items table
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $column_state = 'state';
|
||||
|
||||
/**
|
||||
* Pass extra where SQL statement
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $where;
|
||||
|
||||
/**
|
||||
* The Joomla database object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* 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. This acts as an array container for the field.
|
||||
* For example if the field has name="foo" and the group value is set to "bar" then the
|
||||
* full field name would end up being "bar[foo]".
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public function setup(SimpleXMLElement $element, $value, $group = null)
|
||||
{
|
||||
if ($return = parent::setup($element, $value, $group))
|
||||
{
|
||||
$this->init();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->table = isset($this->element['table']) ? (string) $this->element['table'] : $this->table;
|
||||
|
||||
$this->column_id = isset($this->element['column_id']) ? (string) $this->element['column_id'] : $this->column_id;
|
||||
$this->column_id = $this->prefix($this->column_id);
|
||||
|
||||
$this->column_title = isset($this->element['column_title']) ? (string) $this->element['column_title'] : $this->column_title;
|
||||
$this->column_title = $this->prefix($this->column_title);
|
||||
|
||||
$this->column_state = isset($this->element['column_state']) ? (string) $this->element['column_state'] : $this->column_state;
|
||||
$this->column_state = $this->prefix($this->column_state);
|
||||
|
||||
$this->where = isset($this->element['where']) ? (string) $this->element['where'] : null;
|
||||
$this->join = isset($this->element['join']) ? (string) $this->element['join'] : null;
|
||||
|
||||
if (!isset($this->element['placeholder']))
|
||||
{
|
||||
$this->placeholder = (string) $this->element['description'];
|
||||
}
|
||||
|
||||
// Initialize database Object
|
||||
$this->db = JFactory::getDbo();
|
||||
}
|
||||
|
||||
private function prefix($string)
|
||||
{
|
||||
if (strpos($string, '.') === false)
|
||||
{
|
||||
$string = 'i.' . $string;
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
protected function getTemplateResult()
|
||||
{
|
||||
return '<span class="row-text">\' + state.text + \'</span><span style="float:right; opacity:.7">\' + state.id + \'</span>';
|
||||
}
|
||||
|
||||
protected function getItemsQuery()
|
||||
{
|
||||
$db = $this->db;
|
||||
|
||||
$query = $this->getQuery()
|
||||
->order($db->quoteName($this->column_id) . ' DESC');
|
||||
|
||||
if ($this->limit > 0)
|
||||
{
|
||||
// Joomla uses offset
|
||||
$page = $this->page - 1;
|
||||
|
||||
$query->setLimit($this->limit, $page * $this->limit);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
protected function getItems()
|
||||
{
|
||||
$db = $this->db;
|
||||
|
||||
$db->setQuery($this->getItemsQuery());
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
|
||||
protected function getItemsTotal()
|
||||
{
|
||||
$db = $this->db;
|
||||
|
||||
$query = $this->getQuery()
|
||||
->clear('select')
|
||||
->select('count(*)');
|
||||
$db->setQuery($query);
|
||||
|
||||
return (int) $db->loadResult();
|
||||
}
|
||||
|
||||
protected function getQuery()
|
||||
{
|
||||
$db = $this->db;
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select([
|
||||
$db->quoteName($this->column_id, 'id'),
|
||||
$db->quoteName($this->column_title, 'text'),
|
||||
$db->quoteName($this->column_state, 'state')
|
||||
])
|
||||
->from($db->quoteName('#__' . $this->table, 'i'));
|
||||
|
||||
if (!empty($this->search_term))
|
||||
{
|
||||
$query->where($db->quoteName($this->column_title) . ' LIKE ' . $db->quote('%' . $this->search_term . '%'));
|
||||
}
|
||||
|
||||
if ($this->join)
|
||||
{
|
||||
$query->join('INNER', $this->join);
|
||||
}
|
||||
|
||||
if ($this->where)
|
||||
{
|
||||
$query->where($this->where);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
protected function validateOptions($options)
|
||||
{
|
||||
$db = $this->db;
|
||||
|
||||
$query = $this->getQuery()
|
||||
->where($db->quoteName($this->column_id) . ' IN (' . implode(',', $options) . ')');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadAssocList('id', 'text');
|
||||
}
|
||||
}
|
||||
78
plugins/system/nrframework/fields/conditionbuilder.php
Normal file
78
plugins/system/nrframework/fields/conditionbuilder.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use NRFramework\Conditions\ConditionBuilder;
|
||||
use NRFramework\Extension;
|
||||
|
||||
JFormHelper::loadFieldClass('hidden');
|
||||
|
||||
class JFormFieldConditionBuilder extends JFormFieldHidden
|
||||
{
|
||||
/**
|
||||
* Method to render the input field
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
// Condition Builder relies on com_ajax for AJAX requests.
|
||||
if (!Extension::componentIsEnabled('ajax'))
|
||||
{
|
||||
\JFactory::getApplication()->enqueueMessage(\JText::_('AJAX Component is not enabled.'), 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
// This is required on views we don't control such as the Fields or the Modules view page.
|
||||
JHtml::_('formbehavior.chosen', '.hasChosen');
|
||||
|
||||
JHtml::stylesheet('plg_system_nrframework/fields.css', ['relative' => true, 'version' => 'auto']);
|
||||
JHtml::stylesheet('plg_system_nrframework/joomla' . (defined('nrJ4') ? '4' : '3') . '.css', ['relative' => true, 'version' => 'auto']);
|
||||
|
||||
\JText::script('NR_CB_SELECT_CONDITION_GET_STARTED');
|
||||
\JText::script('NR_ARE_YOU_SURE_YOU_WANT_TO_DELETE_THIS_ITEM');
|
||||
|
||||
// Value must be always be a JSON string.
|
||||
if (is_array($this->value))
|
||||
{
|
||||
$this->value = json_encode($this->value);
|
||||
}
|
||||
|
||||
// If field is empty, initialize it with an empty Condition Group
|
||||
|
||||
$payload = [
|
||||
'include_rules' => isset($this->getOptions()['include_rules']) ? ConditionBuilder::prepareXmlRulesList($this->getOptions()['include_rules']) : '',
|
||||
'exclude_rules' => isset($this->getOptions()['exclude_rules']) ? ConditionBuilder::prepareXmlRulesList($this->getOptions()['exclude_rules']) : '',
|
||||
'geo_modal' => ConditionBuilder::getGeoModal() // Out of context
|
||||
];
|
||||
|
||||
return '
|
||||
<div class="cb-wrapper">
|
||||
' . parent::getInput() . ConditionBuilder::getLayout('conditionbuilder', $payload) . '
|
||||
</div>
|
||||
';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the field options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = [
|
||||
'include_rules' => (string) $this->element['include_rules'],
|
||||
'exclude_rules' => (string) $this->element['exclude_rules']
|
||||
];
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
70
plugins/system/nrframework/fields/content.php
Normal file
70
plugins/system/nrframework/fields/content.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once dirname(__DIR__) . '/helpers/groupfield.php';
|
||||
|
||||
class JFormFieldNR_Content extends NRFormGroupField
|
||||
{
|
||||
public $type = 'Content';
|
||||
|
||||
public function getCategories()
|
||||
{
|
||||
$query = $this->db->getQuery(true)
|
||||
->select('COUNT(c.id)')
|
||||
->from('#__categories AS c')
|
||||
->where('c.extension = ' . $this->db->quote('com_content'))
|
||||
->where('c.parent_id > 0')
|
||||
->where('c.published > -1');
|
||||
$this->db->setQuery($query);
|
||||
$total = $this->db->loadResult();
|
||||
|
||||
$options = array();
|
||||
if ($this->get('show_ignore'))
|
||||
{
|
||||
if (in_array('-1', $this->value))
|
||||
{
|
||||
$this->value = array('-1');
|
||||
}
|
||||
$options[] = JHtml::_('select.option', '-1', '- ' . JText::_('NR_IGNORE') . ' -', 'value', 'text', 0);
|
||||
$options[] = JHtml::_('select.option', '-', ' ', 'value', 'text', 1);
|
||||
}
|
||||
|
||||
$query->clear('select')
|
||||
->select('c.id, c.title as name, c.level, c.published, c.language')
|
||||
->order('c.lft');
|
||||
|
||||
$this->db->setQuery($query);
|
||||
$list = $this->db->loadObjectList();
|
||||
|
||||
$options = array_merge($options, $this->getOptionsByList($list, array('language'), -1));
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getItems()
|
||||
{
|
||||
$query = $this->db->getQuery(true)
|
||||
->select('COUNT(i.id)')
|
||||
->from('#__content AS i')
|
||||
->where('i.access > -1');
|
||||
$this->db->setQuery($query);
|
||||
$total = $this->db->loadResult();
|
||||
|
||||
$query->clear('select')
|
||||
->select('i.id, i.title as name, i.language, c.title as cat, i.access as published')
|
||||
->join('LEFT', '#__categories AS c ON c.id = i.catid')
|
||||
->order('i.title, i.ordering, i.id');
|
||||
$this->db->setQuery($query);
|
||||
$list = $this->db->loadObjectList();
|
||||
|
||||
return $this->getOptionsByList($list, array('language', 'cat', 'id'));
|
||||
}
|
||||
}
|
||||
210
plugins/system/nrframework/fields/currencies.php
Normal file
210
plugins/system/nrframework/fields/currencies.php
Normal file
@@ -0,0 +1,210 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once JPATH_PLUGINS . '/system/nrframework/helpers/fieldlist.php';
|
||||
|
||||
class JFormFieldNR_Currencies extends NRFormFieldList
|
||||
{
|
||||
public $currencies = array(
|
||||
"AED" => "United Arab Emirates Dirham",
|
||||
"AFN" => "Afghan Afghani",
|
||||
"ALL" => "Albanian Lek",
|
||||
"AMD" => "Armenian Dram",
|
||||
"ANG" => "Netherlands Antillean Guilder",
|
||||
"AOA" => "Angolan Kwanza",
|
||||
"ARS" => "Argentine Peso",
|
||||
"AUD" => "Australian Dollar",
|
||||
"AWG" => "Aruban Florin",
|
||||
"AZN" => "Azerbaijani Manat",
|
||||
"BAM" => "Bosnia-Herzegovina Convertible Mark",
|
||||
"BBD" => "Barbadian Dollar",
|
||||
"BDT" => "Bangladeshi Taka",
|
||||
"BGN" => "Bulgarian Lev",
|
||||
"BHD" => "Bahraini Dinar",
|
||||
"BIF" => "Burundian Franc",
|
||||
"BMD" => "Bermudan Dollar",
|
||||
"BND" => "Brunei Dollar",
|
||||
"BOB" => "Bolivian Boliviano",
|
||||
"BRL" => "Brazilian Real",
|
||||
"BSD" => "Bahamian Dollar",
|
||||
"BTC" => "Bitcoin",
|
||||
"BTN" => "Bhutanese Ngultrum",
|
||||
"BWP" => "Botswanan Pula",
|
||||
"BYN" => "Belarusian Ruble",
|
||||
"BYR" => "Belarusian Ruble (pre-2016)",
|
||||
"BZD" => "Belize Dollar",
|
||||
"CAD" => "Canadian Dollar",
|
||||
"CDF" => "Congolese Franc",
|
||||
"CHF" => "Swiss Franc",
|
||||
"CLF" => "Chilean Unit of Account (UF)",
|
||||
"CLP" => "Chilean Peso",
|
||||
"CNY" => "Chinese Yuan",
|
||||
"COP" => "Colombian Peso",
|
||||
"CRC" => "Costa Rican Colón",
|
||||
"CUC" => "Cuban Convertible Peso",
|
||||
"CUP" => "Cuban Peso",
|
||||
"CVE" => "Cape Verdean Escudo",
|
||||
"CZK" => "Czech Republic Koruna",
|
||||
"DJF" => "Djiboutian Franc",
|
||||
"DKK" => "Danish Krone",
|
||||
"DOP" => "Dominican Peso",
|
||||
"DZD" => "Algerian Dinar",
|
||||
"EEK" => "Estonian Kroon",
|
||||
"EGP" => "Egyptian Pound",
|
||||
"ERN" => "Eritrean Nakfa",
|
||||
"ETB" => "Ethiopian Birr",
|
||||
"EUR" => "Euro",
|
||||
"FJD" => "Fijian Dollar",
|
||||
"FKP" => "Falkland Islands Pound",
|
||||
"GBP" => "British Pound Sterling",
|
||||
"GEL" => "Georgian Lari",
|
||||
"GGP" => "Guernsey Pound",
|
||||
"GHS" => "Ghanaian Cedi",
|
||||
"GIP" => "Gibraltar Pound",
|
||||
"GMD" => "Gambian Dalasi",
|
||||
"GNF" => "Guinean Franc",
|
||||
"GTQ" => "Guatemalan Quetzal",
|
||||
"GYD" => "Guyanaese Dollar",
|
||||
"HKD" => "Hong Kong Dollar",
|
||||
"HNL" => "Honduran Lempira",
|
||||
"HRK" => "Croatian Kuna",
|
||||
"HTG" => "Haitian Gourde",
|
||||
"HUF" => "Hungarian Forint",
|
||||
"IDR" => "Indonesian Rupiah",
|
||||
"ILS" => "Israeli New Sheqel",
|
||||
"IMP" => "Manx pound",
|
||||
"INR" => "Indian Rupee",
|
||||
"IQD" => "Iraqi Dinar",
|
||||
"IRR" => "Iranian Rial",
|
||||
"ISK" => "Icelandic Króna",
|
||||
"JEP" => "Jersey Pound",
|
||||
"JMD" => "Jamaican Dollar",
|
||||
"JOD" => "Jordanian Dinar",
|
||||
"JPY" => "Japanese Yen",
|
||||
"KES" => "Kenyan Shilling",
|
||||
"KGS" => "Kyrgystani Som",
|
||||
"KHR" => "Cambodian Riel",
|
||||
"KMF" => "Comorian Franc",
|
||||
"KPW" => "North Korean Won",
|
||||
"KRW" => "South Korean Won",
|
||||
"KWD" => "Kuwaiti Dinar",
|
||||
"KYD" => "Cayman Islands Dollar",
|
||||
"KZT" => "Kazakhstani Tenge",
|
||||
"LAK" => "Laotian Kip",
|
||||
"LBP" => "Lebanese Pound",
|
||||
"LKR" => "Sri Lankan Rupee",
|
||||
"LRD" => "Liberian Dollar",
|
||||
"LSL" => "Lesotho Loti",
|
||||
"LTL" => "Lithuanian Litas",
|
||||
"LVL" => "Latvian Lats",
|
||||
"LYD" => "Libyan Dinar",
|
||||
"MAD" => "Moroccan Dirham",
|
||||
"MDL" => "Moldovan Leu",
|
||||
"MGA" => "Malagasy Ariary",
|
||||
"MKD" => "Macedonian Denar",
|
||||
"MMK" => "Myanma Kyat",
|
||||
"MNT" => "Mongolian Tugrik",
|
||||
"MOP" => "Macanese Pataca",
|
||||
"MRO" => "Mauritanian Ouguiya",
|
||||
"MTL" => "Maltese Lira",
|
||||
"MUR" => "Mauritian Rupee",
|
||||
"MVR" => "Maldivian Rufiyaa",
|
||||
"MWK" => "Malawian Kwacha",
|
||||
"MXN" => "Mexican Peso",
|
||||
"MYR" => "Malaysian Ringgit",
|
||||
"MZN" => "Mozambican Metical",
|
||||
"NAD" => "Namibian Dollar",
|
||||
"NGN" => "Nigerian Naira",
|
||||
"NIO" => "Nicaraguan Córdoba",
|
||||
"NOK" => "Norwegian Krone",
|
||||
"NPR" => "Nepalese Rupee",
|
||||
"NZD" => "New Zealand Dollar",
|
||||
"OMR" => "Omani Rial",
|
||||
"PAB" => "Panamanian Balboa",
|
||||
"PEN" => "Peruvian Nuevo Sol",
|
||||
"PGK" => "Papua New Guinean Kina",
|
||||
"PHP" => "Philippine Peso",
|
||||
"PKR" => "Pakistani Rupee",
|
||||
"PLN" => "Polish Zloty",
|
||||
"PYG" => "Paraguayan Guarani",
|
||||
"QAR" => "Qatari Rial",
|
||||
"RON" => "Romanian Leu",
|
||||
"RSD" => "Serbian Dinar",
|
||||
"RUB" => "Russian Ruble",
|
||||
"RWF" => "Rwandan Franc",
|
||||
"SAR" => "Saudi Riyal",
|
||||
"SBD" => "Solomon Islands Dollar",
|
||||
"SCR" => "Seychellois Rupee",
|
||||
"SDG" => "Sudanese Pound",
|
||||
"SEK" => "Swedish Krona",
|
||||
"SGD" => "Singapore Dollar",
|
||||
"SHP" => "Saint Helena Pound",
|
||||
"SLL" => "Sierra Leonean Leone",
|
||||
"SOS" => "Somali Shilling",
|
||||
"SRD" => "Surinamese Dollar",
|
||||
"STD" => "São Tomé and Príncipe Dobra",
|
||||
"SVC" => "Salvadoran Colón",
|
||||
"SYP" => "Syrian Pound",
|
||||
"SZL" => "Swazi Lilangeni",
|
||||
"THB" => "Thai Baht",
|
||||
"TJS" => "Tajikistani Somoni",
|
||||
"TMT" => "Turkmenistani Manat",
|
||||
"TND" => "Tunisian Dinar",
|
||||
"TOP" => "Tongan Pa?anga",
|
||||
"TRY" => "Turkish Lira",
|
||||
"TTD" => "Trinidad and Tobago Dollar",
|
||||
"TWD" => "New Taiwan Dollar",
|
||||
"TZS" => "Tanzanian Shilling",
|
||||
"UAH" => "Ukrainian Hryvnia",
|
||||
"UGX" => "Ugandan Shilling",
|
||||
"USD" => "United States Dollar",
|
||||
"UYU" => "Uruguayan Peso",
|
||||
"UZS" => "Uzbekistan Som",
|
||||
"VEF" => "Venezuelan Bolívar Fuerte",
|
||||
"VND" => "Vietnamese Dong",
|
||||
"VUV" => "Vanuatu Vatu",
|
||||
"WST" => "Samoan Tala",
|
||||
"XAF" => "CFA Franc BEAC",
|
||||
"XAG" => "Silver Ounce",
|
||||
"XAU" => "Gold Ounce",
|
||||
"XCD" => "East Caribbean Dollar",
|
||||
"XDR" => "Special Drawing Rights",
|
||||
"XOF" => "CFA Franc BCEAO",
|
||||
"XPD" => "Palladium Ounce",
|
||||
"XPF" => "CFP Franc",
|
||||
"XPT" => "Platinum Ounce",
|
||||
"YER" => "Yemeni Rial",
|
||||
"ZAR" => "South African Rand",
|
||||
"ZMK" => "Zambian Kwacha (pre-2013)",
|
||||
"ZMW" => "Zambian Kwacha",
|
||||
"ZWL" => "Zimbabwean Dollar",
|
||||
);
|
||||
|
||||
protected function getOptions()
|
||||
{
|
||||
$options = array();
|
||||
|
||||
if ($this->showSelect())
|
||||
{
|
||||
$options[] = JHTML::_('select.option', "", "- " . JText::_("NR_SELECT_CURRENCY"). " -");
|
||||
}
|
||||
|
||||
asort($this->currencies);
|
||||
|
||||
foreach ($this->currencies as $key => $value)
|
||||
{
|
||||
$options[] = JHTML::_('select.option', $key, $key . " (" . $value . ")");
|
||||
}
|
||||
|
||||
return array_merge(parent::getOptions(), $options);
|
||||
}
|
||||
}
|
||||
68
plugins/system/nrframework/fields/freetext.php
Normal file
68
plugins/system/nrframework/fields/freetext.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once dirname(__DIR__) . '/helpers/field.php';
|
||||
|
||||
class JFormFieldNR_Freetext extends NRFormField
|
||||
{
|
||||
/**
|
||||
* The field type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'freetext';
|
||||
|
||||
/**
|
||||
* Method to render the input field
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$file = $this->get("file", false);
|
||||
$text = $this->get("text", false);
|
||||
$label = $this->get("label", false);
|
||||
|
||||
if (!$label)
|
||||
{
|
||||
$html[] = '</div><div class="freetext '.$this->get("class").'">';
|
||||
}
|
||||
|
||||
if ($file)
|
||||
{
|
||||
$html[] = $this->renderContent($this->get("file"), $this->get("path"), $this);
|
||||
}
|
||||
|
||||
if ($text)
|
||||
{
|
||||
$html[] = $this->prepareText($text);
|
||||
}
|
||||
|
||||
return implode(" ", $html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render PHP file with data
|
||||
*
|
||||
* @param string $file The file name
|
||||
* @param string $path The pathname
|
||||
* @param mixed $displayData The data object passed to template file
|
||||
*
|
||||
* @return string HTML rendered
|
||||
*/
|
||||
private function renderContent($file, $path, $displayData = null)
|
||||
{
|
||||
$layout = new JLayoutFile($file, JPATH_SITE . $path, array('debug' => 0));
|
||||
return $layout->render($displayData);
|
||||
}
|
||||
|
||||
}
|
||||
84
plugins/system/nrframework/fields/geo.php
Normal file
84
plugins/system/nrframework/fields/geo.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
require_once JPATH_PLUGINS . '/system/nrframework/helpers/fieldlist.php';
|
||||
|
||||
class JFormFieldNR_Geo extends NRFormFieldList
|
||||
{
|
||||
private $list;
|
||||
|
||||
protected function getInput()
|
||||
{
|
||||
if ($this->get('detect_visitor_country', false) && empty($this->value) && $countryCode = $this->getVisitorCountryCode())
|
||||
{
|
||||
$this->value = $countryCode;
|
||||
}
|
||||
|
||||
return parent::getInput();
|
||||
}
|
||||
|
||||
protected function getOptions()
|
||||
{
|
||||
switch ($this->get('geo'))
|
||||
{
|
||||
case 'continents':
|
||||
$this->list = \NRFramework\Continents::getContinentsList();
|
||||
$selectLabel = 'NR_SELECT_CONTINENT';
|
||||
break;
|
||||
default:
|
||||
$this->list = \NRFramework\Countries::getCountriesList();
|
||||
$selectLabel = 'NR_SELECT_COUNTRY';
|
||||
break;
|
||||
}
|
||||
|
||||
if ($this->get('use_label_as_value', false))
|
||||
{
|
||||
$this->list = array_combine($this->list, $this->list);
|
||||
}
|
||||
|
||||
$options = array();
|
||||
|
||||
if ($this->get("showselect", 'true') === 'true')
|
||||
{
|
||||
$options[] = JHTML::_('select.option', "", "- " . JText::_($selectLabel) . " -");
|
||||
}
|
||||
|
||||
foreach ($this->list as $key => $value)
|
||||
{
|
||||
$options[] = JHTML::_('select.option', $key, $value);
|
||||
}
|
||||
|
||||
return array_merge(parent::getOptions(), $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect visitor's country
|
||||
*
|
||||
* @return string The visitor's country code (GR)
|
||||
*/
|
||||
private function getVisitorCountryCode()
|
||||
{
|
||||
$path = JPATH_PLUGINS . '/system/tgeoip/';
|
||||
|
||||
if (!\JFolder::exists($path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!class_exists('TGeoIP'))
|
||||
{
|
||||
@include_once $path . 'vendor/autoload.php';
|
||||
@include_once $path . 'helper/tgeoip.php';
|
||||
}
|
||||
|
||||
$geo = new \TGeoIP();
|
||||
return $geo->getCountryCode();
|
||||
}
|
||||
}
|
||||
84
plugins/system/nrframework/fields/geodbchecker.php
Normal file
84
plugins/system/nrframework/fields/geodbchecker.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
class JFormFieldGeoDBChecker extends JFormField
|
||||
{
|
||||
/**
|
||||
* Whether TGeoIP is disabled or not.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $tgeoip_plugin_disabled = false;
|
||||
|
||||
protected function getLabel()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the field.
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function renderField($options = [])
|
||||
{
|
||||
// Check if TGeoIP plugin is enabled
|
||||
if (!\NRFramework\Extension::pluginIsEnabled('tgeoip'))
|
||||
{
|
||||
$this->tgeoip_plugin_disabled = true;
|
||||
return parent::renderField($options);
|
||||
}
|
||||
|
||||
// Do not render the field if the database is up-to-date
|
||||
if (!\NRFramework\Extension::geoPluginNeedsUpdate())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
return parent::renderField($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a warning message when the Geolocation plugin is disabled.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function disabledPluginWarning()
|
||||
{
|
||||
return '<div class="alert alert-warning geo-db-checker" style="margin-top: 0; margin-bottom: 0;">' .
|
||||
'<h3 style="margin-top:0;">' . JText::sprintf('NR_GEO_PLUGIN_DISABLED') . '</h3>' .
|
||||
'<p>' . JText::sprintf('NR_GEO_PLUGIN_DISABLED_DESC', '<a href="' . JRoute::_('index.php?option=com_plugins&view=plugins&filter' . (defined('nrJ4') ? '[search]' : '_search') . '=System - Tassos.gr GeoIP Plugin') . '" target="_blank">', '</a>') . '</p>' .
|
||||
'</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* If the geolocation database is missing or its outdated, then display a helpful message
|
||||
* to the usser notifying them that they need to update.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
if ($this->tgeoip_plugin_disabled)
|
||||
{
|
||||
return $this->disabledPluginWarning();
|
||||
}
|
||||
|
||||
return '<div class="alert alert-info" style="margin: 0;">' .
|
||||
'<h3 style="margin-top:0;">' . JText::sprintf('NR_GEO_MAINTENANCE') . '</h3>' .
|
||||
'<p>' . JText::sprintf('NR_GEO_MAINTENANCE_DESC') . '</p>' .
|
||||
'<a class="btn btn-success" data-toggle="modal" data-bs-toggle="modal" href="#tf-geodbchecker-modal"><span class="icon-refresh"></span> Update Database</a>' .
|
||||
'</div>';
|
||||
}
|
||||
}
|
||||
86
plugins/system/nrframework/fields/gmap.php
Normal file
86
plugins/system/nrframework/fields/gmap.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use NRFramework\HTML;
|
||||
|
||||
require_once dirname(__DIR__) . '/helpers/field.php';
|
||||
|
||||
class JFormFieldNR_Gmap extends NRFormField
|
||||
{
|
||||
/**
|
||||
* The default Google Maps API Key
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $defaultAPIKey = 'AIzaSyAPgVu1A9L7_q0gtYToFeJiUHDSCCXYZKI';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*/
|
||||
public function getInput()
|
||||
{
|
||||
// Setup properties
|
||||
$this->width = $this->get('width', '500px');
|
||||
$this->height = $this->get('height', '400px');
|
||||
$this->zoom = $this->get('zoom', '10');
|
||||
$this->margin = $this->get('margin', '0 0 10px 0');
|
||||
$this->readonly = $this->get('readonly', false) ? 'readonly' : '';
|
||||
$this->value = $this->checkCoordinates($this->value, null) ? $this->value : $this->get('default', '36.892587, 27.287793');
|
||||
$this->hint = $this->prepareText($this->get('hint', 'NR_ENTER_COORDINATES'));
|
||||
|
||||
// Add scripts to DOM
|
||||
JHtml::_('jquery.framework');
|
||||
JFactory::getDocument()->addScript('//maps.googleapis.com/maps/api/js?key=' . $this->getAPIKey());
|
||||
HTML::script('plg_system_nrframework/field.gmap.js');
|
||||
Jtext::script('NR_WRONG_COORDINATES');
|
||||
|
||||
// Add styles to DOM
|
||||
$this->doc->addStyleDeclaration('
|
||||
#' . $this->id . '_map {
|
||||
height: ' . $this->height . ';
|
||||
width: ' . $this->width . ';
|
||||
margin: ' . $this->margin . ';
|
||||
}
|
||||
');
|
||||
|
||||
return '<div id="' . $this->id . '_map"></div><input type="text" name="' . $this->name . '" class="form-control ' . $this->class . ' nr_gmap" id="' . $this->id . '" value="' . $this->value . '" placeholder="' . $this->hint . '" data-zoom="' . $this->zoom . '" ' . $this->readonly . '/>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the validity of the coordinates
|
||||
*/
|
||||
private function checkCoordinates($coordinates)
|
||||
{
|
||||
return (preg_match("/^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$/", $coordinates));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Google Maps API Key.
|
||||
* If no key is found in the framework options then the default API Key will be used instead.
|
||||
*
|
||||
* We should update the default API Key once a while.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getAPIKey()
|
||||
{
|
||||
if (!$framework = JPluginHelper::getPlugin('system', 'nrframework'))
|
||||
{
|
||||
return $this->defaultAPIKey;
|
||||
}
|
||||
|
||||
// Get plugin params
|
||||
$params = new JRegistry($framework->params);
|
||||
return $params->get('gmapkey', $this->defaultAPIKey);
|
||||
}
|
||||
}
|
||||
36
plugins/system/nrframework/fields/inline.php
Normal file
36
plugins/system/nrframework/fields/inline.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once dirname(__DIR__) . '/helpers/field.php';
|
||||
|
||||
class JFormFieldNR_Inline extends NRFormField
|
||||
{
|
||||
/**
|
||||
* Method to render the input field
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
JHtml::stylesheet('plg_system_nrframework/inline-control-group.css', ['relative' => true, 'version' => 'auto']);
|
||||
|
||||
$start = $this->get('start', 1);
|
||||
$end = $this->get('end', 0);
|
||||
|
||||
if ($start && !$end)
|
||||
{
|
||||
return '<div class="inline-control-group '.$this->get('class').'"><div><div>';
|
||||
}
|
||||
|
||||
return '</div></div></div>';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
require_once __DIR__ . '/componentitems.php';
|
||||
|
||||
class JFormFieldJShoppingComponentItems extends JFormFieldComponentItems
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
// Get default language
|
||||
$this->element['column_title'] = 'name_' . $this->getLanguage();
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* JoomShopping is using different columns per language. Therefore, we need to use their API to get the default language code.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getLanguage($default = 'en-GB')
|
||||
{
|
||||
// Silent inclusion.
|
||||
@include_once JPATH_SITE . '/components/com_jshopping/lib/factory.php';
|
||||
|
||||
if (!class_exists('JSFactory'))
|
||||
{
|
||||
return $default;
|
||||
}
|
||||
|
||||
return JSFactory::getConfig()->defaultLanguage;
|
||||
}
|
||||
}
|
||||
60
plugins/system/nrframework/fields/modules.php
Normal file
60
plugins/system/nrframework/fields/modules.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once JPATH_PLUGINS . '/system/nrframework/helpers/fieldlist.php';
|
||||
|
||||
class JFormFieldModules extends NRFormFieldList
|
||||
{
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
*
|
||||
* @return array An array of JHtml options.
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$db = $this->db;
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query->select('*')
|
||||
->from('#__modules')
|
||||
->where('published=1')
|
||||
->where('access !=3')
|
||||
->order('title');
|
||||
|
||||
$client = isset($this->element['client']) ? (int) $this->element['client'] : false;
|
||||
|
||||
if ($client !== false)
|
||||
{
|
||||
$query->where('client_id = ' . $client);
|
||||
}
|
||||
|
||||
$rows = $db->setQuery($query);
|
||||
$results = $db->loadObjectList();
|
||||
|
||||
$options = array();
|
||||
|
||||
if ($this->showSelect())
|
||||
{
|
||||
$options[] = JHTML::_('select.option', "", '- ' . JText::_("NR_SELECT_MODULE") . ' -');
|
||||
}
|
||||
|
||||
foreach ($results as $option)
|
||||
{
|
||||
$options[] = JHTML::_('select.option', $option->id, $option->title);
|
||||
}
|
||||
|
||||
$options = array_merge(parent::getOptions(), $options);
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
40
plugins/system/nrframework/fields/nrbrowser.php
Normal file
40
plugins/system/nrframework/fields/nrbrowser.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
require_once JPATH_PLUGINS . '/system/nrframework/helpers/fieldlist.php';
|
||||
|
||||
class JFormFieldNRBrowser extends NRFormFieldList
|
||||
{
|
||||
/**
|
||||
* Browsers List
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $options = array(
|
||||
'chrome' => 'NR_CHROME',
|
||||
'firefox' => 'NR_FIREFOX',
|
||||
'edge' => 'NR_EDGE',
|
||||
'ie' => 'NR_IE',
|
||||
'safari' => 'NR_SAFARI',
|
||||
'opera' => 'NR_OPERA'
|
||||
);
|
||||
|
||||
protected function getOptions()
|
||||
{
|
||||
asort($this->options);
|
||||
|
||||
foreach ($this->options as $key => $option)
|
||||
{
|
||||
$options[] = JHTML::_('select.option', $key, JText::_($option));
|
||||
}
|
||||
|
||||
return array_merge(parent::getOptions(), $options);
|
||||
}
|
||||
}
|
||||
392
plugins/system/nrframework/fields/nrchainedfields.php
Normal file
392
plugins/system/nrframework/fields/nrchainedfields.php
Normal file
@@ -0,0 +1,392 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
require_once dirname(__DIR__) . '/helpers/field.php';
|
||||
|
||||
class JFormFieldNRChainedFields extends NRFormField
|
||||
{
|
||||
/**
|
||||
* All CSV choices.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $choices = [];
|
||||
|
||||
/**
|
||||
* The separator used in the CSV file.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $separator = ',';
|
||||
|
||||
/**
|
||||
* The data source contents.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dataset = '';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$layout = new \JLayoutFile('chainedfields', JPATH_PLUGINS . '/system/nrframework/layouts');
|
||||
|
||||
$data_source = $this->get('data_source', 'custom');
|
||||
|
||||
switch ($data_source)
|
||||
{
|
||||
case 'custom':
|
||||
$this->dataset = $this->get('data_source_custom', '');
|
||||
break;
|
||||
|
||||
case 'csv_file':
|
||||
$csv_file = $this->get('data_source_csv', '');
|
||||
|
||||
if (!file_exists($csv_file))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->dataset = $csv_file;
|
||||
break;
|
||||
}
|
||||
|
||||
$this->separator = $this->get('separator', ',');
|
||||
|
||||
$data = [
|
||||
'csv' => $this->dataset,
|
||||
'data_source' => $data_source,
|
||||
'value' => $this->getValue(),
|
||||
'data' => $this->getData()
|
||||
];
|
||||
|
||||
return $layout->render($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the field value.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function getValue()
|
||||
{
|
||||
if (!$this->value)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!$this->choices = \NRFramework\Helpers\ChainedFields::loadCSV($this->dataset, $this->get('data_source', 'custom'), $this->separator, $this->id . '_', $this->name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$choices = $this->choices['inputs'];
|
||||
|
||||
// Ensure the value is in correct format when used as plain field or in subform
|
||||
$this->value = array_values((array) $this->value);
|
||||
|
||||
foreach ($this->choices['inputs'] as $key => $input)
|
||||
{
|
||||
$choices[$key]['choices'] = $this->getSelectedChoices($key, $this->value, $input);
|
||||
}
|
||||
|
||||
return $choices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the choices of the select.
|
||||
*
|
||||
* @param string $key
|
||||
* @param array $value
|
||||
* @param array $input
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function getSelectedChoices($key, $value, $input)
|
||||
{
|
||||
$choices = $this->getSelectChoices($value, $input['id']);
|
||||
|
||||
if (!is_array($choices))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// set selected options based on value
|
||||
foreach ($choices as $_key => &$choice)
|
||||
{
|
||||
if (!isset($value[$key]) || $choice['value'] !== $value[$key])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$choice['isSelected'] = true;
|
||||
}
|
||||
|
||||
return $choices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the AJAX request.
|
||||
*
|
||||
* Runs when select a value from a select field.
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function onAjax($options)
|
||||
{
|
||||
$options = new Registry($options);
|
||||
|
||||
if (!$select_id = $options->get('select_id'))
|
||||
{
|
||||
echo json_encode([
|
||||
'error' => true,
|
||||
'response' => \JText::_('NR_CANNOT_PROCESS_REQUEST')
|
||||
]);
|
||||
jexit();
|
||||
}
|
||||
|
||||
if (!$value = $options->get('value'))
|
||||
{
|
||||
echo json_encode([
|
||||
'error' => true,
|
||||
'response' => \JText::_('NR_CANNOT_PROCESS_REQUEST')
|
||||
]);
|
||||
jexit();
|
||||
}
|
||||
|
||||
if (!$value = json_decode($options->get('value'), true))
|
||||
{
|
||||
echo json_encode([
|
||||
'error' => true,
|
||||
'response' => \JText::_('NR_CANNOT_PROCESS_REQUEST')
|
||||
]);
|
||||
jexit();
|
||||
}
|
||||
|
||||
if (!$data_source = $options->get('data_source'))
|
||||
{
|
||||
echo json_encode([
|
||||
'error' => true,
|
||||
'response' => \JText::_('NR_CANNOT_PROCESS_REQUEST')
|
||||
]);
|
||||
jexit();
|
||||
}
|
||||
|
||||
if (!$csv = $options->get('csv'))
|
||||
{
|
||||
echo json_encode([
|
||||
'error' => true,
|
||||
'response' => \JText::_('NR_CANNOT_PROCESS_REQUEST')
|
||||
]);
|
||||
jexit();
|
||||
}
|
||||
|
||||
$csv = json_decode($csv, true);
|
||||
|
||||
// get field ID from select ID
|
||||
$id = preg_replace('/_[0-9]+$/', '', $select_id);
|
||||
|
||||
if (!$id || !$select_id || !$value || !$csv)
|
||||
{
|
||||
echo json_encode([
|
||||
'error' => true,
|
||||
'response' => \JText::_('NR_CANNOT_PROCESS_REQUEST')
|
||||
]);
|
||||
jexit();
|
||||
}
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
// get all CSV data
|
||||
if (!$this->choices = \NRFramework\Helpers\ChainedFields::loadCSV($csv, $data_source, $this->separator, $this->id . '_', $this->name))
|
||||
{
|
||||
echo json_encode([
|
||||
'error' => true,
|
||||
'response' => \JText::_('NR_CANNOT_PROCESS_REQUEST')
|
||||
]);
|
||||
jexit();
|
||||
}
|
||||
|
||||
// find next select options
|
||||
$this->findNextOptions($id, $select_id, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the options of the next select.
|
||||
*
|
||||
* @param string $id
|
||||
* @param string $select_id
|
||||
* @param array $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function findNextOptions($id, $select_id, $value)
|
||||
{
|
||||
// find next ID
|
||||
$next_select_id = $this->getNextSelectID($id, $select_id);
|
||||
|
||||
// get next choices
|
||||
$choices = $next_select_id ? $this->getSelectChoices($value, $next_select_id) : [];
|
||||
|
||||
echo json_encode([
|
||||
'error' => false,
|
||||
'response' => $choices
|
||||
]);
|
||||
jexit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the select choices.
|
||||
*
|
||||
* @param array $field_value
|
||||
* @param string $select_id
|
||||
* @param integer $depth
|
||||
* @param array $choices
|
||||
* @param array $full_field_value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getSelectChoices($field_value = null, $select_id = null, $depth = null, $choices = null, $full_field_value = null)
|
||||
{
|
||||
$full_field_value = $full_field_value !== null ? $full_field_value : $field_value;
|
||||
$value = array_shift($field_value);
|
||||
$index = $select_id ? $this->getSelectID($select_id) : 1;
|
||||
$depth = $depth ? $depth : 1;
|
||||
$choices = $choices === null ? $this->choices['choices'] : (empty($choices) ? [] : $choices);
|
||||
$select_choices = [];
|
||||
|
||||
if ($depth == $index)
|
||||
{
|
||||
$select_choices = $choices;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($choices as $choice)
|
||||
{
|
||||
if ($choice['value'] !== $value)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$select_choices = $this->getSelectChoices($field_value, $select_id, $depth + 1, !empty($choice['choices']) ? $choice['choices'] : [], $full_field_value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($select_choices) && $this->getPreviousSelectValue($select_id, $full_field_value))
|
||||
{
|
||||
$select_choices = [
|
||||
[
|
||||
'text' => 'No options',
|
||||
'value' => '',
|
||||
'isSelected' => true
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
return $select_choices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the previous select value
|
||||
*
|
||||
* @param string $select_id
|
||||
* @param string $full_field_value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPreviousSelectValue($select_id, $full_field_value)
|
||||
{
|
||||
$explode = explode('_', $select_id);
|
||||
|
||||
$input_id = $explode[count($explode) - 1];
|
||||
$field_id = rtrim($select_id, '_' . $input_id);
|
||||
|
||||
$prev_input_id = sprintf('%s.%s', $field_id, $input_id - 1);
|
||||
$prev_input_value = isset($full_field_value[$prev_input_id]) ? $full_field_value[$prev_input_id] : null;
|
||||
|
||||
return $prev_input_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the next select ID
|
||||
*
|
||||
* @param string $base_id
|
||||
* @param string $select_id
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getNextSelectID($base_id, $select_id)
|
||||
{
|
||||
$id = $this->getSelectID($select_id);
|
||||
$next_id = $id + 1;
|
||||
|
||||
if ($next_id % 10 == 0)
|
||||
{
|
||||
$next_id++;
|
||||
}
|
||||
|
||||
$next_select_id = sprintf('%s_%d', $base_id, $next_id);
|
||||
|
||||
foreach ($this->choices['inputs'] as $input)
|
||||
{
|
||||
if ($input['id'] != $next_select_id)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return $next_select_id;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ID (index) of the select by its ID.
|
||||
*
|
||||
* @param string $select_id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSelectID($select_id)
|
||||
{
|
||||
$explode = explode('_', $select_id);
|
||||
|
||||
return (int) array_pop($explode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches all CSV data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getData()
|
||||
{
|
||||
if (!$this->dataset)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!$choices = \NRFramework\Helpers\ChainedFields::loadCSV($this->dataset, $this->get('data_source', 'csv_file'), $this->separator, $this->id . '_', $this->name))
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
return $choices;
|
||||
}
|
||||
}
|
||||
130
plugins/system/nrframework/fields/nrcomponents.php
Normal file
130
plugins/system/nrframework/fields/nrcomponents.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Tassos.gr <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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
jimport('joomla.filesystem.folder');
|
||||
jimport('joomla.filesystem.file');
|
||||
|
||||
class JFormFieldNRComponents extends JFormFieldList
|
||||
{
|
||||
protected function getOptions()
|
||||
{
|
||||
return array_merge(parent::getOptions(), $this->getInstalledComponents());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get field parameters
|
||||
*
|
||||
* @param string $val Field parameter
|
||||
* @param string $default The default value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get($val, $default = '')
|
||||
{
|
||||
return (isset($this->element[$val]) && (string) $this->element[$val] != '') ? (string) $this->element[$val] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a list of installed components
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getInstalledComponents()
|
||||
{
|
||||
$lang = JFactory::getLanguage();
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
$components = $db->setQuery(
|
||||
$db->getQuery(true)
|
||||
->select('name, element')
|
||||
->from('#__extensions')
|
||||
->where('type = ' . $db->quote('component'))
|
||||
->where('name != ""')
|
||||
->where('element != ""')
|
||||
->where('enabled = 1')
|
||||
->order('element, name')
|
||||
)->loadObjectList();
|
||||
|
||||
$comps = array();
|
||||
|
||||
foreach ($components as $component)
|
||||
{
|
||||
// Make sure we have a valid element
|
||||
if (empty($component->element))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip backend-based only components
|
||||
if ($this->get('frontend', false))
|
||||
{
|
||||
$component_folder = JPATH_SITE . '/components/' . $component->element;
|
||||
|
||||
if (!\JFolder::exists($component_folder))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!\JFolder::exists($component_folder . '/views') &&
|
||||
!\JFolder::exists($component_folder . '/View') &&
|
||||
!\JFolder::exists($component_folder . '/view'))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Try loading component's system language file in order to display a user friendly component name
|
||||
// Runs only if the component's name is not translated already.
|
||||
if (strpos($component->name, ' ') === false)
|
||||
{
|
||||
$filenames = [
|
||||
$component->element . '.sys',
|
||||
$component->element
|
||||
];
|
||||
|
||||
$paths = [
|
||||
JPATH_ADMINISTRATOR,
|
||||
JPATH_ADMINISTRATOR . '/components/' . $component->element,
|
||||
JPATH_SITE,
|
||||
JPATH_SITE . '/components/' . $component->element
|
||||
];
|
||||
|
||||
foreach ($filenames as $key => $filename)
|
||||
{
|
||||
foreach ($paths as $key => $path)
|
||||
{
|
||||
$loaded = $lang->load($filename, $path, null) || $lang->load($filename, $path, $lang->getDefault());
|
||||
|
||||
if ($loaded)
|
||||
{
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Translate component's name
|
||||
$component->name = JText::_(strtoupper($component->name));
|
||||
}
|
||||
|
||||
$comps[strtolower($component->element)] = $component->name;
|
||||
}
|
||||
|
||||
asort($comps);
|
||||
|
||||
$options = array();
|
||||
|
||||
foreach ($comps as $key => $name)
|
||||
{
|
||||
$options[] = JHtml::_('select.option', $key, $name);
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
179
plugins/system/nrframework/fields/nrconditions.php
Normal file
179
plugins/system/nrframework/fields/nrconditions.php
Normal file
@@ -0,0 +1,179 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
use NRFramework\Extension;
|
||||
|
||||
JFormHelper::loadFieldClass('groupedlist');
|
||||
|
||||
class JFormFieldNRConditions extends JFormFieldGroupedList
|
||||
{
|
||||
/**
|
||||
* List of available conditions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $conditions = [
|
||||
'NR_DATETIME' => [
|
||||
'Date\Date' => 'NR_DATE',
|
||||
'Date\Day' => 'NR_WEEKDAY',
|
||||
'Date\Month' => 'NR_MONTH',
|
||||
'Date\Time' => 'NR_TIME'
|
||||
],
|
||||
'Joomla' => [
|
||||
'com_content#Component\ContentArticle' => 'NR_CONTENT_ARTICLE',
|
||||
'com_content#Component\ContentCategory' => 'NR_CONTENT_CATEGORY',
|
||||
'com_content#Component\ContentView' => 'NR_CONTENT_VIEW',
|
||||
'Joomla\UserID' => 'NR_ASSIGN_USER_ID',
|
||||
'Joomla\UserGroup' => 'NR_USERGROUP',
|
||||
'Joomla\AccessLevel' => 'NR_USERACCESSLEVEL',
|
||||
'Joomla\Menu' => 'NR_MENU',
|
||||
'Joomla\Component' => 'NR_ASSIGN_COMPONENTS',
|
||||
'Joomla\Language' => 'NR_ASSIGN_LANGS'
|
||||
],
|
||||
'NR_TECHNOLOGY' => [
|
||||
'Device' => 'NR_ASSIGN_DEVICES',
|
||||
'Browser' => 'NR_ASSIGN_BROWSERS',
|
||||
'OS' => 'NR_ASSIGN_OS'
|
||||
],
|
||||
'NR_GEOLOCATION' => [
|
||||
'Geo\City' => 'NR_CITY',
|
||||
'Geo\Country' => 'NR_ASSIGN_COUNTRIES',
|
||||
'Geo\Region' => 'NR_REGION',
|
||||
'Geo\Continent' => 'NR_CONTINENT'
|
||||
],
|
||||
'NR_INTEGRATIONS' => [
|
||||
'com_rstbox#EngageBox'=> 'NR_VIEWED_ANOTHER_BOX',
|
||||
'com_convertforms#ConvertForms'=> 'NR_CONVERT_FORMS_CAMPAIGN',
|
||||
'com_acymailing#AcyMailing|com_acym#AcyMailing' => 'NR_ACYMAILING_LIST',
|
||||
'com_akeebasubs#AkeebaSubs' => 'NR_AKEEBASUBS_LEVEL',
|
||||
],
|
||||
'VirtueMart' => [
|
||||
'com_virtuemart#Component\VirtueMartCartContainsProducts' => 'NR_VM_CART_CONTAINS_PRODUCTS',
|
||||
'com_virtuemart#Component\VirtueMartCartContainsXProducts' => 'NR_VM_CART_CONTAINS_X_PRODUCTS',
|
||||
'com_virtuemart#Component\VirtueMartCartValue' => 'NR_VM_CART_VALUE',
|
||||
'com_virtuemart#Component\VirtueMartSingle' => 'NR_VM_PRODUCT',
|
||||
'com_virtuemart#Component\VirtueMartCategory' => 'NR_VM_CATEGORY'
|
||||
],
|
||||
'Hikashop' => [
|
||||
'com_hikashop#Component\HikashopCartContainsProducts' => 'NR_HIKA_CART_CONTAINS_PRODUCTS',
|
||||
'com_hikashop#Component\HikashopCartContainsXProducts' => 'NR_HIKA_CART_CONTAINS_X_PRODUCTS',
|
||||
'com_hikashop#Component\HikashopCartValue' => 'NR_HIKA_CART_VALUE',
|
||||
'com_hikashop#Component\HikashopSingle' => 'NR_HIKA_PRODUCT',
|
||||
'com_hikashop#Component\HikashopCategory' => 'NR_HIKA_CATEGORY'
|
||||
],
|
||||
'K2' => [
|
||||
'com_k2#Component\K2Item' => 'NR_K2_ITEM',
|
||||
'com_k2#Component\K2Category' => 'NR_K2_CATEGORY',
|
||||
'com_k2#Component\K2Tag' => 'NR_K2_TAG',
|
||||
'com_k2#Component\K2Pagetype' => 'NR_K2_PAGE_TYPE',
|
||||
],
|
||||
'NR_ADVANCED' => [
|
||||
'URL' => 'NR_URL',
|
||||
'Referrer' => 'NR_ASSIGN_REFERRER',
|
||||
'IP' => 'NR_IPADDRESS',
|
||||
'Pageviews' => 'NR_ASSIGN_PAGEVIEWS_VIEWS',
|
||||
'Cookie' => 'NR_COOKIE',
|
||||
'PHP' => 'NR_ASSIGN_PHP',
|
||||
'TimeOnSite' => 'NR_ASSIGN_TIMEONSITE'
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* Method to get the field option groups.
|
||||
*
|
||||
* @return array The field option objects as a nested array in groups.
|
||||
*/
|
||||
protected function getGroups()
|
||||
{
|
||||
$include_rules = empty($this->element['include_rules']) ? [] : explode(',', $this->element['include_rules']);
|
||||
$exclude_rules = empty($this->element['exclude_rules']) ? [] : explode(',', $this->element['exclude_rules']);
|
||||
|
||||
$groups[''][] = JHtml::_('select.option', null, JText::_('NR_CB_SELECT_CONDITION'));
|
||||
|
||||
foreach (self::$conditions as $conditionGroup => $conditions)
|
||||
{
|
||||
foreach ($conditions as $conditionName => $condition)
|
||||
{
|
||||
$skip_condition = false;
|
||||
|
||||
/**
|
||||
* Checks conditions that have multiple components as dependency.
|
||||
* Check for multiple given components for a particular condition, i.e. acymailing can be loaded via com_acymailing or com_acym
|
||||
*/
|
||||
$multiple_components = explode('|', $conditionName);
|
||||
if (count($multiple_components) >= 2)
|
||||
{
|
||||
foreach ($multiple_components as $component)
|
||||
{
|
||||
$skip_condition = false;
|
||||
|
||||
if (!$conditionName = $this->getConditionName($component))
|
||||
{
|
||||
$skip_condition = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the condition must be skipped, skip it
|
||||
if ($skip_condition)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Checks for a single condition whether its component exists and can be used.
|
||||
if (!$conditionName = $this->getConditionName($conditionName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// If its excluded, skip it
|
||||
if (!empty($exclude_rules) && in_array($conditionName, $exclude_rules))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// If its not included, skip it
|
||||
if (!empty($include_rules) && !in_array($conditionName, $include_rules))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Add condition to the group
|
||||
$groups[JText::_($conditionGroup)][] = JHtml::_('select.option', $conditionName, JText::_($condition), 'value', 'text');
|
||||
}
|
||||
}
|
||||
|
||||
// Merge any additional groups in the XML definition.
|
||||
return array_merge(parent::getGroups(), $groups);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parsed condition name.
|
||||
*
|
||||
* i.e. $condition: com_k2#Component\K2Item
|
||||
* will return: Component\K2Item
|
||||
*
|
||||
* @param string $condition
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function getConditionName($condition)
|
||||
{
|
||||
$conditionNameParts = explode('#', $condition);
|
||||
|
||||
if (count($conditionNameParts) >= 2 && !Extension::isEnabled($conditionNameParts[0]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return isset($conditionNameParts[1]) ? $conditionNameParts[1] : $conditionNameParts[0];
|
||||
}
|
||||
}
|
||||
37
plugins/system/nrframework/fields/nrdevice.php
Normal file
37
plugins/system/nrframework/fields/nrdevice.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
require_once JPATH_PLUGINS . '/system/nrframework/helpers/fieldlist.php';
|
||||
|
||||
class JFormFieldNRDevice extends NRFormFieldList
|
||||
{
|
||||
/**
|
||||
* Browsers List
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $options = array(
|
||||
'desktop' => 'NR_DESKTOPS',
|
||||
'mobile' => 'NR_MOBILES',
|
||||
'tablet' => 'NR_TABLETS'
|
||||
);
|
||||
|
||||
protected function getOptions()
|
||||
{
|
||||
asort($this->options);
|
||||
|
||||
foreach ($this->options as $key => $option)
|
||||
{
|
||||
$options[] = JHTML::_('select.option', $key, JText::_($option));
|
||||
}
|
||||
|
||||
return array_merge(parent::getOptions(), $options);
|
||||
}
|
||||
}
|
||||
46
plugins/system/nrframework/fields/nrdjcatalog2categories.php
Normal file
46
plugins/system/nrframework/fields/nrdjcatalog2categories.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once __DIR__ . '/treeselect.php';
|
||||
|
||||
class JFormFieldNRDJCatalog2Categories extends JFormFieldNRTreeSelect
|
||||
{
|
||||
/**
|
||||
* Indicates whether the options array should be sorted before render.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $sortTree = true;
|
||||
|
||||
/**
|
||||
* Indicates whether the options array should have the levels re-calculated
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $fixLevels = true;
|
||||
|
||||
/**
|
||||
* Get a list of all EventBooking Categories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$db = $this->db;
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('id as value, name as text, parent_id as parent, IF (published=1, 0, 1) as disable')
|
||||
->from('#__djc2_categories');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
}
|
||||
47
plugins/system/nrframework/fields/nrdjcfcategories.php
Normal file
47
plugins/system/nrframework/fields/nrdjcfcategories.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once __DIR__ . '/treeselect.php';
|
||||
|
||||
class JFormFieldNRDJCFCategories extends JFormFieldNRTreeSelect
|
||||
{
|
||||
/**
|
||||
* Indicates whether the options array should be sorted before render.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $sortTree = true;
|
||||
|
||||
/**
|
||||
* Indicates whether the options array should have the levels re-calculated
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $fixLevels = true;
|
||||
|
||||
/**
|
||||
* Get a list of all EventBooking Categories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get a database object.
|
||||
$db = $this->db;
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('id as value, name as text, parent_id as `parent`, IF (published=1, 0, 1) as disable')
|
||||
->from('#__djcf_categories');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
}
|
||||
35
plugins/system/nrframework/fields/nrdjeventscategories.php
Normal file
35
plugins/system/nrframework/fields/nrdjeventscategories.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once __DIR__ . '/treeselect.php';
|
||||
|
||||
class JFormFieldNRDJEventsCategories extends JFormFieldNRTreeSelect
|
||||
{
|
||||
/**
|
||||
* Get a list of all DJ Events Categories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get a database object.
|
||||
$db = $this->db;
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.id as value, a.name as text, 0 AS level, 0 as parent, 0 as disable')
|
||||
->from('#__djev_cats as a')
|
||||
->group('a.id, a.name')
|
||||
->order('a.id ASC');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
}
|
||||
36
plugins/system/nrframework/fields/nreasyblogcategories.php
Normal file
36
plugins/system/nrframework/fields/nreasyblogcategories.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once __DIR__ . '/treeselect.php';
|
||||
|
||||
class JFormFieldNREasyBlogCategories extends JFormFieldNRTreeSelect
|
||||
{
|
||||
/**
|
||||
* Get a list of all EventBooking Categories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get a database object.
|
||||
$db = $this->db;
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.id as value, a.title as text, COUNT(DISTINCT b.id) AS level, a.parent_id as parent, IF (a.published=1, 0, 1) as disable')
|
||||
->from('#__easyblog_category as a')
|
||||
->join('LEFT', '#__easyblog_category AS b on a.lft > b.lft AND a.rgt < b.rgt')
|
||||
->group('a.id, a.title, a.lft')
|
||||
->order('a.lft ASC');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
}
|
||||
48
plugins/system/nrframework/fields/nreshopcategories.php
Normal file
48
plugins/system/nrframework/fields/nreshopcategories.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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once __DIR__ . '/treeselect.php';
|
||||
|
||||
class JFormFieldNREShopCategories extends JFormFieldNRTreeSelect
|
||||
{
|
||||
/**
|
||||
* Indicates whether the options array should be sorted before render.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $sortTree = true;
|
||||
|
||||
/**
|
||||
* Indicates whether the options array should have the levels re-calculated
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $fixLevels = true;
|
||||
|
||||
/**
|
||||
* Get a list of all EventBooking Categories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get a database object.
|
||||
$db = $this->db;
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.id as value, b.category_name as text, a.category_parent_id as parent, IF (a.published=1, 0, 1) as disable')
|
||||
->from('#__eshop_categories as a')
|
||||
->join('LEFT', '#__eshop_categorydetails AS b on a.id=b.category_id');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once __DIR__ . '/treeselect.php';
|
||||
|
||||
class JFormFieldNREventBookingCategories extends JFormFieldNRTreeSelect
|
||||
{
|
||||
/**
|
||||
* Indicates whether the options array should be sorted before render.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $sortTree = true;
|
||||
|
||||
/**
|
||||
* Get a list of all EventBooking Categories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get a database object.
|
||||
$db = $this->db;
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('id as value, name as text, level, parent, IF (published=1, 0, 1) as disable')
|
||||
->from('#__eb_categories');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
}
|
||||
43
plugins/system/nrframework/fields/nrfonts.php
Normal file
43
plugins/system/nrframework/fields/nrfonts.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
JFormHelper::loadFieldClass('groupedlist');
|
||||
|
||||
class JFormFieldNRFonts extends JFormFieldGroupedList
|
||||
{
|
||||
/**
|
||||
* Method to get the field option groups.
|
||||
*
|
||||
* @return array The field option objects as a nested array in groups.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function getGroups()
|
||||
{
|
||||
$groups = array();
|
||||
|
||||
foreach (NRFramework\Fonts::getFontGroups() as $name => $fontGroup)
|
||||
{
|
||||
// Initialize the group if necessary.
|
||||
if (!isset($groups[$name]))
|
||||
{
|
||||
$groups[$name] = array();
|
||||
}
|
||||
|
||||
foreach ($fontGroup as $font)
|
||||
{
|
||||
$groups[$name][] = JHtml::_('select.option', $font, $font);
|
||||
}
|
||||
}
|
||||
|
||||
// Merge any additional groups in the XML definition.
|
||||
return array_merge(parent::getGroups(), $groups);
|
||||
}
|
||||
}
|
||||
47
plugins/system/nrframework/fields/nrgridboxcategories.php
Normal file
47
plugins/system/nrframework/fields/nrgridboxcategories.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once __DIR__ . '/treeselect.php';
|
||||
|
||||
class JFormFieldNRGridboxCategories extends JFormFieldNRTreeSelect
|
||||
{
|
||||
/**
|
||||
* Indicates whether the options array should be sorted before render.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $sortTree = true;
|
||||
|
||||
/**
|
||||
* Indicates whether the options array should have the levels re-calculated
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $fixLevels = true;
|
||||
|
||||
/**
|
||||
* Get a list of all Gridbox Categories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get a database object.
|
||||
$db = $this->db;
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('id as value, title as text, parent as parent, IF (published=1, 0, 1) as disable')
|
||||
->from('#__gridbox_categories');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
}
|
||||
37
plugins/system/nrframework/fields/nrgrouplevel.php
Normal file
37
plugins/system/nrframework/fields/nrgrouplevel.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once __DIR__ . '/treeselect.php';
|
||||
|
||||
class JFormFieldNRGroupLevel extends JFormFieldNRTreeSelect
|
||||
{
|
||||
/**
|
||||
* A helper to get the list of user groups.
|
||||
* Logic from administrator\components\com_config\model\field\filters.php@getUserGroups
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get a database object.
|
||||
$db = $this->db;
|
||||
|
||||
// Get the user groups from the database.
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level')
|
||||
->from('#__usergroups AS a')
|
||||
->join('LEFT', '#__usergroups AS b on a.lft > b.lft AND a.rgt < b.rgt')
|
||||
->group('a.id, a.title, a.lft')
|
||||
->order('a.lft ASC');
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
}
|
||||
38
plugins/system/nrframework/fields/nrhikashopcategories.php
Normal file
38
plugins/system/nrframework/fields/nrhikashopcategories.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once __DIR__ . '/treeselect.php';
|
||||
|
||||
class JFormFieldNRHikaShopCategories extends JFormFieldNRTreeSelect
|
||||
{
|
||||
/**
|
||||
* Get a list of all EventBooking Categories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get a database object.
|
||||
$db = $this->db;
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.category_id as value, a.category_name as text, (a.category_depth - 1) AS level, a.category_parent_id as parent, IF (a.category_published=1, 0, 1) as disable')
|
||||
->from('#__hikashop_category as a')
|
||||
->join('LEFT', '#__hikashop_category AS b on a.category_left > b.category_left AND a.category_right < b.category_right')
|
||||
->group('a.category_id, a.category_name, a.category_left')
|
||||
->where($db->quoteName('a.category_type') . ' = ' . $db->quote('product'))
|
||||
->where($db->quoteName('a.category_id') . ' > 2')
|
||||
->order('a.category_left ASC');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
}
|
||||
113
plugins/system/nrframework/fields/nrimagesselector.php
Normal file
113
plugins/system/nrframework/fields/nrimagesselector.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Convert Forms
|
||||
* @version 3.2.12 Free
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
JFormHelper::loadFieldClass('text');
|
||||
|
||||
class JFormFieldNRImagesSelector extends JFormFieldText
|
||||
{
|
||||
/**
|
||||
* Renders the Images Selector
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$field_attributes = (array) $this->element->attributes();
|
||||
$attributes = isset($field_attributes["@attributes"]) ? $field_attributes["@attributes"] : null;
|
||||
$field_attributes = new JRegistry($attributes);
|
||||
|
||||
if (!$images = $field_attributes->get('images', ''))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$columns = $field_attributes->get('columns', 6);
|
||||
$width = $field_attributes->get('width', '100%');
|
||||
$height = $field_attributes->get('height', '');
|
||||
$key_type = $field_attributes->get('key_type', null);
|
||||
|
||||
$class = 'cols_' . $columns . (!empty($this->class) ? ' ' . $this->class : '');
|
||||
|
||||
$paths = explode(',', $images);
|
||||
|
||||
$images = [];
|
||||
foreach ($paths as $key => $path)
|
||||
{
|
||||
// skip empty paths
|
||||
if (empty(rtrim(ltrim($path, ' '), ' ')))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($imgs = $this->getImagesFromPath($path))
|
||||
{
|
||||
// add new images to array of images
|
||||
$images = array_merge($images, $imgs);
|
||||
}
|
||||
else
|
||||
{
|
||||
// check if image exist
|
||||
if (file_exists(JPATH_ROOT . '/' . ltrim($path, ' /')))
|
||||
{
|
||||
// add new image to array of images
|
||||
$images[] = ltrim($path, ' /');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// load CSS
|
||||
JHtml::script('plg_system_nrframework/images-selector-field.js', ['relative' => true, 'version' => true]);
|
||||
JHtml::stylesheet('plg_system_nrframework/images-selector-field.css', ['relative' => true, 'version' => true]);
|
||||
|
||||
$layout = new \JLayoutFile('imagesselector', JPATH_PLUGINS . '/system/nrframework/layouts');
|
||||
|
||||
$data = [
|
||||
'value' => !empty($this->value) ? $this->value : $this->default,
|
||||
'name' => $this->name,
|
||||
'class' => $class,
|
||||
'key_type' => $key_type,
|
||||
'images' => $images,
|
||||
'columns' => $columns,
|
||||
'id' => $this->id,
|
||||
'required' => $this->required,
|
||||
'width' => $width,
|
||||
'height' => $height
|
||||
];
|
||||
|
||||
return $layout->render($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all images in path
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function getImagesFromPath($path)
|
||||
{
|
||||
$folder = JPATH_ROOT . '/' . ltrim($path, ' /');
|
||||
|
||||
if (!is_dir($folder) || !$folder_files = scandir($folder))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$images = array_diff($folder_files, array('.', '..', '.DS_Store'));
|
||||
$images = array_values($images);
|
||||
|
||||
// prepend path to image file names
|
||||
array_walk($images, function(&$value, $key) use ($path) { $value = ltrim($path, ' /') . '/' . $value; } );
|
||||
|
||||
return $images;
|
||||
}
|
||||
}
|
||||
151
plugins/system/nrframework/fields/nrinlinefileupload.php
Normal file
151
plugins/system/nrframework/fields/nrinlinefileupload.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
require_once dirname(__DIR__) . '/helpers/field.php';
|
||||
|
||||
class JFormFieldNRInlineFileUpload extends NRFormField
|
||||
{
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$layout = new \JLayoutFile('inlinefileupload', JPATH_PLUGINS . '/system/nrframework/layouts');
|
||||
|
||||
$data = [
|
||||
'value' => $this->value,
|
||||
'name' => $this->name,
|
||||
'accept' => $this->get('accept'),
|
||||
'upload_folder' => base64_encode($this->get('upload_folder'))
|
||||
];
|
||||
|
||||
return $layout->render($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the AJAX request
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function onAjax($options)
|
||||
{
|
||||
$options = new Registry($options);
|
||||
|
||||
if ($options->get('action') == 'remove')
|
||||
{
|
||||
$this->onRemove($options);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->onUpload();
|
||||
}
|
||||
|
||||
/**
|
||||
* On file upload.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function onUpload()
|
||||
{
|
||||
// Make sure we have a valid file passed
|
||||
if (!$file = $this->app->input->files->get('file', null, null))
|
||||
{
|
||||
echo json_encode([
|
||||
'error' => true,
|
||||
'response' => \JText::_('NR_UPLOAD_ERROR_INVALID_FILE')
|
||||
]);
|
||||
jexit();
|
||||
}
|
||||
|
||||
// ensure an upload folder was given
|
||||
if (!$upload_folder = $this->app->input->get('upload_folder', null, null))
|
||||
{
|
||||
echo json_encode([
|
||||
'error' => true,
|
||||
'response' => \JText::_('NR_UPLOAD_FOLDER_MISSING')
|
||||
]);
|
||||
jexit();
|
||||
}
|
||||
|
||||
// ensure we can decode its value
|
||||
if (!$upload_folder = base64_decode($upload_folder))
|
||||
{
|
||||
echo json_encode([
|
||||
'error' => true,
|
||||
'response' => \JText::_('NR_UPLOAD_FOLDER_INVALID')
|
||||
]);
|
||||
jexit();
|
||||
}
|
||||
|
||||
$uploaded_file = null;
|
||||
$file_size = 0;
|
||||
$file_name = null;
|
||||
|
||||
// try to upload the file.
|
||||
try {
|
||||
$uploaded_file = \NRFramework\File::upload($file, JPATH_ROOT . DIRECTORY_SEPARATOR . $upload_folder, 'text/plain', false, true);
|
||||
$filePathInfo = NRFramework\File::pathinfo($uploaded_file);
|
||||
$file_name = $filePathInfo['basename'];
|
||||
$file_size = JFile::exists($uploaded_file) ? filesize($uploaded_file) : 0;
|
||||
$file_size = $file_size ? number_format($file_size / 1024, 2) . ' KB' : $file_size;
|
||||
} catch (\Throwable $th)
|
||||
{
|
||||
echo json_encode([
|
||||
'error' => true,
|
||||
'response' => $th->getMessage()
|
||||
]);
|
||||
jexit();
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
'error' => false,
|
||||
'response' => \JText::_('NR_FILE_UPLOADED_SUCCESSFULLY'),
|
||||
'file_name' => base64_encode($file_name),
|
||||
'file' => base64_encode($uploaded_file),
|
||||
'file_size' => $file_size
|
||||
]);
|
||||
jexit();
|
||||
}
|
||||
|
||||
/**
|
||||
* On file removal.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function onRemove($options)
|
||||
{
|
||||
if (!$file = $options->get('remove_file'))
|
||||
{
|
||||
echo json_encode([
|
||||
'error' => true,
|
||||
'response' => \JText::_('NR_UPLOAD_ERROR_INVALID_FILE')
|
||||
]);
|
||||
jexit();
|
||||
}
|
||||
|
||||
// If file exists, remove it
|
||||
if (file_exists($file))
|
||||
{
|
||||
unlink($file);
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
'error' => false,
|
||||
'response' => \JText::_('NR_FILE_DELETED')
|
||||
]);
|
||||
jexit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once __DIR__ . '/treeselect.php';
|
||||
|
||||
class JFormFieldNRJBusinessDirectoryCategories extends JFormFieldNRTreeSelect
|
||||
{
|
||||
/**
|
||||
* Get a list of all J-BusinessDirectory Categories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
$filter_type = isset($this->element['filter_type']) ? (string) $this->element['filter_type'] : 1;
|
||||
|
||||
// Get a database object.
|
||||
$db = $this->db;
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.id as value, a.name as text, a.level AS level, a.parent_id as parent, IF (a.published=1, 0, 1) as disable')
|
||||
->from('#__jbusinessdirectory_categories as a')
|
||||
->join('LEFT', '#__jbusinessdirectory_categories AS b on a.lft > b.lft AND a.rgt < b.rgt')
|
||||
->where($db->quoteName('a.type') . ' = ' . $db->q($filter_type))
|
||||
->group('a.id, a.name, a.lft')
|
||||
->order('a.lft ASC');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
}
|
||||
37
plugins/system/nrframework/fields/nrjcalprocategories.php
Normal file
37
plugins/system/nrframework/fields/nrjcalprocategories.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once __DIR__ . '/treeselect.php';
|
||||
|
||||
class JFormFieldNRJCalProCategories extends JFormFieldNRTreeSelect
|
||||
{
|
||||
/**
|
||||
* Get a list of all EventBooking Categories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get a database object.
|
||||
$db = $this->db;
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.id as value, a.title as text, COUNT(DISTINCT b.id) AS level, a.parent_id as parent, IF (a.published=1, 0, 1) as disable')
|
||||
->from('#__categories as a')
|
||||
->join('LEFT', '#__categories AS b on a.lft > b.lft AND a.rgt < b.rgt')
|
||||
->where('a.extension = "com_jcalpro"')
|
||||
->group('a.id, a.title, a.lft')
|
||||
->order('a.lft ASC');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
}
|
||||
37
plugins/system/nrframework/fields/nrjeventscategories.php
Normal file
37
plugins/system/nrframework/fields/nrjeventscategories.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once __DIR__ . '/treeselect.php';
|
||||
|
||||
class JFormFieldNRJEventsCategories extends JFormFieldNRTreeSelect
|
||||
{
|
||||
/**
|
||||
* Get a list of all EventBooking Categories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get a database object.
|
||||
$db = $this->db;
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.id as value, a.title as text, COUNT(DISTINCT b.id) AS level, a.parent_id as parent, IF (a.published=1, 0, 1) as disable')
|
||||
->from('#__categories as a')
|
||||
->join('LEFT', '#__categories AS b on a.lft > b.lft AND a.rgt < b.rgt')
|
||||
->where('a.extension = "com_jevents"')
|
||||
->group('a.id, a.title, a.lft')
|
||||
->order('a.lft ASC');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
}
|
||||
66
plugins/system/nrframework/fields/nrjshoppingcategories.php
Normal file
66
plugins/system/nrframework/fields/nrjshoppingcategories.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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once __DIR__ . '/treeselect.php';
|
||||
|
||||
class JFormFieldNRJShoppingCategories extends JFormFieldNRTreeSelect
|
||||
{
|
||||
/**
|
||||
* Indicates whether the options array should be sorted before render.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $sortTree = true;
|
||||
|
||||
/**
|
||||
* Indicates whether the options array should have the levels re-calculated
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $fixLevels = true;
|
||||
|
||||
/**
|
||||
* Get a list of all EventBooking Categories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get a database object.
|
||||
$db = $this->db;
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('name_' . $this->getLanguage(), 'text'))
|
||||
->select('category_id as value, category_parent_id as parent, IF (category_publish=1, 0, 1) as disable')
|
||||
->from('#__jshopping_categories');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
|
||||
/**
|
||||
* JoomShopping is using different columns per language. Therefore, we need to use their API to get the default language code.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getLanguage($default = 'en-GB')
|
||||
{
|
||||
// Silent inclusion.
|
||||
@include_once JPATH_SITE . '/components/com_jshopping/lib/factory.php';
|
||||
|
||||
if (!class_exists('JSFactory'))
|
||||
{
|
||||
return $default;
|
||||
}
|
||||
|
||||
return JSFactory::getConfig()->defaultLanguage;
|
||||
}
|
||||
}
|
||||
152
plugins/system/nrframework/fields/nrk2.php
Normal file
152
plugins/system/nrframework/fields/nrk2.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Tassos.gr <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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
require_once JPATH_PLUGINS . '/system/nrframework/helpers/groupfield.php';
|
||||
|
||||
class JFormFieldNRK2 extends NRFormGroupField
|
||||
{
|
||||
public $type = 'K2';
|
||||
|
||||
/**
|
||||
* Pagetypes options
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $pagetype_options = array(
|
||||
'itemlist_category' => 'NR_ASSIGN_K2_CATEGORY_OPTION',
|
||||
'item_item' => 'NR_ASSIGN_K2_ITEM_OPTION',
|
||||
'item_itemform' => 'NR_ASSIGN_K2_ITEM_FORM_OPTION',
|
||||
'latest_latest' => 'NR_ASSIGN_K2_LATEST_OPTION',
|
||||
'itemlist_tag' => 'NR_ASSIGN_K2_TAG_OPTION',
|
||||
'itemlist_user' => 'NR_ASSIGN_K2_USER_PAGE_OPTION'
|
||||
);
|
||||
|
||||
|
||||
public function getItems()
|
||||
{
|
||||
$query = $this->db->getQuery(true);
|
||||
$query
|
||||
->select('i.id, i.title as name, i.language, c.name as cat, i.published')
|
||||
->from('#__k2_items as i')
|
||||
->join('LEFT', '#__k2_categories AS c ON c.id = i.catid')
|
||||
->order('i.title, i.ordering, i.id');
|
||||
$this->db->setQuery($query);
|
||||
$list = $this->db->loadObjectList();
|
||||
|
||||
return $this->getOptionsByList($list, array('language', 'cat', 'id'));
|
||||
}
|
||||
|
||||
public function getPagetypes()
|
||||
{
|
||||
asort($this->pagetype_options);
|
||||
|
||||
foreach ($this->pagetype_options as $key => $option)
|
||||
{
|
||||
$options[] = JHTML::_('select.option', $key, JText::_($option));
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getTags()
|
||||
{
|
||||
$query = $this->db->getQuery(true);
|
||||
$query
|
||||
->select('t.id, t.name')
|
||||
->from('#__k2_tags as t')
|
||||
->order('t.id');
|
||||
$this->db->setQuery($query);
|
||||
$list = $this->db->loadObjectList();
|
||||
|
||||
return $this->getOptionsByList($list);
|
||||
}
|
||||
|
||||
public function getCategories()
|
||||
{
|
||||
$query = $this->db->getQuery(true);
|
||||
$query
|
||||
->select('c.id, c.name, c.parent, c.published, c.language')
|
||||
->from('#__k2_categories as c')
|
||||
->where('c.trash = 0')
|
||||
->where('c.id != c.parent')
|
||||
->order('c.ordering');
|
||||
$this->db->setQuery($query);
|
||||
$cats = $this->db->loadObjectList();
|
||||
|
||||
$options = [];
|
||||
// get category levels
|
||||
foreach ($cats as $c)
|
||||
{
|
||||
$level = 0;
|
||||
$parent_id = (int)$c->parent;
|
||||
|
||||
while ($parent_id)
|
||||
{
|
||||
$level++;
|
||||
$parent_id = $this->getNextParentId($cats, $parent_id);
|
||||
}
|
||||
|
||||
$c->level = $level;
|
||||
$options[] = $c;
|
||||
}
|
||||
|
||||
// sort options
|
||||
$options = $this->sortTreeSelectOptions($options);
|
||||
return $this->getOptionsByList($options, array('language'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts treeselect options
|
||||
*
|
||||
* @param array $options
|
||||
* @param int $parent_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function sortTreeSelectOptions($options, $parent_id = 0)
|
||||
{
|
||||
if (empty($options))
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
||||
$sub_options = array_filter($options, function($option) use($parent_id)
|
||||
{
|
||||
return $option->parent == $parent_id;
|
||||
});
|
||||
|
||||
foreach ($sub_options as $option)
|
||||
{
|
||||
$result[] = $option;
|
||||
$result = array_merge($result, $this->sortTreeSelectOptions($options, $option->id));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next parent id
|
||||
* Helper method for getCategories
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getNextParentId($categories, $current_pid)
|
||||
{
|
||||
foreach($categories as $c)
|
||||
{
|
||||
if ((int)$c->id === $current_pid)
|
||||
{
|
||||
return (int)$c->parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
125
plugins/system/nrframework/fields/nrmenuitems.php
Normal file
125
plugins/system/nrframework/fields/nrmenuitems.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use \NRFramework\HTML;
|
||||
|
||||
require_once dirname(__DIR__) . '/helpers/field.php';
|
||||
|
||||
|
||||
class JFormFieldNRMenuItems extends NRFormField
|
||||
{
|
||||
/**
|
||||
* Output the HTML for the field
|
||||
* Example of usage: <field name="field_name" type="nrmenuitems" label="NR_SELECTION" />
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$size = $this->get('size', 300);
|
||||
$options = $this->getMenuItems();
|
||||
|
||||
return HTML::treeselect($options, $this->name, $this->value, $this->id, $size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of menu links for one or all menus.
|
||||
* Logic from administrator\components\com_menus\helpers\menus.php@getMenuLinks()
|
||||
*/
|
||||
public function getMenuItems()
|
||||
{
|
||||
NRFramework\Functions::loadLanguage('com_menus', JPATH_ADMINISTRATOR);
|
||||
$db = $this->db;
|
||||
|
||||
// Prevent the "The SELECT would examine more than MAX_JOIN_SIZE rows; " MySQL error
|
||||
// on websites with a big number of menu items in the db.
|
||||
$db->setQuery('SET SQL_BIG_SELECTS = 1')->execute();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.id AS value, a.title AS text, a.alias, a.level, a.menutype, a.type, a.template_style_id, a.checked_out, a.language')
|
||||
->from('#__menu AS a')
|
||||
->join('LEFT', $db->quoteName('#__menu') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt')
|
||||
->where('a.published != -2')
|
||||
->group('a.id, a.alias, a.title, a.level, a.menutype, a.type, a.template_style_id, a.checked_out, a.lft, a.language')
|
||||
->order('a.lft ASC');
|
||||
|
||||
// Get the options.
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$links = $db->loadObjectList();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
JFactory::getApplication()->enqueueMessage($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Group the items by menutype.
|
||||
$query->clear()
|
||||
->select('*')
|
||||
->from('#__menu_types')
|
||||
->where('menutype <> ' . $db->quote(''))
|
||||
->order('title, menutype');
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$menuTypes = $db->loadObjectList();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
JFactory::getApplication()->enqueueMessage($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create a reverse lookup and aggregate the links.
|
||||
$rlu = array();
|
||||
foreach ($menuTypes as &$type)
|
||||
{
|
||||
$type->value = 'type.' . $type->menutype;
|
||||
$type->text = $type->title;
|
||||
$type->level = 0;
|
||||
$type->class = 'hidechildren';
|
||||
$type->labelclass = 'nav-header';
|
||||
|
||||
$rlu[$type->menutype] = &$type;
|
||||
$type->links = array();
|
||||
}
|
||||
|
||||
foreach ($links as &$link)
|
||||
{
|
||||
if (isset($rlu[$link->menutype]))
|
||||
{
|
||||
if (preg_replace('#[^a-z0-9]#', '', strtolower($link->text)) !== preg_replace('#[^a-z0-9]#', '', $link->alias))
|
||||
{
|
||||
$link->text .= ' <small>[' . $link->alias . ']</small>';
|
||||
}
|
||||
|
||||
if ($link->language && $link->language != '*')
|
||||
{
|
||||
$link->text .= ' <small>(' . $link->language . ')</small>';
|
||||
}
|
||||
|
||||
if ($link->type == 'alias')
|
||||
{
|
||||
$link->text .= ' <small>(' . JText::_('COM_MENUS_TYPE_ALIAS') . ')</small>';
|
||||
$link->disable = 1;
|
||||
}
|
||||
|
||||
$rlu[$link->menutype]->links[] = &$link;
|
||||
|
||||
unset($link->menutype);
|
||||
}
|
||||
}
|
||||
|
||||
return $menuTypes;
|
||||
}
|
||||
|
||||
}
|
||||
67
plugins/system/nrframework/fields/nrmodulepositions.php
Normal file
67
plugins/system/nrframework/fields/nrmodulepositions.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2019 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once JPATH_PLUGINS . '/system/nrframework/helpers/fieldlist.php';
|
||||
|
||||
class JFormFieldNRModulePositions extends NRFormFieldList
|
||||
{
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
*
|
||||
* @return array An array of JHtml options.
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// get templates
|
||||
$templates = $this->getTemplates();
|
||||
|
||||
require_once JPATH_ADMINISTRATOR . '/components/com_templates/helpers/templates.php';
|
||||
|
||||
// get all position options
|
||||
$options = [];
|
||||
|
||||
$options[] = JHTML::_('select.option', '', \JText::_('NR_NONE_SELECTED'));
|
||||
foreach ($templates as $template) {
|
||||
$options[] = JHTML::_('select.option', '<OPTGROUP>', $template->name);
|
||||
|
||||
// find all positions for template
|
||||
$positions = TemplatesHelper::getPositions(0, $template->element);
|
||||
foreach ($positions as $position) {
|
||||
$options[] = JHTML::_('select.option', $position, $position);
|
||||
}
|
||||
|
||||
$options[] = JHTML::_('select.option', '</OPTGROUP>');
|
||||
}
|
||||
|
||||
return array_merge(parent::getOptions(), $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all enabled templates
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
private function getTemplates()
|
||||
{
|
||||
$db = $this->db;
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
$query->select('element, name, enabled');
|
||||
$query->from('#__extensions');
|
||||
$query->where('client_id = 0');
|
||||
$query->where('type = '.$db->quote('template'));
|
||||
$query->where('enabled = 1');
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
}
|
||||
55
plugins/system/nrframework/fields/nrmodules.php
Normal file
55
plugins/system/nrframework/fields/nrmodules.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2019 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once JPATH_PLUGINS . '/system/nrframework/helpers/fieldlist.php';
|
||||
|
||||
class JFormFieldNRModules extends NRFormFieldList
|
||||
{
|
||||
/**
|
||||
* Provide a list of all published modules.
|
||||
*
|
||||
* @return array An array of JHtml options.
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get modules
|
||||
$modules = $this->getModules();
|
||||
|
||||
// get all position options
|
||||
$options = [];
|
||||
|
||||
$options[] = JHTML::_('select.option', '', \JText::_('NR_NONE_SELECTED'));
|
||||
foreach ($modules as $module) {
|
||||
$options[] = JHTML::_('select.option', $module->id, $module->title . ' (' . $module->id . ')');
|
||||
}
|
||||
|
||||
return array_merge(parent::getOptions(), $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all enabled modules.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
private function getModules()
|
||||
{
|
||||
$db = $this->db;
|
||||
|
||||
$query = $db->getQuery(true);
|
||||
$query->select('id, title');
|
||||
$query->from('#__modules');
|
||||
$query->where('published = 1');
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
}
|
||||
41
plugins/system/nrframework/fields/nrnumber.php
Normal file
41
plugins/system/nrframework/fields/nrnumber.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('number');
|
||||
|
||||
class JFormFieldNRNumber extends JFormFieldNumber
|
||||
{
|
||||
/**
|
||||
* Method to render the input field
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getInput()
|
||||
{
|
||||
$parent = parent::getInput();
|
||||
$addon = (string) $this->element['addon'];
|
||||
|
||||
if (empty($addon))
|
||||
{
|
||||
return $parent;
|
||||
}
|
||||
|
||||
return '
|
||||
<div class="input-append input-group">
|
||||
' . $parent . '
|
||||
<span class="add-on input-group-append">
|
||||
<span class="input-group-text" style="font-size:inherit;">' . JText::_($addon) . '</span>
|
||||
</span>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
}
|
||||
41
plugins/system/nrframework/fields/nros.php
Normal file
41
plugins/system/nrframework/fields/nros.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
require_once JPATH_PLUGINS . '/system/nrframework/helpers/fieldlist.php';
|
||||
|
||||
class JFormFieldNROs extends NRFormFieldList
|
||||
{
|
||||
/**
|
||||
* Browsers List
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $options = array(
|
||||
'linux' => 'NR_LINUX',
|
||||
'mac' => 'NR_MAC',
|
||||
'android' => 'NR_ANDROID',
|
||||
'ios' => 'NR_IOS',
|
||||
'windows' => 'NR_WINDOWS',
|
||||
'blackberry' => 'NR_BLACKBERRY',
|
||||
'chromeos' => 'NR_CHROMEOS'
|
||||
);
|
||||
|
||||
protected function getOptions()
|
||||
{
|
||||
asort($this->options);
|
||||
|
||||
foreach ($this->options as $key => $option)
|
||||
{
|
||||
$options[] = JHTML::_('select.option', $key, JText::_($option));
|
||||
}
|
||||
|
||||
return array_merge(parent::getOptions(), $options);
|
||||
}
|
||||
}
|
||||
225
plugins/system/nrframework/fields/nrresponsivecontrol.php
Normal file
225
plugins/system/nrframework/fields/nrresponsivecontrol.php
Normal file
@@ -0,0 +1,225 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2018 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('text');
|
||||
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
class JFormFieldNRResponsiveControl extends JFormFieldText
|
||||
{
|
||||
/**
|
||||
* Method to render the input field
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getInput()
|
||||
{
|
||||
return $this->getLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns html for all devices
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getFieldsData()
|
||||
{
|
||||
if (!$fieldsList = $this->getSubformFieldsList())
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
$html = [
|
||||
'desktop' => '',
|
||||
'tablet' => '',
|
||||
'mobile' => ''
|
||||
];
|
||||
|
||||
$base_name = $fieldsList['base_name'];
|
||||
|
||||
// Control default value
|
||||
$control_default = json_decode($this->default, true);
|
||||
|
||||
// loop for all devices
|
||||
foreach ($html as $device => &$device_output)
|
||||
{
|
||||
// loop all fields
|
||||
foreach ($fieldsList['fields'] as $fieldName)
|
||||
{
|
||||
$name = $fieldName;
|
||||
|
||||
// Default value of the input for breakpoint
|
||||
$default = null;
|
||||
|
||||
if ($control_default && isset($control_default[$device][$name]))
|
||||
{
|
||||
$default = $control_default[$device][$name];
|
||||
}
|
||||
|
||||
$field_data = $this->getFieldInputByDevice($name, $device, $default);
|
||||
$field_html = $field_data['html'];
|
||||
|
||||
$field_html = str_replace(
|
||||
[
|
||||
'[' . $this->group . '][' . $name . ']',
|
||||
'_' . $this->group . '_' . $name
|
||||
],
|
||||
[
|
||||
'[' . $this->group . '][' . $base_name . '][' . $name . '][' . $device . ']',
|
||||
'_' . $this->group . '_' . $base_name . '_' . $name . '_' . $device
|
||||
], $field_html
|
||||
);
|
||||
|
||||
// Render layout
|
||||
$payload = [
|
||||
'label' => $field_data['label'],
|
||||
'description' => $field_data['description'],
|
||||
'data' => $field_html
|
||||
];
|
||||
$layout = new JLayoutFile('responsive_control_item', JPATH_PLUGINS . '/system/nrframework/layouts');
|
||||
$device_output .= $layout->render($payload);
|
||||
}
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the field layout
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getLayout()
|
||||
{
|
||||
JHtml::stylesheet('plg_system_nrframework/responsive_control.css', ['relative' => true, 'version' => 'auto']);
|
||||
JHtml::script('plg_system_nrframework/responsive_control.js', ['relative' => true, 'version' => 'auto']);
|
||||
|
||||
$width = isset($this->element['width']) ? (string) $this->element['width'] : '300px';
|
||||
$title = isset($this->element['title']) ? (string) $this->element['title'] : '';
|
||||
$class = isset($this->element['class']) ? ' ' . (string) $this->element['class'] : '';
|
||||
|
||||
if (defined('nrJ4'))
|
||||
{
|
||||
$class .= ' isJ4';
|
||||
}
|
||||
|
||||
$data = [
|
||||
'title' => JText::_($title),
|
||||
'width' => $width,
|
||||
'class' => $class,
|
||||
'fields' => $this->getFieldsData()
|
||||
];
|
||||
|
||||
// Render layout
|
||||
$layout = new JLayoutFile('responsive_control', JPATH_PLUGINS . '/system/nrframework/layouts');
|
||||
return $layout->render($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of added fields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getSubformFieldsList()
|
||||
{
|
||||
$el = $this->element;
|
||||
|
||||
if (empty(count($el->subform)))
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
$data = [
|
||||
'base_name' => $el->attributes()->name,
|
||||
'fields' => []
|
||||
];
|
||||
|
||||
foreach ($el->subform->field as $key => $field)
|
||||
{
|
||||
$data['fields'][] = (string) $field->attributes()->name;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the field's title and value
|
||||
*
|
||||
* @param string $field_name The field name of the field.
|
||||
* @param string $device The breakpoint of the field.
|
||||
* @param string $default The default value of the field.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getFieldInputByDevice($field_name, $device, $default = null)
|
||||
{
|
||||
$el = $this->element;
|
||||
|
||||
$data = [];
|
||||
|
||||
foreach ($el->subform->field as $key => $field)
|
||||
{
|
||||
if ((string) $field->attributes()->name != $field_name)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get input value
|
||||
$value = $this->getFieldInputValue($field_name, $device);
|
||||
|
||||
// If no value is set, get the default value (if given)
|
||||
if (!$value && $default)
|
||||
{
|
||||
$value = $default;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'label' => JText::_((string) $field->attributes()->label),
|
||||
'description' => JText::_((string) $field->attributes()->description),
|
||||
'html' => $this->form->getInput($field_name, $this->group, $value)
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the field input value
|
||||
*
|
||||
* @param string $field_name
|
||||
* @param string $device
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getFieldInputValue($field_name, $device)
|
||||
{
|
||||
$values = $this->getValue();
|
||||
$values = new Registry($values);
|
||||
|
||||
return $values->get($field_name . '.' . $device);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the field value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function getValue()
|
||||
{
|
||||
if (empty($this->value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
37
plugins/system/nrframework/fields/nrrsblogcategories.php
Normal file
37
plugins/system/nrframework/fields/nrrsblogcategories.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once __DIR__ . '/treeselect.php';
|
||||
|
||||
class JFormFieldNRRSBlogCategories extends JFormFieldNRTreeSelect
|
||||
{
|
||||
/**
|
||||
* Get a list of all EventBooking Categories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get a database object.
|
||||
$db = $this->db;
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.id as value, a.title as text, (COUNT(DISTINCT b.id) - 1) AS level, a.parent_id as parent, IF (a.published=1, 0, 1) as disable')
|
||||
->from('#__rsblog_categories as a')
|
||||
->where('a.parent_id > 0')
|
||||
->join('LEFT', '#__rsblog_categories AS b on a.lft > b.lft AND a.rgt < b.rgt')
|
||||
->group('a.id, a.title, a.lft')
|
||||
->order('a.lft ASC');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
}
|
||||
60
plugins/system/nrframework/fields/nrsobiprocategories.php
Normal file
60
plugins/system/nrframework/fields/nrsobiprocategories.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once __DIR__ . '/treeselect.php';
|
||||
|
||||
class JFormFieldNRSobiProCategories extends JFormFieldNRTreeSelect
|
||||
{
|
||||
/**
|
||||
* Indicates whether the options array should be sorted before render.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $sortTree = true;
|
||||
|
||||
/**
|
||||
* Indicates whether the options array should have the levels re-calculated
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $fixLevels = true;
|
||||
|
||||
/**
|
||||
* Increase the value(ID) of the category by one.
|
||||
* This happens because we have a parent category "Bussiness Directory" that pushes-in the indentation
|
||||
* and we reset it by decreasing the value, level and parent.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $increaseValue = true;
|
||||
|
||||
/**
|
||||
* Get a list of all SobiPro Categories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get a database object.
|
||||
$db = $this->db;
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('(a.id - 1) as value, b.sValue as text, (a.parent - 1) as level, (a.parent - 1) as parent, IF (a.state=1, 0, 1) as disable')
|
||||
->from('#__sobipro_object as a')
|
||||
->join('LEFT', "#__sobipro_language AS b on a.id = b.id AND b.sKey = 'name'")
|
||||
->where($db->quoteName('a.oType') . ' = '. $db->quote('category'));
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
$result = $db->loadObjectList();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once __DIR__ . '/treeselect.php';
|
||||
|
||||
class JFormFieldNRSPPageBuilderCategories extends JFormFieldNRTreeSelect
|
||||
{
|
||||
/**
|
||||
* Get a list of all EventBooking Categories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get a database object.
|
||||
$db = $this->db;
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.id as value, a.title as text, (COUNT(DISTINCT b.id) - 1) AS level, a.parent_id as parent, IF (a.published=1, 0, 1) as disable')
|
||||
->from('#__categories as a')
|
||||
->join('LEFT', '#__categories AS b on a.lft > b.lft AND a.rgt < b.rgt')
|
||||
->where('a.extension = "com_sppagebuilder"')
|
||||
->group('a.id, a.title, a.lft')
|
||||
->order('a.lft ASC');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
}
|
||||
93
plugins/system/nrframework/fields/nrtext.php
Normal file
93
plugins/system/nrframework/fields/nrtext.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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('text');
|
||||
|
||||
class JFormFieldNRText extends JFormFieldText
|
||||
{
|
||||
/**
|
||||
* Method to render the input field
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getInput()
|
||||
{
|
||||
// This line added to help us support the K2 Items and Joomla! Articles dropdown listbox array values
|
||||
$this->value = is_array($this->value) ? implode(',', $this->value) : $this->value;
|
||||
|
||||
// Adds an extra info label next to input
|
||||
$addon = (string) $this->element['addon'];
|
||||
$parent = parent::getInput();
|
||||
|
||||
if (!empty($addon))
|
||||
{
|
||||
$html[] = '
|
||||
<div class="input-append input-group">
|
||||
' . $parent . '
|
||||
<span class="add-on input-group-append">
|
||||
<span class="input-group-text" style="font-size:inherit;">' . JText::_($addon) . '</span>
|
||||
</span>
|
||||
</div>';
|
||||
} else
|
||||
{
|
||||
$html[] = parent::getInput();
|
||||
}
|
||||
|
||||
// Adds a link next to input
|
||||
$url = $this->element['url'];
|
||||
$text = $this->element['urltext'];
|
||||
$target = $this->element['urltarget'] ? $this->element['urltarget'] : "_blank";
|
||||
$class = $this->element['urlclass'] ? $this->element['urlclass'] : "";
|
||||
$attributes = "";
|
||||
|
||||
// Popup mode
|
||||
if ($this->element["urlpopup"])
|
||||
{
|
||||
$class .= " nrPopup";
|
||||
$attributes = 'data-width="600" data-height="600"';
|
||||
$this->addPopupScript();
|
||||
}
|
||||
|
||||
if ($url && $text)
|
||||
{
|
||||
$html[] = '<a ' . $attributes . ' class="' . $class . '" style="margin-left:10px;" href="' . $url . '" target="' . $target . '">' . JText::_($text) . '</a>';
|
||||
}
|
||||
|
||||
return implode('', $html);
|
||||
}
|
||||
|
||||
private function addPopupScript()
|
||||
{
|
||||
static $run;
|
||||
|
||||
if ($run)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$run = true;
|
||||
|
||||
JFactory::getDocument()->addScriptDeclaration('
|
||||
jQuery(function($) {
|
||||
$(".nrPopup").click(function() {
|
||||
url = $(this).attr("href");
|
||||
width = $(this).data("width");
|
||||
height = $(this).data("height");
|
||||
|
||||
window.open(""+url+"", "nrPopup", "width=" + width + ", height=" + height + "");
|
||||
|
||||
return false;
|
||||
})
|
||||
})
|
||||
');
|
||||
}
|
||||
}
|
||||
66
plugins/system/nrframework/fields/nrtoggle.php
Normal file
66
plugins/system/nrframework/fields/nrtoggle.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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use NRFramework\HTML;
|
||||
|
||||
JFormHelper::loadFieldClass('checkbox');
|
||||
|
||||
/**
|
||||
* Pure CSS iOS-like Toggle Button based on the Checkbox field.
|
||||
*
|
||||
* This field also fixes the Unchecked checkbox value using a hidden field.
|
||||
* Credits: http://mistercameron.com/2008/01/unchecked-checkbox-values/
|
||||
*/
|
||||
class JFormFieldNRToggle extends JFormFieldCheckbox
|
||||
{
|
||||
/**
|
||||
* On state value
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $on_value = 1;
|
||||
|
||||
/**
|
||||
* Off state value
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $off_value = 0;
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getInput()
|
||||
{
|
||||
HTML::stylesheet('plg_system_nrframework/toggle.css');
|
||||
|
||||
$required = $this->required ? ' required aria-required="true"' : '';
|
||||
$checked = $this->checked ? ' checked' : '';
|
||||
$class = !empty($this->class) ? ' ' . $this->class : '';
|
||||
|
||||
// Fix bug inherited from the Checkbox field where the input remains checked even if save it unchecked.
|
||||
if ($this->checked && (string) $this->value == (string) $this->off_value)
|
||||
{
|
||||
$checked = '';
|
||||
}
|
||||
|
||||
return '
|
||||
<span class="nrtoggle' . $class . '">
|
||||
<input type="hidden" name="' . $this->name . '" id="' . $this->id . '_" value="' . $this->off_value . '">
|
||||
<input type="checkbox" name="' . $this->name . '" id="' . $this->id . '" value="'
|
||||
. htmlspecialchars($this->on_value, ENT_COMPAT, 'UTF-8') . '"' . $checked . $required . ' />
|
||||
<label for="' . $this->id . '"></label>
|
||||
</span>
|
||||
';
|
||||
}
|
||||
}
|
||||
58
plugins/system/nrframework/fields/nrurl.php
Normal file
58
plugins/system/nrframework/fields/nrurl.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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once dirname(__DIR__) . '/helpers/field.php';
|
||||
|
||||
class JFormFieldNRURL extends NRFormField
|
||||
{
|
||||
/**
|
||||
* Method to render the input field
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getInput()
|
||||
{
|
||||
$url = $this->get("url", "#");
|
||||
$target = $this->get("target", "_blank");
|
||||
$text = $this->get("text");
|
||||
$class = $this->get("class");
|
||||
$icon = $this->get("icon", null);
|
||||
|
||||
$url = str_replace("{{base}}", JURI::base(), $url);
|
||||
$url = str_replace("{{root}}", JURI::root(), $url);
|
||||
|
||||
$html[] = '<a class="nrurl ' . $class . '" href="' . $url . '" target="' . $target . '">';
|
||||
|
||||
if ($icon)
|
||||
{
|
||||
$html[] = '<span class="icon-'.$icon.'"></span>';
|
||||
}
|
||||
|
||||
$html[] = $this->prepareText($text);
|
||||
$html[] = '</a>';
|
||||
|
||||
// Add CSS to the page
|
||||
$run = false;
|
||||
if (!$run)
|
||||
{
|
||||
JFactory::getDocument()->addStyleDeclaration('
|
||||
.nrurl.disabled {
|
||||
pointer-events: none;
|
||||
}
|
||||
');
|
||||
|
||||
$run = true;
|
||||
}
|
||||
|
||||
return implode(" ", $html);
|
||||
}
|
||||
}
|
||||
71
plugins/system/nrframework/fields/nrvirtuemartcategories.php
Normal file
71
plugins/system/nrframework/fields/nrvirtuemartcategories.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once __DIR__ . '/treeselect.php';
|
||||
|
||||
class JFormFieldNRVirtueMartCategories extends JFormFieldNRTreeSelect
|
||||
{
|
||||
/**
|
||||
* Indicates whether the options array should be sorted before render.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $sortTree = true;
|
||||
|
||||
/**
|
||||
* Indicates whether the options array should have the levels re-calculated
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $fixLevels = true;
|
||||
|
||||
/**
|
||||
* Get a list of all EventBooking Categories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get a database object.
|
||||
$db = $this->db;
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.virtuemart_category_id as value, b.category_name as text, c.category_parent_id as parent, IF (a.published=1, 0, 1) as disable')
|
||||
->from('#__virtuemart_categories as a')
|
||||
->join('LEFT', '#__virtuemart_categories_' . $this->getLanguage() . ' AS b on a.virtuemart_category_id = b.virtuemart_category_id')
|
||||
->join('LEFT', '#__virtuemart_category_categories AS c on a.virtuemart_category_id = c.id')
|
||||
->order('c.id desc');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
|
||||
/**
|
||||
* VirtueMart is using different tables per language. Therefore, we need to use their API to get the default language code
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getLanguage($default = 'en_gb')
|
||||
{
|
||||
// Silent inclusion.
|
||||
@include_once JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/config.php';
|
||||
|
||||
if (!class_exists('VmConfig'))
|
||||
{
|
||||
return $default;
|
||||
}
|
||||
|
||||
// Init configuration
|
||||
VmConfig::loadConfig();
|
||||
|
||||
return VmConfig::$jDefLang;
|
||||
}
|
||||
}
|
||||
48
plugins/system/nrframework/fields/nrzoocategories.php
Normal file
48
plugins/system/nrframework/fields/nrzoocategories.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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once __DIR__ . '/treeselect.php';
|
||||
|
||||
class JFormFieldNRZooCategories extends JFormFieldNRTreeSelect
|
||||
{
|
||||
/**
|
||||
* Indicates whether the options array should be sorted before render.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $sortTree = true;
|
||||
|
||||
/**
|
||||
* Indicates whether the options array should have the levels re-calculated
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $fixLevels = true;
|
||||
|
||||
/**
|
||||
* Get a list of all EventBooking Categories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get a database object.
|
||||
$db = $this->db;
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('id as value, name as text, parent as `parent`, IF (published=1, 0, 1) as disable')
|
||||
->from('#__zoo_category')
|
||||
->order('ordering');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
}
|
||||
68
plugins/system/nrframework/fields/password.php
Normal file
68
plugins/system/nrframework/fields/password.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('password');
|
||||
|
||||
class JFormFieldNR_Password extends JFormFieldPassword
|
||||
{
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*/
|
||||
public function getInput()
|
||||
{
|
||||
if (defined('nrJ4'))
|
||||
{
|
||||
return parent::getInput();
|
||||
}
|
||||
|
||||
$id = $this->id . '_btn';
|
||||
|
||||
$doc = JFactory::getDocument();
|
||||
|
||||
JHtml::stylesheet('plg_system_nrframework/fields.css', false, true);
|
||||
|
||||
$doc->addStyleDeclaration('
|
||||
.nr-pass-btn {
|
||||
display:flex;
|
||||
align-items:center;
|
||||
}
|
||||
.nr-pass-btn > * {
|
||||
margin:0 !important;
|
||||
padding:0 !important;
|
||||
}
|
||||
.nr-pass-btn label {
|
||||
margin-left:5px !important;
|
||||
user-select: none;
|
||||
}
|
||||
');
|
||||
|
||||
$doc->addScriptDeclaration('
|
||||
jQuery(function($) {
|
||||
$("#' . $id . '").change(function() {
|
||||
var type = $(this).is(":checked") ? "text" : "password";
|
||||
$(this).closest(".nr-pass").find(".nr-pass-input input").attr("type", type);
|
||||
})
|
||||
})
|
||||
');
|
||||
|
||||
return '
|
||||
<div class="nr-pass input-flex">
|
||||
<div class="input-flex-item nr-pass-input">'. parent::getInput() .'</div>
|
||||
<div class="input-flex-item nr-pass-btn">
|
||||
<input name="' . $id . '" id="' . $id . '" type="checkbox"/>
|
||||
<label for="' . $id . '">'.JText::_("JSHOW").'</label>
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
}
|
||||
49
plugins/system/nrframework/fields/pro.php
Normal file
49
plugins/system/nrframework/fields/pro.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
class JFormFieldNR_PRO extends JFormField
|
||||
{
|
||||
/**
|
||||
* Method to render the input field
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$label = (string) $this->element['label'];
|
||||
$isFeatureMode = !is_null($label) && !empty($label);
|
||||
|
||||
$buttonText = $isFeatureMode ? 'NR_UNLOCK_PRO_FEATURE' : 'NR_UPGRADE_TO_PRO';
|
||||
|
||||
NRFramework\HTML::renderProOnlyModal();
|
||||
|
||||
$html = '<a style="float:none;" class="btn btn-danger btn-sm" href="#" data-pro-only="' . JText::_($label) . '">';
|
||||
|
||||
if (defined('nrJ4'))
|
||||
{
|
||||
$html .= '<span class="icon-lock mr-2"></span> ';
|
||||
} else
|
||||
{
|
||||
if ($isFeatureMode)
|
||||
{
|
||||
$html .= '<span class="icon-lock mr-2" style="position:relative; top:1px;"></span> ';
|
||||
} else
|
||||
{
|
||||
$html .= '<span class="icon-heart mr-2" style="position:relative; top:2px; left:-1px;"></span> ';
|
||||
}
|
||||
}
|
||||
|
||||
$html .= JText::_($buttonText) . '</a>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
108
plugins/system/nrframework/fields/rate.php
Normal file
108
plugins/system/nrframework/fields/rate.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('text');
|
||||
|
||||
require_once dirname(__DIR__) . '/helpers/field.php';
|
||||
|
||||
class JFormFieldNR_Rate extends NRFormField
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'nr_rate';
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*/
|
||||
public function getInput()
|
||||
{
|
||||
// Setup properties
|
||||
$this->starwidth = $this->get('starwidth', '25px');
|
||||
$this->numstarts = $this->get('numstars', 5);
|
||||
$this->maxvalue = $this->get('maxvalue', 5);
|
||||
$this->halfstar = $this->get('halfstar', 0) ? "true" : "false";
|
||||
$this->spacing = $this->get('spacing', "3px");
|
||||
$this->ratedfill = $this->get('ratedfill', "#e7711b");
|
||||
$this->value = empty($this->value) ? 0 : $this->value;
|
||||
|
||||
static $run;
|
||||
if (!$run)
|
||||
{
|
||||
// Add styles and scripts to DOM
|
||||
JHtml::_('jquery.framework');
|
||||
JHtml::script('plg_system_nrframework/vendor/jquery.rateyo.min.js', ['relative' => true, 'version' => true]);
|
||||
JHtml::stylesheet('plg_system_nrframework/vendor/jquery.rateyo.min.css', ['relative' => true, 'version' => true]);
|
||||
|
||||
$this->doc->addStyleDeclaration('
|
||||
.nr_rate {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.nr_rate_preview {
|
||||
background-color: #393939;
|
||||
color: #fff;
|
||||
padding: 7px;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
min-width: 20px;
|
||||
text-align: center;
|
||||
border-radius: 2px;
|
||||
position:relative;
|
||||
top:2px;
|
||||
}
|
||||
.nr_rate .jq-ry-container {
|
||||
padding: 0 10px 0 0;
|
||||
}
|
||||
.nr_rate svg {
|
||||
max-width: unset;
|
||||
}
|
||||
');
|
||||
|
||||
$run = true;
|
||||
}
|
||||
|
||||
$this->doc->addScriptDeclaration('
|
||||
jQuery(function($) {
|
||||
$("#nr_rate_'.$this->id.'").rateYo({
|
||||
rating: ' . $this->value . ',
|
||||
starWidth: "'. $this->starwidth .'",
|
||||
numStars: ' . $this->numstarts . ',
|
||||
maxValue: ' . $this->maxvalue . ',
|
||||
halfStar: ' . $this->halfstar . ',
|
||||
spacing: "' . $this->spacing . '",
|
||||
ratedFill: "' . $this->ratedfill . '",
|
||||
onInit: function (rating) {
|
||||
$(this).parent().find(".nr_rate_preview").html(rating);
|
||||
},
|
||||
onSet: function(rating) {
|
||||
$(this).next("input").val(rating);
|
||||
},
|
||||
onChange: function(rating) {
|
||||
$(this).parent().find(".nr_rate_preview").html(rating);
|
||||
}
|
||||
});
|
||||
});
|
||||
');
|
||||
|
||||
$html[] = '<div class="nr_rate">';
|
||||
$html[] = '<div id="nr_rate_'.$this->id.'"></div>';
|
||||
$html[] = '<input value="' . $this->value . '" name="' . $this->name . '" type="hidden"/>';
|
||||
$html[] = '<span class="nr_rate_preview"></span>';
|
||||
$html[] = '</div>';
|
||||
|
||||
return implode(" ", $html);
|
||||
}
|
||||
}
|
||||
32
plugins/system/nrframework/fields/rulevaluehint.php
Normal file
32
plugins/system/nrframework/fields/rulevaluehint.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
class JFormFieldRuleValueHint extends JFormField
|
||||
{
|
||||
protected function getLabel()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to render the input field
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$ruleName = (string) $this->element['ruleName'];
|
||||
$rule = \NRFramework\Factory::getCondition($ruleName);
|
||||
|
||||
return '<div class="ruleValueHint">' . $rule->getValueHint() . '</div>';
|
||||
}
|
||||
}
|
||||
193
plugins/system/nrframework/fields/smarttags.php
Normal file
193
plugins/system/nrframework/fields/smarttags.php
Normal file
@@ -0,0 +1,193 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once dirname(__DIR__) . "/helpers/smarttags.php";
|
||||
require_once dirname(__DIR__) . '/helpers/field.php';
|
||||
|
||||
class JFormFieldNR_SmartTags extends NRFormField
|
||||
{
|
||||
/**
|
||||
* Method to render the input field
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getInput()
|
||||
{
|
||||
$smartTags = new NRSmartTags();
|
||||
|
||||
// Add extra tags by calling an external method
|
||||
if ($tagsMethod = $this->get("tagsMethod", null))
|
||||
{
|
||||
$method = explode("::", $tagsMethod);
|
||||
|
||||
if (is_array($method))
|
||||
{
|
||||
$extraTags = call_user_func($method);
|
||||
$smartTags->add($extraTags);
|
||||
}
|
||||
}
|
||||
|
||||
$tags = $smartTags->get();
|
||||
|
||||
if (!$tags || !is_array($tags))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$html[] = '
|
||||
<div class="nrSmartTags">
|
||||
<a class="nrst-btn"
|
||||
href="#"
|
||||
data-show-label="' . JText::_("NR_SMARTTAGS_SHOW") . '"
|
||||
data-hide-label="' . JText::_("NR_SMARTTAGS_HIDE") . '">
|
||||
<span class="icon icon-tag"></span>
|
||||
<span class="l">' . $this->prepareText($this->get("linklabel", "NR_SMARTTAGS_SHOW")) . '</span>
|
||||
</a>
|
||||
<div class="nrst-wrap">
|
||||
<div class="nrst-list">';
|
||||
|
||||
foreach ($tags as $tag => $value)
|
||||
{
|
||||
$html[] = '<div><a href="#" data-clipboard="' . $tag . '">' . $tag . '</a></div>';
|
||||
}
|
||||
|
||||
$html[] = '</div></div></div>';
|
||||
|
||||
$this->addScript();
|
||||
|
||||
return implode(" ", $html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds field's script and CSS into the document once
|
||||
*/
|
||||
private function addScript()
|
||||
{
|
||||
static $run;
|
||||
|
||||
if ($run)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Add script
|
||||
$this->doc->addScriptDeclaration('
|
||||
jQuery(function($) {
|
||||
$(".nrst-btn").click(function() {
|
||||
list = $(this).next();
|
||||
$(this).find(".l").html(list.is(":visible") ? $(this).data("show-label") : $(this).data("hide-label"));
|
||||
list.slideToggle();
|
||||
})
|
||||
|
||||
$(".nrst-list a").click(function() {
|
||||
var tag = $(this);
|
||||
copyTextToClipboard(tag.data("clipboard"), function(success) {
|
||||
if (success) {
|
||||
tag.addClass("copied");
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
tag.removeClass("copied");
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
function copyTextToClipboard(text, callback) {
|
||||
var textArea = document.createElement("textarea");
|
||||
textArea.style.position = "fixed";
|
||||
textArea.style.top = 0;
|
||||
textArea.style.left = 0;
|
||||
textArea.style.width = "2em";
|
||||
textArea.style.height = "2em";
|
||||
textArea.style.background = "transparent";
|
||||
textArea.value = text;
|
||||
document.body.appendChild(textArea);
|
||||
textArea.select();
|
||||
|
||||
try {
|
||||
var success = document.execCommand("copy");
|
||||
callback(success);
|
||||
} catch (err) {
|
||||
callback(false);
|
||||
}
|
||||
|
||||
document.body.removeChild(textArea);
|
||||
}
|
||||
})
|
||||
');
|
||||
|
||||
// Add height
|
||||
if ($height = $this->get("height", null))
|
||||
{
|
||||
$this->doc->addStyleDeclaration('
|
||||
.nrst-wrap {
|
||||
height: ' . $height . ';
|
||||
overflow-x: hidden;
|
||||
padding-right: 10px;
|
||||
}'
|
||||
);
|
||||
}
|
||||
|
||||
// Add CSS
|
||||
$this->doc->addStyleDeclaration('
|
||||
.nrst-wrap {
|
||||
display:none;
|
||||
}
|
||||
.nrst-list {
|
||||
display:flex;
|
||||
flex-wrap: wrap;
|
||||
margin:10px -3px 0 -3px;
|
||||
}
|
||||
.nrst-list div {
|
||||
min-width:50%;
|
||||
}
|
||||
.nrst-list a {
|
||||
-webkit-transition: background 150ms ease;
|
||||
-moz-transition: background 150ms ease;
|
||||
transition: background 150ms ease;
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
border: solid 1px #ddd;
|
||||
padding: 7px;
|
||||
line-height: 1;
|
||||
margin: 3px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.nrst-list a:hover {
|
||||
background-color:#eee;
|
||||
}
|
||||
.nrst-list a:after {
|
||||
font-family: "IcoMoon";
|
||||
font-style: normal;
|
||||
speak: none;
|
||||
float: right;
|
||||
font-size: 10px;
|
||||
line-height: 1;
|
||||
}
|
||||
.nrst-list a:hover:after {
|
||||
content: "\e018";
|
||||
}
|
||||
.nrst-list a.copied {
|
||||
background:#dff0d8;
|
||||
}
|
||||
.nrst-list a.copied:after {
|
||||
content: "\47";
|
||||
color: green;
|
||||
}
|
||||
');
|
||||
|
||||
$run = true;
|
||||
}
|
||||
}
|
||||
102
plugins/system/nrframework/fields/smarttagsbox.php
Normal file
102
plugins/system/nrframework/fields/smarttagsbox.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Convert Forms
|
||||
* @version 3.2.12 Free
|
||||
*
|
||||
* @author Tassos Marinos <info@tassos.gr>
|
||||
* @link http://www.tassos.gr
|
||||
* @copyright Copyright © 2022 Tassos Marinos All Rights Reserved
|
||||
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
use NRFramework\SmartTags;
|
||||
|
||||
class JFormFieldSmartTagsBox extends JFormField
|
||||
{
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $input_selector = '.show-smart-tags';
|
||||
|
||||
/**
|
||||
* Disable field label
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function getLabel()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
*
|
||||
* @return array An array of JHtml options.
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
JHtml::_('script', 'plg_system_nrframework/smarttagsbox.js', ['version' => 'auto', 'relative' => true]);
|
||||
JHtml::_('stylesheet', 'plg_system_nrframework/smarttagsbox.css', ['version' => 'auto', 'relative' => true]);
|
||||
|
||||
JText::script('NR_SMARTTAGS_NOTFOUND');
|
||||
JText::script('NR_SMARTTAGS_SHOW');
|
||||
|
||||
JFactory::getDocument()->addScriptOptions('SmartTagsBox', [
|
||||
'selector' => $this->input_selector,
|
||||
'tags' => [
|
||||
'Joomla' => [
|
||||
'{page.title}' => 'Page Title',
|
||||
'{url}' => 'Page URL',
|
||||
'{url.path}' => 'Page Path',
|
||||
'{page.lang}' => 'Page Language Code',
|
||||
'{page.langurl}' => 'Page Language URL',
|
||||
'{page.desc}' => 'Page Meta Description',
|
||||
'{site.name}' => 'Site Name',
|
||||
'{site.url}' => 'Site URL',
|
||||
'{site.email}' => 'Site Email',
|
||||
'{user.id}' => 'User ID',
|
||||
'{user.username}' => 'User Username',
|
||||
'{user.email}' => 'User Email',
|
||||
'{user.name}' => 'User Full name',
|
||||
'{user.firstname}' => 'User First name',
|
||||
'{user.lastname}' => 'User Last name',
|
||||
'{user.groups}' => 'User Group IDs',
|
||||
'{user.registerdate}' => 'User Registration Date',
|
||||
],
|
||||
'Visitor' => [
|
||||
'{client.device}' => 'Visitor Device Type',
|
||||
'{ip}' => 'Visitor IP Address',
|
||||
'{client.browser}' => 'Visitor Browser',
|
||||
'{client.os}' => 'Visitor Operating System',
|
||||
'{client.useragent}' => 'Visitor User Agent String',
|
||||
'{client.id}' => JText::_('NR_TAG_CLIENTID'),
|
||||
'{geo.country}' => JText::_('NR_TAG_GEOCOUNTRY'),
|
||||
'{geo.countrycode}' => JText::_('NR_TAG_GEOCOUNTRYCODE'),
|
||||
'{geo.city}' => JText::_('NR_TAG_GEOCITY'),
|
||||
'{geo.location}' => JText::_('NR_TAG_GEOLOCATION'),
|
||||
],
|
||||
'Other' => [
|
||||
'{date}' => 'Date',
|
||||
'{time}' => 'Time',
|
||||
'{day}' => 'Day',
|
||||
'{month}' => 'Month',
|
||||
'{year}' => 'Year',
|
||||
'{referrer}' => 'Referrer URL',
|
||||
'{randomid}' => 'Random ID',
|
||||
'{querystring.YOUR_KEY}' => 'Query String',
|
||||
'{language.YOUR_KEY}' => 'Language String',
|
||||
'{post.YOUR_KEY}' => 'POST Data'
|
||||
]
|
||||
]
|
||||
]);
|
||||
|
||||
// Render box layout
|
||||
$layout = new JLayoutFile('smarttagsbox', JPATH_PLUGINS . '/system/nrframework/layouts');
|
||||
return $layout->render();
|
||||
}
|
||||
}
|
||||
92
plugins/system/nrframework/fields/tfbordercontrol.php
Normal file
92
plugins/system/nrframework/fields/tfbordercontrol.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Convert Forms
|
||||
* @version 3.2.12 Free
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
class JFormFieldTFBorderControl extends JFormField
|
||||
{
|
||||
protected function getInput()
|
||||
{
|
||||
// Control Group Class
|
||||
$control_group_class = (string) $this->element['control_group_class'];
|
||||
|
||||
// Hides the inner control labels
|
||||
$hide_labels = (bool) $this->element['hide_labels'];
|
||||
$hiddenLabel = $hide_labels ? 'hiddenLabel="true"' : '';
|
||||
|
||||
// Prefix and suffix for the fieldset
|
||||
$prefix = $suffix = '';
|
||||
|
||||
// Whether to display the fields inline
|
||||
$inline = (bool) $this->element['inline'];
|
||||
if ($inline)
|
||||
{
|
||||
$prefix = '<field name="border_control_row_start" type="nr_inline" />';
|
||||
$suffix = '<field name="border_control_row_end" type="nr_inline" end="1" />';
|
||||
}
|
||||
|
||||
$form_source = new SimpleXMLElement('
|
||||
<form>
|
||||
<fieldset name="border">
|
||||
' . $prefix . '
|
||||
<field name="style" type="list"
|
||||
' . $hiddenLabel . '
|
||||
label="NR_STYLE"
|
||||
description="NR_BORDER_CONTROL_STYLE_DESC"
|
||||
required="' . $this->required . '"
|
||||
disabled="' . $this->disabled . '">
|
||||
<option value="none">NR_NONE</option>
|
||||
<option value="solid">NR_SOLID</option>
|
||||
<option value="dotted">NR_DOTTED</option>
|
||||
<option value="dashed">NR_DASHED</option>
|
||||
<option value="double">NR_DOUBLE</option>
|
||||
<option value="groove">NR_GROOVE</option>
|
||||
<option value="ridge">NR_RIDGE</option>
|
||||
</field>
|
||||
<field name="width" type="nrnumber"
|
||||
' . $hiddenLabel . '
|
||||
label="NR_WIDTH"
|
||||
description="NR_BORDER_WIDTH_DESC"
|
||||
class="input-small"
|
||||
default="0"
|
||||
required="' . $this->required . '"
|
||||
disabled="' . $this->disabled . '"
|
||||
addon="px"
|
||||
showon="style!:none"
|
||||
/>
|
||||
<field name="color" type="color"
|
||||
' . $hiddenLabel . '
|
||||
label="NR_COLOR"
|
||||
description="NR_BORDER_COLOR_DESC"
|
||||
keywords="transparent,none"
|
||||
format="rgba"
|
||||
position="bottom"
|
||||
required="' . $this->required . '"
|
||||
disabled="' . $this->disabled . '"
|
||||
showon="style!:none"
|
||||
/>
|
||||
' . $suffix . '
|
||||
</fieldset>
|
||||
</form>
|
||||
');
|
||||
|
||||
$control = $this->name;
|
||||
$formname = 'border.' . str_replace(['jform[', '[', ']'], ['', '.', ''], $control);
|
||||
|
||||
$form = JForm::getInstance($formname, $form_source->asXML(), ['control' => $control]);
|
||||
$form->bind($this->value);
|
||||
|
||||
return $form->renderFieldset('border', [
|
||||
'class' => $control_group_class
|
||||
]);
|
||||
}
|
||||
}
|
||||
30
plugins/system/nrframework/fields/tfborderradiuscontrol.php
Normal file
30
plugins/system/nrframework/fields/tfborderradiuscontrol.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Convert Forms
|
||||
* @version 3.2.12 Free
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
require 'tfdimensioncontrol.php';
|
||||
|
||||
class JFormFieldTFBorderRadiusControl extends JFormFieldTFDimensionControl
|
||||
{
|
||||
/**
|
||||
* Set the dimensions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dimensions = [
|
||||
'top_left' => 'NR_TOP_LEFT',
|
||||
'top_right' => 'NR_TOP_RIGHT',
|
||||
'bottom_right' => 'NR_BOTTOM_RIGHT',
|
||||
'bottom_left' => 'NR_BOTTOM_LEFT'
|
||||
];
|
||||
}
|
||||
116
plugins/system/nrframework/fields/tfdimensioncontrol.php
Normal file
116
plugins/system/nrframework/fields/tfdimensioncontrol.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Convert Forms
|
||||
* @version 3.2.12 Free
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
JFormHelper::loadFieldClass('text');
|
||||
|
||||
class JFormFieldTFDimensionControl extends JFormFieldText
|
||||
{
|
||||
/**
|
||||
* Set the dimensions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dimensions = [
|
||||
'top' => 'NR_TOP',
|
||||
'right' => 'NR_RIGHT',
|
||||
'bottom' => 'NR_BOTTOM',
|
||||
'left' => 'NR_LEFT'
|
||||
];
|
||||
|
||||
/**
|
||||
* Set whether the linked button will be enabled or not.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $linked = true;
|
||||
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
* @return array An array of JHtml options.
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
if (!$this->dimensions = isset($this->element['dimensions']) ? $this->parseDimensions($this->element['dimensions']) : $this->dimensions)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->assets();
|
||||
|
||||
$this->linked = isset($this->element['linked']) ? (boolean) $this->element['linked'] : (isset($this->value->linked) ? (boolean) $this->value->linked : $this->linked);
|
||||
|
||||
$payload = [
|
||||
'dimensions' => $this->dimensions,
|
||||
'linked' => $this->linked,
|
||||
'name' => $this->name,
|
||||
'value' => $this->value
|
||||
];
|
||||
|
||||
$layout = new JLayoutFile('dimension', JPATH_PLUGINS . '/system/nrframework/layouts/controls');
|
||||
return $layout->render($payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the given dimensions.
|
||||
*
|
||||
* Input:
|
||||
*
|
||||
* - top:NR_TOP,right:NR_RIGHT,bottom:NR_BOTTOM,left:NR_LEFT
|
||||
* - top_left:Top Left,top_right:Top Right,bottom_right:Bottom Right,bottom_left:Bottom Left
|
||||
*
|
||||
* @param array $dimensions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function parseDimensions($dimensions = [])
|
||||
{
|
||||
$pairs = explode(',', $dimensions);
|
||||
|
||||
$parsed = [];
|
||||
|
||||
if (empty(array_filter($pairs)))
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
foreach ($pairs as $key => $pair)
|
||||
{
|
||||
if (!$value = explode(':', $pair))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// We expect 2 key,value pairs
|
||||
if (count($value) !== 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$parsed[$value[0]] = \JText::_($value[1]);
|
||||
}
|
||||
|
||||
return $parsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load field assets.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function assets()
|
||||
{
|
||||
JHtml::stylesheet('plg_system_nrframework/controls/dimension.css', ['relative' => true, 'versioning' => 'auto']);
|
||||
JHtml::script('plg_system_nrframework/controls/dimension.js', ['relative' => true, 'version' => true]);
|
||||
}
|
||||
}
|
||||
95
plugins/system/nrframework/fields/tfinputrepeater.php
Normal file
95
plugins/system/nrframework/fields/tfinputrepeater.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Convert Forms
|
||||
* @version 3.2.12 Free
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
JFormHelper::loadFieldClass('subform');
|
||||
|
||||
class JFormFieldTFInputRepeater extends JFormFieldSubform
|
||||
{
|
||||
/**
|
||||
* Method to attach a Form 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)
|
||||
{
|
||||
$element->addAttribute('multiple', true);
|
||||
|
||||
// By default initialize the field with an empty item.
|
||||
if (empty($value))
|
||||
{
|
||||
$value = [0 => ''];
|
||||
}
|
||||
|
||||
// In case we have provided a default value in the XML in JSON format
|
||||
if ($value && is_string($value))
|
||||
{
|
||||
// Attempt to decode as JSON
|
||||
$value_ = json_decode($value, true);
|
||||
|
||||
// If JSON decode fails, expect comma-separated or newline-separated values
|
||||
if (is_null($value_))
|
||||
{
|
||||
$value = NRFramework\Functions::makeArray($value);
|
||||
|
||||
$new_value = [];
|
||||
|
||||
foreach ($value as $key => $val)
|
||||
{
|
||||
$new_value['value' . $key] = [
|
||||
'value' => $val
|
||||
];
|
||||
}
|
||||
|
||||
$value = $new_value;
|
||||
} else
|
||||
{
|
||||
$value = $value_;
|
||||
}
|
||||
}
|
||||
|
||||
parent::setup($element, $value, $group);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a list of options for a list input.
|
||||
* @return array An array of JHtml options.
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$this->layout = 'joomla.form.field.subform.repeatable-table';
|
||||
|
||||
$this->assets();
|
||||
|
||||
return '<div class="tf-input-repeater ' . $this->class . '">' . parent::getInput() . '<a href="#" class="btn tf-input-repeater-add"><span class="icon-plus"></span></a></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Load field assets.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function assets()
|
||||
{
|
||||
JHtml::stylesheet('plg_system_nrframework/tfinputrepeater.css', ['relative' => true, 'versioning' => 'auto']);
|
||||
JHtml::script('plg_system_nrframework/tfinputrepeater.js', ['relative' => true, 'version' => true]);
|
||||
}
|
||||
}
|
||||
94
plugins/system/nrframework/fields/time.php
Normal file
94
plugins/system/nrframework/fields/time.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once dirname(__DIR__) . '/helpers/field.php';
|
||||
|
||||
class JFormFieldNR_Time extends NRFormField
|
||||
{
|
||||
|
||||
/**
|
||||
* Sets the time value
|
||||
*
|
||||
* @var string $time_value
|
||||
*/
|
||||
private $time_value = null;
|
||||
|
||||
/**
|
||||
* Method to get the field input markup.
|
||||
*
|
||||
* @return string The field input markup.
|
||||
*/
|
||||
public function getInput()
|
||||
{
|
||||
// Setup properties
|
||||
$this->hint = $this->get('hint', '00:00');
|
||||
$this->class = $this->get('class');
|
||||
$this->placement = $this->get('placement', 'top');
|
||||
$this->align = $this->get('align', 'left');
|
||||
$this->autoclose = $this->get('autoclose', 'true');
|
||||
$this->default = $this->get('default', 'now');
|
||||
$this->donetext = $this->get('donetext', 'Done');
|
||||
$this->required = $this->get('required') === 'true';
|
||||
|
||||
/**
|
||||
* When an object is created using this class, it cannot set $this->value
|
||||
* So we set $time_value and then use it's value to display the time
|
||||
*/
|
||||
$this->value = !is_null($this->time_value) ? $this->time_value : $this->value;
|
||||
|
||||
// Add styles and scripts to DOM
|
||||
JHtml::_('jquery.framework');
|
||||
JHtml::script('plg_system_nrframework/vendor/jquery-clockpicker.min.js', ['relative' => true, 'version' => true]);
|
||||
JHtml::stylesheet('plg_system_nrframework/vendor/jquery-clockpicker.min.css', ['relative' => true, 'version' => true]);
|
||||
|
||||
static $run;
|
||||
// Run once to initialize it
|
||||
if (!$run)
|
||||
{
|
||||
$this->doc->addScriptDeclaration('
|
||||
jQuery(function($) {
|
||||
$(".clockpicker").clockpicker();
|
||||
});
|
||||
');
|
||||
|
||||
// Fix a CSS conflict caused by the template.css on Joomla 3
|
||||
if (!defined('nrJ4'))
|
||||
{
|
||||
// Fuck you template.css
|
||||
$this->doc->addStyleDeclaration('
|
||||
.clockpicker-align-left.popover > .arrow {
|
||||
left: 25px;
|
||||
}
|
||||
');
|
||||
}
|
||||
|
||||
$run = true;
|
||||
}
|
||||
|
||||
return '
|
||||
<div class="clockpicker" data-donetext="' . $this->donetext . '" data-default="' . $this->default . '" data-placement="' . $this->placement . '" data-align="' . $this->align . '" data-autoclose="' . $this->autoclose . '">
|
||||
' . parent::getInput() . '
|
||||
</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the $time_value of the time when created as an object
|
||||
* due to not being able to set the $this->value byitself
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->time_value = $value;
|
||||
}
|
||||
}
|
||||
162
plugins/system/nrframework/fields/treeselect.php
Normal file
162
plugins/system/nrframework/fields/treeselect.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
use \NRFramework\HTML;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
abstract class JFormFieldNRTreeSelect extends JFormField
|
||||
{
|
||||
/**
|
||||
* Database object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
public $db;
|
||||
|
||||
/**
|
||||
* Indicates whether the options array should be sorted before render.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $sortTree = false;
|
||||
|
||||
/**
|
||||
* Indicates whether the options array should have the levels re-calculated
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $fixLevels = false;
|
||||
|
||||
/**
|
||||
* Increase the value(ID) of the category by one.
|
||||
* This happens because we have a parent category "Bussiness Directory" that pushes-in the indentation
|
||||
* and we reset it by decreasing the value, level and parent.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $increaseValue = false;
|
||||
|
||||
/**
|
||||
* Output the HTML for the field
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
$this->db = JFactory::getDbo();
|
||||
|
||||
$options = $this->getOptions();
|
||||
|
||||
if ($this->sortTree)
|
||||
{
|
||||
$options = $this->sortTreeSelectOptions($options);
|
||||
}
|
||||
|
||||
if ($this->fixLevels)
|
||||
{
|
||||
$options = $this->fixLevels($options);
|
||||
}
|
||||
|
||||
if ($this->increaseValue)
|
||||
{
|
||||
// Increase by 1 the value(ID) of the category
|
||||
foreach ($options as $key => $value)
|
||||
{
|
||||
$options[$key]->value+=1;
|
||||
}
|
||||
}
|
||||
|
||||
return HTML::treeselect($options, $this->name, $this->value, $this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts treeselect options
|
||||
*
|
||||
* @param array $options
|
||||
* @param int $parent_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function sortTreeSelectOptions($options, $parent_id = 0)
|
||||
{
|
||||
if (empty($options))
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
||||
$sub_options = array_filter($options, function($option) use($parent_id)
|
||||
{
|
||||
return $option->parent == $parent_id;
|
||||
});
|
||||
|
||||
foreach ($sub_options as $option)
|
||||
{
|
||||
$result[] = $option;
|
||||
$result = array_merge($result, $this->sortTreeSelectOptions($options, $option->value));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fixes the levels of the categories
|
||||
*
|
||||
* @param array $categories
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function fixLevels($cats)
|
||||
{
|
||||
// new categories
|
||||
$categories = [];
|
||||
|
||||
// get category levels
|
||||
foreach ($cats as $c)
|
||||
{
|
||||
$level = 0;
|
||||
$parent_id = (int)$c->parent;
|
||||
|
||||
while ($parent_id)
|
||||
{
|
||||
$level++;
|
||||
$parent_id = $this->getNextParentId($cats, $parent_id);
|
||||
}
|
||||
|
||||
$c->level = $level;
|
||||
$categories[] = $c;
|
||||
}
|
||||
|
||||
return $categories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next parent id
|
||||
* Helper method for getCategories
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getNextParentId($categories, $current_pid)
|
||||
{
|
||||
foreach($categories as $c)
|
||||
{
|
||||
if ((int)$c->value === $current_pid)
|
||||
{
|
||||
return (int)$c->parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tree options as an Array of objects
|
||||
* Each object should have the attributes: value, text, parent, level, disable
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
abstract protected function getOptions();
|
||||
}
|
||||
53
plugins/system/nrframework/fields/users.php
Normal file
53
plugins/system/nrframework/fields/users.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use \NRFramework\HTML;
|
||||
|
||||
require_once dirname(__DIR__) . '/helpers/field.php';
|
||||
|
||||
class JFormFieldNR_Users extends NRFormField
|
||||
{
|
||||
public $type = 'Users';
|
||||
|
||||
protected function getInput()
|
||||
{
|
||||
$this->params = $this->element->attributes();
|
||||
|
||||
if (!is_array($this->value))
|
||||
{
|
||||
$this->value = explode(',', $this->value);
|
||||
}
|
||||
|
||||
$options = $this->getUsers();
|
||||
|
||||
$size = (int) $this->get('size', 300);
|
||||
|
||||
return HTML::treeselectSimple($options, $this->name, $this->value, $this->id, $size);
|
||||
}
|
||||
|
||||
public function getUsers()
|
||||
{
|
||||
$query = $this->db->getQuery(true)
|
||||
->select('COUNT(u.id)')
|
||||
->from('#__users AS u')
|
||||
->where('u.block = 0');
|
||||
$this->db->setQuery($query);
|
||||
$total = $this->db->loadResult();
|
||||
|
||||
$query->clear('select')
|
||||
->select('u.name, u.username, u.id')
|
||||
->order('name');
|
||||
$this->db->setQuery($query);
|
||||
$list = $this->db->loadObjectList();
|
||||
|
||||
return $this->getOptionsByList($list, array('username', 'id'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
require_once __DIR__ . '/componentitems.php';
|
||||
|
||||
class JFormFieldVirtueMartComponentItems extends JFormFieldComponentItems
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
// Get default language
|
||||
$this->element['table'] = 'virtuemart_products_' . $this->getLanguage();
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* VirtueMart is using different tables per language. Therefore, we need to use their API to get the default language code
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getLanguage($default = 'en_gb')
|
||||
{
|
||||
// Silent inclusion.
|
||||
@include_once JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/config.php';
|
||||
|
||||
if (!class_exists('VmConfig'))
|
||||
{
|
||||
return $default;
|
||||
}
|
||||
|
||||
// Init configuration
|
||||
VmConfig::loadConfig();
|
||||
|
||||
return VmConfig::$jDefLang;
|
||||
}
|
||||
|
||||
protected function getItems()
|
||||
{
|
||||
$items = parent::getItems();
|
||||
|
||||
// If text is not properly decoded, decode it
|
||||
$items = array_map(function($item) {
|
||||
$item->text = html_entity_decode($item->text);
|
||||
return $item;
|
||||
}, $items);
|
||||
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
95
plugins/system/nrframework/fields/well.php
Normal file
95
plugins/system/nrframework/fields/well.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once dirname(__DIR__) . '/helpers/field.php';
|
||||
|
||||
class JFormFieldNR_Well extends NRFormField
|
||||
{
|
||||
/**
|
||||
* The field type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'nr_well';
|
||||
|
||||
/**
|
||||
* Layout to render the form field
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $renderLayout = 'well';
|
||||
|
||||
/**
|
||||
* Override renderer include path
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getLayoutPaths()
|
||||
{
|
||||
return JPATH_PLUGINS . '/system/nrframework/layouts/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to render the input field
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getInput()
|
||||
{
|
||||
JHtml::stylesheet('plg_system_nrframework/fields.css', ['relative' => true, 'version' => 'auto']);
|
||||
|
||||
$title = $this->get('label');
|
||||
$description = $this->get('description');
|
||||
$url = $this->get('url');
|
||||
$class = $this->get('class');
|
||||
$start = $this->get('start', 0);
|
||||
$end = $this->get('end', 0);
|
||||
$info = $this->get("html", null);
|
||||
|
||||
if ($info)
|
||||
{
|
||||
$info = str_replace("{{", "<", $info);
|
||||
$info = str_replace("}}", ">", $info);
|
||||
}
|
||||
|
||||
$html = array();
|
||||
|
||||
if ($start || !$end)
|
||||
{
|
||||
if ($title)
|
||||
{
|
||||
$html[] = '<h4>' . $this->prepareText($title) . '</h4>';
|
||||
}
|
||||
if ($description)
|
||||
{
|
||||
$html[] = '<div class="well-desc">' . $this->prepareText($description) . $info . '</div>';
|
||||
}
|
||||
|
||||
if ($url)
|
||||
{
|
||||
if (defined('nrJ4'))
|
||||
{
|
||||
$html[] = '<a class="btn btn-outline-secondary btn-sm wellbtn" target="_blank" href="' . $url . '"><span class="icon-info-circle"></span></a>';
|
||||
} else
|
||||
{
|
||||
$html[] = '<a class="btn btn-secondary wellbtn" target="_blank" href="' . $url . '"><span class="icon-info"></span></a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($end) {
|
||||
$html[] = '</div>';
|
||||
}
|
||||
|
||||
return implode('', $html);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user