Improved the plugin form builder, to allow multi form field relationships.

This commit is contained in:
Llewellyn van der Merwe 2019-08-22 03:54:47 +02:00
parent c13c752abb
commit d2f94d84fa
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
65 changed files with 1225 additions and 431 deletions

View File

@ -146,14 +146,14 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 16th August, 2019
+ *Last Build*: 22nd August, 2019
+ *Version*: 2.10.0
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **246452**
+ *Field count*: **1319**
+ *File count*: **1595**
+ *Folder count*: **244**
+ *Line count*: **247612**
+ *Field count*: **1343**
+ *File count*: **1604**
+ *Folder count*: **250**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com).
> Developed by [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)

View File

@ -146,14 +146,14 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 16th August, 2019
+ *Last Build*: 22nd August, 2019
+ *Version*: 2.10.0
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **246452**
+ *Field count*: **1319**
+ *File count*: **1595**
+ *Folder count*: **244**
+ *Line count*: **247612**
+ *Field count*: **1343**
+ *File count*: **1604**
+ *Folder count*: **250**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com).
> Developed by [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)

View File

@ -775,6 +775,30 @@ abstract class ###Component###Helper
}
// get field type
$field = JFormHelper::loadFieldType($attributes['type'], true);
// get field xml
$XML = self::getFieldXML($attributes, $options);
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
}
return false;
}
/**
* get the field xml
*
* @param array $attributes The array of attributes
* @param array $options The options to apply to the XML element
*
* @return object
*
*/
public static function getFieldXML(&$attributes, $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes))
{
// start field xml
$XML = new SimpleXMLElement('<field/>');
// load the attributes
@ -785,10 +809,8 @@ abstract class ###Component###Helper
// load the options
self::xmlAddOptions($XML, $options);
}
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
// return the field xml
return $XML;
}
return false;
}

View File

@ -406,7 +406,7 @@ abstract class ###Component###Helper
* @return object
*
*/
public static function getFieldObject($attributes, $default = '', $options = null)
public static function getFieldObject(&$attributes, $default = '', $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes) && isset($attributes['type']))
@ -418,6 +418,30 @@ abstract class ###Component###Helper
}
// get field type
$field = JFormHelper::loadFieldType($attributes['type'], true);
// get field xml
$XML = self::getFieldXML($attributes, $options);
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
}
return false;
}
/**
* get the field xml
*
* @param array $attributes The array of attributes
* @param array $options The options to apply to the XML element
*
* @return object
*
*/
public static function getFieldXML(&$attributes, $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes))
{
// start field xml
$XML = new SimpleXMLElement('<field/>');
// load the attributes
@ -428,10 +452,8 @@ abstract class ###Component###Helper
// load the options
self::xmlAddOptions($XML, $options);
}
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
// return the field xml
return $XML;
}
return false;
}

View File

@ -242,6 +242,8 @@ class ###Component###Model###View### extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_###component###.###view###', $data);
}
return $data;

View File

@ -242,6 +242,8 @@ class ###Component###Model###View### extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_###component###.###view###', $data);
}
return $data;

View File

@ -288,7 +288,7 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin
$pluginId = $jinput->post->get('install_item_id', 0, 'INT');
if ($pluginId > 0 && isset($fileNames[$pluginId]) && $this->installExtension($fileNames[$pluginId]))
{
$message = JText::sprintf('COM_COMPONENTBUILDER_ONLY_SZIP_FILE_WAS_REMOVED_THE_FROM_TMP_FOLDER_DURING_INSTALLATION', $fileName);
$message = JText::sprintf('COM_COMPONENTBUILDER_ONLY_SZIP_FILE_WAS_REMOVED_THE_FROM_TMP_FOLDER_DURING_INSTALLATION', $fileNames[$pluginId]);
$this->setRedirect($redirect_url, $message, 'message');
return true;
}

View File

