Adapted the transliteration to use Joomla API

This commit is contained in:
Llewellyn van der Merwe 2019-10-11 16:51:43 +02:00
parent 4fb4069d64
commit 39b276ac4b
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
8 changed files with 6692 additions and 6634 deletions

View File

@ -150,7 +150,7 @@ TODO
+ *Version*: 2.10.1
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **253705**
+ *Line count*: **253747**
+ *Field count*: **1347**
+ *File count*: **1618**
+ *Folder count*: **261**

View File

@ -150,7 +150,7 @@ TODO
+ *Version*: 2.10.1
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **253705**
+ *Line count*: **253747**
+ *Field count*: **1347**
+ *File count*: **1618**
+ *Folder count*: **261**

View File

@ -17,7 +17,7 @@ defined('_JEXEC') or die('Restricted access');
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Language\Language;
use Joomla\CMS\Language\Language;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
@ -25,7 +25,13 @@ use Joomla\Utilities\ArrayHelper;
* ###Component### component helper.
*/
abstract class ###Component###Helper
{###ADMIN_GLOBAL_EVENT_HELPER######CUSTOM_HELPER_SCRIPT######BOTH_CUSTOM_HELPER_SCRIPT###
{
/**
* The Main Active Language
*
* @var string
*/
public static $langTag;###ADMIN_GLOBAL_EVENT_HELPER######CUSTOM_HELPER_SCRIPT######BOTH_CUSTOM_HELPER_SCRIPT###
/**
* Load the Component xml manifest.
@ -1068,6 +1074,8 @@ abstract class ###Component###Helper
$string = trim($string);
$string = preg_replace('/'.$spacer.'+/', ' ', $string);
$string = preg_replace('/\s+/', ' ', $string);
// Transliterate string
$string = self::transliterate($string);
// remove all and keep only characters
if ($keepOnlyCharacters)
{
@ -1136,6 +1144,19 @@ abstract class ###Component###Helper
return '';
}
public static function transliterate($string)
{
// set tag only once
if (!self::checkString(self::$langTag))
{
// get global value
self::$langTag = JComponentHelper::getParams('com_###component###')->get('language', 'en-GB');
}
// Transliterate on the language requested
$lang = Language::getInstance(self::$langTag);
return $lang->transliterate($string);
}
public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40)
{
if (self::checkString($var))

View File

@ -17,7 +17,7 @@ defined('_JEXEC') or die('Restricted access');
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Language\Language;
use Joomla\CMS\Language\Language;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
@ -25,7 +25,13 @@ use Joomla\Utilities\ArrayHelper;
* ###Component### component helper
*/
abstract class ###Component###Helper
{###SITE_GLOBAL_EVENT_HELPER######SITE_CUSTOM_HELPER_SCRIPT######BOTH_CUSTOM_HELPER_SCRIPT###
{
/**
* The Main Active Language
*
* @var string
*/
public static $langTag;###SITE_GLOBAL_EVENT_HELPER######SITE_CUSTOM_HELPER_SCRIPT######BOTH_CUSTOM_HELPER_SCRIPT###
public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name')
{
@ -1057,6 +1063,8 @@ abstract class ###Component###Helper
$string = trim($string);
$string = preg_replace('/'.$spacer.'+/', ' ', $string);
$string = preg_replace('/\s+/', ' ', $string);
// Transliterate string
$string = self::transliterate($string);
// remove all and keep only characters
if ($keepOnlyCharacters)
{
@ -1125,6 +1133,19 @@ abstract class ###Component###Helper
return '';
}
public static function transliterate($string)
{
// set tag only once
if (!self::checkString(self::$langTag))
{
// get global value
self::$langTag = JComponentHelper::getParams('com_###component###')->get('language', 'en-GB');
}
// Transliterate on the language requested
$lang = Language::getInstance(self::$langTag);
return $lang->transliterate($string);
}
public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40)
{
if (self::checkString($var))

View File

@ -805,8 +805,8 @@ class Get
$this->minify = (isset($config['minify']) && $config['minify'] != 2) ? $config['minify'] : $this->params->get('minify', 0);
// set the global language
$this->langTag = $this->params->get('language', $this->langTag);
// also set the helper calss langTag (for safe string)
// also set the helper class langTag (for safeStrings)
ComponentbuilderHelper::$langTag = $this->langTag;
// setup the main language array
$this->languages[$this->langTag] = array();
// check if we have Tidy enabled

View File

@ -12,7 +12,7 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Language\Language;
use Joomla\CMS\Language\Language;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
@ -21,6 +21,12 @@ use Joomla\Utilities\ArrayHelper;
*/
abstract class ComponentbuilderHelper
{
/**
* The Main Active Language
*
* @var string
*/
public static $langTag;
/**
* The Global Admin Event Method.
@ -6874,32 +6880,8 @@ abstract class ComponentbuilderHelper
$string = trim($string);
$string = preg_replace('/'.$spacer.'+/', ' ', $string);
$string = preg_replace('/\s+/', ' ', $string);
// transliterate cyrillic characters
$transliterationTable = array(
'а' => 'a', 'б' => 'b', 'в' => 'v',
'г' => 'g', 'д' => 'd', 'е' => 'e',
'ё' => 'e', 'ж' => 'zh', 'з' => 'z',
'и' => 'i', 'й' => 'y', 'к' => 'k',
'л' => 'l', 'м' => 'm', 'н' => 'n',
'о' => 'o', 'п' => 'p', 'р' => 'r',
'с' => 's', 'т' => 't', 'у' => 'u',
'ф' => 'f', 'х' => 'h', 'ц' => 'c',
'ч' => 'ch', 'ш' => 'sh', 'щ' => 'sch',
'ь' => '', 'ы' => 'y', 'ъ' => '',
'э' => 'e', 'ю' => 'yu', 'я' => 'ya',
'А' => 'A', 'Б' => 'B', 'В' => 'V',
'Г' => 'G', 'Д' => 'D', 'Е' => 'E',
'Ё' => 'E', 'Ж' => 'Zh', 'З' => 'Z',
'И' => 'I', 'Й' => 'Y', 'К' => 'K',
'Л' => 'L', 'М' => 'M', 'Н' => 'N',
'О' => 'O', 'П' => 'P', 'Р' => 'R',
'С' => 'S', 'Т' => 'T', 'У' => 'U',
'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C',
'Ч' => 'Ch', 'Ш' => 'Sh', 'Щ' => 'Sch',
'Ь' => '', 'Ы' => 'Y', 'Ъ' => '',
'Э' => 'E', 'Ю' => 'Yu', 'Я' => 'Ya',
);
$string = strtr($string, $transliterationTable);
// Transliterate string
$string = self::transliterate($string);
// remove all and keep only characters
if ($keepOnlyCharacters)
{
@ -6968,6 +6950,19 @@ abstract class ComponentbuilderHelper
return '';
}
public static function transliterate($string)
{
// set tag only once
if (!self::checkString(self::$langTag))
{
// get global value
self::$langTag = JComponentHelper::getParams('com_componentbuilder')->get('language', 'en-GB');
}
// Transliterate on the language requested
$lang = Language::getInstance(self::$langTag);
return $lang->transliterate($string);
}
public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40)
{
if (self::checkString($var))

View File

@ -12,7 +12,7 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Language\Language;
use Joomla\CMS\Language\Language;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;
@ -21,6 +21,12 @@ use Joomla\Utilities\ArrayHelper;
*/
abstract class ComponentbuilderHelper
{
/**
* The Main Active Language
*
* @var string
*/
public static $langTag;
/**
* The Global Site Event Method.
@ -6597,6 +6603,8 @@ abstract class ComponentbuilderHelper
$string = trim($string);
$string = preg_replace('/'.$spacer.'+/', ' ', $string);
$string = preg_replace('/\s+/', ' ', $string);
// Transliterate string
$string = self::transliterate($string);
// remove all and keep only characters
if ($keepOnlyCharacters)
{
@ -6665,6 +6673,19 @@ abstract class ComponentbuilderHelper
return '';
}
public static function transliterate($string)
{
// set tag only once
if (!self::checkString(self::$langTag))
{
// get global value
self::$langTag = JComponentHelper::getParams('com_componentbuilder')->get('language', 'en-GB');
}
// Transliterate on the language requested
$lang = Language::getInstance(self::$langTag);
return $lang->transliterate($string);
}
public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40)
{
if (self::checkString($var))