Editors xtd #871

Closed
saman222 wants to merge 3 commits from editors_xtd into staging
8 changed files with 185 additions and 17 deletions

View File

@ -221,6 +221,13 @@
} }
}, },
"dynamic": { "dynamic": {
"plugin": {
"1.0.0.sql": {
"path": "P|uG!n/sql/mysql/updates",
"rename": "1.0.0",
"type": "sql_update"
}
},
"admin": { "admin": {
"whmcs.php": { "whmcs.php": {
"path": "c0mp0n3nt/admin", "path": "c0mp0n3nt/admin",

View File

@ -580,7 +580,7 @@ class Compiler extends Infusion
{ {
$this->setFileContent( $this->setFileContent(
$plugin_file['name'], $plugin_file['path'], $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) 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 // Trigger Event: jcb_ce_onBeforeSetFileContent
$this->triggerEvent( $this->triggerEvent(
'jcb_ce_onBeforeSetFileContent', 'jcb_ce_onBeforeSetFileContent',
@ -667,9 +673,20 @@ class Compiler extends Infusion
// set the dynamic answer // set the dynamic answer
if ($view) if ($view)
{ {
$answer = $this->setPlaceholders( if ($main_view)
$answer, $this->fileContentDynamic[$view], 3 {
); $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 :) // check if this file needs extra care :)
if (isset($this->updateFileContent[$path])) if (isset($this->updateFileContent[$path]))

View File

@ -10149,9 +10149,7 @@ class Get
// set lang prefix // set lang prefix
$plugin->lang_prefix = $this->langPrefix; $plugin->lang_prefix = $this->langPrefix;
// set plugin class name // set plugin class name
$plugin->class_name = 'Plg' . ucfirst($plugin->group) . ucfirst( $plugin->class_name = ComponentbuilderHelper::createPluginClassName($plugin->group, $plugin->code_name);
$plugin->code_name
);
// set plugin install class name // set plugin install class name
$plugin->installer_class_name = 'plg' . ucfirst($plugin->group) $plugin->installer_class_name = 'plg' . ucfirst($plugin->group)
. ucfirst($plugin->code_name) . 'InstallerScript'; . ucfirst($plugin->code_name) . 'InstallerScript';
@ -10701,6 +10699,15 @@ class Get
$plugin->{$server . '_protocol'} = 0; $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) // set the update server stuff (TODO)
// update_server_xml_path // update_server_xml_path
// update_server_xml_file_name // update_server_xml_file_name

View File

@ -1444,7 +1444,8 @@ class Structure extends Get
} }
} }
// set SQL stuff if needed // 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 // create SQL folder
$this->createFolder($plugin->folder_path . '/sql'); $this->createFolder($plugin->folder_path . '/sql');
@ -2764,7 +2765,7 @@ class Structure extends Get
* *
*/ */
public function buildDynamique($target, $type, $fileName = false, public function buildDynamique($target, $type, $fileName = false,
$config = false $config = false, $plugin= null
) )
{ {
// did we build the files (any number) // did we build the files (any number)
@ -2803,6 +2804,13 @@ class Structure extends Get
'c0mp0n3nt/', $this->componentPath . '/', $path '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 else
{ {
$this->app->enqueueMessage( $this->app->enqueueMessage(
@ -2818,7 +2826,10 @@ class Structure extends Get
if (!Folder::exists($path)) if (!Folder::exists($path))
{ {
Folder::create($path); Folder::create($path);
$this->indexHTML($zipPath); if (!empty($plugin))
$this->indexHTML($zipPath,'plugin', $plugin);
else
$this->indexHTML($zipPath);
// count the folder created // count the folder created
$this->folderCount++; $this->folderCount++;
} }
@ -2865,8 +2876,14 @@ class Structure extends Get
{ {
$newFIle['config'] = $config; $newFIle['config'] = $config;
} }
// store the new files // store the new files
$this->newFiles['dynamic'][$name][] = $newFIle; if (!empty($plugin))
$this->newFiles[$plugin->key][$name] = $newFIle;
else
$this->newFiles['dynamic'][$name][] = $newFIle;
// we have build atleast one // we have build atleast one
$build_status = true; $build_status = true;
} }
@ -3196,12 +3213,16 @@ class Structure extends Get
* @return void * @return void
* *
*/ */
private function indexHTML($path, $root = 'component') private function indexHTML($path, $root = 'component', $plugin= null)
{ {
if ('component' === $root) if ('component' === $root)
{ {
$root = $this->componentPath . '/'; $root = $this->componentPath . '/';
} }
if ('plugin' === $root)
{
$root = $plugin->folder_path . '/';
}
// use path if exist // use path if exist
if (strlen($path) > 0) if (strlen($path) > 0)
{ {

View File

@ -1095,6 +1095,43 @@ class Interpretation extends Fields
return ''; 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 * set Version Controller
*/ */
@ -1307,6 +1344,40 @@ class Interpretation extends Fields
$this->setUpdateXMLSQL($update_, $updateXML, $addDynamicSQL); $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 * set Update XML SQL
* *
@ -28853,6 +28924,19 @@ function vdm_dkim() {
$xml .= PHP_EOL . $this->_t(2) . '</sql>'; $xml .= PHP_EOL . $this->_t(2) . '</sql>';
$xml .= PHP_EOL . $this->_t(1) . '</uninstall>'; $xml .= PHP_EOL . $this->_t(1) . '</uninstall>';
} }
// should the sql update be added
if ($plugin->version_update)
{
$xml .= PHP_EOL . PHP_EOL . $this->_t(1) . '<!--' . $this->setLine(
__LINE__
) . ' Runs on update; New in Joomla 1.5 -->';
$xml .= PHP_EOL . $this->_t(1) . '<update>';
$xml .= PHP_EOL . $this->_t(2) . '<schemas>';
$xml .= PHP_EOL . $this->_t(3)
. '<schemapath type="mysql">sql/mysql/updates/</schemapath>';
$xml .= PHP_EOL . $this->_t(2) . '</schemas>';
$xml .= PHP_EOL . $this->_t(1) . '</update>';
}
// should the language xml be added // should the language xml be added
if (ComponentbuilderHelper::checkArray($addLang)) if (ComponentbuilderHelper::checkArray($addLang))
{ {
@ -28903,7 +28987,7 @@ function vdm_dkim() {
$xml .= PHP_EOL . $this->_t(2) . '<folder>language</folder>'; $xml .= PHP_EOL . $this->_t(2) . '<folder>language</folder>';
} }
// add sql folder // 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) . '<folder>sql</folder>'; $xml .= PHP_EOL . $this->_t(2) . '<folder>sql</folder>';
} }

View File

@ -2454,6 +2454,9 @@ class Infusion extends Interpretation
. 'INSTALLCLASS' . $this->hhh] . 'INSTALLCLASS' . $this->hhh]
= $this->getExtensionInstallClass($plugin); = $this->getExtensionInstallClass($plugin);
} }
$this->setPluginVersionController($plugin);
// FIELDSET // FIELDSET
if (isset($plugin->form_files) if (isset($plugin->form_files)
&& ComponentbuilderHelper::checkArray( && ComponentbuilderHelper::checkArray(

View File

@ -6587,8 +6587,22 @@ abstract class ComponentbuilderHelper
return array_values($fieldIds); return array_values($fieldIds);
} }
return false; return false;
} }
/**
* create plugin class name
*/
public static function createPluginClassName($group, $code_name)
{
// editors-xtd group plugins must have a class with plgButton<PluginName> structure
if ($group == 'editors-xtd')
$group= 'Button';
return 'Plg' . ucfirst($group) . ucfirst(
$code_name
);
}
/** /**
* get a plugin fields IDs * get a plugin fields IDs
*/ */

View File

@ -6622,7 +6622,22 @@ abstract class ComponentbuilderHelper
return array_values($fieldIds); return array_values($fieldIds);
} }
return false; return false;
} }
/**
* create plugin class name
*/
public static function createPluginClassName($group, $code_name)
{
// editors-xtd group plugins must have a class with plgButton<PluginName> structure
if ($group == 'editors-xtd')
$group= 'Button';
return 'Plg' . ucfirst($group) . ucfirst(
$code_name
);
}
/** /**
* get an admin view fields IDs * get an admin view fields IDs