@ -20,14 +20,14 @@ ComponentbuilderHelper::autoLoader();
*/
class Compiler extends Infusion
{
/*
/**
* The Temp path
*
* @var string
*/
private $tempPath;
/*
/**
* The timer
*
* @var string
@ -36,7 +36,7 @@ class Compiler extends Infusion
private $time_end;
public $secondsCompiled;
/*
/**
* The file path array
*
* @var string
@ -260,12 +260,48 @@ class Compiler extends Infusion
// free up some memory
unset($this->newFiles['dynamic']);
// do plugins if found
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) && isset($this->newFiles[$plugin->key]) && ComponentbuilderHelper::checkArray($this->newFiles[$plugin->key]))
{
// move field or rule if needed
if (isset($plugin->fields_rules_paths) && $plugin->fields_rules_paths == 2)
{
// check the config fields
if (isset($plugin->config_fields) && ComponentbuilderHelper::checkArray($plugin->config_fields))
{
foreach ($plugin->config_fields as $field_name => $fieldsets)
{
foreach ($fieldsets as $fieldset => $fields)
{
foreach ($fields as $field)
{
$this->moveFieldsRules($field, $plugin->folder_path);
}
}
}
}
// check the fieldsets
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)
{
foreach ($fields as $field)
{
$this->moveFieldsRules($field, $plugin->folder_path);
}
}
}
}
}
}
// now move the files
foreach ($this->newFiles[$plugin->key] as $plugin_file)
{
if (JFile::exists($plugin_file['path']))
@ -355,9 +391,9 @@ class Compiler extends Infusion
}
}
// move the plugins update server to host
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)
&& isset($plugin->add_update_server) && $plugin->add_update_server == 1
@ -528,9 +564,9 @@ class Compiler extends Infusion
$this->triggerEvent('jcb_ce_onAfterUpdateRepo', array(&$this->componentContext, &$this->componentPath, &$repoFullPath, &$this->componentData));
// move the plugins to local folder repos
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) && isset($plugin->file_name))
{
@ -596,9 +632,9 @@ class Compiler extends Infusion
private function zipPlugins()
{
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) && isset($plugin->zip_name)
&& ComponentbuilderHelper::checkString($plugin->zip_name)

View File

@ -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,12 +6182,18 @@ 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)
{
if (isset($this->joomlaPlugins[$id]))
{
return true;
}
else
{
// Create a new query object.
$query = $this->db->getQuery(true);
@ -6235,22 +6263,24 @@ class Get
$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->name);
$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->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->name) . 'InstallerScript';
$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->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->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
@ -6325,32 +6355,142 @@ class Get
'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;
$plugin->config_fields = array_map(function($field) use ($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);
// set unique name counter
$this->setUniqueNameCounter($field['base_name'], $key);
$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($plugin->fields));
}, 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 ($plugin->config_fields as $field)
foreach ($form['fields'] as $field)
{
// so first we lock the field name in
$this->getFieldName($field, $plugin->key);
$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 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)
@ -6452,7 +6592,10 @@ class Get
$this->lang = $_backup_lang;
$this->langPrefix = $_backup_langPrefix;
return $plugin;
$this->joomlaPlugins[$id] = $plugin;
return true;
}
}
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;
}

View File

@ -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,6 +1361,43 @@ 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)
*
@ -1488,7 +1607,6 @@ class Structure extends Get
/**
* set the Joomla Version Data
*
*
* @return oject The version data
*
*/

View File

@ -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'];
}
}
/**

View File

@ -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))
{
$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');
}
}
// get the field set
$xmlFields = $this->getPluginFieldsetXML($plugin, $fields, $dbkey);
// make sure the xml is set and a string
if (isset($xmlField) && ComponentbuilderHelper::checkString($xmlField))
if (isset($xmlFields) && ComponentbuilderHelper::checkString($xmlFields))
{
$config_field .= $xmlField;
$config_fields[$field_name.$fieldset] = $xmlFields;
}
$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;
// 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

View File

@ -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;
}
}
}

View File

@ -6407,6 +6407,30 @@ abstract class ComponentbuilderHelper
}
// get field type
$field = JFormHelper::loadFieldType($attributes['type'], true);
// get field xml
$XML = self::getFieldXML($attributes, $options);
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
}
return false;
}
/**
* get the field xml
*
* @param array $attributes The array of attributes
* @param array $options The options to apply to the XML element
*
* @return object
*
*/
public static function getFieldXML(&$attributes, $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes))
{
// start field xml
$XML = new SimpleXMLElement('<field/>');
// load the attributes
@ -6417,10 +6441,8 @@ abstract class ComponentbuilderHelper
// load the options
self::xmlAddOptions($XML, $options);
}
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
// return the field xml
return $XML;
}
return false;
}

