Improved the plugin form builder, to allow multi form field relationships.
This commit is contained in:
@ -108,6 +108,13 @@ class Get
|
||||
*/
|
||||
public $componentData;
|
||||
|
||||
/**
|
||||
* The Plugins data
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $joomlaPlugins = array();
|
||||
|
||||
/**
|
||||
* The custom script placeholders - we use the (xxx) to avoid detection it should be (***)
|
||||
* ##################################---> PHP/JS <---####################################
|
||||
@ -469,6 +476,13 @@ class Get
|
||||
*/
|
||||
public $validationRules = array();
|
||||
|
||||
/**
|
||||
* The validation linked to fields
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $validationLinkedFields = array();
|
||||
|
||||
/**
|
||||
* The admin views data array
|
||||
*
|
||||
@ -776,6 +790,8 @@ class Get
|
||||
}
|
||||
}
|
||||
}
|
||||
// Trigger Event: jcb_ce_onBeforeGet
|
||||
$this->triggerEvent('jcb_ce_onBeforeGet', array(&$config, $this));
|
||||
// set the Joomla version
|
||||
$this->joomlaVersion = $config['version'];
|
||||
// set the minfy switch of the JavaScript
|
||||
@ -855,6 +871,9 @@ class Get
|
||||
// set the percentage when a language can be added
|
||||
$this->percentageLanguageAdd = (int) $this->params->get('percentagelanguageadd', 50);
|
||||
|
||||
// Trigger Event: jcb_ce_onBeforeGet
|
||||
$this->triggerEvent('jcb_ce_onAfterGet', array(&$this->componentContext, $this));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1659,15 +1678,10 @@ class Get
|
||||
$component->addjoomla_plugins = (isset($component->addjoomla_plugins) && ComponentbuilderHelper::checkJson($component->addjoomla_plugins)) ? json_decode($component->addjoomla_plugins, true) : null;
|
||||
if (ComponentbuilderHelper::checkArray($component->addjoomla_plugins))
|
||||
{
|
||||
$component->joomla_plugins = array_map(function($array) use(&$component)
|
||||
{
|
||||
return $this->getPlugins($array['plugin'], $component);
|
||||
$joomla_plugins = array_map(function($array) use(&$component) {
|
||||
return $this->setJoomlaPlugin($array['plugin'], $component);
|
||||
}, array_values($component->addjoomla_plugins));
|
||||
}
|
||||
else
|
||||
{
|
||||
$component->joomla_plugins = '';
|
||||
}
|
||||
unset($component->addjoomla_plugins);
|
||||
|
||||
// Trigger Event: jcb_ce_onAfterModelComponentData
|
||||
@ -2834,6 +2848,8 @@ class Get
|
||||
{
|
||||
// make sure it is lowercase
|
||||
$validationRule = ComponentbuilderHelper::safeString($validationRule);
|
||||
// link this field to this validation
|
||||
$this->validationLinkedFields[$id] = $validationRule;
|
||||
// make sure it is not already set
|
||||
if (!isset($this->validationRules[$validationRule]))
|
||||
{
|
||||
@ -2859,8 +2875,14 @@ class Get
|
||||
else
|
||||
{
|
||||
// set the notice that this validation rule is custom and was not found (TODO)
|
||||
unset($this->validationLinkedFields[$id], $this->validationRules[$validationRule]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// remove link (we only want custom validations linked)
|
||||
unset($this->validationLinkedFields[$id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6160,299 +6182,420 @@ class Get
|
||||
}
|
||||
|
||||
/**
|
||||
* get the plugins linked to a component
|
||||
* set the Joomla plugins
|
||||
*
|
||||
* @return void
|
||||
* @return true
|
||||
*
|
||||
*/
|
||||
protected function getPlugins($id, &$component)
|
||||
public function setJoomlaPlugin($id, &$component)
|
||||
{
|
||||
// Create a new query object.
|
||||
$query = $this->db->getQuery(true);
|
||||
|
||||
$query->select('a.*');
|
||||
$query->select(
|
||||
$this->db->quoteName(
|
||||
array(
|
||||
'g.name',
|
||||
'e.name',
|
||||
'e.head',
|
||||
'e.comment',
|
||||
'e.id',
|
||||
'f.addfiles',
|
||||
'f.addfolders',
|
||||
'f.addfilesfullpath',
|
||||
'f.addfoldersfullpath',
|
||||
'f.addurls',
|
||||
'u.version_update',
|
||||
'u.id'
|
||||
), array(
|
||||
'group',
|
||||
'extends',
|
||||
'class_head',
|
||||
'comment',
|
||||
'class_id',
|
||||
'addfiles',
|
||||
'addfolders',
|
||||
'addfilesfullpath',
|
||||
'addfoldersfullpath',
|
||||
'addurls',
|
||||
'version_update',
|
||||
'version_update_id'
|
||||
)
|
||||
)
|
||||
);
|
||||
// from these tables
|
||||
$query->from('#__componentbuilder_joomla_plugin AS a');
|
||||
$query->join('LEFT', $this->db->quoteName('#__componentbuilder_joomla_plugin_group', 'g') . ' ON (' . $this->db->quoteName('a.joomla_plugin_group') . ' = ' . $this->db->quoteName('g.id') . ')');
|
||||
$query->join('LEFT', $this->db->quoteName('#__componentbuilder_class_extends', 'e') . ' ON (' . $this->db->quoteName('a.class_extends') . ' = ' . $this->db->quoteName('e.id') . ')');
|
||||
$query->join('LEFT', $this->db->quoteName('#__componentbuilder_joomla_plugin_updates', 'u') . ' ON (' . $this->db->quoteName('a.id') . ' = ' . $this->db->quoteName('u.joomla_plugin') . ')');
|
||||
$query->join('LEFT', $this->db->quoteName('#__componentbuilder_joomla_plugin_files_folders_urls', 'f') . ' ON (' . $this->db->quoteName('a.id') . ' = ' . $this->db->quoteName('f.joomla_plugin') . ')');
|
||||
$query->where($this->db->quoteName('a.id') . ' = ' . (int) $id);
|
||||
$query->where($this->db->quoteName('a.published') . ' >= 1');
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
if ($this->db->getNumRows())
|
||||
if (isset($this->joomlaPlugins[$id]))
|
||||
{
|
||||
// get the plugin data
|
||||
$plugin = $this->db->loadObject();
|
||||
// tweak system to set stuff to the plugin domain
|
||||
$_backup_target = $this->target;
|
||||
$_backup_lang = $this->lang;
|
||||
$_backup_langPrefix = $this->langPrefix;
|
||||
// set some keys
|
||||
$plugin->target_type = 'P|uG!n';
|
||||
$plugin->key = $plugin->id . '_' . $plugin->target_type;
|
||||
// update to point to plugin
|
||||
$this->target = $plugin->key;
|
||||
$this->lang = $plugin->key;
|
||||
// set version if not set
|
||||
if (empty($plugin->plugin_version))
|
||||
{
|
||||
$plugin->plugin_version = '1.0.0';
|
||||
}
|
||||
// set GUI mapper
|
||||
$guiMapper = array( 'table' => 'joomla_plugin', 'id' => (int) $id, 'type' => 'php');
|
||||
// update the name if it has dynamic values
|
||||
$plugin->name = $this->setPlaceholders($this->setDynamicValues($plugin->name), $this->placeholders);
|
||||
// set official name
|
||||
$plugin->official_name = ucwords($plugin->group . ' - ' . $plugin->name);
|
||||
// set langPrefix
|
||||
$this->langPrefix = 'PLG_' . strtoupper($plugin->group) . '_' . strtoupper($plugin->name);
|
||||
// set lang prefix
|
||||
$plugin->lang_prefix = $this->langPrefix;
|
||||
// set plugin class name
|
||||
$plugin->class_name = 'Plg' . ucfirst($plugin->group) . ucfirst($plugin->name);
|
||||
// set plugin install class name
|
||||
$plugin->installer_class_name = 'plg' . ucfirst($plugin->group) . ucfirst($plugin->name) . 'InstallerScript';
|
||||
// set plugin folder name
|
||||
$plugin->folder_name = 'plg_' . strtolower($plugin->group) . '_' . strtolower($plugin->name);
|
||||
// set the zip name
|
||||
$plugin->zip_name = $plugin->folder_name . '_v' . str_replace('.', '_', $plugin->plugin_version). '__J' . $this->joomlaVersion;
|
||||
// set plugin file name
|
||||
$plugin->file_name = strtolower($plugin->name);
|
||||
// set official_name lang strings
|
||||
$this->setLangContent($plugin->key, $this->langPrefix, $plugin->official_name);
|
||||
// set description (TODO) add description field to plugin
|
||||
if (!isset($plugin->description) || !ComponentbuilderHelper::checkString($plugin->description))
|
||||
{
|
||||
$plugin->description = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$plugin->description = $this->setPlaceholders($this->setDynamicValues($plugin->description), $this->placeholders);
|
||||
$this->setLangContent($plugin->key, $plugin->lang_prefix . '_DESCRIPTION', $plugin->description);
|
||||
$plugin->description = '<p>' . $plugin->description . '</p>';
|
||||
}
|
||||
$plugin->xml_description = "<h1>" . $plugin->official_name . " (v." . $plugin->plugin_version . ")</h1> <div style='clear: both;'></div>" . $plugin->description . "<p>Created by <a href='" . trim($component->website) . "' target='_blank'>" . trim(JFilterOutput::cleanText($component->author)) . "</a><br /><small>Development started " . JFactory::getDate($plugin->created)->format("jS F, Y") . "</small></p>";
|
||||
// set xml discription
|
||||
$this->setLangContent($plugin->key, $plugin->lang_prefix . '_XML_DESCRIPTION', $plugin->xml_description);
|
||||
// update the readme if set
|
||||
if ($plugin->addreadme == 1 && !empty($plugin->readme))
|
||||
{
|
||||
$plugin->readme = $this->setPlaceholders($this->setDynamicValues(base64_decode($plugin->readme)), $this->placeholders);
|
||||
}
|
||||
else
|
||||
{
|
||||
$plugin->addreadme = 0;
|
||||
unset($plugin->readme);
|
||||
}
|
||||
// open some base64 strings
|
||||
if (!empty($plugin->main_class_code))
|
||||
{
|
||||
// set GUI mapper field
|
||||
$guiMapper['field'] = 'main_class_code';
|
||||
// base64 Decode main_class_code.
|
||||
$plugin->main_class_code = $this->setGuiCodePlaceholder(
|
||||
$this->setPlaceholders($this->setDynamicValues(base64_decode($plugin->main_class_code)), $this->placeholders),
|
||||
$guiMapper
|
||||
);
|
||||
}
|
||||
// set the head :)
|
||||
if ($plugin->add_head == 1 && !empty($plugin->head))
|
||||
{
|
||||
// set GUI mapper field
|
||||
$guiMapper['field'] = 'head';
|
||||
// base64 Decode head.
|
||||
$plugin->head = $this->setGuiCodePlaceholder(
|
||||
$this->setPlaceholders($this->setDynamicValues(base64_decode($plugin->head)), $this->placeholders),
|
||||
$guiMapper
|
||||
);
|
||||
}
|
||||
elseif (!empty($plugin->class_head))
|
||||
{
|
||||
// base64 Decode head.
|
||||
$plugin->head = $this->setGuiCodePlaceholder(
|
||||
$this->setPlaceholders($this->setDynamicValues(base64_decode($plugin->class_head)), $this->placeholders),
|
||||
array(
|
||||
'table' => 'class_extends',
|
||||
'field' => 'head',
|
||||
'id' => (int) $plugin->class_id,
|
||||
'type' => 'php')
|
||||
);
|
||||
}
|
||||
unset($plugin->class_head);
|
||||
// set the comment
|
||||
if (!empty($plugin->comment))
|
||||
{
|
||||
// base64 Decode comment.
|
||||
$plugin->comment = $this->setGuiCodePlaceholder(
|
||||
$this->setPlaceholders($this->setDynamicValues(base64_decode($plugin->comment)), $this->placeholders),
|
||||
array(
|
||||
'table' => 'class_extends',
|
||||
'field' => 'comment',
|
||||
'id' => (int) $plugin->class_id,
|
||||
'type' => 'php')
|
||||
);
|
||||
}
|
||||
// set the fields data
|
||||
$plugin->fields = (isset($plugin->fields) && ComponentbuilderHelper::checkJson($plugin->fields)) ? json_decode($plugin->fields, true) : null;
|
||||
if (ComponentbuilderHelper::checkArray($plugin->fields))
|
||||
{
|
||||
$key = $plugin->key;
|
||||
$plugin->config_fields = array_map(function($field) use ($key){
|
||||
// make sure the alias and title is 0
|
||||
$field['alias'] = 0;
|
||||
$field['title'] = 0;
|
||||
// set the field details
|
||||
$this->setFieldDetails($field, $key);
|
||||
// set unique name counter
|
||||
$this->setUniqueNameCounter($field['base_name'], $key);
|
||||
// return field
|
||||
return $field;
|
||||
}, array_values($plugin->fields));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create a new query object.
|
||||
$query = $this->db->getQuery(true);
|
||||
|
||||
// do some house cleaning (for fields)
|
||||
foreach ($plugin->config_fields as $field)
|
||||
$query->select('a.*');
|
||||
$query->select(
|
||||
$this->db->quoteName(
|
||||
array(
|
||||
'g.name',
|
||||
'e.name',
|
||||
'e.head',
|
||||
'e.comment',
|
||||
'e.id',
|
||||
'f.addfiles',
|
||||
'f.addfolders',
|
||||
'f.addfilesfullpath',
|
||||
'f.addfoldersfullpath',
|
||||
'f.addurls',
|
||||
'u.version_update',
|
||||
'u.id'
|
||||
), array(
|
||||
'group',
|
||||
'extends',
|
||||
'class_head',
|
||||
'comment',
|
||||
'class_id',
|
||||
'addfiles',
|
||||
'addfolders',
|
||||
'addfilesfullpath',
|
||||
'addfoldersfullpath',
|
||||
'addurls',
|
||||
'version_update',
|
||||
'version_update_id'
|
||||
)
|
||||
)
|
||||
);
|
||||
// from these tables
|
||||
$query->from('#__componentbuilder_joomla_plugin AS a');
|
||||
$query->join('LEFT', $this->db->quoteName('#__componentbuilder_joomla_plugin_group', 'g') . ' ON (' . $this->db->quoteName('a.joomla_plugin_group') . ' = ' . $this->db->quoteName('g.id') . ')');
|
||||
$query->join('LEFT', $this->db->quoteName('#__componentbuilder_class_extends', 'e') . ' ON (' . $this->db->quoteName('a.class_extends') . ' = ' . $this->db->quoteName('e.id') . ')');
|
||||
$query->join('LEFT', $this->db->quoteName('#__componentbuilder_joomla_plugin_updates', 'u') . ' ON (' . $this->db->quoteName('a.id') . ' = ' . $this->db->quoteName('u.joomla_plugin') . ')');
|
||||
$query->join('LEFT', $this->db->quoteName('#__componentbuilder_joomla_plugin_files_folders_urls', 'f') . ' ON (' . $this->db->quoteName('a.id') . ' = ' . $this->db->quoteName('f.joomla_plugin') . ')');
|
||||
$query->where($this->db->quoteName('a.id') . ' = ' . (int) $id);
|
||||
$query->where($this->db->quoteName('a.published') . ' >= 1');
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
if ($this->db->getNumRows())
|
||||
{
|
||||
// get the plugin data
|
||||
$plugin = $this->db->loadObject();
|
||||
// tweak system to set stuff to the plugin domain
|
||||
$_backup_target = $this->target;
|
||||
$_backup_lang = $this->lang;
|
||||
$_backup_langPrefix = $this->langPrefix;
|
||||
// set some keys
|
||||
$plugin->target_type = 'P|uG!n';
|
||||
$plugin->key = $plugin->id . '_' . $plugin->target_type;
|
||||
// update to point to plugin
|
||||
$this->target = $plugin->key;
|
||||
$this->lang = $plugin->key;
|
||||
// set version if not set
|
||||
if (empty($plugin->plugin_version))
|
||||
{
|
||||
// so first we lock the field name in
|
||||
$this->getFieldName($field, $plugin->key);
|
||||
$plugin->plugin_version = '1.0.0';
|
||||
}
|
||||
// unset original value
|
||||
unset($plugin->fields);
|
||||
}
|
||||
// set the add targets
|
||||
$addArray = array('files' => 'files', 'folders' => 'folders', 'urls' => 'urls', 'filesfullpath' => 'files', 'foldersfullpath' => 'folders');
|
||||
foreach ($addArray as $addTarget => $targetHere)
|
||||
{
|
||||
// set the add target data
|
||||
$plugin->{'add' . $addTarget} = (isset($plugin->{'add' . $addTarget}) && ComponentbuilderHelper::checkJson($plugin->{'add' . $addTarget})) ? json_decode($plugin->{'add' . $addTarget}, true) : null;
|
||||
if (ComponentbuilderHelper::checkArray($plugin->{'add' . $addTarget}))
|
||||
// set GUI mapper
|
||||
$guiMapper = array( 'table' => 'joomla_plugin', 'id' => (int) $id, 'type' => 'php');
|
||||
// update the name if it has dynamic values
|
||||
$plugin->name = $this->setPlaceholders($this->setDynamicValues($plugin->name), $this->placeholders);
|
||||
// update the name if it has dynamic values
|
||||
$plugin->code_name = ComponentbuilderHelper::safeClassFunctionName($plugin->name);
|
||||
// set official name
|
||||
$plugin->official_name = ucwords($plugin->group . ' - ' . $plugin->name);
|
||||
// set langPrefix
|
||||
$this->langPrefix = 'PLG_' . strtoupper($plugin->group) . '_' . strtoupper($plugin->code_name);
|
||||
// set lang prefix
|
||||
$plugin->lang_prefix = $this->langPrefix;
|
||||
// set plugin class name
|
||||
$plugin->class_name = 'Plg' . ucfirst($plugin->group) . ucfirst($plugin->code_name);
|
||||
// set plugin install class name
|
||||
$plugin->installer_class_name = 'plg' . ucfirst($plugin->group) . ucfirst($plugin->code_name) . 'InstallerScript';
|
||||
// set plugin folder name
|
||||
$plugin->folder_name = 'plg_' . strtolower($plugin->group) . '_' . strtolower($plugin->code_name);
|
||||
// set the zip name
|
||||
$plugin->zip_name = $plugin->folder_name . '_v' . str_replace('.', '_', $plugin->plugin_version). '__J' . $this->joomlaVersion;
|
||||
// set plugin file name
|
||||
$plugin->file_name = strtolower($plugin->code_name);
|
||||
// set official_name lang strings
|
||||
$this->setLangContent($plugin->key, $this->langPrefix, $plugin->official_name);
|
||||
// set description (TODO) add description field to plugin
|
||||
if (!isset($plugin->description) || !ComponentbuilderHelper::checkString($plugin->description))
|
||||
{
|
||||
if (isset($plugin->{$targetHere}) && ComponentbuilderHelper::checkArray($plugin->{$targetHere}))
|
||||
{
|
||||
foreach ($plugin->{'add' . $addTarget} as $taget)
|
||||
{
|
||||
$plugin->{$targetHere}[] = $taget;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$plugin->{$targetHere} = array_values($plugin->{'add' . $addTarget});
|
||||
}
|
||||
}
|
||||
unset($plugin->{'add' . $addTarget});
|
||||
}
|
||||
// add PHP in plugin install
|
||||
$plugin->add_install_script = false;
|
||||
$addScriptMethods = array('php_preflight', 'php_postflight', 'php_method');
|
||||
$addScriptTypes = array('install', 'update', 'uninstall');
|
||||
foreach ($addScriptMethods as $scriptMethod)
|
||||
{
|
||||
foreach ($addScriptTypes as $scriptType)
|
||||
{
|
||||
if (isset($plugin->{'add_' . $scriptMethod . '_' . $scriptType}) && $plugin->{'add_' . $scriptMethod . '_' . $scriptType} == 1 && ComponentbuilderHelper::checkString($plugin->{$scriptMethod . '_' . $scriptType}))
|
||||
{
|
||||
// set GUI mapper field
|
||||
$guiMapper['field'] = $scriptMethod . '_' . $scriptType;
|
||||
$plugin->{$scriptMethod . '_' . $scriptType} = $this->setGuiCodePlaceholder(
|
||||
$this->setPlaceholders($this->setDynamicValues(base64_decode($plugin->{$scriptMethod . '_' . $scriptType})), $this->placeholders),
|
||||
$guiMapper
|
||||
);
|
||||
$plugin->add_install_script = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($plugin->{$scriptMethod . '_' . $scriptType});
|
||||
$plugin->{'add_' . $scriptMethod . '_' . $scriptType} = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// add_sql
|
||||
if ($plugin->add_sql == 1 && ComponentbuilderHelper::checkString($plugin->sql))
|
||||
{
|
||||
$plugin->sql = $this->setPlaceholders($this->setDynamicValues(base64_decode($plugin->sql)), $this->placeholders);
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($plugin->sql);
|
||||
$plugin->add_sql = 0;
|
||||
}
|
||||
// add_sql_uninstall
|
||||
if ($plugin->add_sql_uninstall == 1 && ComponentbuilderHelper::checkString($plugin->sql_uninstall))
|
||||
{
|
||||
$plugin->sql_uninstall = $this->setPlaceholders($this->setDynamicValues(base64_decode($plugin->sql_uninstall)), $this->placeholders);
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($plugin->sql_uninstall);
|
||||
$plugin->add_sql_uninstall = 0;
|
||||
}
|
||||
// update the URL of the update_server if set
|
||||
if ($plugin->add_update_server == 1 && ComponentbuilderHelper::checkString($plugin->update_server_url))
|
||||
{
|
||||
$plugin->update_server_url = $this->setPlaceholders($this->setDynamicValues($plugin->update_server_url), $this->placeholders);
|
||||
}
|
||||
// add the update/sales server FTP details if that is the expected protocol
|
||||
$serverArray = array('update_server', 'sales_server');
|
||||
foreach ($serverArray as $server)
|
||||
{
|
||||
if ($plugin->{'add_' . $server} == 1 && is_numeric($plugin->{$server}) && $plugin->{$server} > 0)
|
||||
{
|
||||
// get the server protocol
|
||||
$plugin->{$server . '_protocol'} = ComponentbuilderHelper::getVar('server', (int) $plugin->{$server}, 'id', 'protocol');
|
||||
$plugin->description = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$plugin->{$server} = 0;
|
||||
// only change this for sales server (update server can be added loacaly to the zip file)
|
||||
if ('sales_server' === $server)
|
||||
{
|
||||
$plugin->{'add_' . $server} = 0;
|
||||
}
|
||||
$plugin->{$server . '_protocol'} = 0;
|
||||
$plugin->description = $this->setPlaceholders($this->setDynamicValues($plugin->description), $this->placeholders);
|
||||
$this->setLangContent($plugin->key, $plugin->lang_prefix . '_DESCRIPTION', $plugin->description);
|
||||
$plugin->description = '<p>' . $plugin->description . '</p>';
|
||||
}
|
||||
$plugin->xml_description = "<h1>" . $plugin->official_name . " (v." . $plugin->plugin_version . ")</h1> <div style='clear: both;'></div>" . $plugin->description . "<p>Created by <a href='" . trim($component->website) . "' target='_blank'>" . trim(JFilterOutput::cleanText($component->author)) . "</a><br /><small>Development started " . JFactory::getDate($plugin->created)->format("jS F, Y") . "</small></p>";
|
||||
// set xml discription
|
||||
$this->setLangContent($plugin->key, $plugin->lang_prefix . '_XML_DESCRIPTION', $plugin->xml_description);
|
||||
// update the readme if set
|
||||
if ($plugin->addreadme == 1 && !empty($plugin->readme))
|
||||
{
|
||||
$plugin->readme = $this->setPlaceholders($this->setDynamicValues(base64_decode($plugin->readme)), $this->placeholders);
|
||||
}
|
||||
else
|
||||
{
|
||||
$plugin->addreadme = 0;
|
||||
unset($plugin->readme);
|
||||
}
|
||||
// open some base64 strings
|
||||
if (!empty($plugin->main_class_code))
|
||||
{
|
||||
// set GUI mapper field
|
||||
$guiMapper['field'] = 'main_class_code';
|
||||
// base64 Decode main_class_code.
|
||||
$plugin->main_class_code = $this->setGuiCodePlaceholder(
|
||||
$this->setPlaceholders($this->setDynamicValues(base64_decode($plugin->main_class_code)), $this->placeholders),
|
||||
$guiMapper
|
||||
);
|
||||
}
|
||||
// set the head :)
|
||||
if ($plugin->add_head == 1 && !empty($plugin->head))
|
||||
{
|
||||
// set GUI mapper field
|
||||
$guiMapper['field'] = 'head';
|
||||
// base64 Decode head.
|
||||
$plugin->head = $this->setGuiCodePlaceholder(
|
||||
$this->setPlaceholders($this->setDynamicValues(base64_decode($plugin->head)), $this->placeholders),
|
||||
$guiMapper
|
||||
);
|
||||
}
|
||||
elseif (!empty($plugin->class_head))
|
||||
{
|
||||
// base64 Decode head.
|
||||
$plugin->head = $this->setGuiCodePlaceholder(
|
||||
$this->setPlaceholders($this->setDynamicValues(base64_decode($plugin->class_head)), $this->placeholders),
|
||||
array(
|
||||
'table' => 'class_extends',
|
||||
'field' => 'head',
|
||||
'id' => (int) $plugin->class_id,
|
||||
'type' => 'php')
|
||||
);
|
||||
}
|
||||
unset($plugin->class_head);
|
||||
// set the comment
|
||||
if (!empty($plugin->comment))
|
||||
{
|
||||
// base64 Decode comment.
|
||||
$plugin->comment = $this->setGuiCodePlaceholder(
|
||||
$this->setPlaceholders($this->setDynamicValues(base64_decode($plugin->comment)), $this->placeholders),
|
||||
array(
|
||||
'table' => 'class_extends',
|
||||
'field' => 'comment',
|
||||
'id' => (int) $plugin->class_id,
|
||||
'type' => 'php')
|
||||
);
|
||||
}
|
||||
// start the config array
|
||||
$plugin->config_fields = array();
|
||||
// create the form arrays
|
||||
$plugin->form_files = array();
|
||||
$plugin->fieldsets_label = array();
|
||||
$plugin->fieldsets_paths = array();
|
||||
// set global fields rule to default component path
|
||||
$plugin->fields_rules_paths = 1;
|
||||
// set the fields data
|
||||
$plugin->fields = (isset($plugin->fields) && ComponentbuilderHelper::checkJson($plugin->fields)) ? json_decode($plugin->fields, true) : null;
|
||||
if (ComponentbuilderHelper::checkArray($plugin->fields))
|
||||
{
|
||||
// ket global key
|
||||
$key = $plugin->key;
|
||||
$dynamic_fields = array('fieldset' => 'basic', 'fields_name' => 'params', 'file' => 'config');
|
||||
foreach ($plugin->fields as $n => &$form)
|
||||
{
|
||||
if (isset($form['fields']) && ComponentbuilderHelper::checkArray($form['fields']))
|
||||
{
|
||||
// make sure the dynamic_field is set to dynamic_value by default
|
||||
foreach ($dynamic_fields as $dynamic_field => $dynamic_value)
|
||||
{
|
||||
if (!isset($form[$dynamic_field]) || !ComponentbuilderHelper::checkString($form[$dynamic_field]))
|
||||
{
|
||||
$form[$dynamic_field] = $dynamic_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
$form[$dynamic_field] = ComponentbuilderHelper::safeString($form[$dynamic_field]);
|
||||
}
|
||||
}
|
||||
// check if field is external form file
|
||||
if (!isset($form['plugin']) || $form['plugin'] != 1)
|
||||
{
|
||||
// now build the form key
|
||||
$unique = $form['file'] . $form['fields_name'] . $form['fieldset'];
|
||||
}
|
||||
else
|
||||
{
|
||||
// now build the form key
|
||||
$unique = $form['fields_name'] . $form['fieldset'];
|
||||
}
|
||||
// set global fields rule path switchs
|
||||
if ($plugin->fields_rules_paths == 1 && isset($form['fields_rules_paths']) && $form['fields_rules_paths'] == 2)
|
||||
{
|
||||
$plugin->fields_rules_paths = 2;
|
||||
}
|
||||
// set where to path is pointing
|
||||
$plugin->fieldsets_paths[$unique] = $form['fields_rules_paths'];
|
||||
// add the label if set to lang
|
||||
if (isset($form['label']) && ComponentbuilderHelper::checkString($form['label']))
|
||||
{
|
||||
$plugin->fieldsets_label[$unique] = $this->setLang($form['label']);
|
||||
}
|
||||
// build the fields
|
||||
$form['fields'] = array_map(function($field) use ($key, $unique){
|
||||
// make sure the alias and title is 0
|
||||
$field['alias'] = 0;
|
||||
$field['title'] = 0;
|
||||
// set the field details
|
||||
$this->setFieldDetails($field, $key, $key, $unique);
|
||||
// update the default if set
|
||||
if (ComponentbuilderHelper::checkString($field['custom_value']) && isset($field['settings']))
|
||||
{
|
||||
if (($old_default = ComponentbuilderHelper::getBetween($field['settings']->xml, 'default="', '"', false)) !== false)
|
||||
{
|
||||
// replace old default
|
||||
$field['settings']->xml = str_replace('default="' . $old_default . '"', 'default="' . $field['custom_value'] . '"', $field['settings']->xml);
|
||||
}
|
||||
else
|
||||
{
|
||||
// add the default (hmmm not ideal but okay it should work)
|
||||
$field['settings']->xml = 'default="' . $field['custom_value'] . '" ' . $field['settings']->xml;
|
||||
}
|
||||
}
|
||||
unset($field['custom_value']);
|
||||
// return field
|
||||
return $field;
|
||||
}, array_values($form['fields']));
|
||||
// check if field is external form file
|
||||
if (!isset($form['plugin']) || $form['plugin'] != 1)
|
||||
{
|
||||
// load the form file
|
||||
if (!isset($plugin->form_files[$form['file']]))
|
||||
{
|
||||
$plugin->form_files[$form['file']] = array();
|
||||
}
|
||||
if (!isset($plugin->form_files[$form['file']][$form['fields_name']]))
|
||||
{
|
||||
$plugin->form_files[$form['file']][$form['fields_name']] = array();
|
||||
}
|
||||
if (!isset($plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']]))
|
||||
{
|
||||
$plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']] = array();
|
||||
}
|
||||
// do some house cleaning (for fields)
|
||||
foreach ($form['fields'] as $field)
|
||||
{
|
||||
// so first we lock the field name in
|
||||
$this->getFieldName($field, $plugin->key, $unique);
|
||||
// add the fields to the global form file builder
|
||||
$plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']][] = $field;
|
||||
}
|
||||
// remove form
|
||||
unset($plugin->fields[$n]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// load the cofig form
|
||||
if (!isset($plugin->config_fields[$form['fields_name']]))
|
||||
{
|
||||
$plugin->config_fields[$form['fields_name']] = array();
|
||||
}
|
||||
if (!isset($plugin->config_fields[$form['fields_name']][$form['fieldset']]))
|
||||
{
|
||||
$plugin->config_fields[$form['fields_name']][$form['fieldset']] = array();
|
||||
}
|
||||
// do some house cleaning (for fields)
|
||||
foreach ($form['fields'] as $field)
|
||||
{
|
||||
// so first we lock the field name in
|
||||
$this->getFieldName($field, $plugin->key, $unique);
|
||||
// add the fields to the config builder
|
||||
$plugin->config_fields[$form['fields_name']][$form['fieldset']][] = $field;
|
||||
}
|
||||
// remove form
|
||||
unset($plugin->fields[$n]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($plugin->fields[$n]);
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($plugin->fields);
|
||||
// set the add targets
|
||||
$addArray = array('files' => 'files', 'folders' => 'folders', 'urls' => 'urls', 'filesfullpath' => 'files', 'foldersfullpath' => 'folders');
|
||||
foreach ($addArray as $addTarget => $targetHere)
|
||||
{
|
||||
// set the add target data
|
||||
$plugin->{'add' . $addTarget} = (isset($plugin->{'add' . $addTarget}) && ComponentbuilderHelper::checkJson($plugin->{'add' . $addTarget})) ? json_decode($plugin->{'add' . $addTarget}, true) : null;
|
||||
if (ComponentbuilderHelper::checkArray($plugin->{'add' . $addTarget}))
|
||||
{
|
||||
if (isset($plugin->{$targetHere}) && ComponentbuilderHelper::checkArray($plugin->{$targetHere}))
|
||||
{
|
||||
foreach ($plugin->{'add' . $addTarget} as $taget)
|
||||
{
|
||||
$plugin->{$targetHere}[] = $taget;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$plugin->{$targetHere} = array_values($plugin->{'add' . $addTarget});
|
||||
}
|
||||
}
|
||||
unset($plugin->{'add' . $addTarget});
|
||||
}
|
||||
// add PHP in plugin install
|
||||
$plugin->add_install_script = false;
|
||||
$addScriptMethods = array('php_preflight', 'php_postflight', 'php_method');
|
||||
$addScriptTypes = array('install', 'update', 'uninstall');
|
||||
foreach ($addScriptMethods as $scriptMethod)
|
||||
{
|
||||
foreach ($addScriptTypes as $scriptType)
|
||||
{
|
||||
if (isset($plugin->{'add_' . $scriptMethod . '_' . $scriptType}) && $plugin->{'add_' . $scriptMethod . '_' . $scriptType} == 1 && ComponentbuilderHelper::checkString($plugin->{$scriptMethod . '_' . $scriptType}))
|
||||
{
|
||||
// set GUI mapper field
|
||||
$guiMapper['field'] = $scriptMethod . '_' . $scriptType;
|
||||
$plugin->{$scriptMethod . '_' . $scriptType} = $this->setGuiCodePlaceholder(
|
||||
$this->setPlaceholders($this->setDynamicValues(base64_decode($plugin->{$scriptMethod . '_' . $scriptType})), $this->placeholders),
|
||||
$guiMapper
|
||||
);
|
||||
$plugin->add_install_script = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($plugin->{$scriptMethod . '_' . $scriptType});
|
||||
$plugin->{'add_' . $scriptMethod . '_' . $scriptType} = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// add_sql
|
||||
if ($plugin->add_sql == 1 && ComponentbuilderHelper::checkString($plugin->sql))
|
||||
{
|
||||
$plugin->sql = $this->setPlaceholders($this->setDynamicValues(base64_decode($plugin->sql)), $this->placeholders);
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($plugin->sql);
|
||||
$plugin->add_sql = 0;
|
||||
}
|
||||
// add_sql_uninstall
|
||||
if ($plugin->add_sql_uninstall == 1 && ComponentbuilderHelper::checkString($plugin->sql_uninstall))
|
||||
{
|
||||
$plugin->sql_uninstall = $this->setPlaceholders($this->setDynamicValues(base64_decode($plugin->sql_uninstall)), $this->placeholders);
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($plugin->sql_uninstall);
|
||||
$plugin->add_sql_uninstall = 0;
|
||||
}
|
||||
// update the URL of the update_server if set
|
||||
if ($plugin->add_update_server == 1 && ComponentbuilderHelper::checkString($plugin->update_server_url))
|
||||
{
|
||||
$plugin->update_server_url = $this->setPlaceholders($this->setDynamicValues($plugin->update_server_url), $this->placeholders);
|
||||
}
|
||||
// add the update/sales server FTP details if that is the expected protocol
|
||||
$serverArray = array('update_server', 'sales_server');
|
||||
foreach ($serverArray as $server)
|
||||
{
|
||||
if ($plugin->{'add_' . $server} == 1 && is_numeric($plugin->{$server}) && $plugin->{$server} > 0)
|
||||
{
|
||||
// get the server protocol
|
||||
$plugin->{$server . '_protocol'} = ComponentbuilderHelper::getVar('server', (int) $plugin->{$server}, 'id', 'protocol');
|
||||
}
|
||||
else
|
||||
{
|
||||
$plugin->{$server} = 0;
|
||||
// only change this for sales server (update server can be added loacaly to the zip file)
|
||||
if ('sales_server' === $server)
|
||||
{
|
||||
$plugin->{'add_' . $server} = 0;
|
||||
}
|
||||
$plugin->{$server . '_protocol'} = 0;
|
||||
}
|
||||
}
|
||||
// set the update server stuff (TODO)
|
||||
// update_server_xml_path
|
||||
// update_server_xml_file_name
|
||||
|
||||
// rest globals
|
||||
$this->target = $_backup_target;
|
||||
$this->lang = $_backup_lang;
|
||||
$this->langPrefix = $_backup_langPrefix;
|
||||
|
||||
$this->joomlaPlugins[$id] = $plugin;
|
||||
|
||||
return true;
|
||||
}
|
||||
// set the update server stuff (TODO)
|
||||
// update_server_xml_path
|
||||
// update_server_xml_file_name
|
||||
|
||||
// rest globals
|
||||
$this->target = $_backup_target;
|
||||
$this->lang = $_backup_lang;
|
||||
$this->langPrefix = $_backup_langPrefix;
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -6478,7 +6621,6 @@ class Get
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<description>' . $plugin->lang_prefix . '_XML_DESCRIPTION</description>';
|
||||
$xml .= $this->hhh . 'MAINXML' . $this->hhh;
|
||||
$xml .= PHP_EOL . '</extension>';
|
||||
$dates = array();
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
@ -372,7 +372,7 @@ class Structure extends Get
|
||||
// load the libraries files/folders and url's
|
||||
$this->setLibraries();
|
||||
// load the plugin files/folders and url's
|
||||
$this->setPlugins();
|
||||
$this->buildPlugins();
|
||||
// set the Joomla Version Data
|
||||
$this->joomlaVersionData = $this->setJoomlaVersionData();
|
||||
// Trigger Event: jcb_ce_onAfterSetJoomlaVersionData
|
||||
@ -422,13 +422,13 @@ class Structure extends Get
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
private function setPlugins()
|
||||
private function buildPlugins()
|
||||
{
|
||||
if (ComponentbuilderHelper::checkArray($this->componentData->joomla_plugins))
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaPlugins))
|
||||
{
|
||||
// Trigger Event: jcb_ce_onBeforeSetPlugins
|
||||
$this->triggerEvent('jcb_ce_onBeforeSetPlugins', array(&$this->componentContext, &$this->componentData->joomla_plugins));
|
||||
foreach ($this->componentData->joomla_plugins as $plugin)
|
||||
$this->triggerEvent('jcb_ce_onBeforeBuildPlugins', array(&$this->componentContext, &$this->joomlaPlugins));
|
||||
foreach ($this->joomlaPlugins as $plugin)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($plugin) && isset($plugin->folder_name)
|
||||
&& ComponentbuilderHelper::checkString($plugin->folder_name))
|
||||
@ -491,6 +491,88 @@ class Structure extends Get
|
||||
// count the file created
|
||||
$this->fileCount++;
|
||||
}
|
||||
// set fields & rules folders if needed
|
||||
if (isset($plugin->fields_rules_paths) && $plugin->fields_rules_paths == 2)
|
||||
{
|
||||
// create fields folder
|
||||
if (!JFolder::exists($plugin->folder_path . '/fields'))
|
||||
{
|
||||
JFolder::create($plugin->folder_path . '/fields');
|
||||
// count the folder created
|
||||
$this->folderCount++;
|
||||
$this->indexHTML($plugin->folder_name . '/fields', $this->compilerPath);
|
||||
}
|
||||
// create rules folder
|
||||
if (!JFolder::exists($plugin->folder_path . '/rules'))
|
||||
{
|
||||
JFolder::create($plugin->folder_path . '/rules');
|
||||
// count the folder created
|
||||
$this->folderCount++;
|
||||
$this->indexHTML($plugin->folder_name . '/rules', $this->compilerPath);
|
||||
}
|
||||
}
|
||||
// set forms folder if needed
|
||||
if (isset($plugin->form_files) && ComponentbuilderHelper::checkArray($plugin->form_files))
|
||||
{
|
||||
// create forms folder
|
||||
if (!JFolder::exists($plugin->folder_path . '/forms'))
|
||||
{
|
||||
JFolder::create($plugin->folder_path . '/forms');
|
||||
// count the folder created
|
||||
$this->folderCount++;
|
||||
$this->indexHTML($plugin->folder_name . '/forms', $this->compilerPath);
|
||||
}
|
||||
// set the template files
|
||||
foreach($plugin->form_files as $file => $fields)
|
||||
{
|
||||
// set file details
|
||||
$fileDetails = array('path' => $plugin->folder_path . '/forms/' . $file . '.xml',
|
||||
'name' => $file . '.xml', 'zip' => 'forms/' . $file . '.xml');
|
||||
// biuld basic XML
|
||||
$xml = '<?xml version="1.0" encoding="utf-8"?>';
|
||||
$xml .= PHP_EOL . '<!--' . $this->setLine(__LINE__) . ' default paths of ' . $file . ' form points to ' . $this->componentCodeName . ' -->';
|
||||
$xml .= PHP_EOL . '<form';
|
||||
$xml .= PHP_EOL . $this->_t(1) . 'addrulepath="/administrator/components/com_' . $this->componentCodeName . '/models/rules"';
|
||||
$xml .= PHP_EOL . $this->_t(1) . 'addfieldpath="/administrator/components/com_' . $this->componentCodeName . '/models/fields"';
|
||||
$xml .= PHP_EOL . '>';
|
||||
foreach ($fields as $field_name => $fieldsets)
|
||||
{
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<fields name="' . $field_name . '">';
|
||||
foreach ($fieldsets as $fieldset => $field)
|
||||
{
|
||||
// default to the field set name
|
||||
$label = $fieldset;
|
||||
if (isset($plugin->fieldsets_label[$file.$field_name.$fieldset]))
|
||||
{
|
||||
$label = $plugin->fieldsets_label[$file.$field_name.$fieldset];
|
||||
}
|
||||
// add path to plugin rules and custom fields
|
||||
if (isset($plugin->fieldsets_paths[$file.$field_name.$fieldset]) && $plugin->fieldsets_paths[$file.$field_name.$fieldset] == 2)
|
||||
{
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<!--' . $this->setLine(__LINE__) . ' default paths of ' . $fieldset . ' fieldset points to the plugin -->';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<fieldset name="' . $fieldset . '" label="' . $label . '"';
|
||||
$xml .= PHP_EOL . $this->_t(2) . 'addrulepath="/plugins/' . strtolower($plugin->group) . '/' . strtolower($plugin->code_name) . '/rules"';
|
||||
$xml .= PHP_EOL . $this->_t(2) . 'addfieldpath="/plugins/' . strtolower($plugin->group) . '/' . strtolower($plugin->code_name) . '/fields"';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<fieldset name="' . $fieldset . '" label="' . $label . '">';
|
||||
}
|
||||
// add the placeholder of the fields
|
||||
$xml .= $this->hhh . 'FIELDSET_' . $file.$field_name.$fieldset . $this->hhh;
|
||||
$xml .= PHP_EOL . $this->_t(1) . '</fieldset>';
|
||||
}
|
||||
$xml .= PHP_EOL . $this->_t(1) . '</fields>';
|
||||
}
|
||||
$xml .= PHP_EOL . '</form>';
|
||||
// add xml to file
|
||||
$this->writeFile($fileDetails['path'], $xml);
|
||||
$this->newFiles[$plugin->key][] = $fileDetails;
|
||||
// count the file created
|
||||
$this->fileCount++;
|
||||
}
|
||||
}
|
||||
// set SQL stuff if needed
|
||||
if ($plugin->add_sql || $plugin->add_sql_uninstall)
|
||||
{
|
||||
@ -1279,13 +1361,50 @@ class Structure extends Get
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* move the fields and Rules
|
||||
*
|
||||
* @param array $field The field data
|
||||
* @param string $path The path to move to
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function moveFieldsRules($field, $path)
|
||||
{
|
||||
// check if this is a custom field that should be moved
|
||||
if (isset($this->extentionCustomfields[$field['type_name']]))
|
||||
{
|
||||
// check files exist
|
||||
if (JFile::exists($this->componentPath . '/admin/models/fields/' . $field['type_name'] . '.php'))
|
||||
{
|
||||
// move the custom field
|
||||
JFile::copy($this->componentPath . '/admin/models/fields/' . $field['type_name'] . '.php', $path . '/fields/' . $field['type_name'] . '.php');
|
||||
}
|
||||
// do this just once
|
||||
unset($this->extentionCustomfields[$field['type_name']]);
|
||||
}
|
||||
// check if this has validation that should be moved
|
||||
if (isset($this->validationLinkedFields[$field['field']]))
|
||||
{
|
||||
// check files exist
|
||||
if (JFile::exists($this->componentPath . '/admin/models/rules/' . $this->validationLinkedFields[$field['field']] . '.php'))
|
||||
{
|
||||
// move the custom field
|
||||
JFile::copy($this->componentPath . '/admin/models/rules/' . $this->validationLinkedFields[$field['field']] . '.php', $path . '/rules/' . $this->validationLinkedFields[$field['field']] . '.php');
|
||||
}
|
||||
// do this just once
|
||||
unset($this->validationLinkedFields[$field['field']]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the created date of the (view)
|
||||
*
|
||||
*
|
||||
* @param array $view The view values
|
||||
*
|
||||
*
|
||||
* @return string Last Modified Date
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function getCreatedDate($view)
|
||||
{
|
||||
@ -1304,11 +1423,11 @@ class Structure extends Get
|
||||
|
||||
/**
|
||||
* get the last modified date of a MVC (view)
|
||||
*
|
||||
*
|
||||
* @param array $view The view values
|
||||
*
|
||||
*
|
||||
* @return string Last Modified Date
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function getLastModifiedDate($view)
|
||||
{
|
||||
@ -1487,10 +1606,9 @@ class Structure extends Get
|
||||
|
||||
/**
|
||||
* set the Joomla Version Data
|
||||
*
|
||||
*
|
||||
* @return oject The version data
|
||||
*
|
||||
*
|
||||
*/
|
||||
private function setJoomlaVersionData()
|
||||
{
|
||||
@ -1722,11 +1840,11 @@ class Structure extends Get
|
||||
|
||||
/**
|
||||
* set the index.html file in a folder path
|
||||
*
|
||||
*
|
||||
* @param string $path The path to place the index.html file in
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*
|
||||
*/
|
||||
private function indexHTML($path, $root = 'component')
|
||||
{
|
||||
|
@ -333,6 +333,13 @@ class Fields extends Structure
|
||||
*/
|
||||
public $movedPublishingFields = array();
|
||||
|
||||
/**
|
||||
* Extention Custom Fields
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $extentionCustomfields = array();
|
||||
|
||||
/**
|
||||
* Set the line number in comments
|
||||
*
|
||||
@ -1659,7 +1666,8 @@ class Fields extends Structure
|
||||
}
|
||||
$field .= PHP_EOL . $this->_t(2) . $taber . "/>";
|
||||
// incase the field is in the config and has not been set
|
||||
if ('config' === $view_name_single && 'configs' === $view_name_list)
|
||||
if ('config' === $view_name_single && 'configs' === $view_name_list||
|
||||
strpos($view_name_single, 'P|uG!n') !== false)
|
||||
{
|
||||
// set lang (just incase)
|
||||
$listLangName = $langView . '_' . ComponentbuilderHelper::safeString($name, 'U');
|
||||
@ -2144,8 +2152,9 @@ class Fields extends Structure
|
||||
$field->fieldXML->addAttribute($property, $value);
|
||||
}
|
||||
}
|
||||
// incase the field is in the config and has not been set
|
||||
if ('config' === $view_name_single && 'configs' === $view_name_list)
|
||||
// incase the field is in the config and has not been set (or is part of a plugin or module)
|
||||
if (('config' === $view_name_single && 'configs' === $view_name_list) ||
|
||||
strpos($view_name_single, 'P|uG!n') !== false)
|
||||
{
|
||||
// set lang (just incase)
|
||||
$listLangName = $langView . '_' . ComponentbuilderHelper::safeString($name, 'U');
|
||||
@ -3241,6 +3250,12 @@ class Fields extends Structure
|
||||
$this->fileContentDynamic['customfield_' . $data['type']][$this->hhh . 'ADD_BUTTON' . $this->hhh] = $this->setAddButtonToListField($data['custom']);
|
||||
}
|
||||
}
|
||||
// if this field gets used in plugin or module we should track it so if needed we can copy it over
|
||||
if (strpos($view_name_single, 'P|uG!n') !== false &&
|
||||
isset($data['custom']) && isset($data['custom']['type']))
|
||||
{
|
||||
$this->extentionCustomfields[$data['type']] = $data['custom']['type'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16296,13 +16296,7 @@ function vdm_dkim() {
|
||||
|
||||
public function getPluginMainXML(&$plugin)
|
||||
{
|
||||
// tweak system to set stuff to the plugin domain
|
||||
$_backup_target = $this->target;
|
||||
$_backup_lang = $this->lang;
|
||||
$_backup_langPrefix = $this->langPrefix;
|
||||
$this->target = $plugin->key;
|
||||
$this->lang = $plugin->key;
|
||||
$this->langPrefix = $plugin->lang_prefix;
|
||||
// set some defaults
|
||||
$view = '';
|
||||
$viewType = 0;
|
||||
// set the custom table key
|
||||
@ -16310,31 +16304,21 @@ function vdm_dkim() {
|
||||
// build the xml
|
||||
$xml = '';
|
||||
// build the config fields
|
||||
$config_field = '';
|
||||
$config_fields = array();
|
||||
if (isset($plugin->config_fields) && ComponentbuilderHelper::checkArray($plugin->config_fields))
|
||||
{
|
||||
foreach ($plugin->config_fields as $field)
|
||||
foreach ($plugin->config_fields as $field_name => $fieldsets)
|
||||
{
|
||||
// check the field builder type
|
||||
if ($this->fieldBuilderType == 1)
|
||||
foreach ($fieldsets as $fieldset => $fields)
|
||||
{
|
||||
// string manipulation
|
||||
$xmlField = $this->setDynamicField($field, $view, $viewType, $plugin->lang_prefix, $plugin->key, $plugin->key, $this->globalPlaceholders, $dbkey, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// simpleXMLElement class
|
||||
$newxmlField = $this->setDynamicField($field, $view, $viewType, $plugin->lang_prefix, $plugin->key, $plugin->key, $this->globalPlaceholders, $dbkey, false);
|
||||
if (isset($newxmlField->fieldXML))
|
||||
// get the field set
|
||||
$xmlFields = $this->getPluginFieldsetXML($plugin, $fields, $dbkey);
|
||||
// make sure the xml is set and a string
|
||||
if (isset($xmlFields) && ComponentbuilderHelper::checkString($xmlFields))
|
||||
{
|
||||
$xmlField = dom_import_simplexml($newxmlField->fieldXML);
|
||||
$xmlField = PHP_EOL . $this->_t(2) . "<!--" . $this->setLine(__LINE__) . " " . $newxmlField->comment . ' -->' . PHP_EOL . $this->_t(1) . $this->xmlPrettyPrint($xmlField, 'field');
|
||||
$config_fields[$field_name.$fieldset] = $xmlFields;
|
||||
}
|
||||
}
|
||||
// make sure the xml is set and a string
|
||||
if (isset($xmlField) && ComponentbuilderHelper::checkString($xmlField))
|
||||
{
|
||||
$config_field .= $xmlField;
|
||||
$dbkey++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -16348,8 +16332,8 @@ function vdm_dkim() {
|
||||
return $placeholder . '="' . $langstring . '"';
|
||||
}, $this->langContent[$plugin->key], array_keys($this->langContent[$plugin->key]));
|
||||
// add to language file
|
||||
$this->writeFile($plugin->folder_path . '/language/' . $this->langTag . '/' . $this->langTag . '.plg_' . strtolower($plugin->group) . '_' . strtolower($plugin->name) . '.ini', implode(PHP_EOL, $lang));
|
||||
$this->writeFile($plugin->folder_path . '/language/' . $this->langTag . '/' . $this->langTag . '.plg_' . strtolower($plugin->group) . '_' . strtolower($plugin->name) . '.sys.ini', implode(PHP_EOL, $lang));
|
||||
$this->writeFile($plugin->folder_path . '/language/' . $this->langTag . '/' . $this->langTag . '.plg_' . strtolower($plugin->group) . '_' . strtolower($plugin->code_name) . '.ini', implode(PHP_EOL, $lang));
|
||||
$this->writeFile($plugin->folder_path . '/language/' . $this->langTag . '/' . $this->langTag . '.plg_' . strtolower($plugin->group) . '_' . strtolower($plugin->code_name) . '.sys.ini', implode(PHP_EOL, $lang));
|
||||
// set the line counter
|
||||
$this->lineCount = $this->lineCount + count((array) $lang);
|
||||
unset($lang);
|
||||
@ -16392,8 +16376,8 @@ function vdm_dkim() {
|
||||
{
|
||||
$xml .= PHP_EOL . PHP_EOL . $this->_t(1) . '<!--' . $this->setLine(__LINE__) . ' Language files -->';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<languages folder="language">';
|
||||
$xml .= PHP_EOL . $this->_t(2) . '<language tag="en-GB">' . $this->langTag . '/' . $this->langTag . '.plg_' . strtolower($plugin->group) . '_' . strtolower($plugin->name) . '.ini</language>';
|
||||
$xml .= PHP_EOL . $this->_t(2) . '<language tag="en-GB">' . $this->langTag . '/' . $this->langTag . '.plg_' . strtolower($plugin->group) . '_' . strtolower($plugin->name) . '.sys.ini</language>';
|
||||
$xml .= PHP_EOL . $this->_t(2) . '<language tag="en-GB">' . $this->langTag . '/' . $this->langTag . '.plg_' . strtolower($plugin->group) . '_' . strtolower($plugin->code_name) . '.ini</language>';
|
||||
$xml .= PHP_EOL . $this->_t(2) . '<language tag="en-GB">' . $this->langTag . '/' . $this->langTag . '.plg_' . strtolower($plugin->group) . '_' . strtolower($plugin->code_name) . '.sys.ini</language>';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '</languages>';
|
||||
}
|
||||
// add the plugin files
|
||||
@ -16436,15 +16420,49 @@ function vdm_dkim() {
|
||||
}
|
||||
$xml .= PHP_EOL . $this->_t(1) . '</files>';
|
||||
// now add the Config Params if needed
|
||||
if (ComponentbuilderHelper::checkString($config_field))
|
||||
if (ComponentbuilderHelper::checkArray($config_fields))
|
||||
{
|
||||
$xml .= PHP_EOL . PHP_EOL . $this->_t(1) . '<!--' . $this->setLine(__LINE__) . ' Config parameter -->';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<config>';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<fields name="params">';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<fieldset name="basic">';
|
||||
$xml .= $config_field;
|
||||
$xml .= PHP_EOL . $this->_t(1) . '</fieldset>';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '</fields>';
|
||||
// add path to plugin rules and custom fields
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<config';
|
||||
$xml .= PHP_EOL . $this->_t(2) . 'addrulepath="/administrator/components/com_' . $this->componentCodeName . '/models/rules"';
|
||||
$xml .= PHP_EOL . $this->_t(2) . 'addfieldpath="/administrator/components/com_' . $this->componentCodeName . '/models/fields"';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '>';
|
||||
|
||||
foreach ($plugin->config_fields as $field_name => $fieldsets)
|
||||
{
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<fields name="' . $field_name . '">';
|
||||
foreach ($fieldsets as $fieldset => $fields)
|
||||
{
|
||||
// default to the field set name
|
||||
$label = $fieldset;
|
||||
if (isset($plugin->fieldsets_label[$field_name.$fieldset]))
|
||||
{
|
||||
$label = $plugin->fieldsets_label[$field_name.$fieldset];
|
||||
}
|
||||
// add path to plugin rules and custom fields
|
||||
if (isset($plugin->fieldsets_paths[$field_name.$fieldset]) && $plugin->fieldsets_paths[$field_name.$fieldset] == 2)
|
||||
{
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<!--' . $this->setLine(__LINE__) . ' default paths of ' . $fieldset . ' fieldset points to the plugin -->';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<fieldset name="' . $fieldset . '" label="' . $label . '"';
|
||||
$xml .= PHP_EOL . $this->_t(2) . 'addrulepath="/plugins/' . strtolower($plugin->group) . '/' . strtolower($plugin->code_name) . '/rules"';
|
||||
$xml .= PHP_EOL . $this->_t(2) . 'addfieldpath="/plugins/' . strtolower($plugin->group) . '/' . strtolower($plugin->code_name) . '/fields"';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<fieldset name="' . $fieldset . '" label="' . $label . '">';
|
||||
}
|
||||
// load the fields
|
||||
if (isset($config_fields[$field_name.$fieldset]))
|
||||
{
|
||||
$xml .= $config_fields[$field_name.$fieldset];
|
||||
unset($config_fields[$field_name.$fieldset]);
|
||||
}
|
||||
$xml .= PHP_EOL . $this->_t(1) . '</fieldset>';
|
||||
}
|
||||
$xml .= PHP_EOL . $this->_t(1) . '</fields>';
|
||||
}
|
||||
$xml .= PHP_EOL . $this->_t(1) . '</config>';
|
||||
}
|
||||
// set update server if found
|
||||
@ -16455,14 +16473,48 @@ function vdm_dkim() {
|
||||
$xml .= PHP_EOL . $this->_t(2) . '<server type="extension" priority="1" name="' . $plugin->official_name . '">' . $plugin->update_server_url . '</server>';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '</updateservers>';
|
||||
}
|
||||
// rest globals
|
||||
$this->target = $_backup_target;
|
||||
$this->lang = $_backup_lang;
|
||||
$this->langPrefix = $_backup_langPrefix;
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
public function getPluginFieldsetXML(&$plugin, &$fields, $dbkey = 'zz')
|
||||
{
|
||||
// set some defaults
|
||||
$view = '';
|
||||
$viewType = 0;
|
||||
// build the fieldset
|
||||
$fieldset = '';
|
||||
|
||||
if (ComponentbuilderHelper::checkArray($fields))
|
||||
{
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
// check the field builder type
|
||||
if ($this->fieldBuilderType == 1)
|
||||
{
|
||||
// string manipulation
|
||||
$xmlField = $this->setDynamicField($field, $view, $viewType, $plugin->lang_prefix, $plugin->key, $plugin->key, $this->globalPlaceholders, $dbkey, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// simpleXMLElement class
|
||||
$newxmlField = $this->setDynamicField($field, $view, $viewType, $plugin->lang_prefix, $plugin->key, $plugin->key, $this->globalPlaceholders, $dbkey, false);
|
||||
if (isset($newxmlField->fieldXML))
|
||||
{
|
||||
$xmlField = dom_import_simplexml($newxmlField->fieldXML);
|
||||
$xmlField = PHP_EOL . $this->_t(2) . "<!--" . $this->setLine(__LINE__) . " " . $newxmlField->comment . ' -->' . PHP_EOL . $this->_t(1) . $this->xmlPrettyPrint($xmlField, 'field');
|
||||
}
|
||||
}
|
||||
// make sure the xml is set and a string
|
||||
if (isset($xmlField) && ComponentbuilderHelper::checkString($xmlField))
|
||||
{
|
||||
$fieldset .= $xmlField;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $fieldset;
|
||||
}
|
||||
|
||||
public function getPluginInstallClass(&$plugin)
|
||||
{
|
||||
// yes we are adding it
|
||||
|
@ -1033,12 +1033,19 @@ class Infusion extends Interpretation
|
||||
}
|
||||
|
||||
// infuze plugin data if set
|
||||
if (ComponentbuilderHelper::checkArray($this->componentData->joomla_plugins))
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaPlugins))
|
||||
{
|
||||
foreach ($this->componentData->joomla_plugins as $plugin)
|
||||
foreach ($this->joomlaPlugins as $plugin)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($plugin))
|
||||
{
|
||||
// tweak system to set stuff to the plugin domain
|
||||
$_backup_target = $this->target;
|
||||
$_backup_lang = $this->lang;
|
||||
$_backup_langPrefix = $this->langPrefix;
|
||||
$this->target = $plugin->key;
|
||||
$this->lang = $plugin->key;
|
||||
$this->langPrefix = $plugin->lang_prefix;
|
||||
// MAINCLASS
|
||||
$this->fileContentDynamic[$plugin->key][$this->hhh . 'MAINCLASS' . $this->hhh] = $this->getPluginMainClass($plugin);
|
||||
// only add install script if needed
|
||||
@ -1047,8 +1054,28 @@ class Infusion extends Interpretation
|
||||
// INSTALLCLASS
|
||||
$this->fileContentDynamic[$plugin->key][$this->hhh . 'INSTALLCLASS' . $this->hhh] = $this->getPluginInstallClass($plugin);
|
||||
}
|
||||
// FIELDSET
|
||||
if (isset($plugin->form_files) && ComponentbuilderHelper::checkArray($plugin->form_files))
|
||||
{
|
||||
foreach($plugin->form_files as $file => $files)
|
||||
{
|
||||
foreach ($files as $field_name => $fieldsets)
|
||||
{
|
||||
foreach ($fieldsets as $fieldset => $fields)
|
||||
{
|
||||
// FIELDSET_ . $file.$field_name.$fieldset
|
||||
$this->fileContentDynamic[$plugin->key][$this->hhh . 'FIELDSET_' . $file.$field_name.$fieldset . $this->hhh] =
|
||||
$this->getPluginFieldsetXML($plugin, $fields);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// MAINXML
|
||||
$this->fileContentDynamic[$plugin->key][$this->hhh . 'MAINXML' . $this->hhh] = $this->getPluginMainXML($plugin);
|
||||
// rest globals
|
||||
$this->target = $_backup_target;
|
||||
$this->lang = $_backup_lang;
|
||||
$this->langPrefix = $_backup_langPrefix;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user