Fix the update server #978 issue. Fixed the change log to load all entries, not just the last one. Fixed #983 so that database updates are created when adding a new adminview. Moved a few builder arrays to the Compiler Registry. Adds super powers to JCB. Adds Gitea API library. Improves Power filters. Fix #991 to add the Utilities service class. Adds Superpower Key (SPK) replacement feature. Adds Superpower search (GREP) feature. Adds Power Insert/Update Classe. Fix #995 that all update sites are using the correct URL.
This commit is contained in:
@@ -124,39 +124,10 @@ class Dispenser implements DispenserInterface
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// this needs refactoring (TODO)
|
||||
if (!isset($this->hub[$first])
|
||||
|| ($second
|
||||
&& !isset($this->hub[$first][$second])))
|
||||
{
|
||||
// check if the script first key is set
|
||||
if ($second && !isset($this->hub[$first]))
|
||||
{
|
||||
$this->hub[$first] = [];
|
||||
}
|
||||
elseif ($add && !$second
|
||||
&& !isset($this->hub[$first]))
|
||||
{
|
||||
$this->hub[$first] = '';
|
||||
}
|
||||
// check if the script second key is set
|
||||
if ($second && $third
|
||||
&& !isset($this->hub[$first][$second]))
|
||||
{
|
||||
$this->hub[$first][$second] = [];
|
||||
}
|
||||
elseif ($add && $second && !$third
|
||||
&& !isset($this->hub[$first][$second]))
|
||||
{
|
||||
$this->hub[$first][$second] = '';
|
||||
}
|
||||
// check if the script third key is set
|
||||
if ($add && $second && $third
|
||||
&& !isset($this->hub[$first][$second][$third]))
|
||||
{
|
||||
$this->hub[$first][$second][$third] = '';
|
||||
}
|
||||
}
|
||||
|
||||
// init all needed arrays
|
||||
$this->initHub($first, $second, $third, $add);
|
||||
|
||||
// prep the script string
|
||||
if ($base64 && $dynamic)
|
||||
{
|
||||
@@ -166,7 +137,7 @@ class Dispenser implements DispenserInterface
|
||||
{
|
||||
$script = base64_decode($script);
|
||||
}
|
||||
elseif ($dynamic) // this does not happen (just incase)
|
||||
elseif ($dynamic) // this does not happen (just in-case)
|
||||
{
|
||||
$script = $this->customcode->update($script);
|
||||
}
|
||||
@@ -178,49 +149,15 @@ class Dispenser implements DispenserInterface
|
||||
{
|
||||
$script = $this->gui->set($script, $config);
|
||||
}
|
||||
|
||||
// add Dynamic HASHING option of a file/string
|
||||
$script = $this->hash->set($script);
|
||||
|
||||
// add base64 locking option of a string
|
||||
$script = $this->base64->set($script);
|
||||
|
||||
// load the script
|
||||
if ($first && $second && $third)
|
||||
{
|
||||
// now act on loading option
|
||||
if ($add)
|
||||
{
|
||||
$this->hub[$first][$second][$third]
|
||||
.= $script;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->hub[$first][$second][$third]
|
||||
= $script;
|
||||
}
|
||||
}
|
||||
elseif ($first && $second)
|
||||
{
|
||||
// now act on loading option
|
||||
if ($add)
|
||||
{
|
||||
$this->hub[$first][$second] .= $script;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->hub[$first][$second] = $script;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// now act on loading option
|
||||
if ($add)
|
||||
{
|
||||
$this->hub[$first] .= $script;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->hub[$first] = $script;
|
||||
}
|
||||
}
|
||||
$this->setHub($script, $first, $second, $third, $add);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -240,7 +177,6 @@ class Dispenser implements DispenserInterface
|
||||
* @param string $suffix The suffix to add after the script if found
|
||||
*
|
||||
* @return mixed The string/script if found or the default value if not found
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(string $first, string $second, string $prefix = '', ?string $note = null,
|
||||
@@ -279,6 +215,71 @@ class Dispenser implements DispenserInterface
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make sure the hub arrays are all set
|
||||
*
|
||||
* @param string $first The first key
|
||||
* @param string|null $second The second key (if not set we use only first key)
|
||||
* @param string|null $third The third key (if not set we use only first and second key)
|
||||
* @param bool $add The switch to add to exiting instead of replace
|
||||
* default: false
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function initHub(string $first, ?string $second = null, ?string $third = null, bool $add = false)
|
||||
{
|
||||
if (!isset($this->hub[$first]))
|
||||
{
|
||||
$this->hub[$first] = ($second !== null || $add) ? ($second !== null ? [] : '') : [];
|
||||
}
|
||||
|
||||
if ($second !== null && !isset($this->hub[$first][$second]))
|
||||
{
|
||||
$this->hub[$first][$second] = ($third !== null || $add) ? ($third !== null ? [] : '') : [];
|
||||
}
|
||||
|
||||
if ($third !== null && !isset($this->hub[$first][$second][$third]))
|
||||
{
|
||||
$this->hub[$first][$second][$third] = $add ? '' : [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a script in the hub
|
||||
*
|
||||
* @param string $script The script
|
||||
* @param string $first The first key
|
||||
* @param string|null $second The second key (if not set we use only first key)
|
||||
* @param string|null $third The third key (if not set we use only first and second key)
|
||||
* @param bool $add The switch to add to exiting instead of replace
|
||||
* default: false
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function setHub(string $script, string $first, ?string $second = null, ?string $third = null, bool $add = false)
|
||||
{
|
||||
// Load the script
|
||||
if ($second !== null)
|
||||
{
|
||||
if ($third !== null)
|
||||
{
|
||||
$this->hub[$first][$second][$third] =
|
||||
$add ? $this->hub[$first][$second][$third] . $script : $script;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->hub[$first][$second] =
|
||||
$add ? $this->hub[$first][$second] . $script : $script;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->hub[$first] =
|
||||
$add ? $this->hub[$first] . $script : $script;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -23,6 +23,7 @@ use VDM\Joomla\Utilities\String\FieldHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder\Reverse;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Parser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode\GuiInterface;
|
||||
|
||||
|
||||
@@ -49,6 +50,14 @@ class Gui implements GuiInterface
|
||||
**/
|
||||
protected Reverse $reverse;
|
||||
|
||||
/**
|
||||
* Compiler Powers Parser
|
||||
*
|
||||
* @var Parser
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Parser $parser;
|
||||
|
||||
/**
|
||||
* Database object to query local DB
|
||||
*
|
||||
@@ -70,17 +79,19 @@ class Gui implements GuiInterface
|
||||
*
|
||||
* @param Config|null $config The compiler config object.
|
||||
* @param Reverse|null $reverse The compiler placeholder reverse object.
|
||||
* @param Parser|null $parser The powers parser object.
|
||||
* @param \JDatabaseDriver|null $db The Database Driver object.
|
||||
* @param CMSApplication|null $app The CMS Application object.
|
||||
*
|
||||
* @throws \Exception
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Config $config = null, ?Reverse $reverse = null,
|
||||
public function __construct(?Config $config = null, ?Reverse $reverse = null, ?Parser $parser = null,
|
||||
?\JDatabaseDriver $db = null, ?CMSApplication $app = null)
|
||||
{
|
||||
$this->config = $config ?: Compiler::_('Config');
|
||||
$this->reverse = $reverse ?: Compiler::_('Placeholder.Reverse');
|
||||
$this->parser = $parser ?: Compiler::_('Power.Parser');
|
||||
$this->db = $db ?: Factory::getDbo();
|
||||
$this->app = $app ?: Factory::getApplication();
|
||||
}
|
||||
@@ -181,15 +192,18 @@ class Gui implements GuiInterface
|
||||
public function search(string &$file, array &$placeholders, string &$today, string &$target)
|
||||
{
|
||||
// get file content
|
||||
$file_conent = FileHelper::getContent($file);
|
||||
$file_content = FileHelper::getContent($file);
|
||||
|
||||
// get the USE statements (to reverse engineer super power keys)
|
||||
$use_statements = $this->parser->getUseStatements($file_content);
|
||||
|
||||
$guiCode = [];
|
||||
// we add a new search for the GUI CODE Blocks
|
||||
$guiCode[] = GetHelper::allBetween(
|
||||
$file_conent, '/***[JCB' . 'GUI<>', '/***[/JCBGUI' . '$$$$]***/'
|
||||
$file_content, '/***[JCB' . 'GUI<>', '/***[/JCBGUI' . '$$$$]***/'
|
||||
);
|
||||
$guiCode[] = GetHelper::allBetween(
|
||||
$file_conent, '<!--[JCB' . 'GUI<>', '<!--[/JCBGUI' . '$$$$]-->'
|
||||
$file_content, '<!--[JCB' . 'GUI<>', '<!--[/JCBGUI' . '$$$$]-->'
|
||||
);
|
||||
|
||||
if (($guiCode = ArrayHelper::merge($guiCode)) !== false
|
||||
@@ -214,7 +228,7 @@ class Gui implements GuiInterface
|
||||
$table = StringHelper::safe($query[0]);
|
||||
// reverse placeholder as much as we can
|
||||
$code = $this->reverse->engine(
|
||||
$code, $placeholders, $target, $id, $field, $table
|
||||
$code, $placeholders, $target, $id, $field, $table, $use_statements
|
||||
);
|
||||
// update the GUI/Tables/Database
|
||||
$object = new \stdClass();
|
||||
|
Reference in New Issue
Block a user