View File

@ -6017,7 +6017,7 @@ COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ADD_UPDATE_SERVER_LABEL="Add Update Server"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_CLASS_EXTENDS="Class Extends"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_CLASS_EXTENDS_LABEL="Extends"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_CODE="Code"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_CONFIGPARAMS="Config/Params"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_COMPONENT="Component"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_CREATED_BY_DESC="The user that created this Joomla Plugin."
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_CREATED_BY_LABEL="Created By"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_CREATED_DATE_DESC="The date this Joomla Plugin was created."
@ -6034,7 +6034,16 @@ COM_COMPONENTBUILDER_JOOMLA_PLUGIN_EDIT="Editing the Joomla Plugin"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ERROR_UNIQUE_ALIAS="Another Joomla Plugin has the same alias."
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELD="Field"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDS="Fields"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDS_LABEL="Fields"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDSET_DESCRIPTION="Leave default if you don't know what this should be"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDSET_HINT="basic"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDSET_LABEL="Fieldset Name"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDS_DESCRIPTION="All the field that belong to this form."
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDS_LABEL="Related Forms"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDS_NAME_DESCRIPTION="Leave default if you don't know what this should be."
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDS_NAME_HINT="params"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDS_NAME_LABEL="Fields Name"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDS_RULES_PATHS_DESCRIPTION="Where should the <b>custom</b> fields and rules be placed."
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDS_RULES_PATHS_LABEL="Fields & Rules Paths"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELD_DESCRIPTION="Select a field"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELD_LABEL="Field"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS="Joomla Plugin Files, Folders & URLs"
@ -6153,6 +6162,10 @@ COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_URL_LABEL="URL"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_URL_MESSAGE="Error! Please add url here."
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_VERSION_DESC="A count of the number of times this Joomla Plugin Files, Folders & URLs has been revised."
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_VERSION_LABEL="Revision"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILE_DESCRIPTION="Leave default if you don't know what this should be. This field is ignored if this form belongs to the plugin config area."
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILE_HINT="config"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILE_LABEL="File Name"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FORMS_FIELDS="Forms & Fields"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GET_BOILERPLATE_BUTTON_ACCESS="Joomla Plugin Get Boilerplate Button Access"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GET_BOILERPLATE_BUTTON_ACCESS_DESC="Allows the users in this group to access the get boilerplate button."
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_GROUP="Joomla Plugin Group"
@ -6215,6 +6228,9 @@ COM_COMPONENTBUILDER_JOOMLA_PLUGIN_HEAD_LABEL="Class Head"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_ID="Id"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_JOOMLA_PLUGIN_GROUP="Joomla Plugin Group"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_JOOMLA_PLUGIN_GROUP_LABEL="Joomla Plugin Group"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_LABEL_DESCRIPTION="Not mandatory, used to Label the Fieldset"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_LABEL_HINT="Name"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_LABEL_LABEL="Label"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_MAIN_CLASS_CODE="Main Class Code"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_MAIN_CLASS_CODE_DESCRIPTION="Add the class properties & methods here."
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_MAIN_CLASS_CODE_LABEL="Class Properties & Methods"
@ -6272,6 +6288,9 @@ COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PHP_PREFLIGHT_UPDATE_LABEL="PHP Preflight (up
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PHP_SCRIPT_CONSTRUCT="Php Script Construct"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PHP_SCRIPT_CONSTRUCT_DESCRIPTION="PHP script that should run in __construct of script."
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PHP_SCRIPT_CONSTRUCT_LABEL="PHP Script Construct"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PLUGIN="Plugin"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PLUGIN_DESCRIPTION="Add this form the the Plugin Config area."
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PLUGIN_LABEL="Add to Plugin Config"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PLUGIN_VERSION="Plugin Version"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PLUGIN_VERSION_DESCRIPTION="Add Version Number Here"
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PLUGIN_VERSION_HINT="1.0.0"

View File

@ -363,6 +363,8 @@ class ComponentbuilderModelAdmin_custom_tabs extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.admin_custom_tabs', $data);
}
return $data;

View File

