Resolve gh-609 to make sure that custom code set in a field that gets linked to a module will get added to the module.

This commit is contained in:
Llewellyn van der Merwe 2020-12-05 08:17:54 +02:00
parent e7670a1edd
commit dfbd2b2a6d
Signed by: Llewellyn
GPG Key ID: EFC0C720A240551C
7 changed files with 319 additions and 478 deletions

View File

@ -144,13 +144,13 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 3rd December, 2020 + *Last Build*: 5th December, 2020
+ *Version*: 2.12.1 + *Version*: 2.12.1
+ *Copyright*: Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt + *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **289032** + *Line count*: **289032**
+ *Field count*: **1537** + *Field count*: **1537**
+ *File count*: **1880** + *File count*: **1902**
+ *Folder count*: **304** + *Folder count*: **304**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com). > This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com).

View File

@ -144,13 +144,13 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 3rd December, 2020 + *Last Build*: 5th December, 2020
+ *Version*: 2.12.1 + *Version*: 2.12.1
+ *Copyright*: Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt + *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **289032** + *Line count*: **289032**
+ *Field count*: **1537** + *Field count*: **1537**
+ *File count*: **1880** + *File count*: **1902**
+ *Folder count*: **304** + *Folder count*: **304**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com). > This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com).

View File

@ -3986,8 +3986,6 @@ class Get
$this->_fieldData[$id]->css_view_decoded = true; $this->_fieldData[$id]->css_view_decoded = true;
} }
} }
// add this only once to view.
$this->customFieldScript[$name_single][$id] = true;
} }
// check if we should load scripts for list views // check if we should load scripts for list views
if (ComponentbuilderHelper::checkString($name_list) if (ComponentbuilderHelper::checkString($name_list)
@ -4058,7 +4056,7 @@ class Get
$this->setCustomScriptBuilder( $this->setCustomScriptBuilder(
$this->_fieldData[$id]->css_views, $this->_fieldData[$id]->css_views,
'css_views', 'css_views',
$name_list, $name_single,
false, false,
array('prefix' => PHP_EOL), array('prefix' => PHP_EOL),
$convert__, $convert__,
@ -4070,10 +4068,11 @@ class Get
$this->_fieldData[$id]->css_views_decoded = true; $this->_fieldData[$id]->css_views_decoded = true;
} }
} }
// add this only once to view.
$this->customFieldScript[$name_list][$id] = true;
} }
// add this only once to single view.
$this->customFieldScript[$name_single][$id] = true;
// add this only once to list view.
$this->customFieldScript[$name_list][$id] = true;
} }
if ($id > 0 && isset($this->_fieldData[$id])) if ($id > 0 && isset($this->_fieldData[$id]))
{ {
@ -5235,6 +5234,57 @@ class Get
return false; return false;
} }
/**
* get the a script from the custom script builder
*
* @param string $first The first key
* @param string $second The second key
* @param string $prefix The prefix to add in front of the script if found
* @param string $note The switch/note to add to the script
* @param bool $unset The switch to unset the value if found
* @param string $default The switch/string to use as default return if script not found
* @param string $sufix The sufix to add after the script if found
*
* @return mix The string/script if found or the default value if not found
*
*/
public function getCustomScriptBuilder($first, $second, $prefix = '',
$note = null, $unset = null, $default = null, $sufix = ''
) {
// default is to return an empty string
$script = '';
// check if there is any custom script
if (isset($this->customScriptBuilder[$first][$second])
&& ComponentbuilderHelper::checkString(
$this->customScriptBuilder[$first][$second]
))
{
// add not if set
if ($note)
{
$script .= $note;
}
// load the actual script
$script .= $prefix . str_replace(
array_keys($this->placeholders),
array_values($this->placeholders),
$this->customScriptBuilder[$first][$second]
) . $sufix;
// clear some memory
if ($unset)
{
unset($this->customScriptBuilder[$first][$second]);
}
}
// if not found return default
if (!ComponentbuilderHelper::checkString($script) && $default)
{
return $default;
}
return $script;
}
/** /**
* To limit the SQL Demo date build in the views * To limit the SQL Demo date build in the views
* *
@ -8699,7 +8749,7 @@ class Get
$unique = $form['fields_name'] $unique = $form['fields_name']
. $form['fieldset']; . $form['fieldset'];
} }
// set global fields rule path switchs // set global fields rule path switches
if ($module->fields_rules_paths == 1 if ($module->fields_rules_paths == 1
&& isset($form['fields_rules_paths']) && isset($form['fields_rules_paths'])
&& $form['fields_rules_paths'] == 2) && $form['fields_rules_paths'] == 2)
@ -9095,6 +9145,39 @@ class Get
return $xml; return $xml;
} }
/**
* get the module admin custom script field
*
* @return string
*
*/
public function getModAdminVvvvvvvdm($fieldScriptBucket)
{
$form_field_class = array();
$form_field_class[] = $this->hhh . 'BOM' . $this->hhh . PHP_EOL;
$form_field_class[] = "//" . $this->setLine(__LINE__) . " No direct access to this file";
$form_field_class[] = "defined('_JEXEC') or die('Restricted access');";
$form_field_class[] = PHP_EOL . "use Joomla\CMS\Form\FormField;";
$form_field_class[] = "use Joomla\CMS\Factory;";
$form_field_class[] = PHP_EOL . "class JFormFieldModadminvvvvvvvdm extends FormField";
$form_field_class[] = "{";
$form_field_class[] = $this->_t(1) . "protected \$type = 'modadminvvvvvvvdm';";
$form_field_class[] = PHP_EOL . $this->_t(1) . "protected function getLabel()";
$form_field_class[] = $this->_t(1) . "{";
$form_field_class[] = $this->_t(2) . "return;";
$form_field_class[] = $this->_t(1) . "}";
$form_field_class[] = PHP_EOL . $this->_t(1) . "protected function getInput()";
$form_field_class[] = $this->_t(1) . "{";
$form_field_class[] = $this->_t(2) . "//" . $this->setLine(__LINE__) . " Get the document";
$form_field_class[] = $this->_t(2) . "\$document = Factory::getDocument();";
$form_field_class[] = implode(PHP_EOL, $fieldScriptBucket);
$form_field_class[] = $this->_t(2) . "return; // noting for now :)";
$form_field_class[] = $this->_t(1) . "}";
$form_field_class[] = "}";
return implode(PHP_EOL, $form_field_class);
}
/** /**
* get the Joomla plugins IDs * get the Joomla plugins IDs
* *

View File

@ -501,16 +501,8 @@ class Structure extends Get
$this->dynamicPaths[$module->key] = $module->folder_path; $this->dynamicPaths[$module->key] = $module->folder_path;
// make sure there is no old build // make sure there is no old build
$this->removeFolder($module->folder_path); $this->removeFolder($module->folder_path);
// creat the main component folder // creat the main module folder
if (!JFolder::exists($module->folder_path)) $this->createFolder($module->folder_path);
{
JFolder::create($module->folder_path);
// count the folder created
$this->folderCount++;
$this->indexHTML(
$module->folder_name, $this->compilerPath
);
}
// set main mod file // set main mod file
$fileDetails = array('path' => $module->folder_path . '/' $fileDetails = array('path' => $module->folder_path . '/'
. $module->file_name . '.php', . $module->file_name . '.php',
@ -592,15 +584,7 @@ class Structure extends Get
// count the file created // count the file created
$this->fileCount++; $this->fileCount++;
// set tmpl folder // set tmpl folder
if (!JFolder::exists($module->folder_path . '/tmpl')) $this->createFolder($module->folder_path . '/tmpl');
{
JFolder::create($module->folder_path . '/tmpl');
// count the folder created
$this->folderCount++;
$this->indexHTML(
$module->folder_name . '/tmpl', $this->compilerPath
);
}
// set default file // set default file
$fileDetails = array('path' => $module->folder_path $fileDetails = array('path' => $module->folder_path
. '/tmpl/default.php', . '/tmpl/default.php',
@ -652,32 +636,116 @@ class Structure extends Get
// count the file created // count the file created
$this->fileCount++; $this->fileCount++;
} }
// set fields & rules folders if needed // set the folders target path
$target_path = '';
if ($module->target_client === 'administrator')
{
$target_path = '/administrator';
}
// check if we have custom fields needed for scripts
$module->add_scripts_field = false;
$field_script_bucket = array();
// add any css from the fields
if (($css = $this->getCustomScriptBuilder(
'css_view', $module->key
)) !== null
&& ComponentbuilderHelper::checkString($css))
{
// make sure this script does not have PHP
if (strpos($css, '<?php') === false)
{
// make sure the field is added
$module->add_scripts_field = true;
// create the css folder
$this->createFolder($module->folder_path . '/css');
// add the CSS file
$fileDetails = array('path' => $module->folder_path
. '/css/mod_admin.css',
'name' => 'mod_admin.css',
'zip' => 'mod_admin.css');
$this->writeFile(
$fileDetails['path'],
$this->hhh . 'BOM' . $this->hhh . PHP_EOL
. PHP_EOL . $css
);
$this->newFiles[$module->key][] = $fileDetails;
// count the file created
$this->fileCount++;
// add the field script
$field_script_bucket[] = $this->_t(2) . "//"
. $this->setLine(__LINE__) . " Custom CSS";
$field_script_bucket[] = $this->_t(2)
. "\$document->addStyleSheet('" . $target_path
. "/modules/" . $module->folder_name
. "/css/mod_admin.css', ['version' => 'auto', 'relative' => true]);";
}
}
// add any JavaScript from the fields
if (($javascript = $this->getCustomScriptBuilder(
'view_footer', $module->key
)) !== null
&& ComponentbuilderHelper::checkString($javascript))
{
// make sure this script does not have PHP
if (strpos($javascript, '<?php') === false)
{
// make sure the field is added
$module->add_scripts_field = true;
// add the JavaScript file
$this->createFolder($module->folder_path . '/js');
// add the CSS file
$fileDetails = array('path' => $module->folder_path
. '/js/mod_admin.js',
'name' => 'mod_admin.js',
'zip' => 'mod_admin.js');
$this->writeFile(
$fileDetails['path'],
$this->hhh . 'BOM' . $this->hhh . PHP_EOL
. PHP_EOL . $javascript
);
$this->newFiles[$module->key][] = $fileDetails;
// count the file created
$this->fileCount++;
// add the field script
$field_script_bucket[] = $this->_t(2) . "//"
. $this->setLine(__LINE__) . " Custom JS";
$field_script_bucket[] = $this->_t(2)
. "\$document->addScript('" . $target_path
. "/modules/" . $module->folder_name
. "/js/mod_admin.js', ['version' => 'auto', 'relative' => true]);";
}
}
// set fields folders if needed
if ($module->add_scripts_field
|| (isset($module->fields_rules_paths)
&& $module->fields_rules_paths == 2))
{
// create fields folder
$this->createFolder($module->folder_path . '/fields');
// add the custom script field
if ($module->add_scripts_field)
{
$fileDetails = array('path' => $module->folder_path
. '/fields/modadminvvvvvvvdm.php',
'name' => 'modadminvvvvvvvdm.php',
'zip' => 'modadminvvvvvvvdm.php');
$this->writeFile(
$fileDetails['path'],
$this->getModAdminVvvvvvvdm(
$field_script_bucket
)
);
$this->newFiles[$module->key][] = $fileDetails;
// count the file created
$this->fileCount++;
}
}
// set rules folders if needed
if (isset($module->fields_rules_paths) if (isset($module->fields_rules_paths)
&& $module->fields_rules_paths == 2) && $module->fields_rules_paths == 2)
{ {
// create fields folder
if (!JFolder::exists($module->folder_path . '/fields'))
{
JFolder::create($module->folder_path . '/fields');
// count the folder created
$this->folderCount++;
$this->indexHTML(
$module->folder_name . '/fields',
$this->compilerPath
);
}
// create rules folder // create rules folder
if (!JFolder::exists($module->folder_path . '/rules')) $this->createFolder($module->folder_path . '/rules');
{
JFolder::create($module->folder_path . '/rules');
// count the folder created
$this->folderCount++;
$this->indexHTML(
$module->folder_name . '/rules',
$this->compilerPath
);
}
} }
// set forms folder if needed // set forms folder if needed
if (isset($module->form_files) if (isset($module->form_files)
@ -686,16 +754,7 @@ class Structure extends Get
)) ))
{ {
// create forms folder // create forms folder
if (!JFolder::exists($module->folder_path . '/forms')) $this->createFolder($module->folder_path . '/forms');
{
JFolder::create($module->folder_path . '/forms');
// count the folder created
$this->folderCount++;
$this->indexHTML(
$module->folder_name . '/forms',
$this->compilerPath
);
}
// set the template files // set the template files
foreach ($module->form_files as $file => $fields) foreach ($module->form_files as $file => $fields)
{ {
@ -705,7 +764,7 @@ class Structure extends Get
'name' => $file . '.xml', 'name' => $file . '.xml',
'zip' => 'forms/' . $file 'zip' => 'forms/' . $file
. '.xml'); . '.xml');
// biuld basic XML // build basic XML
$xml = '<?xml version="1.0" encoding="utf-8"?>'; $xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= PHP_EOL . '<!--' . $this->setLine(__LINE__) $xml .= PHP_EOL . '<!--' . $this->setLine(__LINE__)
. ' default paths of ' . $file . ' default paths of ' . $file
@ -848,31 +907,11 @@ class Structure extends Get
if ($module->add_sql || $module->add_sql_uninstall) if ($module->add_sql || $module->add_sql_uninstall)
{ {
// create SQL folder // create SQL folder
if (!JFolder::exists($module->folder_path . '/sql')) $this->createFolder($module->folder_path . '/sql');
{
JFolder::create($module->folder_path . '/sql');
// count the folder created
$this->folderCount++;
$this->indexHTML(
$module->folder_name . '/sql',
$this->compilerPath
);
}
// create mysql folder // create mysql folder
if (!JFolder::exists( $this->createFolder(
$module->folder_path . '/sql/mysql' $module->folder_path . '/sql/mysql'
)) );
{
JFolder::create(
$module->folder_path . '/sql/mysql'
);
// count the folder created
$this->folderCount++;
$this->indexHTML(
$module->folder_name . '/sql/mysql',
$this->compilerPath
);
}
// now set the install file // now set the install file
if ($module->add_sql) if ($module->add_sql)
{ {
@ -896,24 +935,11 @@ class Structure extends Get
} }
} }
// creat the language folder // creat the language folder
if (!JFolder::exists($module->folder_path . '/language')) $this->createFolder($module->folder_path . '/language');
{ // also create the lang tag folder
JFolder::create($module->folder_path . '/language'); $this->createFolder(
// count the folder created $module->folder_path . '/language/' . $this->langTag
$this->folderCount++; );
// also the lang tag
if (!JFolder::exists(
$module->folder_path . '/language/' . $this->langTag
))
{
JFolder::create(
$module->folder_path . '/language/'
. $this->langTag
);
// count the folder created
$this->folderCount++;
}
}
// check if this lib has files // check if this lib has files
if (isset($module->files) if (isset($module->files)
&& ComponentbuilderHelper::checkArray($module->files)) && ComponentbuilderHelper::checkArray($module->files))
@ -974,20 +1000,9 @@ class Structure extends Get
$path = ''; $path = '';
} }
// create sub media path if not set // create sub media path if not set
if (!JFolder::exists( $this->createFolder(
$module->folder_path . $path $module->folder_path . $path
)) );
{
JFolder::create(
$module->folder_path . $path
);
// count the folder created
$this->folderCount++;
$this->indexHTML(
$module->folder_name . $path,
$this->compilerPath
);
}
// set the path to module file // set the path to module file
$url['path'] = $module->folder_path . $path $url['path'] = $module->folder_path . $path
. '/' . $fileName; // we need this for later . '/' . $fileName; // we need this for later
@ -1034,15 +1049,7 @@ class Structure extends Get
// make sure there is no old build // make sure there is no old build
$this->removeFolder($plugin->folder_path); $this->removeFolder($plugin->folder_path);
// creat the main component folder // creat the main component folder
if (!JFolder::exists($plugin->folder_path)) $this->createFolder($plugin->folder_path);
{
JFolder::create($plugin->folder_path);
// count the folder created
$this->folderCount++;
$this->indexHTML(
$plugin->folder_name, $this->compilerPath
);
}
// set main class file // set main class file
$fileDetails = array('path' => $plugin->folder_path . '/' $fileDetails = array('path' => $plugin->folder_path . '/'
. $plugin->file_name . '.php', . $plugin->file_name . '.php',
@ -1111,27 +1118,9 @@ class Structure extends Get
&& $plugin->fields_rules_paths == 2) && $plugin->fields_rules_paths == 2)
{ {
// create fields folder // create fields folder
if (!JFolder::exists($plugin->folder_path . '/fields')) $this->createFolder($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 // create rules folder
if (!JFolder::exists($plugin->folder_path . '/rules')) $this->createFolder($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 // set forms folder if needed
if (isset($plugin->form_files) if (isset($plugin->form_files)
@ -1140,16 +1129,7 @@ class Structure extends Get
)) ))
{ {
// create forms folder // create forms folder
if (!JFolder::exists($plugin->folder_path . '/forms')) $this->createFolder($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 // set the template files
foreach ($plugin->form_files as $file => $fields) foreach ($plugin->form_files as $file => $fields)
{ {
@ -1304,31 +1284,11 @@ class Structure extends Get
if ($plugin->add_sql || $plugin->add_sql_uninstall) if ($plugin->add_sql || $plugin->add_sql_uninstall)
{ {
// create SQL folder // create SQL folder
if (!JFolder::exists($plugin->folder_path . '/sql')) $this->createFolder($plugin->folder_path . '/sql');
{
JFolder::create($plugin->folder_path . '/sql');
// count the folder created
$this->folderCount++;
$this->indexHTML(
$plugin->folder_name . '/sql',
$this->compilerPath
);
}
// create mysql folder // create mysql folder
if (!JFolder::exists( $this->createFolder(
$plugin->folder_path . '/sql/mysql' $plugin->folder_path . '/sql/mysql'
)) );
{
JFolder::create(
$plugin->folder_path . '/sql/mysql'
);
// count the folder created
$this->folderCount++;
$this->indexHTML(
$plugin->folder_name . '/sql/mysql',
$this->compilerPath
);
}
// now set the install file // now set the install file
if ($plugin->add_sql) if ($plugin->add_sql)
{ {
@ -1351,25 +1311,12 @@ class Structure extends Get
$this->fileCount++; $this->fileCount++;
} }
} }
// creat the language folder // creat the language folder path
if (!JFolder::exists($plugin->folder_path . '/language')) $this->createFolder($plugin->folder_path . '/language');
{ // also creat the lang tag folder path
JFolder::create($plugin->folder_path . '/language'); $this->createFolder(
// count the folder created $plugin->folder_path . '/language/' . $this->langTag
$this->folderCount++; );
// also the lang tag
if (!JFolder::exists(
$plugin->folder_path . '/language/' . $this->langTag
))
{
JFolder::create(
$plugin->folder_path . '/language/'
. $this->langTag
);
// count the folder created
$this->folderCount++;
}
}
// check if this lib has files // check if this lib has files
if (isset($plugin->files) if (isset($plugin->files)
&& ComponentbuilderHelper::checkArray($plugin->files)) && ComponentbuilderHelper::checkArray($plugin->files))
@ -1429,21 +1376,10 @@ class Structure extends Get
{ {
$path = ''; $path = '';
} }
// create sub media path if not set // create sub media media folder path if not set
if (!JFolder::exists( $this->createFolder(
$plugin->folder_path . $path $plugin->folder_path . $path
)) );
{
JFolder::create(
$plugin->folder_path . $path
);
// count the folder created
$this->folderCount++;
$this->indexHTML(
$plugin->folder_name . $path,
$this->compilerPath
);
}
// set the path to plugin file // set the path to plugin file
$url['path'] = $plugin->folder_path . $path $url['path'] = $plugin->folder_path . $path
. '/' . $fileName; // we need this for later . '/' . $fileName; // we need this for later
@ -1459,6 +1395,31 @@ class Structure extends Get
} }
} }
/**
* Create Path if not exist
*
* @return void
*/
private function createFolder($path)
{
// check if the path exist
if (!JFolder::exists(
$path
))
{
// create the path
JFolder::create(
$path
);
// count the folder created
$this->folderCount++;
// add index.html (boring I know)
$this->indexHTML(
$path, ''
);
}
}
/** /**
* Build the Libraries files, folders, url's and config * Build the Libraries files, folders, url's and config
* *
@ -1483,13 +1444,7 @@ class Structure extends Get
$this->indexHTML(''); $this->indexHTML('');
} }
// create media path if not set // create media path if not set
if (!JFolder::exists($this->componentPath . '/media')) $this->createFolder($this->componentPath . '/media');
{
JFolder::create($this->componentPath . '/media');
// count the folder created
$this->folderCount++;
$this->indexHTML('/media');
}
foreach ($this->libraries as $id => &$library) foreach ($this->libraries as $id => &$library)
{ {
if (ComponentbuilderHelper::checkObject($library)) if (ComponentbuilderHelper::checkObject($library))
@ -1542,17 +1497,9 @@ class Structure extends Get
)) ))
{ {
// create media/lib path if not set // create media/lib path if not set
if (!JFolder::exists( $this->createFolder(
$this->componentPath . $mediaPath $this->componentPath . $mediaPath
)) );
{
JFolder::create(
$this->componentPath . $mediaPath
);
// count the folder created
$this->folderCount++;
$this->indexHTML($mediaPath);
}
// add local folder // add local folder
$addLocalFolder = true; $addLocalFolder = true;
// set file name // set file name
@ -1575,18 +1522,9 @@ class Structure extends Get
$path = ''; $path = '';
} }
// create sub media path if not set // create sub media path if not set
if (!JFolder::exists( $this->createFolder(
$this->componentPath . $mediaPath . $path $this->componentPath . $mediaPath . $path
)) );
{
JFolder::create(
$this->componentPath . $mediaPath
. $path
);
// count the folder created
$this->folderCount++;
$this->indexHTML($mediaPath . $path);
}
// set the path to library file // set the path to library file
$url['path'] = $mediaPath . $path . '/' $url['path'] = $mediaPath . $path . '/'
. $fileName; // we need this for later . $fileName; // we need this for later
@ -1808,47 +1746,22 @@ class Structure extends Get
// now build all folders needed for this component // now build all folders needed for this component
foreach ($this->joomlaVersionData->create as $main => $folders) foreach ($this->joomlaVersionData->create as $main => $folders)
{ {
if (!JFolder::exists($this->componentPath . '/' . $main)) $this->createFolder($this->componentPath . '/' . $main);
{
JFolder::create($this->componentPath . '/' . $main);
// count the folder created
$this->folderCount++;
$this->indexHTML($main);
}
if (ComponentbuilderHelper::checkObject($folders)) if (ComponentbuilderHelper::checkObject($folders))
{ {
foreach ($folders as $sub => $subFolders) foreach ($folders as $sub => $subFolders)
{ {
if (!JFolder::exists( $this->createFolder(
$this->componentPath . '/' . $main . '/' . $sub $this->componentPath . '/' . $main . '/' . $sub
)) );
{
JFolder::create(
$this->componentPath . '/' . $main . '/' . $sub
);
// count the folder created
$this->folderCount++;
$this->indexHTML($main . '/' . $sub);
}
if (ComponentbuilderHelper::checkObject($subFolders)) if (ComponentbuilderHelper::checkObject($subFolders))
{ {
foreach ($subFolders as $sub_2 => $subFolders_2) foreach ($subFolders as $sub_2 => $subFolders_2)
{ {
if (!JFolder::exists( $this->createFolder(
$this->componentPath . '/' . $main . '/' $this->componentPath . '/' . $main . '/'
. $sub . '/' . $sub_2 . $sub . '/' . $sub_2
)) );
{
JFolder::create(
$this->componentPath . '/' . $main . '/'
. $sub . '/' . $sub_2
);
// count the folder created
$this->folderCount++;
$this->indexHTML(
$main . '/' . $sub . '/' . $sub_2
);
}
if (ComponentbuilderHelper::checkObject( if (ComponentbuilderHelper::checkObject(
$subFolders_2 $subFolders_2
)) ))
@ -1857,25 +1770,11 @@ class Structure extends Get
$subFolders_2 as $sub_3 => $subFolders_3 $subFolders_2 as $sub_3 => $subFolders_3
) )
{ {
$this->createFolder(
if (!JFolder::exists(
$this->componentPath . '/' . $main $this->componentPath . '/' . $main
. '/' . $sub . '/' . $sub_2 . '/' . '/' . $sub . '/' . $sub_2 . '/'
. $sub_3 . $sub_3
)) );
{
JFolder::create(
$this->componentPath . '/'
. $main . '/' . $sub . '/'
. $sub_2 . '/' . $sub_3
);
// count the folder created
$this->folderCount++;
$this->indexHTML(
$main . '/' . $sub . '/'
. $sub_2 . '/' . $sub_3
);
}
if (ComponentbuilderHelper::checkObject( if (ComponentbuilderHelper::checkObject(
$subFolders_3 $subFolders_3
)) ))
@ -1885,28 +1784,12 @@ class Structure extends Get
$subFolders_4 $subFolders_4
) )
{ {
if (!JFolder::exists( $this->createFolder(
$this->componentPath . '/' $this->componentPath . '/'
. $main . '/' . $sub . '/' . $main . '/' . $sub . '/'
. $sub_2 . '/' . $sub_3 . $sub_2 . '/' . $sub_3
. '/' . $sub_4 . '/' . $sub_4
)) );
{
JFolder::create(
$this->componentPath
. '/' . $main . '/'
. $sub . '/' . $sub_2
. '/' . $sub_3 . '/'
. $sub_4
);
// count the folder created
$this->folderCount++;
$this->indexHTML(
$main . '/' . $sub . '/'
. $sub_2 . '/' . $sub_3
. '/' . $sub_4
);
}
if (ComponentbuilderHelper::checkObject( if (ComponentbuilderHelper::checkObject(
$subFolders_4 $subFolders_4
)) ))
@ -1916,7 +1799,7 @@ class Structure extends Get
=> $subFolders_5 => $subFolders_5
) )
{ {
if (!JFolder::exists( $this->createFolder(
$this->componentPath $this->componentPath
. '/' . $main . '/' . '/' . $main . '/'
. $sub . '/' . $sub . '/'
@ -1924,28 +1807,7 @@ class Structure extends Get
. $sub_3 . '/' . $sub_3 . '/'
. $sub_4 . '/' . $sub_4 . '/'
. $sub_5 . $sub_5
)) );
{
JFolder::create(
$this->componentPath
. '/' . $main
. '/' . $sub
. '/' . $sub_2
. '/' . $sub_3
. '/' . $sub_4
. '/' . $sub_5
);
// count the folder created
$this->folderCount++;
$this->indexHTML(
$main . '/'
. $sub . '/'
. $sub_2 . '/'
. $sub_3 . '/'
. $sub_4 . '/'
. $sub_5
);
}
if (ComponentbuilderHelper::checkObject( if (ComponentbuilderHelper::checkObject(
$subFolders_5 $subFolders_5
)) ))
@ -1956,11 +1818,12 @@ class Structure extends Get
$subFolders_6 $subFolders_6
) )
{ {
if (!JFolder::exists( $this->createFolder(
$this->componentPath $this->componentPath
. '/' . '/'
. $main . $main
. '/' . $sub . '/'
. $sub
. '/' . '/'
. $sub_2 . $sub_2
. '/' . '/'
@ -1971,43 +1834,7 @@ class Structure extends Get
. $sub_5 . $sub_5
. '/' . '/'
. $sub_6 . $sub_6
)) );
{
JFolder::create(
$this->componentPath
. '/'
. $main
. '/'
. $sub
. '/'
. $sub_2
. '/'
. $sub_3
. '/'
. $sub_4
. '/'
. $sub_5
. '/'
. $sub_6
);
// count the folder created
$this->folderCount++;
$this->indexHTML(
$main
. '/'
. $sub
. '/'
. $sub_2
. '/'
. $sub_3
. '/'
. $sub_4
. '/'
. $sub_5
. '/'
. $sub_6
);
}
if (ComponentbuilderHelper::checkObject( if (ComponentbuilderHelper::checkObject(
$subFolders_6 $subFolders_6
)) ))
@ -2020,7 +1847,7 @@ class Structure extends Get
$subFolders_7 $subFolders_7
) )
{ {
if (!JFolder::exists( $this->createFolder(
$this->componentPath $this->componentPath
. '/' . '/'
. $main . $main
@ -2038,47 +1865,7 @@ class Structure extends Get
. $sub_6 . $sub_6
. '/' . '/'
. $sub_7 . $sub_7
)) );
{
JFolder::create(
$this->componentPath
. '/'
. $main
. '/'
. $sub
. '/'
. $sub_2
. '/'
. $sub_3
. '/'
. $sub_4
. '/'
. $sub_5
. '/'
. $sub_6
. '/'
. $sub_7
);
// count the folder created
$this->folderCount++;
$this->indexHTML(
$main
. '/'
. $sub
. '/'
. $sub_2
. '/'
. $sub_3
. '/'
. $sub_4
. '/'
. $sub_5
. '/'
. $sub_6
. '/'
. $sub_7
);
}
} }
} }
} }
@ -3251,14 +3038,14 @@ class Structure extends Get
{ {
if ('component' === $root) if ('component' === $root)
{ {
$root = $this->componentPath; $root = $this->componentPath . '/';
} }
// use path if exist // use path if exist
if (strlen($path) > 0) if (strlen($path) > 0)
{ {
JFile::copy( JFile::copy(
$this->templatePath . '/index.html', $this->templatePath . '/index.html',
$root . '/' . $path . '/index.html' $root . $path . '/index.html'
); );
// count the file created // count the file created
$this->fileCount++; $this->fileCount++;

View File

@ -5038,7 +5038,7 @@ class Fields extends Structure
{ {
// this pains me... but to avoid collusion // this pains me... but to avoid collusion
$filter_type_code = ComponentbuilderHelper::safeString( $filter_type_code = ComponentbuilderHelper::safeString(
$nameListCode . 'filter' . $name $nameListCode . 'filter' . $name
); );
$filter_type_code = preg_replace('/_+/', '', $filter_type_code); $filter_type_code = preg_replace('/_+/', '', $filter_type_code);
$filter_function_name = ComponentbuilderHelper::safeString( $filter_function_name = ComponentbuilderHelper::safeString(
@ -5628,7 +5628,8 @@ class Fields extends Structure
$field_filter_sets[] = $this->_t(3) . 'type="category"'; $field_filter_sets[] = $this->_t(3) . 'type="category"';
$field_filter_sets[] = $this->_t(3) . 'name="category_id"'; $field_filter_sets[] = $this->_t(3) . 'name="category_id"';
$field_filter_sets[] = $this->_t(3) $field_filter_sets[] = $this->_t(3)
. 'label="' . $this->categoryBuilder[$nameListCode]['name'] . '"'; . 'label="' . $this->categoryBuilder[$nameListCode]['name']
. '"';
$field_filter_sets[] = $this->_t(3) $field_filter_sets[] = $this->_t(3)
. 'description="JOPTION_FILTER_CATEGORY_DESC"'; . 'description="JOPTION_FILTER_CATEGORY_DESC"';
$field_filter_sets[] = $this->_t(3) . 'multiple="true"'; $field_filter_sets[] = $this->_t(3) . 'multiple="true"';

View File

@ -4777,57 +4777,6 @@ class Interpretation extends Fields
return false; return false;
} }
/**
* get the a script from the custom script builder
*
* @param string $first The first key
* @param string $second The second key
* @param string $prefix The prefix to add in front of the script if found
* @param string $note The switch/note to add to the script
* @param bool $unset The switch to unset the value if found
* @param string $default The switch/string to use as default return if script not found
* @param string $sufix The sufix to add after the script if found
*
* @return mix The string/script if found or the default value if not found
*
*/
public function getCustomScriptBuilder($first, $second, $prefix = '',
$note = null, $unset = null, $default = null, $sufix = ''
) {
// default is to return an empty string
$script = '';
// check if there is any custom script
if (isset($this->customScriptBuilder[$first][$second])
&& ComponentbuilderHelper::checkString(
$this->customScriptBuilder[$first][$second]
))
{
// add not if set
if ($note)
{
$script .= $note;
}
// load the actual script
$script .= $prefix . str_replace(
array_keys($this->placeholders),
array_values($this->placeholders),
$this->customScriptBuilder[$first][$second]
) . $sufix;
// clear some memory
if ($unset)
{
unset($this->customScriptBuilder[$first][$second]);
}
}
// if not found return default
if (!ComponentbuilderHelper::checkString($script) && $default)
{
return $default;
}
return $script;
}
public function setCustomViewListQuery(&$get, $code, $return = true) public function setCustomViewListQuery(&$get, $code, $return = true)
{ {
if (ComponentbuilderHelper::checkObject($get)) if (ComponentbuilderHelper::checkObject($get))
@ -14317,11 +14266,14 @@ class Interpretation extends Fields
$Helper = $this->fileContentStatic[$this->hhh . 'Component' $Helper = $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh] . 'Helper'; . $this->hhh] . 'Helper';
// load the access filter query code // load the access filter query code
$query .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) $query .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(
__LINE__
)
. " Filter by access level."; . " Filter by access level.";
$query .= PHP_EOL . $this->_t(2) $query .= PHP_EOL . $this->_t(2)
. "\$_access = \$this->getState('filter.access');"; . "\$_access = \$this->getState('filter.access');";
$query .= PHP_EOL . $this->_t(2) . "if (\$_access && is_numeric(\$_access))"; $query .= PHP_EOL . $this->_t(2)
. "if (\$_access && is_numeric(\$_access))";
$query .= PHP_EOL . $this->_t(2) . "{"; $query .= PHP_EOL . $this->_t(2) . "{";
$query .= PHP_EOL . $this->_t(3) $query .= PHP_EOL . $this->_t(3)
. "\$query->where('a.access = ' . (int) \$_access);"; . "\$query->where('a.access = ' . (int) \$_access);";
@ -14330,8 +14282,10 @@ class Interpretation extends Fields
. $Helper . "::checkArray(\$_access))"; . $Helper . "::checkArray(\$_access))";
$query .= PHP_EOL . $this->_t(2) . "{"; $query .= PHP_EOL . $this->_t(2) . "{";
$query .= PHP_EOL . $this->_t(3) . "//" $query .= PHP_EOL . $this->_t(3) . "//"
. $this->setLine(__LINE__) . " Secure the array for the query"; . $this->setLine(__LINE__)
$query .= PHP_EOL . $this->_t(3) . "\$_access = ArrayHelper::toInteger(\$_access);"; . " Secure the array for the query";
$query .= PHP_EOL . $this->_t(3)
. "\$_access = ArrayHelper::toInteger(\$_access);";
$query .= PHP_EOL . $this->_t(3) . "//" $query .= PHP_EOL . $this->_t(3) . "//"
. $this->setLine(__LINE__) . " Filter by the Access Array."; . $this->setLine(__LINE__) . " Filter by the Access Array.";
$query .= PHP_EOL . $this->_t(3) $query .= PHP_EOL . $this->_t(3)
@ -14754,7 +14708,8 @@ class Interpretation extends Fields
. "\$pks = \$input->post->get('cid', array(), 'array');"; . "\$pks = \$input->post->get('cid', array(), 'array');";
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__) $method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " Sanitize the input"; . " Sanitize the input";
$method[] = $this->_t(3) . "\$pks = ArrayHelper::toInteger(\$pks);"; $method[] = $this->_t(3)
. "\$pks = ArrayHelper::toInteger(\$pks);";
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__) $method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " convert to string"; . " convert to string";
$method[] = $this->_t(3) . "\$ids = implode('_', \$pks);"; $method[] = $this->_t(3) . "\$ids = implode('_', \$pks);";
@ -15443,11 +15398,14 @@ class Interpretation extends Fields
$Helper = $this->fileContentStatic[$this->hhh . 'Component' $Helper = $this->fileContentStatic[$this->hhh . 'Component'
. $this->hhh] . 'Helper'; . $this->hhh] . 'Helper';
// load the access filter query code // load the access filter query code
$query .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) $query .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(
__LINE__
)
. " Filter by access level."; . " Filter by access level.";
$query .= PHP_EOL . $this->_t(2) $query .= PHP_EOL . $this->_t(2)
. "\$_access = \$this->getState('filter.access');"; . "\$_access = \$this->getState('filter.access');";
$query .= PHP_EOL . $this->_t(2) . "if (\$_access && is_numeric(\$_access))"; $query .= PHP_EOL . $this->_t(2)
. "if (\$_access && is_numeric(\$_access))";
$query .= PHP_EOL . $this->_t(2) . "{"; $query .= PHP_EOL . $this->_t(2) . "{";
$query .= PHP_EOL . $this->_t(3) $query .= PHP_EOL . $this->_t(3)
. "\$query->where('a.access = ' . (int) \$_access);"; . "\$query->where('a.access = ' . (int) \$_access);";
@ -15456,8 +15414,10 @@ class Interpretation extends Fields
. $Helper . "::checkArray(\$_access))"; . $Helper . "::checkArray(\$_access))";
$query .= PHP_EOL . $this->_t(2) . "{"; $query .= PHP_EOL . $this->_t(2) . "{";
$query .= PHP_EOL . $this->_t(3) . "//" $query .= PHP_EOL . $this->_t(3) . "//"
. $this->setLine(__LINE__) . " Secure the array for the query"; . $this->setLine(__LINE__)
$query .= PHP_EOL . $this->_t(3) . "\$_access = ArrayHelper::toInteger(\$_access);"; . " Secure the array for the query";
$query .= PHP_EOL . $this->_t(3)
. "\$_access = ArrayHelper::toInteger(\$_access);";
$query .= PHP_EOL . $this->_t(3) . "//" $query .= PHP_EOL . $this->_t(3) . "//"
. $this->setLine(__LINE__) . " Filter by the Access Array."; . $this->setLine(__LINE__) . " Filter by the Access Array.";
$query .= PHP_EOL . $this->_t(3) $query .= PHP_EOL . $this->_t(3)
@ -20922,9 +20882,9 @@ class Interpretation extends Fields
/** /**
* Add the code of the filter in the populate state * Add the code of the filter in the populate state
* *
* @param array $filter The field/filter array * @param array $filter The field/filter array
* @param bool $newFilter The switch to use the new filter * @param bool $newFilter The switch to use the new filter
* @param string $extra The defaults/extra options of the filter * @param string $extra The defaults/extra options of the filter
* *
* @return string The code for the populate state * @return string The code for the populate state
* *
@ -20978,7 +20938,7 @@ class Interpretation extends Fields
* set the default populate state code * set the default populate state code
* *
* @param string $nameSingleCode The single view name * @param string $nameSingleCode The single view name
* @param bool $newFilter The switch to use the new filter * @param bool $newFilter The switch to use the new filter
* *
* @return string The state code added * @return string The state code added
* *
@ -27433,7 +27393,7 @@ function vdm_dkim() {
$default = PHP_EOL . $module->default_header . PHP_EOL . '?>'; $default = PHP_EOL . $module->default_header . PHP_EOL . '?>';
// add any css from the fields // add any css from the fields
$default .= $this->getCustomScriptBuilder( $default .= $this->getCustomScriptBuilder(
'css_views', $key, PHP_EOL . '<style>' . PHP_EOL, '', true, null, 'css_views', $key, PHP_EOL . '<style>', '', true, null,
PHP_EOL . '</style>' . PHP_EOL PHP_EOL . '</style>' . PHP_EOL
); );
// now add the body // now add the body
@ -27441,7 +27401,7 @@ function vdm_dkim() {
// add any JavaScript from the fields // add any JavaScript from the fields
$default .= $this->getCustomScriptBuilder( $default .= $this->getCustomScriptBuilder(
'views_footer', $key, 'views_footer', $key,
PHP_EOL . '<script type="text/javascript">' . PHP_EOL, '', true, PHP_EOL . '<script type="text/javascript">', '', true,
null, PHP_EOL . '</script>' . PHP_EOL null, PHP_EOL . '</script>' . PHP_EOL
); );
@ -27532,6 +27492,7 @@ function vdm_dkim() {
$module->config_fields $module->config_fields
)) ))
{ {
$add_scripts_field = true;
foreach ($module->config_fields as $field_name => $fieldsets) foreach ($module->config_fields as $field_name => $fieldsets)
{ {
foreach ($fieldsets as $fieldset => $fields) foreach ($fieldsets as $fieldset => $fields)
@ -27540,6 +27501,15 @@ function vdm_dkim() {
$xmlFields = $this->getExtensionFieldsetXML( $xmlFields = $this->getExtensionFieldsetXML(
$module, $fields, $dbkey $module, $fields, $dbkey
); );
// check if the custom script field must be set
if ($add_scripts_field && $module->add_scripts_field)
{
// get the custom script field
$xmlFields .= PHP_EOL . $this->_t(2)
. "<field type=\"modadminvvvvvvvdm\" />";
// don't add it again
$add_scripts_field = false;
}
// make sure the xml is set and a string // make sure the xml is set and a string
if (isset($xmlFields) if (isset($xmlFields)
&& ComponentbuilderHelper::checkString($xmlFields)) && ComponentbuilderHelper::checkString($xmlFields))

View File

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