diff --git a/admin/compiler/joomla_3/settings.json b/admin/compiler/joomla_3/settings.json
index edfe475a9..3e5bfec73 100644
--- a/admin/compiler/joomla_3/settings.json
+++ b/admin/compiler/joomla_3/settings.json
@@ -221,6 +221,13 @@
}
},
"dynamic": {
+ "plugin": {
+ "1.0.0.sql": {
+ "path": "P|uG!n/sql/mysql/updates",
+ "rename": "1.0.0",
+ "type": "sql_update"
+ }
+ },
"admin": {
"whmcs.php": {
"path": "c0mp0n3nt/admin",
diff --git a/admin/helpers/compiler.php b/admin/helpers/compiler.php
index 06c4e9d02..32759a37a 100644
--- a/admin/helpers/compiler.php
+++ b/admin/helpers/compiler.php
@@ -580,7 +580,7 @@ class Compiler extends Infusion
{
$this->setFileContent(
$plugin_file['name'], $plugin_file['path'],
- $bom, $plugin->key
+ $bom, ['plugin_key' => $plugin->key, 'view' => $plugin_file['view']]
);
}
}
@@ -633,6 +633,12 @@ class Compiler extends Infusion
*/
protected function setFileContent(&$name, &$path, &$bom, $view = null)
{
+ $main_view= null;
+ if (is_array($view))
+ {
+ $main_view= $view['view'];
+ $view= $view['plugin_key'];
+ }
// Trigger Event: jcb_ce_onBeforeSetFileContent
$this->triggerEvent(
'jcb_ce_onBeforeSetFileContent',
@@ -667,9 +673,20 @@ class Compiler extends Infusion
// set the dynamic answer
if ($view)
{
- $answer = $this->setPlaceholders(
- $answer, $this->fileContentDynamic[$view], 3
- );
+ if ($main_view)
+ {
+ $answer = $this->setPlaceholders(
+ $answer, $this->fileContentDynamic[$view][$main_view], 3
+ );
+ }
+ else
+ {
+ $answer = $this->setPlaceholders(
+ $answer, $this->fileContentDynamic[$view], 3
+ );
+ }
+
+
}
// check if this file needs extra care :)
if (isset($this->updateFileContent[$path]))
diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php
index fb0608da7..5e9a411b9 100644
--- a/admin/helpers/compiler/a_Get.php
+++ b/admin/helpers/compiler/a_Get.php
@@ -10149,9 +10149,7 @@ class Get
// set lang prefix
$plugin->lang_prefix = $this->langPrefix;
// set plugin class name
- $plugin->class_name = 'Plg' . ucfirst($plugin->group) . ucfirst(
- $plugin->code_name
- );
+ $plugin->class_name = ComponentbuilderHelper::createPluginClassName($plugin->group, $plugin->code_name);
// set plugin install class name
$plugin->installer_class_name = 'plg' . ucfirst($plugin->group)
. ucfirst($plugin->code_name) . 'InstallerScript';
@@ -10701,6 +10699,15 @@ class Get
$plugin->{$server . '_protocol'} = 0;
}
}
+ $plugin->version_update = (isset($plugin->version_update)
+ && ComponentbuilderHelper::checkJson($plugin->version_update))
+ ? json_decode($plugin->version_update, true) : null;
+ if (ComponentbuilderHelper::checkArray($plugin->version_update))
+ {
+ $plugin->version_update = array_values(
+ $plugin->version_update
+ );
+ }
// set the update server stuff (TODO)
// update_server_xml_path
// update_server_xml_file_name
diff --git a/admin/helpers/compiler/b_Structure.php b/admin/helpers/compiler/b_Structure.php
index dfde9137c..31c23e8b0 100644
--- a/admin/helpers/compiler/b_Structure.php
+++ b/admin/helpers/compiler/b_Structure.php
@@ -1444,7 +1444,8 @@ class Structure extends Get
}
}
// set SQL stuff if needed
- if ($plugin->add_sql || $plugin->add_sql_uninstall)
+
+ if ($plugin->add_sql || $plugin->add_sql_uninstall || $plugin->version_update)
{
// create SQL folder
$this->createFolder($plugin->folder_path . '/sql');
@@ -2764,7 +2765,7 @@ class Structure extends Get
*
*/
public function buildDynamique($target, $type, $fileName = false,
- $config = false
+ $config = false, $plugin= null
)
{
// did we build the files (any number)
@@ -2803,6 +2804,13 @@ class Structure extends Get
'c0mp0n3nt/', $this->componentPath . '/', $path
);
}
+ elseif (strpos($path, 'P|uG!n') !== false)
+ {
+ $zipPath = str_replace('P|uG!n/', '', $path);
+ $path = str_replace(
+ 'P|uG!n/', $plugin->folder_path . '/', $path
+ );
+ }
else
{
$this->app->enqueueMessage(
@@ -2818,7 +2826,10 @@ class Structure extends Get
if (!Folder::exists($path))
{
Folder::create($path);
- $this->indexHTML($zipPath);
+ if (!empty($plugin))
+ $this->indexHTML($zipPath,'plugin', $plugin);
+ else
+ $this->indexHTML($zipPath);
// count the folder created
$this->folderCount++;
}
@@ -2865,8 +2876,14 @@ class Structure extends Get
{
$newFIle['config'] = $config;
}
- // store the new files
- $this->newFiles['dynamic'][$name][] = $newFIle;
+ // store the new files
+ if (!empty($plugin))
+ $this->newFiles[$plugin->key][$name] = $newFIle;
+ else
+ $this->newFiles['dynamic'][$name][] = $newFIle;
+
+
+
// we have build atleast one
$build_status = true;
}
@@ -3196,12 +3213,16 @@ class Structure extends Get
* @return void
*
*/
- private function indexHTML($path, $root = 'component')
+ private function indexHTML($path, $root = 'component', $plugin= null)
{
if ('component' === $root)
{
$root = $this->componentPath . '/';
}
+ if ('plugin' === $root)
+ {
+ $root = $plugin->folder_path . '/';
+ }
// use path if exist
if (strlen($path) > 0)
{
diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php
index 7f5aa532d..22e9d0fd4 100644
--- a/admin/helpers/compiler/e_Interpretation.php
+++ b/admin/helpers/compiler/e_Interpretation.php
@@ -1095,6 +1095,43 @@ class Interpretation extends Fields
return '';
}
+
+ /**
+ * set plugin Version Controller
+ */
+ public function setPluginVersionController(&$plugin)
+ {
+ if (ComponentbuilderHelper::checkArray(
+ $plugin->version_update
+ ))
+ {
+ $updateXML = array();
+
+
+ // add the dynamic sql switch
+ $addDynamicSQL = true;
+ $addActive = true;
+ if (ComponentbuilderHelper::checkArray(
+ $plugin->version_update
+ ))
+ {
+
+ foreach (
+ $plugin->version_update as $nr => &$update
+ )
+ {
+ $this->setPluginUpdateXMLSQL($update, $updateXML, $addDynamicSQL, $plugin);
+
+ if ($update['version']
+ == $plugin->plugin_version)
+ {
+ $addActive = false;
+ }
+ }
+ }
+ }
+ }
+
/**
* set Version Controller
*/
@@ -1307,6 +1344,40 @@ class Interpretation extends Fields
$this->setUpdateXMLSQL($update_, $updateXML, $addDynamicSQL);
}
+ /**
+ * set plugin Update XML SQL
+ *
+ * @param array $update
+ * @param array $updateXML
+ * @param boolean $addDynamicSQL
+ */
+ public function setPluginUpdateXMLSQL(&$update, &$updateXML, &$addDynamicSQL, $plugin)
+ {
+ // ensure version naming is correct
+ $update['version'] = preg_replace('/[^0-9.]+/', '', $update['version']);
+ // setup SQL
+ if (ComponentbuilderHelper::checkString($update['mysql']))
+ {
+ $update['mysql'] = $this->setPlaceholders(
+ $update['mysql'], $this->placeholders
+ );
+ }
+
+ // setup import files
+ if ($update['version'] != $plugin->plugin_version)
+ {
+ $name = ComponentbuilderHelper::safeString($update['version']);
+ $target = array('plugin' => $name);
+ $this->buildDynamique($target, 'sql_update', $update['version'], false, $plugin);
+ $this->fileContentDynamic[$plugin->key][$name . '_'
+ . $update['version']][$this->hhh . 'UPDATE_VERSION_MYSQL'
+ . $this->hhh]
+ = $update['mysql'];
+ }
+
+ }
+
+
/**
* set Update XML SQL
*
@@ -28853,6 +28924,19 @@ function vdm_dkim() {
$xml .= PHP_EOL . $this->_t(2) . '';
$xml .= PHP_EOL . $this->_t(1) . '';
}
+ // should the sql update be added
+ if ($plugin->version_update)
+ {
+ $xml .= PHP_EOL . PHP_EOL . $this->_t(1) . '';
+ $xml .= PHP_EOL . $this->_t(1) . '';
+ $xml .= PHP_EOL . $this->_t(2) . '';
+ $xml .= PHP_EOL . $this->_t(3)
+ . 'sql/mysql/updates/';
+ $xml .= PHP_EOL . $this->_t(2) . '';
+ $xml .= PHP_EOL . $this->_t(1) . '';
+ }
// should the language xml be added
if (ComponentbuilderHelper::checkArray($addLang))
{
@@ -28903,7 +28987,7 @@ function vdm_dkim() {
$xml .= PHP_EOL . $this->_t(2) . 'language';
}
// add sql folder
- if ($plugin->add_sql || $plugin->add_sql_uninstall)
+ if ($plugin->add_sql || $plugin->add_sql_uninstall || $plugin->version_update)
{
$xml .= PHP_EOL . $this->_t(2) . 'sql';
}
diff --git a/admin/helpers/compiler/f_Infusion.php b/admin/helpers/compiler/f_Infusion.php
index 4cd4ccc89..cc9584d0b 100644
--- a/admin/helpers/compiler/f_Infusion.php
+++ b/admin/helpers/compiler/f_Infusion.php
@@ -2454,6 +2454,9 @@ class Infusion extends Interpretation
. 'INSTALLCLASS' . $this->hhh]
= $this->getExtensionInstallClass($plugin);
}
+
+ $this->setPluginVersionController($plugin);
+
// FIELDSET
if (isset($plugin->form_files)
&& ComponentbuilderHelper::checkArray(
diff --git a/admin/helpers/componentbuilder.php b/admin/helpers/componentbuilder.php
index 99c85408c..49fa4b2b0 100644
--- a/admin/helpers/componentbuilder.php
+++ b/admin/helpers/componentbuilder.php
@@ -6587,8 +6587,22 @@ abstract class ComponentbuilderHelper
return array_values($fieldIds);
}
return false;
- }
-
+ }
+
+ /**
+ * create plugin class name
+ */
+ public static function createPluginClassName($group, $code_name)
+ {
+ // editors-xtd group plugins must have a class with plgButton structure
+ if ($group == 'editors-xtd')
+ $group= 'Button';
+
+ return 'Plg' . ucfirst($group) . ucfirst(
+ $code_name
+ );
+ }
+
/**
* get a plugin fields IDs
*/
diff --git a/site/helpers/componentbuilder.php b/site/helpers/componentbuilder.php
index fb6062b96..b5e0291dc 100644
--- a/site/helpers/componentbuilder.php
+++ b/site/helpers/componentbuilder.php
@@ -6622,7 +6622,22 @@ abstract class ComponentbuilderHelper
return array_values($fieldIds);
}
return false;
- }
+ }
+
+
+ /**
+ * create plugin class name
+ */
+ public static function createPluginClassName($group, $code_name)
+ {
+ // editors-xtd group plugins must have a class with plgButton structure
+ if ($group == 'editors-xtd')
+ $group= 'Button';
+
+ return 'Plg' . ucfirst($group) . ucfirst(
+ $code_name
+ );
+ }
/**
* get an admin view fields IDs