@ -384,6 +384,8 @@ class ComponentbuilderModelAdmin_fields extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.admin_fields', $data);
}
return $data;

View File

@ -384,6 +384,8 @@ class ComponentbuilderModelAdmin_fields_conditions extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.admin_fields_conditions', $data);
}
return $data;

View File

@ -395,6 +395,8 @@ class ComponentbuilderModelAdmin_fields_relations extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.admin_fields_relations', $data);
}
return $data;

View File

@ -893,6 +893,8 @@ class ComponentbuilderModelAdmin_view extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.admin_view', $data);
}
return $data;

View File

@ -426,6 +426,8 @@ class ComponentbuilderModelClass_extends extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.class_extends', $data);
}
return $data;

View File

@ -435,6 +435,8 @@ class ComponentbuilderModelClass_method extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.class_method', $data);
}
return $data;

View File

@ -426,6 +426,8 @@ class ComponentbuilderModelClass_property extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.class_property', $data);
}
return $data;

View File

@ -395,6 +395,8 @@ class ComponentbuilderModelComponent_admin_views extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.component_admin_views', $data);
}
return $data;

View File

@ -394,6 +394,8 @@ class ComponentbuilderModelComponent_config extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.component_config', $data);
}
return $data;

View File

@ -394,6 +394,8 @@ class ComponentbuilderModelComponent_custom_admin_menus extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.component_custom_admin_menus', $data);
}
return $data;

View File

@ -395,6 +395,8 @@ class ComponentbuilderModelComponent_custom_admin_views extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.component_custom_admin_views', $data);
}
return $data;

View File

@ -432,6 +432,8 @@ class ComponentbuilderModelComponent_dashboard extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.component_dashboard', $data);
}
return $data;

View File

@ -431,6 +431,8 @@ class ComponentbuilderModelComponent_files_folders extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.component_files_folders', $data);
}
return $data;

View File

@ -394,6 +394,8 @@ class ComponentbuilderModelComponent_mysql_tweaks extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.component_mysql_tweaks', $data);
}
return $data;

View File

@ -363,6 +363,8 @@ class ComponentbuilderModelComponent_placeholders extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.component_placeholders', $data);
}
return $data;

View File

@ -364,6 +364,8 @@ class ComponentbuilderModelComponent_plugins extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.component_plugins', $data);
}
return $data;

View File

@ -395,6 +395,8 @@ class ComponentbuilderModelComponent_site_views extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.component_site_views', $data);
}
return $data;

View File

@ -394,6 +394,8 @@ class ComponentbuilderModelComponent_updates extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.component_updates', $data);
}
return $data;

View File

@ -599,6 +599,8 @@ class ComponentbuilderModelCustom_admin_view extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.custom_admin_view', $data);
}
return $data;

View File

@ -435,6 +435,8 @@ class ComponentbuilderModelCustom_code extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.custom_code', $data);
}
return $data;

View File

@ -613,6 +613,8 @@ class ComponentbuilderModelDynamic_get extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.dynamic_get', $data);
}
return $data;

View File

@ -483,6 +483,8 @@ class ComponentbuilderModelField extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.field', $data);
}
return $data;

View File

