Spade
Mini Shell
PK�{�[- �֖� .htaccessnu�[���# Apache 2.4+
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
# Apache 2.0-2.2
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>
PK�{�[�#o,,VDM.Joomla/index.htmlnu�[���<html><body
bgcolor="#FFFFFF"></body></html>PK�{�[=I�4�D�DVDM.Joomla/src/Utilities.phpnu�[���<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe
<http://www.joomlacomponentbuilder.com>
* @gitea Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @github Joomla Component Builder
<https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\MathHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\GuidHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Utilities\String\FieldHelper;
use VDM\Joomla\Utilities\String\TypeHelper;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
use VDM\Joomla\Utilities\String\NamespaceHelper;
use VDM\Joomla\Utilities\String\PluginHelper;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Basic shared utilities, a legacy implementation
*
* @since 3.0.9
*/
trait Utilities
{
/**
* The Main Active Language
*
* @var string
*
* @since 3.0.9
*/
public static $langTag;
/**
* Check if have a string with a length
*
* @input string $string The string to check
*
* @returns bool true on success
*
* @since 3.0.9
*
* @deprecated 4.0 - Use StringHelper::check($string);
*/
public static function checkString($string): bool
{
return StringHelper::check($string);
}
/**
* Shorten a string
*
* @input string $string That you would like to shorten
*
* @returns string on success
*
* @since 3.0.9
*
* @deprecated 4.0 - Use StringHelper::shorten($string, $length,
$addTip);
*/
public static function shorten($string, $length = 40, $addTip = true)
{
return StringHelper::shorten($string, $length, $addTip);
}
/**
* Making strings safe (various ways)
*
* @input string $string That you would like to make safe
*
* @returns string on success
*
* @since 3.0.9
*
* @deprecated 4.0 - Use StringHelper::safe($string, $type, $spacer,
$replaceNumbers, $keepOnlyCharacters);
*/
public static function safeString($string, $type = 'L', $spacer
= '_', $replaceNumbers = true, $keepOnlyCharacters = true)
{
// set the local component option
self::setComponentOption();
return StringHelper::safe($string, $type, $spacer, $replaceNumbers,
$keepOnlyCharacters);
}
/**
* Making class or function name safe
*
* @input string The name you would like to make safe
*
* @returns string on success
*
* @since 3.0.9
*
* @deprecated 4.0 - Use ClassfunctionHelper::safe($name);
*/
public static function safeClassFunctionName($name)
{
return ClassfunctionHelper::safe($name);
}
/**
* Making field names safe
*
* @input string The you would like to make safe
* @input boolean The switch to return an ALL UPPER CASE string
* @input string The string to use in white space
*
* @returns string on success
*
* @since 3.0.9
*
* @deprecated 4.0 - Use FieldHelper::safe($string, $allcap, $spacer);
*/
public static function safeFieldName($string, $allcap = false, $spacer =
'_')
{
// set the local component option
self::setComponentOption();
return FieldHelper::safe($string, $allcap, $spacer);
}
/**
* Making field type name safe
*
* @input string The you would like to make safe
*
* @returns string on success
*
* @since 3.0.9
*
* @deprecated 4.0 - Use TypeHelper::safe($string);
*/
public static function safeTypeName($string)
{
// set the local component option
self::setComponentOption();
return TypeHelper::safe($string);
}
/**
* Making namespace safe
*
* @input string The you would like to make safe
*
* @returns string on success
*
* @since 3.0.9
*
* @deprecated 4.0 - Use NamespaceHelper::safe($string);
*/
public static function safeNamespace($string)
{
return NamespaceHelper::safe($string);
}
/**
* @since 3.0.9
*
* @deprecated 4.0 - Use StringHelper::transliterate($string);
*/
public static function transliterate($string)
{
// set the local component option
self::setComponentOption();
return StringHelper::transliterate($string);
}
/**
* @since 3.0.9
*
* @deprecated 4.0 - Use StringHelper::html($var, $charset, $shorten,
$length);
*/
public static function htmlEscape($var, $charset = 'UTF-8',
$shorten = false, $length = 40)
{
// set the local component option
self::setComponentOption();
return StringHelper::html($var, $charset, $shorten, $length);
}
/**
* @since 3.0.9
*
* @deprecated 4.0 - Use StringHelper::numbers($string);
*/
public static function replaceNumbers($string)
{
return StringHelper::numbers($string);
}
/**
* Convert an integer into an English word string
* Thanks to Tom Nicholson
<http://php.net/manual/en/function.strval.php#41988>
*
* @input int $x an int
*
* @returns string a string
*
* @since 3.0.9
*
* @deprecated 4.0 - Use StringHelper::number($x);
*/
public static function numberToString($x)
{
return StringHelper::number($x);
}
/**
* Random Key
*
* @input int $size the length of the string
*
* @returns string a string of random characters
*
* @since 3.0.9
*
* @deprecated 4.0 - Use StringHelper::random($size);
*/
public static function randomkey($size): string
{
return StringHelper::random($size);
}
/**
* Check if you have a json string
*
* @input string $string The json string to check
*
* @returns bool true on success
*
* @since 3.0.9
*
* @deprecated 4.0 - Use JsonHelper::check($string);
*/
public static function checkJson($string): bool
{
return JsonHelper::check($string);
}
/**
* @since 3.0.9
*
* @deprecated 4.0 - Use JsonHelper::string($value, $sperator, $table,
$id, $name);
*/
public static function jsonToString($value, $sperator = ", ",
$table = null, $id = 'id', $name = 'name')
{
return JsonHelper::string($value, $sperator, $table, $id, $name);
}
/**
* Check if you have an array with a length
*
* @input mixed $array The array to check
* @input bool $removeEmptyString Should we remove empty values
*
* @returns int number of items in array on success
*
* @since 3.0.9
*
* @deprecated 4.0 - Use ArrayHelper::check($array, $removeEmptyString);
*/
public static function checkArray($array, $removeEmptyString = false):
int
{
return ArrayHelper::check($array, $removeEmptyString);
}
/**
* Merge an array of array's
*
* @input mixed $arrays The arrays you would like to merge
*
* @returns mixed array on success
*
* @since 3.0.9
*
* @deprecated 4.0 - Use ArrayHelper::merge($arrays);
*/
public static function mergeArrays($arrays)
{
return ArrayHelper::merge($arrays);
}
/**
* Check if you have an object with a length
*
* @input object $object The object to check
*
* @returns bool true on success
*
* @since 3.0.9
*
* @deprecated 4.0 - Use ObjectHelper::check($object);
*/
public static function checkObject($object): bool
{
return ObjectHelper::check($object);
}
/**
* Get a Variable
*
* @param string $table The table from which to get the
variable
* @param string $where The value where
* @param string $whereString The target/field string where/name
* @param string $what The return field
* @param string $operator The operator between $whereString/field
and $where/value
* @param string $main The component in which the table is
found
*
* @return mix string/int/float
*
* @since 3.0.9
*
* @deprecated 4.0 - Use GetHelper::var($table, $where, $whereString,
$what, $operator, $main);
*/
public static function getVar($table, $where = null, $whereString =
'user', $what = 'id', $operator = '=', $main
= null)
{
// set the local component option
self::setComponentOption();
return GetHelper::var($table, $where, $whereString, $what, $operator,
$main);
}
/**
* Get array of variables
*
* @param string $table The table from which to get the
variables
* @param string $where The value where
* @param string $whereString The target/field string where/name
* @param string $what The return field
* @param string $operator The operator between $whereString/field
and $where/value
* @param string $main The component in which the table is
found
* @param bool $unique The switch to return a unique array
*
* @return array
*
* @since 3.0.9
*
* @deprecated 4.0 - Use GetHelper::vars($table, $where, $whereString,
$what, $operator, $main, $unique);
*/
public static function getVars($table, $where = null, $whereString =
'user', $what = 'id', $operator = 'IN', $main
= null, $unique = true)
{
// set the local component option
self::setComponentOption();
return GetHelper::vars($table, $where, $whereString, $what, $operator,
$main, $unique);
}
/**
* get all strings between two other strings
*
* @param string $content The content to search
* @param string $start The starting value
* @param string $end The ending value
*
* @return array On success
*
* @since 3.0.9
*
* @deprecated 4.0 - Use GetHelper::allBetween($content, $start, $end);
*/
public static function getAllBetween($content, $start, $end)
{
return GetHelper::allBetween($content, $start, $end);
}
/**
* get a string between two other strings
*
* @param string $content The content to search
* @param string $start The starting value
* @param string $end The ending value
* @param string $default The default value if none found
*
* @return string On success / empty string on failure
*
* @since 3.0.9
*
* @deprecated 4.0 - Use GetHelper::between($content, $start, $end,
$default);
*/
public static function getBetween($content, $start, $end, $default =
'')
{
return GetHelper::between($content, $start, $end, $default);
}
/**
* bc math wrapper (very basic not for accounting)
*
* @param string $type The type bc math
* @param int $val1 The first value
* @param int $val2 The second value
* @param int $scale The scale value
*
* @return float|int
*
* @since 3.0.9
*
* @deprecated 4.0 - Use MathHelper::bc($type, $val1, $val2, $scale);
*/
public static function bcmath($type, $val1, $val2, $scale = 0)
{
return MathHelper::bc($type, $val1, $val2, $scale);
}
/**
* Basic sum of an array with more precision
*
* @param array $array The values to sum
* @param int $scale The scale value
*
* @return float|int
*
* @since 3.0.9
*
* @deprecated 4.0 - Use MathHelper::sum($array, $scale);
*/
public static function bcsum($array, $scale = 4)
{
return MathHelper::sum($array, $scale);
}
/**
* create plugin class name
*
* @input string The group name
* @input string The name
*
* @return string
*
* @since 3.0.9
*
* @deprecated 4.0 - Use PluginHelper::safe($name, $group);
*/
public static function createPluginClassName($group, $name)
{
return PluginHelper::safeClassName($name, $group);
}
/**
* Returns a GUIDv4 string
*
* Thanks to Dave Pearson (and other)
* https://www.php.net/manual/en/function.com-create-guid.php#119168
*
* Uses the best cryptographically secure method
* for all supported platforms with fallback to an older,
* less secure version.
*
* @param bool $trim
*
* @return string
*
* @since 3.0.9
*
* @deprecated 4.0 - Use GuidHelper::get($trim);
*/
public static function GUID($trim = true)
{
return GuidHelper::get($trim);
}
/**
* Validate the Globally Unique Identifier ( and check if table already
has this identifier)
*
* @param string $guid
* @param string $table
* @param int $id
* @param string|null $component
*
* @return bool
*
* @since 3.0.9
*
* @deprecated 4.0 - Use GuidHelper::valid($guid, $table, $id,
$component);
*/
public static function validGUID($guid, $table = null, $id = 0, $component
= null)
{
// set the local component option
self::setComponentOption();
return GuidHelper::valid($guid, $table, $id, $component);
}
/**
* get the ITEM of a GUID by table
*
* @param string $guid
* @param string $table
* @param string/array $what
* @param string|null $component
*
* @return mix
*
* @since 3.0.9
*
* @deprecated 4.0 - Use GuidHelper::valid($guid, $table, $id,
$component);
*/
public static function getGUID($guid, $table, $what = 'a.id',
$component = null)
{
// set the local component option
self::setComponentOption();
return GuidHelper::item($guid, $table, $what, $component);
}
/**
* Validate the Globally Unique Identifier
*
* Thanks to Lewie
* https://stackoverflow.com/a/1515456/1429677
*
* @param string $guid
*
* @return bool
*
* @deprecated 4.0 - Use GuidHelper::validate($guid);
*/
protected static function validateGUID($guid)
{
return GuidHelper::validate($guid);
}
/**
* The zipper method
*
* @param string $workingDIR The directory where the items must be
zipped
* @param string $filepath The path to where the zip file must
be placed
*
* @return bool true On success
*
* @since 3.0.9
*
* @deprecated 4.0 - Use FileHelper::zip($workingDIR, $filepath);
*/
public static function zip($workingDIR, &$filepath)
{
return FileHelper::zip($workingDIR, $filepath);
}
/**
* get the content of a file
*
* @param string $path The path to the file
* @param string/bool $none The return value if no content was found
*
* @return string On success
*
* @since 3.0.9
*
* @deprecated 4.0 - Use FileHelper::getContent($path, $none);
*/
public static function getFileContents($path, $none = '')
{
return FileHelper::getContent($path, $none);
}
/**
* Write a file to the server
*
* @param string $path The path and file name where to safe the
data
* @param string $data The data to safe
*
* @return bool true On success
*
* @since 3.0.9
*
* @deprecated 4.0 - Use FileHelper::write($path, $data);
*/
public static function writeFile($path, $data)
{
return FileHelper::write($path, $data);
}
/**
* get all the file paths in folder and sub folders
*
* @param string $folder The local path to parse
* @param array $fileTypes The type of files to get
*
* @return void
*
* @since 3.0.9
*
* @deprecated 4.0 - Use FileHelper::getPaths($folder, $fileTypes ,
$recurse, $full);
*/
public static function getAllFilePaths($folder, $fileTypes =
array('\.php', '\.js', '\.css',
'\.less'), $recurse = true, $full = true)
{
return FileHelper::getPaths($folder, $fileTypes , $recurse, $full);
}
/**
* Get the file path or url
*
* @param string $type The (url/path) type to return
* @param string $target The Params Target name (if set)
* @param string $fileType The kind of filename to generate
(if not set no file name is generated)
* @param string $key The key to adjust the filename (if
not set ignored)
* @param string $default The default path if not set in
Params (fallback path)
* @param bool $createIfNotSet The switch to create the folder if
not found
*
* @return string On success the path or url is returned based on the
type requested
*
* @since 3.0.9
*
* @deprecated 4.0 - Use FileHelper::getPath($type, $target, $fileType,
$key, $default, $createIfNotSet);
*/
public static function getFilePath($type = 'path', $target =
'filepath', $fileType = null, $key = '', $default =
'', $createIfNotSet = true)
{
// set the local component option
self::setComponentOption();
return FileHelper::getPath($type, $target, $fileType, $key, $default,
$createIfNotSet);
}
/**
* Set the component option
*
* @param String|null $option The option for the component.
*
* @since 3.0.11
*/
public static function setComponentOption($option = null)
{
// set the local component option
if (empty($option))
{
if (empty(Helper::$option) && property_exists(__CLASS__,
'ComponentCodeName'))
{
Helper::$option = 'com_' . self::$ComponentCodeName;
}
}
else
{
Helper::$option = $option;
}
}
}
PK�{�[|`���(VDM.Joomla/src/Utilities/ArrayHelper.phpnu�[���<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe
<http://www.joomlacomponentbuilder.com>
* @gitea Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @github Joomla Component Builder
<https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Utilities;
/**
* Some array tricks helper
*
* @since 3.0.9
*/
abstract class ArrayHelper
{
/**
* Check if have an array with a length
*
* @input array The array to check
*
* @returns bool/int number of items in array on success
*
* @since 3.0.9
*/
public static function check($array, $removeEmptyString = false)
{
if (is_array($array) && ($nr = count((array)$array)) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
{
foreach ($array as $key => $string)
{
if (empty($string))
{
unset($array[$key]);
}
}
return self::check($array, false);
}
return $nr;
}
return false;
}
/**
* Merge an array of array's
*
* @input array The arrays you would like to merge
*
* @returns array on success
*
* @since 3.0.9
*/
public static function merge($arrays)
{
if(self::check($arrays))
{
$arrayBuket = array();
foreach ($arrays as $array)
{
if (self::check($array))
{
$arrayBuket = array_merge($arrayBuket, $array);
}
}
return $arrayBuket;
}
return false;
}
}
PK�{�[�j�7��-VDM.Joomla/src/Utilities/Component/Helper.phpnu�[���<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe
<http://www.joomlacomponentbuilder.com>
* @gitea Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @github Joomla Component Builder
<https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Utilities\Component;
use Joomla\Input\Input;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\Registry\Registry;
/**
* Some component helper
*
* @since 3.0.11
*/
abstract class Helper
{
/**
* The current option
*
* @var String
* @since 3.0.11
*/
public static $option;
/**
* The component params list cache
*
* @var Registry[]
* @since 3.0.11
*/
protected static $params = array();
/**
* Gets the parameter object for the component
*
* @param String $option The option for the component.
*
* @return Registry A Registry object.
*
* @see Registry
* @since 3.0.11
*/
public static function getParams($option = null)
{
// check that we have an option
if (empty($option))
{
$option = self::getOption();
}
// get global value
if (!isset(self::$params[$option]) || !self::$params[$option] instanceof
Registry)
{
self::$params[$option] = ComponentHelper::getParams($option);
}
return self::$params[$option];
}
/**
* Gets the component option
*
* @param String|Bool $default The default return value if none is
found
*
* @return String|Bool A component option
*
* @since 3.0.11
*/
public static function getOption($default = 'empty')
{
if (empty(self::$option))
{
// get the option from the url input
self::$option = (new Input)->getString('option', false);
}
if (self::$option)
{
return self::$option;
}
return $default;
}
/**
* Gets the component code name
*
* @param String $option The option for the component.
* @param String|Bool $default The default return value if none is
found
*
* @return String|Mixed A component code name
*
* @since 3.0.11
*/
public static function getCode($option = null, $default = null)
{
// check that we have an option
if (empty($option))
{
$option = self::getOption();
}
// option with com_
if (is_string($option) && strpos($option, 'com_') ===
0)
{
return strtolower(trim(substr($option, 4)));
}
return $default;
}
/**
* Gets the component abstract helper class
*
* @param String $option The option for the component.
* @param String|Bool $default The default return value if none is
found
*
* @return String|Mixed A component helper name
*
* @since 3.0.11
*/
public static function get($option = null, $default = null)
{
// check that we have an option
// and get the code name from it
if (($code_name = self::getCode($option, false)) !== false)
{
// we build the helper class name
$helper_name = '\\' . \ucfirst($code_name) .
'Helper';
// check if class exist
if (class_exists($helper_name))
{
return $helper_name;
}
}
return $default;
}
/**
* Check if the helper class of this component has a method
*
* @param String $method The method name to search for
* @param String $option The option for the component.
*
* @return bool true if method exist
*
* @since 3.0.11
*/
public static function methodExists($method, $option = null)
{
// get the helper class
if (($helper = self::get($option, false)) !== false)
{
if (method_exists($helper, $method))
{
return true;
}
}
return false;
}
}
PK�{�[�#o,,-VDM.Joomla/src/Utilities/Component/index.htmlnu�[���<html><body
bgcolor="#FFFFFF"></body></html>PK�{�[Zl�!�!'VDM.Joomla/src/Utilities/FileHelper.phpnu�[���<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe
<http://www.joomlacomponentbuilder.com>
* @gitea Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @github Joomla Component Builder
<https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Utilities;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
use Joomla\Archive\Archive;
use VDM\Joomla\Utilities\Component\Helper;
/**
* File helper
*
* @since 3.0.9
*/
abstract class FileHelper
{
/**
* Trigger error notice only once
*
* @var bool
*
* @since 3.0.9
*/
protected static $curlError = false;
/**
* The zipper method
*
* @param string $workingDirectory The directory where the items
must be zipped
* @param string $filepath The path to where the zip file must
be placed
*
* @return bool true On success
*
* @since 3.0.9
*/
public static function zip($workingDirectory, &$filepath)
{
// store the current joomla working directory
$joomla = getcwd();
// we are changing the working directory to the component temp folder
chdir($workingDirectory);
// the full file path of the zip file
$filepath = Path::clean($filepath);
// delete an existing zip file (or use an exclusion parameter in
Folder::files()
File::delete($filepath);
// get a list of files in the current directory tree (also the hidden
files)
$files = Folder::files('.', '', true, true,
array('.svn', 'CVS', '.DS_Store',
'__MACOSX'), array('.*~'));
$zipArray = array();
// setup the zip array
foreach ($files as $file)
{
$tmp = array();
$tmp['name'] = str_replace('./', '',
$file);
$tmp['data'] = self::getContent($file);
$tmp['time'] = filemtime($file);
$zipArray[] = $tmp;
}
// change back to joomla working directory
chdir($joomla);
// get the zip adapter
$adapter = new Archive();
$zip = $adapter->getAdapter('zip');
//create the zip file
if ($zip->create($filepath, $zipArray))
{
return true;
}
return false;
}
/**
* get the content of a file
*
* @param string $path The path to the file
* @param string/bool $none The return value if no content was found
*
* @return string On success
*
* @since 3.0.9
*/
public static function getContent($path, $none = '')
{
if (StringHelper::check($path))
{
// use basic file get content for now
if (($content = @file_get_contents($path)) !== FALSE)
{
return $content;
}
// use curl if available
elseif (function_exists('curl_version'))
{
// start curl
$ch = curl_init();
// set the options
$options = array();
$options[CURLOPT_URL] = $path;
$options[CURLOPT_USERAGENT] = 'Mozilla/5.0 (Windows; U; Windows NT
6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12';
$options[CURLOPT_RETURNTRANSFER] = TRUE;
$options[CURLOPT_SSL_VERIFYPEER] = FALSE;
// load the options
curl_setopt_array($ch, $options);
// get the content
$content = curl_exec($ch);
// close the connection
curl_close($ch);
// return if found
if (StringHelper::check($content))
{
return $content;
}
}
elseif (!self::$curlError)
{
// set the notice
Factory::getApplication()->enqueueMessage(Text::_('COM_COMPONENTBUILDER_HTWOCURL_NOT_FOUNDHTWOPPLEASE_SETUP_CURL_ON_YOUR_SYSTEM_OR_BCOMPONENTBUILDERB_WILL_NOT_FUNCTION_CORRECTLYP'),
'Error');
// load this notice only once
self::$curlError = true;
}
}
return $none;
}
/**
* Write a file to the server
*
* @param string $path The path and file name where to safe the
data
* @param string $data The data to safe
*
* @return bool true On success
*
* @since 3.0.9
*/
public static function write($path, $data)
{
$klaar = false;
if (StringHelper::check($data))
{
// open the file
$fh = fopen($path, "w");
if (!is_resource($fh))
{
return $klaar;
}
// write to the file
if (fwrite($fh, $data))
{
// has been done
$klaar = true;
}
// close file.
fclose($fh);
}
return $klaar;
}
/**
* get all the file paths in folder and sub folders
*
* @param string $folder The local path to parse
* @param array $fileTypes The type of files to get
*
* @return void
*
* @since 3.0.9
*/
public static function getPaths($folder, $fileTypes =
array('\.php', '\.js', '\.css',
'\.less'), $recurse = true, $full = true)
{
if (Folder::exists($folder))
{
// we must first store the current woking directory
$joomla = getcwd();
// we are changing the working directory to the component path
chdir($folder);
// make sure we have file type filter
if (ArrayHelper::check($fileTypes))
{
// get the files
foreach ($fileTypes as $type)
{
// get a list of files in the current directory tree
$files[] = Folder::files('.', $type, $recurse, $full);
}
}
elseif (StringHelper::check($fileTypes))
{
// get a list of files in the current directory tree
$files[] = Folder::files('.', $fileTypes, $recurse, $full);
}
else
{
// get a list of files in the current directory tree
$files[] = Folder::files('.', '.', $recurse,
$full);
}
// change back to Joomla working directory
chdir($joomla);
// return array of files
return array_map( function($file) { return str_replace('./',
'/', $file); }, (array) ArrayHelper::merge($files));
}
return false;
}
/**
* Get the file path or url
*
* @param string $type The (url/path) type to return
* @param string $target The Params Target name (if set)
* @param string $fileType The kind of filename to generate
(if not set no file name is generated)
* @param string $key The key to adjust the filename (if
not set ignored)
* @param string $default The default path if not set in
Params (fallback path)
* @param bool $createIfNotSet The switch to create the folder if
not found
*
* @return string On success the path or url is returned based on the
type requested
*
* @since 3.0.9
*/
public static function getPath($type = 'path', $target =
'filepath', $fileType = null, $key = '', $default =
'', $createIfNotSet = true)
{
// make sure to always have a string/path
if(!StringHelper::check($default))
{
$default = JPATH_SITE . '/images/';
}
// get the global settings
$filePath = Helper::getParams()->get($target, $default);
// check the file path (revert to default only of not a hidden file
path)
if ('hiddenfilepath' !== $target && strpos($filePath,
JPATH_SITE) === false)
{
$filePath = $default;
}
// create the folder if it does not exist
if ($createIfNotSet && !Folder::exists($filePath))
{
Folder::create($filePath);
}
// setup the file name
$fileName = '';
// Get basic key
$basickey = 'Th!s_iS_n0t_sAfe_buT_b3tter_then_n0thiug';
// get the component helper
$helper = Helper::get();
// check if method exist in helper class
if ($helper && Helper::methodExists('getCryptKey'))
{
$basickey = $helper::getCryptKey('basic', $basickey);
}
// check the key
if (!StringHelper::check($key))
{
$key = 'vDm';
}
// set the file name
if (StringHelper::check($fileType))
{
// set the name
$fileName = trim( md5($type . $target . $basickey . $key) .
'.' . trim($fileType, '.'));
}
else
{
$fileName = trim( md5($type . $target . $basickey . $key)) .
'.txt';
}
// return the url
if ('url' === $type)
{
if (\strpos($filePath, JPATH_SITE) !== false)
{
$filePath = trim( str_replace( JPATH_SITE, '', $filePath),
'/');
return Uri::root() . $filePath . '/' . $fileName;
}
// since the path is behind the root folder of the site, return only the
root url (may be used to build the link)
return Uri::root();
}
// sanitize the path
return '/' . trim( $filePath, '/' ) . '/' .
$fileName;
}
}
PK�{�[�?i�^^&VDM.Joomla/src/Utilities/GetHelper.phpnu�[���<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe
<http://www.joomlacomponentbuilder.com>
* @gitea Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @github Joomla Component Builder
<https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Utilities;
use Joomla\CMS\Factory;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Some easy get...
*
* @since 3.0.9
*/
abstract class GetHelper
{
/**
* Get a Variable
*
* @param string $table The table from which to get the
variable
* @param string $where The value where
* @param string $whereString The target/field string where/name
* @param string $what The return field
* @param string $operator The operator between $whereString/field
and $where/value
* @param string $main The component in which the table is
found
*
* @return mix string/int/float
*
* @since 3.0.9
*/
public static function var($table, $where = null, $whereString =
'user', $what = 'id', $operator = '=', $main
= null)
{
if(empty($where))
{
$where = Factory::getUser()->id;
}
if(empty($main))
{
$main = Helper::getCode();
}
// Get a db connection.
$db = Factory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__' . $main));
}
else
{
$query->from($db->quoteName('#__' . $main .
'_' . $table));
}
if (is_numeric($where))
{
$query->where($db->quoteName($whereString) . ' ' .
$operator . ' ' . (int) $where);
}
elseif (is_string($where))
{
$query->where($db->quoteName($whereString) . ' ' .
$operator . ' ' . $db->quote((string)$where));
}
else
{
return false;
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
return $db->loadResult();
}
return false;
}
/**
* Get array of variables
*
* @param string $table The table from which to get the
variables
* @param string $where The value where
* @param string $whereString The target/field string where/name
* @param string $what The return field
* @param string $operator The operator between $whereString/field
and $where/value
* @param string $main The component in which the table is
found
* @param bool $unique The switch to return a unique array
*
* @return array
*
* @since 3.0.9
*/
public static function vars($table, $where = null, $whereString =
'user', $what = 'id', $operator = 'IN', $main
= null, $unique = true)
{
if(empty($where))
{
$where = Factory::getUser()->id;
}
if(is_null($main))
{
$main = Helper::getCode();
}
if (!ArrayHelper::check($where) && $where > 0)
{
$where = array($where);
}
if (ArrayHelper::check($where))
{
// prep main <-- why? well if $main='' is empty then $table
can be categories or users
if (StringHelper::check($main))
{
$main = '_' . ltrim($main, '_');
}
// Get a db connection.
$db = Factory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array($what)));
if (empty($table))
{
$query->from($db->quoteName('#__' . $main));
}
else
{
$query->from($db->quoteName('#_' . $main .
'_' . $table));
}
// add strings to array search
if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS'
=== $operator)
{
$query->where($db->quoteName($whereString) . ' ' .
str_replace('_STRINGS', '', $operator) . '
("' . implode('","',$where) .
'")');
}
else
{
$query->where($db->quoteName($whereString) . ' ' .
$operator . ' (' . implode(',',$where) .
')');
}
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
if ($unique)
{
return array_unique($db->loadColumn());
}
return $db->loadColumn();
}
}
return false;
}
/**
* get all strings between two other strings
*
* @param string $content The content to search
* @param string $start The starting value
* @param string $end The ending value
*
* @return array On success
*
* @since 3.0.9
*/
public static function allBetween($content, $start, $end)
{
// reset bucket
$bucket = array();
for ($i = 0; ; $i++)
{
// search for string
$found = self::between($content,$start,$end);
if (StringHelper::check($found))
{
// add to bucket
$bucket[] = $found;
// build removal string
$remove = $start.$found.$end;
// remove from content
$content = str_replace($remove,'',$content);
}
else
{
break;
}
// safety catch
if ($i == 500)
{
break;
}
}
// only return unique array of values
return array_unique($bucket);
}
/**
* get a string between two other strings
*
* @param string $content The content to search
* @param string $start The starting value
* @param string $end The ending value
* @param string $default The default value if none found
*
* @return string On success / empty string on failure
*
* @since 3.0.9
*/
public static function between($content, $start, $end, $default =
'')
{
$r = explode($start, $content);
if (isset($r[1]))
{
$r = explode($end, $r[1]);
return $r[0];
}
return $default;
}
}
PK�{�[�bi�'VDM.Joomla/src/Utilities/GuidHelper.phpnu�[���<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe
<http://www.joomlacomponentbuilder.com>
* @gitea Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @github Joomla Component Builder
<https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Utilities;
use Joomla\CMS\Factory;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Global Unique ID Helper
*
* @since 3.0.9
*/
abstract class GuidHelper
{
/**
* Returns a GUIDv4 string
*
* Thanks to Dave Pearson (and other)
* https://www.php.net/manual/en/function.com-create-guid.php#119168
*
* Uses the best cryptographically secure method
* for all supported platforms with fallback to an older,
* less secure version.
*
* @param bool $trim
*
* @return string
*
* @since 3.0.9
*/
public static function get($trim = true)
{
// Windows
if (function_exists('com_create_guid') === true)
{
if ($trim === true)
{
return trim(com_create_guid(), '{}');
}
return com_create_guid();
}
// set the braces if needed
$lbrace = $trim ? "" : chr(123); // "{"
$rbrace = $trim ? "" : chr(125); // "}"
// OSX/Linux
if (function_exists('openssl_random_pseudo_bytes') === true)
{
$data = openssl_random_pseudo_bytes(16);
$data[6] = chr( ord($data[6]) & 0x0f | 0x40); // set version to
0100
$data[8] = chr( ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to
10
return $lbrace . vsprintf('%s%s-%s-%s-%s-%s%s%s',
str_split(bin2hex($data), 4)) . $lbrace;
}
// Fallback (PHP 4.2+)
mt_srand((double) microtime() * 10000);
$charid = strtolower( md5( uniqid( rand(), true)));
$hyphen = chr(45); // "-"
$guidv4 = $lbrace.
substr($charid, 0, 8). $hyphen.
substr($charid, 8, 4). $hyphen.
substr($charid, 12, 4). $hyphen.
substr($charid, 16, 4). $hyphen.
substr($charid, 20, 12).
$rbrace;
return $guidv4;
}
/**
* Validate the Globally Unique Identifier ( and check if table already
has this identifier)
*
* @param string $guid
* @param string $table
* @param int $id
* @param string|null $component
*
* @return bool
*
* @since 3.0.9
*/
public static function valid($guid, $table = null, $id = 0, $component =
null)
{
// check if we have a string
if (self::validate($guid))
{
// check if table already has this identifier
if (StringHelper::check($table))
{
// check that we have the component code name
if (!is_string($component))
{
$component = (string) Helper::getCode();
}
// Get the database object and a new query object.
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query->select('COUNT(*)')
->from('#__' . (string) $component . '_' .
(string) $table)
->where($db->quoteName('guid') . ' = ' .
$db->quote($guid));
// remove this item from the list
if ($id > 0)
{
$query->where($db->quoteName('id') . ' <>
' . (int) $id);
}
// Set and query the database.
$db->setQuery($query);
$duplicate = (bool) $db->loadResult();
if ($duplicate)
{
return false;
}
}
return true;
}
return false;
}
/**
* get the item by guid in a table
*
* @param string $guid
* @param string $table
* @param string/array $what
* @param string|null $component
*
* @return mix
*
* @since 3.0.9
*/
public static function item($guid, $table, $what = 'a.id',
$component = null)
{
// check if we have a string
if (self::validate($guid))
{
// check if table already has this identifier
if (StringHelper::check($table))
{
// check that we have the component code name
if (!is_string($component))
{
$component = (string) Helper::getCode();
}
// Get the database object and a new query object.
$db = Factory::getDbo();
$query = $db->getQuery(true);
if (ArrayHelper::check($what))
{
$query->select($db->quoteName($what));
}
else
{
$query->select($what);
}
$query->from($db->quoteName('#__' . (string) $component
. '_' . (string) $table, 'a'))
->where($db->quoteName('a.guid') . ' = ' .
$db->quote($guid));
// Set and query the database.
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
if (ArrayHelper::check($what) || $what === 'a.*')
{
return $db->loadObject();
}
else
{
return $db->loadResult();
}
}
}
}
return false;
}
/**
* Validate the Globally Unique Identifier
*
* Thanks to Lewie
* https://stackoverflow.com/a/1515456/1429677
*
* @param string $guid
*
* @return bool
*
* @since 3.0.9
*/
protected static function validate($guid)
{
// check if we have a string
if (StringHelper::check($guid))
{
return
preg_match("/^(\{)?[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}(?(1)\})$/i",
$guid);
}
return false;
}
}
PK�{�[�3
��'VDM.Joomla/src/Utilities/JsonHelper.phpnu�[���<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe
<http://www.joomlacomponentbuilder.com>
* @gitea Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @github Joomla Component Builder
<https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Utilities;
/**
* The json checker
*
* @since 3.0.9
*/
abstract class JsonHelper
{
/**
* Check if you have a json string
*
* @input string $string The json string to check
*
* @returns bool true on success
*
* @since 3.0.9
*/
public static function check($string): bool
{
if (StringHelper::check($string))
{
json_decode($string);
return (json_last_error() === JSON_ERROR_NONE);
}
return false;
}
/**
* Convert a json object to a string
*
* @input string $value The json string to convert
*
* @returns a string
*
* @since 3.0.9
*/
public static function string($value, $separator = ", ", $table
= null, $id = 'id', $name = 'name')
{
// do some table foot work
$external = false;
if (strpos($table, '#__') !== false)
{
$external = true;
$table = str_replace('#__', '', $table);
}
// check if string is JSON
$result = json_decode($value, true);
if (json_last_error() === JSON_ERROR_NONE)
{
// is JSON
if (ArrayHelper::check($result))
{
if (StringHelper::check($table))
{
$names = array();
foreach ($result as $val)
{
if ($external)
{
if ($_name = GetHelper::var(null, $val, $id, $name, '=',
$table))
{
$names[] = $_name;
}
}
else
{
if ($_name = GetHelper::var($table, $val, $id, $name))
{
$names[] = $_name;
}
}
}
if (ArrayHelper::check($names))
{
return (string) implode($separator, $names);
}
}
return (string) implode($separator, $result);
}
return (string) json_decode($value);
}
return $value;
}
}
PK�{�[Dk9�6
6
'VDM.Joomla/src/Utilities/MathHelper.phpnu�[���<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe
<http://www.joomlacomponentbuilder.com>
* @gitea Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @github Joomla Component Builder
<https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Utilities;
/**
* Basic Math Helper
*
* @since 3.0.9
*/
abstract class MathHelper
{
/**
* bc math wrapper (very basic not for accounting)
*
* @param string $type The type bc math
* @param int $val1 The first value
* @param int $val2 The second value
* @param int $scale The scale value
*
* @return int
*
* @since 3.0.9
*/
public static function bc($type, $val1, $val2, $scale = 0)
{
// build function name
$function = 'bc' . $type;
// use the bcmath function if available
if (function_exists($function))
{
return $function($val1, $val2, $scale);
}
// if function does not exist we use +-*/ operators (fallback - not
ideal)
switch ($type)
{
// Multiply two numbers
case 'mul':
return (string) round($val1 * $val2, $scale);
break;
// Divide of two numbers
case 'div':
return (string) round($val1 / $val2, $scale);
break;
// Adding two numbers
case 'add':
return (string) round($val1 + $val2, $scale);
break;
// Subtract one number from the other
case 'sub':
return (string) round($val1 - $val2, $scale);
break;
// Raise an arbitrary precision number to another
case 'pow':
return (string) round(pow($val1, $val2), $scale);
break;
// Compare two arbitrary precision numbers
case 'comp':
return (round($val1,2) == round($val2,2));
break;
}
return false;
}
/**
* Basic sum of an array with more precision
*
* @param array $array The values to sum
* @param int $scale The scale value
*
* @return float
*
* @since 3.0.9
*/
public static function sum($array, $scale = 4)
{
// use the bcadd function if available
if (function_exists('bcadd'))
{
// set the start value
$value = 0.0;
// loop the values and run bcadd
foreach($array as $val)
{
$value = bcadd($value, $val, $scale);
}
return $value;
}
// fall back on array sum
return array_sum($array);
}
}
PK�{�[O�'/��)VDM.Joomla/src/Utilities/ObjectHelper.phpnu�[���<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe
<http://www.joomlacomponentbuilder.com>
* @gitea Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @github Joomla Component Builder
<https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Utilities;
/**
* Some object tricks
*
* @since 3.0.9
*/
abstract class ObjectHelper
{
/**
* Check if have an object with a length
*
* @input object The object to check
*
* @returns bool true on success
*
* @since 3.0.9
*/
public static function check($object)
{
if (is_object($object))
{
return count((array) $object) > 0;
}
return false;
}
}
PK�{�[�
����7VDM.Joomla/src/Utilities/String/ClassfunctionHelper.phpnu�[���<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe
<http://www.joomlacomponentbuilder.com>
* @gitea Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @github Joomla Component Builder
<https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Utilities\String;
use VDM\Joomla\Utilities\StringHelper;
/**
* Control the naming of a class and function
*
* @since 3.0.9
*/
abstract class ClassfunctionHelper
{
/**
* Making class or function name safe
*
* @input string The name you would like to make safe
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safe($name)
{
// remove numbers if the first character is a number
if (is_numeric(substr($name, 0, 1)))
{
$name = StringHelper::numbers($name);
}
// remove all spaces and strange characters
return trim(preg_replace("/[^A-Za-z0-9_-]/", '',
$name));
}
}
PK�{�[?� 4
4
/VDM.Joomla/src/Utilities/String/FieldHelper.phpnu�[���<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe
<http://www.joomlacomponentbuilder.com>
* @gitea Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @github Joomla Component Builder
<https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Utilities\String;
use Joomla\CMS\Component\ComponentHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Control the naming of a field
*
* @since 3.0.9
*/
abstract class FieldHelper
{
/**
* The field builder switch
*
* @since 3.0.9
*/
protected static $builder = false;
/**
* Making field names safe
*
* @input string The string you would like to make safe
* @input boolean The switch to return an ALL UPPER CASE string
* @input string The string to use in white space
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safe($string, $allcap = false, $spacer =
'_')
{
// get global value
if (self::$builder === false)
{
self::$builder =
Helper::getParams()->get('field_name_builder', 1);
}
// use the new convention
if (2 == self::$builder)
{
// 0nly continue if we have a string
if (StringHelper::check($string))
{
// check that the first character is not a number
if (is_numeric(substr($string, 0, 1)))
{
$string = StringHelper::numbers($string);
}
// remove all other strange characters
$string = trim($string);
$string = preg_replace('/'.$spacer.'+/', '
', $string);
$string = preg_replace('/\s+/', ' ', $string);
// Transliterate string
$string = StringHelper::transliterate($string);
// remove all and keep only characters and numbers
$string = preg_replace("/[^A-Za-z0-9 ]/", '',
$string);
// replace white space with underscore (SAFEST OPTION)
$string = preg_replace('/\s+/', $spacer, $string);
// return all caps
if ($allcap)
{
return strtoupper($string);
}
// default is to return lower
return strtolower($string);
}
// not a string
return '';
}
// return all caps
if ($allcap)
{
return StringHelper::safe($string, 'U');
}
// use the default (original behavior/convention)
return StringHelper::safe($string);
}
}
PK�{�[oЩ?,,3VDM.Joomla/src/Utilities/String/NamespaceHelper.phpnu�[���<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe
<http://www.joomlacomponentbuilder.com>
* @gitea Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @github Joomla Component Builder
<https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Utilities\String;
use VDM\Joomla\Utilities\StringHelper;
/**
* Control the naming of a namespace helper
*
* @since 3.0.9
*/
abstract class NamespaceHelper
{
/**
* Making namespace safe
*
* @input string The you would like to make safe
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safe($string)
{
// 0nly continue if we have a string
if (StringHelper::check($string))
{
// make sure it has not numbers
$string = StringHelper::numbers($string);
// Transliterate string TODO: look again as this make it lowercase
// $string = StringHelper::transliterate($string);
// first remove all [\] backslashes
$string = str_replace('\\', '1', $string);
// remove all and keep only characters and [\] backslashes inside of the
string
$string = trim( preg_replace("/[^A-Za-z1]/", '',
$string), '1');
// place the [\] backslashes back
return trim( preg_replace("/1+/", '\\', $string));
}
// not a string
return '';
}
}
PK�{�[o<9o
o
0VDM.Joomla/src/Utilities/String/PluginHelper.phpnu�[���<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe
<http://www.joomlacomponentbuilder.com>
* @gitea Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @github Joomla Component Builder
<https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Utilities\String;
/**
* Control the naming of a plugin
*
* @since 3.0.9
*/
abstract class PluginHelper
{
/**
* Making plugin folder name safe
*
* @input string $codeName The name
* @input string $group The group name
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safeFolderName($codeName, $group)
{
// editors-xtd group plugins must have a class with
plgButton<PluginName> structure
if ($group === 'editors-xtd')
{
$group = 'Button';
}
return 'plg_' . strtolower($group) . '_' .
strtolower(
$codeName
);
}
/**
* Making plugin class name safe
*
* @input string $codeName The name
* @input string $group The group name
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safeClassName($codeName, $group)
{
// editors-xtd group plugins must have a class with
plgButton<PluginName> structure
if ($group === 'editors-xtd')
{
$group = 'Button';
}
return 'Plg' . ucfirst($group) . ucfirst(
$codeName
);
}
/**
* Making plugin install class name safe
*
* @input string $codeName The name
* @input string $group The group name
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safeInstallClassName($codeName, $group)
{
// editors-xtd group plugins must have a class with
plgButton<PluginName> structure
if ($group === 'editors-xtd')
{
$group = 'Button';
}
return 'plg' . ucfirst($group) . ucfirst(
$codeName
) . 'InstallerScript';
}
/**
* Making language prefix safe
*
* @input string $codeName The name
* @input string $group The group name
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safeLangPrefix($codeName, $group)
{
// editors-xtd group plugins must have a class with
plgButton<PluginName> structure
if ($group === 'editors-xtd')
{
$group = 'Button';
}
return 'PLG_' . strtoupper($group) . '_' .
strtoupper(
$codeName
);
}
}
PK�{�[��&�WW.VDM.Joomla/src/Utilities/String/TypeHelper.phpnu�[���<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe
<http://www.joomlacomponentbuilder.com>
* @gitea Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @github Joomla Component Builder
<https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Utilities\String;
use Joomla\CMS\Component\ComponentHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Control the naming of a field type
*
* @since 3.0.9
*/
abstract class TypeHelper
{
/**
* The field builder switch
*
* @since 3.0.9
*/
protected static $builder = false;
/**
* Making field type name safe
*
* @param String $string The you would like to make safe
* @param String $option The option for the component.
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safe($string, $option = null)
{
// get global value
if (self::$builder === false)
{
self::$builder =
Helper::getParams($option)->get('type_name_builder', 1);
}
// use the new convention
if (2 == self::$builder)
{
// 0nly continue if we have a string
if (StringHelper::check($string))
{
// check that the first character is not a number
if (is_numeric(substr($string, 0, 1)))
{
$string = StringHelper::numbers($string);
}
// Transliterate string
$string = StringHelper::transliterate($string);
// remove all and keep only characters and numbers and point (TODO just
one point)
$string = trim(preg_replace("/[^A-Za-z0-9\.]/", '',
$string));
// best is to return lower (for all string equality in compiler)
return strtolower($string);
}
// not a string
return '';
}
// use the default (original behaviour/convention)
return StringHelper::safe($string);
}
}
PK�{�[�#o,,*VDM.Joomla/src/Utilities/String/index.htmlnu�[���<html><body
bgcolor="#FFFFFF"></body></html>PK�{�[�
�\'\')VDM.Joomla/src/Utilities/StringHelper.phpnu�[���<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe
<http://www.joomlacomponentbuilder.com>
* @gitea Joomla Component Builder
<https://git.vdm.dev/joomla/Component-Builder>
* @github Joomla Component Builder
<https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights
reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace VDM\Joomla\Utilities;
use Joomla\CMS\Filter\InputFilter;
use Joomla\CMS\Language\Language;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Some string tricks
*
* @since 3.0.9
*/
abstract class StringHelper
{
/**
* The Main Active Language
*
* @var string
*
* @since 3.0.9
*/
public static $langTag;
/**
* Check if we have a string with a length
*
* @input string $string The string to check
*
* @returns bool true on success
*
* @since 3.0.9
*/
public static function check($string): bool
{
if (is_string($string) && strlen($string) > 0)
{
return true;
}
return false;
}
/**
* Shorten a string
*
* @input string The you would like to shorten
*
* @returns string on success
*
* @since 3.0.9
*/
public static function shorten($string, $length = 40, $addTip = true)
{
if (self::check($string))
{
$initial = strlen($string);
$words = preg_split('/([\s\n\r]+)/', $string, null,
PREG_SPLIT_DELIM_CAPTURE);
$words_count = count((array)$words);
$word_length = 0;
$last_word = 0;
for (; $last_word < $words_count; ++$last_word)
{
$word_length += strlen($words[$last_word]);
if ($word_length > $length)
{
break;
}
}
$newString = implode(array_slice($words, 0, $last_word));
$final = strlen($newString);
if ($initial != $final && $addTip)
{
$title = self::shorten($string, 400 , false);
return '<span class="hasTip" title="' .
$title . '" style="cursor:help">' .
trim($newString) . '...</span>';
}
elseif ($initial != $final && !$addTip)
{
return trim($newString) . '...';
}
}
return $string;
}
/**
* Making strings safe (various ways)
*
* @input string The you would like to make safe
*
* @returns string on success
*
* @since 3.0.9
*/
public static function safe($string, $type = 'L', $spacer =
'_', $replaceNumbers = true, $keepOnlyCharacters = true)
{
if ($replaceNumbers === true)
{
// remove all numbers and replace with english text version (works well
only up to millions)
$string = self::numbers($string);
}
// 0nly continue if we have a string
if (self::check($string))
{
// create file name without the extension that is safe
if ($type === 'filename')
{
// make sure VDM is not in the string
$string = str_replace('VDM', 'vDm', $string);
// Remove anything which isn't a word, whitespace, number
// or any of the following caracters -_()
// If you don't need to handle multi-byte characters
// you can use preg_replace rather than mb_ereg_replace
// Thanks @Łukasz Rysiak!
// $string = mb_ereg_replace("([^\w\s\d\-_\(\)])",
'', $string);
$string = preg_replace("([^\w\s\d\-_\(\)])", '',
$string);
// http://stackoverflow.com/a/2021729/1429677
return preg_replace('/\s+/', ' ', $string);
}
// remove all other characters
$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)
{
$string = preg_replace("/[^A-Za-z ]/", '',
$string);
}
// keep both numbers and characters
else
{
$string = preg_replace("/[^A-Za-z0-9 ]/", '',
$string);
}
// select final adaptations
if ($type === 'L' || $type === 'strtolower')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// default is to return lower
return strtolower($string);
}
elseif ($type === 'W')
{
// return a string with all first letter of each word uppercase(no
underscore)
return ucwords(strtolower($string));
}
elseif ($type === 'w' || $type === 'word')
{
// return a string with all lowercase(no underscore)
return strtolower($string);
}
elseif ($type === 'Ww' || $type === 'Word')
{
// return a string with first letter of the first word uppercase and
all the rest lowercase(no underscore)
return ucfirst(strtolower($string));
}
elseif ($type === 'WW' || $type === 'WORD')
{
// return a string with all the uppercase(no underscore)
return strtoupper($string);
}
elseif ($type === 'U' || $type === 'strtoupper')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return all upper
return strtoupper($string);
}
elseif ($type === 'F' || $type === 'ucfirst')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return with first character to upper
return ucfirst(strtolower($string));
}
elseif ($type === 'cA' || $type === 'cAmel' || $type
=== 'camelcase')
{
// convert all words to first letter uppercase
$string = ucwords(strtolower($string));
// remove white space
$string = preg_replace('/\s+/', '', $string);
// now return first letter lowercase
return lcfirst($string);
}
// return string
return $string;
}
// not a string
return '';
}
/**
* Convert none English strings to code usable string
*
* @input an string
*
* @returns a string
*
* @since 3.0.9
*/
public static function transliterate($string)
{
// set tag only once
if (!self::check(self::$langTag))
{
// get global value
self::$langTag = Helper::getParams()->get('language',
'en-GB');
}
// Transliterate on the language requested
$lang = Language::getInstance(self::$langTag);
return $lang->transliterate($string);
}
/**
* make sure a string is HTML save
*
* @input an html string
*
* @returns a string
*
* @since 3.0.9
*/
public static function html($var, $charset = 'UTF-8', $shorten =
false, $length = 40)
{
if (self::check($var))
{
$filter = new InputFilter();
$string = $filter->clean(
html_entity_decode(
htmlentities(
$var,
ENT_COMPAT,
$charset
)
),
'HTML'
);
if ($shorten)
{
return self::shorten($string, $length);
}
return $string;
}
else
{
return '';
}
}
/**
* Convert all int in a string to an English word string
*
* @input an string with numbers
*
* @returns a string
*
* @since 3.0.9
*/
public static function numbers($string)
{
// set numbers array
$numbers = array();
// first get all numbers
preg_match_all('!\d+!', $string, $numbers);
// check if we have any numbers
if (isset($numbers[0]) && ArrayHelper::check($numbers[0]))
{
foreach ($numbers[0] as $number)
{
$searchReplace[$number] = self::number((int)$number);
}
// now replace numbers in string
$string = str_replace(array_keys($searchReplace),
array_values($searchReplace), $string);
// check if we missed any, strange if we did.
return self::numbers($string);
}
// return the string with no numbers remaining.
return $string;
}
/**
* Convert an integer into an English word string
* Thanks to Tom Nicholson
<http://php.net/manual/en/function.strval.php#41988>
*
* @input an int
* @returns a string
*
* @since 3.0.9
*/
public static function number($x)
{
$nwords = array( "zero", "one", "two",
"three", "four", "five", "six",
"seven",
"eight", "nine", "ten",
"eleven", "twelve", "thirteen",
"fourteen", "fifteen", "sixteen",
"seventeen", "eighteen",
"nineteen", "twenty", 30 => "thirty",
40 => "forty",
50 => "fifty", 60 => "sixty", 70 =>
"seventy", 80 => "eighty",
90 => "ninety" );
if(!is_numeric($x))
{
$w = $x;
}
elseif(fmod($x, 1) != 0)
{
$w = $x;
}
else
{
if($x < 0)
{
$w = 'minus ';
$x = -$x;
}
else
{
$w = '';
// ... now $x is a non-negative integer.
}
if($x < 21) // 0 to 20
{
$w .= $nwords[$x];
}
elseif($x < 100) // 21 to 99
{
$w .= $nwords[10 * floor($x/10)];
$r = fmod($x, 10);
if($r > 0)
{
$w .= ' ' . $nwords[$r];
}
}
elseif($x < 1000) // 100 to 999
{
$w .= $nwords[floor($x/100)] .' hundred';
$r = fmod($x, 100);
if($r > 0)
{
$w .= ' and '. self::number($r);
}
}
elseif($x < 1000000) // 1000 to 999999
{
$w .= self::number(floor($x/1000)) .' thousand';
$r = fmod($x, 1000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::number($r);
}
}
else // millions
{
$w .= self::number(floor($x/1000000)) .' million';
$r = fmod($x, 1000000);
if($r > 0)
{
$w .= ' ';
if($r < 100)
{
$w .= 'and ';
}
$w .= self::number($r);
}
}
}
return $w;
}
/**
* Random Key
*
* @returns a string
*
* @since 3.0.9
*/
public static function random($size)
{
$bag =
"abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ";
$key = array();
$bagsize = strlen($bag) - 1;
for ($i = 0; $i < $size; $i++)
{
$get = rand(0, $bagsize);
$key[] = $bag[$get];
}
return implode($key);
}
}
PK�{�[�#o,,#VDM.Joomla/src/Utilities/index.htmlnu�[���<html><body
bgcolor="#FFFFFF"></body></html>PK�{�[-
�֖�htaccess.txtnu�[���# Apache 2.4+
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
# Apache 2.0-2.2
<IfModule !mod_authz_core.c>
Deny from all
</IfModule>
PK�{�[�#o,,
index.htmlnu�[���<html><body
bgcolor="#FFFFFF"></body></html>PK�{�[�3Ϛ�
web.confignu�[���<?xml version="1.0"?>
<system.web>
<authorization>
<deny users="*" />
</authorization>
</system.web>
</configuration>
PK�{�[-
�֖� .htaccessnu�[���PK�{�[�#o,,�VDM.Joomla/index.htmlnu�[���PK�{�[=I�4�D�D@VDM.Joomla/src/Utilities.phpnu�[���PK�{�[|`���(cFVDM.Joomla/src/Utilities/ArrayHelper.phpnu�[���PK�{�[�j�7��-rMVDM.Joomla/src/Utilities/Component/Helper.phpnu�[���PK�{�[�#o,,-�]VDM.Joomla/src/Utilities/Component/index.htmlnu�[���PK�{�[Zl�!�!'
^VDM.Joomla/src/Utilities/FileHelper.phpnu�[���PK�{�[�?i�^^&N�VDM.Joomla/src/Utilities/GetHelper.phpnu�[���PK�{�[�bi�'�VDM.Joomla/src/Utilities/GuidHelper.phpnu�[���PK�{�[�3
��'d�VDM.Joomla/src/Utilities/JsonHelper.phpnu�[���PK�{�[Dk9�6
6
'��VDM.Joomla/src/Utilities/MathHelper.phpnu�[���PK�{�[O�'/��)2�VDM.Joomla/src/Utilities/ObjectHelper.phpnu�[���PK�{�[�
����74�VDM.Joomla/src/Utilities/String/ClassfunctionHelper.phpnu�[���PK�{�[?�
4
4
/B�VDM.Joomla/src/Utilities/String/FieldHelper.phpnu�[���PK�{�[oЩ?,,3��VDM.Joomla/src/Utilities/String/NamespaceHelper.phpnu�[���PK�{�[o<9o
o
0d�VDM.Joomla/src/Utilities/String/PluginHelper.phpnu�[���PK�{�[��&�WW.3�VDM.Joomla/src/Utilities/String/TypeHelper.phpnu�[���PK�{�[�#o,,*��VDM.Joomla/src/Utilities/String/index.htmlnu�[���PK�{�[�
�\'\')n�VDM.Joomla/src/Utilities/StringHelper.phpnu�[���PK�{�[�#o,,##VDM.Joomla/src/Utilities/index.htmlnu�[���PK�{�[-
�֖��htaccess.txtnu�[���PK�{�[�#o,,
tindex.htmlnu�[���PK�{�[�3Ϛ�
�web.confignu�[���PK��