Fixed changelog direction so newest changes is listed at top of the file. Finished the init function of super powers. Adds rest function inside super power. Adds super powers to all templates. Updates many helper class methods to now use the utility classes. Adds the method to the component entry file (as-well). Moved most methods from the compiler fields class to powers. #955 Refactored many new builder classes from the registry class. Converted the Content class to two builder classes. Adds option to add additional templates to a module. Resolves #1002 by adding STRING instead of WORD. Ported the FOF encryption class into Powers. https://git.vdm.dev/joomla/fof Changed all CSS and JS to use instead of in compiler code. Adds option to turn jQuery off if UIKIT 3 is added. Adds option to auto write injection boilerplate code in Powers area. Adds option to auto write service provider boilerplate code in the Powers area. Improved the method and all banner locations to fetch from https://git.vdm.dev/joomla/jcb-external/ instead. Major stability improvements all over the new powers complier classes. New [base Registry class](https://git.vdm.dev/joomla/super-powers/src/branch/master/src/7e822c03-1b20-41d1-9427-f5b8d5836af7) has been created specially for JCB. Remember to update all plug-ins with this version update (use the package).
This commit is contained in:
300
libraries/jcb_powers/VDM.Joomla.FOF/src/Encrypt/AES.php
Normal file
300
libraries/jcb_powers/VDM.Joomla.FOF/src/Encrypt/AES.php
Normal file
@ -0,0 +1,300 @@
|
||||
<?php
|
||||
/**
|
||||
* @package FrameworkOnFramework
|
||||
* @subpackage Encryption
|
||||
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
|
||||
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
|
||||
* - Do not use this in new projects.
|
||||
* - Expect no updates.
|
||||
* - This is outdated.
|
||||
* - Not best choice for encryption.
|
||||
* - Use phpseclib/phpseclib version 3 Instead.
|
||||
* - Checkout the JCB Crypt Suite. <https://git.vdm.dev/joomla/phpseclib>
|
||||
*/
|
||||
namespace VDM\Joomla\FOF\Encrypt;
|
||||
|
||||
|
||||
use VDM\Joomla\FOF\Encrypt\AES\AesInterface;
|
||||
use VDM\Joomla\FOF\Encrypt\AES\Mcrypt;
|
||||
use VDM\Joomla\FOF\Encrypt\AES\Openssl;
|
||||
use VDM\Joomla\FOF\Utils\Phpfunc;
|
||||
|
||||
|
||||
/**
|
||||
* AES encryption class
|
||||
*
|
||||
* @package FrameworkOnFramework
|
||||
* @since 1.0
|
||||
* @deprecated Use phpseclib/phpseclib version 3 Instead.
|
||||
*/
|
||||
class AES
|
||||
{
|
||||
/**
|
||||
* The cipher key.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $key = '';
|
||||
|
||||
/**
|
||||
* The AES encryption adapter in use.
|
||||
*
|
||||
* @var AesInterface
|
||||
*/
|
||||
protected $adapter;
|
||||
|
||||
/**
|
||||
* Initialise the AES encryption object.
|
||||
*
|
||||
* Note: If the key is not 16 bytes this class will do a stupid key expansion for legacy reasons (produce the
|
||||
* SHA-256 of the key string and throw away half of it).
|
||||
*
|
||||
* @param string $key The encryption key (password). It can be a raw key (16 bytes) or a passphrase.
|
||||
* @param int $strength Bit strength (128, 192 or 256) – ALWAYS USE 128 BITS. THIS PARAMETER IS DEPRECATED.
|
||||
* @param string $mode Encryption mode. Can be ebc or cbc. We recommend using cbc.
|
||||
* @param Phpfunc $phpfunc For testing
|
||||
* @param string $priority Priority which adapter we should try first
|
||||
*/
|
||||
public function __construct($key, $strength = 128, $mode = 'cbc', Phpfunc $phpfunc = null, $priority = 'openssl')
|
||||
{
|
||||
if ($priority == 'openssl')
|
||||
{
|
||||
$this->adapter = new Openssl();
|
||||
|
||||
if (!$this->adapter->isSupported($phpfunc))
|
||||
{
|
||||
$this->adapter = new Mcrypt();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->adapter = new Mcrypt();
|
||||
|
||||
if (!$this->adapter->isSupported($phpfunc))
|
||||
{
|
||||
$this->adapter = new Openssl();
|
||||
}
|
||||
}
|
||||
|
||||
$this->adapter->setEncryptionMode($mode, $strength);
|
||||
$this->setPassword($key, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the password for this instance.
|
||||
*
|
||||
* WARNING: Do not use the legacy mode, it's insecure
|
||||
*
|
||||
* @param string $password The password (either user-provided password or binary encryption key) to use
|
||||
* @param bool $legacyMode True to use the legacy key expansion. We recommend against using it.
|
||||
*/
|
||||
public function setPassword($password, $legacyMode = false)
|
||||
{
|
||||
$this->key = $password;
|
||||
|
||||
$passLength = strlen($password);
|
||||
|
||||
if (function_exists('mb_strlen'))
|
||||
{
|
||||
$passLength = mb_strlen($password, 'ASCII');
|
||||
}
|
||||
|
||||
// Legacy mode was doing something stupid, requiring a key of 32 bytes. DO NOT USE LEGACY MODE!
|
||||
if ($legacyMode && ($passLength != 32))
|
||||
{
|
||||
// Legacy mode: use the sha256 of the password
|
||||
$this->key = hash('sha256', $password, true);
|
||||
// We have to trim or zero pad the password (we end up throwing half of it away in Rijndael-128 / AES...)
|
||||
$this->key = $this->adapter->resizeKey($this->key, $this->adapter->getBlockSize());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypts a string using AES
|
||||
*
|
||||
* @param string $stringToEncrypt The plaintext to encrypt
|
||||
* @param bool $base64encoded Should I Base64-encode the result?
|
||||
*
|
||||
* @return string The cryptotext. Please note that the first 16 bytes of
|
||||
* the raw string is the IV (initialisation vector) which
|
||||
* is necessary for decoding the string.
|
||||
*/
|
||||
public function encryptString($stringToEncrypt, $base64encoded = true)
|
||||
{
|
||||
$blockSize = $this->adapter->getBlockSize();
|
||||
$randVal = new Randval();
|
||||
$iv = $randVal->generate($blockSize);
|
||||
|
||||
$key = $this->getExpandedKey($blockSize, $iv);
|
||||
$cipherText = $this->adapter->encrypt($stringToEncrypt, $key, $iv);
|
||||
|
||||
// Optionally pass the result through Base64 encoding
|
||||
if ($base64encoded)
|
||||
{
|
||||
$cipherText = base64_encode((string) $cipherText);
|
||||
}
|
||||
|
||||
// Return the result
|
||||
return $cipherText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypts a ciphertext into a plaintext string using AES
|
||||
*
|
||||
* @param string $stringToDecrypt The ciphertext to decrypt. The first 16 bytes of the raw string must contain
|
||||
* the IV (initialisation vector).
|
||||
* @param bool $base64encoded Should I Base64-decode the data before decryption?
|
||||
*
|
||||
* @return string The plain text string
|
||||
*/
|
||||
public function decryptString($stringToDecrypt, $base64encoded = true)
|
||||
{
|
||||
if ($base64encoded)
|
||||
{
|
||||
$stringToDecrypt = base64_decode($stringToDecrypt);
|
||||
}
|
||||
|
||||
// Extract IV
|
||||
$iv_size = $this->adapter->getBlockSize();
|
||||
$iv = substr($stringToDecrypt, 0, $iv_size);
|
||||
$key = $this->getExpandedKey($iv_size, $iv);
|
||||
|
||||
// Decrypt the data
|
||||
$plainText = $this->adapter->decrypt($stringToDecrypt, $key);
|
||||
|
||||
return $plainText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is AES encryption supported by this PHP installation?
|
||||
*
|
||||
* @param Phpfunc $phpfunc
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isSupported(Phpfunc $phpfunc = null)
|
||||
{
|
||||
if (!is_object($phpfunc) || !($phpfunc instanceof $phpfunc))
|
||||
{
|
||||
$phpfunc = new Phpfunc();
|
||||
}
|
||||
|
||||
$adapter = new Openssl();
|
||||
|
||||
if (!$adapter->isSupported($phpfunc))
|
||||
{
|
||||
$adapter = new Mcrypt();
|
||||
|
||||
if (!$adapter->isSupported($phpfunc))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('base64_encode'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('base64_decode'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('hash_algos'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$algorightms = $phpfunc->hash_algos();
|
||||
|
||||
if (!in_array('sha256', $algorightms))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $blockSize
|
||||
* @param $iv
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExpandedKey($blockSize, $iv)
|
||||
{
|
||||
$key = $this->key;
|
||||
$passLength = strlen($key);
|
||||
|
||||
if (function_exists('mb_strlen'))
|
||||
{
|
||||
$passLength = mb_strlen($key, 'ASCII');
|
||||
}
|
||||
|
||||
if ($passLength != $blockSize)
|
||||
{
|
||||
$iterations = 1000;
|
||||
$salt = $this->adapter->resizeKey($iv, 16);
|
||||
$key = hash_pbkdf2('sha256', $this->key, $salt, $iterations, $blockSize, true);
|
||||
}
|
||||
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('hash_pbkdf2'))
|
||||
{
|
||||
function hash_pbkdf2($algo, $password, $salt, $count, $length = 0, $raw_output = false)
|
||||
{
|
||||
if (!in_array(strtolower((string) $algo), hash_algos()))
|
||||
{
|
||||
trigger_error(__FUNCTION__ . '(): Unknown hashing algorithm: ' . $algo, E_USER_WARNING);
|
||||
}
|
||||
|
||||
if (!is_numeric($count))
|
||||
{
|
||||
trigger_error(__FUNCTION__ . '(): expects parameter 4 to be long, ' . gettype($count) . ' given', E_USER_WARNING);
|
||||
}
|
||||
|
||||
if (!is_numeric($length))
|
||||
{
|
||||
trigger_error(__FUNCTION__ . '(): expects parameter 5 to be long, ' . gettype($length) . ' given', E_USER_WARNING);
|
||||
}
|
||||
|
||||
if ($count <= 0)
|
||||
{
|
||||
trigger_error(__FUNCTION__ . '(): Iterations must be a positive integer: ' . $count, E_USER_WARNING);
|
||||
}
|
||||
|
||||
if ($length < 0)
|
||||
{
|
||||
trigger_error(__FUNCTION__ . '(): Length must be greater than or equal to 0: ' . $length, E_USER_WARNING);
|
||||
}
|
||||
|
||||
$output = '';
|
||||
$block_count = $length ? ceil($length / strlen(hash((string) $algo, '', $raw_output))) : 1;
|
||||
|
||||
for ($i = 1; $i <= $block_count; $i++)
|
||||
{
|
||||
$last = $xorsum = hash_hmac((string) $algo, $salt . pack('N', $i), (string) $password, true);
|
||||
|
||||
for ($j = 1; $j < $count; $j++)
|
||||
{
|
||||
$xorsum ^= ($last = hash_hmac((string) $algo, $last, (string) $password, true));
|
||||
}
|
||||
|
||||
$output .= $xorsum;
|
||||
}
|
||||
|
||||
if (!$raw_output)
|
||||
{
|
||||
$output = bin2hex($output);
|
||||
}
|
||||
|
||||
return $length ? substr($output, 0, $length) : $output;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* @package FrameworkOnFramework
|
||||
* @subpackage Encryption
|
||||
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
|
||||
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
|
||||
* - Do not use this in new projects.
|
||||
* - Expect no updates.
|
||||
* - This is outdated.
|
||||
* - Not best choice for encryption.
|
||||
* - Use phpseclib/phpseclib version 3 Instead.
|
||||
* - Checkout the JCB Crypt Suite. <https://git.vdm.dev/joomla/phpseclib>
|
||||
*/
|
||||
namespace VDM\Joomla\FOF\Encrypt\AES;
|
||||
|
||||
|
||||
/**
|
||||
* Abstract AES encryption class
|
||||
*
|
||||
* @package FrameworkOnFramework
|
||||
* @since 1.0
|
||||
* @deprecated Use phpseclib/phpseclib version 3 Instead.
|
||||
*/
|
||||
abstract class Abstraction
|
||||
{
|
||||
/**
|
||||
* Trims or zero-pads a key / IV
|
||||
*
|
||||
* @param string $key The key or IV to treat
|
||||
* @param int $size The block size of the currently used algorithm
|
||||
*
|
||||
* @return null|string Null if $key is null, treated string of $size byte length otherwise
|
||||
*/
|
||||
public function resizeKey($key, $size)
|
||||
{
|
||||
if (empty($key))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$keyLength = strlen($key);
|
||||
|
||||
if (function_exists('mb_strlen'))
|
||||
{
|
||||
$keyLength = mb_strlen($key, 'ASCII');
|
||||
}
|
||||
|
||||
if ($keyLength == $size)
|
||||
{
|
||||
return $key;
|
||||
}
|
||||
|
||||
if ($keyLength > $size)
|
||||
{
|
||||
if (function_exists('mb_substr'))
|
||||
{
|
||||
return mb_substr($key, 0, $size, 'ASCII');
|
||||
}
|
||||
|
||||
return substr($key, 0, $size);
|
||||
}
|
||||
|
||||
return $key . str_repeat("\0", ($size - $keyLength));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns null bytes to append to the string so that it's zero padded to the specified block size
|
||||
*
|
||||
* @param string $string The binary string which will be zero padded
|
||||
* @param int $blockSize The block size
|
||||
*
|
||||
* @return string The zero bytes to append to the string to zero pad it to $blockSize
|
||||
*/
|
||||
protected function getZeroPadding($string, $blockSize)
|
||||
{
|
||||
$stringSize = strlen($string);
|
||||
|
||||
if (function_exists('mb_strlen'))
|
||||
{
|
||||
$stringSize = mb_strlen($string, 'ASCII');
|
||||
}
|
||||
|
||||
if ($stringSize == $blockSize)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($stringSize < $blockSize)
|
||||
{
|
||||
return str_repeat("\0", $blockSize - $stringSize);
|
||||
}
|
||||
|
||||
$paddingBytes = $stringSize % $blockSize;
|
||||
|
||||
return str_repeat("\0", $blockSize - $paddingBytes);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* @package FrameworkOnFramework
|
||||
* @subpackage Encryption
|
||||
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
|
||||
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
|
||||
* - Do not use this in new projects.
|
||||
* - Expect no updates.
|
||||
* - This is outdated.
|
||||
* - Not best choice for encryption.
|
||||
* - Use phpseclib/phpseclib version 3 Instead.
|
||||
* - Checkout the JCB Crypt Suite. <https://git.vdm.dev/joomla/phpseclib>
|
||||
*/
|
||||
namespace VDM\Joomla\FOF\Encrypt\AES;
|
||||
|
||||
|
||||
use VDM\Joomla\FOF\Utils\Phpfunc;
|
||||
|
||||
|
||||
/**
|
||||
* Interface for AES encryption adapters
|
||||
*
|
||||
* @package FrameworkOnFramework
|
||||
* @since 1.0
|
||||
* @deprecated Use phpseclib/phpseclib version 3 Instead.
|
||||
*/
|
||||
interface AesInterface
|
||||
{
|
||||
/**
|
||||
* Sets the AES encryption mode.
|
||||
*
|
||||
* WARNING: The strength is deprecated as it has a different effect in MCrypt and OpenSSL. MCrypt was abandoned in
|
||||
* 2003 before the Rijndael-128 algorithm was officially the Advanced Encryption Standard (AES). MCrypt also offered
|
||||
* Rijndael-192 and Rijndael-256 algorithms with different block sizes. These are NOT used in AES. OpenSSL, however,
|
||||
* implements AES correctly. It always uses a 128-bit (16 byte) block. The 192 and 256 bit strengths refer to the
|
||||
* key size, not the block size. Therefore using different strengths in MCrypt and OpenSSL will result in different
|
||||
* and incompatible ciphertexts.
|
||||
*
|
||||
* TL;DR: Always use $strength = 128!
|
||||
*
|
||||
* @param string $mode Choose between CBC (recommended) or ECB
|
||||
* @param int $strength Bit strength of the key (128, 192 or 256 bits). DEPRECATED. READ NOTES ABOVE.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function setEncryptionMode($mode = 'cbc', $strength = 128);
|
||||
|
||||
/**
|
||||
* Encrypts a string. Returns the raw binary ciphertext.
|
||||
*
|
||||
* WARNING: The plaintext is zero-padded to the algorithm's block size. You are advised to store the size of the
|
||||
* plaintext and trim the string to that length upon decryption.
|
||||
*
|
||||
* @param string $plainText The plaintext to encrypt
|
||||
* @param string $key The raw binary key (will be zero-padded or chopped if its size is different than the block size)
|
||||
* @param null|string $iv The initialization vector (for CBC mode algorithms)
|
||||
*
|
||||
* @return string The raw encrypted binary string.
|
||||
*/
|
||||
public function encrypt($plainText, $key, $iv = null);
|
||||
|
||||
/**
|
||||
* Decrypts a string. Returns the raw binary plaintext.
|
||||
*
|
||||
* $ciphertext MUST start with the IV followed by the ciphertext, even for EBC data (the first block of data is
|
||||
* dropped in EBC mode since there is no concept of IV in EBC).
|
||||
*
|
||||
* WARNING: The returned plaintext is zero-padded to the algorithm's block size during encryption. You are advised
|
||||
* to trim the string to the original plaintext's length upon decryption. While rtrim($decrypted, "\0") sounds
|
||||
* appealing it's NOT the correct approach for binary data (zero bytes may actually be part of your plaintext, not
|
||||
* just padding!).
|
||||
*
|
||||
* @param string $cipherText The ciphertext to encrypt
|
||||
* @param string $key The raw binary key (will be zero-padded or chopped if its size is different than the block size)
|
||||
*
|
||||
* @return string The raw unencrypted binary string.
|
||||
*/
|
||||
public function decrypt($cipherText, $key);
|
||||
|
||||
/**
|
||||
* Returns the encryption block size in bytes
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBlockSize();
|
||||
|
||||
/**
|
||||
* Is this adapter supported?
|
||||
*
|
||||
* @param Phpfunc $phpfunc
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSupported(Phpfunc $phpfunc = null);
|
||||
}
|
||||
|
178
libraries/jcb_powers/VDM.Joomla.FOF/src/Encrypt/AES/Mcrypt.php
Normal file
178
libraries/jcb_powers/VDM.Joomla.FOF/src/Encrypt/AES/Mcrypt.php
Normal file
@ -0,0 +1,178 @@
|
||||
<?php
|
||||
/**
|
||||
* @package FrameworkOnFramework
|
||||
* @subpackage Encryption
|
||||
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
|
||||
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
|
||||
* - Do not use this in new projects.
|
||||
* - Expect no updates.
|
||||
* - This is outdated.
|
||||
* - Not best choice for encryption.
|
||||
* - Use phpseclib/phpseclib version 3 Instead.
|
||||
* - Checkout the JCB Crypt Suite. <https://git.vdm.dev/joomla/phpseclib>
|
||||
*/
|
||||
namespace VDM\Joomla\FOF\Encrypt\AES;
|
||||
|
||||
|
||||
use VDM\Joomla\FOF\Encrypt\Randval;
|
||||
use VDM\Joomla\FOF\Utils\Phpfunc;
|
||||
use VDM\Joomla\FOF\Encrypt\AES\AesInterface;
|
||||
use VDM\Joomla\FOF\Encrypt\AES\Abstraction;
|
||||
|
||||
|
||||
/**
|
||||
* Mcrypt AES encryption class
|
||||
*
|
||||
* @package FrameworkOnFramework
|
||||
* @since 1.0
|
||||
* @deprecated Use phpseclib/phpseclib version 3 Instead.
|
||||
*/
|
||||
class Mcrypt extends Abstraction implements AesInterface
|
||||
{
|
||||
protected $cipherType = MCRYPT_RIJNDAEL_128;
|
||||
|
||||
protected $cipherMode = MCRYPT_MODE_CBC;
|
||||
|
||||
public function setEncryptionMode($mode = 'cbc', $strength = 128)
|
||||
{
|
||||
switch ((int) $strength)
|
||||
{
|
||||
default:
|
||||
case '128':
|
||||
$this->cipherType = MCRYPT_RIJNDAEL_128;
|
||||
break;
|
||||
|
||||
case '192':
|
||||
$this->cipherType = MCRYPT_RIJNDAEL_192;
|
||||
break;
|
||||
|
||||
case '256':
|
||||
$this->cipherType = MCRYPT_RIJNDAEL_256;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (strtolower($mode))
|
||||
{
|
||||
case 'ecb':
|
||||
$this->cipherMode = MCRYPT_MODE_ECB;
|
||||
break;
|
||||
|
||||
default:
|
||||
case 'cbc':
|
||||
$this->cipherMode = MCRYPT_MODE_CBC;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function encrypt($plainText, $key, $iv = null)
|
||||
{
|
||||
$iv_size = $this->getBlockSize();
|
||||
$key = $this->resizeKey($key, $iv_size);
|
||||
$iv = $this->resizeKey($iv, $iv_size);
|
||||
|
||||
if (empty($iv))
|
||||
{
|
||||
$randVal = new Randval();
|
||||
$iv = $randVal->generate($iv_size);
|
||||
}
|
||||
|
||||
$cipherText = mcrypt_encrypt($this->cipherType, $key, $plainText, $this->cipherMode, $iv);
|
||||
$cipherText = $iv . $cipherText;
|
||||
|
||||
return $cipherText;
|
||||
}
|
||||
|
||||
public function decrypt($cipherText, $key)
|
||||
{
|
||||
$iv_size = $this->getBlockSize();
|
||||
$key = $this->resizeKey($key, $iv_size);
|
||||
$iv = substr($cipherText, 0, $iv_size);
|
||||
$cipherText = substr($cipherText, $iv_size);
|
||||
$plainText = mcrypt_decrypt($this->cipherType, $key, $cipherText, $this->cipherMode, $iv);
|
||||
|
||||
return $plainText;
|
||||
}
|
||||
|
||||
public function isSupported(Phpfunc $phpfunc = null)
|
||||
{
|
||||
if (!is_object($phpfunc) || !($phpfunc instanceof $phpfunc))
|
||||
{
|
||||
$phpfunc = new Phpfunc();
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('mcrypt_get_key_size'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('mcrypt_get_iv_size'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('mcrypt_create_iv'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('mcrypt_encrypt'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('mcrypt_decrypt'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('mcrypt_list_algorithms'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('hash'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('hash_algos'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$algorightms = $phpfunc->mcrypt_list_algorithms();
|
||||
|
||||
if (!in_array('rijndael-128', $algorightms))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!in_array('rijndael-192', $algorightms))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!in_array('rijndael-256', $algorightms))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$algorightms = $phpfunc->hash_algos();
|
||||
|
||||
if (!in_array('sha256', $algorightms))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getBlockSize()
|
||||
{
|
||||
return mcrypt_get_iv_size($this->cipherType, $this->cipherMode);
|
||||
}
|
||||
}
|
||||
|
193
libraries/jcb_powers/VDM.Joomla.FOF/src/Encrypt/AES/Openssl.php
Normal file
193
libraries/jcb_powers/VDM.Joomla.FOF/src/Encrypt/AES/Openssl.php
Normal file
@ -0,0 +1,193 @@
|
||||
<?php
|
||||
/**
|
||||
* @package FrameworkOnFramework
|
||||
* @subpackage Encryption
|
||||
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
|
||||
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
|
||||
* - Do not use this in new projects.
|
||||
* - Expect no updates.
|
||||
* - This is outdated.
|
||||
* - Not best choice for encryption.
|
||||
* - Use phpseclib/phpseclib version 3 Instead.
|
||||
* - Checkout the JCB Crypt Suite. <https://git.vdm.dev/joomla/phpseclib>
|
||||
*/
|
||||
namespace VDM\Joomla\FOF\Encrypt\AES;
|
||||
|
||||
|
||||
use VDM\Joomla\FOF\Encrypt\Randval;
|
||||
use VDM\Joomla\FOF\Utils\Phpfunc;
|
||||
use VDM\Joomla\FOF\Encrypt\AES\AesInterface;
|
||||
use VDM\Joomla\FOF\Encrypt\AES\Abstraction;
|
||||
|
||||
|
||||
/**
|
||||
* Openssl AES encryption class
|
||||
*
|
||||
* @package FrameworkOnFramework
|
||||
* @since 1.0
|
||||
* @deprecated Use phpseclib/phpseclib version 3 Instead.
|
||||
*/
|
||||
class Openssl extends Abstraction implements AesInterface
|
||||
{
|
||||
/**
|
||||
* The OpenSSL options for encryption / decryption
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $openSSLOptions = 0;
|
||||
|
||||
/**
|
||||
* The encryption method to use
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $method = 'aes-128-cbc';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->openSSLOptions = OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING;
|
||||
}
|
||||
|
||||
public function setEncryptionMode($mode = 'cbc', $strength = 128)
|
||||
{
|
||||
static $availableAlgorithms = null;
|
||||
static $defaultAlgo = 'aes-128-cbc';
|
||||
|
||||
if (!is_array($availableAlgorithms))
|
||||
{
|
||||
$availableAlgorithms = openssl_get_cipher_methods();
|
||||
|
||||
foreach (array('aes-256-cbc', 'aes-256-ecb', 'aes-192-cbc',
|
||||
'aes-192-ecb', 'aes-128-cbc', 'aes-128-ecb') as $algo)
|
||||
{
|
||||
if (in_array($algo, $availableAlgorithms))
|
||||
{
|
||||
$defaultAlgo = $algo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$strength = (int) $strength;
|
||||
$mode = strtolower($mode);
|
||||
|
||||
if (!in_array($strength, array(128, 192, 256)))
|
||||
{
|
||||
$strength = 256;
|
||||
}
|
||||
|
||||
if (!in_array($mode, array('cbc', 'ebc')))
|
||||
{
|
||||
$mode = 'cbc';
|
||||
}
|
||||
|
||||
$algo = 'aes-' . $strength . '-' . $mode;
|
||||
|
||||
if (!in_array($algo, $availableAlgorithms))
|
||||
{
|
||||
$algo = $defaultAlgo;
|
||||
}
|
||||
|
||||
$this->method = $algo;
|
||||
}
|
||||
|
||||
public function encrypt($plainText, $key, $iv = null)
|
||||
{
|
||||
$iv_size = $this->getBlockSize();
|
||||
$key = $this->resizeKey($key, $iv_size);
|
||||
$iv = $this->resizeKey($iv, $iv_size);
|
||||
|
||||
if (empty($iv))
|
||||
{
|
||||
$randVal = new Randval();
|
||||
$iv = $randVal->generate($iv_size);
|
||||
}
|
||||
|
||||
$plainText .= $this->getZeroPadding($plainText, $iv_size);
|
||||
$cipherText = openssl_encrypt($plainText, $this->method, $key, $this->openSSLOptions, $iv);
|
||||
$cipherText = $iv . $cipherText;
|
||||
|
||||
return $cipherText;
|
||||
}
|
||||
|
||||
public function decrypt($cipherText, $key)
|
||||
{
|
||||
$iv_size = $this->getBlockSize();
|
||||
$key = $this->resizeKey($key, $iv_size);
|
||||
$iv = substr($cipherText, 0, $iv_size);
|
||||
$cipherText = substr($cipherText, $iv_size);
|
||||
$plainText = openssl_decrypt($cipherText, $this->method, $key, $this->openSSLOptions, $iv);
|
||||
|
||||
return $plainText;
|
||||
}
|
||||
|
||||
public function isSupported(Phpfunc $phpfunc = null)
|
||||
{
|
||||
if (!is_object($phpfunc) || !($phpfunc instanceof $phpfunc))
|
||||
{
|
||||
$phpfunc = new Phpfunc();
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('openssl_get_cipher_methods'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('openssl_random_pseudo_bytes'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('openssl_cipher_iv_length'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('openssl_encrypt'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('openssl_decrypt'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('hash'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('hash_algos'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$algorightms = $phpfunc->openssl_get_cipher_methods();
|
||||
|
||||
if (!in_array('aes-128-cbc', $algorightms))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$algorightms = $phpfunc->hash_algos();
|
||||
|
||||
if (!in_array('sha256', $algorightms))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBlockSize()
|
||||
{
|
||||
return openssl_cipher_iv_length($this->method);
|
||||
}
|
||||
}
|
||||
|
69
libraries/jcb_powers/VDM.Joomla.FOF/src/Encrypt/Randval.php
Normal file
69
libraries/jcb_powers/VDM.Joomla.FOF/src/Encrypt/Randval.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* @package FrameworkOnFramework
|
||||
* @subpackage Encryption
|
||||
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
|
||||
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
|
||||
* - Do not use this in new projects.
|
||||
* - Expect no updates.
|
||||
* - This is outdated.
|
||||
* - Not best choice for encryption.
|
||||
* - Use phpseclib/phpseclib version 3 Instead.
|
||||
* - Checkout the JCB Crypt Suite. <https://git.vdm.dev/joomla/phpseclib>
|
||||
*/
|
||||
namespace VDM\Joomla\FOF\Encrypt;
|
||||
|
||||
|
||||
use VDM\Joomla\FOF\Encrypt\Randvalinterface;
|
||||
|
||||
|
||||
/**
|
||||
* Generates cryptographically-secure random values.
|
||||
*
|
||||
* @package FrameworkOnFramework
|
||||
* @since 1.0
|
||||
* @deprecated Use phpseclib/phpseclib version 3 Instead.
|
||||
*/
|
||||
class Randval implements Randvalinterface
|
||||
{
|
||||
/**
|
||||
* Returns a cryptographically secure random value.
|
||||
*
|
||||
* Since we only run on PHP 7+ we can use random_bytes(), which internally uses a crypto safe PRNG. If the function
|
||||
* doesn't exist, Joomla already loads a secure polyfill.
|
||||
*
|
||||
* The reason this method exists is backwards compatibility with older versions of FOF. It also allows us to quickly
|
||||
* address any future issues if Joomla drops the polyfill or otherwise find problems with PHP's random_bytes() on
|
||||
* some weird host (you can't be too careful when releasing mass-distributed software).
|
||||
*
|
||||
* @param integer $bytes How many bytes to return
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generate($bytes = 32)
|
||||
{
|
||||
return random_bytes($bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate random bytes. Adapted from Joomla! 3.2.
|
||||
*
|
||||
* Since we only run on PHP 7+ we can use random_bytes(), which internally uses a crypto safe PRNG. If the function
|
||||
* doesn't exist, Joomla already loads a secure polyfill.
|
||||
*
|
||||
* The reason this method exists is backwards compatibility with older versions of FOF. It also allows us to quickly
|
||||
* address any future issues if Joomla drops the polyfill or otherwise find problems with PHP's random_bytes() on
|
||||
* some weird host (you can't be too careful when releasing mass-distributed software).
|
||||
*
|
||||
* @param integer $length Length of the random data to generate
|
||||
*
|
||||
* @return string Random binary data
|
||||
*/
|
||||
public function genRandomBytes($length = 32)
|
||||
{
|
||||
return random_bytes($length);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* @package FrameworkOnFramework
|
||||
* @subpackage Encryption
|
||||
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
|
||||
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
|
||||
* - Do not use this in new projects.
|
||||
* - Expect no updates.
|
||||
* - This is outdated.
|
||||
* - Not best choice for encryption.
|
||||
* - Use phpseclib/phpseclib version 3 Instead.
|
||||
* - Checkout the JCB Crypt Suite. <https://git.vdm.dev/joomla/phpseclib>
|
||||
*/
|
||||
namespace VDM\Joomla\FOF\Encrypt;
|
||||
|
||||
|
||||
/**
|
||||
* Randvalinterface
|
||||
*
|
||||
* @package FrameworkOnFramework
|
||||
* @since 1.0
|
||||
* @deprecated Use phpseclib/phpseclib version 3 Instead.
|
||||
*/
|
||||
interface Randvalinterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
* Returns a cryptographically secure random value.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function generate();
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
44
libraries/jcb_powers/VDM.Joomla.FOF/src/Utils/Phpfunc.php
Normal file
44
libraries/jcb_powers/VDM.Joomla.FOF/src/Utils/Phpfunc.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* @package FrameworkOnFramework
|
||||
* @subpackage Utilities
|
||||
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
|
||||
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
|
||||
*/
|
||||
namespace VDM\Joomla\FOF\Utils;
|
||||
|
||||
|
||||
/**
|
||||
* Intercept calls to PHP functions.
|
||||
*
|
||||
* @method function_exists(string $function)
|
||||
* @method mcrypt_list_algorithms()
|
||||
* @method hash_algos()
|
||||
* @method extension_loaded(string $ext)
|
||||
* @method mcrypt_create_iv(int $bytes, int $source)
|
||||
* @method openssl_get_cipher_methods()
|
||||
*
|
||||
* @package FrameworkOnFramework
|
||||
* @since 1.0
|
||||
*/
|
||||
class Phpfunc
|
||||
{
|
||||
/**
|
||||
*
|
||||
* Magic call to intercept any function pass to it.
|
||||
*
|
||||
* @param string $func The function to call.
|
||||
*
|
||||
* @param array $args Arguments passed to the function.
|
||||
*
|
||||
* @return mixed The result of the function call.
|
||||
*
|
||||
*/
|
||||
public function __call($func, $args)
|
||||
{
|
||||
return call_user_func_array($func, $args);
|
||||
}
|
||||
}
|
||||
|
1
libraries/jcb_powers/VDM.Joomla.FOF/src/Utils/index.html
Normal file
1
libraries/jcb_powers/VDM.Joomla.FOF/src/Utils/index.html
Normal file
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -67,16 +67,23 @@ abstract class Api
|
||||
/**
|
||||
* Load/Reload API.
|
||||
*
|
||||
* @param string $url The url.
|
||||
* @param token $token The token.
|
||||
* @param string|null $url The url.
|
||||
* @param token|null $token The token.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function load_(string $url, string $token)
|
||||
public function load_(?string $url = null, ?string $token = null)
|
||||
{
|
||||
$this->uri->setUrl($url);
|
||||
$this->http->setToken($token);
|
||||
if ($url !== null)
|
||||
{
|
||||
$this->uri->setUrl($url);
|
||||
}
|
||||
|
||||
if ($token !== null)
|
||||
{
|
||||
$this->http->setToken($token);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ use VDM\Joomla\Gitea\Service\Issue;
|
||||
use VDM\Joomla\Gitea\Service\Notifications;
|
||||
use VDM\Joomla\Gitea\Service\Miscellaneous;
|
||||
use VDM\Joomla\Gitea\Service\Admin;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\FactoryInterface;
|
||||
use VDM\Joomla\Interfaces\FactoryInterface;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -205,16 +205,19 @@ class Contents extends Api
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/contents";
|
||||
|
||||
// Get the URI with the specified path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Add the 'ref' parameter if it's provided.
|
||||
if ($ref !== null)
|
||||
{
|
||||
$this->uri->setVar('ref', $ref);
|
||||
$uri->setVar('ref', $ref);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
$uri
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -227,8 +230,8 @@ class Contents extends Api
|
||||
* @param string $filepath The file path.
|
||||
* @param string $content The file content.
|
||||
* @param string $message The commit message.
|
||||
* @param string $branch The branch name. Defaults to the repository's default branch.
|
||||
* @param string $sha The blob SHA of the file.
|
||||
* @param string $branch The branch name. Defaults to the repository's default branch.
|
||||
* @param string|null $authorName The author name. Defaults to the authenticated user.
|
||||
* @param string|null $authorEmail The author email. Defaults to the authenticated user.
|
||||
* @param string|null $committerName The committer name. Defaults to the authenticated user.
|
||||
@ -248,8 +251,8 @@ class Contents extends Api
|
||||
string $filepath,
|
||||
string $content,
|
||||
string $message,
|
||||
string $branch = 'master',
|
||||
string $sha,
|
||||
string $branch = 'master',
|
||||
?string $authorName = null,
|
||||
?string $authorEmail = null,
|
||||
?string $committerName = null,
|
||||
@ -503,7 +506,6 @@ class Contents extends Api
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,6 @@ class Admin implements ServiceProviderInterface
|
||||
$container->get('Gitea.Dynamic.Uri'),
|
||||
$container->get('Gitea.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,9 +76,19 @@ class Jcb implements ServiceProviderInterface
|
||||
*/
|
||||
public function getHttp(Container $container): Http
|
||||
{
|
||||
return new Http(
|
||||
Helper::getParams('com_componentbuilder')->get('gitea_token')
|
||||
);
|
||||
$add_gitea_url = Helper::getParams('com_componentbuilder')->get('add_custom_gitea_url', 1);
|
||||
if ($add_gitea_url == 2)
|
||||
{
|
||||
return new Http(
|
||||
Helper::getParams('com_componentbuilder')->get('custom_gitea_token')
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Http(
|
||||
Helper::getParams('com_componentbuilder')->get('gitea_token')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -830,7 +830,6 @@ class Repository implements ServiceProviderInterface
|
||||
$container->get('Gitea.Dynamic.Uri'),
|
||||
$container->get('Gitea.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,6 @@ class Utilities implements ServiceProviderInterface
|
||||
public function getResponse(Container $container): Response
|
||||
{
|
||||
return new Response();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ final class Response
|
||||
// Decode the error response and throw an exception.
|
||||
$message = $this->error($response);
|
||||
|
||||
throw new \DomainException("Invalid response received from API.$message", $response->code);
|
||||
throw new \DomainException("Invalid response received from API. $message", $response->code);
|
||||
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ final class Response
|
||||
// Decode the error response and throw an exception.
|
||||
$message = $this->error($response);
|
||||
|
||||
throw new \DomainException("Invalid response received from API.$message", $response->code);
|
||||
throw new \DomainException("Invalid response received from API. $message", $response->code);
|
||||
|
||||
}
|
||||
|
||||
@ -134,6 +134,10 @@ final class Response
|
||||
{
|
||||
return $error->error;
|
||||
}
|
||||
elseif (isset($error->message))
|
||||
{
|
||||
return $error->message;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ final class Uri
|
||||
**/
|
||||
public function setUrl(string $url)
|
||||
{
|
||||
return $this->url = $url;
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -120,7 +120,7 @@ final class Uri
|
||||
**/
|
||||
private function setEndpoint(string $endpoint)
|
||||
{
|
||||
return $this->endpoint = $endpoint;
|
||||
$this->endpoint = $endpoint;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,7 +133,7 @@ final class Uri
|
||||
**/
|
||||
private function setVersion($version)
|
||||
{
|
||||
return $this->version = $version;
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
}
|
||||
|
1
libraries/jcb_powers/VDM.Joomla.Openai/index.html
Normal file
1
libraries/jcb_powers/VDM.Joomla.Openai/index.html
Normal file
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Openai\Abstraction;
|
||||
|
||||
|
||||
use VDM\Joomla\Openai\Utilities\Http;
|
||||
use VDM\Joomla\Openai\Utilities\Uri;
|
||||
use VDM\Joomla\Openai\Utilities\Response;
|
||||
|
||||
|
||||
/**
|
||||
* The Openai Api
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract class Api
|
||||
{
|
||||
/**
|
||||
* The Http class
|
||||
*
|
||||
* @var Http
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Http $http;
|
||||
|
||||
/**
|
||||
* The Uri class
|
||||
*
|
||||
* @var Uri
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Uri $uri;
|
||||
|
||||
/**
|
||||
* The Response class
|
||||
*
|
||||
* @var Response
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Response $response;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Http $http The http class.
|
||||
* @param Uri $uri The uri class.
|
||||
* @param Response $response The response class.
|
||||
*
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function __construct(Http $http, Uri $uri, Response $response)
|
||||
{
|
||||
$this->http = $http;
|
||||
$this->uri = $uri;
|
||||
$this->response = $response;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
138
libraries/jcb_powers/VDM.Joomla.Openai/src/Audio.php
Normal file
138
libraries/jcb_powers/VDM.Joomla.Openai/src/Audio.php
Normal file
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Openai;
|
||||
|
||||
|
||||
use VDM\Joomla\Openai\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Openai Audio
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Audio extends Api
|
||||
{
|
||||
/**
|
||||
* Transcribes audio into the input language.
|
||||
* API Ref: https://platform.openai.com/docs/api-reference/audio/create
|
||||
*
|
||||
* @param string $file The audio file to transcribe. Formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm (required).
|
||||
* @param string|null $prompt An optional text to guide the model's style (optional).
|
||||
* @param string|null $responseFormat The format of the transcript output. Options: json, text, srt, verbose_json, or vtt (optional).
|
||||
* @param float|null $temperature The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic (optional).
|
||||
* @param string|null $language The language of the input audio (optional).
|
||||
* @param string $model ID of the model to use. Only "whisper-1" is currently available.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function transcribe(
|
||||
string $file,
|
||||
?string $prompt = null,
|
||||
?string $responseFormat = null,
|
||||
?float $temperature = null,
|
||||
?string $language = null,
|
||||
string $model = 'whisper-1'
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/audio/transcriptions";
|
||||
|
||||
// Set the request data.
|
||||
$data = new \stdClass();
|
||||
$data->file = $file;
|
||||
|
||||
if ($prompt !== null)
|
||||
{
|
||||
$data->prompt = $prompt;
|
||||
}
|
||||
|
||||
if ($responseFormat !== null)
|
||||
{
|
||||
$data->response_format = $responseFormat;
|
||||
}
|
||||
|
||||
if ($temperature !== null)
|
||||
{
|
||||
$data->temperature = $temperature;
|
||||
}
|
||||
|
||||
if ($language !== null)
|
||||
{
|
||||
$data->language = $language;
|
||||
}
|
||||
|
||||
$data->model = $model;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data), ['Content-Type' => 'multipart/form-data']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate an audio file into English.
|
||||
* API Ref: https://platform.openai.com/docs/api-reference/audio/create
|
||||
*
|
||||
* @param string $file The the audio file. Formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm (required).
|
||||
* @param string|null $prompt An optional text to guide the model's style or continue a previous audio segment. The prompt should be in English (optional).
|
||||
* @param string|null $responseFormat The format of the transcript output. Options: json, text, srt, verbose_json, or vtt (optional).
|
||||
* @param float|null $temperature The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic (optional).
|
||||
* @param string $model ID of the model to use. Only "whisper-1" is currently available.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function translation(
|
||||
string $file,
|
||||
?string $prompt = null,
|
||||
?string $responseFormat = null,
|
||||
?float $temperature = null,
|
||||
string $model = 'whisper-1'
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/audio/translations";
|
||||
|
||||
// Set the data.
|
||||
$data = new \stdClass();
|
||||
$data->file = $file;
|
||||
|
||||
if ($prompt !== null)
|
||||
{
|
||||
$data->prompt = $prompt;
|
||||
}
|
||||
|
||||
if ($responseFormat !== null)
|
||||
{
|
||||
$data->response_format = $responseFormat;
|
||||
}
|
||||
|
||||
if ($temperature !== null)
|
||||
{
|
||||
$data->temperature = $temperature;
|
||||
}
|
||||
|
||||
$data->model = $model;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data), ['Content-Type' => 'multipart/form-data']
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
142
libraries/jcb_powers/VDM.Joomla.Openai/src/Chat.php
Normal file
142
libraries/jcb_powers/VDM.Joomla.Openai/src/Chat.php
Normal file
@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Openai;
|
||||
|
||||
|
||||
use VDM\Joomla\Openai\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Openai Chat
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Chat extends Api
|
||||
{
|
||||
/**
|
||||
* Create a chat completion with the OpenAI API.
|
||||
* API Ref: https://platform.openai.com/docs/api-reference/chat/create
|
||||
*
|
||||
* @param string $model The model to use for completion.
|
||||
* @param array $messages A list of messages describing the conversation so far.
|
||||
*
|
||||
* Each item in the array is an object with the following:
|
||||
* - role (string) Required
|
||||
* The role of the author of this message.
|
||||
* One of system, user, or assistant.
|
||||
* - content (string) Required
|
||||
* The contents of the message.
|
||||
* - name (string) Optional
|
||||
* The name of the author of this message.
|
||||
* May contain a-z, A-Z, 0-9, and underscores,
|
||||
* with a maximum length of 64 characters.
|
||||
*
|
||||
* @param int|null $maxTokens Maximum number of tokens to generate (optional).
|
||||
* @param float|null $temperature The sampling temperature to use (optional).
|
||||
* @param float|null $topP The nucleus sampling parameter (optional).
|
||||
* @param int|null $n The number of chat completion choices to generate (optional).
|
||||
* @param bool|null $stream Partial message deltas (optional).
|
||||
* @param mixed|null $stop Sequences where the API will stop generating tokens (optional).
|
||||
* @param float|null $presencePenalty Penalty for new tokens based on whether they appear in the text (optional).
|
||||
* @param float|null $frequencyPenalty Penalty for new tokens based on their frequency in the text (optional).
|
||||
* @param array|null $logitBias Modify the likelihood of specified tokens appearing (optional).
|
||||
* @param string|null $user A unique identifier representing the end-user (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $model,
|
||||
array $messages,
|
||||
?int $maxTokens = null,
|
||||
?float $temperature = null,
|
||||
?float $topP = null,
|
||||
?int $n = null,
|
||||
?bool $stream = null,
|
||||
$stop = null,
|
||||
?float $presencePenalty = null,
|
||||
?float $frequencyPenalty = null,
|
||||
?array $logitBias = null,
|
||||
?string $user = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/chat/completions";
|
||||
|
||||
// Set the request data.
|
||||
$data = new \stdClass();
|
||||
$data->model = $model;
|
||||
$data->messages = $messages;
|
||||
|
||||
if ($maxTokens !== null)
|
||||
{
|
||||
$data->max_tokens = $maxTokens;
|
||||
}
|
||||
|
||||
if ($temperature !== null)
|
||||
{
|
||||
$data->temperature = $temperature;
|
||||
}
|
||||
|
||||
if ($topP !== null)
|
||||
{
|
||||
$data->top_p = $topP;
|
||||
}
|
||||
|
||||
if ($n !== null)
|
||||
{
|
||||
$data->n = $n;
|
||||
}
|
||||
|
||||
if ($stream !== null)
|
||||
{
|
||||
$data->stream = $stream;
|
||||
}
|
||||
|
||||
if ($stop !== null)
|
||||
{
|
||||
$data->stop = $stop;
|
||||
}
|
||||
|
||||
if ($presencePenalty !== null)
|
||||
{
|
||||
$data->presence_penalty = $presencePenalty;
|
||||
}
|
||||
|
||||
if ($frequencyPenalty !== null)
|
||||
{
|
||||
$data->frequency_penalty = $frequencyPenalty;
|
||||
}
|
||||
|
||||
if ($logitBias !== null)
|
||||
{
|
||||
$data->logit_bias = new \stdClass();
|
||||
foreach ($logitBias as $key => $val)
|
||||
{
|
||||
$data->logit_bias->$key = $val;
|
||||
}
|
||||
}
|
||||
|
||||
if ($user !== null)
|
||||
{
|
||||
$data->user = $user;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
158
libraries/jcb_powers/VDM.Joomla.Openai/src/Completions.php
Normal file
158
libraries/jcb_powers/VDM.Joomla.Openai/src/Completions.php
Normal file
@ -0,0 +1,158 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Openai;
|
||||
|
||||
|
||||
use VDM\Joomla\Openai\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Openai Completions
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Completions extends Api
|
||||
{
|
||||
/**
|
||||
* Create a completion using the OpenAI API.
|
||||
* API Ref: https://platform.openai.com/docs/api-reference/completions
|
||||
*
|
||||
* @param string $model The ID of the model to use.
|
||||
* @param string|array $prompt The prompt(s) to generate completions for.
|
||||
* @param int|null $maxTokens The maximum number of tokens to generate (optional).
|
||||
* @param float|null $temperature The sampling temperature to use (optional).
|
||||
* @param string $suffix The suffix that comes after a completion of inserted text. (optional).
|
||||
* @param float|null $topP The top_p value for nucleus sampling (optional).
|
||||
* @param int|null $n How many completions to generate (optional).
|
||||
* @param bool|null $stream Whether to stream back partial progress (optional).
|
||||
* @param int|null $logprobs Include the log probabilities on the most likely tokens (optional).
|
||||
* @param bool|null $echo Echo back the prompt in addition to the completion (optional).
|
||||
* @param string|null $stop Up to 4 sequences where the API will stop generating (optional).
|
||||
* @param float|null $presencePenalty The presence penalty to use (optional).
|
||||
* @param float|null $frequencyPenalty The frequency penalty to use (optional).
|
||||
* @param int|null $bestOf Generates best_of completions server-side (optional).
|
||||
* @param array|null $logitBias Modify the likelihood of specified tokens (optional).
|
||||
* @param string|null $user A unique identifier representing your end-user (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $model,
|
||||
$prompt,
|
||||
?int $maxTokens = null,
|
||||
?string $suffix = null,
|
||||
?float $temperature = null,
|
||||
?float $topP = null,
|
||||
?int $n = null,
|
||||
?bool $stream = null,
|
||||
?int $logprobs = null,
|
||||
?bool $echo = null,
|
||||
$stop = null,
|
||||
?float $presencePenalty = null,
|
||||
?float $frequencyPenalty = null,
|
||||
?int $bestOf = null,
|
||||
?array $logitBias = null,
|
||||
?string $user = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/completions";
|
||||
|
||||
// Set the completion data.
|
||||
$data = new \stdClass();
|
||||
$data->model = $model;
|
||||
$data->prompt = $prompt;
|
||||
|
||||
if ($maxTokens !== null)
|
||||
{
|
||||
$data->max_tokens = $maxTokens;
|
||||
}
|
||||
|
||||
if ($temperature !== null)
|
||||
{
|
||||
$data->temperature = $temperature;
|
||||
}
|
||||
|
||||
if ($suffix !== null)
|
||||
{
|
||||
$data->suffix = $suffix;
|
||||
}
|
||||
|
||||
if ($topP !== null)
|
||||
{
|
||||
$data->top_p = $topP;
|
||||
}
|
||||
|
||||
if ($n !== null)
|
||||
{
|
||||
$data->n = $n;
|
||||
}
|
||||
|
||||
if ($stream !== null)
|
||||
{
|
||||
$data->stream = $stream;
|
||||
}
|
||||
|
||||
if ($logprobs !== null)
|
||||
{
|
||||
$data->logprobs = $logprobs;
|
||||
}
|
||||
|
||||
if ($echo !== null)
|
||||
{
|
||||
$data->echo = $echo;
|
||||
}
|
||||
|
||||
if ($stop !== null)
|
||||
{
|
||||
$data->stop = $stop;
|
||||
}
|
||||
|
||||
if ($presencePenalty !== null)
|
||||
{
|
||||
$data->presence_penalty = $presencePenalty;
|
||||
}
|
||||
|
||||
if ($frequencyPenalty !== null)
|
||||
{
|
||||
$data->frequency_penalty = $frequencyPenalty;
|
||||
}
|
||||
|
||||
if ($bestOf !== null)
|
||||
{
|
||||
$data->best_of = $bestOf;
|
||||
}
|
||||
|
||||
if ($logitBias !== null)
|
||||
{
|
||||
$data->logit_bias = new \stdClass();
|
||||
foreach ($logitBias as $key => $val)
|
||||
{
|
||||
$data->logit_bias->$key = $val;
|
||||
}
|
||||
}
|
||||
|
||||
if ($user !== null)
|
||||
{
|
||||
$data->user = $user;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
84
libraries/jcb_powers/VDM.Joomla.Openai/src/Edits.php
Normal file
84
libraries/jcb_powers/VDM.Joomla.Openai/src/Edits.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Openai;
|
||||
|
||||
|
||||
use VDM\Joomla\Openai\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Openai Edits
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Edits extends Api
|
||||
{
|
||||
/**
|
||||
* Create a new edit using OpenAI Edit API.
|
||||
* API Ref: https://platform.openai.com/docs/api-reference/edits
|
||||
*
|
||||
* @param string $model The model to use.
|
||||
* @param string $instruction The instruction for the edit.
|
||||
* @param string|null $input The input text (optional).
|
||||
* @param int|null $n How many edits to generate (optional).
|
||||
* @param float|null $temperature The sampling temperature (optional).
|
||||
* @param float|null $topP Nucleus sampling parameter (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $model,
|
||||
string $instruction,
|
||||
?string $input = null,
|
||||
?int $n = null,
|
||||
?float $temperature = null,
|
||||
?float $topP = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/edits";
|
||||
|
||||
// Set the data.
|
||||
$data = new \stdClass();
|
||||
$data->model = $model;
|
||||
$data->instruction = $instruction;
|
||||
|
||||
if ($input !== null)
|
||||
{
|
||||
$data->input = $input;
|
||||
}
|
||||
|
||||
if ($n !== null)
|
||||
{
|
||||
$data->n = $n;
|
||||
}
|
||||
|
||||
if ($temperature !== null)
|
||||
{
|
||||
$data->temperature = $temperature;
|
||||
}
|
||||
|
||||
if ($topP !== null)
|
||||
{
|
||||
$data->top_p = $topP;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
63
libraries/jcb_powers/VDM.Joomla.Openai/src/Embeddings.php
Normal file
63
libraries/jcb_powers/VDM.Joomla.Openai/src/Embeddings.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Openai;
|
||||
|
||||
|
||||
use VDM\Joomla\Openai\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Openai Embeddings
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Embeddings extends Api
|
||||
{
|
||||
/**
|
||||
* Create an embedding of a given input.
|
||||
* API Ref: https://platform.openai.com/docs/api-reference/embeddings
|
||||
*
|
||||
* @param string $model The ID of the model to use.
|
||||
* @param mixed $input The input text to get embeddings for, encoded as a string or array of tokens.
|
||||
* @param string|null $user A unique identifier representing your end-user (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $model,
|
||||
$input,
|
||||
?string $user = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/embeddings";
|
||||
|
||||
// Set the request data.
|
||||
$data = new \stdClass();
|
||||
$data->model = $model;
|
||||
$data->input = $input;
|
||||
|
||||
if ($user !== null)
|
||||
{
|
||||
$data->user = $user;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
78
libraries/jcb_powers/VDM.Joomla.Openai/src/Factory.php
Normal file
78
libraries/jcb_powers/VDM.Joomla.Openai/src/Factory.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Openai;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use VDM\Joomla\Openai\Service\Api;
|
||||
use VDM\Joomla\Openai\Service\Utilities;
|
||||
use VDM\Joomla\Interfaces\FactoryInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Openai Factory
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract class Factory implements FactoryInterface
|
||||
{
|
||||
/**
|
||||
* Global Package Container
|
||||
*
|
||||
* @var Container
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected static $container = null;
|
||||
|
||||
/**
|
||||
* Get any class from the package container
|
||||
*
|
||||
* @param string $key The container class key
|
||||
*
|
||||
* @return Mixed
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static function _($key)
|
||||
{
|
||||
return self::getContainer()->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the global package container
|
||||
*
|
||||
* @return Container
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static function getContainer(): Container
|
||||
{
|
||||
if (!self::$container)
|
||||
{
|
||||
self::$container = self::createContainer();
|
||||
}
|
||||
|
||||
return self::$container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a container object
|
||||
*
|
||||
* @return Container
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected static function createContainer(): Container
|
||||
{
|
||||
return (new Container())
|
||||
->registerServiceProvider(new Utilities())
|
||||
->registerServiceProvider(new Api());
|
||||
}
|
||||
}
|
||||
|
140
libraries/jcb_powers/VDM.Joomla.Openai/src/Files.php
Normal file
140
libraries/jcb_powers/VDM.Joomla.Openai/src/Files.php
Normal file
@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Openai;
|
||||
|
||||
|
||||
use VDM\Joomla\Openai\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Openai Files
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Files extends Api
|
||||
{
|
||||
/**
|
||||
* Fetches a list of files belonging to the user's organization.
|
||||
* API Ref: https://platform.openai.com/docs/api-reference/files/list
|
||||
*
|
||||
* @return object|null The response from the OpenAI API, or null if an error occurred.
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function list(): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/files";
|
||||
|
||||
// Prepare the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the GET request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload a file that contains document(s) to be used across various endpoints/features.
|
||||
* API Ref: https://platform.openai.com/docs/api-reference/files/upload
|
||||
*
|
||||
* @param string $file The file to upload.
|
||||
* @param string $purpose The intended purpose of the uploaded documents.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function upload(string $file, string $purpose): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/files";
|
||||
|
||||
// Set the request data.
|
||||
$data = new \stdClass();
|
||||
$data->file = $file;
|
||||
$data->purpose = $purpose;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about a specific file.
|
||||
* API Ref: https://platform.openai.com/docs/api-reference/files/retrieve
|
||||
*
|
||||
* @param string $fileID The file id to retrieve info
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function info(string $fileID): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/files/{$fileID}";
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific file content.
|
||||
* API Ref: https://platform.openai.com/docs/api-reference/files/retrieve-content
|
||||
*
|
||||
* @param string $fileID The file id to retrieve content
|
||||
*
|
||||
* @return mixed
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function content(string $fileID)
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/files/{$fileID}/content";
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a file.
|
||||
* API Ref: https://platform.openai.com/docs/api-reference/files/delete
|
||||
*
|
||||
* @param string $fileID The file id to delete
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(string $fileID): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/files/{$fileID}";
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
50
libraries/jcb_powers/VDM.Joomla.Openai/src/FineTunes.php
Normal file
50
libraries/jcb_powers/VDM.Joomla.Openai/src/FineTunes.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Openai;
|
||||
|
||||
|
||||
use VDM\Joomla\Openai\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Openai Fine Tunes
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class FineTunes extends Api
|
||||
{
|
||||
/**
|
||||
* List your organization's fine-tuning jobs
|
||||
* API Ref: https://platform.openai.com/docs/api-reference/fine-tunes/list
|
||||
*
|
||||
* @return object|null The response from the OpenAI API, or null if an error occurred.
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function list(): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/fine-tunes";
|
||||
|
||||
// Prepare the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the GET request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* More to follow: https://platform.openai.com/docs/api-reference/fine-tunes
|
||||
**/
|
||||
}
|
||||
|
203
libraries/jcb_powers/VDM.Joomla.Openai/src/Images.php
Normal file
203
libraries/jcb_powers/VDM.Joomla.Openai/src/Images.php
Normal file
@ -0,0 +1,203 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Openai;
|
||||
|
||||
|
||||
use VDM\Joomla\Openai\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Openai Images
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Images extends Api
|
||||
{
|
||||
/**
|
||||
* Generate an image given a text prompt.
|
||||
* API Ref: https://platform.openai.com/docs/api-reference/images/create
|
||||
*
|
||||
* @param string $prompt The text description of the desired image(s).
|
||||
* @param string|null $size The size of the generated images (optional).
|
||||
* @param string|null $responseFormat The format in which the images are returned (optional).
|
||||
* @param int|null $n The number of images to generate (optional).
|
||||
* @param string|null $user A unique identifier representing the end-user (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function generate(
|
||||
string $prompt,
|
||||
?string $size = null,
|
||||
?string $responseFormat = null,
|
||||
?int $n = null,
|
||||
?string $user = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/images/generations";
|
||||
|
||||
// Set the request data.
|
||||
$data = new \stdClass();
|
||||
$data->prompt = $prompt;
|
||||
|
||||
if ($size !== null)
|
||||
{
|
||||
$data->size = $size;
|
||||
}
|
||||
|
||||
if ($responseFormat !== null)
|
||||
{
|
||||
$data->response_format = $responseFormat;
|
||||
}
|
||||
|
||||
if ($n !== null)
|
||||
{
|
||||
$data->n = $n;
|
||||
}
|
||||
|
||||
if ($user !== null)
|
||||
{
|
||||
$data->user = $user;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an image edit with extended options.
|
||||
* API Ref: https://platform.openai.com/docs/api-reference/images/create-edit
|
||||
*
|
||||
* @param string $image The original image to edit. Must be a valid PNG file, less than 4MB, and square.
|
||||
* @param string|null $mask An additional image for editing (optional).
|
||||
* @param string $prompt A text description of the desired image(s).
|
||||
* @param string|null $size The size of the generated images (optional).
|
||||
* @param string|null $responseFormat The format in which the images are returned (optional).
|
||||
* @param int|null $n The number of images to generate (optional).
|
||||
* @param string|null $user A unique identifier representing your end-user (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function edit(
|
||||
string $image,
|
||||
string $prompt,
|
||||
?string $mask = null,
|
||||
?string $size = null,
|
||||
?string $responseFormat = null,
|
||||
?int $n = null,
|
||||
?string $user = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/images/edits";
|
||||
|
||||
// Set the image edit data.
|
||||
$data = new \stdClass();
|
||||
$data->image = $image;
|
||||
$data->prompt = $prompt;
|
||||
|
||||
if ($mask !== null)
|
||||
{
|
||||
$data->mask = $mask;
|
||||
}
|
||||
|
||||
if ($size !== null)
|
||||
{
|
||||
$data->size = $size;
|
||||
}
|
||||
|
||||
if ($responseFormat !== null)
|
||||
{
|
||||
$data->response_format = $responseFormat;
|
||||
}
|
||||
|
||||
if ($n !== null)
|
||||
{
|
||||
$data->n = $n;
|
||||
}
|
||||
|
||||
if ($user !== null)
|
||||
{
|
||||
$data->user = $user;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a variation of a given image.
|
||||
* API Ref: https://platform.openai.com/docs/api-reference/images/create-variation
|
||||
*
|
||||
* @param string $image The image to use as the basis for the variation(s).
|
||||
* @param string|null $size The size of the generated images (optional).
|
||||
* @param string|null $responseFormat The format in which the generated images are returned (optional).
|
||||
* @param int|null $n The number of images to generate (optional).
|
||||
* @param string|null $user A unique identifier representing your end-user (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function variation(
|
||||
string $image,
|
||||
?string $size = null,
|
||||
?string $responseFormat = null,
|
||||
?int $n = null,
|
||||
?string $user = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/images/variations";
|
||||
|
||||
// Set the image variation data.
|
||||
$data = new \stdClass();
|
||||
$data->image = $image;
|
||||
|
||||
if ($size !== null)
|
||||
{
|
||||
$data->size = $size;
|
||||
}
|
||||
|
||||
if ($responseFormat !== null)
|
||||
{
|
||||
$data->response_format = $responseFormat;
|
||||
}
|
||||
|
||||
if ($n !== null)
|
||||
{
|
||||
$data->n = $n;
|
||||
}
|
||||
|
||||
if ($user !== null)
|
||||
{
|
||||
$data->user = $user;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
44
libraries/jcb_powers/VDM.Joomla.Openai/src/Models.php
Normal file
44
libraries/jcb_powers/VDM.Joomla.Openai/src/Models.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Openai;
|
||||
|
||||
|
||||
use VDM\Joomla\Openai\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Openai Models
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Models extends Api
|
||||
{
|
||||
/**
|
||||
* List the available models from OpenAI API.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/models";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
60
libraries/jcb_powers/VDM.Joomla.Openai/src/Moderate.php
Normal file
60
libraries/jcb_powers/VDM.Joomla.Openai/src/Moderate.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Openai;
|
||||
|
||||
|
||||
use VDM\Joomla\Openai\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Openai Moderate
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Moderate extends Api
|
||||
{
|
||||
/**
|
||||
* Classify if text violates OpenAI's Content Policy.
|
||||
* API Ref: https://platform.openai.com/docs/api-reference/moderations/create
|
||||
*
|
||||
* @param string|array $input The input text to classify.
|
||||
* @param string|null $model The moderation model (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function text(
|
||||
$input,
|
||||
?string $model = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/moderations";
|
||||
|
||||
// Set the moderation data.
|
||||
$data = new \stdClass();
|
||||
$data->input = $input;
|
||||
|
||||
if ($model !== null)
|
||||
{
|
||||
$data->model = $model;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
247
libraries/jcb_powers/VDM.Joomla.Openai/src/Service/Api.php
Normal file
247
libraries/jcb_powers/VDM.Joomla.Openai/src/Service/Api.php
Normal file
@ -0,0 +1,247 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Openai\Service;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Openai\Audio;
|
||||
use VDM\Joomla\Openai\Chat;
|
||||
use VDM\Joomla\Openai\Completions;
|
||||
use VDM\Joomla\Openai\Edits;
|
||||
use VDM\Joomla\Openai\Embeddings;
|
||||
use VDM\Joomla\Openai\Files;
|
||||
use VDM\Joomla\Openai\FineTunes;
|
||||
use VDM\Joomla\Openai\Images;
|
||||
use VDM\Joomla\Openai\Models;
|
||||
use VDM\Joomla\Openai\Moderate;
|
||||
|
||||
|
||||
/**
|
||||
* The Openai Api Service
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Api implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Audio::class, 'Openai.Audio')
|
||||
->share('Openai.Audio', [$this, 'getAudio'], true);
|
||||
|
||||
$container->alias(Chat::class, 'Openai.Chat')
|
||||
->share('Openai.Chat', [$this, 'getChat'], true);
|
||||
|
||||
$container->alias(Completions::class, 'Openai.Completions')
|
||||
->share('Openai.Completions', [$this, 'getCompletions'], true);
|
||||
|
||||
$container->alias(Edits::class, 'Openai.Edits')
|
||||
->share('Openai.Edits', [$this, 'getEdits'], true);
|
||||
|
||||
$container->alias(Embeddings::class, 'Openai.Embeddings')
|
||||
->share('Openai.Embeddings', [$this, 'getEmbeddings'], true);
|
||||
|
||||
$container->alias(Files::class, 'Openai.Files')
|
||||
->share('Openai.Files', [$this, 'getFiles'], true);
|
||||
|
||||
$container->alias(FineTunes::class, 'Openai.FineTunes')
|
||||
->share('Openai.FineTunes', [$this, 'getFineTunes'], true);
|
||||
|
||||
$container->alias(Images::class, 'Openai.Images')
|
||||
->share('Openai.Images', [$this, 'getImages'], true);
|
||||
|
||||
$container->alias(Models::class, 'Openai.Models')
|
||||
->share('Openai.Models', [$this, 'getModels'], true);
|
||||
|
||||
$container->alias(Moderate::class, 'Openai.Moderate')
|
||||
->share('Openai.Moderate', [$this, 'getModerate'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Audio class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Audio
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getAudio(Container $container): Audio
|
||||
{
|
||||
return new Audio(
|
||||
$container->get('Openai.Utilities.Http'),
|
||||
$container->get('Openai.Utilities.Uri'),
|
||||
$container->get('Openai.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Chat class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Chat
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getChat(Container $container): Chat
|
||||
{
|
||||
return new Chat(
|
||||
$container->get('Openai.Utilities.Http'),
|
||||
$container->get('Openai.Utilities.Uri'),
|
||||
$container->get('Openai.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Completions class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Completions
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getCompletions(Container $container): Completions
|
||||
{
|
||||
return new Completions(
|
||||
$container->get('Openai.Utilities.Http'),
|
||||
$container->get('Openai.Utilities.Uri'),
|
||||
$container->get('Openai.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Edits class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Edits
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getEdits(Container $container): Edits
|
||||
{
|
||||
return new Edits(
|
||||
$container->get('Openai.Utilities.Http'),
|
||||
$container->get('Openai.Utilities.Uri'),
|
||||
$container->get('Openai.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Embeddings class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Embeddings
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getEmbeddings(Container $container): Embeddings
|
||||
{
|
||||
return new Embeddings(
|
||||
$container->get('Openai.Utilities.Http'),
|
||||
$container->get('Openai.Utilities.Uri'),
|
||||
$container->get('Openai.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Files class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Files
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getFiles(Container $container): Files
|
||||
{
|
||||
return new Files(
|
||||
$container->get('Openai.Utilities.Http'),
|
||||
$container->get('Openai.Utilities.Uri'),
|
||||
$container->get('Openai.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the FineTunes class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return FineTunes
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getFineTunes(Container $container): FineTunes
|
||||
{
|
||||
return new FineTunes(
|
||||
$container->get('Openai.Utilities.Http'),
|
||||
$container->get('Openai.Utilities.Uri'),
|
||||
$container->get('Openai.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Images class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Images
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getImages(Container $container): Images
|
||||
{
|
||||
return new Images(
|
||||
$container->get('Openai.Utilities.Http'),
|
||||
$container->get('Openai.Utilities.Uri'),
|
||||
$container->get('Openai.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Models class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Models
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getModels(Container $container): Models
|
||||
{
|
||||
return new Models(
|
||||
$container->get('Openai.Utilities.Http'),
|
||||
$container->get('Openai.Utilities.Uri'),
|
||||
$container->get('Openai.Utilities.Response')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Moderate class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Moderate
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getModerate(Container $container): Moderate
|
||||
{
|
||||
return new Moderate(
|
||||
$container->get('Openai.Utilities.Http'),
|
||||
$container->get('Openai.Utilities.Uri'),
|
||||
$container->get('Openai.Utilities.Response')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
113
libraries/jcb_powers/VDM.Joomla.Openai/src/Service/Utilities.php
Normal file
113
libraries/jcb_powers/VDM.Joomla.Openai/src/Service/Utilities.php
Normal file
@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Openai\Service;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Openai\Utilities\Uri;
|
||||
use VDM\Joomla\Openai\Utilities\Response;
|
||||
use VDM\Joomla\Openai\Utilities\Http;
|
||||
use VDM\Joomla\Utilities\Component\Helper;
|
||||
|
||||
|
||||
/**
|
||||
* The Openai Utilities Service
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Utilities implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Uri::class, 'Openai.Utilities.Uri')
|
||||
->share('Openai.Utilities.Uri', [$this, 'getUri'], true);
|
||||
|
||||
$container->alias(Response::class, 'Openai.Utilities.Response')
|
||||
->share('Openai.Utilities.Response', [$this, 'getResponse'], true);
|
||||
|
||||
$container->alias(Http::class, 'Openai.Utilities.Http')
|
||||
->share('Openai.Utilities.Http', [$this, 'getHttp'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Uri class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Uri
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getUri(Container $container): Uri
|
||||
{
|
||||
return new Uri();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Response class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Response
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getResponse(Container $container): Response
|
||||
{
|
||||
return new Response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Http class
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Http
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getHttp(Container $container): Http
|
||||
{
|
||||
$openai_token = null;
|
||||
$openai_org_token = null;
|
||||
if (Helper::getParams()->get('enable_open_ai') == 1)
|
||||
{
|
||||
$openai_token = Helper::getParams()->get('openai_token');
|
||||
if (Helper::getParams()->get('enable_open_ai_org') == 1)
|
||||
{
|
||||
$openai_org_token = Helper::getParams()->get('openai_org_token');
|
||||
}
|
||||
|
||||
if ($openai_token === 'secret')
|
||||
{
|
||||
$openai_token = null;
|
||||
}
|
||||
|
||||
if ($openai_org_token === 'secret')
|
||||
{
|
||||
$openai_org_token = null;
|
||||
}
|
||||
}
|
||||
|
||||
return new Http(
|
||||
$openai_token,
|
||||
$openai_org_token
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
139
libraries/jcb_powers/VDM.Joomla.Openai/src/Utilities/Http.php
Normal file
139
libraries/jcb_powers/VDM.Joomla.Openai/src/Utilities/Http.php
Normal file
@ -0,0 +1,139 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Openai\Utilities;
|
||||
|
||||
|
||||
use Joomla\CMS\Http\Http as JoomlaHttp;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* The Openai Http
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class Http extends JoomlaHttp
|
||||
{
|
||||
/**
|
||||
* The default Header
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $defaultHeaders = ['Content-Type' => 'application/json'];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string|null $token The Openai API token.
|
||||
* @param string|null $orgToken The Openai API Organization token.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @throws \InvalidArgumentException
|
||||
**/
|
||||
public function __construct(?string $token, ?string $orgToken = null)
|
||||
{
|
||||
// add the token if given
|
||||
if (is_string($token))
|
||||
{
|
||||
$this->defaultHeaders['Authorization'] = 'Bearer ' . $token;
|
||||
}
|
||||
|
||||
// add the organization token if given
|
||||
if (is_string($orgToken))
|
||||
{
|
||||
$this->defaultHeaders['OpenAI-Organization'] = $orgToken;
|
||||
}
|
||||
|
||||
// setup config
|
||||
$config = [
|
||||
'userAgent' => 'JoomlaOpenai/3.0',
|
||||
'headers' => $this->defaultHeaders
|
||||
];
|
||||
|
||||
$options = new Registry($config);
|
||||
|
||||
// run parent constructor
|
||||
parent::__construct($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the Tokens.
|
||||
*
|
||||
* @param string|null $token The Openai API token.
|
||||
* @param string|null $orgToken The Openai API Organization token.
|
||||
*
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function setTokens(?string $token = null, ?string $orgToken = null)
|
||||
{
|
||||
// get the current headers
|
||||
$this->defaultHeaders = (array) $this->getOption('headers',
|
||||
$this->defaultHeaders
|
||||
);
|
||||
|
||||
// add the token if given
|
||||
if (is_string($token))
|
||||
{
|
||||
$this->defaultHeaders['Authorization'] = 'Bearer ' . $token;
|
||||
}
|
||||
|
||||
// add the organization token if given
|
||||
if (is_string($orgToken))
|
||||
{
|
||||
$this->defaultHeaders['OpenAI-Organization'] = $orgToken;
|
||||
}
|
||||
|
||||
$this->setOption('headers', $this->defaultHeaders);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the User Token.
|
||||
*
|
||||
* @param string $token The API token.
|
||||
*
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function setToken(string $token)
|
||||
{
|
||||
// get the current headers
|
||||
$this->defaultHeaders = (array) $this->getOption('headers',
|
||||
$this->defaultHeaders
|
||||
);
|
||||
|
||||
// add the token
|
||||
$this->defaultHeaders['Authorization'] = 'Bearer ' . $token;
|
||||
|
||||
$this->setOption('headers', $this->defaultHeaders);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the Organization Token.
|
||||
*
|
||||
* @param string $token The Organization API token.
|
||||
*
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function setOrgToken(string $token)
|
||||
{
|
||||
// get the current headers
|
||||
$this->defaultHeaders = (array) $this->getOption('headers',
|
||||
$this->defaultHeader
|
||||
);
|
||||
|
||||
// add the token
|
||||
$this->defaultHeaders['OpenAI-Organization'] = $token;
|
||||
|
||||
$this->setOption('headers', $this->defaultHeaders);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Openai\Utilities;
|
||||
|
||||
|
||||
use Joomla\CMS\Http\Response as JoomlaResponse;
|
||||
use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
|
||||
|
||||
/**
|
||||
* The Openai Response
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class Response
|
||||
{
|
||||
/**
|
||||
* Process the response and decode it.
|
||||
*
|
||||
* @param JoomlaResponse $response The response.
|
||||
* @param integer $expectedCode The expected "good" code.
|
||||
* @param mixed $default The default if body not have length
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @throws \DomainException
|
||||
**/
|
||||
public function get(JoomlaResponse $response, int $expectedCode = 200, $default = null)
|
||||
{
|
||||
// Validate the response code.
|
||||
if ($response->code != $expectedCode)
|
||||
{
|
||||
// Decode the error response and throw an exception.
|
||||
$message = $this->error($response);
|
||||
|
||||
// Throw an exception with the OpenAI error message and code.
|
||||
throw new \DomainException($message, $response->code);
|
||||
}
|
||||
|
||||
return $this->body($response, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the response and decode it. (when we have multiple success codes)
|
||||
*
|
||||
* @param JoomlaResponse $response The response.
|
||||
* @param array [$expectedCode => $default] The expected "good" code. and The default if body not have length
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @throws \DomainException
|
||||
**/
|
||||
public function get_(JoomlaResponse $response, array $validate = [200 => null])
|
||||
{
|
||||
// Validate the response code.
|
||||
if (!isset($validate[$response->code]))
|
||||
{
|
||||
// Decode the error response and throw an exception.
|
||||
$message = $this->error($response);
|
||||
|
||||
// Throw an exception with the OpenAI error message and code.
|
||||
throw new \DomainException($message, $response->code);
|
||||
|
||||
}
|
||||
|
||||
return $this->body($response, $validate[$response->code]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the body from the response
|
||||
*
|
||||
* @param JoomlaResponse $response The response.
|
||||
* @param mixed $default The default if body not have length
|
||||
*
|
||||
* @return mixed
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected function body(JoomlaResponse $response, $default = null)
|
||||
{
|
||||
// check that we have a body and that its JSON
|
||||
if (isset($response->body) && StringHelper::check($response->body))
|
||||
{
|
||||
if (JsonHelper::check($response->body))
|
||||
{
|
||||
return json_decode((string) $response->body);
|
||||
}
|
||||
|
||||
return $response->body;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the error message from the OpenAI API response
|
||||
*
|
||||
* @param JoomlaResponse $response The response.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected function error(JoomlaResponse $response): string
|
||||
{
|
||||
// do we have a json string
|
||||
if (isset($response->body) && JsonHelper::check($response->body))
|
||||
{
|
||||
$error = json_decode($response->body);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 'Invalid or empty response body.';
|
||||
}
|
||||
|
||||
// check if OpenAI returned an error object
|
||||
if (isset($error->error))
|
||||
{
|
||||
// error object found, extract message and code
|
||||
$errorMessage = isset($error->error->message) ? $error->error->message : 'Unknown error.';
|
||||
$errorCode = isset($error->error->code) ? $error->error->code : 'Unknown error code.';
|
||||
|
||||
// return formatted error message
|
||||
return 'OpenAI Error: ' . $errorMessage . ' Code: ' . $errorCode;
|
||||
}
|
||||
|
||||
return 'No error information found in response.';
|
||||
}
|
||||
}
|
||||
|
115
libraries/jcb_powers/VDM.Joomla.Openai/src/Utilities/Uri.php
Normal file
115
libraries/jcb_powers/VDM.Joomla.Openai/src/Utilities/Uri.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Openai\Utilities;
|
||||
|
||||
|
||||
use Joomla\Uri\Uri as JoomlaUri;
|
||||
|
||||
|
||||
/**
|
||||
* The Openai Uri
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class Uri
|
||||
{
|
||||
/**
|
||||
* The api version
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private string $version;
|
||||
|
||||
/**
|
||||
* The api URL
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private string $url;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $url URL to the openai system
|
||||
* example: https://api.openai.com
|
||||
* @param string $version Version to the openai system
|
||||
*
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function __construct(
|
||||
string $url = 'https://api.openai.com',
|
||||
string $version = 'v1')
|
||||
{
|
||||
// set the API details
|
||||
$this->setUrl($url);
|
||||
$this->setVersion($version);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to build and return a full request URL for the request. This method will
|
||||
* add appropriate pagination details if necessary and also prepend the API url
|
||||
* to have a complete URL for the request.
|
||||
*
|
||||
* @param string $path URL to inflect
|
||||
*
|
||||
* @return JoomlaUri
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $path): JoomlaUri
|
||||
{
|
||||
// Get a new Uri object focusing the api url and given path.
|
||||
$uri = new JoomlaUri($this->api() . $path);
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full API URL
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function api(): string
|
||||
{
|
||||
return $this->url . '/' . $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the URL of the API
|
||||
*
|
||||
* @param string $url URL to your openai system
|
||||
* example: https://api.openai.com
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
**/
|
||||
private function setUrl(string $url)
|
||||
{
|
||||
return $this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the version of the API
|
||||
*
|
||||
* @param string $version version to your openai API
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
**/
|
||||
private function setVersion($version)
|
||||
{
|
||||
return $this->version = $version;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
1
libraries/jcb_powers/VDM.Joomla.Openai/src/index.html
Normal file
1
libraries/jcb_powers/VDM.Joomla.Openai/src/index.html
Normal file
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,272 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Abstraction;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Activeregistryinterface;
|
||||
|
||||
|
||||
/**
|
||||
* Active Storage Registry.
|
||||
*
|
||||
* Don't use this beyond 10 dimensional depth for best performance.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract class ActiveRegistry implements Activeregistryinterface
|
||||
{
|
||||
/**
|
||||
* The registry array.
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected array $active = [];
|
||||
|
||||
/**
|
||||
* Check if the registry has any content.
|
||||
*
|
||||
* @return bool Returns true if the active array is not empty, false otherwise.
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function isActive(): bool
|
||||
{
|
||||
return !empty($this->active);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all value from the active registry.
|
||||
*
|
||||
* @return array The values or empty array.
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function allActive(): array
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value into the registry using multiple keys.
|
||||
*
|
||||
* @param mixed $value The value to set.
|
||||
* @param string ...$keys The keys to determine the location.
|
||||
*
|
||||
* @throws \InvalidArgumentException If any of the keys are not a number or string.
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function setActive($value, string ...$keys): void
|
||||
{
|
||||
if (!$this->validActiveKeys($keys))
|
||||
{
|
||||
throw new \InvalidArgumentException("Keys must only be strings or numbers to set any value.");
|
||||
}
|
||||
|
||||
$array = &$this->active;
|
||||
|
||||
foreach ($keys as $key)
|
||||
{
|
||||
if (!isset($array[$key]))
|
||||
{
|
||||
if (!is_array($array))
|
||||
{
|
||||
$path = '[' . implode('][', $keys) . ']';
|
||||
throw new \InvalidArgumentException("Attempted to use key '{$key}' on a non-array value: {$array}. Path: {$path} Value: {$value}");
|
||||
}
|
||||
|
||||
$array[$key] = [];
|
||||
}
|
||||
$array = &$array[$key];
|
||||
}
|
||||
|
||||
$array = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds content into the registry. If a key exists,
|
||||
* it either appends or concatenates based on the value's type.
|
||||
*
|
||||
* @param mixed $value The value to set.
|
||||
* @param bool $asArray Determines if the new value should be treated as an array.
|
||||
* @param string ...$keys The keys to determine the location.
|
||||
*
|
||||
* @throws \InvalidArgumentException If any of the keys are not a number or string.
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function addActive($value, bool $asArray, string ...$keys): void
|
||||
{
|
||||
if (!$this->validActiveKeys($keys))
|
||||
{
|
||||
throw new \InvalidArgumentException("Keys must only be strings or numbers to add any value.");
|
||||
}
|
||||
|
||||
$array = &$this->active;
|
||||
|
||||
foreach ($keys as $key)
|
||||
{
|
||||
if (!isset($array[$key]))
|
||||
{
|
||||
if (!is_array($array))
|
||||
{
|
||||
$path = '[' . implode('][', $keys) . ']';
|
||||
throw new \InvalidArgumentException("Attempted to use key '{$key}' on a non-array value: {$array}. Path: {$path} Value: {$value}");
|
||||
}
|
||||
|
||||
$array[$key] = [];
|
||||
}
|
||||
$array = &$array[$key];
|
||||
}
|
||||
|
||||
// add string
|
||||
if (!$asArray && $array === [])
|
||||
{
|
||||
$array = '';
|
||||
}
|
||||
|
||||
// Handle the adding logic at the tip of the array
|
||||
if (is_array($array) || $asArray)
|
||||
{
|
||||
if (!is_array($array))
|
||||
{
|
||||
// Convert to array if it's not already an array
|
||||
$array = [$array];
|
||||
}
|
||||
$array[] = $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_string($value) || is_numeric($value))
|
||||
{
|
||||
$array .= (string) $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
$array = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a value (or sub-array) from the registry using multiple keys.
|
||||
*
|
||||
* @param mixed $default The default value if not set.
|
||||
* @param string ...$keys The keys to determine the location.
|
||||
*
|
||||
* @throws \InvalidArgumentException If any of the keys are not a number or string.
|
||||
* @return mixed The value or sub-array from the storage. Null if the location doesn't exist.
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getActive($default, string ...$keys)
|
||||
{
|
||||
if (!$this->validActiveKeys($keys))
|
||||
{
|
||||
throw new \InvalidArgumentException("Keys must only be strings or numbers to get any value.");
|
||||
}
|
||||
|
||||
$array = $this->active;
|
||||
|
||||
foreach ($keys as $key)
|
||||
{
|
||||
if (!isset($array[$key]))
|
||||
{
|
||||
return $default;
|
||||
}
|
||||
$array = $array[$key];
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a value (or sub-array) from the registry using multiple keys.
|
||||
*
|
||||
* @param string ...$keys The keys to determine the location.
|
||||
*
|
||||
* @throws \InvalidArgumentException If any of the keys are not a number or string.
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function removeActive(string ...$keys): void
|
||||
{
|
||||
if (!$this->validActiveKeys($keys))
|
||||
{
|
||||
throw new \InvalidArgumentException("Keys must only be strings or numbers to remove any value.");
|
||||
}
|
||||
|
||||
$array = &$this->active;
|
||||
$lastKey = array_pop($keys);
|
||||
|
||||
foreach ($keys as $key)
|
||||
{
|
||||
if (!isset($array[$key]))
|
||||
{
|
||||
return; // Exit early if the key doesn't exist
|
||||
}
|
||||
$array = &$array[$key];
|
||||
}
|
||||
|
||||
unset($array[$lastKey]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the existence of a particular location in the registry using multiple keys.
|
||||
*
|
||||
* @param string ...$keys The keys to determine the location.
|
||||
*
|
||||
* @throws \InvalidArgumentException If any of the keys are not a number or string.
|
||||
* @return bool True if the location exists, false otherwise.
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function existsActive(string ...$keys): bool
|
||||
{
|
||||
if (!$this->validActiveKeys($keys))
|
||||
{
|
||||
throw new \InvalidArgumentException("Keys must only be strings or numbers to check if any value exist.");
|
||||
}
|
||||
|
||||
$array = $this->active;
|
||||
|
||||
foreach ($keys as $key)
|
||||
{
|
||||
if (!isset($array[$key]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$array = $array[$key];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the keys are valid
|
||||
*
|
||||
* @param array $keys The keys to determine the location.
|
||||
*
|
||||
* @return bool False if any of the keys are not a number or string.
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function validActiveKeys(array $keys): bool
|
||||
{
|
||||
foreach ($keys as $key)
|
||||
{
|
||||
if ($key === '' || (!is_string($key) && !is_numeric($key)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
122
libraries/jcb_powers/VDM.Joomla/src/Abstraction/BaseConfig.php
Normal file
122
libraries/jcb_powers/VDM.Joomla/src/Abstraction/BaseConfig.php
Normal file
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Abstraction;
|
||||
|
||||
|
||||
use Joomla\Registry\Registry as JoomlaRegistry;
|
||||
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
|
||||
|
||||
|
||||
/**
|
||||
* Config
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract class BaseConfig extends JoomlaRegistry
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Instantiate the internal data object.
|
||||
$this->data = new \stdClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* setting any config value
|
||||
*
|
||||
* @param string $key The value's key/path name
|
||||
* @param mixed $value Optional default value, returned if the internal value is null.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __set(string $key, $value)
|
||||
{
|
||||
$this->set($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* getting any valid value
|
||||
*
|
||||
* @param string $key The value's key/path name
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @throws \InvalidArgumentException If $key is not a valid function name.
|
||||
*/
|
||||
public function __get(string $key)
|
||||
{
|
||||
// check if it has been set
|
||||
if (($value = $this->get($key, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(sprintf('Argument %s could not be found as function or path.', $key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a config value.
|
||||
*
|
||||
* @param string $path Registry path (e.g. joomla_content_showauthor)
|
||||
* @param mixed $default Optional default value, returned if the internal value is null.
|
||||
*
|
||||
* @return mixed Value of entry or null
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get($path, $default = null)
|
||||
{
|
||||
// function name with no underscores
|
||||
$method = 'get' . ucfirst((string) ClassfunctionHelper::safe(str_replace('_', '', $path)));
|
||||
|
||||
// check if it has been set
|
||||
if (($value = parent::get($path, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
elseif (method_exists($this, $method))
|
||||
{
|
||||
$value = $this->{$method}($default);
|
||||
|
||||
$this->set($path, $value);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append value to a path in registry of an array
|
||||
*
|
||||
* @param string $path Parent registry Path (e.g. joomla.content.showauthor)
|
||||
* @param mixed $value Value of entry
|
||||
*
|
||||
* @return mixed The value of the that has been set.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function appendArray(string $path, $value)
|
||||
{
|
||||
// check if it does not exist
|
||||
if (!$this->exists($path))
|
||||
{
|
||||
$this->set($path, []);
|
||||
}
|
||||
|
||||
return $this->append($path, $value);
|
||||
}
|
||||
}
|
||||
|
364
libraries/jcb_powers/VDM.Joomla/src/Abstraction/BaseTable.php
Normal file
364
libraries/jcb_powers/VDM.Joomla/src/Abstraction/BaseTable.php
Normal file
@ -0,0 +1,364 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Abstraction;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Tableinterface;
|
||||
|
||||
|
||||
/**
|
||||
* Base Table
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract class BaseTable implements Tableinterface
|
||||
{
|
||||
/**
|
||||
* All areas/views/tables with their field details
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected array $tables;
|
||||
|
||||
/**
|
||||
* All default fields
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected array $defaults = [
|
||||
'id' => [
|
||||
'order' => -1,
|
||||
'name' => 'id',
|
||||
'label' => 'ID',
|
||||
'type' => 'text',
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL
|
||||
],
|
||||
'ordering' => [
|
||||
'name' => 'ordering',
|
||||
'label' => 'Ordering',
|
||||
'type' => 'number',
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL
|
||||
],
|
||||
'published' => [
|
||||
'name' => 'published',
|
||||
'label' => 'Status',
|
||||
'type' => 'list',
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL
|
||||
],
|
||||
'modified_by' => [
|
||||
'name' => 'modified_by',
|
||||
'label' => 'Modified by',
|
||||
'type' => 'user',
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL
|
||||
],
|
||||
'modified' => [
|
||||
'name' => 'modified',
|
||||
'label' => 'Modified',
|
||||
'type' => 'calendar',
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL
|
||||
],
|
||||
'created_by' => [
|
||||
'name' => 'created_by',
|
||||
'label' => 'Created by',
|
||||
'type' => 'user',
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL
|
||||
],
|
||||
'created' => [
|
||||
'name' => 'created',
|
||||
'label' => 'Created',
|
||||
'type' => 'calendar',
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL
|
||||
],
|
||||
'hits' => [
|
||||
'name' => 'hits',
|
||||
'label' => 'Hits',
|
||||
'type' => 'number',
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL
|
||||
],
|
||||
'version' => [
|
||||
'name' => 'version',
|
||||
'label' => 'Version',
|
||||
'type' => 'text',
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* Get any value from a item/field/column of an area/view/table
|
||||
* Example: $this->get('table_name', 'field_name', 'value_key');
|
||||
* Get an item/field/column of an area/view/table
|
||||
* Example: $this->get('table_name', 'field_name');
|
||||
* Get all items/fields/columns of an area/view/table
|
||||
* Example: $this->get('table_name');
|
||||
* Get all areas/views/tables with all their item/field/column details
|
||||
* Example: $this->get('All');
|
||||
*
|
||||
* @param string $table The table
|
||||
* @param string|null $field The field
|
||||
* @param string|null $key The value key
|
||||
*
|
||||
* @return mixed
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(string $table, ?string $field = null, ?string $key = null)
|
||||
{
|
||||
// return the item/field/column of an area/view/table
|
||||
if (is_string($field) && is_string($key))
|
||||
{
|
||||
// return the value of a item/field/column of an area/view/table
|
||||
if (isset($this->tables[$table][$field][$key]))
|
||||
{
|
||||
return $this->tables[$table][$field][$key];
|
||||
}
|
||||
|
||||
return $this->getDefaultKey($field, $key);
|
||||
}
|
||||
// return the item/field/column of an area/view/table
|
||||
elseif (is_string($field))
|
||||
{
|
||||
if (isset($this->tables[$table][$field]))
|
||||
{
|
||||
return $this->tables[$table][$field];
|
||||
}
|
||||
|
||||
return $this->getDefault($field);
|
||||
}
|
||||
// return an area/view/table
|
||||
elseif ($table !== 'All')
|
||||
{
|
||||
if (isset($this->tables[$table]))
|
||||
{
|
||||
return $this->tables[$table];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// return all
|
||||
return $this->tables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title field from an area/view/table
|
||||
*
|
||||
* @param string $table The area
|
||||
*
|
||||
* @return ?array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function title(string $table): ?array
|
||||
{
|
||||
// return the title item/field/column of an area/view/table
|
||||
if (($table = $this->get($table)) !== null)
|
||||
{
|
||||
foreach ($table as $item)
|
||||
{
|
||||
if ($item['title'])
|
||||
{
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// none found
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title field name
|
||||
*
|
||||
* @param string $table The area
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function titleName(string $table): string
|
||||
{
|
||||
// return the title name of an area/view/table
|
||||
if (($field = $this->title($table)) !== null)
|
||||
{
|
||||
return $field['name'];
|
||||
}
|
||||
|
||||
// none found default to ID
|
||||
return 'id';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all tables
|
||||
*
|
||||
* @return array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function tables(): array
|
||||
{
|
||||
// return all areas/views/tables
|
||||
return array_keys($this->tables);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a table (and field) exist
|
||||
*
|
||||
* @param string $table The area
|
||||
* @param string|null $field The area
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function exist(string $table, ?string $field = null): bool
|
||||
{
|
||||
if (isset($this->tables[$table]))
|
||||
{
|
||||
// if we have a field
|
||||
if (is_string($field))
|
||||
{
|
||||
if (isset($this->tables[$table][$field]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->isDefault($field);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all fields of an area/view/table
|
||||
*
|
||||
* @param string $table The area
|
||||
* @param bool $default Add the default fields
|
||||
*
|
||||
* @return array|null On success an array of fields
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function fields(string $table, bool $default = false): ?array
|
||||
{
|
||||
// return all fields of an area/view/table
|
||||
if (($table = $this->get($table)) !== null)
|
||||
{
|
||||
if ($default)
|
||||
{
|
||||
return $this->addDefault(array_keys($table));
|
||||
}
|
||||
else
|
||||
{
|
||||
return array_keys($table);
|
||||
}
|
||||
}
|
||||
|
||||
// none found
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the default fields
|
||||
*
|
||||
* @param array $fields The table dynamic fields
|
||||
*
|
||||
* @return array Fields (with defaults added)
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function addDefault(array $fields): array
|
||||
{
|
||||
// add default fields
|
||||
foreach ($this->defaults as $default)
|
||||
{
|
||||
// used just for loading the fields
|
||||
$order = $default['order'] ?? 1;
|
||||
unset($default['order']);
|
||||
|
||||
if ($order < 0)
|
||||
{
|
||||
array_unshift($fields, $default['name']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$fields[] = $default['name'];
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the field is a default field
|
||||
*
|
||||
* @param string $field The field to check
|
||||
*
|
||||
* @return bool True if a default field
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function isDefault(string $field): bool
|
||||
{
|
||||
return isset($this->defaults[$field]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a default field
|
||||
*
|
||||
* @param string $field The field to check
|
||||
*
|
||||
* @return array|null True if a default field
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getDefault(string $field): ?array
|
||||
{
|
||||
return $this->defaults[$field] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a default field property
|
||||
*
|
||||
* @param string $field The field to check
|
||||
* @param string $key The field key/property to check
|
||||
*
|
||||
* @return string|null String value if a default field property exist
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getDefaultKey(string $field, string $key): ?string
|
||||
{
|
||||
return $this->defaults[$field][$key] ?? null;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Abstraction;
|
||||
namespace VDM\Joomla\Abstraction;
|
||||
|
||||
|
||||
use Joomla\CMS\Factory as JoomlaFactory;
|
||||
@ -113,7 +113,6 @@ abstract class Database
|
||||
}
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -9,16 +9,16 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Abstraction;
|
||||
namespace VDM\Joomla\Abstraction;
|
||||
|
||||
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Componentbuilder\Table;
|
||||
use VDM\Joomla\Interfaces\Tableinterface as Table;
|
||||
|
||||
|
||||
/**
|
||||
* Our base Model
|
||||
* Base Model
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
@ -69,14 +69,20 @@ abstract class Model
|
||||
* Model the values of an item
|
||||
* Example: $this->item(Object, 'table_name');
|
||||
*
|
||||
* @param object $item The item object
|
||||
* @param object|null $item The item object
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function item(object $item, ?string $table = null): ?object
|
||||
public function item(?object $item, ?string $table = null): ?object
|
||||
{
|
||||
// we must have an object
|
||||
if (empty($item))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// set the table name
|
||||
if (empty($table))
|
||||
{
|
||||
@ -114,7 +120,7 @@ abstract class Model
|
||||
}
|
||||
}
|
||||
|
||||
// all items must have more than one field or its empty (1 = id or guid)
|
||||
// all items must have more than one field or its empty (1 = key)
|
||||
if ($field_number > 1)
|
||||
{
|
||||
return $item_bucket;
|
||||
@ -172,14 +178,20 @@ abstract class Model
|
||||
* Model the values of an row
|
||||
* Example: $this->item(Array, 'table_name');
|
||||
*
|
||||
* @param array $item The item array
|
||||
* @param array|null $item The item array
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function row(array $item, ?string $table = null): ?array
|
||||
public function row(?array $item, ?string $table = null): ?array
|
||||
{
|
||||
// we must have an array
|
||||
if (empty($item))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// set the table name
|
||||
if (empty($table))
|
||||
{
|
||||
@ -341,7 +353,6 @@ abstract class Model
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract protected function getTable(): string;
|
||||
|
||||
abstract protected function getTable(): string;
|
||||
}
|
||||
|
182
libraries/jcb_powers/VDM.Joomla/src/Abstraction/Registry.php
Normal file
182
libraries/jcb_powers/VDM.Joomla/src/Abstraction/Registry.php
Normal file
@ -0,0 +1,182 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Abstraction;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Activeregistryinterface;
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\ActiveRegistry;
|
||||
|
||||
|
||||
/**
|
||||
* VDM Basic Registry.
|
||||
*
|
||||
* Don't use this beyond 10 dimensional depth for best performance.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract class Registry extends ActiveRegistry implements Activeregistryinterface, Registryinterface
|
||||
{
|
||||
/**
|
||||
* Path separator
|
||||
*
|
||||
* @var string|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected ?string $separator = '.';
|
||||
|
||||
/**
|
||||
* Sets a value into the registry using multiple keys.
|
||||
*
|
||||
* @param string $path Registry path (e.g. vdm.content.builder)
|
||||
* @param mixed $value Value of entry
|
||||
*
|
||||
* @throws \InvalidArgumentException If any of the path values are not a number or string.
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function set(string $path, $value): void
|
||||
{
|
||||
if (($keys = $this->getActiveKeys($path)) === null)
|
||||
{
|
||||
throw new \InvalidArgumentException("Path must only be strings or numbers to set any value.");
|
||||
}
|
||||
|
||||
$this->setActive($value, ...$keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds content into the registry. If a key exists,
|
||||
* it either appends or concatenates based on $asArray switch.
|
||||
*
|
||||
* @param string $path Registry path (e.g. vdm.content.builder)
|
||||
* @param mixed $value Value of entry
|
||||
* @param bool $asArray Determines if the new value should be treated as an array. Default is false.
|
||||
*
|
||||
* @throws \InvalidArgumentException If any of the path values are not a number or string.
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function add(string $path, $value, bool $asArray = false): void
|
||||
{
|
||||
if (($keys = $this->getActiveKeys($path)) === null)
|
||||
{
|
||||
throw new \InvalidArgumentException("Path must only be strings or numbers to add any value.");
|
||||
}
|
||||
|
||||
$this->addActive($value, $asArray, ...$keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a value (or sub-array) from the registry using multiple keys.
|
||||
*
|
||||
* @param string $path Registry path (e.g. vdm.content.builder)
|
||||
* @param mixed $default Optional default value, returned if the internal doesn't exist.
|
||||
*
|
||||
* @throws \InvalidArgumentException If any of the path values are not a number or string.
|
||||
* @return mixed The value or sub-array from the storage. Null if the location doesn't exist.
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(string $path, $default = null)
|
||||
{
|
||||
if (($keys = $this->getActiveKeys($path)) === null)
|
||||
{
|
||||
throw new \InvalidArgumentException("Path must only be strings or numbers to get any value.");
|
||||
}
|
||||
|
||||
return $this->getActive($default, ...$keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a value (or sub-array) from the registry using multiple keys.
|
||||
*
|
||||
* @param string $path Registry path (e.g. vdm.content.builder)
|
||||
*
|
||||
* @throws \InvalidArgumentException If any of the path values are not a number or string.
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function remove(string $path): void
|
||||
{
|
||||
if (($keys = $this->getActiveKeys($path)) === null)
|
||||
{
|
||||
throw new \InvalidArgumentException("Path must only be strings or numbers to remove any value.");
|
||||
}
|
||||
|
||||
$this->removeActive(...$keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the existence of a particular location in the registry using multiple keys.
|
||||
*
|
||||
* @param string $path Registry path (e.g. vdm.content.builder)
|
||||
*
|
||||
* @throws \InvalidArgumentException If any of the path values are not a number or string.
|
||||
* @return bool True if the location exists, false otherwise.
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function exists(string $path): bool
|
||||
{
|
||||
if (($keys = $this->getActiveKeys($path)) === null)
|
||||
{
|
||||
throw new \InvalidArgumentException("Path must only be strings or numbers to check if any value exist.");
|
||||
}
|
||||
|
||||
return $this->existsActive(...$keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a separator value
|
||||
*
|
||||
* @param string|null $value The value to set.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function setSeparator(?string $value): void
|
||||
{
|
||||
$this->separator = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get that the active keys from a path
|
||||
*
|
||||
* @param string $path The path to determine the location registry.
|
||||
*
|
||||
* @return array|null The valid array of keys
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getActiveKeys(string $path): ?array
|
||||
{
|
||||
// empty path no allowed
|
||||
if ($path === '')
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Flatten the path
|
||||
if ($this->separator === null || $this->separator === '')
|
||||
{
|
||||
return [$path];
|
||||
}
|
||||
|
||||
$keys = array_values(array_filter(explode($this->separator, $path), 'strlen'));
|
||||
|
||||
if (empty($keys))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return $keys;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Abstraction\Registry\Traits;
|
||||
|
||||
|
||||
/**
|
||||
* Count Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
trait Count
|
||||
{
|
||||
/**
|
||||
* Retrieves number of values (or sub-array) from the storage using multiple keys.
|
||||
*
|
||||
* @param string $path Storage path (e.g. vdm.content.builder)
|
||||
*
|
||||
* @throws \InvalidArgumentException If any of the path values are not a number or string.
|
||||
* @return int The number of values
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function count(string $path): int
|
||||
{
|
||||
if (($values = $this->get($path)) === null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (is_array($values))
|
||||
{
|
||||
return count($values);
|
||||
}
|
||||
|
||||
if (is_object($values))
|
||||
{
|
||||
return count((array) $values);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Abstraction\Registry\Traits;
|
||||
|
||||
|
||||
/**
|
||||
* Get String Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
trait GetString
|
||||
{
|
||||
/**
|
||||
* Get a registry path if the return value is a string
|
||||
*
|
||||
* @param string $path Registry path (e.g. joomla.content.showauthor)
|
||||
* @param string|null $default A default value
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getString(string $path, ?string $default = null): ?string
|
||||
{
|
||||
// Return default value if path is empty
|
||||
if (empty($path))
|
||||
{
|
||||
return $default;
|
||||
}
|
||||
|
||||
// get the value
|
||||
if (($node = $this->get($path)) !== null
|
||||
&& is_string($node)
|
||||
&& strlen((string) $node) > 0)
|
||||
{
|
||||
return $node;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Abstraction\Registry\Traits;
|
||||
|
||||
|
||||
/**
|
||||
* Check if a value is in an array
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
trait InArray
|
||||
{
|
||||
/**
|
||||
* Check if a value is found in an array
|
||||
*
|
||||
* @param mixed $value The value to check for
|
||||
* @param string|null $path Registry path (e.g. joomla.content.showauthor)
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function inArray($value, ?string $path = null): bool
|
||||
{
|
||||
// Check base array if no path is given
|
||||
if (empty($path))
|
||||
{
|
||||
return in_array($value, $this->active);
|
||||
}
|
||||
|
||||
// get the value
|
||||
if (($node = $this->get($path)) !== null
|
||||
&& is_array($node)
|
||||
&& in_array($value, $node))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Abstraction\Registry\Traits;
|
||||
|
||||
|
||||
/**
|
||||
* Check if a value is in an array
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
trait IsArray
|
||||
{
|
||||
/**
|
||||
* Check if a path is an array
|
||||
*
|
||||
* @param string $path Registry path (e.g. joomla.content.showauthor)
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function isArray(string $path): bool
|
||||
{
|
||||
// Check base array if no path is given
|
||||
if (empty($path))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// get the value
|
||||
if (($node = $this->get($path)) !== null
|
||||
&& is_array($node))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Abstraction\Registry\Traits;
|
||||
|
||||
|
||||
/**
|
||||
* Is String Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
trait IsString
|
||||
{
|
||||
/**
|
||||
* Check if a registry path exists and is a string
|
||||
*
|
||||
* @param string $path Registry path (e.g. joomla.content.showauthor)
|
||||
*
|
||||
* @return boolean
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function isString(string $path): bool
|
||||
{
|
||||
// Return default value if path is empty
|
||||
if (empty($path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// get the value
|
||||
if (($node = $this->get($path)) !== null
|
||||
&& is_string($node)
|
||||
&& strlen((string) $node) > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Abstraction\Registry\Traits;
|
||||
|
||||
|
||||
/**
|
||||
* To String Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
trait ToString
|
||||
{
|
||||
/**
|
||||
* Convert an array of values to a string (or return string)
|
||||
*
|
||||
* @param string $path Registry path (e.g. joomla.content.showauthor)
|
||||
* @param string $seperator Return string separator
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function toString(string $path, string $separator = ''): string
|
||||
{
|
||||
// Return default value if path is empty
|
||||
if (empty($path))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
// get the value
|
||||
if (($node = $this->get($path)) !== null)
|
||||
{
|
||||
if (is_array($node) && $node !== [])
|
||||
{
|
||||
return implode($separator, $node);
|
||||
}
|
||||
elseif (is_string($node) && strlen((string) $node) > 0)
|
||||
{
|
||||
return $node;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Abstraction\Registry\Traits;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
|
||||
|
||||
/**
|
||||
* Var Export Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
trait VarExport
|
||||
{
|
||||
/**
|
||||
* Default indentation value
|
||||
*
|
||||
* @var int
|
||||
* @since 3.4.0
|
||||
*/
|
||||
protected int $indent = 2;
|
||||
|
||||
/**
|
||||
* Method to export a set of values to a PHP array
|
||||
*
|
||||
* @param string|null $path Registry path (e.g. joomla.content.showauthor)
|
||||
* @param int $indentation The default indentation
|
||||
*
|
||||
* @return ?string The var set being exported as a PHP array
|
||||
* @since 3.4.0
|
||||
*/
|
||||
public function varExport(?string $path = null, int $indentation = 2): ?string
|
||||
{
|
||||
// Load the data array
|
||||
if ($path === null && $this->isActive())
|
||||
{
|
||||
$data = $this->allActive();
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = $this->get($path);
|
||||
}
|
||||
|
||||
// check if we have data
|
||||
if ($data === null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// set the default indentation value
|
||||
$this->indent = $indentation;
|
||||
|
||||
// convert to string
|
||||
$data = var_export($data, true);
|
||||
|
||||
// replace all space with system indentation
|
||||
$data = preg_replace_callback("/^(\s{2})(\s{2})?(\s{2})?(\s{2})?(\s{2})?(\s{2})?(\s{2})?(\s{2})?(\s{2})?(\s{2})?(\s{2})?(.*)/m", [$this, 'convertIndent'], $data);
|
||||
|
||||
// convert all array to []
|
||||
$array = preg_split("/\r\n|\n|\r/", $data);
|
||||
$array = preg_replace(["/\s*array\s\($/", "/\)(,)?$/", "/\s=>\s$/"], [NULL, ']$1', ' => ['], $array);
|
||||
$data = implode(PHP_EOL, array_filter(["["] + $array));
|
||||
|
||||
// add needed indentation to the last ]
|
||||
$data = preg_replace("/^(\])/m", Indent::_($indentation) . '$1', $data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to convert found of grouped spaces to system indentation
|
||||
*
|
||||
* @param array $matches The regex array of matching values
|
||||
*
|
||||
* @return string The resulting string.
|
||||
* @since 3.4.0
|
||||
*/
|
||||
protected function convertIndent(array $matches): string
|
||||
{
|
||||
// set number to indent by default
|
||||
$indent = Indent::_($this->indent);
|
||||
|
||||
// update each found space (group) with one indentation
|
||||
foreach (range(1, 11) as $space)
|
||||
{
|
||||
if (strlen((string) $matches[$space]) > 0)
|
||||
{
|
||||
$indent .= Indent::_(1);
|
||||
}
|
||||
}
|
||||
|
||||
return $indent . $matches[12];
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -15,6 +15,7 @@ namespace VDM\Joomla\Componentbuilder\Abstraction;
|
||||
use Joomla\Registry\Registry as JoomlaRegistry;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\Input\Input;
|
||||
use VDM\Joomla\Abstraction\BaseConfig as Config;
|
||||
use VDM\Joomla\Utilities\Component\Helper;
|
||||
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
|
||||
|
||||
@ -24,7 +25,7 @@ use VDM\Joomla\Utilities\String\ClassfunctionHelper;
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract class BaseConfig extends JoomlaRegistry
|
||||
abstract class BaseConfig extends Config
|
||||
{
|
||||
/**
|
||||
* Hold a JInput object for easier access to the input variables.
|
||||
@ -56,94 +57,8 @@ abstract class BaseConfig extends JoomlaRegistry
|
||||
$this->input = $input ?: Factory::getApplication()->input;
|
||||
$this->params = $params ?: Helper::getParams('com_componentbuilder');
|
||||
|
||||
// Instantiate the internal data object.
|
||||
$this->data = new \stdClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* setting any config value
|
||||
*
|
||||
* @param string $key The value's key/path name
|
||||
* @param mixed $value Optional default value, returned if the internal value is null.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __set(string $key, $value)
|
||||
{
|
||||
$this->set($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* getting any valid value
|
||||
*
|
||||
* @param string $key The value's key/path name
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @throws \InvalidArgumentException If $key is not a valid function name.
|
||||
*/
|
||||
public function __get(string $key)
|
||||
{
|
||||
// check if it has been set
|
||||
if (($value = $this->get($key, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(sprintf('Argument %s could not be found as function or path.', $key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a config value.
|
||||
*
|
||||
* @param string $path Registry path (e.g. joomla_content_showauthor)
|
||||
* @param mixed $default Optional default value, returned if the internal value is null.
|
||||
*
|
||||
* @return mixed Value of entry or null
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get($path, $default = null)
|
||||
{
|
||||
// function name with no underscores
|
||||
$method = 'get' . ucfirst((string) ClassfunctionHelper::safe(str_replace('_', '', $path)));
|
||||
|
||||
// check if it has been set
|
||||
if (($value = parent::get($path, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
elseif (method_exists($this, $method))
|
||||
{
|
||||
$value = $this->{$method}($default);
|
||||
|
||||
$this->set($path, $value);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append value to a path in registry of an array
|
||||
*
|
||||
* @param string $path Parent registry Path (e.g. joomla.content.showauthor)
|
||||
* @param mixed $value Value of entry
|
||||
*
|
||||
* @return mixed The value of the that has been set.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function appendArray(string $path, $value)
|
||||
{
|
||||
// check if it does not exist
|
||||
if (!$this->exists($path))
|
||||
{
|
||||
$this->set($path, []);
|
||||
}
|
||||
|
||||
return $this->append($path, $value);
|
||||
}
|
||||
|
||||
// run parent constructor
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,295 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Abstraction;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Mapperdoubleinterface;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Mappersingleinterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Mapper
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract class Mapper implements Mapperdoubleinterface, Mappersingleinterface
|
||||
{
|
||||
|
||||
/**
|
||||
* The Content
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public array $active = [];
|
||||
|
||||
/**
|
||||
* Check if any values are set in the active array
|
||||
*
|
||||
* @return bool Returns true if the active array is not empty, false otherwise
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function isActive(): bool
|
||||
{
|
||||
return !empty($this->active);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set content
|
||||
*
|
||||
* @param string $key The main string key
|
||||
* @param mixed $value The values to set
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function set(string $key, $value)
|
||||
{
|
||||
$this->active[$this->key($key)] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content
|
||||
*
|
||||
* @param string $key The main string key
|
||||
*
|
||||
* @return mixed
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(string $key)
|
||||
{
|
||||
return $this->active[$this->key($key)] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does key exist
|
||||
*
|
||||
* @param string $key The main string key
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function exist(string $key): bool
|
||||
{
|
||||
if (isset($this->active[$this->key($key)]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add content
|
||||
*
|
||||
* @param string $key The main string key
|
||||
* @param mixed $value The values to set
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function add(string $key, $value)
|
||||
{
|
||||
if (isset($this->active[$this->key($key)]))
|
||||
{
|
||||
$this->active[$this->key($key)] .= $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->active[$this->key($key)] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove content
|
||||
*
|
||||
* @param string $key The main string key
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function remove(string $key)
|
||||
{
|
||||
unset($this->active[$this->key($key)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Model the key
|
||||
*
|
||||
* @param string $key The key to model
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract protected function key(string $key): string;
|
||||
|
||||
/**
|
||||
* The Dynamic Content
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public array $_active = [];
|
||||
|
||||
/**
|
||||
* Check if any values are set in the active array.
|
||||
*
|
||||
* @param string|null $firstKey Optional. The first key to check for values.
|
||||
*
|
||||
* @return bool True if the active array or the specified subarray is not empty, false otherwise.
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function isActive_(string $firstKey = null): bool
|
||||
{
|
||||
// If a firstKey is provided, check if it has any values.
|
||||
if (is_string($firstKey))
|
||||
{
|
||||
// Get the first key from the input parameter and check if it exists in the active array.
|
||||
$firstKey = $this->firstKey($firstKey);
|
||||
if (isset($this->_active[$firstKey]))
|
||||
{
|
||||
return !empty($this->_active[$firstKey]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// If no firstKey is provided, check if the entire active array has any values.
|
||||
return !empty($this->_active);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set dynamic content
|
||||
*
|
||||
* @param string $firstKey The first key
|
||||
* @param string $secondKey The second key
|
||||
* @param mixed $value The values to set
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function set_(string $firstKey, string $secondKey, $value)
|
||||
{
|
||||
$this->_active[$this->firstKey($firstKey)]
|
||||
[$this->secondKey($secondKey)] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get dynamic content
|
||||
*
|
||||
* @param string $firstKey The first key
|
||||
* @param string|null $secondKey The second key
|
||||
*
|
||||
* @return mixed
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get_(string $firstKey, ?string $secondKey = null)
|
||||
{
|
||||
if (is_string($secondKey))
|
||||
{
|
||||
return $this->_active[$this->firstKey($firstKey)]
|
||||
[$this->secondKey($secondKey)] ?? null;
|
||||
}
|
||||
return $this->_active[$this->firstKey($firstKey)] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does keys exist
|
||||
*
|
||||
* @param string $firstKey The first key
|
||||
* @param string|null $secondKey The second key
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function exist_(string $firstKey, ?string $secondKey = null): bool
|
||||
{
|
||||
if (is_string($secondKey) && isset($this->_active[$this->firstKey($firstKey)]) &&
|
||||
isset($this->_active[$this->firstKey($firstKey)]
|
||||
[$this->secondKey($secondKey)]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
elseif (is_null($secondKey) && isset($this->_active[$this->firstKey($firstKey)]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add dynamic content
|
||||
*
|
||||
* @param string $firstKey The first key
|
||||
* @param string $secondKey The second key
|
||||
* @param mixed $value The values to set
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function add_(string $firstKey, string $secondKey, $value)
|
||||
{
|
||||
if (isset($this->_active[$this->firstKey($firstKey)]) &&
|
||||
isset($this->_active[$this->firstKey($firstKey)]
|
||||
[$this->secondKey($secondKey)]))
|
||||
{
|
||||
$this->_active[$this->firstKey($firstKey)]
|
||||
[$this->secondKey($secondKey)] .= $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_active[$this->firstKey($firstKey)]
|
||||
[$this->secondKey($secondKey)] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove dynamic content
|
||||
*
|
||||
* @param string $firstKey The first key
|
||||
* @param string|null $secondKey The second key
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function remove_(string $firstKey, ?string $secondKey = null)
|
||||
{
|
||||
if (is_string($secondKey))
|
||||
{
|
||||
unset($this->_active[$this->firstKey($firstKey)]
|
||||
[$this->secondKey($secondKey)]);
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($this->_active[$this->firstKey($firstKey)]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Model the first key
|
||||
*
|
||||
* @param string $key The first key to model
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract protected function firstKey(string $key): string;
|
||||
|
||||
/**
|
||||
* Model the second key
|
||||
*
|
||||
* @param string $key The second key to model
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract protected function secondKey(string $key): string;
|
||||
}
|
||||
|
@ -1,133 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Abstraction;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Mappersingleinterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Mapper Single
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract class MapperSingle implements Mappersingleinterface
|
||||
{
|
||||
|
||||
/**
|
||||
* The Content
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public array $active = [];
|
||||
|
||||
/**
|
||||
* Check if any values are set in the active array
|
||||
*
|
||||
* @return bool Returns true if the active array is not empty, false otherwise
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function isActive(): bool
|
||||
{
|
||||
return !empty($this->active);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set content
|
||||
*
|
||||
* @param string $key The main string key
|
||||
* @param mixed $value The values to set
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function set(string $key, $value)
|
||||
{
|
||||
$this->active[$this->key($key)] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content
|
||||
*
|
||||
* @param string $key The main string key
|
||||
*
|
||||
* @return mixed
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(string $key)
|
||||
{
|
||||
return $this->active[$this->key($key)] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does key exist
|
||||
*
|
||||
* @param string $key The main string key
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function exist(string $key): bool
|
||||
{
|
||||
if (isset($this->active[$this->key($key)]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add content
|
||||
*
|
||||
* @param string $key The main string key
|
||||
* @param mixed $value The values to set
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function add(string $key, $value)
|
||||
{
|
||||
if (isset($this->active[$this->key($key)]))
|
||||
{
|
||||
$this->active[$this->key($key)] .= $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->active[$this->key($key)] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove content
|
||||
*
|
||||
* @param string $key The main string key
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function remove(string $key)
|
||||
{
|
||||
unset($this->active[$this->key($key)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Model the key
|
||||
*
|
||||
* @param string $key The key to model
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract protected function key(string $key): string;
|
||||
}
|
||||
|
@ -13,29 +13,28 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Adminview;
|
||||
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Registry;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Customtabs;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Tabs;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Fields;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Historyadminview;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Historyadminview as History;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Permissions;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Conditions;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Relations;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Linkedviews;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Javascriptadminview;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Cssadminview;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Phpadminview;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Javascriptadminview as Javascript;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Cssadminview as Css;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Phpadminview as Php;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Custombuttons;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Customimportscripts;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Ajaxadmin;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Ajaxadmin as Ajax;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Customalias;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Sql;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Mysqlsettings;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\SiteEditView;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
@ -49,189 +48,181 @@ use VDM\Joomla\Utilities\ArrayHelper;
|
||||
class Data
|
||||
{
|
||||
/**
|
||||
* Admin views
|
||||
* The Config Class.
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $data;
|
||||
|
||||
/**
|
||||
* Compiler Config
|
||||
*
|
||||
* @var Config
|
||||
* @var Config
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* The compiler registry
|
||||
* The EventInterface Class.
|
||||
*
|
||||
* @var Registry
|
||||
* @var Event
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Registry $registry;
|
||||
protected Event $event;
|
||||
|
||||
/**
|
||||
* Compiler Event
|
||||
* The Placeholder Class.
|
||||
*
|
||||
* @var EventInterface
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected EventInterface $event;
|
||||
|
||||
/**
|
||||
* Compiler Placeholder
|
||||
*
|
||||
* @var Placeholder
|
||||
* @var Placeholder
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Placeholder $placeholder;
|
||||
|
||||
/**
|
||||
* Compiler Customcode Dispenser
|
||||
* The Dispenser Class.
|
||||
*
|
||||
* @var Dispenser
|
||||
* @var Dispenser
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Dispenser $dispenser;
|
||||
|
||||
/**
|
||||
* The modelling customtabs
|
||||
* The Customtabs Class.
|
||||
*
|
||||
* @var Customtabs
|
||||
* @var Customtabs
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Customtabs $customtabs;
|
||||
|
||||
/**
|
||||
* The modelling tabs
|
||||
* The Tabs Class.
|
||||
*
|
||||
* @var Tabs
|
||||
* @var Tabs
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Tabs $tabs;
|
||||
|
||||
/**
|
||||
* The modelling fields
|
||||
* The Fields Class.
|
||||
*
|
||||
* @var Fields
|
||||
* @var Fields
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Fields $fields;
|
||||
|
||||
/**
|
||||
* The modelling admin view history
|
||||
* The Historyadminview Class.
|
||||
*
|
||||
* @var Historyadminview
|
||||
* @var History
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Historyadminview $history;
|
||||
protected History $history;
|
||||
|
||||
/**
|
||||
* The modelling permissions
|
||||
* The Permissions Class.
|
||||
*
|
||||
* @var Permissions
|
||||
* @var Permissions
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Permissions $permissions;
|
||||
|
||||
/**
|
||||
* The modelling conditions
|
||||
* The Conditions Class.
|
||||
*
|
||||
* @var Conditions
|
||||
* @var Conditions
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Conditions $conditions;
|
||||
|
||||
/**
|
||||
* The modelling relations
|
||||
* The Relations Class.
|
||||
*
|
||||
* @var Relations
|
||||
* @var Relations
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Relations $relations;
|
||||
|
||||
/**
|
||||
* The modelling linked views
|
||||
* The Linkedviews Class.
|
||||
*
|
||||
* @var Linkedviews
|
||||
* @var Linkedviews
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Linkedviews $linkedviews;
|
||||
|
||||
/**
|
||||
* The modelling javascript
|
||||
* The Javascriptadminview Class.
|
||||
*
|
||||
* @var Javascriptadminview
|
||||
* @var Javascript
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Javascriptadminview $javascript;
|
||||
protected Javascript $javascript;
|
||||
|
||||
/**
|
||||
* The modelling css
|
||||
* The Cssadminview Class.
|
||||
*
|
||||
* @var Cssadminview
|
||||
* @var Css
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Cssadminview $css;
|
||||
protected Css $css;
|
||||
|
||||
/**
|
||||
* The modelling php admin view
|
||||
* The Phpadminview Class.
|
||||
*
|
||||
* @var Phpadminview
|
||||
* @var Php
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Phpadminview $php;
|
||||
protected Php $php;
|
||||
|
||||
/**
|
||||
* The modelling custom buttons
|
||||
* The Custombuttons Class.
|
||||
*
|
||||
* @var Custombuttons
|
||||
* @var Custombuttons
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Custombuttons $custombuttons;
|
||||
|
||||
/**
|
||||
* The modelling custom import scripts
|
||||
* The Customimportscripts Class.
|
||||
*
|
||||
* @var Customimportscripts
|
||||
* @var Customimportscripts
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Customimportscripts $customimportscripts;
|
||||
|
||||
/**
|
||||
* The modelling ajax
|
||||
* The Ajaxadmin Class.
|
||||
*
|
||||
* @var Ajaxadmin
|
||||
* @var Ajax
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Ajaxadmin $ajax;
|
||||
protected Ajax $ajax;
|
||||
|
||||
/**
|
||||
* The modelling custom alias
|
||||
* The Customalias Class.
|
||||
*
|
||||
* @var Customalias
|
||||
* @var Customalias
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Customalias $customalias;
|
||||
|
||||
/**
|
||||
* The modelling sql
|
||||
* The Sql Class.
|
||||
*
|
||||
* @var Sql
|
||||
* @var Sql
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Sql $sql;
|
||||
|
||||
/**
|
||||
* The modelling mysql settings
|
||||
* The Mysqlsettings Class.
|
||||
*
|
||||
* @var Mysqlsettings
|
||||
* @var Mysqlsettings
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Mysqlsettings $mysqlsettings;
|
||||
|
||||
/**
|
||||
* The SiteEditView Class.
|
||||
*
|
||||
* @var SiteEditView
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected SiteEditView $siteeditview;
|
||||
|
||||
/**
|
||||
* Database object to query local DB
|
||||
*
|
||||
@ -241,66 +232,61 @@ class Data
|
||||
protected \JDatabaseDriver $db;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config|null $config The compiler config object.
|
||||
* @param Registry|null $registry The compiler registry object.
|
||||
* @param EventInterface|null $event The compiler event api object.
|
||||
* @param Placeholder|null $placeholder The compiler placeholder object.
|
||||
* @param Dispenser|null $dispenser The compiler customcode dispenser object.
|
||||
* @param Customtabs|null $customtabs The modelling customtabs object.
|
||||
* @param Tabs|null $tabs The modelling tabs object.
|
||||
* @param Fields|null $fields The modelling fields object.
|
||||
* @param Historyadminview|null $history The modelling admin view history object.
|
||||
* @param Permissions|null $permissions The modelling permissions object.
|
||||
* @param Conditions|null $conditions The modelling conditions object.
|
||||
* @param Relations|null $relations The modelling relations object.
|
||||
* @param Linkedviews|null $linkedviews The modelling linked views object.
|
||||
* @param Javascriptadminview|null $javascript The modelling javascript object.
|
||||
* @param Cssadminview|null $css The modelling css object.
|
||||
* @param Phpadminview|null $php The modelling php admin view object.
|
||||
* @param Custombuttons|null $custombuttons The modelling custom buttons object.
|
||||
* @param Customimportscripts|null $customimportscripts The modelling custom import scripts object.
|
||||
* @param Ajaxadmin|null $ajax The modelling ajax object.
|
||||
* @param Customalias|null $customalias The modelling custom alias object.
|
||||
* @param Sql|null $sql The modelling sql object.
|
||||
* @param Mysqlsettings|null $mysqlsettings The modelling mysql settings object.
|
||||
* @param \JDatabaseDriver|null $db The database object.
|
||||
* @param Config $config The Config Class.
|
||||
* @param Event $event The EventInterface Class.
|
||||
* @param Placeholder $placeholder The Placeholder Class.
|
||||
* @param Dispenser $dispenser The Dispenser Class.
|
||||
* @param Customtabs $customtabs The Customtabs Class.
|
||||
* @param Tabs $tabs The Tabs Class.
|
||||
* @param Fields $fields The Fields Class.
|
||||
* @param History $history The Historyadminview Class.
|
||||
* @param Permissions $permissions The Permissions Class.
|
||||
* @param Conditions $conditions The Conditions Class.
|
||||
* @param Relations $relations The Relations Class.
|
||||
* @param Linkedviews $linkedviews The Linkedviews Class.
|
||||
* @param Javascript $javascript The Javascriptadminview Class.
|
||||
* @param Css $css The Cssadminview Class.
|
||||
* @param Php $php The Phpadminview Class.
|
||||
* @param Custombuttons $custombuttons The Custombuttons Class.
|
||||
* @param Customimportscripts $customimportscripts The Customimportscripts Class.
|
||||
* @param Ajax $ajax The Ajaxadmin Class.
|
||||
* @param Customalias $customalias The Customalias Class.
|
||||
* @param Sql $sql The Sql Class.
|
||||
* @param Mysqlsettings $mysqlsettings The Mysqlsettings Class.
|
||||
* @param SiteEditView $siteeditview The SiteEditView Class.
|
||||
* @param \JDatabaseDriver|null $db The Database Class.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Config $config = null, ?Registry $registry = null,
|
||||
?EventInterface $event = null, ?Placeholder $placeholder = null, ?Dispenser $dispenser = null,
|
||||
?Customtabs $customtabs = null, ?Tabs $tabs = null, ?Fields $fields = null,
|
||||
?Historyadminview $history = null, ?Permissions $permissions = null,
|
||||
?Conditions $conditions = null, Relations $relations = null, ?Linkedviews $linkedviews = null,
|
||||
?Javascriptadminview $javascript = null, ?Cssadminview $css = null, ?Phpadminview $php = null,
|
||||
?Custombuttons $custombuttons = null, ?Customimportscripts $customimportscripts = null,
|
||||
?Ajaxadmin $ajax = null, ?Customalias $customalias = null, ?Sql $sql = null,
|
||||
?Mysqlsettings $mysqlsettings = null, ?\JDatabaseDriver $db = null)
|
||||
public function __construct(Config $config, Event $event, Placeholder $placeholder, Dispenser $dispenser, Customtabs $customtabs, Tabs $tabs, Fields $fields,
|
||||
History $history, Permissions $permissions, Conditions $conditions, Relations $relations, Linkedviews $linkedviews, Javascript $javascript,
|
||||
Css $css, Php $php, Custombuttons $custombuttons, Customimportscripts $customimportscripts, Ajax $ajax, Customalias $customalias, Sql $sql,
|
||||
Mysqlsettings $mysqlsettings, SiteEditView $siteeditview, ?\JDatabaseDriver $db = null)
|
||||
{
|
||||
$this->config = $config ?: Compiler::_('Config');
|
||||
$this->registry = $registry ?: Compiler::_('Registry');
|
||||
$this->event = $event ?: Compiler::_('Event');
|
||||
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
|
||||
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
|
||||
$this->customtabs = $customtabs ?: Compiler::_('Model.Customtabs');
|
||||
$this->tabs = $tabs ?: Compiler::_('Model.Tabs');
|
||||
$this->fields = $fields ?: Compiler::_('Model.Fields');
|
||||
$this->history = $history ?: Compiler::_('Model.Historyadminview');
|
||||
$this->permissions = $permissions ?: Compiler::_('Model.Permissions');
|
||||
$this->conditions = $conditions ?: Compiler::_('Model.Conditions');
|
||||
$this->relations = $relations ?: Compiler::_('Model.Relations');
|
||||
$this->linkedviews = $linkedviews ?: Compiler::_('Model.Linkedviews');
|
||||
$this->javascript = $javascript ?: Compiler::_('Model.Javascriptadminview');
|
||||
$this->css = $css ?: Compiler::_('Model.Cssadminview');
|
||||
$this->php = $php ?: Compiler::_('Model.Phpadminview');
|
||||
$this->custombuttons = $custombuttons ?: Compiler::_('Model.Custombuttons');
|
||||
$this->customimportscripts = $customimportscripts ?: Compiler::_('Model.Customimportscripts');
|
||||
$this->ajax = $ajax ?: Compiler::_('Model.Ajaxadmin');
|
||||
$this->customalias = $customalias ?: Compiler::_('Model.Customalias');
|
||||
$this->sql = $sql ?: Compiler::_('Model.Sql');
|
||||
$this->mysqlsettings = $mysqlsettings ?: Compiler::_('Model.Mysqlsettings');
|
||||
$this->config = $config;
|
||||
$this->event = $event;
|
||||
$this->placeholder = $placeholder;
|
||||
$this->dispenser = $dispenser;
|
||||
$this->customtabs = $customtabs;
|
||||
$this->tabs = $tabs;
|
||||
$this->fields = $fields;
|
||||
$this->history = $history;
|
||||
$this->permissions = $permissions;
|
||||
$this->conditions = $conditions;
|
||||
$this->relations = $relations;
|
||||
$this->linkedviews = $linkedviews;
|
||||
$this->javascript = $javascript;
|
||||
$this->css = $css;
|
||||
$this->php = $php;
|
||||
$this->custombuttons = $custombuttons;
|
||||
$this->customimportscripts = $customimportscripts;
|
||||
$this->ajax = $ajax;
|
||||
$this->customalias = $customalias;
|
||||
$this->sql = $sql;
|
||||
$this->mysqlsettings = $mysqlsettings;
|
||||
$this->siteeditview = $siteeditview;
|
||||
$this->db = $db ?: Factory::getDbo();
|
||||
}
|
||||
|
||||
@ -484,7 +470,7 @@ class Data
|
||||
|
||||
// set the lang target
|
||||
$this->config->lang_target = 'admin';
|
||||
if ($this->registry->get('builder.site_edit_view.' . $id, false))
|
||||
if ($this->siteeditview->exists($id))
|
||||
{
|
||||
$this->config->lang_target = 'both';
|
||||
}
|
||||
@ -539,7 +525,6 @@ class Data
|
||||
|
||||
// return the found view data
|
||||
return $this->data[$id];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Adminview;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\HasPermissions;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
|
||||
|
||||
/**
|
||||
* Admin View Permission Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class Permission
|
||||
{
|
||||
/**
|
||||
* The HasPermissions Class.
|
||||
*
|
||||
* @var HasPermissions
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected HasPermissions $haspermissions;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param HasPermissions $haspermissions The HasPermissions Class.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(HasPermissions $haspermissions)
|
||||
{
|
||||
$this->haspermissions = $haspermissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a view has permissions
|
||||
*
|
||||
* @param array $view View details
|
||||
* @param string $nameSingleCode View Single Code Name
|
||||
*
|
||||
* @return bool true if it has permissions
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function check(array &$view, string &$nameSingleCode): bool
|
||||
{
|
||||
// first check if we have checked this already
|
||||
if (!$this->haspermissions->exists($nameSingleCode))
|
||||
{
|
||||
// when a view has history, it has permissions
|
||||
// since it tracks the version access
|
||||
if (isset($view['history']) && $view['history'] == 1)
|
||||
{
|
||||
// set the permission for later
|
||||
$this->haspermissions->set($nameSingleCode, true);
|
||||
|
||||
// break out here
|
||||
return true;
|
||||
}
|
||||
// check if the view has permissions
|
||||
if (isset($view['settings'])
|
||||
&& ArrayHelper::check(
|
||||
$view['settings']->permissions, true
|
||||
))
|
||||
{
|
||||
foreach ($view['settings']->permissions as $per)
|
||||
{
|
||||
// check if the permission targets the view
|
||||
// 1 = view
|
||||
// 3 = both view & component
|
||||
if (isset($per['implementation'])
|
||||
&& (
|
||||
$per['implementation'] == 1
|
||||
|| $per['implementation'] == 3
|
||||
))
|
||||
{
|
||||
// set the permission for later
|
||||
$this->haspermissions->set($nameSingleCode, true);
|
||||
|
||||
// break out here
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// check if the fields has permissions
|
||||
if (isset($view['settings'])
|
||||
&& ArrayHelper::check(
|
||||
$view['settings']->fields, true
|
||||
))
|
||||
{
|
||||
foreach ($view['settings']->fields as $field)
|
||||
{
|
||||
// if a field has any permissions
|
||||
// the a view has permissions
|
||||
if (isset($field['permission'])
|
||||
&& ArrayHelper::check(
|
||||
$field['permission'], true
|
||||
))
|
||||
{
|
||||
// set the permission for later
|
||||
$this->haspermissions->set($nameSingleCode, true);
|
||||
|
||||
// break out here
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->haspermissions->exists($nameSingleCode);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Access Switch Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class AccessSwitch extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Access Switch List Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class AccessSwitchList extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Admin Filter Type Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class AdminFilterType extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Alias Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class Alias extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Base64 Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class BaseSixFour extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Category Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class Category extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\GetString;
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Category Code Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class CategoryCode extends Registry implements Registryinterface
|
||||
{
|
||||
/**
|
||||
* Get String Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use GetString;
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Category Other Name Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class CategoryOtherName extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Check Box Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class CheckBox extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\VarExport;
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Component Fields Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class ComponentFields extends Registry implements Registryinterface
|
||||
{
|
||||
/**
|
||||
* Var Export Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use VarExport;
|
||||
}
|
||||
|
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\IsArray;
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Content Multi
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class ContentMulti extends Registry implements Registryinterface
|
||||
{
|
||||
/**
|
||||
* Is an Array
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use IsArray;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->setSeparator('|');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get that the active keys from a path
|
||||
*
|
||||
* @param string $path The path to determine the location mapper.
|
||||
*
|
||||
* @return array|null The valid array of keys
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getActiveKeys(string $path): ?array
|
||||
{
|
||||
// Call the parent class's version of this method
|
||||
$keys = parent::getActiveKeys($path);
|
||||
|
||||
if ($keys === null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->modelActiveKeys($keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Model that the active key
|
||||
*
|
||||
* @param array $keys The keys to the location mapper.
|
||||
*
|
||||
* @return array|null The valid array of key
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function modelActiveKeys(array $keys): ?array
|
||||
{
|
||||
if (isset($keys[1]))
|
||||
{
|
||||
return [$keys[0], Placefix::_h($keys[1])];
|
||||
}
|
||||
|
||||
if (isset($keys[0]))
|
||||
{
|
||||
return [$keys[0]];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Content One
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class ContentOne extends Registry implements Registryinterface
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->setSeparator(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get that the active keys from a path
|
||||
*
|
||||
* @param string $path The path to determine the location mapper.
|
||||
*
|
||||
* @return array|null The valid array of keys
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getActiveKeys(string $path): ?array
|
||||
{
|
||||
// Call the parent class's version of this method
|
||||
$keys = parent::getActiveKeys($path);
|
||||
|
||||
if ($keys === null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->modelActiveKeys($keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Model that the active key
|
||||
*
|
||||
* @param array $keys The keys to the location mapper.
|
||||
*
|
||||
* @return array The valid array of key
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function modelActiveKeys(array $keys): array
|
||||
{
|
||||
return [Placefix::_h($keys[0])];
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Custom Alias Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class CustomAlias extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Custom Field Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class CustomField extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\ToString;
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Custom Field Links Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class CustomFieldLinks extends Registry implements Registryinterface
|
||||
{
|
||||
/**
|
||||
* To String Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use ToString;
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Custom List Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class CustomList extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Custom Tabs Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class CustomTabs extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Database Keys Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class DatabaseKeys extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Database Tables Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class DatabaseTables extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Database Unique Guid Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class DatabaseUniqueGuid extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Database Unique Keys Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class DatabaseUniqueKeys extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Do Not Escape Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class DoNotEscape extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\ToString;
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Dynamic Fields Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class DynamicFields extends Registry implements Registryinterface
|
||||
{
|
||||
/**
|
||||
* To String Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use ToString;
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Extension Custom Fields Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class ExtensionCustomFields extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Field Group Control Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class FieldGroupControl extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\IsString;
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Field Names Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class FieldNames extends Registry implements Registryinterface
|
||||
{
|
||||
/**
|
||||
* Is String Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use IsString;
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Field Relations Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class FieldRelations extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Filter Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class Filter extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Footable Scripts Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class FootableScripts extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Get As Lookup Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class GetAsLookup extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Get Module Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class GetModule extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Google Chart Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class GoogleChart extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Has Permissions Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class HasPermissions extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\ToString;
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Hidden Fields Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class HiddenFields extends Registry implements Registryinterface
|
||||
{
|
||||
/**
|
||||
* To String Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use ToString;
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* History Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class History extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\ToString;
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Integer Fields Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class IntegerFields extends Registry implements Registryinterface
|
||||
{
|
||||
/**
|
||||
* To String Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use ToString;
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/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\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Items Method Eximport String Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class ItemsMethodEximportString extends Registry implements Registryinterface
|
||||
{
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user