@ -28,6 +28,110 @@ class JFormFieldJoomlaplugins extends JFormFieldList
*/
public $type = 'joomlaplugins';
/**
* Override to add new button
*
* @return string The field input markup.
*
* @since 3.2
*/
protected function getInput()
{
// see if we should add buttons
$set_button = $this->getAttribute('button');
// get html
$html = parent::getInput();
// if true set button
if ($set_button === 'true')
{
$button = array();
$script = array();
$button_code_name = $this->getAttribute('name');
// get the input from url
$app = JFactory::getApplication();
$jinput = $app->input;
// get the view name & id
$values = $jinput->getArray(array(
'id' => 'int',
'view' => 'word'
));
// check if new item
$ref = '';
$refJ = '';
if (!is_null($values['id']) && strlen($values['view']))
{
// only load referral if not new item.
$ref = '&amp;ref=' . $values['view'] . '&amp;refid=' . $values['id'];
$refJ = '&ref=' . $values['view'] . '&refid=' . $values['id'];
// get the return value.
$_uri = (string) JUri::getInstance();
$_return = urlencode(base64_encode($_uri));
// load return value.
$ref .= '&amp;return=' . $_return;
$refJ .= '&return=' . $_return;
}
// get button label
$button_label = trim($button_code_name);
$button_label = preg_replace('/_+/', ' ', $button_label);
$button_label = preg_replace('/\s+/', ' ', $button_label);
$button_label = preg_replace("/[^A-Za-z ]/", '', $button_label);
$button_label = ucfirst(strtolower($button_label));
// get user object
$user = JFactory::getUser();
// only add if user allowed to create joomla_plugin
if ($user->authorise('joomla_plugin.create', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area.
{
// build Create button
$button[] = '<a id="'.$button_code_name.'Create" class="btn btn-small btn-success hasTooltip" title="'.JText::sprintf('PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_CREATE_NEW_S', $button_label).'" style="border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;"
href="index.php?option=com_componentbuilder&amp;view=joomla_plugin&amp;layout=edit'.$ref.'" >
<span class="icon-new icon-white"></span></a>';
}
// only add if user allowed to edit joomla_plugin
if ($user->authorise('joomla_plugin.edit', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area.
{
// build edit button
$button[] = '<a id="'.$button_code_name.'Edit" class="btn btn-small hasTooltip" title="'.JText::sprintf('PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_EDIT_S', $button_label).'" style="display: none; padding: 4px 4px 4px 7px;" href="#" >
<span class="icon-edit"></span></a>';
// build script
$script[] = "
jQuery(document).ready(function() {
jQuery('#adminForm').on('change', '#jform_".$button_code_name."',function (e) {
e.preventDefault();
var ".$button_code_name."Value = jQuery('#jform_".$button_code_name."').val();
".$button_code_name."Button(".$button_code_name."Value);
});
var ".$button_code_name."Value = jQuery('#jform_".$button_code_name."').val();
".$button_code_name."Button(".$button_code_name."Value);
});
function ".$button_code_name."Button(value) {
if (value > 0) {
// hide the create button
jQuery('#".$button_code_name."Create').hide();
// show edit button
jQuery('#".$button_code_name."Edit').show();
var url = 'index.php?option=com_componentbuilder&view=joomla_plugins&task=joomla_plugin.edit&id='+value+'".$refJ."';
jQuery('#".$button_code_name."Edit').attr('href', url);
} else {
// show the create button
jQuery('#".$button_code_name."Create').show();
// hide edit button
jQuery('#".$button_code_name."Edit').hide();
}
}";
}
// check if button was created for joomla_plugin field.
if (is_array($button) && count($button) > 0)
{
// Load the needed script.
$document = JFactory::getDocument();
$document->addScriptDeclaration(implode(' ',$script));
// return the button attached to input field.
return '<div class="input-append">' .$html . implode('',$button).'</div>';
}
}
return $html;
}
/**
* Method to get a list of options for a list input.
*

View File

@ -41,19 +41,26 @@ class JFormFieldTargetfields extends JFormFieldList
$jinput = JFactory::getApplication()->input;
// get the id
$ID = $jinput->getInt('id', 0);
// get the view name
$VIEW = $jinput->get('view', null, 'WORD');
// rest the fields ids
$fieldIds = array();
if (is_numeric($ID) && $ID >= 1)
// if this is an actual admin view then we are done
if ('admin_view' === $VIEW && is_numeric($ID) && $ID >= 1)
{
$adminView = $ID;
}
elseif (is_numeric($ID) && $ID >= 1)
{
// get the admin view ID
$adminView = ComponentbuilderHelper::getVar('admin_fields_conditions', (int) $ID, 'id', 'admin_view');
}
else
elseif ('admin_view' !== $VIEW)
{
// get the admin view ID
$adminView = $jinput->getInt('refid', 0);
}
if (is_numeric($adminView) && $adminView >= 1)
if (isset($adminView) && is_numeric($adminView) && $adminView >= 1)
{
// get all the fields linked to the admin view
if ($addFields = ComponentbuilderHelper::getVar('admin_fields', (int) $adminView, 'admin_view', 'addfields'))

View File

@ -630,6 +630,8 @@ class ComponentbuilderModelFieldtype extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.fieldtype', $data);
}
return $data;

View File

@ -409,11 +409,105 @@
type="subform"
name="fields"
label="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDS_LABEL"
layout="joomla.form.field.subform.repeatable-table"
layout="joomla.form.field.subform.repeatable"
multiple="true"
buttons="add,remove,move"
icon="list"
max="50">
max="10">
<form hidden="true" name="list_fields_modal" repeat="true">
<!-- Plugin Field. Type: Checkbox. (joomla) -->
<field
type="checkbox"
name="plugin"
label="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PLUGIN_LABEL"
value="1"
default="1"
description="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PLUGIN_DESCRIPTION"
class="inputbox"
/>
<!-- File Field. Type: Text. (joomla) -->
<field
type="text"
name="file"
label="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILE_LABEL"
size="10"
maxlength="50"
default="config"
description="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILE_DESCRIPTION"
class="text_area"
filter="WORD"
hint="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILE_HINT"
autocomplete="on"
/>
<!-- Fields_name Field. Type: Text. (joomla) -->
<field
type="text"
name="fields_name"
label="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDS_NAME_LABEL"
size="10"
maxlength="50"
default="params"
description="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDS_NAME_DESCRIPTION"
class="text_area"
filter="WORD"
hint="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDS_NAME_HINT"
autocomplete="on"
/>
<!-- Fieldset Field. Type: Text. (joomla) -->
<field
type="text"
name="fieldset"
label="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDSET_LABEL"
size="10"
maxlength="50"
default="basic"
description="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDSET_DESCRIPTION"
class="text_area"
filter="WORD"
hint="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDSET_HINT"
autocomplete="on"
/>
<!-- Label Field. Type: Text. (joomla) -->
<field
type="text"
name="label"
label="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_LABEL_LABEL"
size="10"
maxlength="50"
description="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_LABEL_DESCRIPTION"
class="text_area"
filter="String"
hint="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_LABEL_HINT"
autocomplete="on"
/>
<!-- Fields_rules_paths Field. Type: List. (joomla) -->
<field
type="list"
name="fields_rules_paths"
label="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDS_RULES_PATHS_LABEL"
description="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDS_RULES_PATHS_DESCRIPTION"
class="list_class"
multiple="false"
validate="number"
default="1">
<!-- Option Set. -->
<option value="1">
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_COMPONENT</option>
<option value="2">
COM_COMPONENTBUILDER_JOOMLA_PLUGIN_PLUGIN</option>
</field>
<!-- Fields Field. Type: Subform. (joomla) -->
<field
type="subform"
name="fields"
label="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDS_LABEL"
layout="joomla.form.field.subform.repeatable-table"
multiple="true"
buttons="add,remove,move"
description="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FIELDS_DESCRIPTION"
icon="list"
max="50"
nested_depth="1">
<form hidden="true" name="list_fields_modal" repeat="true">
<!-- Field Field. Type: Fields. (custom) -->
<field
@ -443,6 +537,8 @@
/>
</form>
</field>
</form>
</field>
<!-- Add_php_method_uninstall Field. Type: Radio. (joomla) -->
<field
type="radio"

View File

@ -375,6 +375,8 @@ class ComponentbuilderModelHelp_document extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.help_document', $data);
}
return $data;

View File

@ -767,6 +767,8 @@ class ComponentbuilderModelJoomla_component extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.joomla_component', $data);
}
return $data;

View File

@ -94,7 +94,7 @@ class ComponentbuilderModelJoomla_plugin extends JModelAdmin
'readme'
)
),
'configparams' => array(
'forms_fields' => array(
'fullwidth' => array(
'fields'
)
@ -572,6 +572,8 @@ class ComponentbuilderModelJoomla_plugin extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.joomla_plugin', $data);
}
return $data;

View File

@ -409,6 +409,8 @@ class ComponentbuilderModelJoomla_plugin_files_folders_urls extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.joomla_plugin_files_folders_urls', $data);
}
return $data;

View File

@ -352,6 +352,8 @@ class ComponentbuilderModelJoomla_plugin_group extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.joomla_plugin_group', $data);
}
return $data;

View File

@ -363,6 +363,8 @@ class ComponentbuilderModelJoomla_plugin_updates extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.joomla_plugin_updates', $data);
}
return $data;

View File

@ -353,6 +353,8 @@ class ComponentbuilderModelLanguage extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.language', $data);
}
return $data;

View File

@ -397,6 +397,8 @@ class ComponentbuilderModelLanguage_translation extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.language_translation', $data);
}
return $data;

View File

@ -451,6 +451,8 @@ class ComponentbuilderModelLayout extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.layout', $data);
}
return $data;

View File

@ -449,6 +449,8 @@ class ComponentbuilderModelLibrary extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.library', $data);
}
return $data;

View File

@ -363,6 +363,8 @@ class ComponentbuilderModelLibrary_config extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.library_config', $data);
}
return $data;

View File

@ -409,6 +409,8 @@ class ComponentbuilderModelLibrary_files_folders_urls extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.library_files_folders_urls', $data);
}
return $data;

View File

@ -400,6 +400,8 @@ class ComponentbuilderModelPlaceholder extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.placeholder', $data);
}
return $data;

View File

@ -511,6 +511,8 @@ class ComponentbuilderModelServer extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.server', $data);
}
return $data;

View File

@ -620,6 +620,8 @@ class ComponentbuilderModelSite_view extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.site_view', $data);
}
return $data;

View File

@ -380,6 +380,8 @@ class ComponentbuilderModelSnippet extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.snippet', $data);
}
return $data;

View File

@ -353,6 +353,8 @@ class ComponentbuilderModelSnippet_type extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.snippet_type', $data);
}
return $data;

View File

@ -451,6 +451,8 @@ class ComponentbuilderModelTemplate extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.template', $data);
}
return $data;

View File

@ -403,6 +403,8 @@ class ComponentbuilderModelValidation_rule extends JModelAdmin
if (empty($data))
{
$data = $this->getItem();
// run the perprocess of the data
$this->preprocessData('com_componentbuilder.validation_rule', $data);
}
return $data;

View File

@ -65,12 +65,12 @@ $componentParams = $this->params; // will be removed just use $this->params inst
</div>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JHtml::_('bootstrap.addTab', 'joomla_pluginTab', 'configparams', JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_CONFIGPARAMS', true)); ?>
<?php echo JHtml::_('bootstrap.addTab', 'joomla_pluginTab', 'forms_fields', JText::_('COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FORMS_FIELDS', true)); ?>
<div class="row-fluid form-horizontal-desktop">
</div>
<div class="row-fluid form-horizontal-desktop">
<div class="span12">
<?php echo JLayoutHelper::render('joomla_plugin.configparams_fullwidth', $this); ?>
<?php echo JLayoutHelper::render('joomla_plugin.forms_fields_fullwidth', $this); ?>
</div>
</div>
<?php echo JHtml::_('bootstrap.endTab'); ?>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2" method="upgrade">
<name>COM_COMPONENTBUILDER</name>
<creationDate>16th August, 2019</creationDate>
<creationDate>22nd August, 2019</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
<authorUrl>http://www.joomlacomponentbuilder.com</authorUrl>

View File

@ -5670,7 +5670,7 @@ abstract class ComponentbuilderHelper
* @return object
*
*/
public static function getFieldObject($attributes, $default = '', $options = null)
public static function getFieldObject(&$attributes, $default = '', $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes) && isset($attributes['type']))
@ -5682,6 +5682,30 @@ abstract class ComponentbuilderHelper
}
// get field type
$field = JFormHelper::loadFieldType($attributes['type'], true);
// get field xml
$XML = self::getFieldXML($attributes, $options);
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
}
return false;
}
/**
* get the field xml
*
* @param array $attributes The array of attributes
* @param array $options The options to apply to the XML element
*
* @return object
*
*/
public static function getFieldXML(&$attributes, $options = null)
{
// make sure we have attributes and a type value
if (self::checkArray($attributes))
{
// start field xml
$XML = new SimpleXMLElement('<field/>');
// load the attributes
@ -5692,10 +5716,8 @@ abstract class ComponentbuilderHelper
// load the options
self::xmlAddOptions($XML, $options);
}
// setup the field
$field->setup($XML, $default);
// return the field object
return $field;
// return the field xml
return $XML;
}
return false;
}