forked from joomla/Component-Builder
Move the Power, Plugin and Module builders into the container. Many more PHP 8 improvments.
This commit is contained in:
parent
e6c02a29f6
commit
7edbe20c33
@ -140,13 +140,13 @@ TODO
|
||||
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
|
||||
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
+ *First Build*: 30th April, 2015
|
||||
+ *Last Build*: 22nd January, 2023
|
||||
+ *Last Build*: 29th January, 2023
|
||||
+ *Version*: 3.1.13
|
||||
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
|
||||
+ *Line count*: **357633**
|
||||
+ *Line count*: **360674**
|
||||
+ *Field count*: **2009**
|
||||
+ *File count*: **2304**
|
||||
+ *File count*: **2314**
|
||||
+ *Folder count*: **408**
|
||||
|
||||
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com).
|
||||
|
@ -140,13 +140,13 @@ TODO
|
||||
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
|
||||
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||
+ *First Build*: 30th April, 2015
|
||||
+ *Last Build*: 22nd January, 2023
|
||||
+ *Last Build*: 29th January, 2023
|
||||
+ *Version*: 3.1.13
|
||||
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
|
||||
+ *Line count*: **357633**
|
||||
+ *Line count*: **360674**
|
||||
+ *Field count*: **2009**
|
||||
+ *File count*: **2304**
|
||||
+ *File count*: **2314**
|
||||
+ *Folder count*: **408**
|
||||
|
||||
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com).
|
||||
|
@ -191,14 +191,14 @@ const getSelectedItem = async (table, row, field, line) => {
|
||||
formData.append('regex_search', regexObject.checked ? 1 : 0);
|
||||
|
||||
// get search value
|
||||
if (mode == 1) {
|
||||
// calling URL
|
||||
postURL = UrlAjax + 'getSearchValue';
|
||||
} else {
|
||||
if (mode == 2) {
|
||||
// add the line value
|
||||
formData.append('line_nr', line);
|
||||
// calling URL
|
||||
postURL = UrlAjax + 'getReplaceValue';
|
||||
} else {
|
||||
// calling URL
|
||||
postURL = UrlAjax + 'getSearchValue';
|
||||
}
|
||||
|
||||
let options = {
|
||||
@ -613,6 +613,12 @@ const buttonUpdateAllStyleDisplay = async (value) => {
|
||||
* JS Function to execute (A) on search/replace text change , (B) on search options changes
|
||||
*/
|
||||
const startSearch = (field, forced = false) => {
|
||||
// check mode
|
||||
let mode = modeObject.querySelector('input[type=\'radio\']:checked').value;
|
||||
if (mode == 0) {
|
||||
// reset the search area
|
||||
window.location.href = UrlSearch;
|
||||
}
|
||||
// check if we have an Enter click
|
||||
if (field && typeof field.code !== 'undefined' && field.code === "Enter") {
|
||||
forced = true;
|
||||
|
@ -80,7 +80,7 @@ class Compiler extends Infusion
|
||||
{
|
||||
// to check the compiler speed
|
||||
$this->time_start = microtime(true);
|
||||
CFactory::_('Counter')->start();
|
||||
CFactory::_('Utilities.Counter')->start();
|
||||
// first we run the parent constructors
|
||||
if (parent::__construct())
|
||||
{
|
||||
@ -104,9 +104,9 @@ class Compiler extends Infusion
|
||||
if (CFactory::_('Config')->remove_site_folder && CFactory::_('Config')->remove_site_edit_folder)
|
||||
{
|
||||
// first remove the files and folders
|
||||
$this->removeFolder($this->componentPath . '/site');
|
||||
CFactory::_('Utilities.Folder')->remove(CFactory::_('Utilities.Paths')->component_path . '/site');
|
||||
// clear form component xml
|
||||
$xmlPath = $this->componentPath . '/'
|
||||
$xmlPath = CFactory::_('Utilities.Paths')->component_path . '/'
|
||||
. CFactory::_('Content')->get('component') . '.xml';
|
||||
$componentXML = FileHelper::getContent($xmlPath);
|
||||
$textToSite = GetHelper::between(
|
||||
@ -120,7 +120,7 @@ class Compiler extends Infusion
|
||||
'<languages folder="site">' . $textToSiteLang
|
||||
. "</languages>"), array('', ''), (string) $componentXML
|
||||
);
|
||||
$this->writeFile($xmlPath, $componentXML);
|
||||
CFactory::_('Utilities.File')->write($xmlPath, $componentXML);
|
||||
}
|
||||
// for plugin event TODO change event api signatures
|
||||
$component_context = CFactory::_('Config')->component_context;
|
||||
@ -363,7 +363,7 @@ class Compiler extends Infusion
|
||||
// end the timer here
|
||||
$this->time_end = microtime(true);
|
||||
$this->secondsCompiled = $this->time_end - $this->time_start;
|
||||
CFactory::_('Counter')->end();
|
||||
CFactory::_('Utilities.Counter')->end();
|
||||
|
||||
// completed the compilation
|
||||
return true;
|
||||
@ -380,15 +380,13 @@ class Compiler extends Infusion
|
||||
*/
|
||||
protected function updateFiles()
|
||||
{
|
||||
if (isset($this->newFiles['static'])
|
||||
&& ArrayHelper::check($this->newFiles['static'])
|
||||
&& isset($this->newFiles['dynamic'])
|
||||
&& ArrayHelper::check($this->newFiles['dynamic']))
|
||||
if (CFactory::_('Utilities.Files')->exists('static')
|
||||
&& CFactory::_('Utilities.Files')->exists('dynamic'))
|
||||
{
|
||||
// get the bom file
|
||||
$bom = FileHelper::getContent(CFactory::_('Config')->bom_path);
|
||||
// first we do the static files
|
||||
foreach ($this->newFiles['static'] as $static)
|
||||
foreach (CFactory::_('Utilities.Files')->get('static') as $static)
|
||||
{
|
||||
if (File::exists($static['path']))
|
||||
{
|
||||
@ -398,7 +396,7 @@ class Compiler extends Infusion
|
||||
}
|
||||
}
|
||||
// now we do the dynamic files
|
||||
foreach ($this->newFiles['dynamic'] as $view => $files)
|
||||
foreach (CFactory::_('Utilities.Files')->get('dynamic') as $view => $files)
|
||||
{
|
||||
if (CFactory::_('Content')->exist_($view)
|
||||
&& ArrayHelper::check(
|
||||
@ -423,17 +421,14 @@ class Compiler extends Infusion
|
||||
CFactory::_('Content')->remove_($view);
|
||||
}
|
||||
// free up some memory
|
||||
unset($this->newFiles['dynamic']);
|
||||
CFactory::_('Utilities.Files')->remove('dynamic');
|
||||
// do modules if found
|
||||
if (CFactory::_('Joomlamodule.Data')->exists())
|
||||
{
|
||||
foreach (CFactory::_('Joomlamodule.Data')->get() as $module)
|
||||
{
|
||||
if (ObjectHelper::check($module)
|
||||
&& isset($this->newFiles[$module->key])
|
||||
&& ArrayHelper::check(
|
||||
$this->newFiles[$module->key]
|
||||
))
|
||||
&& CFactory::_('Utilities.Files')->exists($module->key))
|
||||
{
|
||||
// move field or rule if needed
|
||||
if (isset($module->fields_rules_paths)
|
||||
@ -489,7 +484,7 @@ class Compiler extends Infusion
|
||||
}
|
||||
}
|
||||
// update the module files
|
||||
foreach ($this->newFiles[$module->key] as $module_file)
|
||||
foreach (CFactory::_('Utilities.Files')->get($module->key) as $module_file)
|
||||
{
|
||||
if (File::exists($module_file['path']))
|
||||
{
|
||||
@ -500,7 +495,7 @@ class Compiler extends Infusion
|
||||
}
|
||||
}
|
||||
// free up some memory
|
||||
unset($this->newFiles[$module->key]);
|
||||
CFactory::_('Utilities.Files')->remove($module->key);
|
||||
CFactory::_('Content')->remove_($module->key);
|
||||
}
|
||||
}
|
||||
@ -511,10 +506,7 @@ class Compiler extends Infusion
|
||||
foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin)
|
||||
{
|
||||
if (ObjectHelper::check($plugin)
|
||||
&& isset($this->newFiles[$plugin->key])
|
||||
&& ArrayHelper::check(
|
||||
$this->newFiles[$plugin->key]
|
||||
))
|
||||
&& CFactory::_('Utilities.Files')->exists($plugin->key))
|
||||
{
|
||||
// move field or rule if needed
|
||||
if (isset($plugin->fields_rules_paths)
|
||||
@ -570,7 +562,7 @@ class Compiler extends Infusion
|
||||
}
|
||||
}
|
||||
// update the plugin files
|
||||
foreach ($this->newFiles[$plugin->key] as $plugin_file)
|
||||
foreach (CFactory::_('Utilities.Files')->get($plugin->key) as $plugin_file)
|
||||
{
|
||||
if (File::exists($plugin_file['path']))
|
||||
{
|
||||
@ -581,7 +573,7 @@ class Compiler extends Infusion
|
||||
}
|
||||
}
|
||||
// free up some memory
|
||||
unset($this->newFiles[$plugin->key]);
|
||||
CFactory::_('Utilities.Files')->remove($plugin->key);
|
||||
CFactory::_('Content')->remove_($plugin->key);
|
||||
}
|
||||
}
|
||||
@ -592,13 +584,10 @@ class Compiler extends Infusion
|
||||
foreach (CFactory::_('Power')->active as $power)
|
||||
{
|
||||
if (ObjectHelper::check($power)
|
||||
&& isset($this->newFiles[$power->key])
|
||||
&& ArrayHelper::check(
|
||||
$this->newFiles[$power->key]
|
||||
))
|
||||
&& CFactory::_('Utilities.Files')->exists($power->key))
|
||||
{
|
||||
// update the power files
|
||||
foreach ($this->newFiles[$power->key] as $power_file)
|
||||
foreach (CFactory::_('Utilities.Files')->get($power->key) as $power_file)
|
||||
{
|
||||
if (File::exists($power_file['path']))
|
||||
{
|
||||
@ -609,7 +598,7 @@ class Compiler extends Infusion
|
||||
}
|
||||
}
|
||||
// free up some memory
|
||||
unset($this->newFiles[$power->key]);
|
||||
CFactory::_('Utilities.Files')->remove($power->key);
|
||||
CFactory::_('Content')->remove_($power->key);
|
||||
}
|
||||
}
|
||||
@ -681,9 +670,9 @@ class Compiler extends Infusion
|
||||
&$view)
|
||||
);
|
||||
// add answer back to file
|
||||
$this->writeFile($path, $answer);
|
||||
CFactory::_('Utilities.File')->write($path, $answer);
|
||||
// count the file lines
|
||||
CFactory::_('Counter')->line += substr_count((string) $answer, PHP_EOL);
|
||||
CFactory::_('Utilities.Counter')->line += substr_count((string) $answer, PHP_EOL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -699,7 +688,7 @@ class Compiler extends Infusion
|
||||
&& isset($this->updateServerFileName)
|
||||
&& $this->dynamicIntegration)
|
||||
{
|
||||
$update_server_xml_path = $this->componentPath . '/'
|
||||
$update_server_xml_path = CFactory::_('Utilities.Paths')->component_path . '/'
|
||||
. $this->updateServerFileName . '.xml';
|
||||
// make sure we have the correct file
|
||||
if (File::exists($update_server_xml_path)
|
||||
@ -843,7 +832,7 @@ class Compiler extends Infusion
|
||||
{
|
||||
// do a final run to update the readme file
|
||||
$two = 0;
|
||||
foreach ($this->newFiles['static'] as $static)
|
||||
foreach (CFactory::_('Utilities.Files')->get('static') as $static)
|
||||
{
|
||||
if (('README.md' === $static['name']
|
||||
|| 'README.txt' === $static['name'])
|
||||
@ -858,23 +847,23 @@ class Compiler extends Infusion
|
||||
break;
|
||||
}
|
||||
}
|
||||
unset($this->newFiles['static']);
|
||||
CFactory::_('Utilities.Files')->remove('static');
|
||||
}
|
||||
|
||||
private function setReadMe($path)
|
||||
{
|
||||
// set readme data if not set already
|
||||
if (!CFactory::_('Content')->exist('LINE_COUNT')
|
||||
|| CFactory::_('Content')->get('LINE_COUNT') != CFactory::_('Counter')->line)
|
||||
|| CFactory::_('Content')->get('LINE_COUNT') != CFactory::_('Utilities.Counter')->line)
|
||||
{
|
||||
CFactory::_('Counter')->set();
|
||||
CFactory::_('Utilities.Counter')->set();
|
||||
}
|
||||
// get the file
|
||||
$string = FileHelper::getContent($path);
|
||||
// update the file
|
||||
$answer = CFactory::_('Placeholder')->update($string, CFactory::_('Content')->active);
|
||||
// add to zip array
|
||||
$this->writeFile($path, $answer);
|
||||
CFactory::_('Utilities.File')->write($path, $answer);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -910,20 +899,21 @@ class Compiler extends Infusion
|
||||
. CFactory::_('Config')->get('version', 3);
|
||||
// for plugin event TODO change event api signatures
|
||||
$component_context = CFactory::_('Config')->component_context;
|
||||
$component_path = CFactory::_('Utilities.Paths')->component_path;
|
||||
// Trigger Event: jcb_ce_onBeforeUpdateRepo
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeUpdateRepo',
|
||||
array(&$component_context, &$this->componentPath,
|
||||
array(&$component_context, &$component_path,
|
||||
&$repoFullPath, &$this->componentData)
|
||||
);
|
||||
// remove old data
|
||||
$this->removeFolder($repoFullPath, CFactory::_('Component')->get('toignore'));
|
||||
CFactory::_('Utilities.Folder')->remove($repoFullPath, CFactory::_('Component')->get('toignore'));
|
||||
// set the new data
|
||||
Folder::copy($this->componentPath, $repoFullPath, '', true);
|
||||
Folder::copy(CFactory::_('Utilities.Paths')->component_path, $repoFullPath, '', true);
|
||||
// Trigger Event: jcb_ce_onAfterUpdateRepo
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onAfterUpdateRepo',
|
||||
array(&$component_context, &$this->componentPath,
|
||||
array(&$component_context, &$component_path,
|
||||
&$repoFullPath, &$this->componentData)
|
||||
);
|
||||
|
||||
@ -948,7 +938,7 @@ class Compiler extends Infusion
|
||||
&$repoFullPath, &$module)
|
||||
);
|
||||
// remove old data
|
||||
$this->removeFolder(
|
||||
CFactory::_('Utilities.Folder')->remove(
|
||||
$repoFullPath, CFactory::_('Component')->get('toignore')
|
||||
);
|
||||
// set the new data
|
||||
@ -985,7 +975,7 @@ class Compiler extends Infusion
|
||||
&$repoFullPath, &$plugin)
|
||||
);
|
||||
// remove old data
|
||||
$this->removeFolder(
|
||||
CFactory::_('Utilities.Folder')->remove(
|
||||
$repoFullPath, CFactory::_('Component')->get('toignore')
|
||||
);
|
||||
// set the new data
|
||||
@ -1007,22 +997,25 @@ class Compiler extends Infusion
|
||||
private function zipComponent()
|
||||
{
|
||||
// Component Folder Name
|
||||
$this->filepath['component-folder'] = $this->componentFolderName;
|
||||
$this->filepath['component-folder'] = CFactory::_('Utilities.Paths')->component_folder_name;
|
||||
// the name of the zip file to create
|
||||
$this->filepath['component'] = $this->tempPath . '/'
|
||||
. $this->filepath['component-folder'] . '.zip';
|
||||
// for plugin event TODO change event api signatures
|
||||
$component_context = CFactory::_('Config')->component_context;
|
||||
$component_path = CFactory::_('Utilities.Paths')->component_path;
|
||||
$component_sales_name = CFactory::_('Utilities.Paths')->component_sales_name;
|
||||
$component_folder_name = CFactory::_('Utilities.Paths')->component_folder_name;
|
||||
// Trigger Event: jcb_ce_onBeforeZipComponent
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeZipComponent',
|
||||
array(&$component_context, &$this->componentPath,
|
||||
array(&$component_context, &$component_path,
|
||||
&$this->filepath['component'], &$this->tempPath,
|
||||
&$this->componentFolderName, &$this->componentData)
|
||||
&$component_folder_name, &$this->componentData)
|
||||
);
|
||||
//create the zip file
|
||||
if (FileHelper::zip(
|
||||
$this->componentPath, $this->filepath['component']
|
||||
CFactory::_('Utilities.Paths')->component_path, $this->filepath['component']
|
||||
))
|
||||
{
|
||||
// now move to backup if zip was made and backup is required
|
||||
@ -1039,7 +1032,7 @@ class Compiler extends Infusion
|
||||
// copy the zip to backup path
|
||||
File::copy(
|
||||
$this->filepath['component'],
|
||||
$this->backupPath . '/' . $this->componentBackupName
|
||||
$this->backupPath . '/' . CFactory::_('Utilities.Paths')->component_backup_name
|
||||
. '.zip'
|
||||
);
|
||||
}
|
||||
@ -1055,12 +1048,12 @@ class Compiler extends Infusion
|
||||
'jcb_ce_onBeforeMoveToServer',
|
||||
array(&$component_context,
|
||||
&$this->filepath['component'], &$this->tempPath,
|
||||
&$this->componentSalesName, &$this->componentData)
|
||||
&$component_sales_name, &$this->componentData)
|
||||
);
|
||||
// move to server
|
||||
ComponentbuilderHelper::moveToServer(
|
||||
$this->filepath['component'],
|
||||
$this->componentSalesName . '.zip',
|
||||
$component_sales_name . '.zip',
|
||||
(int) CFactory::_('Component')->get('sales_server'),
|
||||
CFactory::_('Component')->get('sales_server_protocol')
|
||||
);
|
||||
@ -1070,11 +1063,11 @@ class Compiler extends Infusion
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onAfterZipComponent',
|
||||
array(&$component_context, &$this->filepath['component'],
|
||||
&$this->tempPath, &$this->componentFolderName,
|
||||
&$this->tempPath, &$component_folder_name,
|
||||
&$this->componentData)
|
||||
);
|
||||
// remove the component folder since we are done
|
||||
if ($this->removeFolder($this->componentPath))
|
||||
if (CFactory::_('Utilities.Folder')->remove(CFactory::_('Utilities.Paths')->component_path))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -1170,7 +1163,7 @@ class Compiler extends Infusion
|
||||
&$module)
|
||||
);
|
||||
// remove the module folder since we are done
|
||||
$this->removeFolder($module->folder_path);
|
||||
CFactory::_('Utilities.Folder')->remove($module->folder_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1264,7 +1257,7 @@ class Compiler extends Infusion
|
||||
&$plugin)
|
||||
);
|
||||
// remove the plugin folder since we are done
|
||||
$this->removeFolder($plugin->folder_path);
|
||||
CFactory::_('Utilities.Folder')->remove($plugin->folder_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1288,7 +1281,7 @@ class Compiler extends Infusion
|
||||
$target['hashtarget'][1]
|
||||
))
|
||||
{
|
||||
$file = $this->componentPath . '/' . $target['path'];
|
||||
$file = CFactory::_('Utilities.Paths')->component_path . '/' . $target['path'];
|
||||
$size = (int) $target['hashtarget'][0];
|
||||
$hash = $target['hashtarget'][1];
|
||||
$cut = $size - 1;
|
||||
|
@ -2681,70 +2681,38 @@ class Get
|
||||
* get the module xml template
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public function getModuleXMLTemplate(&$module)
|
||||
{
|
||||
$xml = '<?xml version="1.0" encoding="utf-8"?>';
|
||||
$xml .= PHP_EOL . '<extension type="module" version="'
|
||||
. $this->joomlaVersions[CFactory::_('Config')->joomla_version]['xml_version'] . '" client="'
|
||||
. $module->target_client . '" method="upgrade">';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<name>' . $module->lang_prefix
|
||||
. '</name>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<creationDate>' . Placefix::_h('BUILDDATE') . '</creationDate>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<author>' . Placefix::_h('AUTHOR') . '</author>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<authorEmail>' . Placefix::_h('AUTHOREMAIL') . '</authorEmail>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<authorUrl>' . Placefix::_h('AUTHORWEBSITE') . '</authorUrl>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<copyright>' . Placefix::_h('COPYRIGHT') . '</copyright>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<license>' . Placefix::_h('LICENSE') . '</license>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<version>' . $module->module_version
|
||||
. '</version>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<description>' . $module->lang_prefix
|
||||
. '_XML_DESCRIPTION</description>';
|
||||
$xml .= Placefix::_h('MAINXML');
|
||||
$xml .= PHP_EOL . '</extension>';
|
||||
|
||||
return $xml;
|
||||
// set notice that we could not get a valid string from the target
|
||||
$this->app->enqueueMessage(
|
||||
JText::sprintf('<hr /><h3>%s Warning</h3>', __CLASS__), 'Error'
|
||||
);
|
||||
$this->app->enqueueMessage(
|
||||
JText::sprintf(
|
||||
'Use of a deprecated method (%s)!', __METHOD__
|
||||
), 'Error'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* get the module admin custom script field
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
public function getModAdminVvvvvvvdm($fieldScriptBucket)
|
||||
{
|
||||
$form_field_class = array();
|
||||
$form_field_class[] = Placefix::_h('BOM') . PHP_EOL;
|
||||
$form_field_class[] = "//" . Line::_(__Line__, __Class__)
|
||||
. " 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[] = Indent::_(1)
|
||||
. "protected \$type = 'modadminvvvvvvvdm';";
|
||||
$form_field_class[] = PHP_EOL . Indent::_(1)
|
||||
. "protected function getLabel()";
|
||||
$form_field_class[] = Indent::_(1) . "{";
|
||||
$form_field_class[] = Indent::_(2) . "return;";
|
||||
$form_field_class[] = Indent::_(1) . "}";
|
||||
$form_field_class[] = PHP_EOL . Indent::_(1)
|
||||
. "protected function getInput()";
|
||||
$form_field_class[] = Indent::_(1) . "{";
|
||||
$form_field_class[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Get the document";
|
||||
$form_field_class[] = Indent::_(2)
|
||||
. "\$document = Factory::getDocument();";
|
||||
$form_field_class[] = implode(PHP_EOL, $fieldScriptBucket);
|
||||
$form_field_class[] = Indent::_(2) . "return; // noting for now :)";
|
||||
$form_field_class[] = Indent::_(1) . "}";
|
||||
$form_field_class[] = "}";
|
||||
|
||||
return implode(PHP_EOL, $form_field_class);
|
||||
// set notice that we could not get a valid string from the target
|
||||
$this->app->enqueueMessage(
|
||||
JText::sprintf('<hr /><h3>%s Warning</h3>', __CLASS__), 'Error'
|
||||
);
|
||||
$this->app->enqueueMessage(
|
||||
JText::sprintf(
|
||||
'Use of a deprecated method (%s)!', __METHOD__
|
||||
), 'Error'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2810,7 +2778,7 @@ class Get
|
||||
{
|
||||
$xml = '<?xml version="1.0" encoding="utf-8"?>';
|
||||
$xml .= PHP_EOL . '<extension type="plugin" version="'
|
||||
. $this->joomlaVersions[CFactory::_('Config')->joomla_version]['xml_version'] . '" group="'
|
||||
. CFactory::_('Config')->joomla_versions[CFactory::_('Config')->joomla_version]['xml_version'] . '" group="'
|
||||
. strtolower((string) $plugin->group) . '" method="upgrade">';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<name>' . $plugin->lang_prefix
|
||||
. '</name>';
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -658,7 +658,7 @@ class Fields extends Structure
|
||||
$fieldSet[] = Indent::_(3) . 'readonly="true"';
|
||||
$fieldSet[] = Indent::_(2) . "/>";
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// if created is not set
|
||||
if (!isset($this->fieldsNames[$nameSingleCode]['created']))
|
||||
@ -681,7 +681,7 @@ class Fields extends Structure
|
||||
$fieldSet[] = Indent::_(3) . "filter=" . '"user_utc"';
|
||||
$fieldSet[] = Indent::_(2) . "/>";
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// if created_by is not set
|
||||
if (!isset($this->fieldsNames[$nameSingleCode]['created_by']))
|
||||
@ -701,7 +701,7 @@ class Fields extends Structure
|
||||
. '_CREATED_BY_DESC"';
|
||||
$fieldSet[] = Indent::_(2) . "/>";
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// if published is not set
|
||||
if (!isset($this->fieldsNames[$nameSingleCode]['published']))
|
||||
@ -728,7 +728,7 @@ class Fields extends Structure
|
||||
$fieldSet[] = Indent::_(4) . "JTRASHED</option>";
|
||||
$fieldSet[] = Indent::_(2) . "</field>";
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// if modified is not set
|
||||
if (!isset($this->fieldsNames[$nameSingleCode]['modified']))
|
||||
@ -743,7 +743,7 @@ class Fields extends Structure
|
||||
$fieldSet[] = Indent::_(3)
|
||||
. 'size="22" readonly="true" format="%Y-%m-%d %H:%M:%S" filter="user_utc" />';
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// if modified_by is not set
|
||||
if (!isset($this->fieldsNames[$nameSingleCode]['modified_by']))
|
||||
@ -761,7 +761,7 @@ class Fields extends Structure
|
||||
$fieldSet[] = Indent::_(3) . 'filter="unset"';
|
||||
$fieldSet[] = Indent::_(2) . "/>";
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// check if view has access
|
||||
if (isset($this->accessBuilder[$nameSingleCode])
|
||||
@ -784,7 +784,7 @@ class Fields extends Structure
|
||||
$fieldSet[] = Indent::_(3) . 'required="false"';
|
||||
$fieldSet[] = Indent::_(2) . "/>";
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// if ordering is not set
|
||||
if (!isset($this->fieldsNames[$nameSingleCode]['ordering']))
|
||||
@ -807,7 +807,7 @@ class Fields extends Structure
|
||||
$fieldSet[] = Indent::_(3) . 'required="false"';
|
||||
$fieldSet[] = Indent::_(2) . "/>";
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// if version is not set
|
||||
if (!isset($this->fieldsNames[$nameSingleCode]['version']))
|
||||
@ -827,7 +827,7 @@ class Fields extends Structure
|
||||
$fieldSet[] = Indent::_(3) . 'filter="unset"';
|
||||
$fieldSet[] = Indent::_(2) . "/>";
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// check if metadata is added to this view
|
||||
if (isset($this->metadataBuilder[$nameSingleCode])
|
||||
@ -851,7 +851,7 @@ class Fields extends Structure
|
||||
$fieldSet[] = Indent::_(3) . 'cols="30"';
|
||||
$fieldSet[] = Indent::_(2) . "/>";
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// metadesc
|
||||
if (!isset($this->fieldsNames[$nameSingleCode]['metadesc']))
|
||||
@ -869,7 +869,7 @@ class Fields extends Structure
|
||||
$fieldSet[] = Indent::_(3) . 'cols="30"';
|
||||
$fieldSet[] = Indent::_(2) . "/>";
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
}
|
||||
// fix the permissions field "title" issue gh-629
|
||||
@ -896,7 +896,7 @@ class Fields extends Structure
|
||||
. $nameSingleCode . '"';
|
||||
$fieldSet[] = Indent::_(2) . "/>";
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
// setup needed field values for layout
|
||||
$field_array = array();
|
||||
$field_array['order_edit'] = 0;
|
||||
@ -957,7 +957,7 @@ class Fields extends Structure
|
||||
. '<option value="noindex, nofollow">JGLOBAL_NOINDEX_NOFOLLOW</option>';
|
||||
$fieldSet[] = Indent::_(3) . '</field>';
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// author
|
||||
if (!isset($this->fieldsNames[$nameSingleCode]['author']))
|
||||
@ -972,7 +972,7 @@ class Fields extends Structure
|
||||
$fieldSet[] = Indent::_(4) . 'size="20"';
|
||||
$fieldSet[] = Indent::_(3) . "/>";
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// rights
|
||||
if (!isset($this->fieldsNames[$nameSingleCode]['rights']))
|
||||
@ -987,7 +987,7 @@ class Fields extends Structure
|
||||
$fieldSet[] = Indent::_(4) . 'cols="30" rows="2"';
|
||||
$fieldSet[] = Indent::_(3) . "/>";
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
$fieldSet[] = Indent::_(2) . "</fieldset>";
|
||||
$fieldSet[] = Indent::_(1) . "</fields>";
|
||||
@ -1084,7 +1084,7 @@ class Fields extends Structure
|
||||
$fieldXML = $fieldSetXML->addChild('field');
|
||||
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// if created is not set
|
||||
if (!isset($this->fieldsNames[$nameSingleCode]['created']))
|
||||
@ -1106,7 +1106,7 @@ class Fields extends Structure
|
||||
$fieldXML = $fieldSetXML->addChild('field');
|
||||
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// if created_by is not set
|
||||
if (!isset($this->fieldsNames[$nameSingleCode]['created_by']))
|
||||
@ -1125,7 +1125,7 @@ class Fields extends Structure
|
||||
$fieldXML = $fieldSetXML->addChild('field');
|
||||
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// if published is not set
|
||||
if (!isset($this->fieldsNames[$nameSingleCode]['published']))
|
||||
@ -1143,7 +1143,7 @@ class Fields extends Structure
|
||||
$fieldXML = $fieldSetXML->addChild('field');
|
||||
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
foreach (
|
||||
array('JPUBLISHED' => 1, 'JUNPUBLISHED' => 0, 'JARCHIVED' => 2,
|
||||
'JTRASHED' => -2) as $text => $value
|
||||
@ -1175,7 +1175,7 @@ class Fields extends Structure
|
||||
$fieldXML = $fieldSetXML->addChild('field');
|
||||
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// if modified_by is not set
|
||||
if (!isset($this->fieldsNames[$nameSingleCode]['modified_by']))
|
||||
@ -1196,7 +1196,7 @@ class Fields extends Structure
|
||||
$fieldXML = $fieldSetXML->addChild('field');
|
||||
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// check if view has access
|
||||
if (isset($this->accessBuilder[$nameSingleCode])
|
||||
@ -1221,7 +1221,7 @@ class Fields extends Structure
|
||||
$fieldXML = $fieldSetXML->addChild('field');
|
||||
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// if ordering is not set
|
||||
if (!isset($this->fieldsNames[$nameSingleCode]['ordering']))
|
||||
@ -1244,7 +1244,7 @@ class Fields extends Structure
|
||||
$fieldXML = $fieldSetXML->addChild('field');
|
||||
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// if version is not set
|
||||
if (!isset($this->fieldsNames[$nameSingleCode]['version']))
|
||||
@ -1266,7 +1266,7 @@ class Fields extends Structure
|
||||
$fieldXML = $fieldSetXML->addChild('field');
|
||||
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// check if metadata is added to this view
|
||||
if (isset($this->metadataBuilder[$nameSingleCode])
|
||||
@ -1294,7 +1294,7 @@ class Fields extends Structure
|
||||
$fieldXML, $attributes
|
||||
);
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// metadesc
|
||||
if (!isset($this->fieldsNames[$nameSingleCode]['metadesc']))
|
||||
@ -1311,7 +1311,7 @@ class Fields extends Structure
|
||||
$fieldXML, $attributes
|
||||
);
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
}
|
||||
// fix the permissions field "title" issue gh-629
|
||||
@ -1346,7 +1346,7 @@ class Fields extends Structure
|
||||
$fieldXML = $fieldSetXML->addChild('field');
|
||||
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
// setup needed field values for layout
|
||||
$field_array = array();
|
||||
$field_array['order_edit'] = 0;
|
||||
@ -1409,7 +1409,7 @@ class Fields extends Structure
|
||||
$robots, $attributes
|
||||
);
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
$options = array(
|
||||
'JGLOBAL_USE_GLOBAL' => '',
|
||||
'JGLOBAL_INDEX_FOLLOW' => 'index, follow',
|
||||
@ -1443,7 +1443,7 @@ class Fields extends Structure
|
||||
$author, $attributes
|
||||
);
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
// rights
|
||||
if (!isset($this->fieldsNames[$nameSingleCode]['rights']))
|
||||
@ -1467,7 +1467,7 @@ class Fields extends Structure
|
||||
$rights, $attributes
|
||||
);
|
||||
// count the static field created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1891,7 +1891,7 @@ class Fields extends Structure
|
||||
&$optionArray, $custom = null, $taber = ''
|
||||
) {
|
||||
// count the dynamic fields created
|
||||
CFactory::_('Counter')->field++;
|
||||
CFactory::_('Utilities.Counter')->field++;
|
||||
// check what type of field builder to use
|
||||
if (CFactory::_('Config')->get('field_builder_type', 2) == 1)
|
||||
{
|
||||
|
@ -1234,9 +1234,10 @@ class Interpretation extends Fields
|
||||
}
|
||||
// stop it from being added double
|
||||
$addDynamicSQL = false;
|
||||
CFactory::_('Component')->appendArray('version_update', $update_);
|
||||
// add dynamic SQL
|
||||
$this->setUpdateXMLSQL($update_, $updateXML, $addDynamicSQL);
|
||||
|
||||
CFactory::_('Component')->appendArray('version_update', $update_);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1249,7 +1250,7 @@ class Interpretation extends Fields
|
||||
public function setUpdateXMLSQL(&$update, &$updateXML, &$addDynamicSQL)
|
||||
{
|
||||
// ensure version naming is correct
|
||||
$update['version'] = preg_replace('/[^0-9.]+/', '', (string) $update['version']);
|
||||
$update['version'] = preg_replace('/[^0-9\.]+/', '', (string) $update['version']);
|
||||
// setup SQL
|
||||
if (StringHelper::check($update['mysql']))
|
||||
{
|
||||
@ -1284,7 +1285,8 @@ class Interpretation extends Fields
|
||||
$name = StringHelper::safe($update['version']);
|
||||
$target = array('admin' => $name);
|
||||
$this->buildDynamique($target, 'sql_update', $update['version']);
|
||||
CFactory::_('Content')->set_($name . '_' . $update['version'], 'UPDATE_VERSION_MYSQL',
|
||||
$_name = preg_replace('/[\.]+/', '_', (string) $update['version']);
|
||||
CFactory::_('Content')->set_($name . '_' . $_name, 'UPDATE_VERSION_MYSQL',
|
||||
$update['mysql']
|
||||
);
|
||||
}
|
||||
@ -6294,7 +6296,7 @@ class Interpretation extends Fields
|
||||
if (isset($folder['rename']) && 1 == $folder['rename'])
|
||||
{
|
||||
if ($_paths = FileHelper::getPaths(
|
||||
$this->componentPath . $path
|
||||
CFactory::_('Utilities.Paths')->component_path . $path
|
||||
))
|
||||
{
|
||||
$files[$path] = $_paths;
|
||||
@ -6304,7 +6306,7 @@ class Interpretation extends Fields
|
||||
{
|
||||
$path = $path . '/' . trim((string)$folder['folder'], '/');
|
||||
if ($_paths = FileHelper::getPaths(
|
||||
$this->componentPath . $path
|
||||
CFactory::_('Utilities.Paths')->component_path . $path
|
||||
))
|
||||
{
|
||||
$files[$path] = $_paths;
|
||||
@ -7087,7 +7089,7 @@ class Interpretation extends Fields
|
||||
|
||||
public function getReplacementNames()
|
||||
{
|
||||
foreach ($this->newFiles as $type => $files)
|
||||
foreach (CFactory::_('Utilities.Files')->toArray() as $type => $files)
|
||||
{
|
||||
foreach ($files as $view => $file)
|
||||
{
|
||||
@ -8512,7 +8514,7 @@ class Interpretation extends Fields
|
||||
|
||||
public function setMoveFolderScript()
|
||||
{
|
||||
if ($this->setMoveFolders)
|
||||
if (CFactory::_('Registry')->get('set_move_folders_install_script'))
|
||||
{
|
||||
// reset script
|
||||
$script = array();
|
||||
@ -8530,7 +8532,7 @@ class Interpretation extends Fields
|
||||
|
||||
public function setMoveFolderMethod()
|
||||
{
|
||||
if ($this->setMoveFolders)
|
||||
if (CFactory::_('Registry')->get('set_move_folders_install_script'))
|
||||
{
|
||||
// reset script
|
||||
$script = array();
|
||||
@ -22535,7 +22537,7 @@ class Interpretation extends Fields
|
||||
$type = ComponentbuilderHelper::imageInfo($path);
|
||||
if ($type)
|
||||
{
|
||||
$imagePath = $this->componentPath . '/admin/assets/images';
|
||||
$imagePath = CFactory::_('Utilities.Paths')->component_path . '/admin/assets/images';
|
||||
// move the image to its place
|
||||
File::copy(
|
||||
JPATH_SITE . '/' . $path,
|
||||
@ -22757,7 +22759,7 @@ class Interpretation extends Fields
|
||||
$this->iconBuilder
|
||||
))
|
||||
{
|
||||
$imagePath = $this->componentPath
|
||||
$imagePath = CFactory::_('Utilities.Paths')->component_path
|
||||
. '/admin/assets/images/icons';
|
||||
foreach ($this->iconBuilder as $icon => $path)
|
||||
{
|
||||
@ -27924,20 +27926,20 @@ function vdm_dkim() {
|
||||
{
|
||||
Folder::create($path);
|
||||
// count the folder created
|
||||
CFactory::_('Counter')->folder++;
|
||||
CFactory::_('Utilities.Counter')->folder++;
|
||||
}
|
||||
// add to language files (for now we add all to both TODO)
|
||||
$this->writeFile(
|
||||
CFactory::_('Utilities.File')->write(
|
||||
$path . $file_name,
|
||||
implode(PHP_EOL, $lang)
|
||||
);
|
||||
$this->writeFile(
|
||||
CFactory::_('Utilities.File')->write(
|
||||
$path . $tag . '.' . $module->file_name
|
||||
. '.sys.ini',
|
||||
implode(PHP_EOL, $lang)
|
||||
);
|
||||
// set the line counter
|
||||
CFactory::_('Counter')->line += count(
|
||||
CFactory::_('Utilities.Counter')->line += count(
|
||||
(array) $lang
|
||||
);
|
||||
unset($lang);
|
||||
@ -28316,14 +28318,14 @@ function vdm_dkim() {
|
||||
{
|
||||
Folder::create($path);
|
||||
// count the folder created
|
||||
CFactory::_('Counter')->folder++;
|
||||
CFactory::_('Utilities.Counter')->folder++;
|
||||
}
|
||||
// add to language file
|
||||
$this->writeFile(
|
||||
CFactory::_('Utilities.File')->write(
|
||||
$path . $file_name,
|
||||
implode(PHP_EOL, $lang)
|
||||
);
|
||||
$this->writeFile(
|
||||
CFactory::_('Utilities.File')->write(
|
||||
$path . $tag . '.plg_' . strtolower(
|
||||
(string) $plugin->group
|
||||
)
|
||||
@ -28332,7 +28334,7 @@ function vdm_dkim() {
|
||||
implode(PHP_EOL, $lang)
|
||||
);
|
||||
// set the line counter
|
||||
CFactory::_('Counter')->line += count(
|
||||
CFactory::_('Utilities.Counter')->line += count(
|
||||
(array) $lang
|
||||
);
|
||||
unset($lang);
|
||||
|
@ -172,7 +172,7 @@ class Infusion extends Interpretation
|
||||
CFactory::_('Content')->set('GLOBALVERSION', CFactory::_('Content')->get('VERSION'));
|
||||
|
||||
// set the joomla target xml version
|
||||
CFactory::_('Content')->set('XMLVERSION', $this->joomlaVersions[CFactory::_('Config')->joomla_version]['xml_version']);
|
||||
CFactory::_('Content')->set('XMLVERSION', CFactory::_('Config')->joomla_versions[CFactory::_('Config')->joomla_version]['xml_version']);
|
||||
|
||||
// Component_name
|
||||
$name = CFactory::_('Component')->get('name');
|
||||
@ -2095,7 +2095,7 @@ class Infusion extends Interpretation
|
||||
// remove old unused language strings
|
||||
$this->purgeLanuageStrings($values, CFactory::_('Config')->component_id);
|
||||
// path to INI file
|
||||
$getPAth = $this->templatePath . '/en-GB.com_admin.ini';
|
||||
$getPAth = CFactory::_('Utilities.Paths')->template_path . '/en-GB.com_admin.ini';
|
||||
// for plugin event TODO change event api signatures
|
||||
$component_context = CFactory::_('Config')->component_context;
|
||||
// Trigger Event: jcb_ce_onBeforeBuildAllLangFiles
|
||||
@ -2143,18 +2143,18 @@ class Infusion extends Interpretation
|
||||
))
|
||||
{
|
||||
// build the path to place the lang file
|
||||
$path = $this->componentPath . '/' . $p . '/language/'
|
||||
$path = CFactory::_('Utilities.Paths')->component_path . '/' . $p . '/language/'
|
||||
. $tag . '/';
|
||||
if (!Folder::exists($path))
|
||||
{
|
||||
Folder::create($path);
|
||||
// count the folder created
|
||||
CFactory::_('Counter')->folder++;
|
||||
CFactory::_('Utilities.Counter')->folder++;
|
||||
}
|
||||
// move the file to its place
|
||||
File::copy($getPAth, $path . $file_name);
|
||||
// count the file created
|
||||
CFactory::_('Counter')->file++;
|
||||
CFactory::_('Utilities.Counter')->file++;
|
||||
// add content to it
|
||||
$lang = array_map(
|
||||
fn($langstring, $placeholder) => $placeholder . '="' . $langstring . '"',
|
||||
@ -2162,11 +2162,11 @@ class Infusion extends Interpretation
|
||||
array_keys($languageStrings)
|
||||
);
|
||||
// add to language file
|
||||
$this->writeFile(
|
||||
CFactory::_('Utilities.File')->write(
|
||||
$path . $file_name, implode(PHP_EOL, $lang)
|
||||
);
|
||||
// set the line counter
|
||||
CFactory::_('Counter')->line += count(
|
||||
CFactory::_('Utilities.Counter')->line += count(
|
||||
(array) $lang
|
||||
);
|
||||
unset($lang);
|
||||
@ -2199,7 +2199,7 @@ class Infusion extends Interpretation
|
||||
= implode(PHP_EOL . Indent::_(2), $langXML['site']);
|
||||
}
|
||||
// build xml path
|
||||
$xmlPath = $this->componentPath . '/' . CFactory::_('Config')->component_code_name
|
||||
$xmlPath = CFactory::_('Utilities.Paths')->component_path . '/' . CFactory::_('Config')->component_code_name
|
||||
. '.xml';
|
||||
// get the content in xml
|
||||
$componentXML = FileHelper::getContent(
|
||||
@ -2208,7 +2208,7 @@ class Infusion extends Interpretation
|
||||
// update the xml content
|
||||
$componentXML = CFactory::_('Placeholder')->update($componentXML, $replace);
|
||||
// store the values back to xml
|
||||
$this->writeFile($xmlPath, $componentXML);
|
||||
CFactory::_('Utilities.File')->write($xmlPath, $componentXML);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1318,6 +1318,7 @@ COM_COMPONENTBUILDER_AUTHOR_NAME="Author Name"
|
||||
COM_COMPONENTBUILDER_AUTHOR_WEBSITE="Author Website"
|
||||
COM_COMPONENTBUILDER_AUTO_CHECKIN="Auto Check-in"
|
||||
COM_COMPONENTBUILDER_AVAILABLE_LIBRARIES="Available Libraries"
|
||||
COM_COMPONENTBUILDER_A_METHOD_SETDYNAMICFZEROLDTHREERS_WAS_ADDED_TO_THE_INSTALL_BSCRIPTPHPB_OF_THIS_PACKAGE_TO_INSURE_THAT_THE_FOLDERS_ARE_COPIED_INTO_THE_CORRECT_PLACE_WHEN_THIS_COMPONENT_IS_INSTALLED="A method (setDynamicF0ld3rs) was added to the install <b>script.php</b> of this package to insure that the folder(s) are copied into the correct place when this component is installed!"
|
||||
COM_COMPONENTBUILDER_A_S_SPAN_CLASSICONFLAG_SPANREPORT_BROKEN_PACKAGEA="<a %s ><span class="icon-flag"> </span>Report Broken Package</a>"
|
||||
COM_COMPONENTBUILDER_BACK="Back"
|
||||
COM_COMPONENTBUILDER_BACKUP="Backup"
|
||||
@ -1651,6 +1652,7 @@ COM_COMPONENTBUILDER_CLASS_PROPERTY_VERSION_DESC="A count of the number of times
|
||||
COM_COMPONENTBUILDER_CLASS_PROPERTY_VERSION_LABEL="Version"
|
||||
COM_COMPONENTBUILDER_CLASS_PROPERTY_VISIBILITY_DESCRIPTION="The visibility of a function/method or property can be defined by prefixing the declaration with the keywords public, protected or private. You also have the option to make function/method or property static."
|
||||
COM_COMPONENTBUILDER_CLASS_PROPERTY_VISIBILITY_LABEL="Visibility"
|
||||
COM_COMPONENTBUILDER_CLEAR="Clear"
|
||||
COM_COMPONENTBUILDER_CLEAR_TMP="Clear tmp"
|
||||
COM_COMPONENTBUILDER_CLONE="Clone"
|
||||
COM_COMPONENTBUILDER_CLONE_FAILED="Clone failed!"
|
||||
@ -5602,6 +5604,7 @@ COM_COMPONENTBUILDER_HIDE_ONLY="Hide Only"
|
||||
COM_COMPONENTBUILDER_HIDE_TOGGLE="Hide Toggle"
|
||||
COM_COMPONENTBUILDER_HOW_TO_GET_A_S_FREE_KEYSA_FROM_VDM="How to get <a %s >free keys</a> from VDM."
|
||||
COM_COMPONENTBUILDER_HR_HTHREECUSTOM_CODES_WARNINGHTHREE="<hr /><h3>Custom Codes Warning</h3>"
|
||||
COM_COMPONENTBUILDER_HR_HTHREEDYNAMIC_FOLDERS_WERE_DETECTEDHTHREE="<hr /><h3>Dynamic folder(s) were detected.</h3>"
|
||||
COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_ERRORHTHREE="<hr /><h3>External Code Error</h3>"
|
||||
COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_NOTICEHTHREE="<hr /><h3>External Code Notice</h3>"
|
||||
COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_WARNINGHTHREE="<hr /><h3>External Code Warning</h3>"
|
||||
|
File diff suppressed because one or more lines are too long
@ -137,7 +137,8 @@ class ComponentbuilderViewSearch extends HtmlView
|
||||
// set the mode options
|
||||
$options = [
|
||||
1 => 'COM_COMPONENTBUILDER_SEARCH',
|
||||
2 => 'COM_COMPONENTBUILDER_REPLACE'];
|
||||
2 => 'COM_COMPONENTBUILDER_REPLACE',
|
||||
0 => 'COM_COMPONENTBUILDER_CLEAR'];
|
||||
// add to form
|
||||
$xml = ComponentbuilderHelper::getFieldXML($attributes, $options);
|
||||
if ($xml instanceof SimpleXMLElement)
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="component" version="4" method="upgrade">
|
||||
<name>COM_COMPONENTBUILDER</name>
|
||||
<creationDate>22nd January, 2023</creationDate>
|
||||
<creationDate>29th January, 2023</creationDate>
|
||||
<author>Llewellyn van der Merwe</author>
|
||||
<authorEmail>joomla@vdm.io</authorEmail>
|
||||
<authorUrl>https://dev.vdm.io</authorUrl>
|
||||
|
@ -83,7 +83,7 @@ abstract class AbstractGiteaObject
|
||||
if ($this->options->get('access.token', false))
|
||||
{
|
||||
// Use oAuth authentication
|
||||
$headers = $this->client->getOption('headers', array());
|
||||
$headers = $this->client->getOption('headers', []);
|
||||
|
||||
if (!isset($headers['Authorization']))
|
||||
{
|
||||
|
@ -70,7 +70,7 @@ class Wiki extends AbstractPackage
|
||||
$path = '/markdown';
|
||||
|
||||
// Get headers
|
||||
$headers = $this->client->getOption('headers', array());
|
||||
$headers = $this->client->getOption('headers', []);
|
||||
|
||||
$headers['accept'] = 'text/html';
|
||||
$headers['Content-Type'] = 'application/json';
|
||||
|
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Abstraction;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Mappersingleinterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Mapper Single
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract class MapperSingle implements Mappersingleinterface
|
||||
{
|
||||
|
||||
/**
|
||||
* The Content
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public array $active = [];
|
||||
|
||||
/**
|
||||
* Set content
|
||||
*
|
||||
* @param string $key The main string key
|
||||
* @param mixed $value The values to set
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function set(string $key, $value)
|
||||
{
|
||||
$this->active[$this->key($key)] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content
|
||||
*
|
||||
* @param string $key The main string key
|
||||
*
|
||||
* @return mixed
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(string $key)
|
||||
{
|
||||
return $this->active[$this->key($key)] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does key exist
|
||||
*
|
||||
* @param string $key The main string key
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function exist(string $key): bool
|
||||
{
|
||||
if (isset($this->active[$this->key($key)]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add content
|
||||
*
|
||||
* @param string $key The main string key
|
||||
* @param mixed $value The values to set
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function add(string $key, $value)
|
||||
{
|
||||
if (isset($this->active[$this->key($key)]))
|
||||
{
|
||||
$this->active[$this->key($key)] .= $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->active[$this->key($key)] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove content
|
||||
*
|
||||
* @param string $key The main string key
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function remove(string $key)
|
||||
{
|
||||
unset($this->active[$this->key($key)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Model the key
|
||||
*
|
||||
* @param string $key The key to model
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract protected function key(string $key): string;
|
||||
}
|
||||
|
@ -86,6 +86,22 @@ class Data
|
||||
*/
|
||||
protected Dispenser $dispenser;
|
||||
|
||||
/**
|
||||
* Compiler Customcode
|
||||
*
|
||||
* @var Customcode
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Customcode $customcode;
|
||||
|
||||
/**
|
||||
* Compiler Customcode in Gui
|
||||
*
|
||||
* @var Gui
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Gui $gui;
|
||||
|
||||
/**
|
||||
* Compiler Field
|
||||
*
|
||||
@ -223,8 +239,7 @@ class Data
|
||||
?Filesfolders $filesFolders = null, ?Historycomponent $history = null, ?Whmcs $whmcs = null,
|
||||
?Sqltweaking $sqltweaking = null, ?Adminviews $adminviews = null, ?Siteviews $siteviews = null,
|
||||
?Customadminviews $customadminviews = null, ?Joomlamodules $modules = null,
|
||||
?Joomlaplugins $plugins = null,
|
||||
?\JDatabaseDriver $db = null)
|
||||
?Joomlaplugins $plugins = null, ?\JDatabaseDriver $db = null)
|
||||
{
|
||||
$this->config = $config ?: Compiler::_('Config');
|
||||
$this->event = $event ?: Compiler::_('Event');
|
||||
@ -709,16 +724,11 @@ class Data
|
||||
unset($component->bom);
|
||||
|
||||
// README
|
||||
if ($component->addreadme)
|
||||
{
|
||||
$component->readme = $this->customcode->update(
|
||||
$component->readme =
|
||||
$component->addreadme ?
|
||||
$this->customcode->update(
|
||||
base64_decode((string) $component->readme)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$component->readme = '';
|
||||
}
|
||||
) : '';
|
||||
|
||||
// set lang now
|
||||
$nowLang = $this->config->lang_target;
|
||||
|
@ -88,7 +88,7 @@ class Placeholder implements PlaceholderInterface
|
||||
// load the db
|
||||
$db = $this->db;
|
||||
// reset bucket
|
||||
$bucket = array();
|
||||
$bucket = [];
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
$query->select($db->quoteName(array('a.target', 'a.value')));
|
||||
|
@ -475,6 +475,21 @@ class Config extends BaseConfig
|
||||
return $this->compiler_path . '/default.txt';
|
||||
}
|
||||
|
||||
/**
|
||||
* get custom folder path
|
||||
*
|
||||
* @return string The custom folder path
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getCustomfolderpath(): string
|
||||
{
|
||||
// get the custom folder path
|
||||
return $this->params->get(
|
||||
'custom_folder_path',
|
||||
JPATH_COMPONENT_ADMINISTRATOR . '/custom'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* get switch to add assets table fix
|
||||
*
|
||||
|
@ -193,7 +193,7 @@ class Customcode implements CustomcodeInterface
|
||||
var_dump($string);
|
||||
}
|
||||
// the ids found in this content
|
||||
$bucket = array();
|
||||
$bucket = [];
|
||||
$found = GetHelper::allBetween(
|
||||
$string, '[CUSTO' . 'MCODE=', ']'
|
||||
);
|
||||
@ -268,7 +268,7 @@ class Customcode implements CustomcodeInterface
|
||||
{
|
||||
if (!isset($this->data[$id]['args']))
|
||||
{
|
||||
$this->data[$id]['args'] = array();
|
||||
$this->data[$id]['args'] = [];
|
||||
}
|
||||
// only load if not already loaded
|
||||
if (!isset($this->data[$id]['args'][$key]))
|
||||
@ -289,7 +289,7 @@ class Customcode implements CustomcodeInterface
|
||||
))
|
||||
{
|
||||
$this->data[$id]['args'][$key]
|
||||
= array();
|
||||
= [];
|
||||
// update the function values with the custom code key placeholders (this allow the use of [] + and , in the values)
|
||||
$this->data[$id]['args'][$key][]
|
||||
= $this->placeholder->update(
|
||||
@ -415,7 +415,7 @@ class Customcode implements CustomcodeInterface
|
||||
$this->db->quoteName('a.from_line') . ' ASC'
|
||||
); // <--- insure we always add code from top of file
|
||||
// reset custom code
|
||||
$this->active = array();
|
||||
$this->active = [];
|
||||
}
|
||||
$query->where($this->db->quoteName('a.published') . ' >= 1');
|
||||
$this->db->setQuery($query);
|
||||
@ -502,7 +502,7 @@ class Customcode implements CustomcodeInterface
|
||||
*/
|
||||
protected function insert(array $ids, string $string, int $debug = 0): string
|
||||
{
|
||||
$code = array();
|
||||
$code = [];
|
||||
// load the code
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
|
@ -117,7 +117,7 @@ class Dispenser implements DispenserInterface
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function set(&$script, string $first, ?string $second = null, ?string $third = null,
|
||||
array $config = array(), bool $base64 = true, bool $dynamic = true, bool $add = false): bool
|
||||
array $config = [], bool $base64 = true, bool $dynamic = true, bool $add = false): bool
|
||||
{
|
||||
// only load if we have a string
|
||||
if (!StringHelper::check($script))
|
||||
@ -132,7 +132,7 @@ class Dispenser implements DispenserInterface
|
||||
// check if the script first key is set
|
||||
if ($second && !isset($this->hub[$first]))
|
||||
{
|
||||
$this->hub[$first] = array();
|
||||
$this->hub[$first] = [];
|
||||
}
|
||||
elseif ($add && !$second
|
||||
&& !isset($this->hub[$first]))
|
||||
@ -143,7 +143,7 @@ class Dispenser implements DispenserInterface
|
||||
if ($second && $third
|
||||
&& !isset($this->hub[$first][$second]))
|
||||
{
|
||||
$this->hub[$first][$second] = array();
|
||||
$this->hub[$first][$second] = [];
|
||||
}
|
||||
elseif ($add && $second && !$third
|
||||
&& !isset($this->hub[$first][$second]))
|
||||
|
@ -122,7 +122,7 @@ class External implements ExternalInterface
|
||||
var_dump($string);
|
||||
}
|
||||
// target content
|
||||
$bucket = array();
|
||||
$bucket = [];
|
||||
$found = GetHelper::allBetween(
|
||||
$string, '[EXTERNA' . 'LCODE=', ']'
|
||||
);
|
||||
@ -342,17 +342,9 @@ class External implements ExternalInterface
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// add to local bucket
|
||||
if (isset($this->code[$target_key]))
|
||||
{
|
||||
// update the placeholder with the external code string
|
||||
$bucket[$key] = $this->code[$target_key];
|
||||
}
|
||||
else
|
||||
{
|
||||
// remove the placeholder
|
||||
$bucket[$key] = '';
|
||||
}
|
||||
$bucket[$key] = $this->code[$target_key] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -328,15 +328,7 @@ class Extractor implements ExtractorInterface
|
||||
// make sure we have the path correct (the script file is not in admin path for example)
|
||||
// there may be more... will nead to keep our eye on this... since files could be moved during install
|
||||
$file = str_replace('./', '', (string) $file); # TODO (windows path issues)
|
||||
|
||||
if ($file !== 'script.php')
|
||||
{
|
||||
$path = $target . '/' . $file;
|
||||
}
|
||||
else
|
||||
{
|
||||
$path = $file;
|
||||
}
|
||||
$path = $file !== 'script.php' ? $target . '/' . $file : $file;
|
||||
|
||||
// now we go line by line
|
||||
foreach (new \SplFileObject($file) as $lineNumber => $lineContent)
|
||||
|
@ -130,7 +130,7 @@ class Paths
|
||||
protected function load()
|
||||
{
|
||||
// set the local paths to search
|
||||
$local_paths = array();
|
||||
$local_paths = [];
|
||||
|
||||
// admin path
|
||||
$local_paths['admin'] = JPATH_ADMINISTRATOR . '/components/com_'
|
||||
@ -213,15 +213,8 @@ class Paths
|
||||
{
|
||||
$joomla_modules = array_filter(
|
||||
array_values($addjoomla_modules),
|
||||
function ($array) {
|
||||
// only load the modules whose target association call for it
|
||||
if (!isset($array['target']) || $array['target'] != 2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
fn($array): bool => !isset($array['target']) || $array['target'] != 2
|
||||
);
|
||||
// if we have values we return IDs
|
||||
if (ArrayHelper::check($joomla_modules))
|
||||
|
@ -183,7 +183,7 @@ class Gui implements GuiInterface
|
||||
// get file content
|
||||
$file_conent = FileHelper::getContent($file);
|
||||
|
||||
$guiCode = array();
|
||||
$guiCode = [];
|
||||
// we add a new search for the GUI CODE Blocks
|
||||
$guiCode[] = GetHelper::allBetween(
|
||||
$file_conent, '/***[JCB' . 'GUI<>', '/***[/JCBGUI' . '$$$$]***/'
|
||||
|
@ -62,7 +62,7 @@ class Hash
|
||||
$values = GetHelper::allBetween(
|
||||
$script, 'HASH' . 'STRING((((', '))))'
|
||||
);
|
||||
$locker = array();
|
||||
$locker = [];
|
||||
// convert them
|
||||
foreach ($values as $value)
|
||||
{
|
||||
@ -80,7 +80,7 @@ class Hash
|
||||
$values = GetHelper::allBetween(
|
||||
$script, 'HASH' . 'FILE((((', '))))'
|
||||
);
|
||||
$locker = array();
|
||||
$locker = [];
|
||||
// convert them
|
||||
foreach ($values as $path)
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ class LockBase implements LockBaseInterface
|
||||
$values = GetHelper::allBetween(
|
||||
$script, 'LOCK'.'BASE64((((', '))))'
|
||||
);
|
||||
$locker = array();
|
||||
$locker = [];
|
||||
// convert them
|
||||
foreach ($values as $value)
|
||||
{
|
||||
|
@ -294,15 +294,7 @@ class Data
|
||||
$main_get = $this->dynamic->get(
|
||||
array($item->main_get), $item->code, $item->context
|
||||
);
|
||||
|
||||
if (ArrayHelper::check($main_get))
|
||||
{
|
||||
$item->main_get = $main_get[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
$item->main_get = null;
|
||||
}
|
||||
$item->main_get = ArrayHelper::check($main_get) ? $main_get[0] : null;
|
||||
|
||||
// set the custom_get data
|
||||
$item->custom_get = (isset($item->custom_get)
|
||||
|
@ -34,6 +34,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Service\Extension;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Service\Field;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Service\Joomlamodule;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Service\Joomlaplugin;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Service\Utilities;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\FactoryInterface;
|
||||
|
||||
|
||||
@ -136,7 +137,8 @@ abstract class Factory implements FactoryInterface
|
||||
->registerServiceProvider(new Extension())
|
||||
->registerServiceProvider(new Field())
|
||||
->registerServiceProvider(new Joomlamodule())
|
||||
->registerServiceProvider(new Joomlaplugin());
|
||||
->registerServiceProvider(new Joomlaplugin())
|
||||
->registerServiceProvider(new Utilities());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ interface DispenserInterface
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function set(&$script, string $first, ?string $second = null, ?string $third = null,
|
||||
array $config = array(), bool $base64 = true, bool $dynamic = true, bool $add = false): bool;
|
||||
array $config = [], bool $base64 = true, bool $dynamic = true, bool $add = false): bool;
|
||||
|
||||
/**
|
||||
* Get the script from the customcode dispenser
|
||||
|
@ -170,7 +170,7 @@ class History implements HistoryInterface
|
||||
}
|
||||
else
|
||||
{
|
||||
$version_note = array('component' => array());
|
||||
$version_note = array('component' => []);
|
||||
}
|
||||
// set watch
|
||||
switch ($action)
|
||||
|
@ -0,0 +1,883 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Joomlamodule;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\Data as Module;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Component;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Registry;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Folder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Files;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\ObjectHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Utilities\FileHelper;
|
||||
|
||||
|
||||
/**
|
||||
* Joomla Module Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Builder
|
||||
{
|
||||
/**
|
||||
* Compiler Joomla Module Data Class
|
||||
*
|
||||
* @var Module
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Module $module;
|
||||
|
||||
/**
|
||||
* Compiler Component
|
||||
*
|
||||
* @var Component
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Component $component;
|
||||
|
||||
/**
|
||||
* Compiler Config
|
||||
*
|
||||
* @var Config
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* The compiler registry
|
||||
*
|
||||
* @var Registry
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Registry $registry;
|
||||
|
||||
/**
|
||||
* Compiler Customcode Dispenser
|
||||
*
|
||||
* @var Dispenser
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Dispenser $dispenser;
|
||||
|
||||
/**
|
||||
* Compiler Event
|
||||
*
|
||||
* @var EventInterface
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected EventInterface $event;
|
||||
|
||||
/**
|
||||
* Compiler Counter
|
||||
*
|
||||
* @var Counter
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Counter $counter;
|
||||
|
||||
/**
|
||||
* Compiler Utilities Folder
|
||||
*
|
||||
* @var Folder
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Folder $folder;
|
||||
|
||||
/**
|
||||
* Compiler Utilities File
|
||||
*
|
||||
* @var File
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected File $file;
|
||||
|
||||
/**
|
||||
* Compiler Utilities Files
|
||||
*
|
||||
* @var Files
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Files $files;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Module|null $module The compiler Joomla module data object.
|
||||
* @param Component|null $component The component class.
|
||||
* @param Config|null $config The compiler config object.
|
||||
* @param Registry|null $registry The compiler registry object.
|
||||
* @param Dispenser|null $dispenser The compiler customcode dispenser object.
|
||||
* @param EventInterface|null $event The compiler event api object.
|
||||
* @param Counter|null $counter The compiler counter object.
|
||||
* @param Folder|null $folder The compiler folder object.
|
||||
* @param File|null $file The compiler file object.
|
||||
* @param Files|null $files The compiler files object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Module $module = null, ?Component $component = null,
|
||||
?Config $config = null, ?Registry $registry = null,
|
||||
?Dispenser $dispenser = null, ?EventInterface $event = null,
|
||||
?Counter $counter = null, ?Folder $folder = null,
|
||||
?File $file = null, ?Files $files = null)
|
||||
{
|
||||
$this->module = $module ?: Compiler::_('Joomlamodule.Data');
|
||||
$this->component = $component ?: Compiler::_('Component');
|
||||
$this->config = $config ?: Compiler::_('Config');
|
||||
$this->registry = $registry ?: Compiler::_('Registry');
|
||||
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
|
||||
$this->event = $event ?: Compiler::_('Event');
|
||||
$this->counter = $counter ?? Compiler::_('Utilities.Counter');
|
||||
$this->folder = $folder ?? Compiler::_('Utilities.Folder');
|
||||
$this->file = $file ?? Compiler::_('Utilities.File');
|
||||
$this->files = $files ?? Compiler::_('Utilities.Files');
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Modules files, folders, url's and config
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
if ($this->module->exists())
|
||||
{
|
||||
// for plugin event TODO change event api signatures
|
||||
$component_context = $this->config->component_context;
|
||||
$modules = $this->module->get();
|
||||
// Trigger Event: jcb_ce_onBeforeSetModules
|
||||
$this->event->trigger(
|
||||
'jcb_ce_onBeforeBuildModules',
|
||||
array(&$component_context, &$modules)
|
||||
);
|
||||
|
||||
foreach ($modules as $module)
|
||||
{
|
||||
if (ObjectHelper::check($module)
|
||||
&& isset($module->folder_name)
|
||||
&& StringHelper::check(
|
||||
$module->folder_name
|
||||
))
|
||||
{
|
||||
// module path
|
||||
$module->folder_path = $this->config->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
|
||||
. $module->folder_name;
|
||||
|
||||
// set the module paths
|
||||
$this->registry->set('dynamic_paths.' . $module->key, $module->folder_path);
|
||||
|
||||
// make sure there is no old build
|
||||
$this->folder->remove($module->folder_path);
|
||||
|
||||
// creat the main module folder
|
||||
$this->folder->create($module->folder_path);
|
||||
|
||||
// set main mod file
|
||||
$fileDetails = array('path' => $module->folder_path . '/'
|
||||
. $module->file_name . '.php',
|
||||
'name' => $module->file_name . '.php',
|
||||
'zip' => $module->file_name . '.php');
|
||||
$this->file->write(
|
||||
$fileDetails['path'],
|
||||
'<?php' . PHP_EOL . '// main modfile' .
|
||||
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
|
||||
PHP_EOL . '// No direct access to this file' . PHP_EOL .
|
||||
"defined('_JEXEC') or die('Restricted access');"
|
||||
. PHP_EOL .
|
||||
Placefix::_h('MODCODE')
|
||||
);
|
||||
$this->files->appendArray($module->key, $fileDetails);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
|
||||
// set custom_get
|
||||
if ($module->custom_get)
|
||||
{
|
||||
$fileDetails = array(
|
||||
'path' => $module->folder_path . '/data.php',
|
||||
'name' => 'data.php',
|
||||
'zip' => 'data.php'
|
||||
);
|
||||
$this->file->write(
|
||||
$fileDetails['path'],
|
||||
'<?php' . PHP_EOL . '// get data file' .
|
||||
PHP_EOL . Placefix::_h('BOM') . PHP_EOL
|
||||
.
|
||||
PHP_EOL . '// No direct access to this file'
|
||||
. PHP_EOL .
|
||||
"defined('_JEXEC') or die('Restricted access');"
|
||||
. PHP_EOL . PHP_EOL .
|
||||
'/**' . PHP_EOL .
|
||||
' * Module ' . $module->official_name . ' Data'
|
||||
. PHP_EOL .
|
||||
' */' . PHP_EOL .
|
||||
"class " . $module->class_data_name
|
||||
. ' extends \JObject' . PHP_EOL .
|
||||
"{" . Placefix::_h('DYNAMICGETS') . "}"
|
||||
. PHP_EOL
|
||||
);
|
||||
$this->files->appendArray($module->key, $fileDetails);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
|
||||
// set helper file
|
||||
if ($module->add_class_helper >= 1)
|
||||
{
|
||||
$fileDetails = array('path' => $module->folder_path
|
||||
. '/helper.php',
|
||||
'name' => 'helper.php',
|
||||
'zip' => 'helper.php');
|
||||
$this->file->write(
|
||||
$fileDetails['path'],
|
||||
'<?php' . PHP_EOL . '// helper file' .
|
||||
PHP_EOL . Placefix::_h('BOM') . PHP_EOL
|
||||
.
|
||||
PHP_EOL . '// No direct access to this file'
|
||||
. PHP_EOL .
|
||||
"defined('_JEXEC') or die('Restricted access');"
|
||||
. PHP_EOL .
|
||||
Placefix::_h('HELPERCODE')
|
||||
);
|
||||
$this->files->appendArray($module->key, $fileDetails);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
|
||||
// set main xml file
|
||||
$fileDetails = array('path' => $module->folder_path . '/'
|
||||
. $module->file_name . '.xml',
|
||||
'name' => $module->file_name . '.xml',
|
||||
'zip' => $module->file_name . '.xml');
|
||||
$this->file->write(
|
||||
$fileDetails['path'],
|
||||
$this->getXML($module)
|
||||
);
|
||||
$this->files->appendArray($module->key, $fileDetails);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
|
||||
// set tmpl folder
|
||||
$this->folder->create($module->folder_path . '/tmpl');
|
||||
|
||||
// set default file
|
||||
$fileDetails = array('path' => $module->folder_path
|
||||
. '/tmpl/default.php',
|
||||
'name' => 'default.php',
|
||||
'zip' => 'tmpl/default.php');
|
||||
$this->file->write(
|
||||
$fileDetails['path'],
|
||||
'<?php' . PHP_EOL . '// default tmpl' .
|
||||
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
|
||||
PHP_EOL . '// No direct access to this file' . PHP_EOL .
|
||||
"defined('_JEXEC') or die('Restricted access');"
|
||||
. PHP_EOL .
|
||||
Placefix::_h('MODDEFAULT')
|
||||
);
|
||||
$this->files->appendArray($module->key, $fileDetails);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
|
||||
// set install script if needed
|
||||
if ($module->add_install_script)
|
||||
{
|
||||
$fileDetails = array('path' => $module->folder_path
|
||||
. '/script.php',
|
||||
'name' => 'script.php',
|
||||
'zip' => 'script.php');
|
||||
$this->file->write(
|
||||
$fileDetails['path'],
|
||||
'<?php' . PHP_EOL . '// Script template' .
|
||||
PHP_EOL . Placefix::_h('BOM') . PHP_EOL
|
||||
.
|
||||
PHP_EOL . '// No direct access to this file'
|
||||
. PHP_EOL .
|
||||
"defined('_JEXEC') or die('Restricted access');"
|
||||
. PHP_EOL .
|
||||
Placefix::_h('INSTALLCLASS')
|
||||
);
|
||||
$this->files->appendArray($module->key, $fileDetails);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
|
||||
// set readme if found
|
||||
if ($module->addreadme)
|
||||
{
|
||||
$fileDetails = array('path' => $module->folder_path
|
||||
. '/README.md',
|
||||
'name' => 'README.md',
|
||||
'zip' => 'README.md');
|
||||
$this->file->write($fileDetails['path'], $module->readme);
|
||||
$this->files->appendArray($module->key, $fileDetails);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
|
||||
// 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 = [];
|
||||
|
||||
// add any css from the fields
|
||||
if (($css = $this->dispenser->get(
|
||||
'css_view', $module->key
|
||||
)) !== null
|
||||
&& StringHelper::check($css))
|
||||
{
|
||||
// make sure this script does not have PHP
|
||||
if (strpos((string) $css, '<?php') === false)
|
||||
{
|
||||
// make sure the field is added
|
||||
$module->add_scripts_field = true;
|
||||
|
||||
// create the css folder
|
||||
$this->folder->create($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->file->write(
|
||||
$fileDetails['path'],
|
||||
Placefix::_h('BOM') . PHP_EOL
|
||||
. PHP_EOL . $css
|
||||
);
|
||||
$this->files->appendArray($module->key, $fileDetails);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
|
||||
// add the field script
|
||||
$field_script_bucket[] = Indent::_(2) . "//"
|
||||
. Line::_(__Line__, __Class__) . " Custom CSS";
|
||||
$field_script_bucket[] = Indent::_(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->dispenser->get(
|
||||
'view_footer', $module->key
|
||||
)) !== null
|
||||
&& StringHelper::check($javascript))
|
||||
{
|
||||
// make sure this script does not have PHP
|
||||
if (strpos((string) $javascript, '<?php') === false)
|
||||
{
|
||||
// make sure the field is added
|
||||
$module->add_scripts_field = true;
|
||||
|
||||
// add the JavaScript file
|
||||
$this->folder->create($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->file->write(
|
||||
$fileDetails['path'],
|
||||
Placefix::_h('BOM') . PHP_EOL
|
||||
. PHP_EOL . $javascript
|
||||
);
|
||||
$this->files->appendArray($module->key, $fileDetails);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
|
||||
// add the field script
|
||||
$field_script_bucket[] = Indent::_(2) . "//"
|
||||
. Line::_(__Line__, __Class__) . " Custom JS";
|
||||
$field_script_bucket[] = Indent::_(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->folder->create($module->folder_path . '/fields');
|
||||
|
||||
// add the custom script field
|
||||
if ($module->add_scripts_field)
|
||||
{
|
||||
$fileDetails = [
|
||||
'path' => $module->folder_path
|
||||
. '/fields/modadminvvvvvvvdm.php',
|
||||
'name' => 'modadminvvvvvvvdm.php',
|
||||
'zip' => 'modadminvvvvvvvdm.php'
|
||||
];
|
||||
$this->file->write(
|
||||
$fileDetails['path'],
|
||||
$this->getCustomScriptField(
|
||||
$field_script_bucket
|
||||
)
|
||||
);
|
||||
$this->files->appendArray($module->key, $fileDetails);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
}
|
||||
|
||||
// set rules folders if needed
|
||||
if (isset($module->fields_rules_paths)
|
||||
&& $module->fields_rules_paths == 2)
|
||||
{
|
||||
// create rules folder
|
||||
$this->folder->create($module->folder_path . '/rules');
|
||||
}
|
||||
|
||||
// set forms folder if needed
|
||||
if (isset($module->form_files)
|
||||
&& ArrayHelper::check(
|
||||
$module->form_files
|
||||
))
|
||||
{
|
||||
// create forms folder
|
||||
$this->folder->create($module->folder_path . '/forms');
|
||||
|
||||
// set the template files
|
||||
foreach ($module->form_files as $file => $fields)
|
||||
{
|
||||
// set file details
|
||||
$fileDetails = array('path' => $module->folder_path
|
||||
. '/forms/' . $file . '.xml',
|
||||
'name' => $file . '.xml',
|
||||
'zip' => 'forms/' . $file
|
||||
. '.xml');
|
||||
|
||||
// build basic XML
|
||||
$xml = '<?xml version="1.0" encoding="utf-8"?>';
|
||||
$xml .= PHP_EOL . '<!--' . Line::_(__Line__, __Class__)
|
||||
. ' default paths of ' . $file
|
||||
. ' form points to ' . $this->config->component_code_name
|
||||
. ' -->';
|
||||
|
||||
// search if we must add the component path
|
||||
$add_component_path = false;
|
||||
foreach ($fields as $field_name => $fieldsets)
|
||||
{
|
||||
if (!$add_component_path)
|
||||
{
|
||||
foreach ($fieldsets as $fieldset => $field)
|
||||
{
|
||||
if (!$add_component_path
|
||||
&& isset(
|
||||
$module->fieldsets_paths[$file
|
||||
. $field_name . $fieldset]
|
||||
)
|
||||
&& $module->fieldsets_paths[$file
|
||||
. $field_name . $fieldset] == 1)
|
||||
{
|
||||
$add_component_path = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// only add if part of the component field types path is required
|
||||
if ($add_component_path)
|
||||
{
|
||||
$xml .= PHP_EOL . '<form';
|
||||
$xml .= PHP_EOL . Indent::_(1)
|
||||
. 'addrulepath="/administrator/components/com_'
|
||||
. $this->config->component_code_name
|
||||
. '/models/rules"';
|
||||
$xml .= PHP_EOL . Indent::_(1)
|
||||
. 'addfieldpath="/administrator/components/com_'
|
||||
. $this->config->component_code_name
|
||||
. '/models/fields"';
|
||||
$xml .= PHP_EOL . '>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$xml .= PHP_EOL . '<form>';
|
||||
}
|
||||
|
||||
// add the fields
|
||||
foreach ($fields as $field_name => $fieldsets)
|
||||
{
|
||||
// check if we have an double fields naming set
|
||||
$field_name_inner = '';
|
||||
$field_name_outer = $field_name;
|
||||
if (strpos((string) $field_name, '.') !== false)
|
||||
{
|
||||
$field_names = explode('.', (string) $field_name);
|
||||
if (count((array) $field_names) == 2)
|
||||
{
|
||||
$field_name_outer = $field_names[0];
|
||||
$field_name_inner = $field_names[1];
|
||||
}
|
||||
}
|
||||
$xml .= PHP_EOL . Indent::_(1)
|
||||
. '<fields name="' . $field_name_outer
|
||||
. '">';
|
||||
foreach ($fieldsets as $fieldset => $field)
|
||||
{
|
||||
// default to the field set name
|
||||
$label = $fieldset;
|
||||
if (isset($module->fieldsets_label[$file . $field_name . $fieldset]))
|
||||
{
|
||||
$label = $module->fieldsets_label[$file . $field_name . $fieldset];
|
||||
}
|
||||
|
||||
// add path to module rules and custom fields
|
||||
if (isset($module->fieldsets_paths[$file . $field_name . $fieldset])
|
||||
&& ($module->fieldsets_paths[$file . $field_name . $fieldset] == 2
|
||||
|| $module->fieldsets_paths[$file . $field_name . $fieldset] == 3))
|
||||
{
|
||||
if ($module->target == 2)
|
||||
{
|
||||
if (!isset($module->add_rule_path[$file . $field_name . $fieldset]))
|
||||
{
|
||||
$module->add_rule_path[$file . $field_name . $fieldset] =
|
||||
'/administrator/modules/'
|
||||
. $module->file_name . '/rules';
|
||||
}
|
||||
|
||||
if (!isset($module->add_field_path[$file . $field_name . $fieldset]))
|
||||
{
|
||||
$module->add_field_path[$file . $field_name . $fieldset] =
|
||||
'/administrator/modules/'
|
||||
. $module->file_name . '/fields';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isset($module->add_rule_path[$file . $field_name . $fieldset]))
|
||||
{
|
||||
$module->add_rule_path[$file . $field_name . $fieldset] =
|
||||
'/modules/' . $module->file_name
|
||||
. '/rules';
|
||||
}
|
||||
|
||||
if (!isset($module->add_field_path[$file . $field_name . $fieldset]))
|
||||
{
|
||||
$module->add_field_path[$file . $field_name . $fieldset] =
|
||||
'/modules/' . $module->file_name
|
||||
. '/fields';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add path to module rules and custom fields
|
||||
if (isset($module->add_rule_path[$file . $field_name . $fieldset])
|
||||
|| isset($module->add_field_path[$file . $field_name . $fieldset]))
|
||||
{
|
||||
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<!--'
|
||||
. Line::_(__Line__, __Class__) . ' default paths of '
|
||||
. $fieldset . ' fieldset points to the module -->';
|
||||
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<fieldset name="'
|
||||
. $fieldset . '" label="' . $label . '"';
|
||||
|
||||
if (isset($module->add_rule_path[$file . $field_name . $fieldset]))
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(2)
|
||||
. 'addrulepath="' . $module->add_rule_path[$file . $field_name . $fieldset] . '"';
|
||||
}
|
||||
|
||||
if (isset($module->add_field_path[$file . $field_name . $fieldset]))
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(2)
|
||||
. 'addfieldpath="' . $module->add_field_path[$file . $field_name . $fieldset] . '"';
|
||||
}
|
||||
|
||||
$xml .= PHP_EOL . Indent::_(1) . '>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<fieldset name="'
|
||||
. $fieldset . '" label="' . $label . '">';
|
||||
}
|
||||
|
||||
// check if we have an inner field set
|
||||
if (StringHelper::check(
|
||||
$field_name_inner
|
||||
))
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(1)
|
||||
. '<fields name="'
|
||||
. $field_name_inner . '">';
|
||||
}
|
||||
|
||||
// add the placeholder of the fields
|
||||
$xml .= Placefix::_h('FIELDSET_' . $file
|
||||
. $field_name . $fieldset );
|
||||
|
||||
// check if we have an inner field set
|
||||
if (StringHelper::check(
|
||||
$field_name_inner
|
||||
))
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(1)
|
||||
. '</fields>';
|
||||
}
|
||||
$xml .= PHP_EOL . Indent::_(1)
|
||||
. '</fieldset>';
|
||||
}
|
||||
$xml .= PHP_EOL . Indent::_(1) . '</fields>';
|
||||
}
|
||||
$xml .= PHP_EOL . '</form>';
|
||||
|
||||
// add xml to file
|
||||
$this->file->write($fileDetails['path'], $xml);
|
||||
$this->files->appendArray($module->key, $fileDetails);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
}
|
||||
|
||||
// set SQL stuff if needed
|
||||
if ($module->add_sql || $module->add_sql_uninstall)
|
||||
{
|
||||
// create SQL folder
|
||||
$this->folder->create($module->folder_path . '/sql');
|
||||
|
||||
// create mysql folder
|
||||
$this->folder->create(
|
||||
$module->folder_path . '/sql/mysql'
|
||||
);
|
||||
|
||||
// now set the install file
|
||||
if ($module->add_sql)
|
||||
{
|
||||
$this->file->write(
|
||||
$module->folder_path . '/sql/mysql/install.sql',
|
||||
$module->sql
|
||||
);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
|
||||
// now set the uninstall file
|
||||
if ($module->add_sql_uninstall)
|
||||
{
|
||||
$this->file->write(
|
||||
$module->folder_path
|
||||
. '/sql/mysql/uninstall.sql',
|
||||
$module->sql_uninstall
|
||||
);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
}
|
||||
|
||||
// creat the language folder
|
||||
$this->folder->create($module->folder_path . '/language');
|
||||
// also create the lang tag folder
|
||||
$this->folder->create(
|
||||
$module->folder_path . '/language/' . $this->config->get('lang_tag', 'en-GB')
|
||||
);
|
||||
|
||||
// check if this lib has files
|
||||
if (isset($module->files)
|
||||
&& ArrayHelper::check($module->files))
|
||||
{
|
||||
// add to component files
|
||||
foreach ($module->files as $file)
|
||||
{
|
||||
// set the pathfinder
|
||||
$file['target_type'] = $module->target_type;
|
||||
$file['target_id'] = $module->id;
|
||||
$this->component->appendArray('files', $file);
|
||||
}
|
||||
}
|
||||
|
||||
// check if this lib has folders
|
||||
if (isset($module->folders)
|
||||
&& ArrayHelper::check($module->folders))
|
||||
{
|
||||
// add to component folders
|
||||
foreach ($module->folders as $folder)
|
||||
{
|
||||
// set the pathfinder
|
||||
$folder['target_type'] = $module->target_type;
|
||||
$folder['target_id'] = $module->id;
|
||||
$this->component->appendArray('folders', $folder);
|
||||
}
|
||||
}
|
||||
|
||||
// check if this module has urls
|
||||
if (isset($module->urls)
|
||||
&& ArrayHelper::check($module->urls))
|
||||
{
|
||||
// add to component urls
|
||||
foreach ($module->urls as $n => &$url)
|
||||
{
|
||||
// should we add the local folder
|
||||
if (isset($url['type']) && $url['type'] > 1
|
||||
&& isset($url['url'])
|
||||
&& StringHelper::check(
|
||||
$url['url']
|
||||
))
|
||||
{
|
||||
// set file name
|
||||
$fileName = basename((string) $url['url']);
|
||||
|
||||
// get the file contents
|
||||
$data = FileHelper::getContent(
|
||||
$url['url']
|
||||
);
|
||||
|
||||
// build sub path
|
||||
if (strpos($fileName, '.js') !== false)
|
||||
{
|
||||
$path = '/js';
|
||||
}
|
||||
elseif (strpos($fileName, '.css') !== false)
|
||||
{
|
||||
$path = '/css';
|
||||
}
|
||||
else
|
||||
{
|
||||
$path = '';
|
||||
}
|
||||
|
||||
// create sub media path if not set
|
||||
$this->folder->create(
|
||||
$module->folder_path . $path
|
||||
);
|
||||
|
||||
// set the path to module file
|
||||
$url['path'] = $module->folder_path . $path
|
||||
. '/' . $fileName; // we need this for later
|
||||
|
||||
// write data to path
|
||||
$this->file->write($url['path'], $data);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the module xml template
|
||||
*
|
||||
* @param object $module The module object
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getXML(object &$module): string
|
||||
{
|
||||
$xml = '<?xml version="1.0" encoding="utf-8"?>';
|
||||
$xml .= PHP_EOL . '<extension type="module" version="'
|
||||
. $this->config->joomla_versions[$this->config->joomla_version]['xml_version'] . '" client="'
|
||||
. $module->target_client . '" method="upgrade">';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<name>' . $module->lang_prefix
|
||||
. '</name>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<creationDate>' . Placefix::_h('BUILDDATE') . '</creationDate>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<author>' . Placefix::_h('AUTHOR') . '</author>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<authorEmail>' . Placefix::_h('AUTHOREMAIL') . '</authorEmail>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<authorUrl>' . Placefix::_h('AUTHORWEBSITE') . '</authorUrl>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<copyright>' . Placefix::_h('COPYRIGHT') . '</copyright>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<license>' . Placefix::_h('LICENSE') . '</license>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<version>' . $module->module_version
|
||||
. '</version>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<description>' . $module->lang_prefix
|
||||
. '_XML_DESCRIPTION</description>';
|
||||
$xml .= Placefix::_h('MAINXML');
|
||||
$xml .= PHP_EOL . '</extension>';
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the module admin custom script field
|
||||
*
|
||||
* @param array $fieldScriptBucket The field
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*
|
||||
*/
|
||||
protected function getCustomScriptField(array $fieldScriptBucket): string
|
||||
{
|
||||
$form_field_class = [];
|
||||
$form_field_class[] = Placefix::_h('BOM') . PHP_EOL;
|
||||
$form_field_class[] = "//" . Line::_(__Line__, __Class__)
|
||||
. " 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[] = Indent::_(1)
|
||||
. "protected \$type = 'modadminvvvvvvvdm';";
|
||||
$form_field_class[] = PHP_EOL . Indent::_(1)
|
||||
. "protected function getLabel()";
|
||||
$form_field_class[] = Indent::_(1) . "{";
|
||||
$form_field_class[] = Indent::_(2) . "return;";
|
||||
$form_field_class[] = Indent::_(1) . "}";
|
||||
$form_field_class[] = PHP_EOL . Indent::_(1)
|
||||
. "protected function getInput()";
|
||||
$form_field_class[] = Indent::_(1) . "{";
|
||||
$form_field_class[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Get the document";
|
||||
$form_field_class[] = Indent::_(2)
|
||||
. "\$document = Factory::getDocument();";
|
||||
$form_field_class[] = implode(PHP_EOL, $fieldScriptBucket);
|
||||
$form_field_class[] = Indent::_(2) . "return; // noting for now :)";
|
||||
$form_field_class[] = Indent::_(1) . "}";
|
||||
$form_field_class[] = "}";
|
||||
|
||||
return implode(PHP_EOL, $form_field_class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -744,17 +744,17 @@ class Data
|
||||
if (!isset($module->form_files[$form['file']]))
|
||||
{
|
||||
$module->form_files[$form['file']]
|
||||
= array();
|
||||
= [];
|
||||
}
|
||||
if (!isset($module->form_files[$form['file']][$form['fields_name']]))
|
||||
{
|
||||
$module->form_files[$form['file']][$form['fields_name']]
|
||||
= array();
|
||||
= [];
|
||||
}
|
||||
if (!isset($module->form_files[$form['file']][$form['fields_name']][$form['fieldset']]))
|
||||
{
|
||||
$module->form_files[$form['file']][$form['fields_name']][$form['fieldset']]
|
||||
= array();
|
||||
= [];
|
||||
}
|
||||
// do some house cleaning (for fields)
|
||||
foreach ($form['fields'] as $field)
|
||||
@ -776,12 +776,12 @@ class Data
|
||||
if (!isset($module->config_fields[$form['fields_name']]))
|
||||
{
|
||||
$module->config_fields[$form['fields_name']]
|
||||
= array();
|
||||
= [];
|
||||
}
|
||||
if (!isset($module->config_fields[$form['fields_name']][$form['fieldset']]))
|
||||
{
|
||||
$module->config_fields[$form['fields_name']][$form['fieldset']]
|
||||
= array();
|
||||
= [];
|
||||
}
|
||||
// do some house cleaning (for fields)
|
||||
foreach ($form['fields'] as $field)
|
||||
|
@ -0,0 +1,626 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\Data as Plugin;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Component;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Registry;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Folder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Files;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\ObjectHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Utilities\FileHelper;
|
||||
|
||||
|
||||
/**
|
||||
* Joomla Plugin Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Builder
|
||||
{
|
||||
/**
|
||||
* Compiler Joomla Plugin Data Class
|
||||
*
|
||||
* @var Plugin
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Plugin $plugin;
|
||||
|
||||
/**
|
||||
* Compiler Component
|
||||
*
|
||||
* @var Component
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Component $component;
|
||||
|
||||
/**
|
||||
* Compiler Config
|
||||
*
|
||||
* @var Config
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* The compiler registry
|
||||
*
|
||||
* @var Registry
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Registry $registry;
|
||||
|
||||
/**
|
||||
* Compiler Customcode Dispenser
|
||||
*
|
||||
* @var Dispenser
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Dispenser $dispenser;
|
||||
|
||||
/**
|
||||
* Compiler Event
|
||||
*
|
||||
* @var EventInterface
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected EventInterface $event;
|
||||
|
||||
/**
|
||||
* Compiler Counter
|
||||
*
|
||||
* @var Counter
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Counter $counter;
|
||||
|
||||
/**
|
||||
* Compiler Utilities Folder
|
||||
*
|
||||
* @var Folder
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Folder $folder;
|
||||
|
||||
/**
|
||||
* Compiler Utilities File
|
||||
*
|
||||
* @var File
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected File $file;
|
||||
|
||||
/**
|
||||
* Compiler Utilities Files
|
||||
*
|
||||
* @var Files
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Files $files;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Plugin|null $plugin The compiler Joomla plugin data object.
|
||||
* @param Component|null $component The component class.
|
||||
* @param Config|null $config The compiler config object.
|
||||
* @param Registry|null $registry The compiler registry object.
|
||||
* @param Dispenser|null $dispenser The compiler customcode dispenser object.
|
||||
* @param EventInterface|null $event The compiler event api object.
|
||||
* @param Counter|null $counter The compiler counter object.
|
||||
* @param Folder|null $folder The compiler folder object.
|
||||
* @param File|null $file The compiler file object.
|
||||
* @param Files|null $files The compiler files object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Plugin $plugin = null, ?Component $component = null,
|
||||
?Config $config = null, ?Registry $registry = null,
|
||||
?Dispenser $dispenser = null, ?EventInterface $event = null,
|
||||
?Counter $counter = null, ?Folder $folder = null,
|
||||
?File $file = null, ?Files $files = null)
|
||||
{
|
||||
$this->plugin = $plugin ?: Compiler::_('Joomlaplugin.Data');
|
||||
$this->component = $component ?: Compiler::_('Component');
|
||||
$this->config = $config ?: Compiler::_('Config');
|
||||
$this->registry = $registry ?: Compiler::_('Registry');
|
||||
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
|
||||
$this->event = $event ?: Compiler::_('Event');
|
||||
$this->counter = $counter ?? Compiler::_('Utilities.Counter');
|
||||
$this->folder = $folder ?? Compiler::_('Utilities.Folder');
|
||||
$this->file = $file ?? Compiler::_('Utilities.File');
|
||||
$this->files = $files ?? Compiler::_('Utilities.Files');
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Plugins files, folders, url's and config
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
if ($this->plugin->exists())
|
||||
{
|
||||
// for plugin event TODO change event api signatures
|
||||
$component_context = $this->config->component_context;
|
||||
$plugins = $this->plugin->get();
|
||||
// Trigger Event: jcb_ce_onBeforeSetPlugins
|
||||
$this->event->trigger(
|
||||
'jcb_ce_onBeforeBuildPlugins',
|
||||
array(&$component_context, &$plugins)
|
||||
);
|
||||
foreach ($plugins as $plugin)
|
||||
{
|
||||
if (ObjectHelper::check($plugin)
|
||||
&& isset($plugin->folder_name)
|
||||
&& StringHelper::check(
|
||||
$plugin->folder_name
|
||||
))
|
||||
{
|
||||
// plugin path
|
||||
$plugin->folder_path = $this->config->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
|
||||
. $plugin->folder_name;
|
||||
|
||||
// set the plugin paths
|
||||
$this->registry->set('dynamic_paths.' . $plugin->key, $plugin->folder_path);
|
||||
|
||||
// make sure there is no old build
|
||||
$this->folder->remove($plugin->folder_path);
|
||||
|
||||
// creat the main component folder
|
||||
$this->folder->create($plugin->folder_path);
|
||||
|
||||
// set main class file
|
||||
$fileDetails = array('path' => $plugin->folder_path . '/'
|
||||
. $plugin->file_name . '.php',
|
||||
'name' => $plugin->file_name . '.php',
|
||||
'zip' => $plugin->file_name . '.php');
|
||||
$this->file->write(
|
||||
$fileDetails['path'],
|
||||
'<?php' . PHP_EOL . '// Plugin main class template' .
|
||||
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
|
||||
PHP_EOL . '// No direct access to this file' . PHP_EOL .
|
||||
"defined('_JEXEC') or die('Restricted access');"
|
||||
. PHP_EOL .
|
||||
Placefix::_h('MAINCLASS')
|
||||
);
|
||||
$this->files->appendArray($plugin->key, $fileDetails);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
|
||||
// set main xml file
|
||||
$fileDetails = array('path' => $plugin->folder_path . '/'
|
||||
. $plugin->file_name . '.xml',
|
||||
'name' => $plugin->file_name . '.xml',
|
||||
'zip' => $plugin->file_name . '.xml');
|
||||
$this->file->write(
|
||||
$fileDetails['path'],
|
||||
$this->getXML($plugin)
|
||||
);
|
||||
$this->files->appendArray($plugin->key, $fileDetails);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
|
||||
// set install script if needed
|
||||
if ($plugin->add_install_script)
|
||||
{
|
||||
$fileDetails = array('path' => $plugin->folder_path
|
||||
. '/script.php',
|
||||
'name' => 'script.php',
|
||||
'zip' => 'script.php');
|
||||
$this->file->write(
|
||||
$fileDetails['path'],
|
||||
'<?php' . PHP_EOL . '// Script template' .
|
||||
PHP_EOL . Placefix::_h('BOM') . PHP_EOL
|
||||
.
|
||||
PHP_EOL . '// No direct access to this file'
|
||||
. PHP_EOL .
|
||||
"defined('_JEXEC') or die('Restricted access');"
|
||||
. PHP_EOL .
|
||||
Placefix::_h('INSTALLCLASS')
|
||||
);
|
||||
$this->files->appendArray($plugin->key, $fileDetails);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
|
||||
// set readme if found
|
||||
if ($plugin->addreadme)
|
||||
{
|
||||
$fileDetails = array('path' => $plugin->folder_path
|
||||
. '/README.md',
|
||||
'name' => 'README.md',
|
||||
'zip' => 'README.md');
|
||||
$this->file->write($fileDetails['path'], $plugin->readme);
|
||||
$this->files->appendArray($plugin->key, $fileDetails);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
|
||||
// set fields & rules folders if needed
|
||||
if (isset($plugin->fields_rules_paths)
|
||||
&& $plugin->fields_rules_paths == 2)
|
||||
{
|
||||
// create fields folder
|
||||
$this->folder->create($plugin->folder_path . '/fields');
|
||||
|
||||
// create rules folder
|
||||
$this->folder->create($plugin->folder_path . '/rules');
|
||||
}
|
||||
|
||||
// set forms folder if needed
|
||||
if (isset($plugin->form_files)
|
||||
&& ArrayHelper::check(
|
||||
$plugin->form_files
|
||||
))
|
||||
{
|
||||
// create forms folder
|
||||
$this->folder->create($plugin->folder_path . '/forms');
|
||||
|
||||
// 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');
|
||||
|
||||
// build basic XML
|
||||
$xml = '<?xml version="1.0" encoding="utf-8"?>';
|
||||
$xml .= PHP_EOL . '<!--' . Line::_(__Line__, __Class__)
|
||||
. ' default paths of ' . $file
|
||||
. ' form points to ' . $this->config->component_code_name
|
||||
. ' -->';
|
||||
|
||||
// search if we must add the component path
|
||||
$add_component_path = false;
|
||||
foreach ($fields as $field_name => $fieldsets)
|
||||
{
|
||||
if (!$add_component_path)
|
||||
{
|
||||
foreach ($fieldsets as $fieldset => $field)
|
||||
{
|
||||
if (!$add_component_path
|
||||
&& isset(
|
||||
$plugin->fieldsets_paths[$file
|
||||
. $field_name . $fieldset]
|
||||
)
|
||||
&& $plugin->fieldsets_paths[$file
|
||||
. $field_name . $fieldset] == 1)
|
||||
{
|
||||
$add_component_path = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// only add if part of the component field types path is required
|
||||
if ($add_component_path)
|
||||
{
|
||||
$xml .= PHP_EOL . '<form';
|
||||
$xml .= PHP_EOL . Indent::_(1)
|
||||
. 'addrulepath="/administrator/components/com_'
|
||||
. $this->config->component_code_name
|
||||
. '/models/rules"';
|
||||
$xml .= PHP_EOL . Indent::_(1)
|
||||
. 'addfieldpath="/administrator/components/com_'
|
||||
. $this->config->component_code_name
|
||||
. '/models/fields"';
|
||||
$xml .= PHP_EOL . '>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$xml .= PHP_EOL . '<form>';
|
||||
}
|
||||
|
||||
// add the fields
|
||||
foreach ($fields as $field_name => $fieldsets)
|
||||
{
|
||||
// check if we have an double fields naming set
|
||||
$field_name_inner = '';
|
||||
$field_name_outer = $field_name;
|
||||
if (strpos((string) $field_name, '.') !== false)
|
||||
{
|
||||
$field_names = explode('.', (string) $field_name);
|
||||
if (count((array) $field_names) == 2)
|
||||
{
|
||||
$field_name_outer = $field_names[0];
|
||||
$field_name_inner = $field_names[1];
|
||||
}
|
||||
}
|
||||
$xml .= PHP_EOL . Indent::_(1)
|
||||
. '<fields name="' . $field_name_outer
|
||||
. '">';
|
||||
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
|
||||
|| $plugin->fieldsets_paths[$file . $field_name . $fieldset] == 3))
|
||||
{
|
||||
if (!isset($plugin->add_rule_path[$file . $field_name . $fieldset]))
|
||||
{
|
||||
$plugin->add_rule_path[$file . $field_name . $fieldset] =
|
||||
'/plugins/' . strtolower((string) $plugin->group
|
||||
) . '/' . strtolower((string) $plugin->code_name)
|
||||
. '/rules';
|
||||
}
|
||||
|
||||
if (!isset($plugin->add_field_path[$file . $field_name . $fieldset]))
|
||||
{
|
||||
$plugin->add_field_path[$file . $field_name . $fieldset] =
|
||||
'/plugins/' . strtolower((string) $plugin->group
|
||||
) . '/' . strtolower((string) $plugin->code_name)
|
||||
. '/fields';
|
||||
}
|
||||
}
|
||||
|
||||
// add path to plugin rules and custom fields
|
||||
if (isset($plugin->add_rule_path[$file . $field_name . $fieldset])
|
||||
|| isset($plugin->add_field_path[$file . $field_name . $fieldset]))
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<!--'
|
||||
. Line::_(__Line__, __Class__) . ' default paths of '
|
||||
. $fieldset . ' fieldset points to the plugin -->';
|
||||
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<fieldset name="'
|
||||
. $fieldset . '" label="' . $label . '"';
|
||||
|
||||
if (isset($plugin->add_rule_path[$file . $field_name . $fieldset]))
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(2)
|
||||
. 'addrulepath="' . $plugin->add_rule_path[$file . $field_name . $fieldset] . '"';
|
||||
}
|
||||
|
||||
if (isset($plugin->add_field_path[$file . $field_name . $fieldset]))
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(2)
|
||||
. 'addfieldpath="' . $plugin->add_field_path[$file . $field_name . $fieldset] . '"';
|
||||
}
|
||||
|
||||
$xml .= PHP_EOL . Indent::_(1) . '>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<fieldset name="'
|
||||
. $fieldset . '" label="' . $label . '">';
|
||||
}
|
||||
|
||||
// check if we have an inner field set
|
||||
if (StringHelper::check(
|
||||
$field_name_inner
|
||||
))
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(1)
|
||||
. '<fields name="'
|
||||
. $field_name_inner . '">';
|
||||
}
|
||||
|
||||
// add the placeholder of the fields
|
||||
$xml .= Placefix::_h('FIELDSET_' . $file
|
||||
. $field_name . $fieldset );
|
||||
|
||||
// check if we have an inner field set
|
||||
if (StringHelper::check(
|
||||
$field_name_inner
|
||||
))
|
||||
{
|
||||
$xml .= PHP_EOL . Indent::_(1)
|
||||
. '</fields>';
|
||||
}
|
||||
$xml .= PHP_EOL . Indent::_(1)
|
||||
. '</fieldset>';
|
||||
}
|
||||
$xml .= PHP_EOL . Indent::_(1) . '</fields>';
|
||||
}
|
||||
$xml .= PHP_EOL . '</form>';
|
||||
|
||||
// add xml to file
|
||||
$this->file->write($fileDetails['path'], $xml);
|
||||
$this->files->appendArray($plugin->key, $fileDetails);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
}
|
||||
|
||||
// set SQL stuff if needed
|
||||
if ($plugin->add_sql || $plugin->add_sql_uninstall)
|
||||
{
|
||||
// create SQL folder
|
||||
$this->folder->create($plugin->folder_path . '/sql');
|
||||
|
||||
// create mysql folder
|
||||
$this->folder->create(
|
||||
$plugin->folder_path . '/sql/mysql'
|
||||
);
|
||||
|
||||
// now set the install file
|
||||
if ($plugin->add_sql)
|
||||
{
|
||||
$this->file->write(
|
||||
$plugin->folder_path . '/sql/mysql/install.sql',
|
||||
$plugin->sql
|
||||
);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
|
||||
// now set the uninstall file
|
||||
if ($plugin->add_sql_uninstall)
|
||||
{
|
||||
$this->file->write(
|
||||
$plugin->folder_path
|
||||
. '/sql/mysql/uninstall.sql',
|
||||
$plugin->sql_uninstall
|
||||
);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
}
|
||||
|
||||
// creat the language folder path
|
||||
$this->folder->create($plugin->folder_path . '/language');
|
||||
|
||||
// also creat the lang tag folder path
|
||||
$this->folder->create(
|
||||
$plugin->folder_path . '/language/' . $this->config->get('lang_tag', 'en-GB')
|
||||
);
|
||||
|
||||
// check if this lib has files
|
||||
if (isset($plugin->files)
|
||||
&& ArrayHelper::check($plugin->files))
|
||||
{
|
||||
// add to component files
|
||||
foreach ($plugin->files as $file)
|
||||
{
|
||||
// set the path finder
|
||||
$file['target_type'] = $plugin->target_type;
|
||||
$file['target_id'] = $plugin->id;
|
||||
$this->component->appendArray('files', $file);
|
||||
}
|
||||
}
|
||||
|
||||
// check if this lib has folders
|
||||
if (isset($plugin->folders)
|
||||
&& ArrayHelper::check($plugin->folders))
|
||||
{
|
||||
// add to component folders
|
||||
foreach ($plugin->folders as $folder)
|
||||
{
|
||||
// set the path finder
|
||||
$folder['target_type'] = $plugin->target_type;
|
||||
$folder['target_id'] = $plugin->id;
|
||||
$this->component->appendArray('folders', $folder);
|
||||
}
|
||||
}
|
||||
|
||||
// check if this plugin has urls
|
||||
if (isset($plugin->urls)
|
||||
&& ArrayHelper::check($plugin->urls))
|
||||
{
|
||||
// add to component urls
|
||||
foreach ($plugin->urls as $n => &$url)
|
||||
{
|
||||
// should we add the local folder
|
||||
if (isset($url['type']) && $url['type'] > 1
|
||||
&& isset($url['url'])
|
||||
&& StringHelper::check(
|
||||
$url['url']
|
||||
))
|
||||
{
|
||||
// set file name
|
||||
$fileName = basename((string) $url['url']);
|
||||
|
||||
// get the file contents
|
||||
$data = FileHelper::getContent(
|
||||
$url['url']
|
||||
);
|
||||
|
||||
// build sub path
|
||||
if (strpos($fileName, '.js') !== false)
|
||||
{
|
||||
$path = '/js';
|
||||
}
|
||||
elseif (strpos($fileName, '.css') !== false)
|
||||
{
|
||||
$path = '/css';
|
||||
}
|
||||
else
|
||||
{
|
||||
$path = '';
|
||||
}
|
||||
|
||||
// create sub media media folder path if not set
|
||||
$this->folder->create(
|
||||
$plugin->folder_path . $path
|
||||
);
|
||||
|
||||
// set the path to plugin file
|
||||
$url['path'] = $plugin->folder_path . $path
|
||||
. '/' . $fileName; // we need this for later
|
||||
|
||||
// write data to path
|
||||
$this->file->write($url['path'], $data);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the plugin xml template
|
||||
*
|
||||
* @param object $module The plugin object
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getXML(object &$plugin): string
|
||||
{
|
||||
$xml = '<?xml version="1.0" encoding="utf-8"?>';
|
||||
$xml .= PHP_EOL . '<extension type="plugin" version="'
|
||||
. $this->config->joomla_versions[$this->config->joomla_version]['xml_version'] . '" group="'
|
||||
. strtolower((string) $plugin->group) . '" method="upgrade">';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<name>' . $plugin->lang_prefix
|
||||
. '</name>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<creationDate>' . Placefix::_h('BUILDDATE') . '</creationDate>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<author>' . Placefix::_h('AUTHOR') . '</author>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<authorEmail>' . Placefix::_h('AUTHOREMAIL') . '</authorEmail>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<authorUrl>' . Placefix::_h('AUTHORWEBSITE') . '</authorUrl>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<copyright>' . Placefix::_h('COPYRIGHT') . '</copyright>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<license>' . Placefix::_h('LICENSE') . '</license>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<version>' . $plugin->plugin_version
|
||||
. '</version>';
|
||||
$xml .= PHP_EOL . Indent::_(1) . '<description>' . $plugin->lang_prefix
|
||||
. '_XML_DESCRIPTION</description>';
|
||||
$xml .= Placefix::_h('MAINXML');
|
||||
$xml .= PHP_EOL . '</extension>';
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -669,17 +669,17 @@ class Data
|
||||
if (!isset($plugin->form_files[$form['file']]))
|
||||
{
|
||||
$plugin->form_files[$form['file']]
|
||||
= array();
|
||||
= [];
|
||||
}
|
||||
if (!isset($plugin->form_files[$form['file']][$form['fields_name']]))
|
||||
{
|
||||
$plugin->form_files[$form['file']][$form['fields_name']]
|
||||
= array();
|
||||
= [];
|
||||
}
|
||||
if (!isset($plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']]))
|
||||
{
|
||||
$plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']]
|
||||
= array();
|
||||
= [];
|
||||
}
|
||||
// do some house cleaning (for fields)
|
||||
foreach ($form['fields'] as $field)
|
||||
@ -701,12 +701,12 @@ class Data
|
||||
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)
|
||||
|
@ -112,11 +112,11 @@ class Extractor
|
||||
// insure string is not broken
|
||||
$content = $this->placeholder->update_($content);
|
||||
// reset some buckets
|
||||
$lang_holders = array();
|
||||
$lang_check = array();
|
||||
$lang_only = array();
|
||||
$js_text = array();
|
||||
$sc_text = array();
|
||||
$lang_holders = [];
|
||||
$lang_check = [];
|
||||
$lang_only = [];
|
||||
$js_text = [];
|
||||
$sc_text = [];
|
||||
// first get the Joomla .JText._()
|
||||
if (in_array('Joomla' . '.JText._(', $lang_string_targets))
|
||||
{
|
||||
|
@ -0,0 +1,318 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Library;
|
||||
|
||||
|
||||
use Joomla\CMS\Filesystem\Folder as JoomlaFolder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Registry;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Component;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Content;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Folder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Utilities\ObjectHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Utilities\FileHelper;
|
||||
|
||||
|
||||
/**
|
||||
* Library Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Builder
|
||||
{
|
||||
/**
|
||||
* Compiler Config
|
||||
*
|
||||
* @var Config
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* The compiler registry
|
||||
*
|
||||
* @var Registry
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Registry $registry;
|
||||
|
||||
/**
|
||||
* Compiler Event
|
||||
*
|
||||
* @var EventInterface
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected EventInterface $event;
|
||||
|
||||
/**
|
||||
* Compiler Component
|
||||
*
|
||||
* @var Component
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Component $component;
|
||||
|
||||
/**
|
||||
* Compiler Content
|
||||
*
|
||||
* @var Content
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Content $content;
|
||||
|
||||
/**
|
||||
* Compiler Counter
|
||||
*
|
||||
* @var Counter
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Counter $counter;
|
||||
|
||||
/**
|
||||
* Compiler Utilities Paths
|
||||
*
|
||||
* @var Paths
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Paths $paths;
|
||||
|
||||
/**
|
||||
* Compiler Utilities Folder
|
||||
*
|
||||
* @var Folder
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Folder $folder;
|
||||
|
||||
/**
|
||||
* Compiler Utilities File
|
||||
*
|
||||
* @var File
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected File $file;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Config|null $config The compiler config object.
|
||||
* @param Registry|null $registry The compiler registry object.
|
||||
* @param EventInterface|null $event The compiler event api object.
|
||||
* @param Component|null $component The component class.
|
||||
* @param Content|null $content The compiler content object.
|
||||
* @param Counter|null $counter The compiler counter object.
|
||||
* @param Paths|null $paths The compiler paths object.
|
||||
* @param Folder|null $folder The compiler folder object.
|
||||
* @param File|null $file The compiler file object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Config $config = null, ?Registry $registry = null,
|
||||
?EventInterface $event = null, ?Component $component = null,
|
||||
?Content $content = null,?Counter $counter = null,
|
||||
?Paths $paths = null, ?Folder $folder = null,
|
||||
?File $file = null)
|
||||
{
|
||||
$this->config = $config ?: Compiler::_('Config');
|
||||
$this->registry = $registry ?: Compiler::_('Registry');
|
||||
$this->event = $event ?: Compiler::_('Event');
|
||||
$this->component = $component ?: Compiler::_('Component');
|
||||
$this->content = $content ?: Compiler::_('Content');
|
||||
$this->counter = $counter ?: Compiler::_('Utilities.Counter');
|
||||
$this->paths = $paths ?: Compiler::_('Utilities.Paths');
|
||||
$this->folder = $folder ?: Compiler::_('Utilities.Folder');
|
||||
$this->file = $file ?: Compiler::_('Utilities.File');
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Libraries files, folders, url's and config
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
if (($libraries_ = $this->registry->get('builder.libraries')) !== null)
|
||||
{
|
||||
// for plugin event TODO change event api signatures
|
||||
$component_context = $this->config->component_context;
|
||||
|
||||
// Trigger Event: jcb_ce_onBeforeSetLibraries
|
||||
$this->event->trigger(
|
||||
'jcb_ce_onBeforeSetLibraries',
|
||||
array(&$component_context, &$libraries_)
|
||||
);
|
||||
|
||||
// creat the main component folder
|
||||
if (!JoomlaFolder::exists($this->paths->component_path))
|
||||
{
|
||||
JoomlaFolder::create($this->paths->component_path);
|
||||
|
||||
// count the folder created
|
||||
$this->counter->folder++;
|
||||
$this->file->html('');
|
||||
}
|
||||
|
||||
// create media path if not set
|
||||
$this->folder->create($this->paths->component_path . '/media');
|
||||
foreach ($libraries_ as $id => &$library)
|
||||
{
|
||||
if (ObjectHelper::check($library))
|
||||
{
|
||||
// check if this lib has files
|
||||
if (isset($library->files)
|
||||
&& ArrayHelper::check($library->files))
|
||||
{
|
||||
// add to component files
|
||||
foreach ($library->files as $file)
|
||||
{
|
||||
$this->component->appendArray('files', $file);
|
||||
}
|
||||
}
|
||||
|
||||
// check if this lib has folders
|
||||
if (isset($library->folders)
|
||||
&& ArrayHelper::check(
|
||||
$library->folders
|
||||
))
|
||||
{
|
||||
// add to component folders
|
||||
foreach ($library->folders as $folder)
|
||||
{
|
||||
$this->component->appendArray('folders', $folder);
|
||||
}
|
||||
}
|
||||
|
||||
// check if this lib has urls
|
||||
if (isset($library->urls)
|
||||
&& ArrayHelper::check($library->urls))
|
||||
{
|
||||
// build media folder path
|
||||
$libFolder = strtolower(
|
||||
preg_replace(
|
||||
'/\s+/', '-',
|
||||
(string) StringHelper::safe(
|
||||
$library->name, 'filename', ' ', false
|
||||
)
|
||||
)
|
||||
);
|
||||
$mediaPath = '/media/' . $libFolder;
|
||||
|
||||
// should we add the local folder
|
||||
$addLocalFolder = false;
|
||||
|
||||
// add to component urls
|
||||
foreach ($library->urls as $n => &$url)
|
||||
{
|
||||
if (isset($url['type']) && $url['type'] > 1
|
||||
&& isset($url['url'])
|
||||
&& StringHelper::check(
|
||||
$url['url']
|
||||
))
|
||||
{
|
||||
// create media/lib path if not set
|
||||
$this->folder->create(
|
||||
$this->paths->component_path . $mediaPath
|
||||
);
|
||||
|
||||
// add local folder
|
||||
$addLocalFolder = true;
|
||||
|
||||
// set file name
|
||||
$fileName = basename((string) $url['url']);
|
||||
|
||||
// get the file contents
|
||||
$data = FileHelper::getContent(
|
||||
$url['url']
|
||||
);
|
||||
|
||||
// build sub path
|
||||
if (strpos($fileName, '.js') !== false)
|
||||
{
|
||||
$path = '/js';
|
||||
}
|
||||
elseif (strpos($fileName, '.css') !== false)
|
||||
{
|
||||
$path = '/css';
|
||||
}
|
||||
else
|
||||
{
|
||||
$path = '';
|
||||
}
|
||||
|
||||
// create sub media path if not set
|
||||
$this->folder->create(
|
||||
$this->paths->component_path . $mediaPath . $path
|
||||
);
|
||||
|
||||
// set the path to library file
|
||||
$url['path'] = $mediaPath . $path . '/'
|
||||
. $fileName; // we need this for later
|
||||
|
||||
// set full path
|
||||
$path = $this->paths->component_path . $url['path'];
|
||||
|
||||
// write data to path
|
||||
$this->file->write($path, $data);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
}
|
||||
|
||||
// only add if local
|
||||
if ($addLocalFolder)
|
||||
{
|
||||
// add folder to xml of media folders
|
||||
$this->content->add('EXSTRA_MEDIA_FOLDERS',
|
||||
PHP_EOL . Indent::_(2) . "<folder>"
|
||||
. $libFolder . "</folder>");
|
||||
}
|
||||
}
|
||||
|
||||
// if config fields are found load into component config (avoiding duplicates)
|
||||
if (isset($library->how) && $library->how > 1
|
||||
&& isset($library->config)
|
||||
&& ArrayHelper::check($library->config))
|
||||
{
|
||||
foreach ($library->config as $cofig)
|
||||
{
|
||||
$found = array_filter(
|
||||
$this->component->get('config'),
|
||||
fn($item) => $item['field'] == $cofig['field']
|
||||
);
|
||||
|
||||
// set the config data if not found
|
||||
if (!ArrayHelper::check($found))
|
||||
{
|
||||
$this->component->appendArray('config', $cofig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update the global value just in case for now
|
||||
$this->registry->set("builder.libraries.$id", $library);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ class Dynamicget
|
||||
// build relationship
|
||||
$_relationship = array_map(
|
||||
function ($op) use (&$_part_of_a) {
|
||||
$bucket = array();
|
||||
$bucket = [];
|
||||
// array(on_field_as, on_field)
|
||||
$bucket['on_field'] = array_map(
|
||||
'trim',
|
||||
@ -386,11 +386,11 @@ class Dynamicget
|
||||
))
|
||||
{
|
||||
// start the part of a table bucket
|
||||
$_part_of_a = array();
|
||||
$_part_of_a = [];
|
||||
// build relationship
|
||||
$_relationship = array_map(
|
||||
function ($op) use (&$_part_of_a) {
|
||||
$bucket = array();
|
||||
$bucket = [];
|
||||
// array(on_field_as, on_field)
|
||||
$bucket['on_field'] = array_map(
|
||||
'trim',
|
||||
|
@ -272,7 +272,7 @@ class Fields
|
||||
&& 'tag' !== $field['settings']->type_name)
|
||||
{
|
||||
// build temp field bucket
|
||||
$tmpfield = array();
|
||||
$tmpfield = [];
|
||||
$tmpfield['settings'] = new \stdClass();
|
||||
|
||||
// convert the xml json string to normal string
|
||||
|
@ -94,8 +94,8 @@ class Sqldump
|
||||
if (ArrayHelper::check($fields))
|
||||
{
|
||||
// reset array buckets
|
||||
$sourceArray = array();
|
||||
$targetArray = array();
|
||||
$sourceArray = [];
|
||||
$targetArray = [];
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
if (strpos($field, "=>") !== false)
|
||||
@ -148,8 +148,8 @@ class Sqldump
|
||||
if (ArrayHelper::check($fields))
|
||||
{
|
||||
// reset array buckets
|
||||
$sourceArray = array();
|
||||
$targetArray = array();
|
||||
$sourceArray = [];
|
||||
$targetArray = [];
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
if (strpos($field, "=>") !== false)
|
||||
|
@ -110,7 +110,7 @@ class Sqltweaking
|
||||
if (2 == $setting['add_sql_options'])
|
||||
{
|
||||
// rest always
|
||||
$id_array = array();
|
||||
$id_array = [];
|
||||
|
||||
// by id (first remove backups)
|
||||
$ids = $setting['ids'];
|
||||
@ -126,7 +126,7 @@ class Sqltweaking
|
||||
{
|
||||
$id_array[] = trim((string) $ids);
|
||||
}
|
||||
$id_array_new = array();
|
||||
$id_array_new = [];
|
||||
|
||||
// check for ranges
|
||||
foreach ($id_array as $key => $id)
|
||||
|
@ -131,7 +131,7 @@ class Reverse
|
||||
if (ArrayHelper::check($lang_string_targets))
|
||||
{
|
||||
// start lang holder
|
||||
$lang_holders = array();
|
||||
$lang_holders = [];
|
||||
// set the lang for both since we don't know what area is being targeted
|
||||
$_tmp = $this->config->lang_target;
|
||||
// set the lang based on target
|
||||
|
@ -542,7 +542,7 @@ class Power implements PowerInterface
|
||||
$this->active[$guid]->use_selection
|
||||
)) ? json_decode((string) $this->active[$guid]->use_selection, true) : null;
|
||||
|
||||
if ($this->active[$guid]->use_selection)
|
||||
if (ArrayHelper::check($this->active[$guid]->use_selection))
|
||||
{
|
||||
$use = array_values(array_map(function ($u) use(&$as) {
|
||||
// track the AS options
|
||||
@ -551,6 +551,10 @@ class Power implements PowerInterface
|
||||
return $u['use'];
|
||||
}, $this->active[$guid]->use_selection));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->active[$guid]->use_selection = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -569,7 +573,7 @@ class Power implements PowerInterface
|
||||
$this->active[$guid]->load_selection
|
||||
)) ? json_decode((string) $this->active[$guid]->load_selection, true) : null;
|
||||
|
||||
if ($this->active[$guid]->load_selection)
|
||||
if (ArrayHelper::check($this->active[$guid]->load_selection))
|
||||
{
|
||||
// load use ids
|
||||
array_map(
|
||||
@ -578,6 +582,10 @@ class Power implements PowerInterface
|
||||
$this->active[$guid]->load_selection
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->active[$guid]->load_selection = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,339 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Power;
|
||||
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Registry;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Folder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Files;
|
||||
use VDM\Joomla\Utilities\ObjectHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
|
||||
|
||||
|
||||
/**
|
||||
* Power Builder Class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Builder
|
||||
{
|
||||
/**
|
||||
* we track the creation of htaccess files
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected array $htaccess = [];
|
||||
|
||||
/**
|
||||
* Power Objects
|
||||
*
|
||||
* @var Power
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Power $power;
|
||||
|
||||
/**
|
||||
* Compiler Config
|
||||
*
|
||||
* @var Config
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* The compiler registry
|
||||
*
|
||||
* @var Registry
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Registry $registry;
|
||||
|
||||
/**
|
||||
* Compiler Event
|
||||
*
|
||||
* @var EventInterface
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected EventInterface $event;
|
||||
|
||||
/**
|
||||
* Compiler Counter
|
||||
*
|
||||
* @var Counter
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Counter $counter;
|
||||
|
||||
/**
|
||||
* Compiler Utilities Paths
|
||||
*
|
||||
* @var Paths
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Paths $paths;
|
||||
|
||||
/**
|
||||
* Compiler Utilities Folder
|
||||
*
|
||||
* @var Folder
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Folder $folder;
|
||||
|
||||
/**
|
||||
* Compiler Utilities File
|
||||
*
|
||||
* @var File
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected File $file;
|
||||
|
||||
/**
|
||||
* Compiler Utilities Files
|
||||
*
|
||||
* @var Files
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Files $files;
|
||||
|
||||
/**
|
||||
* Database object to query local DB
|
||||
*
|
||||
* @var CMSApplication
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected CMSApplication $app;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Power|null $power The power object.
|
||||
* @param Config|null $config The compiler config object.
|
||||
* @param Registry|null $registry The compiler registry object.
|
||||
* @param EventInterface|null $event The compiler event api object.
|
||||
* @param Counter|null $counter The compiler counter object.
|
||||
* @param Paths|null $paths The compiler paths object.
|
||||
* @param Folder|null $folder The compiler folder object.
|
||||
* @param File|null $file The compiler file object.
|
||||
* @param Files|null $files The compiler files object.
|
||||
* @param CMSApplication|null $app The CMS Application object.
|
||||
*
|
||||
* @throws \Exception
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Power $power = null, ?Config $config = null,
|
||||
?Registry $registry = null, ?EventInterface $event = null,
|
||||
?Counter $counter = null, ?Paths $paths = null, ?Folder $folder = null,
|
||||
?File $file = null, ?Files $files = null, ?CMSApplication $app = null)
|
||||
{
|
||||
$this->power = $power ?: Compiler::_('Power');
|
||||
$this->config = $config ?: Compiler::_('Config');
|
||||
$this->registry = $registry ?: Compiler::_('Registry');
|
||||
$this->event = $event ?: Compiler::_('Event');
|
||||
$this->counter = $counter ?: Compiler::_('Utilities.Counter');
|
||||
$this->paths = $paths ?: Compiler::_('Utilities.Paths');
|
||||
$this->folder = $folder ?: Compiler::_('Utilities.Folder');
|
||||
$this->file = $file ?: Compiler::_('Utilities.File');
|
||||
$this->files = $files ?: Compiler::_('Utilities.Files');
|
||||
$this->app = $app ?: Factory::getApplication();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Powers files, folders
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
if (ArrayHelper::check($this->power->active))
|
||||
{
|
||||
// for plugin event TODO change event api signatures
|
||||
$powers = $this->power->active;
|
||||
$component_context = $this->config->component_context;
|
||||
// Trigger Event: jcb_ce_onBeforeSetModules
|
||||
$this->event->trigger(
|
||||
'jcb_ce_onBeforeBuildPowers',
|
||||
array(&$component_context, &$powers)
|
||||
);
|
||||
// for plugin event TODO change event api signatures
|
||||
$this->power->active = $powers;
|
||||
|
||||
foreach ($this->power->active as $power)
|
||||
{
|
||||
if (ObjectHelper::check($power)
|
||||
&& isset($power->path)
|
||||
&& StringHelper::check(
|
||||
$power->path
|
||||
))
|
||||
{
|
||||
// activate dynamic folders
|
||||
$this->setDynamicFolders();
|
||||
|
||||
// power path
|
||||
$power->full_path = $this->paths->component_path . '/'
|
||||
. $power->path;
|
||||
$power->full_path_jcb = $this->paths->component_path . '/'
|
||||
. $power->path_jcb;
|
||||
$power->full_path_parent = $this->paths->component_path . '/'
|
||||
. $power->path_parent;
|
||||
|
||||
// set the power paths
|
||||
$this->registry->set('dynamic_paths.' . $power->key, $power->full_path_parent);
|
||||
|
||||
// create the power folder if it does not exist
|
||||
// we do it like this to add html files to each part
|
||||
$this->folder->create($power->full_path_jcb);
|
||||
$this->folder->create($power->full_path_parent);
|
||||
$this->folder->create($power->full_path);
|
||||
|
||||
// set power file
|
||||
$fileDetails = array('path' => $power->full_path . '/'
|
||||
. $power->file_name . '.php',
|
||||
'name' => $power->file_name . '.php',
|
||||
'zip' => $power->file_name . '.php');
|
||||
$bom = '<?php' . PHP_EOL . '// A POWER FILE' .
|
||||
PHP_EOL . Placefix::_h('BOM') . PHP_EOL;
|
||||
|
||||
// add custom override if found
|
||||
if ($power->add_licensing_template == 2)
|
||||
{
|
||||
$bom = '<?php' . PHP_EOL . $power->licensing_template;
|
||||
}
|
||||
$this->file->write(
|
||||
$fileDetails['path'],
|
||||
$bom . PHP_EOL . Placefix::_h('POWERCODE')
|
||||
. PHP_EOL . Placefix::_h('POWERLINKER')
|
||||
);
|
||||
$this->files->appendArray($power->key, $fileDetails);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
|
||||
// set htaccess once per path
|
||||
$this->setHtaccess($power);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the .htaccess for this power path
|
||||
*
|
||||
* @param object $power The power object
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function setHtaccess(object &$power)
|
||||
{
|
||||
if (!isset($this->htaccess[$power->path_jcb]))
|
||||
{
|
||||
// set the htaccess data
|
||||
$data = '# Apache 2.4+' . PHP_EOL .
|
||||
'<IfModule mod_authz_core.c>' . PHP_EOL .
|
||||
' Require all denied' . PHP_EOL .
|
||||
'</IfModule>' . PHP_EOL . PHP_EOL .
|
||||
'# Apache 2.0-2.2' . PHP_EOL .
|
||||
'<IfModule !mod_authz_core.c>' . PHP_EOL .
|
||||
' Deny from all' . PHP_EOL .
|
||||
'</IfModule>' . PHP_EOL;
|
||||
|
||||
// now we must add the .htaccess file
|
||||
$fileDetails = array('path' => $power->full_path_jcb . '/.htaccess',
|
||||
'name' => '.htaccess',
|
||||
'zip' => '.htaccess');
|
||||
$this->file->write(
|
||||
$fileDetails['path'], $data
|
||||
);
|
||||
$this->files->appendArray($power->key, $fileDetails);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
|
||||
// now we must add the htaccess.txt file where the zip package my not get the [.] files
|
||||
$fileDetails = array('path' => $power->full_path_jcb . '/htaccess.txt',
|
||||
'name' => 'htaccess.txt',
|
||||
'zip' => 'htaccess.txt');
|
||||
$this->file->write(
|
||||
$fileDetails['path'], $data
|
||||
);
|
||||
$this->files->appendArray($power->key, $fileDetails);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
|
||||
// now we must add the web.config file
|
||||
$fileDetails = array('path' => $power->full_path_jcb . '/web.config',
|
||||
'name' => 'web.config',
|
||||
'zip' => 'web.config');
|
||||
$this->file->write(
|
||||
$fileDetails['path'],
|
||||
'<?xml version="1.0"?>' . PHP_EOL .
|
||||
' <system.web>' . PHP_EOL .
|
||||
' <authorization>' . PHP_EOL .
|
||||
' <deny users="*" />' . PHP_EOL .
|
||||
' </authorization>' . PHP_EOL .
|
||||
' </system.web>' . PHP_EOL .
|
||||
'</configuration>' . PHP_EOL
|
||||
);
|
||||
$this->files->appendArray($power->key, $fileDetails);
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
|
||||
// we set these files only once
|
||||
$this->htaccess[$power->path_jcb] = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the dynamic folders
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function setDynamicFolders()
|
||||
{
|
||||
// check if we should add the dynamic folder moving script to the installer script
|
||||
if (!$this->registry->get('set_move_folders_install_script'))
|
||||
{
|
||||
// add the setDynamicF0ld3rs() method to the install scipt.php file
|
||||
$this->registry->set('set_move_folders_install_script', true);
|
||||
|
||||
// set message that this was done (will still add a tutorial link later)
|
||||
$this->app->enqueueMessage(
|
||||
Text::_('COM_COMPONENTBUILDER_HR_HTHREEDYNAMIC_FOLDERS_WERE_DETECTEDHTHREE'),
|
||||
'Notice'
|
||||
);
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('COM_COMPONENTBUILDER_A_METHOD_SETDYNAMICFZEROLDTHREERS_WAS_ADDED_TO_THE_INSTALL_BSCRIPTPHPB_OF_THIS_PACKAGE_TO_INSURE_THAT_THE_FOLDERS_ARE_COPIED_INTO_THE_CORRECT_PLACE_WHEN_THIS_COMPONENT_IS_INSTALLED'),
|
||||
'Notice'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -128,6 +128,11 @@ class Infusion
|
||||
// POWERCODE
|
||||
$this->content->set_($power->key, 'POWERCODE', $this->get($power));
|
||||
|
||||
// POWERLINKER
|
||||
// SOON WE STILL NEED TO THINK THIS OVER
|
||||
// $this->content->set_($power->key, 'POWERLINKER', $this->linker($power));
|
||||
$this->content->set_($power->key, 'POWERLINKER', '');
|
||||
|
||||
// Trigger Event: jcb_ce_onAfterInfusePowerData
|
||||
$this->event->trigger(
|
||||
'jcb_ce_onAfterInfusePowerData',
|
||||
@ -198,10 +203,84 @@ class Infusion
|
||||
$code[] = $power->main_class_code;
|
||||
}
|
||||
|
||||
$code[] = '}' . PHP_EOL . PHP_EOL;
|
||||
$code[] = '}' . PHP_EOL;
|
||||
|
||||
return $this->placeholder->update(implode(PHP_EOL, $code), $this->content->active);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Power Linker
|
||||
*
|
||||
* @param object $power A power object.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function linker(object &$power): string
|
||||
{
|
||||
$map = [];
|
||||
$body = [];
|
||||
|
||||
// set the LINKER
|
||||
$map[] = '/******************| POWER LINKER |*******************|';
|
||||
$map[] = '';
|
||||
$map[] = '{';
|
||||
|
||||
// we build the JSON body
|
||||
$body[] = ' "guid": "' . $power->guid . '"';
|
||||
|
||||
// load extends
|
||||
if (GuidHelper::valid($power->extends))
|
||||
{
|
||||
$body[] = ' "extends": "' . $power->extends . '"';
|
||||
}
|
||||
|
||||
// load implements
|
||||
if (ArrayHelper::check($power->implements))
|
||||
{
|
||||
$sud = [];
|
||||
foreach ($power->implements as $implement)
|
||||
{
|
||||
$sud[] = ' "' . $implement . '"';
|
||||
}
|
||||
$sud = implode(','. PHP_EOL, $sud);
|
||||
|
||||
$body[] = ' "implements": [' . PHP_EOL . $sud . PHP_EOL . ' ]';
|
||||
}
|
||||
|
||||
// load (Use Selection)
|
||||
if (ArrayHelper::check($power->use_selection))
|
||||
{
|
||||
$sud = [];
|
||||
foreach ($power->use_selection as $use)
|
||||
{
|
||||
$sud[] = ' "' . $use['use'] . '"';
|
||||
}
|
||||
$sud = implode(','. PHP_EOL, $sud);
|
||||
|
||||
$body[] = ' "use": [' . PHP_EOL . $sud . PHP_EOL . ' ]';
|
||||
}
|
||||
|
||||
// load (Load Selection)
|
||||
if (ArrayHelper::check($power->load_selection))
|
||||
{
|
||||
$sud = [];
|
||||
foreach ($power->load_selection as $load)
|
||||
{
|
||||
$sud[] = ' "' . $load['load'] . '"';
|
||||
}
|
||||
$sud = implode(','. PHP_EOL, $sud);
|
||||
|
||||
$body[] = ' "load": [' . PHP_EOL . $sud . PHP_EOL . ' ]';
|
||||
}
|
||||
$map[] = implode(','. PHP_EOL, $body);
|
||||
|
||||
$map[] = '}';
|
||||
$map[] = '';
|
||||
$map[] = '|******************| POWER LINKER |*******************/' . PHP_EOL . PHP_EOL;
|
||||
|
||||
return implode(PHP_EOL, $map);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Registry;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Counter;
|
||||
|
||||
|
||||
/**
|
||||
@ -41,9 +40,6 @@ class Compiler implements ServiceProviderInterface
|
||||
|
||||
$container->alias(Registry::class, 'Registry')
|
||||
->share('Registry', [$this, 'getRegistry'], true);
|
||||
|
||||
$container->alias(Counter::class, 'Counter')
|
||||
->share('Counter', [$this, 'getCounter'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,18 +68,5 @@ class Compiler implements ServiceProviderInterface
|
||||
return new Registry();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Counter
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Counter
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getCounter(Container $container): Counter
|
||||
{
|
||||
return new Counter();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\Data as JoomlaModuleData;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\Builder as JoomlaModuleBuilder;
|
||||
|
||||
|
||||
/**
|
||||
@ -36,6 +37,9 @@ class Joomlamodule implements ServiceProviderInterface
|
||||
{
|
||||
$container->alias(JoomlaModuleData::class, 'Joomlamodule.Data')
|
||||
->share('Joomlamodule.Data', [$this, 'getJoomlaModuleData'], true);
|
||||
|
||||
$container->alias(JoomlaModuleBuilder::class, 'Joomlamodule.Builder')
|
||||
->share('Joomlamodule.Builder', [$this, 'getJoomlaModuleBuilder'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -62,5 +66,29 @@ class Joomlamodule implements ServiceProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Joomla Module Builder
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return JoomlaModuleBuilder
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getJoomlaModuleBuilder(Container $container): JoomlaModuleBuilder
|
||||
{
|
||||
return new JoomlaModuleBuilder(
|
||||
$container->get('Joomlamodule.Data'),
|
||||
$container->get('Component'),
|
||||
$container->get('Config'),
|
||||
$container->get('Registry'),
|
||||
$container->get('Customcode.Dispenser'),
|
||||
$container->get('Event'),
|
||||
$container->get('Utilities.Counter'),
|
||||
$container->get('Utilities.Folder'),
|
||||
$container->get('Utilities.File'),
|
||||
$container->get('Utilities.Files')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\Data as JoomlaPluginData;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\Builder as JoomlaPluginBuilder;
|
||||
|
||||
|
||||
/**
|
||||
@ -36,6 +37,9 @@ class Joomlaplugin implements ServiceProviderInterface
|
||||
{
|
||||
$container->alias(JoomlaPluginData::class, 'Joomlaplugin.Data')
|
||||
->share('Joomlaplugin.Data', [$this, 'getJoomlaPluginData'], true);
|
||||
|
||||
$container->alias(JoomlaPluginBuilder::class, 'Joomlaplugin.Builder')
|
||||
->share('Joomlaplugin.Builder', [$this, 'getJoomlaPluginBuilder'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,5 +64,29 @@ class Joomlaplugin implements ServiceProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Joomla Plugin Builder
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return JoomlaPluginBuilder
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getJoomlaPluginBuilder(Container $container): JoomlaPluginBuilder
|
||||
{
|
||||
return new JoomlaPluginBuilder(
|
||||
$container->get('Joomlaplugin.Data'),
|
||||
$container->get('Component'),
|
||||
$container->get('Config'),
|
||||
$container->get('Registry'),
|
||||
$container->get('Customcode.Dispenser'),
|
||||
$container->get('Event'),
|
||||
$container->get('Utilities.Counter'),
|
||||
$container->get('Utilities.Folder'),
|
||||
$container->get('Utilities.File'),
|
||||
$container->get('Utilities.Files')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,8 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service;
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Library\Data as LibraryData;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Library\Data;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Library\Builder;
|
||||
|
||||
|
||||
/**
|
||||
@ -34,8 +35,11 @@ class Library implements ServiceProviderInterface
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(LibraryData::class, 'Library.Data')
|
||||
->share('Library.Data', [$this, 'getLibraryData'], true);
|
||||
$container->alias(Data::class, 'Library.Data')
|
||||
->share('Library.Data', [$this, 'getData'], true);
|
||||
|
||||
$container->alias(Builder::class, 'Library.Builder')
|
||||
->share('Library.Builder', [$this, 'getBuilder'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -43,12 +47,12 @@ class Library implements ServiceProviderInterface
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return LibraryData
|
||||
* @return Data
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getLibraryData(Container $container): LibraryData
|
||||
public function getData(Container $container): Data
|
||||
{
|
||||
return new LibraryData(
|
||||
return new Data(
|
||||
$container->get('Config'),
|
||||
$container->get('Registry'),
|
||||
$container->get('Customcode'),
|
||||
@ -58,5 +62,28 @@ class Library implements ServiceProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Library Builder
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Builder
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getBuilder(Container $container): Builder
|
||||
{
|
||||
return new Builder(
|
||||
$container->get('Config'),
|
||||
$container->get('Registry'),
|
||||
$container->get('Event'),
|
||||
$container->get('Component'),
|
||||
$container->get('Content'),
|
||||
$container->get('Utilities.Counter'),
|
||||
$container->get('Utilities.Paths'),
|
||||
$container->get('Utilities.Folder'),
|
||||
$container->get('Utilities.File')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power as Powers;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Infusion;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Autoloader;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Builder;
|
||||
|
||||
|
||||
/**
|
||||
@ -44,6 +45,9 @@ class Power implements ServiceProviderInterface
|
||||
|
||||
$container->alias(Infusion::class, 'Power.Infusion')
|
||||
->share('Power.Infusion', [$this, 'getInfusion'], true);
|
||||
|
||||
$container->alias(Builder::class, 'Power.Builder')
|
||||
->share('Power.Builder', [$this, 'getBuilder'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,5 +105,28 @@ class Power implements ServiceProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Power Builder
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Builder
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getBuilder(Container $container): Builder
|
||||
{
|
||||
return new Builder(
|
||||
$container->get('Power'),
|
||||
$container->get('Config'),
|
||||
$container->get('Registry'),
|
||||
$container->get('Event'),
|
||||
$container->get('Utilities.Counter'),
|
||||
$container->get('Utilities.Paths'),
|
||||
$container->get('Utilities.Folder'),
|
||||
$container->get('Utilities.File'),
|
||||
$container->get('Utilities.Files')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Service;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Folder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Files;
|
||||
|
||||
|
||||
/**
|
||||
* Utilities Service Provider
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Utilities implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Folder::class, 'Utilities.Folder')
|
||||
->share('Utilities.Folder', [$this, 'getFolder'], true);
|
||||
|
||||
$container->alias(File::class, 'Utilities.File')
|
||||
->share('Utilities.File', [$this, 'getFile'], true);
|
||||
|
||||
$container->alias(Counter::class, 'Utilities.Counter')
|
||||
->share('Utilities.Counter', [$this, 'getCounter'], true);
|
||||
|
||||
$container->alias(Paths::class, 'Utilities.Paths')
|
||||
->share('Utilities.Paths', [$this, 'getPaths'], true);
|
||||
|
||||
$container->alias(Files::class, 'Utilities.Files')
|
||||
->share('Utilities.Files', [$this, 'getFiles'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Folder
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Folder
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getFolder(Container $container): Folder
|
||||
{
|
||||
return new Folder(
|
||||
$container->get('Utilities.Counter'),
|
||||
$container->get('Utilities.File')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler File
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return File
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getFile(Container $container): File
|
||||
{
|
||||
return new File(
|
||||
$container->get('Utilities.Counter')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Counter
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Counter
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getCounter(Container $container): Counter
|
||||
{
|
||||
return new Counter(
|
||||
$container->get('Content')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Paths
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Paths
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getPaths(Container $container): Paths
|
||||
{
|
||||
return new Paths(
|
||||
$container->get('Config'),
|
||||
$container->get('Component')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Files Bucket
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Files
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getFiles(Container $container): Files
|
||||
{
|
||||
return new Files();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler;
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Utilities;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
@ -17,7 +17,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Content;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Counter
|
||||
* Compiler Utilities Counter
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
@ -300,7 +300,6 @@ class Counter
|
||||
$this->timer = $this->end - $this->start;
|
||||
|
||||
// compiler time
|
||||
$this->content->set('COMPILER_TIMER_START', $this->start);
|
||||
$this->content->set('COMPILER_TIMER_END', $this->end);
|
||||
$this->content->set('COMPILER_TIMER', $this->timer);
|
||||
}
|
||||
@ -353,8 +352,6 @@ class Counter
|
||||
|
||||
// compiler time
|
||||
$this->content->set('COMPILER_TIMER_START', $this->start);
|
||||
$this->content->set('COMPILER_TIMER_END', $this->end);
|
||||
$this->content->set('COMPILER_TIMER', $this->timer);
|
||||
}
|
||||
|
||||
/**
|
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2020
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Utilities;
|
||||
|
||||
|
||||
use Joomla\CMS\Filesystem\File as JoomlaFile;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths;
|
||||
use VDM\Joomla\Utilities\FileHelper;
|
||||
|
||||
|
||||
/**
|
||||
* File helper
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class File
|
||||
{
|
||||
/**
|
||||
* Compiler Utilities Counter
|
||||
*
|
||||
* @var Counter
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Counter $counter;
|
||||
|
||||
/**
|
||||
* Compiler Utilities Paths
|
||||
*
|
||||
* @var Paths
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Paths $paths;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Counter|null $counter The compiler counter object.
|
||||
* @param Paths|null $paths The compiler paths object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Counter $counter = null, ?Paths $paths = null)
|
||||
{
|
||||
$this->counter = $counter ?: Compiler::_('Utilities.Counter');
|
||||
$this->paths = $paths ?: Compiler::_('Utilities.Paths');
|
||||
}
|
||||
|
||||
/**
|
||||
* set HTML blank file to a path
|
||||
*
|
||||
* @param string $path The path to where to set the blank html file
|
||||
* @param string $root The root path
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function html(string $path = '', string $root = 'component')
|
||||
{
|
||||
if ('component' === $root)
|
||||
{
|
||||
$root = $this->paths->component_path . '/';
|
||||
}
|
||||
|
||||
// use path if exist
|
||||
if (strlen($path) > 0)
|
||||
{
|
||||
JoomlaFile::copy(
|
||||
$this->paths->template_path . '/index.html',
|
||||
$root . $path . '/index.html'
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
JoomlaFile::copy(
|
||||
$this->paths->template_path . '/index.html',
|
||||
$root . '/index.html'
|
||||
);
|
||||
}
|
||||
|
||||
// count the file created
|
||||
$this->counter->file++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a file on the server if it does not exist, or Overwrite existing files
|
||||
*
|
||||
* @param string $path The path and file name where to safe the data
|
||||
* @param string $data The data to safe
|
||||
*
|
||||
* @return bool true On success
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function write(string $path, string $data): bool
|
||||
{
|
||||
return FileHelper::write($path, $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Utilities;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Abstraction\BaseRegistry;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Utilities Files Bucket
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Files extends BaseRegistry
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1,172 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2020
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Utilities;
|
||||
|
||||
|
||||
use Joomla\CMS\Filesystem\Folder as JoomlaFolder;
|
||||
use Joomla\CMS\Filesystem\File as JoomlaFile;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\File;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
|
||||
|
||||
/**
|
||||
* Folder helper
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Folder
|
||||
{
|
||||
/**
|
||||
* Compiler Counter
|
||||
*
|
||||
* @var Counter
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Counter $counter;
|
||||
|
||||
/**
|
||||
* Compiler Utilities File
|
||||
*
|
||||
* @var File
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected File $file;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Counter|null $counter The compiler counter object.
|
||||
* @param File|null $file The compiler file object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Counter $counter = null, ?File $file = null)
|
||||
{
|
||||
$this->counter = $counter ?: Compiler::_('Utilities.Counter');
|
||||
$this->file = $file ?: Compiler::_('Utilities.File');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Path if not exist
|
||||
*
|
||||
* @param string $path The path to folder to create
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function create(string $path)
|
||||
{
|
||||
// check if the path exist
|
||||
if (!JoomlaFolder::exists($path))
|
||||
{
|
||||
// create the path
|
||||
JoomlaFolder::create(
|
||||
$path
|
||||
);
|
||||
|
||||
// count the folder created
|
||||
$this->counter->folder++;
|
||||
|
||||
// add index.html (boring I know)
|
||||
$this->file->html(
|
||||
$path, ''
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove folders with files
|
||||
*
|
||||
* @param string $path The path to folder to remove
|
||||
* @param array|null $ignore The folders and files to ignore and not remove
|
||||
*
|
||||
* @return boolean True if all are removed
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function remove(string $path, ?array $ignore = null): bool
|
||||
{
|
||||
if (JoomlaFolder::exists($path))
|
||||
{
|
||||
$it = new \RecursiveDirectoryIterator($path);
|
||||
$it = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST);
|
||||
|
||||
// remove ending /
|
||||
$path = rtrim($path, '/');
|
||||
|
||||
// now loop the files & folders
|
||||
foreach ($it as $file)
|
||||
{
|
||||
if ('.' === $file->getBasename() || '..' === $file->getBasename()) continue;
|
||||
|
||||
// set file dir
|
||||
$file_dir = $file->getPathname();
|
||||
|
||||
// check if this is a dir or a file
|
||||
if ($file->isDir())
|
||||
{
|
||||
$keeper = false;
|
||||
if (ArrayHelper::check($ignore))
|
||||
{
|
||||
foreach ($ignore as $keep)
|
||||
{
|
||||
if (strpos((string) $file_dir, $path . '/' . $keep) !== false)
|
||||
{
|
||||
$keeper = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($keeper)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
JoomlaFolder::delete($file_dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
$keeper = false;
|
||||
if (ArrayHelper::check($ignore))
|
||||
{
|
||||
foreach ($ignore as $keep)
|
||||
{
|
||||
if (strpos((string) $file_dir, $path . '/'. $keep) !== false)
|
||||
{
|
||||
$keeper = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($keeper)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
JoomlaFile::delete($file_dir);
|
||||
}
|
||||
}
|
||||
|
||||
// delete the root folder if ignore not set
|
||||
if (!ArrayHelper::check($ignore))
|
||||
{
|
||||
return JoomlaFolder::delete($path);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ abstract class Path
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static function fix(&$values, $targets = array())
|
||||
public static function fix(&$values, $targets = [])
|
||||
{
|
||||
// if multiple to gets searched and fixed
|
||||
if (ArrayHelper::check($values) && ArrayHelper::check($targets))
|
||||
|
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Utilities;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Component;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Mappersingleinterface;
|
||||
use VDM\Joomla\Componentbuilder\Abstraction\MapperSingle;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Utilities Paths
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Paths extends MapperSingle implements Mappersingleinterface
|
||||
{
|
||||
/**
|
||||
* Compiler Config
|
||||
*
|
||||
* @var Config
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* Compiler Component
|
||||
*
|
||||
* @var Component
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Component $component;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Config|null $config The compiler config object.
|
||||
* @param Component|null $component The component class.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Config $config = null, ?Component $component = null)
|
||||
{
|
||||
$this->config = $config ?: Compiler::_('Config');
|
||||
$this->component = $component ?: Compiler::_('Component');
|
||||
|
||||
// set the template path
|
||||
$this->set('template_path',
|
||||
$this->config->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/joomla_'
|
||||
. $this->config->joomla_versions[$this->config->joomla_version]['folder_key']
|
||||
);
|
||||
|
||||
// set component sales name
|
||||
$this->set('component_sales_name',
|
||||
'com_' . $this->component->get('sales_name') . '__J'
|
||||
. $this->config->joomla_version
|
||||
);
|
||||
|
||||
// set component backup name
|
||||
$this->set('component_backup_name',
|
||||
'com_' . $this->component->get('sales_name') . '_v' . str_replace(
|
||||
'.', '_', (string) $this->component->get('component_version')
|
||||
) . '__J' . $this->config->joomla_version
|
||||
);
|
||||
|
||||
// set component folder name
|
||||
$this->set('component_folder_name',
|
||||
'com_' . $this->component->get('name_code') . '_v' . str_replace(
|
||||
'.', '_', (string) $this->component->get('component_version')
|
||||
) . '__J' . $this->config->joomla_version
|
||||
);
|
||||
|
||||
// set component path
|
||||
$this->set('component_path',
|
||||
$this->config->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
|
||||
. $this->get('component_folder_name')
|
||||
);
|
||||
|
||||
// set the template path for custom TODO: just use custom_folder_path in config
|
||||
$this->set('template_path_custom',
|
||||
$this->config->get(
|
||||
'custom_folder_path', JPATH_COMPONENT_ADMINISTRATOR . '/custom'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* getting any valid paths
|
||||
*
|
||||
* @param string $key The value's key/path name
|
||||
*
|
||||
* @return string The path found as a string
|
||||
* @since 3.2.0
|
||||
* @throws \InvalidArgumentException If $key is not a valid function name.
|
||||
*/
|
||||
public function __get(string $key): string
|
||||
{
|
||||
// check if it has been set
|
||||
if ($this->exist($key))
|
||||
{
|
||||
return $this->get($key);
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(sprintf('Path %s could not be found in the Paths Class.', $key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Model the key
|
||||
*
|
||||
* @param string $key The key to model
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function key(string $key): string
|
||||
{
|
||||
return $key;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,11 +45,13 @@ abstract class Unique
|
||||
*/
|
||||
public static function get($size): string
|
||||
{
|
||||
$unique = end(self::$unique[$size]);
|
||||
$unique = (isset(self::$unique[$size])) ? end(self::$unique[$size]) : null;
|
||||
|
||||
if(!$unique)
|
||||
{
|
||||
$unique = substr("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv", 0, $size);
|
||||
|
||||
self::$unique[$size] = [];
|
||||
}
|
||||
|
||||
while(in_array($unique, self::$unique[$size]))
|
||||
|
@ -119,7 +119,7 @@ class Ftp implements Serverinterface
|
||||
}
|
||||
else
|
||||
{
|
||||
$options = array();
|
||||
$options = [];
|
||||
}
|
||||
// get ftp object
|
||||
if (isset($host) && $host != 'HOSTNAME' &&
|
||||
|
@ -37,7 +37,7 @@ abstract class ArrayHelper
|
||||
{
|
||||
$array = array_filter($array);
|
||||
|
||||
if (empty($array))
|
||||
if ($array === [])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ abstract class FileHelper
|
||||
*
|
||||
* @since 3.0.9
|
||||
*/
|
||||
public static function zip($workingDirectory, &$filepath)
|
||||
public static function zip($workingDirectory, &$filepath): bool
|
||||
{
|
||||
// store the current joomla working directory
|
||||
$joomla = getcwd();
|
||||
@ -65,11 +65,11 @@ abstract class FileHelper
|
||||
// get a list of files in the current directory tree (also the hidden files)
|
||||
$files = Folder::files('.', '', true, true, array('.svn', 'CVS', '.DS_Store', '__MACOSX'), array('.*~'));
|
||||
|
||||
$zipArray = array();
|
||||
$zipArray = [];
|
||||
// setup the zip array
|
||||
foreach ($files as $file)
|
||||
{
|
||||
$tmp = array();
|
||||
$tmp = [];
|
||||
$tmp['name'] = str_replace('./', '', (string) $file);
|
||||
$tmp['data'] = self::getContent($file);
|
||||
$tmp['time'] = filemtime($file);
|
||||
@ -80,15 +80,10 @@ abstract class FileHelper
|
||||
chdir($joomla);
|
||||
|
||||
// get the zip adapter
|
||||
$adapter = new Archive();
|
||||
$zip = $adapter->getAdapter('zip');
|
||||
$zip = (new Archive())->getAdapter('zip');
|
||||
|
||||
//create the zip file
|
||||
if ($zip->create($filepath, $zipArray))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (bool) $zip->create($filepath, $zipArray);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,7 +111,7 @@ abstract class FileHelper
|
||||
// start curl
|
||||
$ch = curl_init();
|
||||
// set the options
|
||||
$options = array();
|
||||
$options = [];
|
||||
$options[CURLOPT_URL] = $path;
|
||||
$options[CURLOPT_USERAGENT] = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12';
|
||||
$options[CURLOPT_RETURNTRANSFER] = TRUE;
|
||||
|
@ -67,7 +67,7 @@ abstract class JsonHelper
|
||||
{
|
||||
if (StringHelper::check($table))
|
||||
{
|
||||
$names = array();
|
||||
$names = [];
|
||||
foreach ($result as $val)
|
||||
{
|
||||
if ($external)
|
||||
|
@ -31,7 +31,7 @@ abstract class ClassfunctionHelper
|
||||
*
|
||||
* @since 3.0.9
|
||||
*/
|
||||
public static function safe($name)
|
||||
public static function safe($name): string
|
||||
{
|
||||
// remove numbers if the first character is a number
|
||||
if (is_numeric(substr((string) $name, 0, 1)))
|
||||
|
@ -399,7 +399,7 @@ abstract class StringHelper
|
||||
public static function random($size): string
|
||||
{
|
||||
$bag = "abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ";
|
||||
$key = array();
|
||||
$key = [];
|
||||
$bagsize = strlen($bag) - 1;
|
||||
|
||||
for ($i = 0; $i < $size; $i++)
|
||||
|
@ -32,14 +32,14 @@ abstract class Minify
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $data = array();
|
||||
protected $data = [];
|
||||
|
||||
/**
|
||||
* Array of patterns to match.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $patterns = array();
|
||||
protected $patterns = [];
|
||||
|
||||
/**
|
||||
* This array will hold content of strings and regular expressions that have
|
||||
@ -50,7 +50,7 @@ abstract class Minify
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
public $extracted = array();
|
||||
public $extracted = [];
|
||||
|
||||
/**
|
||||
* Init the minify class - optionally, code may be passed along already.
|
||||
@ -279,7 +279,7 @@ abstract class Minify
|
||||
$output = '';
|
||||
$processedOffset = 0;
|
||||
$positions = array_fill(0, count($this->patterns), -1);
|
||||
$matches = array();
|
||||
$matches = [];
|
||||
|
||||
while ($processedOffset < $contentLength) {
|
||||
// find first match for all patterns
|
||||
@ -435,7 +435,7 @@ abstract class Minify
|
||||
|
||||
$content = strtr($content, $this->extracted);
|
||||
|
||||
$this->extracted = array();
|
||||
$this->extracted = [];
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
@ -171,15 +171,15 @@ class Css extends Minify
|
||||
);
|
||||
|
||||
// find all relative imports in css
|
||||
$matches = array();
|
||||
$matches = [];
|
||||
foreach ($importRegexes as $importRegex) {
|
||||
if (preg_match_all($importRegex, $content, $regexMatches, PREG_SET_ORDER)) {
|
||||
$matches = [...$matches, ...$regexMatches];
|
||||
}
|
||||
}
|
||||
|
||||
$search = array();
|
||||
$replace = array();
|
||||
$search = [];
|
||||
$replace = [];
|
||||
|
||||
// loop the matches
|
||||
foreach ($matches as $match) {
|
||||
@ -234,8 +234,8 @@ class Css extends Minify
|
||||
{
|
||||
$regex = '/url\((["\']?)(.+?)\\1\)/i';
|
||||
if ($this->importExtensions && preg_match_all($regex, $content, $matches, PREG_SET_ORDER)) {
|
||||
$search = array();
|
||||
$replace = array();
|
||||
$search = [];
|
||||
$replace = [];
|
||||
|
||||
// loop the matches
|
||||
foreach ($matches as $match) {
|
||||
@ -277,7 +277,7 @@ class Css extends Minify
|
||||
*
|
||||
* @return string The minified data
|
||||
*/
|
||||
public function execute($path = null, $parents = array())
|
||||
public function execute($path = null, $parents = [])
|
||||
{
|
||||
$content = '';
|
||||
|
||||
@ -387,15 +387,15 @@ class Css extends Minify
|
||||
);
|
||||
|
||||
// find all relative urls in css
|
||||
$matches = array();
|
||||
$matches = [];
|
||||
foreach ($relativeRegexes as $relativeRegex) {
|
||||
if (preg_match_all($relativeRegex, $content, $regexMatches, PREG_SET_ORDER)) {
|
||||
$matches = [...$matches, ...$regexMatches];
|
||||
}
|
||||
}
|
||||
|
||||
$search = array();
|
||||
$replace = array();
|
||||
$search = [];
|
||||
$replace = [];
|
||||
|
||||
// loop all urls
|
||||
foreach ($matches as $match) {
|
||||
|
@ -114,10 +114,10 @@ class Converter implements ConverterInterface
|
||||
// $path could theoretically be empty (e.g. no path is given), in which
|
||||
// case it shouldn't expand to array(''), which would compare to one's
|
||||
// root /
|
||||
$path1 = $path1 ? explode('/', $path1) : array();
|
||||
$path2 = $path2 ? explode('/', $path2) : array();
|
||||
$path1 = $path1 ? explode('/', $path1) : [];
|
||||
$path2 = $path2 ? explode('/', $path2) : [];
|
||||
|
||||
$shared = array();
|
||||
$shared = [];
|
||||
|
||||
// compare paths & strip identical ancestors
|
||||
foreach ($path1 as $i => $chunk) {
|
||||
|
@ -3,6 +3,7 @@ COM_COMPONENTBUILDER_ACCESS_DENIED="Access denied!"
|
||||
COM_COMPONENTBUILDER_ALL_UNSAVED_WORK_ON_THIS_PAGE_WILL_BE_LOST_ARE_YOU_SURE_YOU_WANT_TO_CONTINUE="All unsaved work on this page will be lost, are you sure you want to continue?"
|
||||
COM_COMPONENTBUILDER_API="Api"
|
||||
COM_COMPONENTBUILDER_API_DESC="Sync Portal API"
|
||||
COM_COMPONENTBUILDER_A_METHOD_SETDYNAMICFZEROLDTHREERS_WAS_ADDED_TO_THE_INSTALL_BSCRIPTPHPB_OF_THIS_PACKAGE_TO_INSURE_THAT_THE_FOLDERS_ARE_COPIED_INTO_THE_CORRECT_PLACE_WHEN_THIS_COMPONENT_IS_INSTALLED="A method (setDynamicF0ld3rs) was added to the install <b>script.php</b> of this package to insure that the folder(s) are copied into the correct place when this component is installed!"
|
||||
COM_COMPONENTBUILDER_BACKUP_FAILED_PLEASE_TRY_AGAIN_IF_THE_ERROR_CONTINUE_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR="Backup failed, please try again. If the error continue, please contact your system administrator."
|
||||
COM_COMPONENTBUILDER_BACKUP_WAS_DONE_SUCCESSFULLY="Backup was done successfully"
|
||||
COM_COMPONENTBUILDER_BE_CAUTIOUS_DO_NOT_CONTINUE_UNLESS_YOU_TRUST_THE_ORIGIN_OF_THIS_PACKAGE="Be cautious! Do not continue unless you trust the origin of this package!"
|
||||
@ -43,6 +44,7 @@ COM_COMPONENTBUILDER_GREAT_THIS_PLACEHOLDER_WILL_WORK="Great, this placeholder w
|
||||
COM_COMPONENTBUILDER_HFOUR_CLASSNAVHEADERCOPYRIGHTHFOURPSP="<h4 class="nav-header">Copyright</h4><p>%s</p>"
|
||||
COM_COMPONENTBUILDER_HFOUR_CLASSNAVHEADERLICENSEHFOURPSP="<h4 class="nav-header">License</h4><p>%s</p>"
|
||||
COM_COMPONENTBUILDER_HR_HTHREECUSTOM_CODES_WARNINGHTHREE="<hr /><h3>Custom Codes Warning</h3>"
|
||||
COM_COMPONENTBUILDER_HR_HTHREEDYNAMIC_FOLDERS_WERE_DETECTEDHTHREE="<hr /><h3>Dynamic folder(s) were detected.</h3>"
|
||||
COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_ERRORHTHREE="<hr /><h3>External Code Error</h3>"
|
||||
COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_NOTICEHTHREE="<hr /><h3>External Code Notice</h3>"
|
||||
COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_WARNINGHTHREE="<hr /><h3>External Code Warning</h3>"
|
||||
|
Loading…
Reference in New Issue
Block a user