';
+
+ if ($lang_file)
+ {
+ jimport('joomla.filesystem.file');
+
+ // Include extra language file
+ $lang = str_replace('_', '-', JFactory::getLanguage()->getTag());
+
+ $inc = '';
+ $lang_path = 'language/' . $lang . '/' . $lang . '.' . $lang_file . '.inc.php';
+ if (JFile::exists(JPATH_ADMINISTRATOR . '/' . $lang_path))
+ {
+ $inc = JPATH_ADMINISTRATOR . '/' . $lang_path;
+ }
+ else if (JFile::exists(JPATH_SITE . '/' . $lang_path))
+ {
+ $inc = JPATH_SITE . '/' . $lang_path;
+ }
+ if ( ! $inc && $lang != 'en-GB')
+ {
+ $lang = 'en-GB';
+ $lang_path = 'language/' . $lang . '/' . $lang . '.' . $lang_file . '.inc.php';
+ if (JFile::exists(JPATH_ADMINISTRATOR . '/' . $lang_path))
+ {
+ $inc = JPATH_ADMINISTRATOR . '/' . $lang_path;
+ }
+ else if (JFile::exists(JPATH_SITE . '/' . $lang_path))
+ {
+ $inc = JPATH_SITE . '/' . $lang_path;
+ }
+ }
+ if ($inc)
+ {
+ include $inc;
+ }
+ }
+
+ if ($description)
+ {
+ if ($description[0] != '<')
+ {
+ $description = '' . $description . '
';
+ }
+ $class = 'rl_panel rl_panel_description';
+ $html .= '';
+ $html .= $description;
+ $html .= '
';
+ }
+
+ return $html;
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/fields/tags.php b/deployed/regularlabs/libraries/regularlabs/fields/tags.php
new file mode 100644
index 00000000..ece0371e
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/fields/tags.php
@@ -0,0 +1,97 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\HTML\HTMLHelper as JHtml;
+use Joomla\CMS\Language\Text as JText;
+use Joomla\Registry\Registry;
+
+if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ return;
+}
+
+require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+
+class JFormFieldRL_Tags extends \RegularLabs\Library\Field
+{
+ public $type = 'Tags';
+
+ protected function getInput()
+ {
+ $size = (int) $this->get('size');
+ $simple = (int) $this->get('simple');
+ $show_ignore = $this->get('show_ignore');
+ $use_names = $this->get('use_names');
+
+ if ($show_ignore && in_array('-1', $this->value))
+ {
+ $this->value = ['-1'];
+ }
+
+ return $this->selectListAjax(
+ $this->type, $this->name, $this->value, $this->id,
+ compact('size', 'simple', 'show_ignore', 'use_names'),
+ $simple
+ );
+ }
+
+ function getAjaxRaw(Registry $attributes)
+ {
+ $name = $attributes->get('name', $this->type);
+ $id = $attributes->get('id', strtolower($name));
+ $value = $attributes->get('value', []);
+ $size = $attributes->get('size');
+ $simple = $attributes->get('simple');
+
+ $options = $this->getOptions(
+ (bool) $attributes->get('show_all'),
+ (bool) $attributes->get('use_names')
+ );
+
+ return $this->selectList($options, $name, $value, $id, $size, true, $simple);
+ }
+
+ protected function getOptions($show_ignore = false, $use_names = false, $value = [])
+ {
+ // assemble items to the array
+ $options = [];
+
+ if ($show_ignore)
+ {
+ $options[] = JHtml::_('select.option', '-1', '- ' . JText::_('RL_IGNORE') . ' -');
+ $options[] = JHtml::_('select.option', '-', ' ', 'value', 'text', true);
+ }
+
+ $options = array_merge($options, $this->getTags($use_names));
+
+ return $options;
+ }
+
+ protected function getTags($use_names)
+ {
+ $value = $use_names ? 'a.title' : 'a.id';
+
+ $query = $this->db->getQuery(true)
+ ->select($value . ' as value, a.title as text, a.parent_id AS parent')
+ ->from('#__tags AS a')
+ ->select('COUNT(DISTINCT b.id) - 1 AS level')
+ ->join('LEFT', '#__tags AS b ON a.lft > b.lft AND a.rgt < b.rgt')
+ ->where('a.alias <> ' . $this->db->quote('root'))
+ ->where('a.published IN (0,1)')
+ ->group('a.id')
+ ->order('a.lft ASC');
+ $this->db->setQuery($query);
+
+ return $this->db->loadObjectList();
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/fields/templates.php b/deployed/regularlabs/libraries/regularlabs/fields/templates.php
new file mode 100644
index 00000000..aa93758f
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/fields/templates.php
@@ -0,0 +1,129 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Factory as JFactory;
+use Joomla\CMS\HTML\HTMLHelper as JHtml;
+use Joomla\CMS\Language\Text as JText;
+use Joomla\Registry\Registry;
+
+if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ return;
+}
+
+require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+
+class JFormFieldRL_Templates extends \RegularLabs\Library\Field
+{
+ public $type = 'Templates';
+
+ protected function getInput()
+ {
+ // fix old '::' separator and change it to '--'
+ $value = json_encode($this->value);
+ $value = str_replace('::', '--', $value);
+ $value = (array) json_decode($value, true);
+
+ $size = (int) $this->get('size');
+ $multiple = $this->get('multiple');
+
+ return $this->selectListAjax(
+ $this->type, $this->name, $value, $this->id,
+ compact('size', 'multiple')
+ );
+ }
+
+ function getAjaxRaw(Registry $attributes)
+ {
+ $name = $attributes->get('name', $this->type);
+ $id = $attributes->get('id', strtolower($name));
+ $value = $attributes->get('value', []);
+ $size = $attributes->get('size');
+ $multiple = $attributes->get('multiple');
+
+ $options = $this->getOptions();
+
+ return $this->selectList($options, $name, $value, $id, $size, $multiple);
+ }
+
+ protected function getOptions()
+ {
+ $options = [];
+
+ $templates = $this->getTemplates();
+
+ foreach ($templates as $styles)
+ {
+ $level = 0;
+ foreach ($styles as $style)
+ {
+ $style->level = $level;
+ $options[] = $style;
+
+ if (count($styles) <= 2)
+ {
+ break;
+ }
+
+ $level = 1;
+ }
+ }
+
+ return $options;
+ }
+
+ protected function getTemplates()
+ {
+ $groups = [];
+ $lang = JFactory::getLanguage();
+
+ // Get the database object and a new query object.
+ $db = JFactory::getDbo();
+ $query = $db->getQuery(true)
+ ->select('s.id, s.title, e.name as name, s.template')
+ ->from('#__template_styles as s')
+ ->where('s.client_id = 0')
+ ->join('LEFT', '#__extensions as e on e.element=s.template')
+ ->where('e.enabled=1')
+ ->where($db->quoteName('e.type') . '=' . $db->quote('template'))
+ ->order('s.template')
+ ->order('s.title');
+
+ // Set the query and load the styles.
+ $db->setQuery($query);
+ $styles = $db->loadObjectList();
+
+ // Build the grouped list array.
+ if ($styles)
+ {
+ foreach ($styles as $style)
+ {
+ $template = $style->template;
+ $lang->load('tpl_' . $template . '.sys', JPATH_SITE)
+ || $lang->load('tpl_' . $template . '.sys', JPATH_SITE . '/templates/' . $template);
+ $name = JText::_($style->name);
+
+ // Initialize the group if necessary.
+ if ( ! isset($groups[$template]))
+ {
+ $groups[$template] = [];
+ $groups[$template][] = JHtml::_('select.option', $template, $name);
+ }
+
+ $groups[$template][] = JHtml::_('select.option', $template . '--' . $style->id, $style->title);
+ }
+ }
+
+ return $groups;
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/fields/text.php b/deployed/regularlabs/libraries/regularlabs/fields/text.php
new file mode 100644
index 00000000..cf5797dd
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/fields/text.php
@@ -0,0 +1,75 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Language\Text as JText;
+use RegularLabs\Library\StringHelper as RL_String;
+
+require_once JPATH_LIBRARIES . '/joomla/form/fields/text.php';
+
+if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ return;
+}
+
+require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+
+class JFormFieldRL_Text extends JFormFieldText
+{
+ public $type = 'Text';
+
+ public function setup(SimpleXMLElement $element, $value, $group = null)
+ {
+ $this->element = $element;
+
+ $element['label'] = $this->prepareText($element['label']);
+ $element['description'] = $this->prepareText($element['description']);
+ $element['hint'] = $this->prepareText($element['hint']);
+ $element['translateDescription'] = false;
+
+ return parent::setup($element, $value, $group);
+ }
+
+ private function prepareText($string = '')
+ {
+ $string = trim($string);
+
+ if ($string == '')
+ {
+ return '';
+ }
+
+ // variables
+ $var1 = JText::_($this->get('var1'));
+ $var2 = JText::_($this->get('var2'));
+ $var3 = JText::_($this->get('var3'));
+ $var4 = JText::_($this->get('var4'));
+ $var5 = JText::_($this->get('var5'));
+
+ $string = JText::sprintf(JText::_($string), $var1, $var2, $var3, $var4, $var5);
+ $string = trim(RL_String::html_entity_decoder($string));
+ $string = str_replace('"', '"', $string);
+ $string = str_replace('span style="font-family:monospace;"', 'span class="rl_code"', $string);
+
+ return $string;
+ }
+
+ private function get($val, $default = '')
+ {
+ if ( ! isset($this->params[$val]) || (string) $this->params[$val] == '')
+ {
+ return $default;
+ }
+
+ return (string) $this->params[$val];
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/fields/textareaplus.php b/deployed/regularlabs/libraries/regularlabs/fields/textareaplus.php
new file mode 100644
index 00000000..557db6d2
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/fields/textareaplus.php
@@ -0,0 +1,114 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Date\Date as JDate;
+use Joomla\CMS\Factory as JFactory;
+use Joomla\CMS\Language\Text as JText;
+use RegularLabs\Library\StringHelper as RL_String;
+
+if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ return;
+}
+
+require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+
+class JFormFieldRL_TextAreaPlus extends \RegularLabs\Library\Field
+{
+ public $type = 'TextAreaPlus';
+
+ protected function getLabel()
+ {
+ $resize = $this->get('resize', 0);
+ $show_insert_date_name = $this->get('show_insert_date_name', 0);
+
+ $label = RL_String::html_entity_decoder(JText::_($this->get('label')));
+
+ $attribs = 'id="' . $this->id . '-lbl" for="' . $this->id . '"';
+
+ if ($this->description)
+ {
+ $attribs .= ' class="hasPopover" title="' . $label . '"'
+ . ' data-content="' . JText::_($this->description) . '"';
+ }
+
+ $html = '' . $label;
+
+ if ($show_insert_date_name)
+ {
+ $date_name = JDate::getInstance()->format('[Y-m-d]') . ' ' . JFactory::getUser()->name . ' : ';
+ $onclick = "RegularLabsForm.prependTextarea('" . $this->id . "', '" . addslashes($date_name) . "', '---');";
+
+ $html .= ''
+ . JText::_('RL_INSERT_DATE_NAME')
+ . ' ';
+ }
+
+ if ($resize)
+ {
+ $html .= ''
+ . ''
+ . '[ + ]'
+ . ' '
+ . ''
+ . '[ - ]'
+ . ' '
+ . ' ';
+ }
+
+ $html .= ' ';
+
+ return $html;
+ }
+
+ protected function getInput()
+ {
+ $width = $this->get('width', 600);
+ $height = $this->get('height', 80);
+ $class = ' class="' . trim('rl_textarea ' . $this->get('class')) . '"';
+ $type = $this->get('texttype');
+ $hint = $this->get('hint');
+
+ if (is_array($this->value))
+ {
+ $this->value = trim(implode("\n", $this->value));
+ }
+
+ if ($type == 'html')
+ {
+ // Convert tags so they are not visible when editing
+ $this->value = str_replace(' ', "\n", $this->value);
+ }
+ else if ($type == 'regex')
+ {
+ // Protects the special characters
+ $this->value = str_replace('[:REGEX_ENTER:]', '\n', $this->value);
+ }
+
+ if ($this->get('translate') && $this->get('translate') !== 'false')
+ {
+ $this->value = JText::_($this->value);
+ $hint = JText::_($hint);
+ }
+
+ $this->value = htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8');
+
+ $hint = $hint ? ' placeholder="' . $hint . '"' : '';
+
+ return
+ '';
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/fields/toggler.php b/deployed/regularlabs/libraries/regularlabs/fields/toggler.php
new file mode 100644
index 00000000..2c113420
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/fields/toggler.php
@@ -0,0 +1,144 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Factory as JFactory;
+use Joomla\CMS\Form\FormField as JFormField;
+use RegularLabs\Library\Document as RL_Document;
+use RegularLabs\Library\RegEx as RL_RegEx;
+
+if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ return;
+}
+
+require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+
+/**
+ * @deprecated 2018-10-30 Use ShowOn instead
+ */
+
+/**
+ * To use this, make a start xml param tag with the param and value set
+ * And an end xml param tag without the param and value set
+ * Everything between those tags will be included in the slide
+ *
+ * Available extra parameters:
+ * param The name of the reference parameter
+ * value a comma separated list of value on which to show the framework
+ */
+class JFormFieldRL_Toggler extends JFormField
+{
+ public $type = 'Toggler';
+
+ protected function getLabel()
+ {
+ return '';
+ }
+
+ protected function getInput()
+ {
+ if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+ {
+ return null;
+ }
+
+ $field = new RLFieldToggler;
+
+ return $field->getInput($this->element->attributes());
+ }
+}
+
+class RLFieldToggler
+{
+ function getInput($params)
+ {
+ $this->params = $params;
+
+ $option = JFactory::getApplication()->input->get('option');
+
+ // do not place toggler stuff on JoomFish pages
+ if ($option == 'com_joomfish')
+ {
+ return '';
+ }
+
+ $param = $this->get('param');
+ $value = $this->get('value');
+ $nofx = $this->get('nofx');
+ $method = $this->get('method');
+ $div = $this->get('div', 0);
+
+ RL_Document::script('regularlabs/toggler.min.js');
+
+ $param = RL_RegEx::replace('^\s*(.*?)\s*$', '\1', $param);
+ $param = RL_RegEx::replace('\s*\|\s*', '|', $param);
+
+ $html = [];
+ if ( ! $param)
+ {
+ return '';
+ }
+
+ $param = RL_RegEx::replace('[^a-z0-9-\.\|\@]', '_', $param);
+ $param = str_replace('@', '_', $param);
+ $set_groups = explode('|', $param);
+ $set_values = explode('|', $value);
+ $ids = [];
+ foreach ($set_groups as $i => $group)
+ {
+ $count = $i;
+ if ($count >= count($set_values))
+ {
+ $count = 0;
+ }
+ $value = explode(',', $set_values[$count]);
+ foreach ($value as $val)
+ {
+ $ids[] = $group . '.' . $val;
+ }
+ }
+
+ if ( ! $div)
+ {
+ $html[] = '';
+ }
+
+ $html[] = '';
+
+ if ( ! $div)
+ {
+ $html[] = '
';
+ }
+
+ return implode('', $html);
+ }
+
+ private function get($val, $default = '')
+ {
+ if ( ! isset($this->params[$val]) || (string) $this->params[$val] == '')
+ {
+ return $default;
+ }
+
+ return (string) $this->params[$val];
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/fields/users.php b/deployed/regularlabs/libraries/regularlabs/fields/users.php
new file mode 100644
index 00000000..69b88fa9
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/fields/users.php
@@ -0,0 +1,87 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Language\Text as JText;
+use Joomla\Registry\Registry;
+
+if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ return;
+}
+
+require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+
+class JFormFieldRL_Users extends \RegularLabs\Library\Field
+{
+ public $type = 'Users';
+
+ protected function getInput()
+ {
+ if ( ! is_array($this->value))
+ {
+ $this->value = explode(',', $this->value);
+ }
+
+ $size = (int) $this->get('size');
+ $multiple = $this->get('multiple');
+
+ return $this->selectListSimpleAjax(
+ $this->type, $this->name, $this->value, $this->id,
+ compact('size', 'multiple')
+ );
+ }
+
+ function getAjaxRaw(Registry $attributes)
+ {
+ $name = $attributes->get('name', $this->type);
+ $id = $attributes->get('id', strtolower($name));
+ $value = $attributes->get('value', []);
+ $size = $attributes->get('size');
+ $multiple = $attributes->get('multiple');
+
+ $options = $this->getUsers();
+
+ return $this->selectListSimple($options, $name, $value, $id, $size, $multiple);
+ }
+
+ function getUsers()
+ {
+ $query = $this->db->getQuery(true)
+ ->select('COUNT(*)')
+ ->from('#__users AS u');
+ $this->db->setQuery($query);
+ $total = $this->db->loadResult();
+
+ if ($total > $this->max_list_count)
+ {
+ return -1;
+ }
+
+ $query->clear('select')
+ ->select('u.name, u.username, u.id, u.block as disabled')
+ ->order('name');
+ $this->db->setQuery($query);
+ $list = $this->db->loadObjectList();
+
+ $list = array_map(function ($item) {
+ if ($item->disabled)
+ {
+ $item->name .= ' (' . JText::_('JDISABLED') . ')';
+ }
+
+ return $item;
+ }, $list);
+
+ return $this->getOptionsByList($list, ['username', 'id']);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/fields/version.php b/deployed/regularlabs/libraries/regularlabs/fields/version.php
new file mode 100644
index 00000000..0a304e8b
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/fields/version.php
@@ -0,0 +1,67 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Factory as JFactory;
+use RegularLabs\Library\Version as RL_Version;
+
+if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ return;
+}
+
+require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+
+class JFormFieldRL_Version extends \RegularLabs\Library\Field
+{
+ public $type = 'Version';
+
+ protected function getLabel()
+ {
+ return '';
+ }
+
+ protected function getInput()
+ {
+ $extension = $this->get('extension');
+ $xml = $this->get('xml');
+
+ if ( ! $xml && $this->form->getValue('element'))
+ {
+ if ($this->form->getValue('folder'))
+ {
+ $xml = 'plugins/' . $this->form->getValue('folder') . '/' . $this->form->getValue('element') . '/' . $this->form->getValue('element') . '.xml';
+ }
+ else
+ {
+ $xml = 'administrator/modules/' . $this->form->getValue('element') . '/' . $this->form->getValue('element') . '.xml';
+ }
+ if ( ! JFile::exists(JPATH_SITE . '/' . $xml))
+ {
+ return '';
+ }
+ }
+
+ if ( ! strlen($extension) || ! strlen($xml))
+ {
+ return '';
+ }
+
+ $authorise = JFactory::getUser()->authorise('core.manage', 'com_installer');
+ if ( ! $authorise)
+ {
+ return '';
+ }
+
+ return '
' . RL_Version::getMessage($extension);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/fields/virtuemart.php b/deployed/regularlabs/libraries/regularlabs/fields/virtuemart.php
new file mode 100644
index 00000000..54d45e3f
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/fields/virtuemart.php
@@ -0,0 +1,131 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+defined('_JEXEC') or die;
+
+if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ return;
+}
+
+require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+
+class JFormFieldRL_VirtueMart extends \RegularLabs\Library\FieldGroup
+{
+ public $type = 'VirtueMart';
+ public $language = null;
+
+ protected function getInput()
+ {
+ if ($error = $this->missingFilesOrTables(['categories', 'products']))
+ {
+ return $error;
+ }
+
+ return $this->getSelectList();
+ }
+
+ function getCategories()
+ {
+ $query = $this->db->getQuery(true)
+ ->select('COUNT(*)')
+ ->from('#__virtuemart_categories AS c')
+ ->where('c.published > -1');
+ $this->db->setQuery($query);
+ $total = $this->db->loadResult();
+
+ if ($total > $this->max_list_count)
+ {
+ return -1;
+ }
+
+ $query->clear()
+ ->select('c.virtuemart_category_id as id, cc.category_parent_id AS parent_id, l.category_name AS title, c.published')
+ ->from('#__virtuemart_categories_' . $this->getActiveLanguage() . ' AS l')
+ ->join('', '#__virtuemart_categories AS c using (virtuemart_category_id)')
+ ->join('LEFT', '#__virtuemart_category_categories AS cc ON l.virtuemart_category_id = cc.category_child_id')
+ ->where('c.published > -1')
+ ->group('c.virtuemart_category_id')
+ ->order('c.ordering, l.category_name');
+ $this->db->setQuery($query);
+ $items = $this->db->loadObjectList();
+
+ return $this->getOptionsTreeByList($items);
+ }
+
+ function getProducts()
+ {
+ $query = $this->db->getQuery(true)
+ ->select('COUNT(*)')
+ ->from('#__virtuemart_products AS p')
+ ->where('p.published > -1');
+ $this->db->setQuery($query);
+ $total = $this->db->loadResult();
+
+ if ($total > $this->max_list_count)
+ {
+ return -1;
+ }
+
+ $query->clear('select')
+ ->select('p.virtuemart_product_id as id, l.product_name AS name, p.product_sku as sku, cl.category_name AS cat, p.published')
+ ->join('LEFT', '#__virtuemart_products_' . $this->getActiveLanguage() . ' AS l ON l.virtuemart_product_id = p.virtuemart_product_id')
+ ->join('LEFT', '#__virtuemart_product_categories AS x ON x.virtuemart_product_id = p.virtuemart_product_id')
+ ->join('LEFT', '#__virtuemart_categories AS c ON c.virtuemart_category_id = x.virtuemart_category_id')
+ ->join('LEFT', '#__virtuemart_categories_' . $this->getActiveLanguage() . ' AS cl ON cl.virtuemart_category_id = c.virtuemart_category_id')
+ ->group('p.virtuemart_product_id')
+ ->order('l.product_name, p.product_sku');
+ $this->db->setQuery($query);
+ $list = $this->db->loadObjectList();
+
+ return $this->getOptionsByList($list, ['sku', 'cat', 'id']);
+ }
+
+ private function getActiveLanguage()
+ {
+ if (isset($this->language))
+ {
+ return $this->language;
+ }
+
+ $this->language = 'en_gb';
+
+ if ( ! class_exists('VmConfig'))
+ {
+ require_once JPATH_ROOT . '/administrator/components/com_virtuemart/helpers/config.php';
+ }
+
+ if ( ! class_exists('VmConfig'))
+ {
+ return $this->language;
+ }
+
+ VmConfig::loadConfig();
+
+ if ( ! empty(VmConfig::$vmlang))
+ {
+ $this->language = str_replace('-', '_', strtolower(VmConfig::$vmlang));
+
+ return $this->language;
+ }
+
+ $active_languages = VmConfig::get('active_languages', []);
+
+ if ( ! isset($active_languages[0]))
+ {
+ return $this->language;
+ }
+
+ $this->language = str_replace('-', '_', strtolower($active_languages[0]));
+
+ return $this->language;
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/fields/zoo.php b/deployed/regularlabs/libraries/regularlabs/fields/zoo.php
new file mode 100644
index 00000000..b0d7e555
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/fields/zoo.php
@@ -0,0 +1,145 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\HTML\HTMLHelper as JHtml;
+use Joomla\CMS\Language\Text as JText;
+use RegularLabs\Library\Form as RL_Form;
+
+if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ return;
+}
+
+require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+
+class JFormFieldRL_Zoo extends \RegularLabs\Library\FieldGroup
+{
+ public $type = 'Zoo';
+
+ protected function getInput()
+ {
+ if ($error = $this->missingFilesOrTables(['applications' => 'application', 'categories' => 'category', 'items' => 'item']))
+ {
+ return $error;
+ }
+
+ return $this->getSelectList();
+ }
+
+ function getCategories()
+ {
+ $query = $this->db->getQuery(true)
+ ->select('COUNT(*)')
+ ->from('#__zoo_category AS c')
+ ->where('c.published > -1');
+ $this->db->setQuery($query);
+ $total = $this->db->loadResult();
+
+ if ($total > $this->max_list_count)
+ {
+ return -1;
+ }
+
+ $options = [];
+ if ($this->get('show_ignore'))
+ {
+ if (in_array('-1', $this->value))
+ {
+ $this->value = ['-1'];
+ }
+ $options[] = JHtml::_('select.option', '-1', '- ' . JText::_('RL_IGNORE') . ' -');
+ $options[] = JHtml::_('select.option', '-', ' ', 'value', 'text', true);
+ }
+
+ $query->clear()
+ ->select('a.id, a.name')
+ ->from('#__zoo_application AS a')
+ ->order('a.name, a.id');
+ $this->db->setQuery($query);
+ $apps = $this->db->loadObjectList();
+
+ foreach ($apps as $i => $app)
+ {
+ $query->clear()
+ ->select('c.id, c.parent AS parent_id, c.name AS title, c.published')
+ ->from('#__zoo_category AS c')
+ ->where('c.application_id = ' . (int) $app->id)
+ ->where('c.published > -1')
+ ->order('c.ordering, c.name');
+ $this->db->setQuery($query);
+ $items = $this->db->loadObjectList();
+
+ if ($i)
+ {
+ $options[] = JHtml::_('select.option', '-', ' ', 'value', 'text', true);
+ }
+
+ // establish the hierarchy of the menu
+ // TODO: use node model
+ $children = [];
+
+ if ($items)
+ {
+ // first pass - collect children
+ foreach ($items as $v)
+ {
+ $pt = $v->parent_id;
+ $list = @$children[$pt] ? $children[$pt] : [];
+ array_push($list, $v);
+ $children[$pt] = $list;
+ }
+ }
+
+ // second pass - get an indent list of the items
+ $list = JHtml::_('menu.treerecurse', 0, '', [], $children, 9999, 0, 0);
+
+ // assemble items to the array
+ $options[] = JHtml::_('select.option', 'app' . $app->id, '[' . $app->name . ']');
+ foreach ($list as $item)
+ {
+ $item->treename = ' ' . str_replace(' - ', ' ', $item->treename);
+ $item->treename = RL_Form::prepareSelectItem($item->treename, $item->published);
+ $option = JHtml::_('select.option', $item->id, $item->treename);
+ $option->level = 1;
+ $options[] = $option;
+ }
+ }
+
+ return $options;
+ }
+
+ function getItems()
+ {
+ $query = $this->db->getQuery(true)
+ ->select('COUNT(*)')
+ ->from('#__zoo_item AS i')
+ ->where('i.state > -1');
+ $this->db->setQuery($query);
+ $total = $this->db->loadResult();
+
+ if ($total > $this->max_list_count)
+ {
+ return -1;
+ }
+
+ $query->clear('select')
+ ->select('i.id, i.name, a.name as cat, i.state as published')
+ ->join('LEFT', '#__zoo_application AS a ON a.id = i.application_id')
+ ->group('i.id')
+ ->order('i.name, i.priority, i.id');
+ $this->db->setQuery($query);
+ $list = $this->db->loadObjectList();
+
+ return $this->getOptionsByList($list, ['cat', 'id']);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignment.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignment.php
new file mode 100644
index 00000000..d88b1fbd
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignment.php
@@ -0,0 +1,53 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+class RLAssignment
+ extends \RegularLabs\Library\Condition
+{
+ function pass($pass = true, $include_type = null)
+ {
+ return $this->_($pass, $include_type);
+ }
+
+ public function passByPageTypes($option, $selection = [], $assignment = 'all', $add_view = false, $get_task = false, $get_layout = true)
+ {
+ return $this->passByPageType($option, $selection, $assignment, $add_view, $get_task, $get_layout);
+ }
+
+ public function passContentIds()
+ {
+ return $this->passContentId();
+ }
+
+ public function passContentKeywords($fields = ['title', 'introtext', 'fulltext'], $text = '')
+ {
+ return $this->passContentKeyword($fields, $text);
+ }
+
+ public function passMetaKeywords($field = 'metakey', $keywords = '')
+ {
+ return $this->passMetaKeyword($field, $keywords);
+ }
+
+ public function passAuthors($field = 'created_by', $author = '')
+ {
+ return $this->passAuthors($field, $author);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments.php
new file mode 100644
index 00000000..66a3a678
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments.php
@@ -0,0 +1,44 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use RegularLabs\Library\Conditions as RL_Conditions;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+class RLAssignmentsHelper
+{
+ function passAll($assignments, $matching_method = 'all', $item = 0)
+ {
+ return RL_Conditions::pass($assignments, $matching_method, $item);
+ }
+
+ public function getAssignmentsFromParams(&$params)
+ {
+ return RL_Conditions::getConditionsFromParams($params);
+ }
+
+ public function getAssignmentsFromTagAttributes(&$params, $types = [])
+ {
+ return RL_Conditions::getConditionsFromTagAttributes($params, $types);
+ }
+
+ public function hasAssignments(&$assignments)
+ {
+ return RL_Conditions::hasConditions($assignments);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/agents.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/agents.php
new file mode 100644
index 00000000..0c6e9eb7
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/agents.php
@@ -0,0 +1,199 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+require_once dirname(__DIR__) . '/text.php';
+require_once dirname(__DIR__) . '/mobile_detect.php';
+
+class RLAssignmentsAgents extends RLAssignment
+{
+ var $agent = null;
+ var $device = null;
+
+ /**
+ * passBrowsers
+ */
+ public function passBrowsers()
+ {
+ if (empty($this->selection))
+ {
+ return $this->pass(false);
+ }
+
+ foreach ($this->selection as $browser)
+ {
+ if ( ! $this->passBrowser($browser))
+ {
+ continue;
+ }
+
+ return $this->pass(true);
+ }
+
+ return $this->pass(false);
+ }
+
+ /**
+ * passOS
+ */
+ public function passOS()
+ {
+ return self::passBrowsers();
+ }
+
+ /**
+ * passDevices
+ */
+ public function passDevices()
+ {
+ $pass = (in_array('mobile', $this->selection) && $this->isMobile())
+ || (in_array('tablet', $this->selection) && $this->isTablet())
+ || (in_array('desktop', $this->selection) && $this->isDesktop());
+
+ return $this->pass($pass);
+ }
+
+ /**
+ * isPhone
+ */
+ public function isPhone()
+ {
+ return $this->isMobile();
+ }
+
+ /**
+ * isMobile
+ */
+ public function isMobile()
+ {
+ return $this->getDevice() == 'mobile';
+ }
+
+ /**
+ * isTablet
+ */
+ public function isTablet()
+ {
+ return $this->getDevice() == 'tablet';
+ }
+
+ /**
+ * isDesktop
+ */
+ public function isDesktop()
+ {
+ return $this->getDevice() == 'desktop';
+ }
+
+ /**
+ * setDevice
+ */
+ private function getDevice()
+ {
+ if ( ! is_null($this->device))
+ {
+ return $this->device;
+ }
+
+ $detect = new RLMobile_Detect;
+
+ $this->is_mobile = $detect->isMobile();
+
+ switch (true)
+ {
+ case($detect->isTablet()):
+ $this->device = 'tablet';
+ break;
+
+ case ($detect->isMobile()):
+ $this->device = 'mobile';
+ break;
+
+ default:
+ $this->device = 'desktop';
+ }
+
+ return $this->device;
+ }
+
+ /**
+ * getAgent
+ */
+ private function getAgent()
+ {
+ if ( ! is_null($this->agent))
+ {
+ return $this->agent;
+ }
+
+ $detect = new RLMobile_Detect;
+ $agent = $detect->getUserAgent();
+
+ switch (true)
+ {
+ case (stripos($agent, 'Trident') !== false):
+ // Add MSIE to IE11
+ $agent = preg_replace('#(Trident/[0-9\.]+; rv:([0-9\.]+))#is', '\1 MSIE \2', $agent);
+ break;
+
+ case (stripos($agent, 'Chrome') !== false):
+ // Remove Safari from Chrome
+ $agent = preg_replace('#(Chrome/.*)Safari/[0-9\.]*#is', '\1', $agent);
+ // Add MSIE to IE Edge and remove Chrome from IE Edge
+ $agent = preg_replace('#Chrome/.*(Edge/[0-9])#is', 'MSIE \1', $agent);
+ break;
+
+ case (stripos($agent, 'Opera') !== false):
+ $agent = preg_replace('#(Opera/.*)Version/#is', '\1Opera/', $agent);
+ break;
+ }
+
+ $this->agent = $agent;
+
+ return $this->agent;
+ }
+
+ /**
+ * passBrowser
+ */
+ private function passBrowser($browser = '')
+ {
+ if ( ! $browser)
+ {
+ return false;
+ }
+
+ if ($browser == 'mobile')
+ {
+ return $this->isMobile();
+ }
+
+ if ( ! (strpos($browser, '#') === 0))
+ {
+ $browser = '#' . RLText::pregQuote($browser) . '#';
+ }
+
+ // also check for _ instead of .
+ $browser = preg_replace('#\\\.([^\]])#', '[\._]\1', $browser);
+ $browser = str_replace('\.]', '\._]', $browser);
+
+ return preg_match($browser . 'i', $this->getAgent());
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/akeebasubs.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/akeebasubs.php
new file mode 100644
index 00000000..e3e3902b
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/akeebasubs.php
@@ -0,0 +1,56 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Factory as JFactory;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+class RLAssignmentsAkeebaSubs extends RLAssignment
+{
+ public function init()
+ {
+ if ( ! $this->request->id && $this->request->view == 'level')
+ {
+ $slug = JFactory::getApplication()->input->getString('slug', '');
+ if ($slug)
+ {
+ $query = $this->db->getQuery(true)
+ ->select('l.akeebasubs_level_id')
+ ->from('#__akeebasubs_levels AS l')
+ ->where('l.slug = ' . $this->db->quote($slug));
+ $this->db->setQuery($query);
+ $this->request->id = $this->db->loadResult();
+ }
+ }
+ }
+
+ public function passPageTypes()
+ {
+ return $this->passByPageTypes('com_akeebasubs', $this->selection, $this->assignment);
+ }
+
+ public function passLevels()
+ {
+ if ( ! $this->request->id || $this->request->option != 'com_akeebasubs' || $this->request->view != 'level')
+ {
+ return $this->pass(false);
+ }
+
+ return $this->passSimple($this->request->id);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/components.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/components.php
new file mode 100644
index 00000000..f0d09e87
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/components.php
@@ -0,0 +1,29 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+
+class RLAssignmentsComponents extends RLAssignment
+{
+ public function passComponents()
+ {
+ return $this->passSimple(strtolower($this->request->option));
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/content.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/content.php
new file mode 100644
index 00000000..34fc9e20
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/content.php
@@ -0,0 +1,245 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Factory as JFactory;
+use Joomla\CMS\MVC\Model\BaseDatabaseModel as JModel;
+use Joomla\CMS\Table\Table as JTable;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+
+class RLAssignmentsContent extends RLAssignment
+{
+ public function passPageTypes()
+ {
+ $components = ['com_content', 'com_contentsubmit'];
+ if ( ! in_array($this->request->option, $components))
+ {
+ return $this->pass(false);
+ }
+ if ($this->request->view == 'category' && $this->request->layout == 'blog')
+ {
+ $view = 'categoryblog';
+ }
+ else
+ {
+ $view = $this->request->view;
+ }
+
+ return $this->passSimple($view);
+ }
+
+ public function passCategories()
+ {
+ // components that use the com_content secs/cats
+ $components = ['com_content', 'com_flexicontent', 'com_contentsubmit'];
+ if ( ! in_array($this->request->option, $components))
+ {
+ return $this->pass(false);
+ }
+
+ if (empty($this->selection))
+ {
+ return $this->pass(false);
+ }
+
+ $is_content = in_array($this->request->option, ['com_content', 'com_flexicontent']);
+ $is_category = in_array($this->request->view, ['category']);
+ $is_item = in_array($this->request->view, ['', 'article', 'item', 'form']);
+
+ if (
+ $this->request->option != 'com_contentsubmit'
+ && ! ($this->params->inc_categories && $is_content && $is_category)
+ && ! ($this->params->inc_articles && $is_content && $is_item)
+ && ! ($this->params->inc_others && ! ($is_content && ($is_category || $is_item)))
+ )
+ {
+ return $this->pass(false);
+ }
+
+ if ($this->request->option == 'com_contentsubmit')
+ {
+ // Content Submit
+ $contentsubmit_params = new ContentsubmitModelArticle;
+ if (in_array($contentsubmit_params->_id, $this->selection))
+ {
+ return $this->pass(true);
+ }
+
+ return $this->pass(false);
+ }
+
+ $pass = false;
+ if (
+ $this->params->inc_others
+ && ! ($is_content && ($is_category || $is_item))
+ && $this->article
+ )
+ {
+ if ( ! isset($this->article->id) && isset($this->article->slug))
+ {
+ $this->article->id = (int) $this->article->slug;
+ }
+
+ if ( ! isset($this->article->catid) && isset($this->article->catslug))
+ {
+ $this->article->catid = (int) $this->article->catslug;
+ }
+
+ $this->request->id = $this->article->id;
+ $this->request->view = 'article';
+ }
+
+ $catids = $this->getCategoryIds($is_category);
+
+ foreach ($catids as $catid)
+ {
+ if ( ! $catid)
+ {
+ continue;
+ }
+
+ $pass = in_array($catid, $this->selection);
+
+ if ($pass && $this->params->inc_children == 2)
+ {
+ $pass = false;
+ continue;
+ }
+
+ if ( ! $pass && $this->params->inc_children)
+ {
+ $parent_ids = $this->getCatParentIds($catid);
+ $parent_ids = array_diff($parent_ids, [1]);
+ foreach ($parent_ids as $id)
+ {
+ if (in_array($id, $this->selection))
+ {
+ $pass = true;
+ break;
+ }
+ }
+
+ unset($parent_ids);
+ }
+ }
+
+ return $this->pass($pass);
+ }
+
+ private function getCategoryIds($is_category = false)
+ {
+ if ($is_category)
+ {
+ return (array) $this->request->id;
+ }
+
+ if ( ! $this->article && $this->request->id)
+ {
+ $this->article = JTable::getInstance('content');
+ $this->article->load($this->request->id);
+ }
+
+ if ($this->article && $this->article->catid)
+ {
+ return (array) $this->article->catid;
+ }
+
+ $catid = JFactory::getApplication()->input->getInt('catid', JFactory::getApplication()->getUserState('com_content.articles.filter.category_id'));
+ $menuparams = $this->getMenuItemParams($this->request->Itemid);
+
+ if ($this->request->view == 'featured')
+ {
+ $menuparams = $this->getMenuItemParams($this->request->Itemid);
+
+ return isset($menuparams->featured_categories) ? (array) $menuparams->featured_categories : (array) $catid;
+ }
+
+ return isset($menuparams->catid) ? (array) $menuparams->catid : (array) $catid;
+ }
+
+ public function passArticles()
+ {
+ if ( ! $this->request->id
+ || ! (($this->request->option == 'com_content' && $this->request->view == 'article')
+ || ($this->request->option == 'com_flexicontent' && $this->request->view == 'item')
+ )
+ )
+ {
+ return $this->pass(false);
+ }
+
+ $pass = false;
+
+ // Pass Article Id
+ if ( ! $this->passItemByType($pass, 'ContentIds'))
+ {
+ return $this->pass(false);
+ }
+
+ // Pass Content Keywords
+ if ( ! $this->passItemByType($pass, 'ContentKeywords'))
+ {
+ return $this->pass(false);
+ }
+
+ // Pass Meta Keywords
+ if ( ! $this->passItemByType($pass, 'MetaKeywords'))
+ {
+ return $this->pass(false);
+ }
+
+ // Pass Authors
+ if ( ! $this->passItemByType($pass, 'Authors'))
+ {
+ return $this->pass(false);
+ }
+
+ return $this->pass($pass);
+ }
+
+ public function getItem($fields = [])
+ {
+ if ($this->article)
+ {
+ return $this->article;
+ }
+
+ if ( ! class_exists('ContentModelArticle'))
+ {
+ require_once JPATH_SITE . '/components/com_content/models/article.php';
+ }
+
+ $model = JModel::getInstance('article', 'contentModel');
+
+ if ( ! method_exists($model, 'getItem'))
+ {
+ return null;
+ }
+
+ $this->article = $model->getItem($this->request->id);
+
+ return $this->article;
+ }
+
+ private function getCatParentIds($id = 0)
+ {
+ return $this->getParentIds($id, 'categories');
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/cookieconfirm.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/cookieconfirm.php
new file mode 100644
index 00000000..cd592730
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/cookieconfirm.php
@@ -0,0 +1,32 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+
+class RLAssignmentsCookieConfirm extends RLAssignment
+{
+ public function passCookieConfirm()
+ {
+ require_once JPATH_PLUGINS . '/system/cookieconfirm/core.php';
+ $pass = PlgSystemCookieconfirmCore::getInstance()->isCookiesAllowed();
+
+ return $this->pass($pass);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/datetime.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/datetime.php
new file mode 100644
index 00000000..882bf746
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/datetime.php
@@ -0,0 +1,278 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Factory as JFactory;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+
+class RLAssignmentsDateTime extends RLAssignment
+{
+ var $timezone = null;
+ var $dates = [];
+
+ public function passDate()
+ {
+ if ( ! $this->params->publish_up && ! $this->params->publish_down)
+ {
+ // no date range set
+ return ($this->assignment == 'include');
+ }
+
+ require_once dirname(__DIR__) . '/text.php';
+
+ RLText::fixDate($this->params->publish_up);
+ RLText::fixDate($this->params->publish_down);
+
+ $now = $this->getNow();
+ $up = $this->getDate($this->params->publish_up);
+ $down = $this->getDate($this->params->publish_down);
+
+ if (isset($this->params->recurring) && $this->params->recurring)
+ {
+ if ( ! (int) $this->params->publish_up || ! (int) $this->params->publish_down)
+ {
+ // no date range set
+ return ($this->assignment == 'include');
+ }
+
+ $up = strtotime(date('Y') . $up->format('-m-d H:i:s', true));
+ $down = strtotime(date('Y') . $down->format('-m-d H:i:s', true));
+
+ // pass:
+ // 1) now is between up and down
+ // 2) up is later in year than down and:
+ // 2a) now is after up
+ // 2b) now is before down
+ if (
+ ($up < $now && $down > $now)
+ || ($up > $down
+ && (
+ $up < $now
+ || $down > $now
+ )
+ )
+ )
+ {
+ return ($this->assignment == 'include');
+ }
+
+ // outside date range
+ return $this->pass(false);
+ }
+
+ if (
+ (
+ (int) $this->params->publish_up
+ && strtotime($up->format('Y-m-d H:i:s', true)) > $now
+ )
+ || (
+ (int) $this->params->publish_down
+ && strtotime($down->format('Y-m-d H:i:s', true)) < $now
+ )
+ )
+ {
+ // outside date range
+ return $this->pass(false);
+ }
+
+ // pass
+ return ($this->assignment == 'include');
+ }
+
+ public function passSeasons()
+ {
+ $season = self::getSeason($this->date, $this->params->hemisphere);
+
+ return $this->passSimple($season);
+ }
+
+ public function passMonths()
+ {
+ $month = $this->date->format('m', true); // 01 (for January) through 12 (for December)
+
+ return $this->passSimple((int) $month);
+ }
+
+ public function passDays()
+ {
+ $day = $this->date->format('N', true); // 1 (for Monday) though 7 (for Sunday )
+
+ return $this->passSimple($day);
+ }
+
+ public function passTime()
+ {
+ $now = $this->getNow();
+ $up = strtotime($this->date->format('Y-m-d ', true) . $this->params->publish_up);
+ $down = strtotime($this->date->format('Y-m-d ', true) . $this->params->publish_down);
+
+ if ($up > $down)
+ {
+ // publish up is after publish down (spans midnight)
+ // current time should be:
+ // - after publish up
+ // - OR before publish down
+ if ($now >= $up || $now < $down)
+ {
+ return $this->pass(true);
+ }
+
+ return $this->pass(false);
+ }
+
+ // publish down is after publish up (simple time span)
+ // current time should be:
+ // - after publish up
+ // - AND before publish down
+ if ($now >= $up && $now < $down)
+ {
+ return $this->pass(true);
+ }
+
+ return $this->pass(false);
+ }
+
+ private function getSeason(&$d, $hemisphere = 'northern')
+ {
+ // Set $date to today
+ $date = strtotime($d->format('Y-m-d H:i:s', true));
+
+ // Get year of date specified
+ $date_year = $d->format('Y', true); // Four digit representation for the year
+
+ // Specify the season names
+ $season_names = ['winter', 'spring', 'summer', 'fall'];
+
+ // Declare season date ranges
+ switch (strtolower($hemisphere))
+ {
+ case 'southern':
+ if (
+ $date < strtotime($date_year . '-03-21')
+ || $date >= strtotime($date_year . '-12-21')
+ )
+ {
+ return $season_names[2]; // Must be in Summer
+ }
+
+ if ($date >= strtotime($date_year . '-09-23'))
+ {
+ return $season_names[1]; // Must be in Spring
+ }
+
+ if ($date >= strtotime($date_year . '-06-21'))
+ {
+ return $season_names[0]; // Must be in Winter
+ }
+
+ if ($date >= strtotime($date_year . '-03-21'))
+ {
+ return $season_names[3]; // Must be in Fall
+ }
+ break;
+ case 'australia':
+ if (
+ $date < strtotime($date_year . '-03-01')
+ || $date >= strtotime($date_year . '-12-01')
+ )
+ {
+ return $season_names[2]; // Must be in Summer
+ }
+
+ if ($date >= strtotime($date_year . '-09-01'))
+ {
+ return $season_names[1]; // Must be in Spring
+ }
+
+ if ($date >= strtotime($date_year . '-06-01'))
+ {
+ return $season_names[0]; // Must be in Winter
+ }
+
+ if ($date >= strtotime($date_year . '-03-01'))
+ {
+ return $season_names[3]; // Must be in Fall
+ }
+ break;
+ default: // northern
+ if (
+ $date < strtotime($date_year . '-03-21')
+ || $date >= strtotime($date_year . '-12-21')
+ )
+ {
+ return $season_names[0]; // Must be in Winter
+ }
+
+ if ($date >= strtotime($date_year . '-09-23'))
+ {
+ return $season_names[3]; // Must be in Fall
+ }
+
+ if ($date >= strtotime($date_year . '-06-21'))
+ {
+ return $season_names[2]; // Must be in Summer
+ }
+
+ if ($date >= strtotime($date_year . '-03-21'))
+ {
+ return $season_names[1]; // Must be in Spring
+ }
+ break;
+ }
+
+ return 0;
+ }
+
+ private function getNow()
+ {
+ return strtotime($this->date->format('Y-m-d H:i:s', true));
+ }
+
+ private function getDate($date = '')
+ {
+ $id = 'date_' . $date;
+
+ if (isset($this->dates[$id]))
+ {
+ return $this->dates[$id];
+ }
+
+ $this->dates[$id] = JFactory::getDate($date);
+
+ if (empty($this->params->ignore_time_zone))
+ {
+ $this->dates[$id]->setTimeZone($this->getTimeZone());
+ }
+
+ return $this->dates[$id];
+ }
+
+ private function getTimeZone()
+ {
+ if ( ! is_null($this->timezone))
+ {
+ return $this->timezone;
+ }
+
+ $this->timezone = new DateTimeZone(JFactory::getApplication()->getCfg('offset'));
+
+ return $this->timezone;
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/easyblog.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/easyblog.php
new file mode 100644
index 00000000..858a8ee2
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/easyblog.php
@@ -0,0 +1,186 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+
+class RLAssignmentsEasyBlog extends RLAssignment
+{
+ public function passPageTypes()
+ {
+ return $this->passByPageTypes('com_easyblog', $this->selection, $this->assignment);
+ }
+
+ public function passCategories()
+ {
+ if ($this->request->option != 'com_easyblog')
+ {
+ return $this->pass(false);
+ }
+
+ $pass = (
+ ($this->params->inc_categories && $this->request->view == 'categories')
+ || ($this->params->inc_items && $this->request->view == 'entry')
+ );
+
+ if ( ! $pass)
+ {
+ return $this->pass(false);
+ }
+
+ $cats = $this->makeArray($this->getCategories());
+
+ $pass = $this->passSimple($cats, 'include');
+
+ if ($pass && $this->params->inc_children == 2)
+ {
+ return $this->pass(false);
+ }
+ else if ( ! $pass && $this->params->inc_children)
+ {
+ foreach ($cats as $cat)
+ {
+ $cats = array_merge($cats, $this->getCatParentIds($cat));
+ }
+ }
+
+ return $this->passSimple($cats);
+ }
+
+ private function getCategories()
+ {
+ switch ($this->request->view)
+ {
+ case 'entry' :
+ return $this->getCategoryIDFromItem();
+ break;
+
+ case 'categories' :
+ return $this->request->id;
+ break;
+
+ default:
+ return '';
+ }
+ }
+
+ private function getCategoryIDFromItem()
+ {
+ $query = $this->db->getQuery(true)
+ ->select('i.category_id')
+ ->from('#__easyblog_post AS i')
+ ->where('i.id = ' . (int) $this->request->id);
+ $this->db->setQuery($query);
+
+ return $this->db->loadResult();
+ }
+
+ public function passTags()
+ {
+ if ($this->request->option != 'com_easyblog')
+ {
+ return $this->pass(false);
+ }
+
+ $pass = (
+ ($this->params->inc_tags && $this->request->layout == 'tag')
+ || ($this->params->inc_items && $this->request->view == 'entry')
+ );
+
+ if ( ! $pass)
+ {
+ return $this->pass(false);
+ }
+
+ if ($this->params->inc_tags && $this->request->layout == 'tag')
+ {
+ $query = $this->db->getQuery(true)
+ ->select('t.alias')
+ ->from('#__easyblog_tag AS t')
+ ->where('t.id = ' . (int) $this->request->id)
+ ->where('t.published = 1');
+ $this->db->setQuery($query);
+ $tags = $this->db->loadColumn();
+
+ return $this->passSimple($tags, true);
+ }
+
+ $query = $this->db->getQuery(true)
+ ->select('t.alias')
+ ->from('#__easyblog_post_tag AS x')
+ ->join('LEFT', '#__easyblog_tag AS t ON t.id = x.tag_id')
+ ->where('x.post_id = ' . (int) $this->request->id)
+ ->where('t.published = 1');
+ $this->db->setQuery($query);
+ $tags = $this->db->loadColumn();
+
+ return $this->passSimple($tags, true);
+ }
+
+ public function passItems()
+ {
+ if ( ! $this->request->id || $this->request->option != 'com_easyblog' || $this->request->view != 'entry')
+ {
+ return $this->pass(false);
+ }
+
+ $pass = false;
+
+ // Pass Article Id
+ if ( ! $this->passItemByType($pass, 'ContentIds'))
+ {
+ return $this->pass(false);
+ }
+
+ // Pass Content Keywords
+ if ( ! $this->passItemByType($pass, 'ContentKeywords'))
+ {
+ return $this->pass(false);
+ }
+
+ // Pass Authors
+ if ( ! $this->passItemByType($pass, 'Authors'))
+ {
+ return $this->pass(false);
+ }
+
+ return $this->pass($pass);
+ }
+
+ public function passContentKeywords($fields = ['title', 'intro', 'content'], $text = '')
+ {
+ parent::passContentKeywords($fields);
+ }
+
+ public function getItem($fields = [])
+ {
+ $query = $this->db->getQuery(true)
+ ->select($fields)
+ ->from('#__easyblog_post')
+ ->where('id = ' . (int) $this->request->id);
+ $this->db->setQuery($query);
+
+ return $this->db->loadObject();
+ }
+
+ private function getCatParentIds($id = 0)
+ {
+ return $this->getParentIds($id, 'easyblog_category', 'parent_id');
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/flexicontent.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/flexicontent.php
new file mode 100644
index 00000000..5d04c55f
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/flexicontent.php
@@ -0,0 +1,100 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Factory as JFactory;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+
+class RLAssignmentsFlexiContent extends RLAssignment
+{
+ public function passPageTypes()
+ {
+ return $this->passByPageTypes('com_flexicontent', $this->selection, $this->assignment);
+ }
+
+ public function passTags()
+ {
+ if ($this->request->option != 'com_flexicontent')
+ {
+ return $this->pass(false);
+ }
+
+ $pass = (
+ ($this->params->inc_tags && $this->request->view == 'tags')
+ || ($this->params->inc_items && in_array($this->request->view, ['item', 'items']))
+ );
+
+ if ( ! $pass)
+ {
+ return $this->pass(false);
+ }
+
+ if ($this->params->inc_tags && $this->request->view == 'tags')
+ {
+ $query = $this->db->getQuery(true)
+ ->select('t.name')
+ ->from('#__flexicontent_tags AS t')
+ ->where('t.id = ' . (int) trim(JFactory::getApplication()->input->getInt('id', 0)))
+ ->where('t.published = 1');
+ $this->db->setQuery($query);
+ $tag = $this->db->loadResult();
+ $tags = [$tag];
+ }
+ else
+ {
+ $query = $this->db->getQuery(true)
+ ->select('t.name')
+ ->from('#__flexicontent_tags_item_relations AS x')
+ ->join('LEFT', '#__flexicontent_tags AS t ON t.id = x.tid')
+ ->where('x.itemid = ' . (int) $this->request->id)
+ ->where('t.published = 1');
+ $this->db->setQuery($query);
+ $tags = $this->db->loadColumn();
+ }
+
+ return $this->passSimple($tags, true);
+ }
+
+ public function passTypes()
+ {
+ if ($this->request->option != 'com_flexicontent')
+ {
+ return $this->pass(false);
+ }
+
+ $pass = in_array($this->request->view, ['item', 'items']);
+
+ if ( ! $pass)
+ {
+ return $this->pass(false);
+ }
+
+ $query = $this->db->getQuery(true)
+ ->select('x.type_id')
+ ->from('#__flexicontent_items_ext AS x')
+ ->where('x.item_id = ' . (int) $this->request->id);
+ $this->db->setQuery($query);
+ $type = $this->db->loadResult();
+
+ $types = $this->makeArray($type);
+
+ return $this->passSimple($types);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/form2content.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/form2content.php
new file mode 100644
index 00000000..43942b26
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/form2content.php
@@ -0,0 +1,43 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+
+class RLAssignmentsForm2Content extends RLAssignment
+{
+ public function passProjects()
+ {
+ if ($this->request->option != 'com_content' && $this->request->view == 'article')
+ {
+ return $this->pass(false);
+ }
+
+ $query = $this->db->getQuery(true)
+ ->select('c.projectid')
+ ->from('#__f2c_form AS c')
+ ->where('c.reference_id = ' . (int) $this->request->id);
+ $this->db->setQuery($query);
+ $type = $this->db->loadResult();
+
+ $types = $this->makeArray($type);
+
+ return $this->passSimple($types);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/geo.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/geo.php
new file mode 100644
index 00000000..4e9e784f
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/geo.php
@@ -0,0 +1,132 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Log\Log as JLog;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+
+class RLAssignmentsGeo extends RLAssignment
+{
+ var $geo = null;
+
+ /**
+ * passContinents
+ */
+ public function passContinents()
+ {
+ if ( ! $this->getGeo() || empty($this->geo->continentCode))
+ {
+ return $this->pass(false);
+ }
+
+ return $this->passSimple([$this->geo->continent, $this->geo->continentCode]);
+ }
+
+ /**
+ * passCountries
+ */
+ public function passCountries()
+ {
+ $this->getGeo();
+
+ if ( ! $this->getGeo() || empty($this->geo->countryCode))
+ {
+ return $this->pass(false);
+ }
+
+ return $this->passSimple([$this->geo->country, $this->geo->countryCode]);
+ }
+
+ /**
+ * passRegions
+ */
+ public function passRegions()
+ {
+ if ( ! $this->getGeo() || empty($this->geo->countryCode) || empty($this->geo->regionCodes))
+ {
+ return $this->pass(false);
+ }
+
+ $regions = $this->geo->regionCodes;
+ array_walk($regions, function (&$value) {
+ $value = $this->geo->countryCode . '-' . $value;
+ });
+
+ return $this->passSimple($regions);
+ }
+
+ /**
+ * passPostalcodes
+ */
+ public function passPostalcodes()
+ {
+ if ( ! $this->getGeo() || empty($this->geo->postalCode))
+ {
+ return $this->pass(false);
+ }
+
+ // replace dashes with dots: 730-0011 => 730.0011
+ $postalcode = str_replace('-', '.', $this->geo->postalCode);
+
+ return $this->passInRange($postalcode);
+ }
+
+ public function getGeo($ip = '')
+ {
+ if ($this->geo !== null)
+ {
+ return $this->geo;
+ }
+
+ $geo = $this->getGeoObject($ip);
+
+ if (empty($geo))
+ {
+ return false;
+ }
+
+ $this->geo = $geo->get();
+
+ if (JDEBUG)
+ {
+ JLog::addLogger(['text_file' => 'regularlabs_geoip.log.php'], JLog::ALL, ['regularlabs_geoip']);
+ JLog::add(json_encode($this->geo), JLog::DEBUG, 'regularlabs_geoip');
+ }
+
+ return $this->geo;
+ }
+
+ private function getGeoObject($ip)
+ {
+ if ( ! file_exists(JPATH_LIBRARIES . '/geoip/geoip.php'))
+ {
+ return false;
+ }
+
+ require_once JPATH_LIBRARIES . '/geoip/geoip.php';
+
+ if ( ! class_exists('RegularLabs_GeoIp'))
+ {
+ return new GeoIp($ip);
+ }
+
+ return new RegularLabs_GeoIp($ip);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/hikashop.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/hikashop.php
new file mode 100644
index 00000000..8ed42f76
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/hikashop.php
@@ -0,0 +1,125 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+
+class RLAssignmentsHikaShop extends RLAssignment
+{
+ public function passPageTypes()
+ {
+ if ($this->request->option != 'com_hikashop')
+ {
+ return $this->pass(false);
+ }
+
+ $type = $this->request->view;
+ if (
+ ($type == 'product' && in_array($this->request->layout, ['contact', 'show']))
+ || ($type == 'user' && in_array($this->request->layout, ['cpanel']))
+ )
+ {
+ $type .= '_' . $this->request->layout;
+ }
+
+ return $this->passSimple($type);
+ }
+
+ public function passCategories()
+ {
+ if ($this->request->option != 'com_hikashop')
+ {
+ return $this->pass(false);
+ }
+
+ $pass = (
+ ($this->params->inc_categories
+ && ($this->request->view == 'category' || $this->request->layout == 'listing')
+ )
+ || ($this->params->inc_items && $this->request->view == 'product')
+ );
+
+ if ( ! $pass)
+ {
+ return $this->pass(false);
+ }
+
+ $cats = $this->getCategories();
+
+ $pass = $this->passSimple($cats, 'include');
+
+ if ($pass && $this->params->inc_children == 2)
+ {
+ return $this->pass(false);
+ }
+ else if ( ! $pass && $this->params->inc_children)
+ {
+ foreach ($cats as $cat)
+ {
+ $cats = array_merge($cats, $this->getCatParentIds($cat));
+ }
+ }
+
+ return $this->passSimple($cats);
+ }
+
+ public function passProducts()
+ {
+ if ( ! $this->request->id || $this->request->option != 'com_hikashop' || $this->request->view != 'product')
+ {
+ return $this->pass(false);
+ }
+
+ return $this->passSimple($this->request->id);
+ }
+
+ private function getCategories()
+ {
+ switch (true)
+ {
+ case (($this->request->view == 'category' || $this->request->layout == 'listing') && $this->request->id):
+ return [$this->request->id];
+
+ case ($this->request->view == 'category' || $this->request->layout == 'listing'):
+ include_once JPATH_ADMINISTRATOR . '/components/com_hikashop/helpers/helper.php';
+ $menuClass = hikashop_get('class.menus');
+ $menuData = $menuClass->get($this->request->Itemid);
+
+ return $this->makeArray($menuData->hikashop_params['selectparentlisting']);
+
+ case ($this->request->id):
+ $query = $this->db->getQuery(true)
+ ->select('c.category_id')
+ ->from('#__hikashop_product_category AS c')
+ ->where('c.product_id = ' . (int) $this->request->id);
+ $this->db->setQuery($query);
+ $cats = $this->db->loadColumn();
+
+ return $this->makeArray($cats);
+
+ default:
+ return [];
+ }
+ }
+
+ private function getCatParentIds($id = 0)
+ {
+ return $this->getParentIds($id, 'hikashop_category', 'category_parent_id', 'category_id');
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/homepage.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/homepage.php
new file mode 100644
index 00000000..3e3d1979
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/homepage.php
@@ -0,0 +1,192 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Factory as JFactory;
+use Joomla\CMS\Language\LanguageHelper as JLanguageHelper;
+use Joomla\CMS\Uri\Uri as JUri;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/text.php';
+require_once dirname(__DIR__) . '/string.php';
+require_once dirname(__DIR__) . '/assignment.php';
+
+class RLAssignmentsHomePage extends RLAssignment
+{
+ public function passHomePage()
+ {
+ $home = JFactory::getApplication()->getMenu('site')->getDefault(JFactory::getLanguage()->getTag());
+
+ // return if option or other set values do not match the homepage menu item values
+ if ($this->request->option)
+ {
+ // check if option is different to home menu
+ if ( ! $home || ! isset($home->query['option']) || $home->query['option'] != $this->request->option)
+ {
+ return $this->pass(false);
+ }
+
+ if ( ! $this->request->option)
+ {
+ // set the view/task/layout in the menu item to empty if not set
+ $home->query['view'] = isset($home->query['view']) ? $home->query['view'] : '';
+ $home->query['task'] = isset($home->query['task']) ? $home->query['task'] : '';
+ $home->query['layout'] = isset($home->query['layout']) ? $home->query['layout'] : '';
+ }
+
+ // check set values against home menu query items
+ foreach ($home->query as $k => $v)
+ {
+ if ((isset($this->request->{$k}) && $this->request->{$k} != $v)
+ || (
+ ( ! isset($this->request->{$k}) || in_array($v, ['virtuemart', 'mijoshop']))
+ && JFactory::getApplication()->input->get($k) != $v
+ )
+ )
+ {
+ return $this->pass(false);
+ }
+ }
+
+ // check post values against home menu params
+ foreach ($home->params->toObject() as $k => $v)
+ {
+ if (($v && isset($_POST[$k]) && $_POST[$k] != $v)
+ || ( ! $v && isset($_POST[$k]) && $_POST[$k])
+ )
+ {
+ return $this->pass(false);
+ }
+ }
+ }
+
+ $pass = $this->checkPass($home);
+
+ if ( ! $pass)
+ {
+ $pass = $this->checkPass($home, 1);
+ }
+
+ return $this->pass($pass);
+ }
+
+ private function checkPass(&$home, $addlang = 0)
+ {
+ $uri = JUri::getInstance();
+
+ if ($addlang)
+ {
+ $sef = $uri->getVar('lang');
+ if (empty($sef))
+ {
+ $langs = array_keys(JLanguageHelper::getLanguages('sef'));
+ $path = RLString::substr(
+ $uri->toString(['scheme', 'user', 'pass', 'host', 'port', 'path']),
+ RLString::strlen($uri->base())
+ );
+ $path = preg_replace('#^index\.php/?#', '', $path);
+ $parts = explode('/', $path);
+ $part = reset($parts);
+ if (in_array($part, $langs))
+ {
+ $sef = $part;
+ }
+ }
+
+ if (empty($sef))
+ {
+ return false;
+ }
+ }
+
+ $query = $uri->toString(['query']);
+ if (strpos($query, 'option=') === false && strpos($query, 'Itemid=') === false)
+ {
+ $url = $uri->toString(['host', 'path']);
+ }
+ else
+ {
+ $url = $uri->toString(['host', 'path', 'query']);
+ }
+
+ // remove the www.
+ $url = preg_replace('#^www\.#', '', $url);
+ // replace ampersand chars
+ $url = str_replace('&', '&', $url);
+ // remove any language vars
+ $url = preg_replace('#((\?)lang=[a-z-_]*(&|$)|&lang=[a-z-_]*)#', '\2', $url);
+ // remove trailing nonsense
+ $url = trim(preg_replace('#/?\??&?$#', '', $url));
+ // remove the index.php/
+ $url = preg_replace('#/index\.php(/|$)#', '/', $url);
+ // remove trailing /
+ $url = trim(preg_replace('#/$#', '', $url));
+
+ $root = JUri::root();
+
+ // remove the http(s)
+ $root = preg_replace('#^.*?://#', '', $root);
+ // remove the www.
+ $root = preg_replace('#^www\.#', '', $root);
+ //remove the port
+ $root = preg_replace('#:[0-9]+#', '', $root);
+ // so also passes on urls with trailing /, ?, &, /?, etc...
+ $root = preg_replace('#(Itemid=[0-9]*).*^#', '\1', $root);
+ // remove trailing /
+ $root = trim(preg_replace('#/$#', '', $root));
+
+ if ($addlang)
+ {
+ $root .= '/' . $sef;
+ }
+
+ /* Pass urls:
+ * [root]
+ */
+ $regex = '#^' . $root . '$#i';
+
+ if (preg_match($regex, $url))
+ {
+ return true;
+ }
+
+ /* Pass urls:
+ * [root]?Itemid=[menu-id]
+ * [root]/?Itemid=[menu-id]
+ * [root]/index.php?Itemid=[menu-id]
+ * [root]/[menu-alias]
+ * [root]/[menu-alias]?Itemid=[menu-id]
+ * [root]/index.php?[menu-alias]
+ * [root]/index.php?[menu-alias]?Itemid=[menu-id]
+ * [root]/[menu-link]
+ * [root]/[menu-link]&Itemid=[menu-id]
+ */
+ $regex = '#^' . $root
+ . '(/('
+ . 'index\.php'
+ . '|'
+ . '(index\.php\?)?' . RLText::pregQuote($home->alias)
+ . '|'
+ . RLText::pregQuote($home->link)
+ . ')?)?'
+ . '(/?[\?&]Itemid=' . (int) $home->id . ')?'
+ . '$#i';
+
+ return preg_match($regex, $url);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/ips.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/ips.php
new file mode 100644
index 00000000..cd2edba5
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/ips.php
@@ -0,0 +1,148 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+
+class RLAssignmentsIPs extends RLAssignment
+{
+ public function passIPs()
+ {
+ if (is_array($this->selection))
+ {
+ $this->selection = implode(',', $this->selection);
+ }
+
+ $this->selection = explode(',', str_replace([' ', "\r", "\n"], ['', '', ','], $this->selection));
+
+ $pass = $this->checkIPList();
+
+ return $this->pass($pass);
+ }
+
+ private function checkIPList()
+ {
+ foreach ($this->selection as $range)
+ {
+ // Check next range if this one doesn't match
+ if ( ! $this->checkIP($range))
+ {
+ continue;
+ }
+
+ // Match found, so return true!
+ return true;
+ }
+
+ // No matches found, so return false
+ return false;
+ }
+
+ private function checkIP($range)
+ {
+ if (empty($range))
+ {
+ return false;
+ }
+
+ if (strpos($range, '-') !== false)
+ {
+ // Selection is an IP range
+ return $this->checkIPRange($range);
+ }
+
+ // Selection is a single IP (part)
+ return $this->checkIPPart($range);
+ }
+
+ private function checkIPRange($range)
+ {
+ $ip = $_SERVER['REMOTE_ADDR'];
+
+ // Return if no IP address can be found (shouldn't happen, but who knows)
+ if (empty($ip))
+ {
+ return false;
+ }
+
+ // check if IP is between or equal to the from and to IP range
+ list($min, $max) = explode('-', trim($range), 2);
+
+ // Return false if IP is smaller than the range start
+ if ($ip < trim($min))
+ {
+ return false;
+ }
+
+ $max = $this->fillMaxRange($max, $min);
+
+ // Return false if IP is larger than the range end
+ if ($ip > trim($max))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ /* Fill the max range by prefixing it with the missing parts from the min range
+ * So 101.102.103.104-201.202 becomes:
+ * max: 101.102.201.202
+ */
+ private function fillMaxRange($max, $min)
+ {
+ $max_parts = explode('.', $max);
+
+ if (count() == 4)
+ {
+ return $max;
+ }
+
+ $min_parts = explode('.', $min);
+
+ $prefix = array_slice($min_parts, 0, count($min_parts) - count($max_parts));
+
+ return implode('.', $prefix) . '.' . implode('.', $max_parts);
+ }
+
+ private function checkIPPart($range)
+ {
+ $ip = $_SERVER['REMOTE_ADDR'];
+
+ // Return if no IP address can be found (shouldn't happen, but who knows)
+ if (empty($ip))
+ {
+ return false;
+ }
+
+ $ip_parts = explode('.', $ip);
+ $range_parts = explode('.', trim($range));
+
+ // Trim the IP to the part length of the range
+ $ip = implode('.', array_slice($ip_parts, 0, count($range_parts)));
+
+ // Return false if ip does not match the range
+ if ($range != $ip)
+ {
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/k2.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/k2.php
new file mode 100644
index 00000000..fc73b892
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/k2.php
@@ -0,0 +1,202 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Factory as JFactory;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+
+// If controller.php exists, assume this is K2 v3
+defined('RL_K2_VERSION') or define('RL_K2_VERSION', JFile::exists(JPATH_ADMINISTRATOR . '/components/com_k2/controller.php') ? 3 : 2);
+
+class RLAssignmentsK2 extends RLAssignment
+{
+ public function passPageTypes()
+ {
+ return $this->passByPageTypes('com_k2', $this->selection, $this->assignment, false, true);
+ }
+
+ public function passCategories()
+ {
+ if ($this->request->option != 'com_k2')
+ {
+ return $this->pass(false);
+ }
+
+ $pass = (
+ ($this->params->inc_categories
+ && (($this->request->view == 'itemlist' && $this->request->task == 'category')
+ || $this->request->view == 'latest'
+ )
+ )
+ || ($this->params->inc_items && $this->request->view == 'item')
+ );
+
+ if ( ! $pass)
+ {
+ return $this->pass(false);
+ }
+
+ $cats = $this->makeArray($this->getCategories());
+ $pass = $this->passSimple($cats, 'include');
+
+ if ($pass && $this->params->inc_children == 2)
+ {
+ return $this->pass(false);
+ }
+ else if ( ! $pass && $this->params->inc_children)
+ {
+ foreach ($cats as $cat)
+ {
+ $cats = array_merge($cats, $this->getCatParentIds($cat));
+ }
+ }
+
+ return $this->passSimple($cats);
+ }
+
+ private function getCategories()
+ {
+ switch ($this->request->view)
+ {
+ case 'item' :
+ return $this->getCategoryIDFromItem();
+ break;
+
+ case 'itemlist' :
+ return $this->getCategoryID();
+ break;
+
+ default:
+ return '';
+ }
+ }
+
+ private function getCategoryID()
+ {
+ return $this->request->id ?: JFactory::getApplication()->getUserStateFromRequest('com_k2itemsfilter_category', 'catid', 0, 'int');
+ }
+
+ private function getCategoryIDFromItem()
+ {
+ if ($this->article && isset($this->article->catid))
+ {
+ return $this->article->catid;
+ }
+
+ $query = $this->db->getQuery(true)
+ ->select('i.catid')
+ ->from('#__k2_items AS i')
+ ->where('i.id = ' . (int) $this->request->id);
+ $this->db->setQuery($query);
+
+ return $this->db->loadResult();
+ }
+
+ public function passTags()
+ {
+ if ($this->request->option != 'com_k2')
+ {
+ return $this->pass(false);
+ }
+
+ $tag = trim(JFactory::getApplication()->input->getString('tag', ''));
+ $pass = (
+ ($this->params->inc_tags && $tag != '')
+ || ($this->params->inc_items && $this->request->view == 'item')
+ );
+
+ if ( ! $pass)
+ {
+ return $this->pass(false);
+ }
+
+ if ($this->params->inc_tags && $tag != '')
+ {
+ $tags = [trim(JFactory::getApplication()->input->getString('tag', ''))];
+
+ return $this->passSimple($tags, true);
+ }
+
+ $query = $this->db->getQuery(true)
+ ->select('t.name')
+ ->from('#__k2_tags_xref AS x')
+ ->join('LEFT', '#__k2_tags AS t ON t.id = x.tagID')
+ ->where('x.itemID = ' . (int) $this->request->id)
+ ->where('t.published = 1');
+ $this->db->setQuery($query);
+ $tags = $this->db->loadColumn();
+
+ return $this->passSimple($tags, true);
+ }
+
+ public function passItems()
+ {
+ if ( ! $this->request->id || $this->request->option != 'com_k2' || $this->request->view != 'item')
+ {
+ return $this->pass(false);
+ }
+
+ $pass = false;
+
+ // Pass Article Id
+ if ( ! $this->passItemByType($pass, 'ContentIds'))
+ {
+ return $this->pass(false);
+ }
+
+ // Pass Content Keywords
+ if ( ! $this->passItemByType($pass, 'ContentKeywords'))
+ {
+ return $this->pass(false);
+ }
+
+ // Pass Meta Keywords
+ if ( ! $this->passItemByType($pass, 'MetaKeywords'))
+ {
+ return $this->pass(false);
+ }
+
+ // Pass Authors
+ if ( ! $this->passItemByType($pass, 'Authors'))
+ {
+ return $this->pass(false);
+ }
+
+ return $this->pass($pass);
+ }
+
+ public function getItem($fields = [])
+ {
+ $query = $this->db->getQuery(true)
+ ->select($fields)
+ ->from('#__k2_items')
+ ->where('id = ' . (int) $this->request->id);
+ $this->db->setQuery($query);
+
+ return $this->db->loadObject();
+ }
+
+ private function getCatParentIds($id = 0)
+ {
+ $parent_field = RL_K2_VERSION == 3 ? 'parent_id' : 'parent';
+
+ return $this->getParentIds($id, 'k2_categories', $parent_field);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/languages.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/languages.php
new file mode 100644
index 00000000..d7ca1233
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/languages.php
@@ -0,0 +1,31 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Factory as JFactory;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+
+class RLAssignmentsLanguages extends RLAssignment
+{
+ public function passLanguages()
+ {
+ return $this->passSimple(JFactory::getLanguage()->getTag(), true);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/menu.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/menu.php
new file mode 100644
index 00000000..d7123d2c
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/menu.php
@@ -0,0 +1,106 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Factory as JFactory;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+
+class RLAssignmentsMenu extends RLAssignment
+{
+ public function passMenu()
+ {
+ // return if no Itemid or selection is set
+ if ( ! $this->request->Itemid || empty($this->selection))
+ {
+ return $this->pass($this->params->inc_noitemid);
+ }
+
+ $menutype = 'type.' . self::getMenuType();
+
+ // return true if menu type is in selection
+ if (in_array($menutype, $this->selection))
+ {
+ return $this->pass(true);
+ }
+
+ // return true if menu is in selection
+ if (in_array($this->request->Itemid, $this->selection))
+ {
+ return $this->pass(($this->params->inc_children != 2));
+ }
+
+ if ( ! $this->params->inc_children)
+ {
+ return $this->pass(false);
+ }
+
+ $parent_ids = $this->getMenuParentIds($this->request->Itemid);
+ $parent_ids = array_diff($parent_ids, [1]);
+ foreach ($parent_ids as $id)
+ {
+ if ( ! in_array($id, $this->selection))
+ {
+ continue;
+ }
+
+ return $this->pass(true);
+ }
+
+ return $this->pass(false);
+ }
+
+ private function getMenuParentIds($id = 0)
+ {
+ return $this->getParentIds($id, 'menu');
+ }
+
+ private function getMenuType()
+ {
+ if (isset($this->request->menutype))
+ {
+ return $this->request->menutype;
+ }
+
+ if (empty($this->request->Itemid))
+ {
+ $this->request->menutype = '';
+
+ return $this->request->menutype;
+ }
+
+ if (JFactory::getApplication()->isClient('site'))
+ {
+ $menu = JFactory::getApplication()->getMenu()->getItem((int) $this->request->Itemid);
+
+ $this->request->menutype = isset($menu->menutype) ? $menu->menutype : '';
+
+ return $this->request->menutype;
+ }
+
+ $query = $this->db->getQuery(true)
+ ->select('m.menutype')
+ ->from('#__menu AS m')
+ ->where('m.id = ' . (int) $this->request->Itemid);
+ $this->db->setQuery($query);
+ $this->request->menutype = $this->db->loadResult();
+
+ return $this->request->menutype;
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/mijoshop.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/mijoshop.php
new file mode 100644
index 00000000..86399c4d
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/mijoshop.php
@@ -0,0 +1,131 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Factory as JFactory;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+
+class RLAssignmentsMijoShop extends RLAssignment
+{
+ public function init()
+ {
+ $input = JFactory::getApplication()->input;
+
+ $category_id = $input->getCmd('path', 0);
+ if (strpos($category_id, '_'))
+ {
+ $category_id = end(explode('_', $category_id));
+ }
+
+ $this->request->item_id = $input->getInt('product_id', 0);
+ $this->request->category_id = $category_id;
+ $this->request->id = ($this->request->item_id) ? $this->request->item_id : $this->request->category_id;
+
+ $view = $input->getCmd('view', '');
+ if (empty($view))
+ {
+ $mijoshop = JPATH_ROOT . '/components/com_mijoshop/mijoshop/mijoshop.php';
+ if ( ! file_exists($mijoshop))
+ {
+ return;
+ }
+
+ require_once($mijoshop);
+
+ $route = $input->getString('route', '');
+ $view = MijoShop::get('router')->getView($route);
+ }
+
+ $this->request->view = $view;
+ }
+
+ public function passPageTypes()
+ {
+ return $this->passByPageTypes('com_mijoshop', $this->selection, $this->assignment, true);
+ }
+
+ public function passCategories()
+ {
+ if ($this->request->option != 'com_mijoshop')
+ {
+ return $this->pass(false);
+ }
+
+ $pass = (
+ ($this->params->inc_categories
+ && ($this->request->view == 'category')
+ )
+ || ($this->params->inc_items && $this->request->view == 'product')
+ );
+
+ if ( ! $pass)
+ {
+ return $this->pass(false);
+ }
+
+ $cats = [];
+ if ($this->request->category_id)
+ {
+ $cats = $this->request->category_id;
+ }
+ else if ($this->request->item_id)
+ {
+ $query = $this->db->getQuery(true)
+ ->select('c.category_id')
+ ->from('#__mijoshop_product_to_category AS c')
+ ->where('c.product_id = ' . (int) $this->request->id);
+ $this->db->setQuery($query);
+ $cats = $this->db->loadColumn();
+ }
+
+ $cats = $this->makeArray($cats);
+
+ $pass = $this->passSimple($cats, 'include');
+
+ if ($pass && $this->params->inc_children == 2)
+ {
+ return $this->pass(false);
+ }
+ else if ( ! $pass && $this->params->inc_children)
+ {
+ foreach ($cats as $cat)
+ {
+ $cats = array_merge($cats, $this->getCatParentIds($cat));
+ }
+ }
+
+ return $this->passSimple($cats);
+ }
+
+ public function passProducts()
+ {
+ if ( ! $this->request->id || $this->request->option != 'com_mijoshop' || $this->request->view != 'product')
+ {
+ return $this->pass(false);
+ }
+
+ return $this->passSimple($this->request->id);
+ }
+
+ private function getCatParentIds($id = 0)
+ {
+ return $this->getParentIds($id, 'mijoshop_category', 'parent_id', 'category_id');
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/php.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/php.php
new file mode 100644
index 00000000..7afddf12
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/php.php
@@ -0,0 +1,131 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Factory as JFactory;
+use Joomla\CMS\MVC\Model\BaseDatabaseModel as JModel;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+
+class RLAssignmentsPHP extends RLAssignment
+{
+ public function passPHP()
+ {
+ $article = $this->article;
+
+ if ( ! is_array($this->selection))
+ {
+ $this->selection = [$this->selection];
+ }
+
+ $pass = false;
+ foreach ($this->selection as $php)
+ {
+ // replace \n with newline and other fix stuff
+ $php = str_replace('\|', '|', $php);
+ $php = preg_replace('#(?request->option == 'com_content' && $this->request->view == 'article')
+ {
+ $article = $this->getArticleById($this->request->id);
+ }
+ }
+ if ( ! isset($Itemid))
+ {
+ $Itemid = JFactory::getApplication()->input->getInt('Itemid', 0);
+ }
+ if ( ! isset($mainframe))
+ {
+ $mainframe = JFactory::getApplication();
+ }
+ if ( ! isset($app))
+ {
+ $app = JFactory::getApplication();
+ }
+ if ( ! isset($document))
+ {
+ $document = JFactory::getDocument();
+ }
+ if ( ! isset($doc))
+ {
+ $doc = JFactory::getDocument();
+ }
+ if ( ! isset($database))
+ {
+ $database = JFactory::getDbo();
+ }
+ if ( ! isset($db))
+ {
+ $db = JFactory::getDbo();
+ }
+ if ( ! isset($user))
+ {
+ $user = JFactory::getUser();
+ }
+ $php .= ';return true;';
+
+ $temp_PHP_func = create_function('&$article, &$Itemid, &$mainframe, &$app, &$document, &$doc, &$database, &$db, &$user', $php);
+
+ // evaluate the script
+ ob_start();
+ $pass = (bool) $temp_PHP_func($article, $Itemid, $mainframe, $app, $document, $doc, $database, $db, $user);
+ unset($temp_PHP_func);
+ ob_end_clean();
+
+ if ($pass)
+ {
+ break;
+ }
+ }
+
+ return $this->pass($pass);
+ }
+
+ private function getArticleById($id = 0)
+ {
+ if ( ! $id)
+ {
+ return null;
+ }
+
+ if ( ! class_exists('ContentModelArticle'))
+ {
+ require_once JPATH_SITE . '/components/com_content/models/article.php';
+ }
+
+ $model = JModel::getInstance('article', 'contentModel');
+
+ if ( ! method_exists($model, 'getItem'))
+ {
+ return null;
+ }
+
+ return $model->getItem($this->request->id);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/redshop.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/redshop.php
new file mode 100644
index 00000000..daed3a09
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/redshop.php
@@ -0,0 +1,106 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Factory as JFactory;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+
+class RLAssignmentsRedShop extends RLAssignment
+{
+ public function init()
+ {
+ $this->request->item_id = JFactory::getApplication()->input->getInt('pid', 0);
+ $this->request->category_id = JFactory::getApplication()->input->getInt('cid', 0);
+ $this->request->id = ($this->request->item_id) ? $this->request->item_id : $this->request->category_id;
+ }
+
+ public function passPageTypes()
+ {
+ return $this->passByPageTypes('com_redshop', $this->selection, $this->assignment, true);
+ }
+
+ public function passCategories()
+ {
+ if ($this->request->option != 'com_redshop')
+ {
+ return $this->pass(false);
+ }
+
+ $pass = (
+ ($this->params->inc_categories
+ && ($this->request->view == 'category')
+ )
+ || ($this->params->inc_items && $this->request->view == 'product')
+ );
+
+ if ( ! $pass)
+ {
+ return $this->pass(false);
+ }
+
+ $cats = [];
+ if ($this->request->category_id)
+ {
+ $cats = $this->request->category_id;
+ }
+ else if ($this->request->item_id)
+ {
+ $query = $this->db->getQuery(true)
+ ->select('x.category_id')
+ ->from('#__redshop_product_category_xref AS x')
+ ->where('x.product_id = ' . (int) $this->request->item_id);
+ $this->db->setQuery($query);
+ $cats = $this->db->loadColumn();
+ }
+
+ $cats = $this->makeArray($cats);
+
+ $pass = $this->passSimple($cats, 'include');
+
+ if ($pass && $this->params->inc_children == 2)
+ {
+ return $this->pass(false);
+ }
+ else if ( ! $pass && $this->params->inc_children)
+ {
+ foreach ($cats as $cat)
+ {
+ $cats = array_merge($cats, $this->getCatParentIds($cat));
+ }
+ }
+
+ return $this->passSimple($cats);
+ }
+
+ public function passProducts()
+ {
+ if ( ! $this->request->id || $this->request->option != 'com_redshop' || $this->request->view != 'product')
+ {
+ return $this->pass(false);
+ }
+
+ return $this->passSimple($this->request->id);
+ }
+
+ private function getCatParentIds($id = 0)
+ {
+ return $this->getParentIds($id, 'redshop_category_xref', 'category_parent_id', 'category_child_id');
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/tags.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/tags.php
new file mode 100644
index 00000000..73db7baf
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/tags.php
@@ -0,0 +1,125 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+
+class RLAssignmentsTags extends RLAssignment
+{
+ public function passTags()
+ {
+ if (in_array($this->request->option, ['com_content', 'com_flexicontent']))
+ {
+ return $this->passTagsContent();
+ }
+
+ if ($this->request->option != 'com_tags'
+ || $this->request->view != 'tag'
+ || ! $this->request->id
+ )
+ {
+ return $this->pass(false);
+ }
+
+ return $this->passTag($this->request->id);
+ }
+
+ private function passTagsContent()
+ {
+ $is_item = in_array($this->request->view, ['', 'article', 'item']);
+ $is_category = in_array($this->request->view, ['category']);
+
+ switch (true)
+ {
+ case ($is_item):
+ $prefix = 'com_content.article';
+ break;
+
+ case ($is_category):
+ $prefix = 'com_content.category';
+ break;
+
+ default:
+ return $this->pass(false);
+ }
+
+ // Load the tags.
+ $query = $this->db->getQuery(true)
+ ->select($this->db->quoteName('t.id'))
+ ->select($this->db->quoteName('t.title'))
+ ->from('#__tags AS t')
+ ->join(
+ 'INNER', '#__contentitem_tag_map AS m'
+ . ' ON m.tag_id = t.id'
+ . ' AND m.type_alias = ' . $this->db->quote($prefix)
+ . ' AND m.content_item_id IN ( ' . $this->request->id . ')'
+ );
+ $this->db->setQuery($query);
+ $tags = $this->db->loadObjectList();
+
+ if (empty($tags))
+ {
+ return $this->pass(false);
+ }
+
+ foreach ($tags as $tag)
+ {
+ if ( ! $this->passTag($tag->id) && ! $this->passTag($tag->title))
+ {
+ continue;
+ }
+
+ return $this->pass(true);
+ }
+
+ return $this->pass(false);
+ }
+
+ private function passTag($tag)
+ {
+ $pass = in_array($tag, $this->selection);
+
+ if ($pass)
+ {
+ // If passed, return false if assigned to only children
+ // Else return true
+ return ($this->params->inc_children != 2);
+ }
+
+ if ( ! $this->params->inc_children)
+ {
+ return false;
+ }
+
+ // Return true if a parent id is present in the selection
+ return array_intersect(
+ $this->getTagsParentIds($tag),
+ $this->selection
+ );
+ }
+
+ private function getTagsParentIds($id = 0)
+ {
+ $parentids = $this->getParentIds($id, 'tags');
+ // Remove the root tag
+ $parentids = array_diff($parentids, [1]);
+
+ return $parentids;
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/templates.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/templates.php
new file mode 100644
index 00000000..80555516
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/templates.php
@@ -0,0 +1,73 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Factory as JFactory;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+
+class RLAssignmentsTemplates extends RLAssignment
+{
+ public function passTemplates()
+ {
+ $template = $this->getTemplate();
+
+ // Put template name and name + style id into array
+ // The '::' separator was used in pre Joomla 3.3
+ $template = [$template->template, $template->template . '--' . $template->id, $template->template . '::' . $template->id];
+
+ return $this->passSimple($template, true);
+ }
+
+ public function getTemplate()
+ {
+ $template = JFactory::getApplication()->getTemplate(true);
+
+ if (isset($template->id))
+ {
+ return $template;
+ }
+
+ $params = json_encode($template->params);
+
+ // Find template style id based on params, as the template style id is not always stored in the getTemplate
+ $query = $this->db->getQuery(true)
+ ->select('id')
+ ->from('#__template_styles as s')
+ ->where('s.client_id = 0')
+ ->where('s.template = ' . $this->db->quote($template->template))
+ ->where('s.params = ' . $this->db->quote($params));
+ $this->db->setQuery($query, 0, 1);
+ $template->id = $this->db->loadResult('id');
+
+ if ($template->id)
+ {
+ return $template;
+ }
+
+ // No template style id is found, so just grab the first result based on the template name
+ $query->clear('where')
+ ->where('s.client_id = 0')
+ ->where('s.template = ' . $this->db->quote($template->template));
+ $this->db->setQuery($query, 0, 1);
+ $template->id = $this->db->loadResult('id');
+
+ return $template;
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/urls.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/urls.php
new file mode 100644
index 00000000..960d033d
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/urls.php
@@ -0,0 +1,92 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Uri\Uri as JUri;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+require_once dirname(__DIR__) . '/text.php';
+
+class RLAssignmentsURLs extends RLAssignment
+{
+ public function passURLs()
+ {
+ $regex = isset($this->params->regex) ? $this->params->regex : 0;
+
+ if ( ! is_array($this->selection))
+ {
+ $this->selection = explode("\n", $this->selection);
+ }
+
+ if (count($this->selection) == 1)
+ {
+ $this->selection = explode("\n", $this->selection[0]);
+ }
+
+ $url = JUri::getInstance();
+ $url = $url->toString();
+
+ $urls = [
+ RLText::html_entity_decoder(urldecode($url)),
+ urldecode($url),
+ RLText::html_entity_decoder($url),
+ $url,
+ ];
+ $urls = array_unique($urls);
+
+ $pass = false;
+ foreach ($urls as $url)
+ {
+ foreach ($this->selection as $s)
+ {
+ $s = trim($s);
+ if ($s == '')
+ {
+ continue;
+ }
+
+ if ($regex)
+ {
+ $url_part = str_replace(['#', '&'], ['\#', '(&|&)'], $s);
+ $s = '#' . $url_part . '#si';
+ if (@preg_match($s . 'u', $url) || @preg_match($s, $url))
+ {
+ $pass = true;
+ break;
+ }
+
+ continue;
+ }
+
+ if (strpos($url, $s) !== false)
+ {
+ $pass = true;
+ break;
+ }
+ }
+
+ if ($pass)
+ {
+ break;
+ }
+ }
+
+ return $this->pass($pass);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/users.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/users.php
new file mode 100644
index 00000000..f8c33728
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/users.php
@@ -0,0 +1,175 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Factory as JFactory;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+
+class RLAssignmentsUsers extends RLAssignment
+{
+ public function passAccessLevels()
+ {
+ $user = JFactory::getUser();
+
+ $levels = $user->getAuthorisedViewLevels();
+
+ $this->selection = $this->convertAccessLevelNamesToIds($this->selection);
+
+ return $this->passSimple($levels);
+ }
+
+ public function passUserGroupLevels()
+ {
+ $user = JFactory::getUser();
+
+ if ( ! empty($user->groups))
+ {
+ $groups = array_values($user->groups);
+ }
+ else
+ {
+ $groups = $user->getAuthorisedGroups();
+ }
+
+ if ($this->params->inc_children)
+ {
+ $this->setUserGroupChildrenIds();
+ }
+
+ $this->selection = $this->convertUsergroupNamesToIds($this->selection);
+
+ return $this->passSimple($groups);
+ }
+
+ public function passUsers()
+ {
+ return $this->passSimple(JFactory::getUser()->get('id'));
+ }
+
+ private function convertAccessLevelNamesToIds($selection)
+ {
+ $names = [];
+
+ foreach ($selection as $i => $level)
+ {
+ if (is_numeric($level))
+ {
+ continue;
+ }
+
+ unset($selection[$i]);
+
+ $names[] = strtolower(str_replace(' ', '', $level));
+ }
+
+ $db = JFactory::getDbo();
+
+ $query = $db->getQuery(true)
+ ->select($db->quoteName('id'))
+ ->from('#__viewlevels')
+ ->where('LOWER(REPLACE(' . $db->quoteName('title') . ', " ", "")) IN (\'' . implode('\',\'', $names) . '\')');
+ $db->setQuery($query);
+
+ $level_ids = $db->loadColumn();
+
+ return array_unique(array_merge($selection, $level_ids));
+ }
+
+ private function convertUsergroupNamesToIds($selection)
+ {
+ $names = [];
+
+ foreach ($selection as $i => $group)
+ {
+ if (is_numeric($group))
+ {
+ continue;
+ }
+
+ unset($selection[$i]);
+
+ $names[] = strtolower(str_replace(' ', '', $group));
+ }
+
+ $db = JFactory::getDbo();
+
+ $query = $db->getQuery(true)
+ ->select($db->quoteName('id'))
+ ->from('#__usergroups')
+ ->where('LOWER(REPLACE(' . $db->quoteName('title') . ', " ", "")) IN (\'' . implode('\',\'', $names) . '\')');
+ $db->setQuery($query);
+
+ $group_ids = $db->loadColumn();
+
+ return array_unique(array_merge($selection, $group_ids));
+ }
+
+ private function setUserGroupChildrenIds()
+ {
+ $children = $this->getUserGroupChildrenIds($this->selection);
+
+ if ($this->params->inc_children == 2)
+ {
+ $this->selection = $children;
+
+ return;
+ }
+
+ $this->selection = array_merge($this->selection, $children);
+ }
+
+ private function getUserGroupChildrenIds($groups)
+ {
+ $children = [];
+
+ $db = JFactory::getDbo();
+
+ foreach ($groups as $group)
+ {
+ $query = $db->getQuery(true)
+ ->select($db->quoteName('id'))
+ ->from($db->quoteName('#__usergroups'))
+ ->where($db->quoteName('parent_id') . ' = ' . (int) $group);
+ $db->setQuery($query);
+
+ $group_children = $db->loadColumn();
+
+ if (empty($group_children))
+ {
+ continue;
+ }
+
+ $children = array_merge($children, $group_children);
+
+ $group_grand_children = $this->getUserGroupChildrenIds($group_children);
+
+ if (empty($group_grand_children))
+ {
+ continue;
+ }
+
+ $children = array_merge($children, $group_grand_children);
+ }
+
+ $children = array_unique($children);
+
+ return $children;
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/virtuemart.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/virtuemart.php
new file mode 100644
index 00000000..379b0cce
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/virtuemart.php
@@ -0,0 +1,142 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Factory as JFactory;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+
+class RLAssignmentsVirtueMart extends RLAssignment
+{
+ public function init()
+ {
+ $virtuemart_product_id = JFactory::getApplication()->input->get('virtuemart_product_id', [], 'array');
+ $virtuemart_category_id = JFactory::getApplication()->input->get('virtuemart_category_id', [], 'array');
+
+ $this->request->item_id = isset($virtuemart_product_id[0]) ? $virtuemart_product_id[0] : null;
+ $this->request->category_id = isset($virtuemart_category_id[0]) ? $virtuemart_category_id[0] : null;
+ $this->request->id = ($this->request->item_id) ? $this->request->item_id : $this->request->category_id;
+ }
+
+ public function passPageTypes()
+ {
+ // Because VM sucks, we have to get the view again
+ $this->request->view = JFactory::getApplication()->input->getString('view');
+
+ return $this->passByPageTypes('com_virtuemart', $this->selection, $this->assignment, true);
+ }
+
+ public function passCategories()
+ {
+ if ($this->request->option != 'com_virtuemart')
+ {
+ return $this->pass(false);
+ }
+
+ // Because VM sucks, we have to get the view again
+ $this->request->view = JFactory::getApplication()->input->getString('view');
+
+ $pass = (($this->params->inc_categories && in_array($this->request->view, ['categories', 'category']))
+ || ($this->params->inc_items && $this->request->view == 'productdetails')
+ );
+
+ if ( ! $pass)
+ {
+ return $this->pass(false);
+ }
+
+ $cats = [];
+ if ($this->request->view == 'productdetails' && $this->request->item_id)
+ {
+ $query = $this->db->getQuery(true)
+ ->select('x.virtuemart_category_id')
+ ->from('#__virtuemart_product_categories AS x')
+ ->where('x.virtuemart_product_id = ' . (int) $this->request->item_id);
+ $this->db->setQuery($query);
+ $cats = $this->db->loadColumn();
+ }
+ else if ($this->request->category_id)
+ {
+ $cats = $this->request->category_id;
+ if ( ! is_numeric($cats))
+ {
+ $query = $this->db->getQuery(true)
+ ->select('config')
+ ->from('#__virtuemart_configs')
+ ->where('virtuemart_config_id = 1');
+ $this->db->setQuery($query);
+ $config = $this->db->loadResult();
+ $lang = substr($config, strpos($config, 'vmlang='));
+ $lang = substr($lang, 0, strpos($lang, '|'));
+ if (preg_match('#"([^"]*_[^"]*)"#', $lang, $lang))
+ {
+ $lang = $lang[1];
+ }
+ else
+ {
+ $lang = 'en_gb';
+ }
+
+ $query = $this->db->getQuery(true)
+ ->select('l.virtuemart_category_id')
+ ->from('#__virtuemart_categories_' . $lang . ' AS l')
+ ->where('l.slug = ' . $this->db->quote($cats));
+ $this->db->setQuery($query);
+ $cats = $this->db->loadResult();
+ }
+ }
+
+ $cats = $this->makeArray($cats);
+
+ $pass = $this->passSimple($cats, 'include');
+
+ if ($pass && $this->params->inc_children == 2)
+ {
+ return $this->pass(false);
+ }
+
+ if ( ! $pass && $this->params->inc_children)
+ {
+ foreach ($cats as $cat)
+ {
+ $cats = array_merge($cats, $this->getCatParentIds($cat));
+ }
+ }
+
+ return $this->passSimple($cats);
+ }
+
+ public function passProducts()
+ {
+ // Because VM sucks, we have to get the view again
+ $this->request->view = JFactory::getApplication()->input->getString('view');
+
+ if ( ! $this->request->id || $this->request->option != 'com_virtuemart' || $this->request->view != 'productdetails')
+ {
+ return $this->pass(false);
+ }
+
+ return $this->passSimple($this->request->id);
+ }
+
+ private function getCatParentIds($id = 0)
+ {
+ return $this->getParentIds($id, 'virtuemart_category_categories', 'category_parent_id', 'category_child_id');
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/assignments/zoo.php b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/zoo.php
new file mode 100644
index 00000000..251b5a6e
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/assignments/zoo.php
@@ -0,0 +1,290 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Factory as JFactory;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+require_once dirname(__DIR__) . '/assignment.php';
+
+class RLAssignmentsZoo extends RLAssignment
+{
+ public function init()
+ {
+ if ( ! $this->request->view)
+ {
+ $this->request->view = $this->request->task;
+ }
+
+ switch ($this->request->view)
+ {
+ case 'item':
+ $this->request->idname = 'item_id';
+ break;
+ case 'category':
+ $this->request->idname = 'category_id';
+ break;
+ }
+
+ $this->request->id = JFactory::getApplication()->input->getInt($this->request->idname, 0);
+ }
+
+ public function initAssignment($assignment, $article = 0)
+ {
+ parent::initAssignment($assignment, $article);
+
+ if ($this->request->option != 'com_zoo' && ! isset($this->request->idname))
+ {
+ return;
+ }
+
+ switch ($this->request->idname)
+ {
+ case 'item_id':
+ $this->request->view = 'item';
+ break;
+ case 'category_id':
+ $this->request->view = 'category';
+ break;
+ }
+ }
+
+ public function passPageTypes()
+ {
+ return $this->passByPageTypes('com_zoo', $this->selection, $this->assignment);
+ }
+
+ public function passCategories()
+ {
+ if ($this->request->option != 'com_zoo')
+ {
+ return $this->pass(false);
+ }
+
+ $pass = (
+ ($this->params->inc_apps && $this->request->view == 'frontpage')
+ || ($this->params->inc_categories && $this->request->view == 'category')
+ || ($this->params->inc_items && $this->request->view == 'item')
+ );
+
+ if ( ! $pass)
+ {
+ return $this->pass(false);
+ }
+
+ $cats = $this->getCategories();
+
+ if ($cats === false)
+ {
+ return $this->pass(false);
+ }
+
+ $cats = $this->makeArray($cats);
+
+ $pass = $this->passSimple($cats, 'include');
+
+ if ($pass && $this->params->inc_children == 2)
+ {
+ return $this->pass(false);
+ }
+
+ if ( ! $pass && $this->params->inc_children)
+ {
+ foreach ($cats as $cat)
+ {
+ $cats = array_merge($cats, $this->getCatParentIds($cat));
+ }
+ }
+
+ return $this->passSimple($cats);
+ }
+
+ private function getCategories()
+ {
+ if ($this->article && isset($this->article->catid))
+ {
+ return [$this->article->catid];
+ }
+
+ $menuparams = $this->getMenuItemParams($this->request->Itemid);
+
+ switch ($this->request->view)
+ {
+ case 'frontpage':
+ if ($this->request->id)
+ {
+ return [$this->request->id];
+ }
+
+ if ( ! isset($menuparams->application))
+ {
+ return [];
+ }
+
+ return ['app' . $menuparams->application];
+
+ case 'category':
+ $cats = [];
+
+ if ($this->request->id)
+ {
+ $cats[] = $this->request->id;
+ }
+ else if (isset($menuparams->category))
+ {
+ $cats[] = $menuparams->category;
+ }
+
+ if (empty($cats[0]))
+ {
+ return [];
+ }
+
+ $query = $this->db->getQuery(true)
+ ->select('c.application_id')
+ ->from('#__zoo_category AS c')
+ ->where('c.id = ' . (int) $cats[0]);
+ $this->db->setQuery($query);
+ $cats[] = 'app' . $this->db->loadResult();
+
+ return $cats;
+
+ case 'item':
+ $id = $this->request->id;
+
+ if ( ! $id && isset($menuparams->item_id))
+ {
+ $id = $menuparams->item_id;
+ }
+
+ if ( ! $id)
+ {
+ return [];
+ }
+
+ $query = $this->db->getQuery(true)
+ ->select('c.category_id')
+ ->from('#__zoo_category_item AS c')
+ ->where('c.item_id = ' . (int) $id)
+ ->where('c.category_id != 0');
+ $this->db->setQuery($query);
+ $cats = $this->db->loadColumn();
+
+ $query = $this->db->getQuery(true)
+ ->select('i.application_id')
+ ->from('#__zoo_item AS i')
+ ->where('i.id = ' . (int) $id);
+ $this->db->setQuery($query);
+ $cats[] = 'app' . $this->db->loadResult();
+
+ return $cats;
+
+ default:
+ return false;
+ }
+ }
+
+ public function passItems()
+ {
+ if ( ! $this->request->id || $this->request->option != 'com_zoo')
+ {
+ return $this->pass(false);
+ }
+
+ if ($this->request->view != 'item')
+ {
+ return $this->pass(false);
+ }
+
+ $pass = false;
+
+ // Pass Article Id
+ if ( ! $this->passItemByType($pass, 'ContentIds'))
+ {
+ return $this->pass(false);
+ }
+
+ // Pass Authors
+ if ( ! $this->passItemByType($pass, 'Authors'))
+ {
+ return $this->pass(false);
+ }
+
+ return $this->pass($pass);
+ }
+
+ public function getItem($fields = [])
+ {
+ $query = $this->db->getQuery(true)
+ ->select($fields)
+ ->from('#__zoo_item')
+ ->where('id = ' . (int) $this->request->id);
+ $this->db->setQuery($query);
+
+ return $this->db->loadObject();
+ }
+
+ private function getCatParentIds($id = 0)
+ {
+ $parent_ids = [];
+
+ if ( ! $id)
+ {
+ return $parent_ids;
+ }
+
+ while ($id)
+ {
+ if (substr($id, 0, 3) == 'app')
+ {
+ $parent_ids[] = $id;
+ break;
+ }
+
+ $query = $this->db->getQuery(true)
+ ->select('c.parent')
+ ->from('#__zoo_category AS c')
+ ->where('c.id = ' . (int) $id);
+ $this->db->setQuery($query);
+ $pid = $this->db->loadResult();
+
+ if ( ! $pid)
+ {
+ $query = $this->db->getQuery(true)
+ ->select('c.application_id')
+ ->from('#__zoo_category AS c')
+ ->where('c.id = ' . (int) $id);
+ $this->db->setQuery($query);
+ $app = $this->db->loadResult();
+
+ if ($app)
+ {
+ $parent_ids[] = 'app' . $app;
+ }
+
+ break;
+ }
+
+ $parent_ids[] = $pid;
+
+ $id = $pid;
+ }
+
+ return $parent_ids;
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/cache.php b/deployed/regularlabs/libraries/regularlabs/helpers/cache.php
new file mode 100644
index 00000000..a6a37d88
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/cache.php
@@ -0,0 +1,51 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use RegularLabs\Library\Cache as RL_Cache;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+class RLCache
+{
+ static $cache = [];
+
+ public static function has($id)
+ {
+ return RL_Cache::has($id);
+ }
+
+ public static function get($id)
+ {
+ return RL_Cache::get($id);
+ }
+
+ public static function set($id, $data)
+ {
+ return RL_Cache::set($id, $data);
+ }
+
+ public static function read($id)
+ {
+ return RL_Cache::read($id);
+ }
+
+ public static function write($id, $data, $ttl = 0)
+ {
+ return RL_Cache::write($id, $data, $ttl);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/field.php b/deployed/regularlabs/libraries/regularlabs/helpers/field.php
new file mode 100644
index 00000000..2284f8b9
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/field.php
@@ -0,0 +1,24 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+class RLFormField
+ extends \RegularLabs\Library\Field
+{
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/functions.php b/deployed/regularlabs/libraries/regularlabs/helpers/functions.php
new file mode 100644
index 00000000..5c9bac97
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/functions.php
@@ -0,0 +1,150 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use RegularLabs\Library\Document as RL_Document;
+use RegularLabs\Library\Extension as RL_Extension;
+use RegularLabs\Library\File as RL_File;
+use RegularLabs\Library\Http as RL_Http;
+use RegularLabs\Library\Language as RL_Language;
+use RegularLabs\Library\Xml as RL_Xml;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+/**
+ * Framework Functions
+ */
+class RLFunctions
+{
+ public static function getContents($url, $timeout = 20)
+ {
+ return ! class_exists('RegularLabs\Library\Http') ? '' : RL_Http::get($url, $timeout);
+ }
+
+ public static function getByUrl($url, $timeout = 20)
+ {
+ return ! class_exists('RegularLabs\Library\Http') ? '' : RL_Http::getFromServer($url, $timeout);
+ }
+
+ public static function isFeed()
+ {
+ return class_exists('RegularLabs\Library\Document') && RL_Document::isFeed();
+ }
+
+ public static function script($file, $version = '')
+ {
+ class_exists('RegularLabs\Library\Document') && RL_Document::script($file, $version);
+ }
+
+ public static function stylesheet($file, $version = '')
+ {
+ class_exists('RegularLabs\Library\Document') && RL_Document::stylesheet($file, $version);
+ }
+
+ public static function addScriptVersion($url)
+ {
+ jimport('joomla.filesystem.file');
+
+ $version = '';
+
+ if (JFile::exists(JPATH_SITE . $url))
+ {
+ $version = filemtime(JPATH_SITE . $url);
+ }
+
+ self::script($url, $version);
+ }
+
+ public static function addStyleSheetVersion($url)
+ {
+ jimport('joomla.filesystem.file');
+
+ $version = '';
+
+ if (JFile::exists(JPATH_SITE . $url))
+ {
+ $version = filemtime(JPATH_SITE . $url);
+ }
+
+ self::stylesheet($url, $version);
+ }
+
+ protected static function getFileByFolder($folder, $file)
+ {
+ return ! class_exists('RegularLabs\Library\File') ? '' : RL_File::getMediaFile($folder, $file);
+ }
+
+ public static function getComponentBuffer()
+ {
+ return ! class_exists('RegularLabs\Library\Document') ? '' : RL_Document::getBuffer();
+ }
+
+ public static function getAliasAndElement(&$name)
+ {
+ return ! class_exists('RegularLabs\Library\Extension') ? '' : RL_Extension::getAliasAndElement($name);
+ }
+
+ public static function getNameByAlias($alias)
+ {
+ return ! class_exists('RegularLabs\Library\Extension') ? '' : RL_Extension::getNameByAlias($alias);
+ }
+
+ public static function getAliasByName($name)
+ {
+ return ! class_exists('RegularLabs\Library\Extension') ? '' : RL_Extension::getAliasByName($name);
+ }
+
+ public static function getElementByAlias($alias)
+ {
+ return ! class_exists('RegularLabs\Library\Extension') ? '' : RL_Extension::getElementByAlias($alias);
+ }
+
+ public static function getXMLValue($key, $alias, $type = 'component', $folder = 'system')
+ {
+ return ! class_exists('RegularLabs\Library\Extension') ? '' : RL_Extension::getXMLValue($key, $alias, $type, $folder);
+ }
+
+ public static function getXML($alias, $type = 'component', $folder = 'system')
+ {
+ return ! class_exists('RegularLabs\Library\Extension') ? '' : RL_Extension::getXML($alias, $type, $folder);
+ }
+
+ public static function getXMLFile($alias, $type = 'component', $folder = 'system')
+ {
+ return ! class_exists('RegularLabs\Library\Extension') ? '' : RL_Extension::getXMLFile($alias, $type, $folder);
+ }
+
+ public static function extensionInstalled($extension, $type = 'component', $folder = 'system')
+ {
+ return ! class_exists('RegularLabs\Library\Extension') ? '' : RL_Extension::isInstalled($extension, $type, $folder);
+ }
+
+ public static function getExtensionPath($extension = 'plg_system_regularlabs', $basePath = JPATH_ADMINISTRATOR, $check_folder = '')
+ {
+ return ! class_exists('RegularLabs\Library\Extension') ? '' : RL_Extension::getPath($extension, $basePath, $check_folder);
+ }
+
+ public static function loadLanguage($extension = 'plg_system_regularlabs', $basePath = '', $reload = false)
+ {
+ return class_exists('RegularLabs\Library\Language') && RL_Language::load($extension, $basePath, $reload);
+ }
+
+ public static function xmlToObject($url, $root = '')
+ {
+ return ! class_exists('RegularLabs\Library\Xml') ? '' : RL_Xml::toObject($url, $root);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/groupfield.php b/deployed/regularlabs/libraries/regularlabs/helpers/groupfield.php
new file mode 100644
index 00000000..8da110b0
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/groupfield.php
@@ -0,0 +1,24 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+class RLFormGroupField
+ extends \RegularLabs\Library\FieldGroup
+{
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/helper.php b/deployed/regularlabs/libraries/regularlabs/helpers/helper.php
new file mode 100644
index 00000000..d3809334
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/helper.php
@@ -0,0 +1,70 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+defined('_JEXEC') or die;
+
+use RegularLabs\Library\Article as RL_Article;
+use RegularLabs\Library\Cache as RL_Cache;
+use RegularLabs\Library\Document as RL_Document;
+use RegularLabs\Library\Parameters as RL_Parameters;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+class RLHelper
+{
+ public static function getPluginHelper($plugin, $params = null)
+ {
+ if ( ! class_exists('RegularLabs\Library\Cache'))
+ {
+ return null;
+ }
+
+ $hash = md5('getPluginHelper_' . $plugin->get('_type') . '_' . $plugin->get('_name') . '_' . json_encode($params));
+
+ if (RL_Cache::has($hash))
+ {
+ return RL_Cache::get($hash);
+ }
+
+ if ( ! $params)
+ {
+ $params = RL_Parameters::getInstance()->getPluginParams($plugin->get('_name'));
+ }
+
+ $file = JPATH_PLUGINS . '/' . $plugin->get('_type') . '/' . $plugin->get('_name') . '/helper.php';
+
+ if ( ! is_file($file))
+ {
+ return null;
+ }
+
+ require_once $file;
+ $class = get_class($plugin) . 'Helper';
+
+ return RL_Cache::set(
+ $hash,
+ new $class($params)
+ );
+ }
+
+ public static function processArticle(&$article, &$context, &$helper, $method, $params = [])
+ {
+ class_exists('RegularLabs\Library\Article') && RL_Article::process($article, $context, $helper, $method, $params);
+ }
+
+ public static function isCategoryList($context)
+ {
+ return class_exists('RegularLabs\Library\Document') && RL_Document::isCategoryList($context);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/html.php b/deployed/regularlabs/libraries/regularlabs/helpers/html.php
new file mode 100644
index 00000000..c6c19f9a
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/html.php
@@ -0,0 +1,34 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use RegularLabs\Library\Form as RL_Form;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+class RLHtml
+{
+ static function selectlist(&$options, $name, $value, $id, $size = 0, $multiple = 0, $simple = 0)
+ {
+ return RL_Form::selectList($options, $name, $value, $id, $size, $multiple, $simple);
+ }
+
+ static function selectlistsimple(&$options, $name, $value, $id, $size = 0, $multiple = 0)
+ {
+ return RL_Form::selectListSimple($options, $name, $value, $id, $size, $multiple);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/htmlfix.php b/deployed/regularlabs/libraries/regularlabs/helpers/htmlfix.php
new file mode 100644
index 00000000..68a36a53
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/htmlfix.php
@@ -0,0 +1,29 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use RegularLabs\Library\Html as RL_Html;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+class RLHtmlFix
+{
+ public static function _($string)
+ {
+ return RL_Html::fix($string);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/licenses.php b/deployed/regularlabs/libraries/regularlabs/helpers/licenses.php
new file mode 100644
index 00000000..d7d0c497
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/licenses.php
@@ -0,0 +1,29 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use RegularLabs\Library\License as RL_License;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+class RLLicenses
+{
+ public static function render($name, $check_pro = false)
+ {
+ return ! class_exists('RegularLabs\Library\License') ? '' : RL_License::getMessage($name, $check_pro);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/mobile_detect.php b/deployed/regularlabs/libraries/regularlabs/helpers/mobile_detect.php
new file mode 100644
index 00000000..9ecba8e2
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/mobile_detect.php
@@ -0,0 +1,23 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+class RLMobile_Detect extends \RegularLabs\Library\MobileDetect
+{
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/parameters.php b/deployed/regularlabs/libraries/regularlabs/helpers/parameters.php
new file mode 100644
index 00000000..aa61c731
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/parameters.php
@@ -0,0 +1,29 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use RegularLabs\Library\Parameters as RL_Parameters;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+class RLParameters
+{
+ public static function getInstance()
+ {
+ return RL_Parameters::getInstance();
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/protect.php b/deployed/regularlabs/libraries/regularlabs/helpers/protect.php
new file mode 100644
index 00000000..98cce821
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/protect.php
@@ -0,0 +1,195 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use RegularLabs\Library\Document as RL_Document;
+use RegularLabs\Library\Protect as RL_Protect;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+class RLProtect
+{
+ public static function isProtectedPage($extension_alias = '', $hastags = false, $exclude_formats = ['pdf'])
+ {
+ if ( ! class_exists('RegularLabs\Library\Protect'))
+ {
+ return true;
+ }
+
+ if (RL_Protect::isDisabledByUrl($extension_alias))
+ {
+ return true;
+ }
+
+ return class_exists('RegularLabs\Library\Protect') && RL_Protect::isRestrictedPage($hastags, $exclude_formats);
+ }
+
+ public static function isAdmin($block_login = false)
+ {
+ return class_exists('RegularLabs\Library\Document') && RL_Document::isAdmin($block_login);
+ }
+
+ public static function isEditPage()
+ {
+ return class_exists('RegularLabs\Library\Document') && RL_Document::isEditPage();
+ }
+
+ public static function isRestrictedComponent($restricted_components, $area = 'component')
+ {
+ return class_exists('RegularLabs\Library\Protect') && RL_Protect::isRestrictedComponent($restricted_components, $area);
+ }
+
+ public static function isComponentInstalled($extension_alias)
+ {
+ return class_exists('RegularLabs\Library\Protect') && RL_Protect::isComponentInstalled($extension_alias);
+ }
+
+ public static function isSystemPluginInstalled($extension_alias)
+ {
+ return class_exists('RegularLabs\Library\Protect') && RL_Protect::isSystemPluginInstalled($extension_alias);
+ }
+
+ public static function getFormRegex($regex_format = false)
+ {
+ return class_exists('RegularLabs\Library\Protect') && RL_Protect::getFormRegex($regex_format);
+ }
+
+ public static function protectFields(&$string, $search_strings = [])
+ {
+ class_exists('RegularLabs\Library\Protect') && RL_Protect::protectFields($string, $search_strings);
+ }
+
+ public static function protectScripts(&$string)
+ {
+ class_exists('RegularLabs\Library\Protect') && RL_Protect::protectScripts($string);
+ }
+
+ public static function protectHtmlTags(&$string)
+ {
+ class_exists('RegularLabs\Library\Protect') && RL_Protect::protectHtmlTags($string);
+ }
+
+ public static function protectByRegex(&$string, $regex)
+ {
+ class_exists('RegularLabs\Library\Protect') && RL_Protect::protectByRegex($string, $regex);
+ }
+
+ public static function protectTags(&$string, $tags = [], $include_closing_tags = true)
+ {
+ class_exists('RegularLabs\Library\Protect') && RL_Protect::protectTags($string, $tags, $include_closing_tags);
+ }
+
+ public static function unprotectTags(&$string, $tags = [], $include_closing_tags = true)
+ {
+ class_exists('RegularLabs\Library\Protect') && RL_Protect::unprotectTags($string, $tags, $include_closing_tags);
+ }
+
+ public static function protectInString(&$string, $unprotected = [], $protected = [])
+ {
+ class_exists('RegularLabs\Library\Protect') && RL_Protect::protectInString($string, $unprotected, $protected);
+ }
+
+ public static function unprotectInString(&$string, $unprotected = [], $protected = [])
+ {
+ class_exists('RegularLabs\Library\Protect') && RL_Protect::unprotectInString($string, $unprotected, $protected);
+ }
+
+ public static function protectSourcerer(&$string)
+ {
+ class_exists('RegularLabs\Library\Protect') && RL_Protect::protectSourcerer($string);
+ }
+
+ public static function protectForm(&$string, $tags = [], $include_closing_tags = true)
+ {
+ class_exists('RegularLabs\Library\Protect') && RL_Protect::protectForm($string, $tags, $include_closing_tags);
+ }
+
+ public static function unprotect(&$string)
+ {
+ class_exists('RegularLabs\Library\Protect') && RL_Protect::unprotect($string);
+ }
+
+ public static function convertProtectionToHtmlSafe(&$string)
+ {
+ class_exists('RegularLabs\Library\Protect') && RL_Protect::convertProtectionToHtmlSafe($string);
+ }
+
+ public static function unprotectHtmlSafe(&$string)
+ {
+ class_exists('RegularLabs\Library\Protect') && RL_Protect::unprotectHtmlSafe($string);
+ }
+
+ public static function protectString($string, $is_tag = false)
+ {
+ return class_exists('RegularLabs\Library\Protect') && RL_Protect::protectString($string, $is_tag);
+ }
+
+ public static function unprotectString($string, $is_tag = false)
+ {
+ return class_exists('RegularLabs\Library\Protect') && RL_Protect::unprotectString($string, $is_tag);
+ }
+
+ public static function protectTag($string)
+ {
+ return class_exists('RegularLabs\Library\Protect') && RL_Protect::protectTag($string);
+ }
+
+ public static function protectArray($array, $is_tag = false)
+ {
+ return class_exists('RegularLabs\Library\Protect') && RL_Protect::protectArray($array, $is_tag);
+ }
+
+ public static function unprotectArray($array, $is_tag = false)
+ {
+ return class_exists('RegularLabs\Library\Protect') && RL_Protect::unprotectArray($array, $is_tag);
+ }
+
+ public static function unprotectForm(&$string, $tags = [])
+ {
+ class_exists('RegularLabs\Library\Protect') && RL_Protect::unprotectForm($string, $tags);
+ }
+
+ public static function removeInlineComments(&$string, $name)
+ {
+ class_exists('RegularLabs\Library\Protect') && RL_Protect::removeInlineComments($string, $name);
+ }
+
+ public static function removePluginTags(&$string, $tags, $character_start = '{', $character_end = '{', $keep_content = true)
+ {
+ class_exists('RegularLabs\Library\Protect') && RL_Protect::removePluginTags($string, $tags, $character_start, $character_end, $keep_content);
+ }
+
+ public static function removeFromHtmlTagContent(&$string, $tags, $include_closing_tags = true, $html_tags = ['title'])
+ {
+ class_exists('RegularLabs\Library\Protect') && RL_Protect::removeFromHtmlTagContent($string, $tags, $include_closing_tags, $html_tags);
+ }
+
+ public static function removeFromHtmlTagAttributes(&$string, $tags, $attributes = 'ALL', $include_closing_tags = true)
+ {
+ class_exists('RegularLabs\Library\Protect') && RL_Protect::removeFromHtmlTagAttributes($string, $tags, $attributes, $include_closing_tags);
+ }
+
+ public static function articlePassesSecurity(&$article, $securtiy_levels = [])
+ {
+ return class_exists('RegularLabs\Library\Protect') && RL_Protect::articlePassesSecurity($article, $securtiy_levels);
+ }
+
+ public static function isJoomla3()
+ {
+ return true;
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/search.php b/deployed/regularlabs/libraries/regularlabs/helpers/search.php
new file mode 100644
index 00000000..40346bb9
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/search.php
@@ -0,0 +1,290 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/**
+ * BASE ON JOOMLA CORE FILE:
+ * /components/com_search/models/search.php
+ */
+
+/**
+ * @package Joomla.Site
+ * @subpackage com_search
+ *
+ * @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Factory as JFactory;
+use Joomla\CMS\MVC\Model\BaseDatabaseModel as JModel;
+use Joomla\CMS\Pagination\Pagination as JPagination;
+use Joomla\CMS\Plugin\PluginHelper as JPluginHelper;
+
+/**
+ * Search Component Search Model
+ *
+ * @since 1.5
+ */
+class SearchModelSearch extends JModel
+{
+ /**
+ * Search data array
+ *
+ * @var array
+ */
+ protected $_data = null;
+
+ /**
+ * Search total
+ *
+ * @var integer
+ */
+ protected $_total = null;
+
+ /**
+ * Search areas
+ *
+ * @var integer
+ */
+ protected $_areas = null;
+
+ /**
+ * Pagination object
+ *
+ * @var object
+ */
+ protected $_pagination = null;
+
+ /**
+ * Constructor
+ *
+ * @since 1.5
+ */
+ public function __construct()
+ {
+ parent::__construct();
+
+ // Get configuration
+ $app = JFactory::getApplication();
+ $config = JFactory::getConfig();
+
+ // Get the pagination request variables
+ $this->setState('limit', $app->getUserStateFromRequest('com_search.limit', 'limit', $config->get('list_limit'), 'uint'));
+ $this->setState('limitstart', $app->input->get('limitstart', 0, 'uint'));
+
+ // Get parameters.
+ $params = $app->getParams();
+
+ if ($params->get('searchphrase') == 1)
+ {
+ $searchphrase = 'any';
+ }
+ elseif ($params->get('searchphrase') == 2)
+ {
+ $searchphrase = 'exact';
+ }
+ else
+ {
+ $searchphrase = 'all';
+ }
+
+ // Set the search parameters
+ $keyword = urldecode($app->input->getString('searchword'));
+ $match = $app->input->get('searchphrase', $searchphrase, 'word');
+ $ordering = $app->input->get('ordering', $params->get('ordering', 'newest'), 'word');
+ $this->setSearch($keyword, $match, $ordering);
+
+ // Set the search areas
+ $areas = $app->input->get('areas', null, 'array');
+ $this->setAreas($areas);
+ }
+
+ /**
+ * Method to set the search parameters
+ *
+ * @param string $keyword string search string
+ * @param string $match matching option, exact|any|all
+ * @param string $ordering option, newest|oldest|popular|alpha|category
+ *
+ * @return void
+ *
+ * @access public
+ */
+ public function setSearch($keyword, $match = 'all', $ordering = 'newest')
+ {
+ if (isset($keyword))
+ {
+ $this->setState('origkeyword', $keyword);
+
+ if ($match !== 'exact')
+ {
+ $keyword = preg_replace('#\xE3\x80\x80#s', ' ', $keyword);
+ }
+
+ $this->setState('keyword', $keyword);
+ }
+
+ if (isset($match))
+ {
+ $this->setState('match', $match);
+ }
+
+ if (isset($ordering))
+ {
+ $this->setState('ordering', $ordering);
+ }
+ }
+
+ /**
+ * Method to get weblink item data for the category
+ *
+ * @access public
+ * @return array
+ */
+ public function getData()
+ {
+ // Lets load the content if it doesn't already exist
+ if (empty($this->_data))
+ {
+ $areas = $this->getAreas();
+
+ JPluginHelper::importPlugin('search');
+ $dispatcher = JEventDispatcher::getInstance();
+ $results = $dispatcher->trigger('onContentSearch', [
+ $this->getState('keyword'),
+ $this->getState('match'),
+ $this->getState('ordering'),
+ $areas['active'],
+ ]
+ );
+
+ $rows = [];
+
+ foreach ($results as $result)
+ {
+ $rows = array_merge((array) $rows, (array) $result);
+ }
+
+ $this->_total = count($rows);
+
+ if ($this->getState('limit') > 0)
+ {
+ $this->_data = array_splice($rows, $this->getState('limitstart'), $this->getState('limit'));
+ }
+ else
+ {
+ $this->_data = $rows;
+ }
+
+ /* >>> ADDED: Run content plugins over results */
+ $params = JFactory::getApplication()->getParams('com_content');
+ $params->set('rl_search', 1);
+ foreach ($this->_data as $item)
+ {
+ if (empty($item->text))
+ {
+ continue;
+ }
+
+ $dispatcher->trigger('onContentPrepare', ['com_search.search.article', &$item, &$params, 0]);
+
+ if (empty($item->title))
+ {
+ continue;
+ }
+
+ // strip html tags from title
+ $item->title = strip_tags($item->title);
+ }
+ /* <<< */
+ }
+
+ return $this->_data;
+ }
+
+ /**
+ * Method to get the total number of weblink items for the category
+ *
+ * @access public
+ *
+ * @return integer
+ */
+ public function getTotal()
+ {
+ return $this->_total;
+ }
+
+ /**
+ * Method to set the search areas
+ *
+ * @param array $active areas
+ * @param array $search areas
+ *
+ * @return void
+ *
+ * @access public
+ */
+ public function setAreas($active = [], $search = [])
+ {
+ $this->_areas['active'] = $active;
+ $this->_areas['search'] = $search;
+ }
+
+ /**
+ * Method to get a pagination object of the weblink items for the category
+ *
+ * @access public
+ * @return integer
+ */
+ public function getPagination()
+ {
+ // Lets load the content if it doesn't already exist
+ if (empty($this->_pagination))
+ {
+ $this->_pagination = new JPagination($this->getTotal(), $this->getState('limitstart'), $this->getState('limit'));
+ }
+
+ return $this->_pagination;
+ }
+
+ /**
+ * Method to get the search areas
+ *
+ * @return int
+ *
+ * @since 1.5
+ */
+ public function getAreas()
+ {
+ // Load the Category data
+ if (empty($this->_areas['search']))
+ {
+ $areas = [];
+
+ JPluginHelper::importPlugin('search');
+ $dispatcher = JEventDispatcher::getInstance();
+ $searchareas = $dispatcher->trigger('onContentSearchAreas');
+
+ foreach ($searchareas as $area)
+ {
+ if (is_array($area))
+ {
+ $areas = array_merge($areas, $area);
+ }
+ }
+
+ $this->_areas['search'] = $areas;
+ }
+
+ return $this->_areas;
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/string.php b/deployed/regularlabs/libraries/regularlabs/helpers/string.php
new file mode 100644
index 00000000..66f483c6
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/string.php
@@ -0,0 +1,20 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+jimport('joomla.string.string');
+
+abstract class RLString extends JString
+{
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/tags.php b/deployed/regularlabs/libraries/regularlabs/helpers/tags.php
new file mode 100644
index 00000000..34d7741f
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/tags.php
@@ -0,0 +1,199 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use RegularLabs\Library\Html as RL_Html;
+use RegularLabs\Library\PluginTag as RL_PluginTag;
+use RegularLabs\Library\RegEx as RL_RegEx;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+class RLTags
+{
+ static $protected_characters = [
+ '=' => '[[:EQUAL:]]',
+ '"' => '[[:QUOTE:]]',
+ ',' => '[[:COMMA:]]',
+ '|' => '[[:BAR:]]',
+ ':' => '[[:COLON:]]',
+ ];
+
+ public static function getValuesFromString($string = '', $main_key = 'title', $known_boolean_keys = [], $keep_escaped = [','])
+ {
+ return RL_PluginTag::getAttributesFromString($string, $main_key, $known_boolean_keys, $keep_escaped);
+ }
+
+ public static function protectSpecialChars(&$string)
+ {
+ RL_PluginTag::protectSpecialChars($string);
+ }
+
+ public static function unprotectSpecialChars(&$string, $keep_escaped_chars = [])
+ {
+ RL_PluginTag::unprotectSpecialChars($string, $keep_escaped_chars);
+ }
+
+ public static function replaceKeyAliases(&$values, $key_aliases = [], $handle_plurals = false)
+ {
+ RL_PluginTag::replaceKeyAliases($values, $key_aliases, $handle_plurals);
+ }
+
+ public static function convertOldSyntax(&$values, $known_boolean_keys = [], $extra_key = 'class')
+ {
+ RL_PluginTag::convertOldSyntax($values, $known_boolean_keys, $extra_key);
+ }
+
+ public static function getRegexSpaces($modifier = '+')
+ {
+ return RL_PluginTag::getRegexSpaces($modifier);
+ }
+
+ public static function getRegexInsideTag()
+ {
+ return RL_PluginTag::getRegexInsideTag();
+ }
+
+ public static function getRegexSurroundingTagPre($elements = ['p', 'span'])
+ {
+ return RL_PluginTag::getRegexSurroundingTagPre($elements);
+ }
+
+ public static function getRegexSurroundingTagPost($elements = ['p', 'span'])
+ {
+ return RL_PluginTag::getRegexSurroundingTagPost($elements);
+ }
+
+ public static function getRegexTags($tags, $include_no_attributes = true, $include_ending = true, $required_attributes = [])
+ {
+ return RL_PluginTag::getRegexTags($tags, $include_no_attributes, $include_ending, $required_attributes);
+ }
+
+ public static function fixBrokenHtmlTags($string)
+ {
+ return RL_Html::fix($string);
+ }
+
+ public static function cleanSurroundingTags($tags, $elements = ['p', 'span'])
+ {
+ return RL_Html::cleanSurroundingTags($tags, $elements);
+ }
+
+ public static function fixSurroundingTags($tags)
+ {
+ return RL_Html::fixArray($tags);
+ }
+
+ public static function removeEmptyHtmlTagPairs($string, $elements = ['p', 'span'])
+ {
+ return RL_Html::removeEmptyTagPairs($string, $elements);
+ }
+
+ public static function getDivTags($start_tag = '', $end_tag = '', $tag_start = '{', $tag_end = '}')
+ {
+ $tag_start = RL_RegEx::unquote($tag_start);
+ $tag_end = RL_RegEx::unquote($tag_end);
+
+ return RL_PluginTag::getDivTags($start_tag, $end_tag, $tag_start, $tag_end);
+ }
+
+ public static function getTagValues($string = '', $keys = ['title'], $separator = '|', $equal = '=', $limit = 0)
+ {
+ return RL_PluginTag::getAttributesFromStringOld($string, $keys, $separator, $equal, $limit);
+ }
+
+ /* @Deprecated */
+
+ public static function setSurroundingTags($pre, $post, $tags = 0)
+ {
+ if ($tags == 0)
+ {
+ // tags that have a matching ending tag
+ $tags = [
+ 'div', 'p', 'span', 'pre', 'a',
+ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
+ 'strong', 'b', 'em', 'i', 'u', 'big', 'small', 'font',
+ // html 5 stuff
+ 'header', 'nav', 'section', 'article', 'aside', 'footer',
+ 'figure', 'figcaption', 'details', 'summary', 'mark', 'time',
+ ];
+ }
+
+ $a = explode('<', $pre);
+ $b = explode('', $post);
+
+ if (count($b) < 2 || count($a) < 2)
+ {
+ return [trim($pre), trim($post)];
+ }
+
+ $a = array_reverse($a);
+ $a_pre = array_pop($a);
+ $b_pre = array_shift($b);
+ $a_tags = $a;
+
+ foreach ($a_tags as $i => $a_tag)
+ {
+ $a[$i] = '<' . trim($a_tag);
+ $a_tags[$i] = RL_RegEx::replace('^([a-z0-9]+).*$', '\1', trim($a_tag));
+ }
+
+ $b_tags = $b;
+
+ foreach ($b_tags as $i => $b_tag)
+ {
+ $b[$i] = '' . trim($b_tag);
+ $b_tags[$i] = RL_RegEx::replace('^([a-z0-9]+).*$', '\1', trim($b_tag));
+ }
+
+ foreach ($b_tags as $i => $b_tag)
+ {
+ if (empty($b_tag) || ! in_array($b_tag, $tags))
+ {
+ continue;
+ }
+
+ foreach ($a_tags as $j => $a_tag)
+ {
+ if ($b_tag != $a_tag)
+ {
+ continue;
+ }
+
+ $a_tags[$i] = '';
+ $b[$i] = trim(RL_RegEx::replace('^' . $b_tag . '.*?>', '', $b[$i]));
+ $a[$j] = trim(RL_RegEx::replace('^<' . $a_tag . '.*?>', '', $a[$j]));
+ break;
+ }
+ }
+
+ foreach ($a_tags as $i => $tag)
+ {
+ if (empty($tag) || ! in_array($tag, $tags))
+ {
+ continue;
+ }
+
+ array_unshift($b, trim($a[$i]));
+ $a[$i] = '';
+ }
+
+ $a = array_reverse($a);
+ list($pre, $post) = [implode('', $a), implode('', $b)];
+
+ return [trim($pre), trim($post)];
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/text.php b/deployed/regularlabs/libraries/regularlabs/helpers/text.php
new file mode 100644
index 00000000..57cf1670
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/text.php
@@ -0,0 +1,195 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use RegularLabs\Library\Alias as RL_Alias;
+use RegularLabs\Library\ArrayHelper as RL_Array;
+use RegularLabs\Library\Date as RL_Date;
+use RegularLabs\Library\Form as RL_Form;
+use RegularLabs\Library\Html as RL_Html;
+use RegularLabs\Library\HtmlTag as RL_HtmlTag;
+use RegularLabs\Library\PluginTag as RL_PluginTag;
+use RegularLabs\Library\RegEx as RL_RegEx;
+use RegularLabs\Library\StringHelper as RL_String;
+use RegularLabs\Library\Title as RL_Title;
+use RegularLabs\Library\Uri as RL_Uri;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+class RLText
+{
+ /* Date functions */
+
+ public static function fixDate(&$date)
+ {
+ $date = RL_Date::fix($date);
+ }
+
+ public static function fixDateOffset(&$date)
+ {
+ RL_Date::applyTimezone($date);
+ }
+
+ public static function dateToDateFormat($dateFormat)
+ {
+ return RL_Date::strftimeToDateFormat($dateFormat);
+ }
+
+ public static function dateToStrftimeFormat($dateFormat)
+ {
+ return RL_Date::dateToStrftimeFormat($dateFormat);
+ }
+
+ /* String functions */
+
+ public static function html_entity_decoder($string, $quote_style = ENT_QUOTES, $charset = 'UTF-8')
+ {
+ return RL_String::html_entity_decoder($string, $quote_style, $charset);
+ }
+
+ public static function stringContains($haystacks, $needles)
+ {
+ return RL_String::contains($haystacks, $needles);
+ }
+
+ public static function is_alphanumeric($string)
+ {
+ return RL_String::is_alphanumeric($string);
+ }
+
+ public static function splitString($string, $delimiters = [], $max_length = 10000, $maximize_parts = true)
+ {
+ return RL_String::split($string, $delimiters, $max_length, $maximize_parts);
+ }
+
+ public static function strReplaceOnce($search, $replace, $string)
+ {
+ return RL_String::replaceOnce($search, $replace, $string);
+ }
+
+ /* Array functions */
+
+ public static function toArray($data, $separator = '')
+ {
+ return RL_Array::toArray($data, $separator);
+ }
+
+ public static function createArray($data, $separator = ',')
+ {
+ return RL_Array::toArray($data, $separator, true);
+ }
+
+ /* RegEx functions */
+
+ public static function regexReplace($pattern, $replacement, $string)
+ {
+ return RL_RegEx::replace($pattern, $replacement, $string);
+ }
+
+ public static function pregQuote($string = '', $delimiter = '#')
+ {
+ return RL_RegEx::quote($string, $delimiter);
+ }
+
+ public static function pregQuoteArray($array = [], $delimiter = '#')
+ {
+ return RL_RegEx::quoteArray($array, $delimiter);
+ }
+
+ /* Title functions */
+
+ public static function cleanTitle($string, $strip_tags = false, $strip_spaces = true)
+ {
+ return RL_Title::clean($string, $strip_tags, $strip_spaces);
+ }
+
+ public static function createUrlMatches($titles = [])
+ {
+ return RL_Title::getUrlMatches($titles);
+ }
+
+ /* Alias functions */
+
+ public static function createAlias($string)
+ {
+ return RL_Alias::get($string);
+ }
+
+ /* Uri functions */
+
+ public static function getURI($hash = '')
+ {
+ return RL_Uri::get($hash);
+ }
+
+ /* Plugin Tag functions */
+
+ public static function getTagRegex($tags, $include_no_attributes = true, $include_ending = true, $required_attributes = [])
+ {
+ return RL_PluginTag::getRegexTags($tags, $include_no_attributes, $include_ending, $required_attributes);
+ }
+
+ /* HTML functions */
+ public static function getBody($html)
+ {
+ return RL_Html::getBody($html);
+ }
+
+ public static function getContentContainingSearches($string, $start_searches = [], $end_searches = [], $start_offset = 1000, $end_offset = null)
+ {
+ return RL_Html::getContentContainingSearches($string, $start_searches, $end_searches, $start_offset, $end_offset);
+ }
+
+ public static function convertWysiwygToPlainText($string)
+ {
+ return RL_Html::convertWysiwygToPlainText($string);
+ }
+
+ public static function combinePTags(&$string)
+ {
+ RL_Html::combinePTags($string);
+ }
+
+ /* HTML Tag functions */
+
+ public static function combineTags($tag1, $tag2)
+ {
+ return RL_HtmlTag::combine($tag1, $tag2);
+ }
+
+ public static function getAttribute($key, $string)
+ {
+ return RL_HtmlTag::getAttributeValue($key, $string);
+ }
+
+ public static function getAttributes($string)
+ {
+ return RL_HtmlTag::getAttributes($string);
+ }
+
+ public static function combineAttributes($string1, $string2)
+ {
+ return RL_HtmlTag::combineAttributes($string1, $string2);
+ }
+
+ /* Form functions */
+
+ public static function prepareSelectItem($string, $published = 1, $type = '', $remove_first = 0)
+ {
+ return RL_Form::prepareSelectItem($string, $published, $type, $remove_first);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/helpers/versions.php b/deployed/regularlabs/libraries/regularlabs/helpers/versions.php
new file mode 100644
index 00000000..d0384891
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/helpers/versions.php
@@ -0,0 +1,44 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+/* @DEPRECATED */
+
+defined('_JEXEC') or die;
+
+use RegularLabs\Library\Version as RL_Version;
+
+if (is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
+{
+ require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
+}
+
+class RLVersions
+{
+ public static function getXMLVersion($alias, $urlformat = false, $type = 'component', $folder = 'system')
+ {
+ return ! class_exists('RegularLabs\Library\Version') ? '' : RL_Version::get($alias, $type, $folder);
+ }
+
+ public static function getPluginXMLVersion($alias, $folder = 'system')
+ {
+ return ! class_exists('RegularLabs\Library\Version') ? '' : RL_Version::getPluginVersion($alias, $folder);
+ }
+
+ public static function render($alias)
+ {
+ return ! class_exists('RegularLabs\Library\Version') ? '' : RL_Version::getMessage($alias);
+ }
+
+ public static function getFooter($name, $copyright = 1)
+ {
+ return ! class_exists('RegularLabs\Library\Version') ? '' : RL_Version::getFooter($name, $copyright);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/regularlabs.xml b/deployed/regularlabs/libraries/regularlabs/regularlabs.xml
new file mode 100644
index 00000000..9e14f862
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/regularlabs.xml
@@ -0,0 +1,33 @@
+
+
+ Regular Labs Library
+ regularlabs
+
+ 18.12.3953
+ December 2018
+ Regular Labs (Peter van Westen)
+ info@regularlabs.com
+ https://www.regularlabs.com
+ Copyright © 2018 Regular Labs - All Rights Reserved
+ http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+
+ script.install.php
+
+
+ vendor
+ src
+ autoload.php
+ regularlabs.xml
+ fields
+ helpers
+ script.install.helper.php
+
+
+
+ css
+ fonts
+ images
+ js
+ less
+
+
diff --git a/deployed/regularlabs/libraries/regularlabs/script.install.helper.php b/deployed/regularlabs/libraries/regularlabs/script.install.helper.php
new file mode 100644
index 00000000..084b4966
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/script.install.helper.php
@@ -0,0 +1,878 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+defined('_JEXEC') or die;
+
+class RegularLabsInstallerScriptHelper
+{
+ public $name = '';
+ public $alias = '';
+ public $extname = '';
+ public $extension_type = '';
+ public $plugin_folder = 'system';
+ public $module_position = 'status';
+ public $client_id = 1;
+ public $install_type = 'install';
+ public $show_message = true;
+ public $db = null;
+ public $softbreak = null;
+ public $installed_version = '';
+
+ public function __construct(&$params)
+ {
+ $this->extname = $this->extname ?: $this->alias;
+ $this->db = JFactory::getDbo();
+ }
+
+ public function preflight($route, JAdapterInstance $adapter)
+ {
+ if ( ! in_array($route, ['install', 'update']))
+ {
+ return true;
+ }
+
+ JFactory::getLanguage()->load('plg_system_regularlabsinstaller', JPATH_PLUGINS . '/system/regularlabsinstaller');
+
+ $this->installed_version = $this->getVersion($this->getInstalledXMLFile());
+
+ if ($this->show_message && $this->isInstalled())
+ {
+ $this->install_type = 'update';
+ }
+
+ if ($this->onBeforeInstall($route) === false)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public function postflight($route, JAdapterInstance $adapter)
+ {
+ $this->removeGlobalLanguageFiles();
+ $this->removeUnusedLanguageFiles();
+
+ JFactory::getLanguage()->load($this->getPrefix() . '_' . $this->extname, $this->getMainFolder());
+
+ if ( ! in_array($route, ['install', 'update']))
+ {
+ return true;
+ }
+
+ $this->fixExtensionNames();
+ $this->updateUpdateSites();
+ $this->removeAdminCache();
+
+ if ($this->onAfterInstall($route) === false)
+ {
+ return false;
+ }
+
+ if ($route == 'install')
+ {
+ $this->publishExtension();
+ }
+
+ if ($this->show_message)
+ {
+ $this->addInstalledMessage();
+ }
+
+ JFactory::getCache()->clean('com_plugins');
+ JFactory::getCache()->clean('_system');
+
+ return true;
+ }
+
+ public function isInstalled()
+ {
+ if ( ! is_file($this->getInstalledXMLFile()))
+ {
+ return false;
+ }
+
+ $query = $this->db->getQuery(true)
+ ->select($this->db->quoteName('extension_id'))
+ ->from('#__extensions')
+ ->where($this->db->quoteName('type') . ' = ' . $this->db->quote($this->extension_type))
+ ->where($this->db->quoteName('element') . ' = ' . $this->db->quote($this->getElementName()));
+ $this->db->setQuery($query, 0, 1);
+ $result = $this->db->loadResult();
+
+ return empty($result) ? false : true;
+ }
+
+ public function getMainFolder()
+ {
+ switch ($this->extension_type)
+ {
+ case 'plugin' :
+ return JPATH_PLUGINS . '/' . $this->plugin_folder . '/' . $this->extname;
+
+ case 'component' :
+ return JPATH_ADMINISTRATOR . '/components/com_' . $this->extname;
+
+ case 'module' :
+ return JPATH_ADMINISTRATOR . '/modules/mod_' . $this->extname;
+
+ case 'library' :
+ return JPATH_SITE . '/libraries/' . $this->extname;
+ }
+ }
+
+ public function getInstalledXMLFile()
+ {
+ return $this->getXMLFile($this->getMainFolder());
+ }
+
+ public function getCurrentXMLFile()
+ {
+ return $this->getXMLFile(__DIR__);
+ }
+
+ public function getXMLFile($folder)
+ {
+ switch ($this->extension_type)
+ {
+ case 'module' :
+ return $folder . '/mod_' . $this->extname . '.xml';
+
+ default :
+ return $folder . '/' . $this->extname . '.xml';
+ }
+ }
+
+ public function uninstallExtension($extname, $type = 'plugin', $folder = 'system', $show_message = true)
+ {
+ if (empty($extname))
+ {
+ return;
+ }
+
+ $folders = [];
+
+ switch ($type)
+ {
+ case 'plugin';
+ $folders[] = JPATH_PLUGINS . '/' . $folder . '/' . $extname;
+ break;
+
+ case 'component':
+ $folders[] = JPATH_ADMINISTRATOR . '/components/com_' . $extname;
+ $folders[] = JPATH_SITE . '/components/com_' . $extname;
+ break;
+
+ case 'module':
+ $folders[] = JPATH_ADMINISTRATOR . '/modules/mod_' . $extname;
+ $folders[] = JPATH_SITE . '/modules/mod_' . $extname;
+ break;
+ }
+
+ if ( ! $this->foldersExist($folders))
+ {
+ return;
+ }
+
+ $query = $this->db->getQuery(true)
+ ->select($this->db->quoteName('extension_id'))
+ ->from('#__extensions')
+ ->where($this->db->quoteName('element') . ' = ' . $this->db->quote($this->getElementName($type, $extname)))
+ ->where($this->db->quoteName('type') . ' = ' . $this->db->quote($type));
+
+ if ($type == 'plugin')
+ {
+ $query->where($this->db->quoteName('folder') . ' = ' . $this->db->quote($folder));
+ }
+
+ $this->db->setQuery($query);
+ $ids = $this->db->loadColumn();
+
+ if (empty($ids))
+ {
+ foreach ($folders as $folder)
+ {
+ JFactory::getApplication()->enqueueMessage('2. Deleting: ' . $folder, 'notice');
+ JFolder::delete($folder);
+ }
+
+ return;
+ }
+
+ $ignore_ids = JFactory::getApplication()->getUserState('rl_ignore_uninstall_ids', []);
+
+ if (JFactory::getApplication()->input->get('option') == 'com_installer' && JFactory::getApplication()->input->get('task') == 'remove')
+ {
+ // Don't attempt to uninstall extensions that are already selected to get uninstalled by them selves
+ $ignore_ids = array_merge($ignore_ids, JFactory::getApplication()->input->get('cid', [], 'array'));
+ JFactory::getApplication()->input->set('cid', array_merge($ignore_ids, $ids));
+ }
+
+ $ids = array_diff($ids, $ignore_ids);
+
+ if (empty($ids))
+ {
+ return;
+ }
+
+ $ignore_ids = array_merge($ignore_ids, $ids);
+ JFactory::getApplication()->setUserState('rl_ignore_uninstall_ids', $ignore_ids);
+
+ foreach ($ids as $id)
+ {
+ $tmpInstaller = new JInstaller;
+ $tmpInstaller->uninstall($type, $id);
+ }
+
+ if ($show_message)
+ {
+ JFactory::getApplication()->enqueueMessage(
+ JText::sprintf(
+ 'COM_INSTALLER_UNINSTALL_SUCCESS',
+ JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($type))
+ )
+ );
+ }
+ }
+
+ public function foldersExist($folders = [])
+ {
+ foreach ($folders as $folder)
+ {
+ if (is_dir($folder))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public function uninstallPlugin($extname, $folder = 'system', $show_message = true)
+ {
+ $this->uninstallExtension($extname, 'plugin', $folder, $show_message);
+ }
+
+ public function uninstallComponent($extname, $show_message = true)
+ {
+ $this->uninstallExtension($extname, 'component', null, $show_message);
+ }
+
+ public function uninstallModule($extname, $show_message = true)
+ {
+ $this->uninstallExtension($extname, 'module', null, $show_message);
+ }
+
+ public function publishExtension()
+ {
+ switch ($this->extension_type)
+ {
+ case 'plugin' :
+ $this->publishPlugin();
+
+ case 'module' :
+ $this->publishModule();
+ }
+ }
+
+ public function publishPlugin()
+ {
+ $query = $this->db->getQuery(true)
+ ->update('#__extensions')
+ ->set($this->db->quoteName('enabled') . ' = 1')
+ ->where($this->db->quoteName('type') . ' = ' . $this->db->quote('plugin'))
+ ->where($this->db->quoteName('element') . ' = ' . $this->db->quote($this->extname))
+ ->where($this->db->quoteName('folder') . ' = ' . $this->db->quote($this->plugin_folder));
+ $this->db->setQuery($query);
+ $this->db->execute();
+ }
+
+ public function publishModule()
+ {
+ // Get module id
+ $query = $this->db->getQuery(true)
+ ->select($this->db->quoteName('id'))
+ ->from('#__modules')
+ ->where($this->db->quoteName('module') . ' = ' . $this->db->quote('mod_' . $this->extname))
+ ->where($this->db->quoteName('client_id') . ' = ' . (int) $this->client_id);
+ $this->db->setQuery($query, 0, 1);
+ $id = $this->db->loadResult();
+
+ if ( ! $id)
+ {
+ return;
+ }
+
+ // check if module is already in the modules_menu table (meaning is is already saved)
+ $query->clear()
+ ->select($this->db->quoteName('moduleid'))
+ ->from('#__modules_menu')
+ ->where($this->db->quoteName('moduleid') . ' = ' . (int) $id);
+ $this->db->setQuery($query, 0, 1);
+ $exists = $this->db->loadResult();
+
+ if ($exists)
+ {
+ return;
+ }
+
+ // Get highest ordering number in position
+ $query->clear()
+ ->select($this->db->quoteName('ordering'))
+ ->from('#__modules')
+ ->where($this->db->quoteName('position') . ' = ' . $this->db->quote($this->module_position))
+ ->where($this->db->quoteName('client_id') . ' = ' . (int) $this->client_id)
+ ->order('ordering DESC');
+ $this->db->setQuery($query, 0, 1);
+ $ordering = $this->db->loadResult();
+ $ordering++;
+
+ // publish module and set ordering number
+ $query->clear()
+ ->update('#__modules')
+ ->set($this->db->quoteName('published') . ' = 1')
+ ->set($this->db->quoteName('ordering') . ' = ' . (int) $ordering)
+ ->set($this->db->quoteName('position') . ' = ' . $this->db->quote($this->module_position))
+ ->where($this->db->quoteName('id') . ' = ' . (int) $id);
+ $this->db->setQuery($query);
+ $this->db->execute();
+
+ // add module to the modules_menu table
+ $query->clear()
+ ->insert('#__modules_menu')
+ ->columns([$this->db->quoteName('moduleid'), $this->db->quoteName('menuid')])
+ ->values((int) $id . ', 0');
+ $this->db->setQuery($query);
+ $this->db->execute();
+ }
+
+ public function addInstalledMessage()
+ {
+ JFactory::getApplication()->enqueueMessage(
+ JText::sprintf(
+ JText::_($this->install_type == 'update' ? 'RLI_THE_EXTENSION_HAS_BEEN_UPDATED_SUCCESSFULLY' : 'RLI_THE_EXTENSION_HAS_BEEN_INSTALLED_SUCCESSFULLY'),
+ '
' . JText::_($this->name) . ' ',
+ '
' . $this->getVersion() . ' ',
+ $this->getFullType()
+ )
+ );
+ }
+
+ public function getPrefix()
+ {
+ switch ($this->extension_type)
+ {
+ case 'plugin';
+ return JText::_('plg_' . strtolower($this->plugin_folder));
+
+ case 'component':
+ return JText::_('com');
+
+ case 'module':
+ return JText::_('mod');
+
+ case 'library':
+ return JText::_('lib');
+
+ default:
+ return $this->extension_type;
+ }
+ }
+
+ public function getElementName($type = null, $extname = null)
+ {
+ $type = is_null($type) ? $this->extension_type : $type;
+ $extname = is_null($extname) ? $this->extname : $extname;
+
+ switch ($type)
+ {
+ case 'component' :
+ return 'com_' . $extname;
+
+ case 'module' :
+ return 'mod_' . $extname;
+
+ case 'plugin' :
+ default:
+ return $extname;
+ }
+ }
+
+ public function getFullType()
+ {
+ return JText::_('RLI_' . strtoupper($this->getPrefix()));
+ }
+
+ public function getVersion($file = '')
+ {
+ $file = $file ?: $this->getCurrentXMLFile();
+
+ if ( ! is_file($file))
+ {
+ return '';
+ }
+
+ $xml = JApplicationHelper::parseXMLInstallFile($file);
+
+ if ( ! $xml || ! isset($xml['version']))
+ {
+ return '';
+ }
+
+ return $xml['version'];
+ }
+
+ public function isNewer()
+ {
+ if ( ! $this->installed_version)
+ {
+ return true;
+ }
+
+ $package_version = $this->getVersion();
+
+ return version_compare($this->installed_version, $package_version, '<=');
+ }
+
+ public function canInstall()
+ {
+ // The extension is not installed yet
+ if ( ! $this->installed_version)
+ {
+ return true;
+ }
+
+ // The free version is installed. So any version is ok to install
+ if (strpos($this->installed_version, 'PRO') === false)
+ {
+ return true;
+ }
+
+ // Current package is a pro version, so all good
+ if (strpos($this->getVersion(), 'PRO') !== false)
+ {
+ return true;
+ }
+
+ JFactory::getLanguage()->load($this->getPrefix() . '_' . $this->extname, __DIR__);
+
+ JFactory::getApplication()->enqueueMessage(JText::_('RLI_ERROR_PRO_TO_FREE'), 'error');
+
+ JFactory::getApplication()->enqueueMessage(
+ html_entity_decode(
+ JText::sprintf(
+ 'RLI_ERROR_UNINSTALL_FIRST',
+ '
',
+ ' ',
+ JText::_($this->name)
+ )
+ ), 'error'
+ );
+
+ return false;
+ }
+
+ /*
+ * Fixes incorrectly formed versions because of issues in old packager
+ */
+ public function fixFileVersions($file)
+ {
+ if (is_array($file))
+ {
+ foreach ($file as $f)
+ {
+ self::fixFileVersions($f);
+ }
+
+ return;
+ }
+
+ if ( ! is_string($file) || ! is_file($file))
+ {
+ return;
+ }
+
+ $contents = file_get_contents($file);
+
+ if (
+ strpos($contents, 'FREEFREE') === false
+ && strpos($contents, 'FREEPRO') === false
+ && strpos($contents, 'PROFREE') === false
+ && strpos($contents, 'PROPRO') === false
+ )
+ {
+ return;
+ }
+
+ $contents = str_replace(
+ ['FREEFREE', 'FREEPRO', 'PROFREE', 'PROPRO'],
+ ['FREE', 'PRO', 'FREE', 'PRO'],
+ $contents
+ );
+
+ JFile::write($file, $contents);
+ }
+
+ public function onBeforeInstall($route)
+ {
+ if ( ! $this->canInstall())
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public function onAfterInstall($route)
+ {
+ }
+
+ public function delete($files = [])
+ {
+ foreach ($files as $file)
+ {
+ if (is_dir($file))
+ {
+ JFolder::delete($file);
+ }
+
+ if (is_file($file))
+ {
+ JFile::delete($file);
+ }
+ }
+ }
+
+ public function fixAssetsRules()
+ {
+ $query = $this->db->getQuery(true)
+ ->select($this->db->quoteName('rules'))
+ ->from('#__assets')
+ ->where($this->db->quoteName('title') . ' = ' . $this->db->quote('com_' . $this->extname));
+ $this->db->setQuery($query, 0, 1);
+ $rules = $this->db->loadResult();
+
+ $rules = json_decode($rules);
+
+ if(empty($rules)) {
+ return;
+ }
+
+ foreach($rules as $key => $value) {
+ if(!empty($value)) {
+ continue;
+ }
+
+ unset($rules->$key);
+ }
+
+ $rules = json_encode($rules);
+
+
+ $query = $this->db->getQuery(true)
+ ->update($this->db->quoteName('#__assets'))
+ ->set($this->db->quoteName('rules') . ' = ' . $this->db->quote($rules))
+ ->where($this->db->quoteName('title') . ' = ' . $this->db->quote('com_' . $this->extname));
+ $this->db->setQuery($query);
+ $this->db->execute();
+ }
+
+ private function fixExtensionNames()
+ {
+ switch ($this->extension_type)
+ {
+ case 'module' :
+ $this->fixModuleNames();
+ }
+ }
+
+ private function fixModuleNames()
+ {
+ // Get module id
+ $query = $this->db->getQuery(true)
+ ->select($this->db->quoteName('id'))
+ ->from('#__modules')
+ ->where($this->db->quoteName('module') . ' = ' . $this->db->quote('mod_' . $this->extname))
+ ->where($this->db->quoteName('client_id') . ' = ' . (int) $this->client_id);
+ $this->db->setQuery($query, 0, 1);
+ $module_id = $this->db->loadResult();
+
+ if (empty($module_id))
+ {
+ return;
+ }
+
+ $title = 'Regular Labs - ' . JText::_($this->name);
+
+ $query->clear()
+ ->update('#__modules')
+ ->set($this->db->quoteName('title') . ' = ' . $this->db->quote($title))
+ ->where($this->db->quoteName('id') . ' = ' . (int) $module_id)
+ ->where($this->db->quoteName('title') . ' LIKE ' . $this->db->quote('NoNumber%'));
+ $this->db->setQuery($query);
+ $this->db->execute();
+
+ // Fix module assets
+
+ // Get asset id
+ $query = $this->db->getQuery(true)
+ ->select($this->db->quoteName('id'))
+ ->from('#__assets')
+ ->where($this->db->quoteName('name') . ' = ' . $this->db->quote('com_modules.module.' . (int) $module_id))
+ ->where($this->db->quoteName('title') . ' LIKE ' . $this->db->quote('NoNumber%'));
+ $this->db->setQuery($query, 0, 1);
+ $asset_id = $this->db->loadResult();
+
+ if (empty($asset_id))
+ {
+ return;
+ }
+
+ $query->clear()
+ ->update('#__assets')
+ ->set($this->db->quoteName('title') . ' = ' . $this->db->quote($title))
+ ->where($this->db->quoteName('id') . ' = ' . (int) $asset_id);
+ $this->db->setQuery($query);
+ $this->db->execute();
+ }
+
+ private function updateUpdateSites()
+ {
+ $this->removeOldUpdateSites();
+ $this->updateNamesInUpdateSites();
+ $this->updateHttptoHttpsInUpdateSites();
+ $this->removeDuplicateUpdateSite();
+ $this->updateDownloadKey();
+ }
+
+ private function removeOldUpdateSites()
+ {
+ $query = $this->db->getQuery(true)
+ ->select($this->db->quoteName('update_site_id'))
+ ->from('#__update_sites')
+ ->where($this->db->quoteName('location') . ' LIKE ' . $this->db->quote('nonumber.nl%'))
+ ->where($this->db->quoteName('location') . ' LIKE ' . $this->db->quote('%e=' . $this->alias . '%'));
+ $this->db->setQuery($query, 0, 1);
+ $id = $this->db->loadResult();
+
+ if ( ! $id)
+ {
+ return;
+ }
+
+ $query->clear()
+ ->delete('#__update_sites')
+ ->where($this->db->quoteName('update_site_id') . ' = ' . (int) $id);
+ $this->db->setQuery($query);
+ $this->db->execute();
+
+ $query->clear()
+ ->delete('#__update_sites_extensions')
+ ->where($this->db->quoteName('update_site_id') . ' = ' . (int) $id);
+ $this->db->setQuery($query);
+ $this->db->execute();
+ }
+
+ private function updateNamesInUpdateSites()
+ {
+ $name = JText::_($this->name);
+ if ($this->alias != 'extensionmanager')
+ {
+ $name = 'Regular Labs - ' . $name;
+ }
+
+ $query = $this->db->getQuery(true)
+ ->update('#__update_sites')
+ ->set($this->db->quoteName('name') . ' = ' . $this->db->quote($name))
+ ->where($this->db->quoteName('location') . ' LIKE ' . $this->db->quote('%download.regularlabs.com%'))
+ ->where($this->db->quoteName('location') . ' LIKE ' . $this->db->quote('%e=' . $this->alias . '%'));
+ $this->db->setQuery($query);
+ $this->db->execute();
+ }
+
+ private function updateHttptoHttpsInUpdateSites()
+ {
+ $query = $this->db->getQuery(true)
+ ->update('#__update_sites')
+ ->set($this->db->quoteName('location') . ' = REPLACE('
+ . $this->db->quoteName('location') . ', '
+ . $this->db->quote('http://') . ', '
+ . $this->db->quote('https://')
+ . ')')
+ ->where($this->db->quoteName('location') . ' LIKE ' . $this->db->quote('http://download.regularlabs.com%'));
+ $this->db->setQuery($query);
+ $this->db->execute();
+ }
+
+ private function removeDuplicateUpdateSite()
+ {
+ // First check to see if there is a pro entry
+
+ $query = $this->db->getQuery(true)
+ ->select($this->db->quoteName('update_site_id'))
+ ->from('#__update_sites')
+ ->where($this->db->quoteName('location') . ' LIKE ' . $this->db->quote('%download.regularlabs.com%'))
+ ->where($this->db->quoteName('location') . ' LIKE ' . $this->db->quote('%e=' . $this->alias . '%'))
+ ->where($this->db->quoteName('location') . ' NOT LIKE ' . $this->db->quote('%pro=1%'));
+ $this->db->setQuery($query, 0, 1);
+ $id = $this->db->loadResult();
+
+ // Otherwise just get the first match
+ if ( ! $id)
+ {
+ $query->clear()
+ ->select($this->db->quoteName('update_site_id'))
+ ->from('#__update_sites')
+ ->where($this->db->quoteName('location') . ' LIKE ' . $this->db->quote('%download.regularlabs.com%'))
+ ->where($this->db->quoteName('location') . ' LIKE ' . $this->db->quote('%e=' . $this->alias . '%'));
+ $this->db->setQuery($query, 0, 1);
+ $id = $this->db->loadResult();
+
+ // Remove pro=1 from the found update site
+ $query->clear()
+ ->update('#__update_sites')
+ ->set($this->db->quoteName('location')
+ . ' = replace(' . $this->db->quoteName('location') . ', ' . $this->db->quote('&pro=1') . ', ' . $this->db->quote('') . ')')
+ ->where($this->db->quoteName('update_site_id') . ' = ' . (int) $id);
+ $this->db->setQuery($query);
+ $this->db->execute();
+ }
+
+ if ( ! $id)
+ {
+ return;
+ }
+
+ $query->clear()
+ ->select($this->db->quoteName('update_site_id'))
+ ->from('#__update_sites')
+ ->where($this->db->quoteName('location') . ' LIKE ' . $this->db->quote('%download.regularlabs.com%'))
+ ->where($this->db->quoteName('location') . ' LIKE ' . $this->db->quote('%e=' . $this->alias . '%'))
+ ->where($this->db->quoteName('update_site_id') . ' != ' . $id);
+ $this->db->setQuery($query);
+ $ids = $this->db->loadColumn();
+
+ if (empty($ids))
+ {
+ return;
+ }
+
+ $query->clear()
+ ->delete('#__update_sites')
+ ->where($this->db->quoteName('update_site_id') . ' IN (' . implode(',', $ids) . ')');
+ $this->db->setQuery($query);
+ $this->db->execute();
+
+ $query->clear()
+ ->delete('#__update_sites_extensions')
+ ->where($this->db->quoteName('update_site_id') . ' IN (' . implode(',', $ids) . ')');
+ $this->db->setQuery($query);
+ $this->db->execute();
+ }
+
+ // Save the download key from the Regular Labs Extension Manager config to the update sites
+ private function updateDownloadKey()
+ {
+ $query = $this->db->getQuery(true)
+ ->select($this->db->quoteName('params'))
+ ->from('#__extensions')
+ ->where($this->db->quoteName('element') . ' = ' . $this->db->quote('com_regularlabsmanager'));
+ $this->db->setQuery($query);
+ $params = $this->db->loadResult();
+
+ if ( ! $params)
+ {
+ return;
+ }
+
+ $params = json_decode($params);
+
+ if ( ! isset($params->key))
+ {
+ return;
+ }
+
+ // Add the key on all regularlabs.com urls
+ $query->clear()
+ ->update('#__update_sites')
+ ->set($this->db->quoteName('extra_query') . ' = ' . $this->db->quote('k=' . $params->key))
+ ->where($this->db->quoteName('location') . ' LIKE ' . $this->db->quote('%download.regularlabs.com%'));
+ $this->db->setQuery($query);
+ $this->db->execute();
+ }
+
+ private function removeAdminCache()
+ {
+ $this->delete([JPATH_ADMINISTRATOR . '/cache/regularlabs']);
+ $this->delete([JPATH_ADMINISTRATOR . '/cache/nonumber']);
+ }
+
+ private function removeGlobalLanguageFiles()
+ {
+ if ($this->extension_type == 'library')
+ {
+ return;
+ }
+
+ $language_files = JFolder::files(JPATH_ADMINISTRATOR . '/language', '\.' . $this->getPrefix() . '_' . $this->extname . '\.', true, true);
+
+ // Remove override files
+ foreach ($language_files as $i => $language_file)
+ {
+ if (strpos($language_file, '/overrides/') === false)
+ {
+ continue;
+ }
+
+ unset($language_files[$i]);
+ }
+
+ if (empty($language_files))
+ {
+ return;
+ }
+
+ JFile::delete($language_files);
+ }
+
+ private function removeUnusedLanguageFiles()
+ {
+ if ($this->extension_type == 'library')
+ {
+ return;
+ }
+
+ $installed_languages = array_merge(
+ JFolder::folders(JPATH_SITE . '/language'),
+ JFolder::folders(JPATH_ADMINISTRATOR . '/language')
+ );
+
+ $languages = array_diff(
+ JFolder::folders(__DIR__ . '/language'),
+ $installed_languages
+ );
+
+ $delete_languages = [];
+
+ foreach ($languages as $language)
+ {
+ $delete_languages[] = $this->getMainFolder() . '/language/' . $language;
+ }
+
+ if (empty($delete_languages))
+ {
+ return;
+ }
+
+ // Remove folders
+ $this->delete($delete_languages);
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/script.install.php b/deployed/regularlabs/libraries/regularlabs/script.install.php
new file mode 100644
index 00000000..64c9fcbc
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/script.install.php
@@ -0,0 +1,36 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+defined('_JEXEC') or die;
+
+if ( ! class_exists('RegularLabsInstallerScript'))
+{
+ require_once __DIR__ . '/script.install.helper.php';
+
+ class RegularLabsInstallerScript extends RegularLabsInstallerScriptHelper
+ {
+ public $name = 'Regular Labs Library';
+ public $alias = 'regularlabs';
+ public $extension_type = 'library';
+
+ public function onBeforeInstall($route)
+ {
+ if ( ! $this->isNewer())
+ {
+ $this->softbreak = true;
+
+ return false;
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/src/ActionLogPlugin.php b/deployed/regularlabs/libraries/regularlabs/src/ActionLogPlugin.php
new file mode 100644
index 00000000..b8cd858d
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/src/ActionLogPlugin.php
@@ -0,0 +1,308 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+namespace RegularLabs\Library;
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Factory as JFactory;
+use Joomla\CMS\Language\Text as JText;
+use Joomla\CMS\Plugin\CMSPlugin as JPlugin;
+use RegularLabs\Library\ArrayHelper as RL_Array;
+use RegularLabs\Library\Extension as RL_Extension;
+use RegularLabs\Library\Log as RL_Log;
+use RegularLabs\Library\Parameters as RL_Parameters;
+
+/**
+ * Class ActionLogPlugin
+ * @package RegularLabs\Library
+ */
+class ActionLogPlugin
+ extends JPlugin
+{
+ public $name = '';
+ public $alias = '';
+ public $option = '';
+ public $items = [];
+ public $table = null;
+ public $events = [];
+
+ static $ids = [];
+
+ public function __construct(&$subject, array $config = [])
+ {
+ parent::__construct($subject, $config);
+
+ Language::load('plg_actionlog_' . $this->alias);
+
+ $config = RL_Parameters::getInstance()->getComponentParams($this->alias);
+
+ $enable_actionlog = isset($config->enable_actionlog) ? $config->enable_actionlog : true;
+ $this->events = $enable_actionlog ? ['*'] : [];
+
+ if ($enable_actionlog && ! empty($config->actionlog_events))
+ {
+ $this->events = RL_Array::toArray($config->actionlog_events);
+ }
+
+ $this->name = JText::_($this->name);
+ $this->option = $this->option ?: 'com_' . $this->alias;
+ }
+
+ public function onContentAfterSave($context, $table, $isNew)
+ {
+ if (strpos($context, $this->option) === false)
+ {
+ return;
+ }
+
+ $event = $isNew ? 'create' : 'update';
+
+ if ( ! RL_Array::find(['*', $event], $this->events))
+ {
+ return;
+ }
+
+ $item = $this->getItem($context);
+
+ $title = isset($table->title) ? $table->title : (isset($table->name) ? $table->name : $table->id);
+ $item_url = str_replace('{id}', $table->id, $item->url);
+
+ $message = [
+ 'type' => $item->title,
+ 'id' => $table->id,
+ 'title' => $title,
+ 'itemlink' => $item_url,
+ ];
+
+ RL_Log::save($message, $context, $isNew);
+ }
+
+ public function onContentAfterDelete($context, $table)
+ {
+ if (strpos($context, $this->option) === false)
+ {
+ return;
+ }
+
+ if ( ! RL_Array::find(['*', 'delete'], $this->events))
+ {
+ return;
+ }
+
+ $item = $this->getItem($context);
+
+ $title = isset($table->title) ? $table->title : (isset($table->name) ? $table->name : $table->id);
+
+ $message = [
+ 'type' => $item->title,
+ 'id' => $table->id,
+ 'title' => $title,
+ ];
+
+ RL_Log::delete($message, $context);
+ }
+
+ public function onContentChangeState($context, $ids, $value)
+ {
+ if (strpos($context, $this->option) === false)
+ {
+ return;
+ }
+
+ if ( ! RL_Array::find(['*', 'change_state'], $this->events))
+ {
+ return;
+ }
+
+ $item = $this->getItem($context);
+
+ if ( ! $this->table)
+ {
+ if ( ! is_file($item->file))
+ {
+ return;
+ }
+
+ require_once $item->file;
+
+ $this->table = (new $item->model)->getTable();
+ }
+
+ foreach ($ids as $id)
+ {
+ $this->table->load($id);
+
+ $title = isset($this->table->title) ? $this->table->title : (isset($this->table->name) ? $this->table->name : $this->table->id);
+ $itemlink = str_replace('{id}', $this->table->id, $item->url);
+
+ $message = [
+ 'type' => $item->title,
+ 'id' => $id,
+ 'title' => $title,
+ 'itemlink' => $itemlink,
+ ];
+
+ RL_Log::changeState($message, $context, $value);
+ }
+ }
+
+ public function onExtensionAfterSave($context, $table, $isNew)
+ {
+ self::onContentAfterSave($context, $table, $isNew);
+ }
+
+ public function onExtensionAfterDelete($context, $table)
+ {
+ self::onContentAfterDelete($context, $table);
+ }
+
+ public function onExtensionAfterInstall($installer, $eid)
+ {
+ // Prevent duplicate logs
+ if (in_array('install_' . $eid, self::$ids))
+ {
+ return;
+ }
+
+ $context = JFactory::getApplication()->input->get('option');
+
+ if (strpos($context, $this->option) === false)
+ {
+ return;
+ }
+
+ if ( ! RL_Array::find(['*', 'install'], $this->events))
+ {
+ return;
+ }
+
+ $extension = RL_Extension::getById($eid);
+
+ if (empty($extension->manifest_cache))
+ {
+ return;
+ }
+
+ $manifest = json_decode($extension->manifest_cache);
+
+ if (empty($manifest->name))
+ {
+ return;
+ }
+
+ self::$ids[] = 'install_' . $eid;
+
+ $message = [
+ 'id' => $eid,
+ 'extension_name' => JText::_($manifest->name),
+ ];
+
+ RL_Log::install($message, 'com_regularlabsmanager', $manifest->type);
+ }
+
+ public function onExtensionAfterUninstall($installer, $eid, $result)
+ {
+ // Prevent duplicate logs
+ if (in_array('uninstall_' . $eid, self::$ids))
+ {
+ return;
+ }
+
+ $context = JFactory::getApplication()->input->get('option');
+
+ if (strpos($context, $this->option) === false)
+ {
+ return;
+ }
+
+ if ( ! RL_Array::find(['*', 'uninstall'], $this->events))
+ {
+ return;
+ }
+
+ if ($result === false)
+ {
+ return;
+ }
+
+ $manifest = $installer->get('manifest');
+
+ if ($manifest === null)
+ {
+ return;
+ }
+
+ self::$ids[] = 'uninstall_' . $eid;
+
+ $message = [
+ 'id' => $eid,
+ 'extension_name' => JText::_($manifest->name),
+ ];
+
+ RL_Log::uninstall($message, 'com_regularlabsmanager', $manifest->attributes()->type);
+ }
+
+ private function getItem($context)
+ {
+ $item = $this->getItemData($context);
+
+ $item->title = isset($item->title)
+ ? JText::_($item->title)
+ : $this->type . ' ' . JText::_('RL_ITEM');
+
+ if ( ! isset($item->file))
+ {
+ $item->file = JPATH_ADMINISTRATOR . '/components/' . $this->option . '/models/' . $item->type . '.php';
+ }
+
+ if ( ! isset($item->model))
+ {
+ $item->model = $this->alias . 'Model' . ucfirst($item->type);
+ }
+
+ if ( ! isset($item->url))
+ {
+ $item->url = 'index.php?option=' . $this->option . '&view=' . $item->type . '&layout=edit&id={id}';
+ }
+
+ return $item;
+ }
+
+ private function getItemData($context)
+ {
+ $default = (object) [
+ 'type' => 'item',
+ ];
+
+ $type = key($this->items) ?: 'item';
+
+ if (strpos($context, '.') !== false)
+ {
+ $parts = explode('.', $context);
+ $type = $parts[1];
+ }
+
+ if ( ! isset($this->items[$type]))
+ {
+ return $default;
+ }
+
+ $item = $this->items[$type];
+
+ if ( ! isset($item->type))
+ {
+ $item->type = $type;
+ }
+
+ return $item;
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/src/Alias.php b/deployed/regularlabs/libraries/regularlabs/src/Alias.php
new file mode 100644
index 00000000..88c1d64e
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/src/Alias.php
@@ -0,0 +1,113 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+namespace RegularLabs\Library;
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Application\ApplicationHelper as JApplicationHelper;
+use Joomla\CMS\Factory as JFactory;
+
+/**
+ * Class Alias
+ * @package RegularLabs\Library
+ */
+class Alias
+{
+ /**
+ * Creates an alias from a string
+ *
+ * @param string $string
+ *
+ * @return string
+ */
+ public static function get($string = '', $unicode = false)
+ {
+ if (empty($string))
+ {
+ return '';
+ }
+
+ $string = StringHelper::removeHtml($string);
+
+ if ($unicode || JFactory::getConfig()->get('unicodeslugs') == 1)
+ {
+ return self::stringURLUnicodeSlug($string);
+ }
+
+ // Remove < > html entities
+ $string = str_replace(['<', '>'], '', $string);
+
+ // Convert html entities
+ $string = StringHelper::html_entity_decoder($string);
+
+ return JApplicationHelper::stringURLSafe($string);
+ }
+
+ /**
+ * Creates a unicode alias from a string
+ * Based on stringURLUnicodeSlug method from the unicode slug plugin by infograf768
+ *
+ * @param string $string
+ *
+ * @return string
+ */
+ private static function stringURLUnicodeSlug($string = '')
+ {
+ if (empty($string))
+ {
+ return '';
+ }
+
+ // Remove < > html entities
+ $string = str_replace(['<', '>'], '', $string);
+
+ // Convert html entities
+ $string = StringHelper::html_entity_decoder($string);
+
+ // Convert to lowercase
+ $string = StringHelper::strtolower($string);
+
+ // remove html tags
+ $string = RegEx::replace('?[a-z][^>]*>', '', $string);
+ // remove comments tags
+ $string = RegEx::replace('<\!--.*?-->', '', $string);
+
+ // Replace weird whitespace characters like (Â) with spaces
+ //$string = str_replace(array(chr(160), chr(194)), ' ', $string);
+ $string = str_replace("\xC2\xA0", ' ', $string);
+ $string = str_replace("\xE2\x80\xA8", ' ', $string); // ascii only
+
+ // Replace double byte whitespaces by single byte (East Asian languages)
+ $string = str_replace("\xE3\x80\x80", ' ', $string);
+
+ // Remove any '-' from the string as they will be used as concatenator.
+ // Would be great to let the spaces in but only Firefox is friendly with this
+ $string = str_replace('-', ' ', $string);
+
+ // Replace forbidden characters by whitespaces
+ $string = RegEx::replace('[' . RegEx::quote(',:#$*"@+=;&.%()[]{}/\'\\|') . ']', "\x20", $string);
+
+ // Delete all characters that should not take up any space, like: ?
+ $string = RegEx::replace('[' . RegEx::quote('?!¿¡') . ']', '', $string);
+
+ // Trim white spaces at beginning and end of alias and make lowercase
+ $string = trim($string);
+
+ // Remove any duplicate whitespace and replace whitespaces by hyphens
+ $string = RegEx::replace('\x20+', '-', $string);
+
+ // Remove leading and trailing hyphens
+ $string = trim($string, '-');
+
+ return $string;
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/src/Api/ConditionInterface.php b/deployed/regularlabs/libraries/regularlabs/src/Api/ConditionInterface.php
new file mode 100644
index 00000000..ecfcb3f9
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/src/Api/ConditionInterface.php
@@ -0,0 +1,23 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+namespace RegularLabs\Library\Api;
+
+defined('_JEXEC') or die;
+
+/**
+ * Interface ConditionConditionInterface
+ * @package RegularLabs\Library\Api
+ */
+interface ConditionInterface
+{
+ public function pass();
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/src/ArrayHelper.php b/deployed/regularlabs/libraries/regularlabs/src/ArrayHelper.php
new file mode 100644
index 00000000..81782dc6
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/src/ArrayHelper.php
@@ -0,0 +1,210 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+namespace RegularLabs\Library;
+
+defined('_JEXEC') or die;
+
+/**
+ * Class ArrayHelper
+ * @package RegularLabs\Library
+ */
+class ArrayHelper
+{
+ /**
+ * Convert data (string or object) to an array
+ *
+ * @param mixed $data
+ * @param string $separator
+ * @param bool $unique
+ *
+ * @return array
+ */
+ public static function toArray($data, $separator = ',', $unique = false, $trim = true)
+ {
+ if (is_array($data))
+ {
+ return $data;
+ }
+
+ if (is_object($data))
+ {
+ return (array) $data;
+ }
+
+ if ($data == '')
+ {
+ return [];
+ }
+
+ if ($separator == '')
+ {
+ return [$data];
+ }
+
+ $array = explode($separator, $data);
+
+ if ($trim)
+ {
+ $array = self::trim($array);
+ }
+
+ if ($unique)
+ {
+ $array = array_unique($array);
+ }
+
+ return $array;
+ }
+
+ /**
+ * Clean array by trimming values and removing empty/false values
+ *
+ * @param array $array
+ *
+ * @return array
+ */
+ public static function clean($array)
+ {
+ if ( ! is_array($array))
+ {
+ return $array;
+ }
+
+ $array = self::trim($array);
+ $array = self::unique($array);
+ $array = self::removeEmpty($array);
+
+ return $array;
+ }
+
+ /**
+ * Removes empty values from the array
+ *
+ * @param array $array
+ *
+ * @return array
+ */
+ public static function removeEmpty($array)
+ {
+ if ( ! is_array($array))
+ {
+ return $array;
+ }
+
+ foreach ($array as $key => &$value)
+ {
+ if ($key && ! is_numeric($key))
+ {
+ continue;
+ }
+
+ if ($value !== '')
+ {
+ continue;
+ }
+
+ unset($array[$key]);
+ }
+
+ return $array;
+ }
+
+ /**
+ * Removes duplicate values from the array
+ *
+ * @param array $array
+ *
+ * @return array
+ */
+ public static function unique($array)
+ {
+ if ( ! is_array($array))
+ {
+ return $array;
+ }
+
+ $values = [];
+
+ foreach ($array as $key => $value)
+ {
+ if ( ! is_numeric($key))
+ {
+ continue;
+ }
+
+ if ( ! in_array($value, $values))
+ {
+ $values[] = $value;
+ continue;
+ }
+
+ unset($array[$key]);
+ }
+
+ return $array;
+ }
+
+ /**
+ * Clean array by trimming values
+ *
+ * @param array $array
+ *
+ * @return array
+ */
+ public static function trim($array)
+ {
+ if ( ! is_array($array))
+ {
+ return $array;
+ }
+
+ foreach ($array as &$value)
+ {
+ if ( ! is_string($value))
+ {
+ continue;
+ }
+
+ $value = trim($value);
+ }
+
+ return $array;
+ }
+
+ /**
+ * Check if any of the given values is found in the array
+ *
+ * @param array $values
+ * @param array $array
+ *
+ * @return boolean
+ */
+ public static function find($values, $array)
+ {
+ if ( ! is_array($array) || empty($array))
+ {
+ return false;
+ }
+
+ $values = self::toArray($values);
+
+ foreach ($values as $value)
+ {
+ if (in_array($value, $array))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/deployed/regularlabs/libraries/regularlabs/src/Article.php b/deployed/regularlabs/libraries/regularlabs/src/Article.php
new file mode 100644
index 00000000..1a54bff7
--- /dev/null
+++ b/deployed/regularlabs/libraries/regularlabs/src/Article.php
@@ -0,0 +1,228 @@
+
+ * @link http://www.regularlabs.com
+ * @copyright Copyright © 2018 Regular Labs All Rights Reserved
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ */
+
+namespace RegularLabs\Library;
+
+defined('_JEXEC') or die;
+
+use Joomla\CMS\Factory as JFactory;
+use Joomla\Registry\Registry;
+
+jimport('joomla.filesystem.file');
+
+/**
+ * Class Article
+ * @package RegularLabs\Library
+ */
+class Article
+{
+ static $articles = [];
+ static $splitter = '[[:SPLIT-ARTICLE:]]';
+
+ /**
+ * Method to get article data.
+ *
+ * @param integer $id The id of the article.
+ *
+ * @return object|boolean Menu item data object on success, boolean false
+ */
+ public static function get($id = null, $get_unpublished = false)
+ {
+ $id = ! empty($id) ? $id : (int) self::getId();
+
+ if (isset(self::$articles[$id]))
+ {
+ return self::$articles[$id];
+ }
+
+ $db = JFactory::getDbo();
+ $user = JFactory::getUser();
+
+ $query = $db->getQuery(true)
+ ->select(
+ [
+ 'a.id', 'a.asset_id', 'a.title', 'a.alias', 'a.introtext', 'a.fulltext',
+ 'a.state', 'a.catid', 'a.created', 'a.created_by', 'a.created_by_alias',
+ // Use created if modified is 0
+ 'CASE WHEN a.modified = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.modified END as modified',
+ 'a.modified_by', 'a.checked_out', 'a.checked_out_time', 'a.publish_up', 'a.publish_down',
+ 'a.images', 'a.urls', 'a.attribs', 'a.version', 'a.ordering',
+ 'a.metakey', 'a.metadesc', 'a.access', 'a.hits', 'a.metadata', 'a.featured', 'a.language', 'a.xreference',
+ ]
+ )
+ ->from($db->quoteName('#__content', 'a'))
+ ->where($db->quoteName('a.id') . ' = ' . (int) $id);
+
+ // Join on category table.
+ $query->select([
+ $db->quoteName('c.title', 'category_title'),
+ $db->quoteName('c.alias', 'category_alias'),
+ $db->quoteName('c.access', 'category_access'),
+ ])
+ ->innerJoin($db->quoteName('#__categories', 'c') . ' ON ' . $db->quoteName('c.id') . ' = ' . $db->quoteName('a.catid'))
+ ->where($db->quoteName('c.published') . ' > 0');
+
+ // Join on user table.
+ $query->select($db->quoteName('u.name', 'author'))
+ ->join('LEFT', $db->quoteName('#__users', 'u') . ' ON ' . $db->quoteName('u.id') . ' = ' . $db->quoteName('a.created_by'));
+
+ // Join over the categories to get parent category titles
+ $query->select([
+ $db->quoteName('parent.title', 'parent_title'),
+ $db->quoteName('parent.id', 'parent_id'),
+ $db->quoteName('parent.path', 'parent_route'),
+ $db->quoteName('parent.alias', 'parent_alias'),
+ ])
+ ->join('LEFT', $db->quoteName('#__categories', 'parent') . ' ON ' . $db->quoteName('parent.id') . ' = ' . $db->quoteName('c.parent_id'));
+
+ // Join on voting table
+ $query->select([
+ 'ROUND(v.rating_sum / v.rating_count, 0) AS rating',
+ $db->quoteName('v.rating_count', 'rating_count'),
+ ])
+ ->join('LEFT', $db->quoteName('#__content_rating', 'v') . ' ON ' . $db->quoteName('v.content_id') . ' = ' . $db->quoteName('a.id'));
+
+ if ( ! $get_unpublished
+ && ( ! $user->authorise('core.edit.state', 'com_content'))
+ && ( ! $user->authorise('core.edit', 'com_content'))
+ )
+ {
+ // Filter by start and end dates.
+ $nullDate = $db->quote($db->getNullDate());
+ $date = JFactory::getDate();
+
+ $nowDate = $db->quote($date->toSql());
+
+ $query->where($db->quoteName('a.state') . ' = 1')
+ ->where('(' . $db->quoteName('a.publish_up') . ' = ' . $nullDate . ' OR ' . $db->quoteName('a.publish_up') . ' <= ' . $nowDate . ')')
+ ->where('(' . $db->quoteName('a.publish_down') . ' = ' . $nullDate . ' OR ' . $db->quoteName('a.publish_down') . ' >= ' . $nowDate . ')');
+ }
+
+ $db->setQuery($query);
+
+ $data = $db->loadObject();
+
+ if (empty($data))
+ {
+ return false;
+ }
+
+ // Convert parameter fields to objects.
+ $data->params = new Registry($data->attribs);
+ $data->metadata = new Registry($data->metadata);
+
+ self::$articles[$id] = $data;
+
+ return self::$articles[$id];
+ }
+
+ /**
+ * Gets the current article id based on url data
+ */
+ public static function getId()
+ {
+ $input = JFactory::getApplication()->input;
+
+ if ( ! $id = $input->getInt('id')
+ || ! (($input->get('option') == 'com_content' && $input->get('view') == 'article')
+ || ($input->get('option') == 'com_flexicontent' && $input->get('view') == 'item')
+ )
+ )
+ {
+ return false;
+ }
+
+ return $id;
+ }
+
+ /**
+ * Passes the different article parts through the given plugin method
+ *
+ * @param object $article
+ * @param string $context
+ * @param object $helper
+ * @param string $method
+ * @param array $params
+ * @param array $ignore
+ */
+ public static function process(&$article, &$context, &$helper, $method, $params = [], $ignore = [])
+ {
+ self::processText('title', $article, $helper, $method, $params, $ignore);
+ self::processText('created_by_alias', $article, $helper, $method, $params, $ignore);
+ self::processText('description', $article, $helper, $method, $params, $ignore);
+
+ // Don't replace in text fields in the category list view, as they won't get used anyway
+ if (Document::isCategoryList($context))
+ {
+ return;
+ }
+
+ // prevent fulltext from being messed with, when it is a json encoded string (Yootheme Pro templates do this for some weird f-ing reason)
+ if ( ! empty($article->fulltext) && substr($article->fulltext, 0, 6) == '\s*)*';
+
+ $string = implode($splitter, $array);
+
+ $string = RegEx::replace(
+ '<([a-z][a-z0-9]*)(?: [^>]*)?>\s*(' . $comments . RegEx::quote($splitter) . $comments . ')\s*\1>',
+ '\2',
+ $string
+ );
+
+ return explode($splitter, $string);
+ }
+
+ /**
+ * Fix broken/invalid html syntax in a string using php DOMDocument functionality
+ *
+ * @param string $string
+ *
+ * @return mixed
+ */
+ private static function fixUsingDOMDocument($string)
+ {
+ $doc = new DOMDocument;
+
+ $doc->substituteEntities = false;
+
+ // Add temporary surrounding div
+ $string = '
' . $string . '
';
+
+ @$doc->loadHTML($string);
+ $string = $doc->saveHTML();
+
+ // Remove html document structures
+ $string = RegEx::replace('^<[^>]*>(.*?).*?(?:(.*).*?)?(.*).*?$', '\1\2\3', $string);
+
+ // Remove temporary surrounding div
+ $string = RegEx::replace('^\s*
(.*)
\s*$', '\1', $string);
+
+ // Remove leading/trailing empty paragraph
+ $string = RegEx::replace('(^\s*
\s*
|
\s*
\s*$)', '', $string);
+
+ // Remove leading/trailing empty paragraph
+ $string = RegEx::replace('(^\s*
]*)?>\s*
|
]*)?>\s*
\s*$)', '', $string);
+
+ return $string;
+ }
+
+ /**
+ * Fix broken/invalid html syntax in a string using custom code as an alternative to php DOMDocument functionality
+ *
+ * @param string $string
+ *
+ * @return string
+ */
+ private static function fixUsingCustomFixer($string)
+ {
+ $block_regex = '<(' . implode('|', self::getBlockElementsNoDiv()) . ')[\s>]';
+
+ $string = RegEx::replace('(' . $block_regex . ')', '[:SPLIT-BLOCK:]\1', $string);
+ $parts = explode('[:SPLIT-BLOCK:]', $string);
+
+ foreach ($parts as $i => &$part)
+ {
+ if ( ! RegEx::match('^' . $block_regex, $part, $type))
+ {
+ continue;
+ }
+
+ $type = strtolower($type[1]);
+
+ // remove endings of other block elements
+ $part = RegEx::replace('(?:' . implode('|', self::getBlockElementsNoDiv($type)) . ')>', '', $part);
+
+ if (strpos($part, '' . $type . '>') !== false)
+ {
+ continue;
+ }
+
+ // Add ending tag once
+ $part = RegEx::replaceOnce('(\s*)$', '' . $type . '>\1', $part);
+
+ // Remove empty block tags
+ $part = RegEx::replace('^<' . $type . '(?: [^>]*)?>\s*' . $type . '>', '', $part);
+ }
+
+ return implode('', $parts);
+ }
+
+ /**
+ * Removes complete html tag pairs from the concatenated parts
+ *
+ * @param array $parts
+ * @param array $elements
+ *
+ * @return array
+ */
+ public static function cleanSurroundingTags($parts, $elements = ['p', 'span'])
+ {
+ $breaks = '(?:(?:
|<\!--.*?-->|:\|:)\s*)*';
+ $keys = array_keys($parts);
+
+ $string = implode(':|:', $parts);
+
+ // Remove empty tags
+ $regex = '<(' . implode('|', $elements) . ')(?: [^>]*)?>\s*(' . $breaks . ')<\/\1>\s*';
+
+ while (RegEx::match($regex, $string, $match))
+ {
+ $string = str_replace($match[0], $match[2], $string);
+ }
+
+ // Remove paragraphs around block elements
+ $block_elements = [
+ 'p', 'div',
+ 'table', 'tr', 'td', 'thead', 'tfoot',
+ 'h[1-6]',
+ ];
+ $block_elements = '(' . implode('|', $block_elements) . ')';
+
+ $regex = '(
]*)?>)(\s*' . $breaks . ')(<' . $block_elements . '(?: [^>]*)?>)';
+
+ while (RegEx::match($regex, $string, $match))
+ {
+ if ($match[4] == 'p')
+ {
+ $match[3] = $match[1] . $match[3];
+ self::combinePTags($match[3]);
+ }
+
+ $string = str_replace($match[0], $match[2] . $match[3], $string);
+ }
+
+ $regex = '(' . $block_elements . '>\s*' . $breaks . ')
';
+
+ while (RegEx::match($regex, $string, $match))
+ {
+ $string = str_replace($match[0], $match[1], $string);
+ }
+
+ $parts = explode(':|:', $string);
+
+ $new_tags = [];
+
+ foreach ($parts as $key => $val)
+ {
+ $key = isset($keys[$key]) ? $keys[$key] : $key;
+ $new_tags[$key] = $val;
+ }
+
+ return $new_tags;
+ }
+
+ /**
+ * Remove
tags around block elements
+ *
+ * @param string $string
+ *
+ * @return mixed
+ */
+ private static function removeParagraphsAroundBlockElements($string)
+ {
+ if (strpos($string, '
') == false)
+ {
+ return $string;
+ }
+
+ $string = RegEx::replace(
+ '
]*)?>\s*'
+ . '((?:<\!--.*?-->\s*)*?(?:' . implode('|', self::getBlockElements()) . ')' . '(?: [^>]*)?>)',
+ '\1',
+ $string
+ );
+
+ $string = RegEx::replace(
+ '(?(?:' . implode('|', self::getBlockElements()) . ')' . '(?: [^>]*)?>(?:\s*<\!--.*?-->)*)'
+ . '(?:\s*
)',
+ '\1',
+ $string
+ );
+
+ return $string;
+ }
+
+ /**
+ * Remove
tags around comments
+ *
+ * @param string $string
+ *
+ * @return mixed
+ */
+ private static function removeParagraphsAroundComments($string)
+ {
+ if (strpos($string, '
') == false)
+ {
+ return $string;
+ }
+
+ $string = RegEx::replace(
+ '(?:
]*)?>\s*)'
+ . '(<\!--.*?-->)'
+ . '(?:\s*
)',
+ '\1',
+ $string
+ );
+
+ return $string;
+ }
+
+ /**
+ * Fix
tags around other
elements
+ *
+ * @param string $string
+ *
+ * @return mixed
+ */
+ private static function fixParagraphsAroundParagraphElements($string)
+ {
+ if (strpos($string, '
') == false)
+ {
+ return $string;
+ }
+
+ $parts = explode('', $string);
+ $ending = '' . array_pop($parts);
+
+ foreach ($parts as &$part)
+ {
+ if (strpos($part, '
') === false && strpos($part, '
' . $part;
+ continue;
+ }
+
+ $part = RegEx::replace(
+ '(
]*)?>.*?)(
]*)?>)',
+ '\1
\2',
+ $part
+ );
+ }
+
+ return implode('', $parts) . $ending;
+ }
+
+ /*
+ * Remove empty tags
+ *
+ * @param string $string
+ * @param array $elements
+ *
+ * @return mixed
+ */
+ public static function removeEmptyTagPairs($string, $elements = ['p', 'span'])
+ {
+ $breaks = '(?:(?:
|<\!--.*?-->)\s*)*';
+
+ $regex = '<(' . implode('|', $elements) . ')(?: [^>]*)?>\s*(' . $breaks . ')<\/\1>\s*';
+
+ while (RegEx::match($regex, $string, $match))
+ {
+ $string = str_replace($match[0], $match[2], $string);
+ }
+
+ return $string;
+ }
+
+ /**
+ * Convert
tags inside inline elements to tags
+ *
+ * @param string $string
+ *
+ * @return mixed
+ */
+ private static function convertDivsInsideInlineElementsToSpans($string)
+ {
+ if (strpos($string, '
') == false)
+ {
+ return $string;
+ }
+
+ // Ignore block elements inside anchors
+ $regex = '<(' . implode('|', self::getInlineElementsNoAnchor()) . ')(?: [^>]*)?>.*?\1>';
+ RegEx::matchAll($regex, $string, $matches, '', PREG_PATTERN_ORDER);
+
+ if (empty($matches))
+ {
+ return $string;
+ }
+
+ $matches = array_unique($matches[0]);
+ $searches = [];
+ $replacements = [];
+
+ foreach ($matches as $match)
+ {
+ if (strpos($match, '
') === false)
+ {
+ continue;
+ }
+
+ $searches[] = $match;
+ $replacements[] = str_replace(
+ ['
', '
'],
+ ['
', ''],
+ $match
+ );
+ }
+
+ if (empty($searches))
+ {
+ return $string;
+ }
+
+ return str_replace($searches, $replacements, $string);
+ }
+
+ /**
+ * Combine duplicate tags
+ * input:
+ * output:
+ *
+ * @param $string
+ */
+ public static function combinePTags(&$string)
+ {
+ if (empty($string))
+ {
+ return;
+ }
+
+ $p_start_tag = '
]*)?>';
+ $optional_tags = '\s*(?:<\!--.*?-->| |&\#160;)*\s*';
+ RegEx::matchAll('(' . $p_start_tag . ')(' . $optional_tags . ')(' . $p_start_tag . ')', $string, $tags);
+
+ if (empty($tags))
+ {
+ return;
+ }
+
+ foreach ($tags as $tag)
+ {
+ $string = str_replace($tag[0], $tag[2] . HtmlTag::combine($tag[1], $tag[3]), $string);
+ }
+ }
+
+ /**
+ * Remove inline elements around block elements
+ *
+ * @param string $string
+ *
+ * @return mixed
+ */
+ public static function removeInlineElementsAroundBlockElements($string)
+ {
+ $string = RegEx::replace(
+ '(?:<(?:' . implode('|', self::getInlineElementsNoAnchor()) . ')(?: [^>]*)?>\s*)'
+ . '(?(?:' . implode('|', self::getBlockElements()) . ')(?: [^>]*)?>)',
+ '\1',
+ $string
+ );
+
+ $string = RegEx::replace(
+ '(?(?:' . implode('|', self::getBlockElements()) . ')(?: [^>]*)?>)'
+ . '(?:\s*(?:' . implode('|', self::getInlineElementsNoAnchor()) . ')>)',
+ '\1',
+ $string
+ );
+
+ return $string;
+ }
+
+ /**
+ * Return an array of block element names, optionally without any of the names given $exclude
+ *
+ * @param array $exclude
+ *
+ * @return array
+ */
+ public static function getBlockElements($exclude = [])
+ {
+ if ( ! is_array($exclude))
+ {
+ $exclude = [$exclude];
+ }
+
+ $elements = [
+ 'div', 'p', 'pre',
+ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
+ ];
+
+ $elements = array_diff($elements, $exclude);
+
+ $elements = implode(',', $elements);
+ $elements = str_replace('h1,h2,h3,h4,h5,h6', 'h[1-6]', $elements);
+ $elements = explode(',', $elements);
+
+ return $elements;
+ }
+
+ /**
+ * Return an array of inline element names, optionally without any of the names given $exclude
+ *
+ * @param array $exclude
+ *
+ * @return array
+ */
+ public static function getInlineElements($exclude = [])
+ {
+ if ( ! is_array($exclude))
+ {
+ $exclude = [$exclude];
+ }
+
+ $elements = [
+ 'span', 'code', 'a',
+ 'strong', 'b', 'em', 'i', 'u', 'big', 'small', 'font',
+ 'sup', 'sub',
+ ];
+
+ return array_diff($elements, $exclude);
+ }
+
+ /**
+ * Return an array of block element names, without divs and any of the names given $exclude
+ *
+ * @param array $exclude
+ *
+ * @return array
+ */
+ public static function getBlockElementsNoDiv($exclude = [])
+ {
+ return array_diff(self::getBlockElements($exclude), ['div']);
+ }
+
+ /**
+ * Return an array of block element names, without anchors (a) and any of the names given $exclude
+ *
+ * @param array $exclude
+ *
+ * @return array
+ */
+ public static function getInlineElementsNoAnchor($exclude = [])
+ {
+ return array_diff(self::getInlineElements($exclude), ['a']);
+ }
+
+ /**
+ * Protect plugin style tags and php
+ *
+ * @param $string
+ *
+ * @return mixed
+ */
+ private static function protectSpecialCode($string)
+ {
+ // Protect PHP code
+ Protect::protectByRegex($string, '(<|<)\?php\s.*?\?(>|>)');
+
+ // Protect {...} tags
+ Protect::protectByRegex($string, '\{[a-z0-9].*?\}');
+
+ // Protect [...] tags
+ Protect::protectByRegex($string, '\[[a-z0-9].*?\]');
+
+ // Protect scripts
+ Protect::protectByRegex($string, '');
+
+ // Protect css
+ Protect::protectByRegex($string, '');
+
+ Protect::convertProtectionToHtmlSafe($string);
+
+ return $string;
+ }
+
+ /**
+ * Unprotect protected tags
+ *
+ * @param $string
+ *
+ * @return mixed
+ */
+ private static function unprotectSpecialCode($string)
+ {
+ Protect::unprotectHtmlSafe($string);
+
+ return $string;
+ }
+
+ /**
+ * Prevents broken html tags at the end of $pre (other half at beginning of $string)
+ * It will move the broken part to the beginning of $string to complete it
+ *
+ * @param $pre
+ * @param $string
+ */
+ private static function fixBrokenTagsByPreString(&$pre, &$string)
+ {
+ if ( ! RegEx::match('<(\![^>]*|/?[a-z][^>]*(="[^"]*)?)$', $pre, $match))
+ {
+ return;
+ }
+
+ $pre = substr($pre, 0, strlen($pre) - strlen($match[0]));
+ $string = $match[0] . $string;
+ }
+
+ /**
+ * Prevents broken html tags at the beginning of $pre (other half at end of $string)
+ * It will move the broken part to the end of $string to complete it
+ *
+ * @param $post
+ * @param $string
+ */
+ private static function fixBrokenTagsByPostString(&$post, &$string)
+ {
+ if ( ! RegEx::match('<(\![^>]*|/?[a-z][^>]*(="[^"]*)?)$', $string, $match))
+ {
+ return;
+ }
+
+ if ( ! RegEx::match('^[^>]*>', $post, $match))
+ {
+ return;
+ }
+
+ $post = substr($post, strlen($match[0]));
+
+ $string .= $match[0];
+ }
+
+ /**
+ * Removes html tags from string
+ *
+ * @param string $string
+ *
+ * @return string
+ */
+ public static function removeHtmlTags($string)
+ {
+ // remove pagenavcounter
+ $string = RegEx::replace('
.*?
', ' ', $string);
+ // remove pagenavbar
+ $string = RegEx::replace('', ' ', $string);
+ // remove inline scripts
+ $string = RegEx::replace('') === false)
+ {
+ return;
+ }
+
+ self::protectByRegex(
+ $string,
+ ''
+ );
+ }
+
+ /**
+ * Protect all html tags with some type of attributes/content
+ *
+ * @param string $string
+ */
+ public static function protectHtmlTags(&$string)
+ {
+ // protect comment tags
+ self::protectHtmlCommentTags($string);
+
+ // protect html tags
+ self::protectByRegex($string, '<[a-z][^>]*(?:="[^"]*"|=\'[^\']*\')+[^>]*>');
+ }
+
+ /**
+ * Protect all html comment tags
+ *
+ * @param string $string
+ */
+ public static function protectHtmlCommentTags(&$string)
+ {
+ // protect comment tags
+ self::protectByRegex($string, '<\!--.*?-->');
+ }
+
+ /**
+ * Protect text by given regex
+ *
+ * @param string $string
+ * @param string $regex
+ */
+ public static function protectByRegex(&$string, $regex)
+ {
+ RegEx::matchAll($regex, $string, $matches, null, PREG_PATTERN_ORDER);
+
+ if (empty($matches))
+ {
+ return;
+ }
+
+ $matches = array_unique($matches[0]);
+ $replacements = [];
+
+ foreach ($matches as $match)
+ {
+ $replacements[] = self::protectString($match);
+ }
+
+ $string = str_replace($matches, $replacements, $string);
+ }
+
+ /**
+ * Protect given plugin style tags
+ *
+ * @param string $string
+ * @param array $tags
+ * @param bool $include_closing_tags
+ */
+ public static function protectTags(&$string, $tags = [], $include_closing_tags = true)
+ {
+ list($tags, $protected) = self::prepareTags($tags, $include_closing_tags);
+
+ $string = str_replace($tags, $protected, $string);
+ }
+
+ /**
+ * Replace any protected tags to original
+ *
+ * @param string $string
+ * @param array $tags
+ * @param bool $include_closing_tags
+ */
+ public static function unprotectTags(&$string, $tags = [], $include_closing_tags = true)
+ {
+ list($tags, $protected) = self::prepareTags($tags, $include_closing_tags);
+
+ $string = str_replace($protected, $tags, $string);
+ }
+
+ /**
+ * Protect array of strings
+ *
+ * @param string $string
+ * @param array $unprotected
+ * @param array $protected
+ */
+ public static function protectInString(&$string, $unprotected = [], $protected = [])
+ {
+ $protected = empty($protected) ? self::protectArray($unprotected) : $protected;
+
+ $string = str_replace($unprotected, $protected, $string);
+ }
+
+ /**
+ * Replace any protected tags to original
+ *
+ * @param string $string
+ * @param array $unprotected
+ * @param array $protected
+ */
+ public static function unprotectInString(&$string, $unprotected = [], $protected = [])
+ {
+ $protected = empty($protected) ? self::protectArray($unprotected) : $protected;
+
+ $string = str_replace($protected, $unprotected, $string);
+ }
+
+ /**
+ * Return the sourcerer tag name and characters
+ *
+ * @return array
+ */
+ public static function getSourcererTag()
+ {
+ if ( ! is_null(self::$sourcerer_tag))
+ {
+ return [self::$sourcerer_tag, self::$sourcerer_characters];
+ }
+
+ $parameters = Parameters::getInstance()->getPluginParams('sourcerer');
+
+ self::$sourcerer_tag = isset($parameters->syntax_word) ? $parameters->syntax_word : '';
+ self::$sourcerer_characters = isset($parameters->tag_characters) ? $parameters->tag_characters : '{.}';
+
+ return [self::$sourcerer_tag, self::$sourcerer_characters];
+ }
+
+ /**
+ * Protect all Sourcerer blocks
+ *
+ * @param string $string
+ */
+ public static function protectSourcerer(&$string)
+ {
+ list($tag, $characters) = self::getSourcererTag();
+
+ if (empty($tag))
+ {
+ return;
+ }
+
+ list($start, $end) = explode('.', $characters);
+
+ if (strpos($string, $start . '/' . $tag . $end) === false)
+ {
+ return;
+ }
+
+ $regex = RegEx::quote($start . $tag)
+ . '[\s\}].*?'
+ . RegEx::quote($start . '/' . $tag . $end);
+
+ RegEx::matchAll($regex, $string, $matches, null, PREG_PATTERN_ORDER);
+
+ if (empty($matches))
+ {
+ return;
+ }
+
+ $matches = array_unique($matches[0]);
+
+ foreach ($matches as $match)
+ {
+ $string = str_replace($match, self::protectString($match), $string);
+ }
+ }
+
+ /**
+ * Protect complete AdminForm
+ *
+ * @param string $string
+ * @param array $tags
+ * @param bool $include_closing_tags
+ */
+ public static function protectForm(&$string, $tags = [], $include_closing_tags = true)
+ {
+ if ( ! Document::isEditPage())
+ {
+ return;
+ }
+
+ list($tags, $protected_tags) = self::prepareTags($tags, $include_closing_tags);
+
+ $string = RegEx::replace(self::getFormRegex(), '\1', $string);
+ $string = explode('', $string);
+
+ foreach ($string as $i => &$string_part)
+ {
+ if (empty($string_part) || ! fmod($i, 2))
+ {
+ continue;
+ }
+
+ self::protectFormPart($string_part, $tags, $protected_tags);
+ }
+
+ $string = implode('', $string);
+ }
+
+ /**
+ * Protect part of the AdminForm
+ *
+ * @param string $string
+ * @param array $tags
+ * @param array $protected_tags
+ */
+ private static function protectFormPart(&$string, $tags = [], $protected_tags = [])
+ {
+ if (strpos($string, '') === false)
+ {
+ return;
+ }
+
+ // Protect entire form
+ if (empty($tags))
+ {
+ $form_parts = explode('', $string, 2);
+ $form_parts[0] = self::protectString($form_parts[0] . '');
+ $string = implode('', $form_parts);
+
+ return;
+ }
+
+ $regex_tags = RegEx::quote($tags);
+
+ if ( ! RegEx::match($regex_tags, $string))
+ {
+ return;
+ }
+
+ $form_parts = explode('', $string, 2);
+ // protect tags only inside form fields
+ RegEx::matchAll(
+ '(?: