Move the whole compiler GET of the component object to now use the container->component object/class.

This commit is contained in:
Llewellyn van der Merwe 2023-01-22 02:38:21 +02:00
parent f44f385159
commit e6c02a29f6
Signed by: Llewellyn
GPG Key ID: A9201372263741E7
115 changed files with 13148 additions and 6292 deletions

View File

@ -140,14 +140,14 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder) + *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 15th January, 2023 + *Last Build*: 22nd January, 2023
+ *Version*: 3.1.13 + *Version*: 3.1.13
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt + *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **345248** + *Line count*: **357633**
+ *Field count*: **2009** + *Field count*: **2009**
+ *File count*: **2240** + *File count*: **2304**
+ *Folder count*: **399** + *Folder count*: **408**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com). > This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com).
> Developed by [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) > Developed by [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)

View File

@ -140,14 +140,14 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder) + *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 15th January, 2023 + *Last Build*: 22nd January, 2023
+ *Version*: 3.1.13 + *Version*: 3.1.13
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt + *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **345248** + *Line count*: **357633**
+ *Field count*: **2009** + *Field count*: **2009**
+ *File count*: **2240** + *File count*: **2304**
+ *Folder count*: **399** + *Folder count*: **408**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com). > This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com).
> Developed by [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) > Developed by [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)

View File

@ -171,19 +171,19 @@ class ComponentbuilderControllerCompiler extends AdminController
} }
$message[] = '<h2>Total time saved</h2>'; $message[] = '<h2>Total time saved</h2>';
$message[] = '<ul>'; $message[] = '<ul>';
$message[] = '<li>Total folders created: <b>'.$model->compiler->folderCount.'</b></li>'; $message[] = '<li>Total folders created: <b>#'.'##FOLDER_COUNT##'.'#</b></li>';
$message[] = '<li>Total files created: <b>'.$model->compiler->fileCount.'</b></li>'; $message[] = '<li>Total files created: <b>#'.'##FILE_COUNT##'.'#</b></li>';
$message[] = '<li>Total fields created: <b>'.$model->compiler->fieldCount.'</b></li>'; $message[] = '<li>Total fields created: <b>#'.'##FIELD_COUNT##'.'#</b></li>';
$message[] = '<li>Total lines written: <b>'.$model->compiler->lineCount.'</b></li>'; $message[] = '<li>Total lines written: <b>#'.'##LINE_COUNT##'.'#</b></li>';
$message[] = '<li>A4 Book of: <b>'.$model->compiler->pageCount.' pages</b></li>'; $message[] = '<li>A4 Book of: <b>#'.'##PAGE_COUNT##'.'# pages</b></li>';
$message[] = '</ul>'; $message[] = '</ul>';
$message[] = '<p><b>'.$model->compiler->totalHours.' Hours</b> or <b>'.$model->compiler->totalDays.' Eight Hour Days</b> <em>(actual time you saved)</em><br />'; $message[] = '<p><b>#'.'##totalHours##'.'# Hours</b> or <b>#'.'##totalDays##'.'# Eight Hour Days</b> <em>(actual time you saved)</em><br />';
$message[] = '<small>(if creating a folder and file took <b>5 seconds</b> and writing one line of code took <b>10 seconds</b>, never making one mistake or taking any coffee break.)</small><br />'; $message[] = '<small>(if creating a folder and file took <b>5 seconds</b> and writing one line of code took <b>10 seconds</b>, never making one mistake or taking any coffee break.)</small><br />';
$message[] = '<b>'.$model->compiler->actualHoursSpent.' Hours</b> or <b>'.$model->compiler->actualDaysSpent.' Eight Hour Days</b> <em>(the actual time you spent)</em><br />'; $message[] = '<b>#'.'##actualHoursSpent##'.'# Hours</b> or <b>#'.'##actualDaysSpent##'.'# Eight Hour Days</b> <em>(the actual time you spent)</em><br />';
$message[] = '<small>(with the following break down: <b>debugging @'.$model->compiler->debuggingHours.'hours</b> = codingtime / 4; <b>planning @'.$model->compiler->planningHours.'hours</b> = codingtime / 7; <b>mapping @'.$model->compiler->mappingHours.'hours</b> = codingtime / 10; <b>office @'.$model->compiler->officeHours.'hours</b> = codingtime / 6;)</small></p>'; $message[] = '<small>(with the following break down: <b>debugging @#'.'##debuggingHours##'.'#hours</b> = codingtime / 4; <b>planning @#'.'##planningHours##'.'#hours</b> = codingtime / 7; <b>mapping @#'.'##mappingHours##'.'#hours</b> = codingtime / 10; <b>office @#'.'##officeHours##'.'#hours</b> = codingtime / 6;)</small></p>';
$message[] = '<p><b>'.$model->compiler->actualTotalHours.' Hours</b> or <b>'.$model->compiler->actualTotalDays.' Eight Hour Days</b> <em>(a total of the realistic time frame for this project)</em><br />'; $message[] = '<p><b>#'.'##actualTotalHours##'.'# Hours</b> or <b>#'.'##actualTotalDays##'.'# Eight Hour Days</b> <em>(a total of the realistic time frame for this project)</em><br />';
$message[] = '<small>(if creating a folder and file took <b>5 seconds</b> and writing one line of code took <b>10 seconds</b>, with the normal everyday realities at the office, that includes the component planning, mapping & debugging.)</small></p>'; $message[] = '<small>(if creating a folder and file took <b>5 seconds</b> and writing one line of code took <b>10 seconds</b>, with the normal everyday realities at the office, that includes the component planning, mapping & debugging.)</small></p>';
$message[] = '<p>Project duration: <b>'.$model->compiler->projectWeekTime. ' weeks</b> or <b>'.$model->compiler->projectMonthTime.' months</b></p>'; $message[] = '<p>Project duration: <b>'.$model->compiler->projectWeekTime. ' weeks</b> or <b>#'.'##projectMonthTime##'.'# months</b></p>';
// check if we have modules or plugins // check if we have modules or plugins
if ($add_multi_install) if ($add_multi_install)
{ {
@ -254,9 +254,14 @@ class ComponentbuilderControllerCompiler extends AdminController
$message[] = '<a class="btn btn-success" href="' . $url . '" ><span class="icon-download icon-white"></span>Download</a></p>'; $message[] = '<a class="btn btn-success" href="' . $url . '" ><span class="icon-download icon-white"></span>Download</a></p>';
$message[] = '<p><small><b>Remember!</b> This zip file is in your tmp folder and therefore publicly accessible until you click [Clear tmp]!</small> </p>'; $message[] = '<p><small><b>Remember!</b> This zip file is in your tmp folder and therefore publicly accessible until you click [Clear tmp]!</small> </p>';
} }
$message[] = '<p><small>Compilation took <b>'.$model->compiler->secondsCompiled.'</b> seconds to complete.</small> </p>'; $message[] = '<p><small>Compilation took <b>#'.'##COMPILER_TIMER##'.'#</b> seconds to complete.</small> </p>';
// pass the message via the user state... wow this is painful // pass the message via the user state... wow this is painful
$app->setUserState('com_componentbuilder.success_message', implode(PHP_EOL, $message)); $app->setUserState('com_componentbuilder.success_message',
CFactory::_('Placeholder')->update(
implode(PHP_EOL, $message),
CFactory::_('Content')->active
)
);
// set redirect // set redirect
$this->setRedirect($redirect_url, '<h2>Successful Build!</h2>', 'message'); $this->setRedirect($redirect_url, '<h2>Successful Build!</h2>', 'message');
$app->setUserState('com_componentbuilder.component_folder_name', $model->compiler->filepath['component-folder']); $app->setUserState('com_componentbuilder.component_folder_name', $model->compiler->filepath['component-folder']);

View File

@ -31,6 +31,7 @@ ComponentbuilderHelper::autoLoader();
/** /**
* Compiler class * Compiler class
* @deprecated 3.3
*/ */
class Compiler extends Infusion class Compiler extends Infusion
{ {
@ -79,7 +80,8 @@ class Compiler extends Infusion
{ {
// to check the compiler speed // to check the compiler speed
$this->time_start = microtime(true); $this->time_start = microtime(true);
// first we run the perent constructors CFactory::_('Counter')->start();
// first we run the parent constructors
if (parent::__construct()) if (parent::__construct())
{ {
// set temp directory // set temp directory
@ -271,8 +273,6 @@ class Compiler extends Infusion
} }
// move the update server into place // move the update server into place
$this->setUpdateServer(); $this->setUpdateServer();
// set the global counters
$this->setCountingStuff();
// build read me // build read me
$this->buildReadMe(); $this->buildReadMe();
// set local repos // set local repos
@ -363,6 +363,7 @@ class Compiler extends Infusion
// end the timer here // end the timer here
$this->time_end = microtime(true); $this->time_end = microtime(true);
$this->secondsCompiled = $this->time_end - $this->time_start; $this->secondsCompiled = $this->time_end - $this->time_start;
CFactory::_('Counter')->end();
// completed the compilation // completed the compilation
return true; return true;
@ -424,9 +425,9 @@ class Compiler extends Infusion
// free up some memory // free up some memory
unset($this->newFiles['dynamic']); unset($this->newFiles['dynamic']);
// do modules if found // do modules if found
if (ArrayHelper::check($this->joomlaModules)) if (CFactory::_('Joomlamodule.Data')->exists())
{ {
foreach ($this->joomlaModules as $module) foreach (CFactory::_('Joomlamodule.Data')->get() as $module)
{ {
if (ObjectHelper::check($module) if (ObjectHelper::check($module)
&& isset($this->newFiles[$module->key]) && isset($this->newFiles[$module->key])
@ -505,9 +506,9 @@ class Compiler extends Infusion
} }
} }
// do plugins if found // do plugins if found
if (ArrayHelper::check($this->joomlaPlugins)) if (CFactory::_('Joomlaplugin.Data')->exists())
{ {
foreach ($this->joomlaPlugins as $plugin) foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin)
{ {
if (ObjectHelper::check($plugin) if (ObjectHelper::check($plugin)
&& isset($this->newFiles[$plugin->key]) && isset($this->newFiles[$plugin->key])
@ -682,7 +683,7 @@ class Compiler extends Infusion
// add answer back to file // add answer back to file
$this->writeFile($path, $answer); $this->writeFile($path, $answer);
// count the file lines // count the file lines
$this->lineCount = $this->lineCount + substr_count((string) $answer, PHP_EOL); CFactory::_('Counter')->line += substr_count((string) $answer, PHP_EOL);
} }
/** /**
@ -694,8 +695,7 @@ class Compiler extends Infusion
protected function setUpdateServer() protected function setUpdateServer()
{ {
// move the component update server to host // move the component update server to host
if ($this->componentData->add_update_server == 1 if (CFactory::_('Component')->get('add_update_server', 0) == 1
&& $this->componentData->update_server_target == 1
&& isset($this->updateServerFileName) && isset($this->updateServerFileName)
&& $this->dynamicIntegration) && $this->dynamicIntegration)
{ {
@ -703,23 +703,23 @@ class Compiler extends Infusion
. $this->updateServerFileName . '.xml'; . $this->updateServerFileName . '.xml';
// make sure we have the correct file // make sure we have the correct file
if (File::exists($update_server_xml_path) if (File::exists($update_server_xml_path)
&& isset($this->componentData->update_server)) && ($update_server = CFactory::_('Component')->get('update_server')) !== null)
{ {
// move to server // move to server
ComponentbuilderHelper::moveToServer( ComponentbuilderHelper::moveToServer(
$update_server_xml_path, $update_server_xml_path,
$this->updateServerFileName . '.xml', $this->updateServerFileName . '.xml',
(int) $this->componentData->update_server, (int) $update_server,
$this->componentData->update_server_protocol CFactory::_('Component')->get('update_server_protocol')
); );
// remove the local file // remove the local file
File::delete($update_server_xml_path); File::delete($update_server_xml_path);
} }
} }
// move the modules update server to host // move the modules update server to host
if (ArrayHelper::check($this->joomlaModules)) if (CFactory::_('Joomlamodule.Data')->exists())
{ {
foreach ($this->joomlaModules as $module) foreach (CFactory::_('Joomlamodule.Data')->get() as $module)
{ {
if (ObjectHelper::check($module) if (ObjectHelper::check($module)
&& isset($module->add_update_server) && isset($module->add_update_server)
@ -750,9 +750,9 @@ class Compiler extends Infusion
} }
} }
// move the plugins update server to host // move the plugins update server to host
if (ArrayHelper::check($this->joomlaPlugins)) if (CFactory::_('Joomlaplugin.Data')->exists())
{ {
foreach ($this->joomlaPlugins as $plugin) foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin)
{ {
if (ObjectHelper::check($plugin) if (ObjectHelper::check($plugin)
&& isset($plugin->add_update_server) && isset($plugin->add_update_server)
@ -791,7 +791,7 @@ class Compiler extends Infusion
&& ArrayHelper::check( && ArrayHelper::check(
$data['config'] $data['config']
) )
&& $this->componentData->mvc_versiondate == 1) && CFactory::_('Component')->get('mvc_versiondate', 0) == 1)
{ {
foreach ($data['config'] as $key => $value) foreach ($data['config'] as $key => $value)
{ {
@ -820,40 +820,23 @@ class Compiler extends Infusion
CFactory::_('Content')->set('VERSION', CFactory::_('Content')->get('GLOBALVERSION')); CFactory::_('Content')->set('VERSION', CFactory::_('Content')->get('GLOBALVERSION'));
} }
// set all global numbers /**
* Set all global numbers
*
* @return void
* @deprecated 3.3
*/
protected function setCountingStuff() protected function setCountingStuff()
{ {
// what is the size in terms of an A4 book // set notice that we could not get a valid string from the target
$this->pageCount = round($this->lineCount / 56); $this->app->enqueueMessage(
// setup the unrealistic numbers JText::sprintf('<hr /><h3>%s Warning</h3>', __CLASS__), 'Error'
$this->folderSeconds = $this->folderCount * 5; );
$this->fileSeconds = $this->fileCount * 5; $this->app->enqueueMessage(
$this->lineSeconds = $this->lineCount * 10; JText::sprintf(
$this->seconds = $this->folderSeconds + $this->fileSeconds 'Use of a deprecated method (%s)!', __METHOD__
+ $this->lineSeconds; ), 'Error'
$this->totalHours = round($this->seconds / 3600); );
$this->totalDays = round($this->totalHours / 8);
// setup the more realistic numbers
$this->secondsDebugging = $this->seconds / 4;
$this->secondsPlanning = $this->seconds / 7;
$this->secondsMapping = $this->seconds / 10;
$this->secondsOffice = $this->seconds / 6;
$this->actualSeconds = $this->folderSeconds + $this->fileSeconds
+ $this->lineSeconds + $this->secondsDebugging
+ $this->secondsPlanning + $this->secondsMapping
+ $this->secondsOffice;
$this->actualTotalHours = round($this->actualSeconds / 3600);
$this->actualTotalDays = round($this->actualTotalHours / 8);
$this->debuggingHours = round($this->secondsDebugging / 3600);
$this->planningHours = round($this->secondsPlanning / 3600);
$this->mappingHours = round($this->secondsMapping / 3600);
$this->officeHours = round($this->secondsOffice / 3600);
// the actual time spent
$this->actualHoursSpent = $this->actualTotalHours - $this->totalHours;
$this->actualDaysSpent = $this->actualTotalDays - $this->totalDays;
// calculate the projects actual time frame of completion
$this->projectWeekTime = round($this->actualTotalDays / 5, 1);
$this->projectMonthTime = round($this->actualTotalDays / 24, 1);
} }
private function buildReadMe() private function buildReadMe()
@ -864,7 +847,7 @@ class Compiler extends Infusion
{ {
if (('README.md' === $static['name'] if (('README.md' === $static['name']
|| 'README.txt' === $static['name']) || 'README.txt' === $static['name'])
&& $this->componentData->addreadme && CFactory::_('Component')->get('addreadme')
&& File::exists($static['path'])) && File::exists($static['path']))
{ {
$this->setReadMe($static['path']); $this->setReadMe($static['path']);
@ -882,10 +865,9 @@ class Compiler extends Infusion
{ {
// set readme data if not set already // set readme data if not set already
if (!CFactory::_('Content')->exist('LINE_COUNT') if (!CFactory::_('Content')->exist('LINE_COUNT')
|| CFactory::_('Content')->get('LINE_COUNT') || CFactory::_('Content')->get('LINE_COUNT') != CFactory::_('Counter')->line)
!= $this->lineCount)
{ {
$this->buildReadMeData(); CFactory::_('Counter')->set();
} }
// get the file // get the file
$string = FileHelper::getContent($path); $string = FileHelper::getContent($path);
@ -895,42 +877,23 @@ class Compiler extends Infusion
$this->writeFile($path, $answer); $this->writeFile($path, $answer);
} }
/**
* Build README data
*
* @return void
* @deprecated 3.3
*/
private function buildReadMeData() private function buildReadMeData()
{ {
// set some defaults // set notice that we could not get a valid string from the target
CFactory::_('Content')->set('LINE_COUNT', $this->lineCount); $this->app->enqueueMessage(
CFactory::_('Content')->set('FIELD_COUNT', $this->fieldCount); JText::sprintf('<hr /><h3>%s Warning</h3>', __CLASS__), 'Error'
CFactory::_('Content')->set('FILE_COUNT', $this->fileCount); );
CFactory::_('Content')->set('FOLDER_COUNT', $this->folderCount); $this->app->enqueueMessage(
CFactory::_('Content')->set('PAGE_COUNT', $this->pageCount); JText::sprintf(
CFactory::_('Content')->set('folders', $this->folderSeconds); 'Use of a deprecated method (%s)!', __METHOD__
CFactory::_('Content')->set('foldersSeconds', $this->folderSeconds); ), 'Error'
CFactory::_('Content')->set('files', $this->fileSeconds); );
CFactory::_('Content')->set('filesSeconds', $this->fileSeconds);
CFactory::_('Content')->set('lines', $this->lineSeconds);
CFactory::_('Content')->set('linesSeconds', $this->lineSeconds);
CFactory::_('Content')->set('seconds', $this->actualSeconds);
CFactory::_('Content')->set('actualSeconds', $this->actualSeconds);
CFactory::_('Content')->set('totalHours', $this->totalHours);
CFactory::_('Content')->set('totalDays', $this->totalDays);
CFactory::_('Content')->set('debugging', $this->secondsDebugging);
CFactory::_('Content')->set('secondsDebugging', $this->secondsDebugging);
CFactory::_('Content')->set('planning', $this->secondsPlanning);
CFactory::_('Content')->set('secondsPlanning', $this->secondsPlanning);
CFactory::_('Content')->set('mapping', $this->secondsMapping);
CFactory::_('Content')->set('secondsMapping', $this->secondsMapping);
CFactory::_('Content')->set('office', $this->secondsOffice);
CFactory::_('Content')->set('secondsOffice', $this->secondsOffice);
CFactory::_('Content')->set('actualTotalHours', $this->actualTotalHours);
CFactory::_('Content')->set('actualTotalDays', $this->actualTotalDays);
CFactory::_('Content')->set('debuggingHours', $this->debuggingHours);
CFactory::_('Content')->set('planningHours', $this->planningHours);
CFactory::_('Content')->set('mappingHours', $this->mappingHours);
CFactory::_('Content')->set('officeHours', $this->officeHours);
CFactory::_('Content')->set('actualHoursSpent', $this->actualHoursSpent);
CFactory::_('Content')->set('actualDaysSpent', $this->actualDaysSpent);
CFactory::_('Content')->set('projectWeekTime', $this->projectWeekTime);
CFactory::_('Content')->set('projectMonthTime', $this->projectMonthTime);
} }
private function setLocalRepos() private function setLocalRepos()
@ -943,7 +906,7 @@ class Compiler extends Infusion
{ {
// set the repo path // set the repo path
$repoFullPath = $this->repoPath . '/com_' $repoFullPath = $this->repoPath . '/com_'
. $this->componentData->sales_name . '__joomla_' . CFactory::_('Component')->get('sales_name') . '__joomla_'
. CFactory::_('Config')->get('version', 3); . CFactory::_('Config')->get('version', 3);
// for plugin event TODO change event api signatures // for plugin event TODO change event api signatures
$component_context = CFactory::_('Config')->component_context; $component_context = CFactory::_('Config')->component_context;
@ -954,7 +917,7 @@ class Compiler extends Infusion
&$repoFullPath, &$this->componentData) &$repoFullPath, &$this->componentData)
); );
// remove old data // remove old data
$this->removeFolder($repoFullPath, $this->componentData->toignore); $this->removeFolder($repoFullPath, CFactory::_('Component')->get('toignore'));
// set the new data // set the new data
Folder::copy($this->componentPath, $repoFullPath, '', true); Folder::copy($this->componentPath, $repoFullPath, '', true);
// Trigger Event: jcb_ce_onAfterUpdateRepo // Trigger Event: jcb_ce_onAfterUpdateRepo
@ -965,9 +928,9 @@ class Compiler extends Infusion
); );
// move the modules to local folder repos // move the modules to local folder repos
if (ArrayHelper::check($this->joomlaModules)) if (CFactory::_('Joomlamodule.Data')->exists())
{ {
foreach ($this->joomlaModules as $module) foreach (CFactory::_('Joomlamodule.Data')->get() as $module)
{ {
if (ObjectHelper::check($module) if (ObjectHelper::check($module)
&& isset($module->file_name)) && isset($module->file_name))
@ -986,7 +949,7 @@ class Compiler extends Infusion
); );
// remove old data // remove old data
$this->removeFolder( $this->removeFolder(
$repoFullPath, $this->componentData->toignore $repoFullPath, CFactory::_('Component')->get('toignore')
); );
// set the new data // set the new data
Folder::copy( Folder::copy(
@ -1002,9 +965,9 @@ class Compiler extends Infusion
} }
} }
// move the plugins to local folder repos // move the plugins to local folder repos
if (ArrayHelper::check($this->joomlaPlugins)) if (CFactory::_('Joomlaplugin.Data')->exists())
{ {
foreach ($this->joomlaPlugins as $plugin) foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin)
{ {
if (ObjectHelper::check($plugin) if (ObjectHelper::check($plugin)
&& isset($plugin->file_name)) && isset($plugin->file_name))
@ -1023,7 +986,7 @@ class Compiler extends Infusion
); );
// remove old data // remove old data
$this->removeFolder( $this->removeFolder(
$repoFullPath, $this->componentData->toignore $repoFullPath, CFactory::_('Component')->get('toignore')
); );
// set the new data // set the new data
Folder::copy( Folder::copy(
@ -1081,11 +1044,11 @@ class Compiler extends Infusion
); );
} }
// move to sales server host // move to sales server host
if ($this->componentData->add_sales_server == 1 if (CFactory::_('Component')->get('add_sales_server', 0) == 1
&& $this->dynamicIntegration) && $this->dynamicIntegration)
{ {
// make sure we have the correct file // make sure we have the correct file
if (isset($this->componentData->sales_server)) if (CFactory::_('Component')->get('sales_server'))
{ {
// Trigger Event: jcb_ce_onBeforeMoveToServer // Trigger Event: jcb_ce_onBeforeMoveToServer
CFactory::_('Event')->trigger( CFactory::_('Event')->trigger(
@ -1098,8 +1061,8 @@ class Compiler extends Infusion
ComponentbuilderHelper::moveToServer( ComponentbuilderHelper::moveToServer(
$this->filepath['component'], $this->filepath['component'],
$this->componentSalesName . '.zip', $this->componentSalesName . '.zip',
(int) $this->componentData->sales_server, (int) CFactory::_('Component')->get('sales_server'),
$this->componentData->sales_server_protocol CFactory::_('Component')->get('sales_server_protocol')
); );
} }
} }
@ -1122,9 +1085,9 @@ class Compiler extends Infusion
private function zipModules() private function zipModules()
{ {
if (ArrayHelper::check($this->joomlaModules)) if (CFactory::_('Joomlamodule.Data')->exists())
{ {
foreach ($this->joomlaModules as $module) foreach (CFactory::_('Joomlamodule.Data')->get() as $module)
{ {
if (ObjectHelper::check($module) if (ObjectHelper::check($module)
&& isset($module->zip_name) && isset($module->zip_name)
@ -1216,9 +1179,9 @@ class Compiler extends Infusion
private function zipPlugins() private function zipPlugins()
{ {
if (ArrayHelper::check($this->joomlaPlugins)) if (CFactory::_('Joomlaplugin.Data')->exists())
{ {
foreach ($this->joomlaPlugins as $plugin) foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin)
{ {
if (ObjectHelper::check($plugin) if (ObjectHelper::check($plugin)
&& isset($plugin->zip_name) && isset($plugin->zip_name)

File diff suppressed because it is too large Load Diff

View File

@ -28,15 +28,16 @@ use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
/** /**
* Structure class * Structure class
* @deprecated 3.3
*/ */
class Structure extends Get class Structure extends Get
{ {
/** /**
* The folder counter * The folder counter
* *
* @var int * @var int
* @deprecated 3.3 Use CFactory::_('Counter')->folder;
*/ */
public $folderCount = 0; public $folderCount = 0;
@ -44,6 +45,7 @@ class Structure extends Get
* The file counter * The file counter
* *
* @var int * @var int
* @deprecated 3.3 Use CFactory::_('Counter')->file;
*/ */
public $fileCount = 0; public $fileCount = 0;
@ -51,6 +53,7 @@ class Structure extends Get
* The page counter * The page counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $pageCount = 0; public $pageCount = 0;
@ -58,6 +61,8 @@ class Structure extends Get
* The line counter * The line counter
* *
* @var int * @var int
* @deprecated 3.3
* @deprecated 3.3 Use CFactory::_('Counter')->line;
*/ */
public $lineCount = 0; public $lineCount = 0;
@ -65,6 +70,7 @@ class Structure extends Get
* The field counter * The field counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $fieldCount = 0; public $fieldCount = 0;
@ -72,6 +78,7 @@ class Structure extends Get
* The seconds counter * The seconds counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $seconds = 0; public $seconds = 0;
@ -79,6 +86,7 @@ class Structure extends Get
* The actual seconds counter * The actual seconds counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $actualSeconds = 0; public $actualSeconds = 0;
@ -86,6 +94,7 @@ class Structure extends Get
* The folder seconds counter * The folder seconds counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $folderSeconds = 0; public $folderSeconds = 0;
@ -93,6 +102,7 @@ class Structure extends Get
* The file seconds counter * The file seconds counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $fileSeconds = 0; public $fileSeconds = 0;
@ -100,6 +110,7 @@ class Structure extends Get
* The line seconds counter * The line seconds counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $lineSeconds = 0; public $lineSeconds = 0;
@ -107,6 +118,7 @@ class Structure extends Get
* The seconds debugging counter * The seconds debugging counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $secondsDebugging = 0; public $secondsDebugging = 0;
@ -114,6 +126,7 @@ class Structure extends Get
* The seconds planning counter * The seconds planning counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $secondsPlanning = 0; public $secondsPlanning = 0;
@ -121,6 +134,7 @@ class Structure extends Get
* The seconds mapping counter * The seconds mapping counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $secondsMapping = 0; public $secondsMapping = 0;
@ -128,6 +142,7 @@ class Structure extends Get
* The seconds office counter * The seconds office counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $secondsOffice = 0; public $secondsOffice = 0;
@ -135,6 +150,7 @@ class Structure extends Get
* The total hours counter * The total hours counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $totalHours = 0; public $totalHours = 0;
@ -142,6 +158,7 @@ class Structure extends Get
* The debugging hours counter * The debugging hours counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $debuggingHours = 0; public $debuggingHours = 0;
@ -149,6 +166,7 @@ class Structure extends Get
* The planning hours counter * The planning hours counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $planningHours = 0; public $planningHours = 0;
@ -156,6 +174,7 @@ class Structure extends Get
* The mapping hours counter * The mapping hours counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $mappingHours = 0; public $mappingHours = 0;
@ -163,6 +182,7 @@ class Structure extends Get
* The office hours counter * The office hours counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $officeHours = 0; public $officeHours = 0;
@ -170,6 +190,7 @@ class Structure extends Get
* The actual Total Hours counter * The actual Total Hours counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $actualTotalHours = 0; public $actualTotalHours = 0;
@ -177,6 +198,7 @@ class Structure extends Get
* The actual hours spent counter * The actual hours spent counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $actualHoursSpent = 0; public $actualHoursSpent = 0;
@ -184,6 +206,7 @@ class Structure extends Get
* The actual days spent counter * The actual days spent counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $actualDaysSpent = 0; public $actualDaysSpent = 0;
@ -191,6 +214,7 @@ class Structure extends Get
* The total days counter * The total days counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $totalDays = 0; public $totalDays = 0;
@ -198,6 +222,7 @@ class Structure extends Get
* The actual Total Days counter * The actual Total Days counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $actualTotalDays = 0; public $actualTotalDays = 0;
@ -205,6 +230,7 @@ class Structure extends Get
* The project week time counter * The project week time counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $projectWeekTime = 0; public $projectWeekTime = 0;
@ -212,6 +238,7 @@ class Structure extends Get
* The project month time counter * The project month time counter
* *
* @var int * @var int
* @deprecated 3.3
*/ */
public $projectMonthTime = 0; public $projectMonthTime = 0;
@ -378,11 +405,11 @@ class Structure extends Get
*/ */
public function __construct() public function __construct()
{ {
// first we run the perent constructor // first we run the parent constructor
if (parent::__construct()) if (parent::__construct())
{ {
// set the standard admin file // set the standard admin file
$this->stdRootFiles[] = $this->componentData->name_code . '.php'; $this->stdRootFiles[] = CFactory::_('Component')->get('name_code') . '.php';
// set incase no extra admin folder are loaded // set incase no extra admin folder are loaded
CFactory::_('Content')->set('EXSTRA_ADMIN_FOLDERS', ''); CFactory::_('Content')->set('EXSTRA_ADMIN_FOLDERS', '');
// set incase no extra site folder are loaded // set incase no extra site folder are loaded
@ -395,22 +422,20 @@ class Structure extends Get
CFactory::_('Content')->set('EXSTRA_SITE_FILES', ''); CFactory::_('Content')->set('EXSTRA_SITE_FILES', '');
// set incase no extra media files are loaded // set incase no extra media files are loaded
CFactory::_('Content')->set('EXSTRA_MEDIA_FILES', ''); CFactory::_('Content')->set('EXSTRA_MEDIA_FILES', '');
// run global updater
ComponentbuilderHelper::runGlobalUpdater();
// set the template path // set the template path
$this->templatePath = CFactory::_('Config')->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/joomla_' $this->templatePath = CFactory::_('Config')->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/joomla_'
. $this->joomlaVersions[CFactory::_('Config')->joomla_version]['folder_key']; . CFactory::_('Config')->joomla_versions[CFactory::_('Config')->joomla_version]['folder_key'];
// set some default names // set some default names
$this->componentSalesName = 'com_' $this->componentSalesName = 'com_'
. $this->componentData->sales_name . '__J' . CFactory::_('Component')->get('sales_name') . '__J'
. CFactory::_('Config')->joomla_version; . CFactory::_('Config')->joomla_version;
$this->componentBackupName = 'com_' $this->componentBackupName = 'com_'
. $this->componentData->sales_name . '_v' . str_replace( . CFactory::_('Component')->get('sales_name') . '_v' . str_replace(
'.', '_', (string) $this->componentData->component_version '.', '_', (string) CFactory::_('Component')->get('component_version')
) . '__J' . CFactory::_('Config')->joomla_version; ) . '__J' . CFactory::_('Config')->joomla_version;
$this->componentFolderName = 'com_' $this->componentFolderName = 'com_'
. $this->componentData->name_code . '_v' . str_replace( . CFactory::_('Component')->get('name_code') . '_v' . str_replace(
'.', '_', (string) $this->componentData->component_version '.', '_', (string) CFactory::_('Component')->get('component_version')
) . '__J' . CFactory::_('Config')->joomla_version; ) . '__J' . CFactory::_('Config')->joomla_version;
// set component folder path // set component folder path
$this->componentPath = CFactory::_('Config')->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/' $this->componentPath = CFactory::_('Config')->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
@ -526,7 +551,7 @@ class Structure extends Get
); );
$this->newFiles[$power->key][] = $fileDetails; $this->newFiles[$power->key][] = $fileDetails;
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
if (!isset($htaccess[$power->path_jcb])) if (!isset($htaccess[$power->path_jcb]))
{ {
// set the htaccess data // set the htaccess data
@ -547,7 +572,7 @@ class Structure extends Get
); );
$this->newFiles[$power->key][] = $fileDetails; $this->newFiles[$power->key][] = $fileDetails;
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
// now we must add the htaccess.txt file where the zip package my not get the [.] files // 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', $fileDetails = array('path' => $power->full_path_jcb . '/htaccess.txt',
'name' => 'htaccess.txt', 'name' => 'htaccess.txt',
@ -557,7 +582,7 @@ class Structure extends Get
); );
$this->newFiles[$power->key][] = $fileDetails; $this->newFiles[$power->key][] = $fileDetails;
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
// now we must add the web.config file // now we must add the web.config file
$fileDetails = array('path' => $power->full_path_jcb . '/web.config', $fileDetails = array('path' => $power->full_path_jcb . '/web.config',
'name' => 'web.config', 'name' => 'web.config',
@ -574,7 +599,7 @@ class Structure extends Get
); );
$this->newFiles[$power->key][] = $fileDetails; $this->newFiles[$power->key][] = $fileDetails;
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
// we set these files only once // we set these files only once
$htaccess[$power->path_jcb] = true; $htaccess[$power->path_jcb] = true;
} }
@ -591,16 +616,17 @@ class Structure extends Get
*/ */
private function buildModules() private function buildModules()
{ {
if (ArrayHelper::check($this->joomlaModules)) if (CFactory::_('Joomlamodule.Data')->exists())
{ {
// for plugin event TODO change event api signatures // for plugin event TODO change event api signatures
$component_context = CFactory::_('Config')->component_context; $component_context = CFactory::_('Config')->component_context;
$modules = CFactory::_('Joomlamodule.Data')->get();
// Trigger Event: jcb_ce_onBeforeSetModules // Trigger Event: jcb_ce_onBeforeSetModules
CFactory::_('Event')->trigger( CFactory::_('Event')->trigger(
'jcb_ce_onBeforeBuildModules', 'jcb_ce_onBeforeBuildModules',
array(&$component_context, &$this->joomlaModules) array(&$component_context, &$modules)
); );
foreach ($this->joomlaModules as $module) foreach ($modules as $module)
{ {
if (ObjectHelper::check($module) if (ObjectHelper::check($module)
&& isset($module->folder_name) && isset($module->folder_name)
@ -633,7 +659,7 @@ class Structure extends Get
); );
$this->newFiles[$module->key][] = $fileDetails; $this->newFiles[$module->key][] = $fileDetails;
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
// set custom_get // set custom_get
if ($module->custom_get) if ($module->custom_get)
{ {
@ -661,7 +687,7 @@ class Structure extends Get
); );
$this->newFiles[$module->key][] = $fileDetails; $this->newFiles[$module->key][] = $fileDetails;
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
} }
// set helper file // set helper file
if ($module->add_class_helper >= 1) if ($module->add_class_helper >= 1)
@ -683,7 +709,7 @@ class Structure extends Get
); );
$this->newFiles[$module->key][] = $fileDetails; $this->newFiles[$module->key][] = $fileDetails;
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
} }
// set main xml file // set main xml file
$fileDetails = array('path' => $module->folder_path . '/' $fileDetails = array('path' => $module->folder_path . '/'
@ -696,7 +722,7 @@ class Structure extends Get
); );
$this->newFiles[$module->key][] = $fileDetails; $this->newFiles[$module->key][] = $fileDetails;
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
// set tmpl folder // set tmpl folder
$this->createFolder($module->folder_path . '/tmpl'); $this->createFolder($module->folder_path . '/tmpl');
// set default file // set default file
@ -715,7 +741,7 @@ class Structure extends Get
); );
$this->newFiles[$module->key][] = $fileDetails; $this->newFiles[$module->key][] = $fileDetails;
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
// set install script if needed // set install script if needed
if ($module->add_install_script) if ($module->add_install_script)
{ {
@ -736,7 +762,7 @@ class Structure extends Get
); );
$this->newFiles[$module->key][] = $fileDetails; $this->newFiles[$module->key][] = $fileDetails;
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
} }
// set readme if found // set readme if found
if ($module->addreadme) if ($module->addreadme)
@ -748,7 +774,7 @@ class Structure extends Get
$this->writeFile($fileDetails['path'], $module->readme); $this->writeFile($fileDetails['path'], $module->readme);
$this->newFiles[$module->key][] = $fileDetails; $this->newFiles[$module->key][] = $fileDetails;
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
} }
// set the folders target path // set the folders target path
$target_path = ''; $target_path = '';
@ -784,7 +810,7 @@ class Structure extends Get
); );
$this->newFiles[$module->key][] = $fileDetails; $this->newFiles[$module->key][] = $fileDetails;
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
// add the field script // add the field script
$field_script_bucket[] = Indent::_(2) . "//" $field_script_bucket[] = Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Custom CSS"; . Line::_(__Line__, __Class__) . " Custom CSS";
@ -819,7 +845,7 @@ class Structure extends Get
); );
$this->newFiles[$module->key][] = $fileDetails; $this->newFiles[$module->key][] = $fileDetails;
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
// add the field script // add the field script
$field_script_bucket[] = Indent::_(2) . "//" $field_script_bucket[] = Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Custom JS"; . Line::_(__Line__, __Class__) . " Custom JS";
@ -851,7 +877,7 @@ class Structure extends Get
); );
$this->newFiles[$module->key][] = $fileDetails; $this->newFiles[$module->key][] = $fileDetails;
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
} }
} }
// set rules folders if needed // set rules folders if needed
@ -1048,7 +1074,7 @@ class Structure extends Get
$this->writeFile($fileDetails['path'], $xml); $this->writeFile($fileDetails['path'], $xml);
$this->newFiles[$module->key][] = $fileDetails; $this->newFiles[$module->key][] = $fileDetails;
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
} }
} }
// set SQL stuff if needed // set SQL stuff if needed
@ -1068,7 +1094,7 @@ class Structure extends Get
$module->sql $module->sql
); );
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
} }
// now set the uninstall file // now set the uninstall file
if ($module->add_sql_uninstall) if ($module->add_sql_uninstall)
@ -1079,7 +1105,7 @@ class Structure extends Get
$module->sql_uninstall $module->sql_uninstall
); );
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
} }
} }
// creat the language folder // creat the language folder
@ -1095,10 +1121,10 @@ class Structure extends Get
// add to component files // add to component files
foreach ($module->files as $file) foreach ($module->files as $file)
{ {
// set the path finder // set the pathfinder
$file['target_type'] = $module->target_type; $file['target_type'] = $module->target_type;
$file['target_id'] = $module->id; $file['target_id'] = $module->id;
$this->componentData->files[] = $file; CFactory::_('Component')->appendArray('files', $file);
} }
} }
// check if this lib has folders // check if this lib has folders
@ -1108,10 +1134,10 @@ class Structure extends Get
// add to component folders // add to component folders
foreach ($module->folders as $folder) foreach ($module->folders as $folder)
{ {
// set the path finder // set the pathfinder
$folder['target_type'] = $module->target_type; $folder['target_type'] = $module->target_type;
$folder['target_id'] = $module->id; $folder['target_id'] = $module->id;
$this->componentData->folders[] = $folder; CFactory::_('Component')->appendArray('folders', $folder);
} }
} }
// check if this module has urls // check if this module has urls
@ -1157,7 +1183,7 @@ class Structure extends Get
// write data to path // write data to path
$this->writeFile($url['path'], $data); $this->writeFile($url['path'], $data);
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
} }
} }
} }
@ -1174,16 +1200,17 @@ class Structure extends Get
*/ */
private function buildPlugins() private function buildPlugins()
{ {
if (ArrayHelper::check($this->joomlaPlugins)) if (CFactory::_('Joomlaplugin.Data')->exists())
{ {
// for plugin event TODO change event api signatures // for plugin event TODO change event api signatures
$component_context = CFactory::_('Config')->component_context; $component_context = CFactory::_('Config')->component_context;
$plugins = CFactory::_('Joomlaplugin.Data')->get();
// Trigger Event: jcb_ce_onBeforeSetPlugins // Trigger Event: jcb_ce_onBeforeSetPlugins
CFactory::_('Event')->trigger( CFactory::_('Event')->trigger(
'jcb_ce_onBeforeBuildPlugins', 'jcb_ce_onBeforeBuildPlugins',
array(&$component_context, &$this->joomlaPlugins) array(&$component_context, &$plugins)
); );
foreach ($this->joomlaPlugins as $plugin) foreach ($plugins as $plugin)
{ {
if (ObjectHelper::check($plugin) if (ObjectHelper::check($plugin)
&& isset($plugin->folder_name) && isset($plugin->folder_name)
@ -1216,7 +1243,7 @@ class Structure extends Get
); );
$this->newFiles[$plugin->key][] = $fileDetails; $this->newFiles[$plugin->key][] = $fileDetails;
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
// set main xml file // set main xml file
$fileDetails = array('path' => $plugin->folder_path . '/' $fileDetails = array('path' => $plugin->folder_path . '/'
. $plugin->file_name . '.xml', . $plugin->file_name . '.xml',
@ -1228,7 +1255,7 @@ class Structure extends Get
); );
$this->newFiles[$plugin->key][] = $fileDetails; $this->newFiles[$plugin->key][] = $fileDetails;
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
// set install script if needed // set install script if needed
if ($plugin->add_install_script) if ($plugin->add_install_script)
{ {
@ -1249,7 +1276,7 @@ class Structure extends Get
); );
$this->newFiles[$plugin->key][] = $fileDetails; $this->newFiles[$plugin->key][] = $fileDetails;
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
} }
// set readme if found // set readme if found
if ($plugin->addreadme) if ($plugin->addreadme)
@ -1261,7 +1288,7 @@ class Structure extends Get
$this->writeFile($fileDetails['path'], $plugin->readme); $this->writeFile($fileDetails['path'], $plugin->readme);
$this->newFiles[$plugin->key][] = $fileDetails; $this->newFiles[$plugin->key][] = $fileDetails;
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
} }
// set fields & rules folders if needed // set fields & rules folders if needed
if (isset($plugin->fields_rules_paths) if (isset($plugin->fields_rules_paths)
@ -1441,7 +1468,7 @@ class Structure extends Get
$this->writeFile($fileDetails['path'], $xml); $this->writeFile($fileDetails['path'], $xml);
$this->newFiles[$plugin->key][] = $fileDetails; $this->newFiles[$plugin->key][] = $fileDetails;
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
} }
} }
// set SQL stuff if needed // set SQL stuff if needed
@ -1461,7 +1488,7 @@ class Structure extends Get
$plugin->sql $plugin->sql
); );
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
} }
// now set the uninstall file // now set the uninstall file
if ($plugin->add_sql_uninstall) if ($plugin->add_sql_uninstall)
@ -1472,7 +1499,7 @@ class Structure extends Get
$plugin->sql_uninstall $plugin->sql_uninstall
); );
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
} }
} }
// creat the language folder path // creat the language folder path
@ -1491,7 +1518,7 @@ class Structure extends Get
// set the path finder // set the path finder
$file['target_type'] = $plugin->target_type; $file['target_type'] = $plugin->target_type;
$file['target_id'] = $plugin->id; $file['target_id'] = $plugin->id;
$this->componentData->files[] = $file; CFactory::_('Component')->appendArray('files', $file);
} }
} }
// check if this lib has folders // check if this lib has folders
@ -1504,7 +1531,7 @@ class Structure extends Get
// set the path finder // set the path finder
$folder['target_type'] = $plugin->target_type; $folder['target_type'] = $plugin->target_type;
$folder['target_id'] = $plugin->id; $folder['target_id'] = $plugin->id;
$this->componentData->folders[] = $folder; CFactory::_('Component')->appendArray('folders', $folder);
} }
} }
// check if this plugin has urls // check if this plugin has urls
@ -1550,7 +1577,7 @@ class Structure extends Get
// write data to path // write data to path
$this->writeFile($url['path'], $data); $this->writeFile($url['path'], $data);
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
} }
} }
} }
@ -1576,7 +1603,7 @@ class Structure extends Get
$path $path
); );
// count the folder created // count the folder created
$this->folderCount++; CFactory::_('Counter')->folder++;
// add index.html (boring I know) // add index.html (boring I know)
$this->indexHTML( $this->indexHTML(
$path, '' $path, ''
@ -1592,7 +1619,7 @@ class Structure extends Get
*/ */
private function setLibraries() private function setLibraries()
{ {
if (($libraries_ = CFactory::_('Registry')->extract('builder.libraries')) !== null) if (($libraries_ = CFactory::_('Registry')->get('builder.libraries')) !== null)
{ {
// for plugin event TODO change event api signatures // for plugin event TODO change event api signatures
$component_context = CFactory::_('Config')->component_context; $component_context = CFactory::_('Config')->component_context;
@ -1606,7 +1633,7 @@ class Structure extends Get
{ {
Folder::create($this->componentPath); Folder::create($this->componentPath);
// count the folder created // count the folder created
$this->folderCount++; CFactory::_('Counter')->folder++;
$this->indexHTML(''); $this->indexHTML('');
} }
// create media path if not set // create media path if not set
@ -1622,7 +1649,7 @@ class Structure extends Get
// add to component files // add to component files
foreach ($library->files as $file) foreach ($library->files as $file)
{ {
$this->componentData->files[] = $file; CFactory::_('Component')->appendArray('files', $file);
} }
} }
// check if this lib has folders // check if this lib has folders
@ -1634,7 +1661,7 @@ class Structure extends Get
// add to component folders // add to component folders
foreach ($library->folders as $folder) foreach ($library->folders as $folder)
{ {
$this->componentData->folders[] = $folder; CFactory::_('Component')->appendArray('folders', $folder);
} }
} }
// check if this lib has urls // check if this lib has urls
@ -1699,7 +1726,7 @@ class Structure extends Get
// write data to path // write data to path
$this->writeFile($path, $data); $this->writeFile($path, $data);
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
} }
} }
// only add if local // only add if local
@ -1719,15 +1746,13 @@ class Structure extends Get
foreach ($library->config as $cofig) foreach ($library->config as $cofig)
{ {
$found = array_filter( $found = array_filter(
$this->componentData->config, CFactory::_('Component')->get('config'),
function ($item) use ($cofig) { fn($item) => $item['field'] == $cofig['field']
return $item['field'] == $cofig['field'];
}
); );
// set the config data if not found // set the config data if not found
if (!ArrayHelper::check($found)) if (!ArrayHelper::check($found))
{ {
$this->componentData->config[] = $cofig; CFactory::_('Component')->appendArray('config', $cofig);
} }
} }
} }
@ -1747,16 +1772,13 @@ class Structure extends Get
private function setDynamicDashboard() private function setDynamicDashboard()
{ {
// only add the dynamic dashboard if all checks out // only add the dynamic dashboard if all checks out
if (isset($this->componentData->dashboard_type) if (CFactory::_('Component')->get('dashboard_type', 0) == 2
&& 2 == $this->componentData->dashboard_type && ($dashboard_ = CFactory::_('Component')->get('dashboard')) !== null
&& isset($this->componentData->dashboard) && StringHelper::check($dashboard_)
&& StringHelper::check( && strpos((string) $dashboard_, '_') !== false)
$this->componentData->dashboard
)
&& strpos((string) $this->componentData->dashboard, '_') !== false)
{ {
// set the default view // set the default view
$getter = explode('_', (string) $this->componentData->dashboard); $getter = explode('_', (string) $dashboard_);
if (count((array) $getter) == 2 && is_numeric($getter[1])) if (count((array) $getter) == 2 && is_numeric($getter[1]))
{ {
// the pointers // the pointers
@ -1777,14 +1799,12 @@ class Structure extends Get
$targets[$t], 'w' $targets[$t], 'w'
); );
// set the dynamic dash // set the dynamic dash
if (isset($this->componentData->{$targets[$t]}) if (($target_ = CFactory::_('Component')->get($targets[$t])) !== null
&& ArrayHelper::check( && ArrayHelper::check($target_))
$this->componentData->{$targets[$t]}
))
{ {
// search the target views // search the target views
$dashboard = (array) array_filter( $dashboard = (array) array_filter(
$this->componentData->{$targets[$t]}, $target_,
function ($view) use ($id, $t, $types) { function ($view) use ($id, $t, $types) {
if (isset($view[$types[$t]]) if (isset($view[$types[$t]])
&& $id == $view[$types[$t]]) && $id == $view[$types[$t]])
@ -1821,7 +1841,7 @@ class Structure extends Get
$this->app->enqueueMessage( $this->app->enqueueMessage(
JText::sprintf( JText::sprintf(
'The <b>%s</b> (<b>%s</b>) is not available in your component! Please insure to only used %s, for a dynamic dashboard, that are still linked to your component.', 'The <b>%s</b> (<b>%s</b>) is not available in your component! Please insure to only used %s, for a dynamic dashboard, that are still linked to your component.',
$names[$t], $this->componentData->dashboard, $names[$t], $dashboard_,
$type_names $type_names
), 'Error' ), 'Error'
); );
@ -1836,7 +1856,7 @@ class Structure extends Get
$this->app->enqueueMessage( $this->app->enqueueMessage(
JText::sprintf( JText::sprintf(
'The <b>%s</b> (<b>%s</b>) is not available in your component! Please insure to only used %s, for a dynamic dashboard, that are still linked to your component.', 'The <b>%s</b> (<b>%s</b>) is not available in your component! Please insure to only used %s, for a dynamic dashboard, that are still linked to your component.',
$names[$t], $this->componentData->dashboard, $names[$t], $dashboard_,
$type_names $type_names
), 'Error' ), 'Error'
); );
@ -1851,7 +1871,7 @@ class Structure extends Get
$this->app->enqueueMessage( $this->app->enqueueMessage(
JText::sprintf( JText::sprintf(
'The <b>%s</b> value for the dynamic dashboard is invalid.', 'The <b>%s</b> value for the dynamic dashboard is invalid.',
$this->componentData->dashboard $dashboard_
), 'Error' ), 'Error'
); );
} }
@ -1865,7 +1885,7 @@ class Structure extends Get
$this->app->enqueueMessage( $this->app->enqueueMessage(
JText::sprintf( JText::sprintf(
'The <b>%s</b> value for the dynamic dashboard is invalid.', 'The <b>%s</b> value for the dynamic dashboard is invalid.',
$this->componentData->dashboard $dashboard_
), 'Error' ), 'Error'
); );
} }
@ -1873,8 +1893,8 @@ class Structure extends Get
if (StringHelper::check($this->dynamicDashboard)) if (StringHelper::check($this->dynamicDashboard))
{ {
// dynamic dashboard is used // dynamic dashboard is used
$this->componentData->dashboard_tab = ''; CFactory::_('Component')->remove('dashboard_tab');
$this->componentData->php_dashboard_methods = ''; CFactory::_('Component')->remove('php_dashboard_methods');
} }
} }
} }
@ -1907,7 +1927,7 @@ class Structure extends Get
{ {
Folder::create($this->componentPath); Folder::create($this->componentPath);
// count the folder created // count the folder created
$this->folderCount++; CFactory::_('Counter')->folder++;
$this->indexHTML(''); $this->indexHTML('');
} }
// now build all folders needed for this component // now build all folders needed for this component
@ -2072,7 +2092,7 @@ class Structure extends Get
$this->notNew[] = 'LICENSE.txt'; $this->notNew[] = 'LICENSE.txt';
// do license check // do license check
$LICENSE = false; $LICENSE = false;
$licenseChecker = strtolower((string) $this->componentData->license); $licenseChecker = strtolower((string) CFactory::_('Component')->get('license', ''));
if (strpos($licenseChecker, 'gnu') !== false if (strpos($licenseChecker, 'gnu') !== false
&& strpos( && strpos(
$licenseChecker, '2' $licenseChecker, '2'
@ -2088,7 +2108,7 @@ class Structure extends Get
// do README check // do README check
$README = false; $README = false;
// add the README file if needed // add the README file if needed
if ($this->componentData->addreadme) if (CFactory::_('Component')->get('addreadme', false))
{ {
$README = true; $README = true;
} }
@ -2188,7 +2208,7 @@ class Structure extends Get
// move the file to its place // move the file to its place
File::copy($currentFullPath, $packageFullPath); File::copy($currentFullPath, $packageFullPath);
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
// store the new files // store the new files
if (!in_array($ftem, $this->notNew)) if (!in_array($ftem, $this->notNew))
{ {
@ -2241,7 +2261,7 @@ class Structure extends Get
$currentFullPath, $packageFullPath, '', true $currentFullPath, $packageFullPath, '', true
); );
// count the folder created // count the folder created
$this->folderCount++; CFactory::_('Counter')->folder++;
} }
} }
// only add if no target found since those belong to plugins and modules // only add if no target found since those belong to plugins and modules
@ -2322,19 +2342,16 @@ class Structure extends Get
&& ObjectHelper::check( && ObjectHelper::check(
$this->joomlaVersionData->move->dynamic $this->joomlaVersionData->move->dynamic
)) ))
&& (isset($this->componentData->admin_views) && CFactory::_('Component')->isArray('admin_views'))
&& ArrayHelper::check(
$this->componentData->admin_views
)))
{ {
if (!StringHelper::check($this->dynamicDashboard)) if (!StringHelper::check($this->dynamicDashboard))
{ {
// setup dashboard // setup dashboard
$target = array('admin' => $this->componentData->name_code); $target = array('admin' => CFactory::_('Component')->get('name_code'));
$this->buildDynamique($target, 'dashboard'); $this->buildDynamique($target, 'dashboard');
} }
// now the rest of the views // now the rest of the views
foreach ($this->componentData->admin_views as $nr => $view) foreach (CFactory::_('Component')->get('admin_views') as $nr => $view)
{ {
if (ObjectHelper::check($view['settings'])) if (ObjectHelper::check($view['settings']))
{ {
@ -2389,13 +2406,10 @@ class Structure extends Get
&& ObjectHelper::check( && ObjectHelper::check(
$this->joomlaVersionData->move->dynamic $this->joomlaVersionData->move->dynamic
)) ))
&& (isset($this->componentData->site_views) && CFactory::_('Component')->isArray('site_views'))
&& ArrayHelper::check(
$this->componentData->site_views
)))
{ {
foreach ($this->componentData->site_views as $nr => $view) foreach (CFactory::_('Component')->get('site_views') as $nr => $view)
{ {
$created = $this->getCreatedDate($view); $created = $this->getCreatedDate($view);
$modified = $this->getLastModifiedDate($view); $modified = $this->getLastModifiedDate($view);
@ -2424,12 +2438,9 @@ class Structure extends Get
&& ObjectHelper::check( && ObjectHelper::check(
$this->joomlaVersionData->move->dynamic $this->joomlaVersionData->move->dynamic
)) ))
&& (isset($this->componentData->custom_admin_views) && CFactory::_('Component')->isArray('custom_admin_views'))
&& ArrayHelper::check(
$this->componentData->custom_admin_views
)))
{ {
foreach ($this->componentData->custom_admin_views as $nr => $view) foreach (CFactory::_('Component')->get('custom_admin_views') as $nr => $view)
{ {
$created = $this->getCreatedDate($view); $created = $this->getCreatedDate($view);
$modified = $this->getLastModifiedDate($view); $modified = $this->getLastModifiedDate($view);
@ -2789,7 +2800,7 @@ class Structure extends Get
Folder::create($path); Folder::create($path);
$this->indexHTML($zipPath); $this->indexHTML($zipPath);
// count the folder created // count the folder created
$this->folderCount++; CFactory::_('Counter')->folder++;
} }
// do the file renaming // do the file renaming
if ($details->rename) if ($details->rename)
@ -2824,7 +2835,7 @@ class Structure extends Get
$path . '/' . $new $path . '/' . $new
); );
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
} }
// setup array for new file // setup array for new file
$newFIle = array('path' => $path . '/' . $new, $newFIle = array('path' => $path . '/' . $new,
@ -2878,37 +2889,35 @@ class Structure extends Get
$footable = CFactory::_('Config')->get('footable', false); $footable = CFactory::_('Config')->get('footable', false);
$add_eximport = CFactory::_('Config')->get('add_eximport', false); $add_eximport = CFactory::_('Config')->get('add_eximport', false);
// add custom folders // add custom folders
if ((isset($this->componentData->folders) if (CFactory::_('Component')->isArray('folders')
&& ArrayHelper::check( || $add_eximport || $uikit || $footable)
$this->componentData->folders
)) || $add_eximport || $uikit || $footable)
{ {
if ($add_eximport) if ($add_eximport)
{ {
// move the import view folder in place // move the import view folder in place
$this->componentData->folders[] = array('folder' => 'importViews', CFactory::_('Component')->appendArray('folders', array('folder' => 'importViews',
'path' => 'admin/views/import', 'path' => 'admin/views/import',
'rename' => 1); 'rename' => 1));
// move the phpspreadsheet Folder (TODO we must move this to a library package) // move the phpspreadsheet Folder (TODO we must move this to a library package)
$this->componentData->folders[] = array('folderpath' => 'JPATH_LIBRARIES/phpspreadsheet/vendor', CFactory::_('Component')->appendArray('folders', array('folderpath' => 'JPATH_LIBRARIES/phpspreadsheet/vendor',
'path' => '/libraries/phpspreadsheet/', 'path' => '/libraries/phpspreadsheet/',
'rename' => 0); 'rename' => 0));
} }
// set uikit // set uikit
if (2 == $uikit || 1 == $uikit) if (2 == $uikit || 1 == $uikit)
{ {
// move the UIKIT Folder into place // move the UIKIT Folder into place
$this->componentData->folders[] = array('folder' => 'uikit-v2', CFactory::_('Component')->appendArray('folders', array('folder' => 'uikit-v2',
'path' => 'media', 'path' => 'media',
'rename' => 0); 'rename' => 0));
} }
if (2 == $uikit || 3 == $uikit) if (2 == $uikit || 3 == $uikit)
{ {
// move the UIKIT-3 Folder into place // move the UIKIT-3 Folder into place
$this->componentData->folders[] = array('folder' => 'uikit-v3', CFactory::_('Component')->appendArray('folders', array('folder' => 'uikit-v3',
'path' => 'media', 'path' => 'media',
'rename' => 0); 'rename' => 0));
} }
// set footable // set footable
@ -2916,21 +2925,21 @@ class Structure extends Get
if ($footable && 2 == $footable_version) if ($footable && 2 == $footable_version)
{ {
// move the footable folder into place // move the footable folder into place
$this->componentData->folders[] = array('folder' => 'footable-v2', CFactory::_('Component')->appendArray('folders', array('folder' => 'footable-v2',
'path' => 'media', 'path' => 'media',
'rename' => 0); 'rename' => 0));
} }
elseif ($footable && 3 == $footable_version) elseif ($footable && 3 == $footable_version)
{ {
// move the footable folder into place // move the footable folder into place
$this->componentData->folders[] = array('folder' => 'footable-v3', CFactory::_('Component')->appendArray('folders', array('folder' => 'footable-v3',
'path' => 'media', 'path' => 'media',
'rename' => 0); 'rename' => 0));
} }
// pointer tracker // pointer tracker
$pointer_tracker = 'h'; $pointer_tracker = 'h';
foreach ($this->componentData->folders as $custom) foreach (CFactory::_('Component')->get('folders') as $custom)
{ {
// check type of target type // check type of target type
$_target_type = 'c0mp0n3nt'; $_target_type = 'c0mp0n3nt';
@ -3026,31 +3035,29 @@ class Structure extends Get
'type' => $custom['target_type']); 'type' => $custom['target_type']);
} }
} }
unset($this->componentData->folders); CFactory::_('Component')->remove('folders');
unset($custom); unset($custom);
} }
// get the google chart switch // get the google chart switch
$google_chart = CFactory::_('Config')->get('google_chart', false); $google_chart = CFactory::_('Config')->get('google_chart', false);
// add custom files // add custom files
if ((isset($this->componentData->files) if (CFactory::_('Component')->isArray('files')
&& ArrayHelper::check( || $google_chart)
$this->componentData->files
)) || $google_chart)
{ {
if ($google_chart) if ($google_chart)
{ {
// move the google chart files // move the google chart files
$this->componentData->files[] = array('file' => 'google.jsapi.js', CFactory::_('Component')->appendArray('files', array('file' => 'google.jsapi.js',
'path' => 'media/js', 'path' => 'media/js',
'rename' => 0); 'rename' => 0));
$this->componentData->files[] = array('file' => 'chartbuilder.php', CFactory::_('Component')->appendArray('files', array('file' => 'chartbuilder.php',
'path' => 'admin/helpers', 'path' => 'admin/helpers',
'rename' => 0); 'rename' => 0));
} }
// pointer tracker // pointer tracker
$pointer_tracker = 'h'; $pointer_tracker = 'h';
foreach ($this->componentData->files as $custom) foreach (CFactory::_('Component')->get('files') as $custom)
{ {
// check type of target type // check type of target type
$_target_type = 'c0mp0n3nt'; $_target_type = 'c0mp0n3nt';
@ -3158,7 +3165,7 @@ class Structure extends Get
$this->updateFileContent[$key_pointer] = true; $this->updateFileContent[$key_pointer] = true;
} }
} }
unset($this->componentData->files); CFactory::_('Component')->remove('files');
unset($custom); unset($custom);
} }
@ -3211,7 +3218,7 @@ class Structure extends Get
$root . $path . '/index.html' $root . $path . '/index.html'
); );
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
} }
else else
{ {
@ -3219,7 +3226,7 @@ class Structure extends Get
$this->templatePath . '/index.html', $root . '/index.html' $this->templatePath . '/index.html', $root . '/index.html'
); );
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
} }
} }

View File

@ -25,6 +25,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
/** /**
* Compiler class * Compiler class
* @deprecated 3.3
*/ */
class Fields extends Structure class Fields extends Structure
{ {
@ -657,7 +658,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(3) . 'readonly="true"'; $fieldSet[] = Indent::_(3) . 'readonly="true"';
$fieldSet[] = Indent::_(2) . "/>"; $fieldSet[] = Indent::_(2) . "/>";
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// if created is not set // if created is not set
if (!isset($this->fieldsNames[$nameSingleCode]['created'])) if (!isset($this->fieldsNames[$nameSingleCode]['created']))
@ -680,7 +681,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(3) . "filter=" . '"user_utc"'; $fieldSet[] = Indent::_(3) . "filter=" . '"user_utc"';
$fieldSet[] = Indent::_(2) . "/>"; $fieldSet[] = Indent::_(2) . "/>";
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// if created_by is not set // if created_by is not set
if (!isset($this->fieldsNames[$nameSingleCode]['created_by'])) if (!isset($this->fieldsNames[$nameSingleCode]['created_by']))
@ -700,7 +701,7 @@ class Fields extends Structure
. '_CREATED_BY_DESC"'; . '_CREATED_BY_DESC"';
$fieldSet[] = Indent::_(2) . "/>"; $fieldSet[] = Indent::_(2) . "/>";
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// if published is not set // if published is not set
if (!isset($this->fieldsNames[$nameSingleCode]['published'])) if (!isset($this->fieldsNames[$nameSingleCode]['published']))
@ -727,7 +728,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(4) . "JTRASHED</option>"; $fieldSet[] = Indent::_(4) . "JTRASHED</option>";
$fieldSet[] = Indent::_(2) . "</field>"; $fieldSet[] = Indent::_(2) . "</field>";
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// if modified is not set // if modified is not set
if (!isset($this->fieldsNames[$nameSingleCode]['modified'])) if (!isset($this->fieldsNames[$nameSingleCode]['modified']))
@ -742,7 +743,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(3) $fieldSet[] = Indent::_(3)
. 'size="22" readonly="true" format="%Y-%m-%d %H:%M:%S" filter="user_utc" />'; . 'size="22" readonly="true" format="%Y-%m-%d %H:%M:%S" filter="user_utc" />';
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// if modified_by is not set // if modified_by is not set
if (!isset($this->fieldsNames[$nameSingleCode]['modified_by'])) if (!isset($this->fieldsNames[$nameSingleCode]['modified_by']))
@ -760,7 +761,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(3) . 'filter="unset"'; $fieldSet[] = Indent::_(3) . 'filter="unset"';
$fieldSet[] = Indent::_(2) . "/>"; $fieldSet[] = Indent::_(2) . "/>";
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// check if view has access // check if view has access
if (isset($this->accessBuilder[$nameSingleCode]) if (isset($this->accessBuilder[$nameSingleCode])
@ -783,7 +784,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(3) . 'required="false"'; $fieldSet[] = Indent::_(3) . 'required="false"';
$fieldSet[] = Indent::_(2) . "/>"; $fieldSet[] = Indent::_(2) . "/>";
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// if ordering is not set // if ordering is not set
if (!isset($this->fieldsNames[$nameSingleCode]['ordering'])) if (!isset($this->fieldsNames[$nameSingleCode]['ordering']))
@ -806,7 +807,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(3) . 'required="false"'; $fieldSet[] = Indent::_(3) . 'required="false"';
$fieldSet[] = Indent::_(2) . "/>"; $fieldSet[] = Indent::_(2) . "/>";
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// if version is not set // if version is not set
if (!isset($this->fieldsNames[$nameSingleCode]['version'])) if (!isset($this->fieldsNames[$nameSingleCode]['version']))
@ -826,7 +827,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(3) . 'filter="unset"'; $fieldSet[] = Indent::_(3) . 'filter="unset"';
$fieldSet[] = Indent::_(2) . "/>"; $fieldSet[] = Indent::_(2) . "/>";
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// check if metadata is added to this view // check if metadata is added to this view
if (isset($this->metadataBuilder[$nameSingleCode]) if (isset($this->metadataBuilder[$nameSingleCode])
@ -850,7 +851,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(3) . 'cols="30"'; $fieldSet[] = Indent::_(3) . 'cols="30"';
$fieldSet[] = Indent::_(2) . "/>"; $fieldSet[] = Indent::_(2) . "/>";
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// metadesc // metadesc
if (!isset($this->fieldsNames[$nameSingleCode]['metadesc'])) if (!isset($this->fieldsNames[$nameSingleCode]['metadesc']))
@ -868,7 +869,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(3) . 'cols="30"'; $fieldSet[] = Indent::_(3) . 'cols="30"';
$fieldSet[] = Indent::_(2) . "/>"; $fieldSet[] = Indent::_(2) . "/>";
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
} }
// fix the permissions field "title" issue gh-629 // fix the permissions field "title" issue gh-629
@ -895,7 +896,7 @@ class Fields extends Structure
. $nameSingleCode . '"'; . $nameSingleCode . '"';
$fieldSet[] = Indent::_(2) . "/>"; $fieldSet[] = Indent::_(2) . "/>";
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
// setup needed field values for layout // setup needed field values for layout
$field_array = array(); $field_array = array();
$field_array['order_edit'] = 0; $field_array['order_edit'] = 0;
@ -956,7 +957,7 @@ class Fields extends Structure
. '<option value="noindex, nofollow">JGLOBAL_NOINDEX_NOFOLLOW</option>'; . '<option value="noindex, nofollow">JGLOBAL_NOINDEX_NOFOLLOW</option>';
$fieldSet[] = Indent::_(3) . '</field>'; $fieldSet[] = Indent::_(3) . '</field>';
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// author // author
if (!isset($this->fieldsNames[$nameSingleCode]['author'])) if (!isset($this->fieldsNames[$nameSingleCode]['author']))
@ -971,7 +972,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(4) . 'size="20"'; $fieldSet[] = Indent::_(4) . 'size="20"';
$fieldSet[] = Indent::_(3) . "/>"; $fieldSet[] = Indent::_(3) . "/>";
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// rights // rights
if (!isset($this->fieldsNames[$nameSingleCode]['rights'])) if (!isset($this->fieldsNames[$nameSingleCode]['rights']))
@ -986,7 +987,7 @@ class Fields extends Structure
$fieldSet[] = Indent::_(4) . 'cols="30" rows="2"'; $fieldSet[] = Indent::_(4) . 'cols="30" rows="2"';
$fieldSet[] = Indent::_(3) . "/>"; $fieldSet[] = Indent::_(3) . "/>";
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
$fieldSet[] = Indent::_(2) . "</fieldset>"; $fieldSet[] = Indent::_(2) . "</fieldset>";
$fieldSet[] = Indent::_(1) . "</fields>"; $fieldSet[] = Indent::_(1) . "</fields>";
@ -1083,7 +1084,7 @@ class Fields extends Structure
$fieldXML = $fieldSetXML->addChild('field'); $fieldXML = $fieldSetXML->addChild('field');
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes); ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// if created is not set // if created is not set
if (!isset($this->fieldsNames[$nameSingleCode]['created'])) if (!isset($this->fieldsNames[$nameSingleCode]['created']))
@ -1105,7 +1106,7 @@ class Fields extends Structure
$fieldXML = $fieldSetXML->addChild('field'); $fieldXML = $fieldSetXML->addChild('field');
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes); ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// if created_by is not set // if created_by is not set
if (!isset($this->fieldsNames[$nameSingleCode]['created_by'])) if (!isset($this->fieldsNames[$nameSingleCode]['created_by']))
@ -1124,7 +1125,7 @@ class Fields extends Structure
$fieldXML = $fieldSetXML->addChild('field'); $fieldXML = $fieldSetXML->addChild('field');
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes); ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// if published is not set // if published is not set
if (!isset($this->fieldsNames[$nameSingleCode]['published'])) if (!isset($this->fieldsNames[$nameSingleCode]['published']))
@ -1142,7 +1143,7 @@ class Fields extends Structure
$fieldXML = $fieldSetXML->addChild('field'); $fieldXML = $fieldSetXML->addChild('field');
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes); ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
foreach ( foreach (
array('JPUBLISHED' => 1, 'JUNPUBLISHED' => 0, 'JARCHIVED' => 2, array('JPUBLISHED' => 1, 'JUNPUBLISHED' => 0, 'JARCHIVED' => 2,
'JTRASHED' => -2) as $text => $value 'JTRASHED' => -2) as $text => $value
@ -1174,7 +1175,7 @@ class Fields extends Structure
$fieldXML = $fieldSetXML->addChild('field'); $fieldXML = $fieldSetXML->addChild('field');
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes); ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// if modified_by is not set // if modified_by is not set
if (!isset($this->fieldsNames[$nameSingleCode]['modified_by'])) if (!isset($this->fieldsNames[$nameSingleCode]['modified_by']))
@ -1195,7 +1196,7 @@ class Fields extends Structure
$fieldXML = $fieldSetXML->addChild('field'); $fieldXML = $fieldSetXML->addChild('field');
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes); ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// check if view has access // check if view has access
if (isset($this->accessBuilder[$nameSingleCode]) if (isset($this->accessBuilder[$nameSingleCode])
@ -1220,7 +1221,7 @@ class Fields extends Structure
$fieldXML = $fieldSetXML->addChild('field'); $fieldXML = $fieldSetXML->addChild('field');
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes); ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// if ordering is not set // if ordering is not set
if (!isset($this->fieldsNames[$nameSingleCode]['ordering'])) if (!isset($this->fieldsNames[$nameSingleCode]['ordering']))
@ -1243,7 +1244,7 @@ class Fields extends Structure
$fieldXML = $fieldSetXML->addChild('field'); $fieldXML = $fieldSetXML->addChild('field');
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes); ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// if version is not set // if version is not set
if (!isset($this->fieldsNames[$nameSingleCode]['version'])) if (!isset($this->fieldsNames[$nameSingleCode]['version']))
@ -1265,7 +1266,7 @@ class Fields extends Structure
$fieldXML = $fieldSetXML->addChild('field'); $fieldXML = $fieldSetXML->addChild('field');
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes); ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// check if metadata is added to this view // check if metadata is added to this view
if (isset($this->metadataBuilder[$nameSingleCode]) if (isset($this->metadataBuilder[$nameSingleCode])
@ -1293,7 +1294,7 @@ class Fields extends Structure
$fieldXML, $attributes $fieldXML, $attributes
); );
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// metadesc // metadesc
if (!isset($this->fieldsNames[$nameSingleCode]['metadesc'])) if (!isset($this->fieldsNames[$nameSingleCode]['metadesc']))
@ -1310,7 +1311,7 @@ class Fields extends Structure
$fieldXML, $attributes $fieldXML, $attributes
); );
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
} }
// fix the permissions field "title" issue gh-629 // fix the permissions field "title" issue gh-629
@ -1345,7 +1346,7 @@ class Fields extends Structure
$fieldXML = $fieldSetXML->addChild('field'); $fieldXML = $fieldSetXML->addChild('field');
ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes); ComponentbuilderHelper::xmlAddAttributes($fieldXML, $attributes);
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
// setup needed field values for layout // setup needed field values for layout
$field_array = array(); $field_array = array();
$field_array['order_edit'] = 0; $field_array['order_edit'] = 0;
@ -1408,7 +1409,7 @@ class Fields extends Structure
$robots, $attributes $robots, $attributes
); );
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
$options = array( $options = array(
'JGLOBAL_USE_GLOBAL' => '', 'JGLOBAL_USE_GLOBAL' => '',
'JGLOBAL_INDEX_FOLLOW' => 'index, follow', 'JGLOBAL_INDEX_FOLLOW' => 'index, follow',
@ -1442,7 +1443,7 @@ class Fields extends Structure
$author, $attributes $author, $attributes
); );
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
// rights // rights
if (!isset($this->fieldsNames[$nameSingleCode]['rights'])) if (!isset($this->fieldsNames[$nameSingleCode]['rights']))
@ -1466,7 +1467,7 @@ class Fields extends Structure
$rights, $attributes $rights, $attributes
); );
// count the static field created // count the static field created
$this->fieldCount++; CFactory::_('Counter')->field++;
} }
} }
} }
@ -1890,7 +1891,7 @@ class Fields extends Structure
&$optionArray, $custom = null, $taber = '' &$optionArray, $custom = null, $taber = ''
) { ) {
// count the dynamic fields created // count the dynamic fields created
$this->fieldCount++; CFactory::_('Counter')->field++;
// check what type of field builder to use // check what type of field builder to use
if (CFactory::_('Config')->get('field_builder_type', 2) == 1) if (CFactory::_('Config')->get('field_builder_type', 2) == 1)
{ {
@ -4780,13 +4781,8 @@ class Fields extends Structure
// load to list builder // load to list builder
if ($listSwitch) if ($listSwitch)
{ {
// check if it does not exists
if (!CFactory::_('Registry')->exists('builder.list.' . $nameListCode))
{
CFactory::_('Registry')->set('builder.list.' . $nameListCode, []);
}
// append values // append values
CFactory::_('Registry')->append('builder.list.' . $nameListCode, [ CFactory::_('Registry')->appendArray('builder.list.' . $nameListCode, [
'id' => (int) $field['field'], 'id' => (int) $field['field'],
'type' => $typeName, 'type' => $typeName,
'code' => $name, 'code' => $name,

File diff suppressed because it is too large Load Diff

View File

@ -27,6 +27,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Utilities\Minify;
/** /**
* Infusion class * Infusion class
* @deprecated 3.3
*/ */
class Infusion extends Interpretation class Infusion extends Interpretation
{ {
@ -73,10 +74,7 @@ class Infusion extends Interpretation
*/ */
protected function buildFileContent() protected function buildFileContent()
{ {
if (isset($this->componentData->admin_views) if (CFactory::_('Component')->isArray('admin_views'))
&& ArrayHelper::check(
$this->componentData->admin_views
))
{ {
// for plugin event TODO change event api signatures // for plugin event TODO change event api signatures
$placeholders = CFactory::_('Placeholder')->active; $placeholders = CFactory::_('Placeholder')->active;
@ -104,13 +102,14 @@ class Infusion extends Interpretation
CFactory::_('Content')->set('component', CFactory::_('Placeholder')->get('component')); CFactory::_('Content')->set('component', CFactory::_('Placeholder')->get('component'));
// COMPANYNAME // COMPANYNAME
$companyname = CFactory::_('Component')->get('companyname');
CFactory::_('Content')->set('COMPANYNAME', trim( CFactory::_('Content')->set('COMPANYNAME', trim(
(string) JFilterOutput::cleanText($this->componentData->companyname) (string) JFilterOutput::cleanText($companyname)
)); ));
// CREATIONDATE // CREATIONDATE
CFactory::_('Content')->set('CREATIONDATE', CFactory::_('Content')->set('CREATIONDATE',
JFactory::getDate($this->componentData->created)->format( JFactory::getDate(CFactory::_('Component')->get('created'))->format(
'jS F, Y' 'jS F, Y'
)); ));
CFactory::_('Content')->set('GLOBALCREATIONDATE', CFactory::_('Content')->set('GLOBALCREATIONDATE',
@ -122,24 +121,25 @@ class Infusion extends Interpretation
CFactory::_('Content')->get('BUILDDATE')); CFactory::_('Content')->get('BUILDDATE'));
// AUTHOR // AUTHOR
$author = CFactory::_('Component')->get('author');
CFactory::_('Content')->set('AUTHOR', trim( CFactory::_('Content')->set('AUTHOR', trim(
(string) JFilterOutput::cleanText($this->componentData->author) (string) JFilterOutput::cleanText($author)
)); ));
// AUTHOREMAIL // AUTHOREMAIL
CFactory::_('Content')->set('AUTHOREMAIL', trim((string) $this->componentData->email)); CFactory::_('Content')->set('AUTHOREMAIL', trim((string) CFactory::_('Component')->get('email', '')));
// AUTHORWEBSITE // AUTHORWEBSITE
CFactory::_('Content')->set('AUTHORWEBSITE', trim((string) $this->componentData->website)); CFactory::_('Content')->set('AUTHORWEBSITE', trim((string) CFactory::_('Component')->get('website', '')));
// COPYRIGHT // COPYRIGHT
CFactory::_('Content')->set('COPYRIGHT', trim((string) $this->componentData->copyright)); CFactory::_('Content')->set('COPYRIGHT', trim((string) CFactory::_('Component')->get('copyright', '')));
// LICENSE // LICENSE
CFactory::_('Content')->set('LICENSE', trim((string) $this->componentData->license)); CFactory::_('Content')->set('LICENSE', trim((string) CFactory::_('Component')->get('license', '')));
// VERSION // VERSION
CFactory::_('Content')->set('VERSION', trim((string) $this->componentData->component_version)); CFactory::_('Content')->set('VERSION', trim((string) CFactory::_('Component')->get('component_version', '')));
// set the actual global version // set the actual global version
CFactory::_('Content')->set('ACTUALVERSION', CFactory::_('Content')->get('VERSION')); CFactory::_('Content')->set('ACTUALVERSION', CFactory::_('Content')->get('VERSION'));
@ -154,7 +154,7 @@ class Infusion extends Interpretation
if (isset($versionArray) if (isset($versionArray)
&& ArrayHelper::check( && ArrayHelper::check(
$versionArray $versionArray
) && $this->componentData->mvc_versiondate == 2) ) && CFactory::_('Component')->get('mvc_versiondate', 0) == 2)
{ {
CFactory::_('Content')->set('VERSION', $versionArray[0] . '.' . $versionArray[1] . '.x'); CFactory::_('Content')->set('VERSION', $versionArray[0] . '.' . $versionArray[1] . '.x');
} }
@ -162,7 +162,7 @@ class Infusion extends Interpretation
elseif (isset($versionArray) elseif (isset($versionArray)
&& ArrayHelper::check( && ArrayHelper::check(
$versionArray $versionArray
) && $this->componentData->mvc_versiondate == 3) ) && CFactory::_('Component')->get('mvc_versiondate', 0) == 3)
{ {
CFactory::_('Content')->set('VERSION', $versionArray[0] . '.x.x'); CFactory::_('Content')->set('VERSION', $versionArray[0] . '.x.x');
} }
@ -175,20 +175,22 @@ class Infusion extends Interpretation
CFactory::_('Content')->set('XMLVERSION', $this->joomlaVersions[CFactory::_('Config')->joomla_version]['xml_version']); CFactory::_('Content')->set('XMLVERSION', $this->joomlaVersions[CFactory::_('Config')->joomla_version]['xml_version']);
// Component_name // Component_name
CFactory::_('Content')->set('Component_name', JFilterOutput::cleanText($this->componentData->name)); $name = CFactory::_('Component')->get('name');
CFactory::_('Content')->set('Component_name', JFilterOutput::cleanText($name));
// SHORT_DISCRIPTION // SHORT_DISCRIPTION
$short_description = CFactory::_('Component')->get('short_description');
CFactory::_('Content')->set('SHORT_DESCRIPTION', trim( CFactory::_('Content')->set('SHORT_DESCRIPTION', trim(
(string) JFilterOutput::cleanText( (string) JFilterOutput::cleanText(
$this->componentData->short_description $short_description
) )
)); ));
// DESCRIPTION // DESCRIPTION
CFactory::_('Content')->set('DESCRIPTION', trim((string) $this->componentData->description)); CFactory::_('Content')->set('DESCRIPTION', trim((string) CFactory::_('Component')->get('description')));
// COMP_IMAGE_TYPE // COMP_IMAGE_TYPE
CFactory::_('Content')->set('COMP_IMAGE_TYPE', $this->setComponentImageType($this->componentData->image)); CFactory::_('Content')->set('COMP_IMAGE_TYPE', $this->setComponentImageType(CFactory::_('Component')->get('image')));
// ACCESS_SECTIONS // ACCESS_SECTIONS
CFactory::_('Content')->set('ACCESS_SECTIONS', $this->setAccessSections()); CFactory::_('Content')->set('ACCESS_SECTIONS', $this->setAccessSections());
@ -247,7 +249,7 @@ class Infusion extends Interpretation
CFactory::_('Content')->set('ADMIN_GLOBAL_EVENT_HELPER', ''); CFactory::_('Content')->set('ADMIN_GLOBAL_EVENT_HELPER', '');
} }
// now load the data for the global event if needed // now load the data for the global event if needed
if ($this->componentData->add_admin_event == 1) if (CFactory::_('Component')->get('add_admin_event', 0) == 1)
{ {
// ADMIN_GLOBAL_EVENT // ADMIN_GLOBAL_EVENT
CFactory::_('Content')->add('ADMIN_GLOBAL_EVENT', PHP_EOL . PHP_EOL . '// Trigger the Global Admin Event'); CFactory::_('Content')->add('ADMIN_GLOBAL_EVENT', PHP_EOL . PHP_EOL . '// Trigger the Global Admin Event');
@ -272,7 +274,7 @@ class Infusion extends Interpretation
} }
// now load the readme file if needed // now load the readme file if needed
if ($this->componentData->addreadme == 1) if (CFactory::_('Component')->get('addreadme', 0) == 1)
{ {
CFactory::_('Content')->add('EXSTRA_ADMIN_FILES', CFactory::_('Content')->add('EXSTRA_ADMIN_FILES',
PHP_EOL . Indent::_(3) PHP_EOL . Indent::_(3)
@ -282,7 +284,7 @@ class Infusion extends Interpretation
// HELPER_CREATEUSER // HELPER_CREATEUSER
CFactory::_('Content')->add('HELPER_CREATEUSER', CFactory::_('Content')->add('HELPER_CREATEUSER',
$this->setCreateUserHelperMethod( $this->setCreateUserHelperMethod(
$this->componentData->creatuserhelper CFactory::_('Component')->get('creatuserhelper')
)); ));
// HELP // HELP
@ -310,7 +312,7 @@ class Infusion extends Interpretation
$viewarray = array(); $viewarray = array();
$site_edit_view_array = array(); $site_edit_view_array = array();
// start dynamic build // start dynamic build
foreach ($this->componentData->admin_views as $view) foreach (CFactory::_('Component')->get('admin_views') as $view)
{ {
// set the target // set the target
CFactory::_('Config')->build_target = 'admin'; CFactory::_('Config')->build_target = 'admin';
@ -1041,15 +1043,12 @@ class Infusion extends Interpretation
$this->setCustomViewLayouts(); $this->setCustomViewLayouts();
// setup custom_admin_views and all needed stuff for the site // setup custom_admin_views and all needed stuff for the site
if (isset($this->componentData->custom_admin_views) if (CFactory::_('Component')->isArray('custom_admin_views'))
&& ArrayHelper::check(
$this->componentData->custom_admin_views
))
{ {
CFactory::_('Config')->build_target = 'custom_admin'; CFactory::_('Config')->build_target = 'custom_admin';
CFactory::_('Config')->lang_target = 'admin'; CFactory::_('Config')->lang_target = 'admin';
// start dynamic build // start dynamic build
foreach ($this->componentData->custom_admin_views as $view) foreach (CFactory::_('Component')->get('custom_admin_views') as $view)
{ {
// for single views // for single views
CFactory::_('Content')->set_($view['settings']->code, 'SView', $view['settings']->Code); CFactory::_('Content')->set_($view['settings']->code, 'SView', $view['settings']->Code);
@ -1455,14 +1454,11 @@ class Infusion extends Interpretation
CFactory::_('Config')->lang_target = $keepLang; CFactory::_('Config')->lang_target = $keepLang;
// setup front-views and all needed stuff for the site // setup front-views and all needed stuff for the site
if (isset($this->componentData->site_views) if (CFactory::_('Component')->isArray('site_views'))
&& ArrayHelper::check(
$this->componentData->site_views
))
{ {
CFactory::_('Config')->build_target = 'site'; CFactory::_('Config')->build_target = 'site';
// start dynamic build // start dynamic build
foreach ($this->componentData->site_views as $view) foreach (CFactory::_('Component')->get('site_views') as $view)
{ {
// for list views // for list views
CFactory::_('Content')->set_($view['settings']->code, 'SViews', $view['settings']->Code); CFactory::_('Content')->set_($view['settings']->code, 'SViews', $view['settings']->Code);
@ -1725,7 +1721,7 @@ class Infusion extends Interpretation
CFactory::_('Content')->set('SITE_GLOBAL_EVENT_HELPER', ''); CFactory::_('Content')->set('SITE_GLOBAL_EVENT_HELPER', '');
} }
// now load the data for the global event if needed // now load the data for the global event if needed
if ($this->componentData->add_site_event == 1) if (CFactory::_('Component')->get('add_site_event', 0) == 1)
{ {
CFactory::_('Content')->add('SITE_GLOBAL_EVENT', PHP_EOL . PHP_EOL . '// Trigger the Global Site Event'); CFactory::_('Content')->add('SITE_GLOBAL_EVENT', PHP_EOL . PHP_EOL . '// Trigger the Global Site Event');
CFactory::_('Content')->add('SITE_GLOBAL_EVENT', CFactory::_('Content')->add('SITE_GLOBAL_EVENT',
@ -1796,9 +1792,9 @@ class Infusion extends Interpretation
} }
// README // README
if ($this->componentData->addreadme) if (CFactory::_('Component')->get('addreadme'))
{ {
CFactory::_('Content')->set('README', $this->componentData->readme); CFactory::_('Content')->set('README', CFactory::_('Component')->get('readme'));
} }
// Infuse POWERS // Infuse POWERS
@ -1809,9 +1805,9 @@ class Infusion extends Interpretation
$_backup_lang = CFactory::_('Config')->lang_target; $_backup_lang = CFactory::_('Config')->lang_target;
$_backup_langPrefix = CFactory::_('Config')->lang_prefix; $_backup_langPrefix = CFactory::_('Config')->lang_prefix;
// infuse module data if set // infuse module data if set
if (ArrayHelper::check($this->joomlaModules)) if (CFactory::_('Joomlamodule.Data')->exists())
{ {
foreach ($this->joomlaModules as $module) foreach (CFactory::_('Joomlamodule.Data')->get() as $module)
{ {
if (ObjectHelper::check($module)) if (ObjectHelper::check($module))
{ {
@ -1877,9 +1873,9 @@ class Infusion extends Interpretation
} }
} }
// infuse plugin data if set // infuse plugin data if set
if (ArrayHelper::check($this->joomlaPlugins)) if (CFactory::_('Joomlaplugin.Data')->exists())
{ {
foreach ($this->joomlaPlugins as $plugin) foreach (CFactory::_('Joomlaplugin.Data')->get() as $plugin)
{ {
if (ObjectHelper::check($plugin)) if (ObjectHelper::check($plugin))
{ {
@ -1946,7 +1942,7 @@ class Infusion extends Interpretation
CFactory::_('Event')->trigger( CFactory::_('Event')->trigger(
'jcb_ce_onAfterBuildFilesContent', 'jcb_ce_onAfterBuildFilesContent',
array(&$component_context, &$this->componentData, array(&$component_context, &$this->componentData,
&$fileContentStatic, &$this->fileContentDynamic, &$fileContentStatic, &$fileContentDynamic,
&$placeholders, &$this->hhh) &$placeholders, &$this->hhh)
); );
unset($fileContentStatic); unset($fileContentStatic);
@ -2153,17 +2149,16 @@ class Infusion extends Interpretation
{ {
Folder::create($path); Folder::create($path);
// count the folder created // count the folder created
$this->folderCount++; CFactory::_('Counter')->folder++;
} }
// move the file to its place // move the file to its place
File::copy($getPAth, $path . $file_name); File::copy($getPAth, $path . $file_name);
// count the file created // count the file created
$this->fileCount++; CFactory::_('Counter')->file++;
// add content to it // add content to it
$lang = array_map( $lang = array_map(
function ($langstring, $placeholder) { fn($langstring, $placeholder) => $placeholder . '="' . $langstring . '"',
return $placeholder . '="' . $langstring . '"'; array_values($languageStrings),
}, array_values($languageStrings),
array_keys($languageStrings) array_keys($languageStrings)
); );
// add to language file // add to language file
@ -2171,7 +2166,7 @@ class Infusion extends Interpretation
$path . $file_name, implode(PHP_EOL, $lang) $path . $file_name, implode(PHP_EOL, $lang)
); );
// set the line counter // set the line counter
$this->lineCount = $this->lineCount + count( CFactory::_('Counter')->line += count(
(array) $lang (array) $lang
); );
unset($lang); unset($lang);

View File

@ -5605,6 +5605,7 @@ COM_COMPONENTBUILDER_HR_HTHREECUSTOM_CODES_WARNINGHTHREE="<hr /><h3>Custom Codes
COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_ERRORHTHREE="<hr /><h3>External Code Error</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_NOTICEHTHREE="<hr /><h3>External Code Notice</h3>"
COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_WARNINGHTHREE="<hr /><h3>External Code Warning</h3>" COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_WARNINGHTHREE="<hr /><h3>External Code Warning</h3>"
COM_COMPONENTBUILDER_HR_HTHREEFIELD_NOTICEHTHREE="<hr /><h3>Field Notice</h3>"
COM_COMPONENTBUILDER_HTHREEPLACEHOLDER_REMOVEDHTHREEPBTHISB_CUSTOM_CODE_CAN_ONLY_BE_USED_IN_BOTHERB_CUSTOM_CODE_NOT_IN_IT_SELF_SINCE_THAT_WILL_CAUSE_A_INFINITE_LOOP_IN_THE_COMPILERP="<h3>Placeholder Removed!</h3><p><b>This</b> custom code can only be used in <b>other</b> custom code, not in it self! Since that will cause a infinite loop in the compiler.</p>" COM_COMPONENTBUILDER_HTHREEPLACEHOLDER_REMOVEDHTHREEPBTHISB_CUSTOM_CODE_CAN_ONLY_BE_USED_IN_BOTHERB_CUSTOM_CODE_NOT_IN_IT_SELF_SINCE_THAT_WILL_CAUSE_A_INFINITE_LOOP_IN_THE_COMPILERP="<h3>Placeholder Removed!</h3><p><b>This</b> custom code can only be used in <b>other</b> custom code, not in it self! Since that will cause a infinite loop in the compiler.</p>"
COM_COMPONENTBUILDER_HTHREESHTHREEPCUSTOM_CODE_CAN_ONLY_BE_USED_IN_OTHER_CUSTOM_CODE_IF_SET_AS_BJCB_MANUALB_YOU_CAN_NOT_ADD_THEM_TO_EMHASH_AUTOMATIONEM_CODE_AT_THIS_POINTP="<h3>%s</h3><p>Custom code can only be used in other custom code if set as <b>JCB (manual)</b>, you can not add them to <em>Hash (Automation)</em> code at this point.</p>" COM_COMPONENTBUILDER_HTHREESHTHREEPCUSTOM_CODE_CAN_ONLY_BE_USED_IN_OTHER_CUSTOM_CODE_IF_SET_AS_BJCB_MANUALB_YOU_CAN_NOT_ADD_THEM_TO_EMHASH_AUTOMATIONEM_CODE_AT_THIS_POINTP="<h3>%s</h3><p>Custom code can only be used in other custom code if set as <b>JCB (manual)</b>, you can not add them to <em>Hash (Automation)</em> code at this point.</p>"
COM_COMPONENTBUILDER_HTHREES_NAMESPACE_ERROR_SHTHREEPYOU_MUST_ATLEAST_HAVE_TWO_SECTIONS_IN_YOUR_NAMESPACE_YOU_JUST_HAVE_ONE_S_THIS_IS_AN_UNACCEPTABLE_ACTION_PLEASE_SEE_A_HREFS_PSRFOURA_FOR_MORE_INFOPPTHIS_S_WAS_THEREFORE_REMOVED_A_HREFSCLICK_HEREA_TO_FIX_THIS_ISSUEP="<h3>%s namespace error (%s)</h3><p>You must at-least have two sections in your namespace, you just have one (%s). This is an unacceptable action, please see <a href=%s >psr-4</a> for more info.</p><p>This %s was therefore removed, <a href=%s>click here</a> to fix this issue.</p>" COM_COMPONENTBUILDER_HTHREES_NAMESPACE_ERROR_SHTHREEPYOU_MUST_ATLEAST_HAVE_TWO_SECTIONS_IN_YOUR_NAMESPACE_YOU_JUST_HAVE_ONE_S_THIS_IS_AN_UNACCEPTABLE_ACTION_PLEASE_SEE_A_HREFS_PSRFOURA_FOR_MORE_INFOPPTHIS_S_WAS_THEREFORE_REMOVED_A_HREFSCLICK_HEREA_TO_FIX_THIS_ISSUEP="<h3>%s namespace error (%s)</h3><p>You must at-least have two sections in your namespace, you just have one (%s). This is an unacceptable action, please see <a href=%s >psr-4</a> for more info.</p><p>This %s was therefore removed, <a href=%s>click here</a> to fix this issue.</p>"

View File

@ -425,9 +425,8 @@
buttons="add,remove,move" buttons="add,remove,move"
description="COM_COMPONENTBUILDER_POWER_USE_SELECTION_DESCRIPTION" description="COM_COMPONENTBUILDER_POWER_USE_SELECTION_DESCRIPTION"
icon="list" icon="list"
max="30" max="100"
min="0" min="0">
showon="type!:interface">
<form hidden="true" name="list_use_selection_modal" repeat="true"> <form hidden="true" name="list_use_selection_modal" repeat="true">
<!-- Use Field. Type: Namespaces. (custom) --> <!-- Use Field. Type: Namespaces. (custom) -->
<field <field

File diff suppressed because one or more lines are too long

View File

@ -92,7 +92,6 @@ class ComponentbuilderViewGet_snippets extends HtmlView
{ {
// Set the default uikit components in this view. // Set the default uikit components in this view.
$uikitComp = array(); $uikitComp = array();
$uikitComp[] = 'UIkit.notify';
$uikitComp[] = 'data-uk-grid'; $uikitComp[] = 'data-uk-grid';
} }

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="4" method="upgrade"> <extension type="component" version="4" method="upgrade">
<name>COM_COMPONENTBUILDER</name> <name>COM_COMPONENTBUILDER</name>
<creationDate>15th January, 2023</creationDate> <creationDate>22nd January, 2023</creationDate>
<author>Llewellyn van der Merwe</author> <author>Llewellyn van der Merwe</author>
<authorEmail>joomla@vdm.io</authorEmail> <authorEmail>joomla@vdm.io</authorEmail>
<authorUrl>https://dev.vdm.io</authorUrl> <authorUrl>https://dev.vdm.io</authorUrl>

View File

@ -58,7 +58,7 @@ abstract class AbstractGiteaObject
$this->options = $options ?: new Registry; $this->options = $options ?: new Registry;
$this->client = $client ?: (new HttpFactory)->getHttp($this->options); $this->client = $client ?: (new HttpFactory)->getHttp($this->options);
$this->package = \get_class($this); $this->package = static::class;
$this->package = substr($this->package, strrpos($this->package, '\\') + 1); $this->package = substr($this->package, strrpos($this->package, '\\') + 1);
} }
@ -137,7 +137,7 @@ abstract class AbstractGiteaObject
if ($response->code != $expectedCode) if ($response->code != $expectedCode)
{ {
// Decode the error response and throw an exception. // Decode the error response and throw an exception.
$error = json_decode($response->body); $error = json_decode((string) $response->body);
$message = isset($error->message) ? $error->message : 'Invalid response received from Gitea.'; $message = isset($error->message) ? $error->message : 'Invalid response received from Gitea.';
throw new \DomainException($message, $response->code); throw new \DomainException($message, $response->code);
@ -145,11 +145,11 @@ abstract class AbstractGiteaObject
if (JsonHelper::check($response->body)) if (JsonHelper::check($response->body))
{ {
$body = json_decode($response->body); $body = json_decode((string) $response->body);
if (isset($body->content_base64)) if (isset($body->content_base64))
{ {
$body->content = base64_decode($body->content_base64); $body->content = base64_decode((string) $body->content_base64);
} }
} }
else else

View File

@ -30,7 +30,7 @@ abstract class AbstractPackage extends AbstractGiteaObject
{ {
parent::__construct($options, $client); parent::__construct($options, $client);
$this->package = \get_class($this); $this->package = static::class;
$this->package = substr($this->package, strrpos($this->package, '\\') + 1); $this->package = substr($this->package, strrpos($this->package, '\\') + 1);
} }

View File

@ -108,7 +108,7 @@ abstract class BaseConfig extends JoomlaRegistry
public function get($path, $default = null) public function get($path, $default = null)
{ {
// function name with no underscores // function name with no underscores
$method = 'get' . ucfirst(ClassfunctionHelper::safe(str_replace('_', '', $path))); $method = 'get' . ucfirst((string) ClassfunctionHelper::safe(str_replace('_', '', $path)));
// check if it has been set // check if it has been set
if (($value = parent::get($path, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_') if (($value = parent::get($path, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')
@ -126,6 +126,27 @@ abstract class BaseConfig extends JoomlaRegistry
return $default; return $default;
} }
/**
* Append value to a path in registry of an array
*
* @param string $path Parent registry Path (e.g. joomla.content.showauthor)
* @param mixed $value Value of entry
*
* @return mixed The value of the that has been set.
*
* @since 3.2.0
*/
public function appendArray(string $path, $value)
{
// check if it does not exist
if (!$this->exists($path))
{
$this->set($path, []);
}
return $this->append($path, $value);
}
} }

View File

@ -44,6 +44,107 @@ abstract class BaseRegistry extends JoomlaRegistry implements \JsonSerializable,
return $data->getIterator(); return $data->getIterator();
} }
/**
* Append value to a path in registry of an array
*
* @param string $path Parent registry Path (e.g. joomla.content.showauthor)
* @param mixed $value Value of entry
*
* @return mixed The value of the that has been set.
*
* @since 3.2.0
*/
public function appendArray(string $path, $value)
{
// check if it does not exist
if (!$this->exists($path))
{
$this->set($path, []);
}
return $this->append($path, $value);
}
/**
* Check if a registry path exists and is an array
*
* @param string $path Registry path (e.g. joomla.content.showauthor)
*
* @return boolean
*
* @since 3.2.0
*/
public function isArray(string $path): bool
{
// Return default value if path is empty
if (empty($path)) {
return false;
}
// get the value
if (($node = $this->get($path)) !== null
&& is_array($node)
&& $node !== [])
{
return true;
}
return false;
}
/**
* Check if a registry path exists and is a string
*
* @param string $path Registry path (e.g. joomla.content.showauthor)
*
* @return boolean
*
* @since 3.2.0
*/
public function isString(string $path): bool
{
// Return default value if path is empty
if (empty($path)) {
return false;
}
// get the value
if (($node = $this->get($path)) !== null
&& is_string($node)
&& strlen((string) $node) > 0)
{
return true;
}
return false;
}
/**
* Check if a registry path exists and is numeric
*
* @param string $path Registry path (e.g. joomla.content.showauthor)
*
* @return boolean
*
* @since 3.2.0
*/
public function isNumeric(string $path): bool
{
// Return default value if path is empty
if (empty($path)) {
return false;
}
// get the value
if (($node = $this->get($path)) !== null
&& is_numeric($node))
{
return true;
}
return false;
}
} }

View File

@ -50,7 +50,6 @@ abstract class Mapper implements Mapperdoubleinterface, Mappersingleinterface
* Get content * Get content
* *
* @param string $key The main string key * @param string $key The main string key
* @param mixed $value The values to set
* *
* @return mixed * @return mixed
* @since 3.2.0 * @since 3.2.0
@ -148,8 +147,8 @@ abstract class Mapper implements Mapperdoubleinterface, Mappersingleinterface
/** /**
* Get dynamic content * Get dynamic content
* *
* @param string $firstKey The first key * @param string $firstKey The first key
* @param string $secondKey The second key * @param string|null $secondKey The second key
* *
* @return mixed * @return mixed
* @since 3.2.0 * @since 3.2.0

View File

@ -0,0 +1,545 @@
<?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\Adminview;
use Joomla\CMS\Factory;
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\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Model\Customtabs;
use VDM\Joomla\Componentbuilder\Compiler\Model\Tabs;
use VDM\Joomla\Componentbuilder\Compiler\Model\Fields;
use VDM\Joomla\Componentbuilder\Compiler\Model\Historyadminview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Permissions;
use VDM\Joomla\Componentbuilder\Compiler\Model\Conditions;
use VDM\Joomla\Componentbuilder\Compiler\Model\Relations;
use VDM\Joomla\Componentbuilder\Compiler\Model\Linkedviews;
use VDM\Joomla\Componentbuilder\Compiler\Model\Javascriptadminview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Cssadminview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Phpadminview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Custombuttons;
use VDM\Joomla\Componentbuilder\Compiler\Model\Customimportscripts;
use VDM\Joomla\Componentbuilder\Compiler\Model\Ajaxadmin;
use VDM\Joomla\Componentbuilder\Compiler\Model\Customalias;
use VDM\Joomla\Componentbuilder\Compiler\Model\Sql;
use VDM\Joomla\Componentbuilder\Compiler\Model\Mysqlsettings;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Admin View Data Class
*
* @since 3.2.0
*/
class Data
{
/**
* Admin views
*
* @var array
* @since 3.2.0
*/
protected array $data;
/**
* 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 Placeholder
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* The modelling customtabs
*
* @var Customtabs
* @since 3.2.0
*/
protected Customtabs $customtabs;
/**
* The modelling tabs
*
* @var Tabs
* @since 3.2.0
*/
protected Tabs $tabs;
/**
* The modelling fields
*
* @var Fields
* @since 3.2.0
*/
protected Fields $fields;
/**
* The modelling admin view history
*
* @var Historyadminview
* @since 3.2.0
*/
protected Historyadminview $history;
/**
* The modelling permissions
*
* @var Permissions
* @since 3.2.0
*/
protected Permissions $permissions;
/**
* The modelling conditions
*
* @var Conditions
* @since 3.2.0
*/
protected Conditions $conditions;
/**
* The modelling relations
*
* @var Relations
* @since 3.2.0
*/
protected Relations $relations;
/**
* The modelling linked views
*
* @var Linkedviews
* @since 3.2.0
*/
protected Linkedviews $linkedviews;
/**
* The modelling javascript
*
* @var Javascriptadminview
* @since 3.2.0
*/
protected Javascriptadminview $javascript;
/**
* The modelling css
*
* @var Cssadminview
* @since 3.2.0
*/
protected Cssadminview $css;
/**
* The modelling php admin view
*
* @var Phpadminview
* @since 3.2.0
*/
protected Phpadminview $php;
/**
* The modelling custom buttons
*
* @var Custombuttons
* @since 3.2.0
*/
protected Custombuttons $custombuttons;
/**
* The modelling custom import scripts
*
* @var Customimportscripts
* @since 3.2.0
*/
protected Customimportscripts $customimportscripts;
/**
* The modelling ajax
*
* @var Ajaxadmin
* @since 3.2.0
*/
protected Ajaxadmin $ajax;
/**
* The modelling custom alias
*
* @var Customalias
* @since 3.2.0
*/
protected Customalias $customalias;
/**
* The modelling sql
*
* @var Sql
* @since 3.2.0
*/
protected Sql $sql;
/**
* The modelling mysql settings
*
* @var Mysqlsettings
* @since 3.2.0
*/
protected Mysqlsettings $mysqlsettings;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
/**
* 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 Placeholder|null $placeholder The compiler placeholder object.
* @param Dispenser|null $dispenser The compiler customcode dispenser object.
* @param Customtabs|null $customtabs The modelling customtabs object.
* @param Tabs|null $tabs The modelling tabs object.
* @param Fields|null $fields The modelling fields object.
* @param Historyadminview|null $history The modelling admin view history object.
* @param Permissions|null $permissions The modelling permissions object.
* @param Conditions|null $conditions The modelling conditions object.
* @param Relations|null $relations The modelling relations object.
* @param Linkedviews|null $linkedviews The modelling linked views object.
* @param Javascriptadminview|null $javascript The modelling javascript object.
* @param Cssadminview|null $css The modelling css object.
* @param Phpadminview|null $php The modelling php admin view object.
* @param Custombuttons|null $custombuttons The modelling custom buttons object.
* @param Customimportscripts|null $customimportscripts The modelling custom import scripts object.
* @param Ajaxadmin|null $ajax The modelling ajax object.
* @param Customalias|null $customalias The modelling custom alias object.
* @param Sql|null $sql The modelling sql object.
* @param Mysqlsettings|null $mysqlsettings The modelling mysql settings object.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry = null,
?EventInterface $event = null, ?Placeholder $placeholder = null, ?Dispenser $dispenser = null,
?Customtabs $customtabs = null, ?Tabs $tabs = null, ?Fields $fields = null,
?Historyadminview $history = null, ?Permissions $permissions = null,
?Conditions $conditions = null, Relations $relations = null, ?Linkedviews $linkedviews = null,
?Javascriptadminview $javascript = null, ?Cssadminview $css = null, ?Phpadminview $php = null,
?Custombuttons $custombuttons = null, ?Customimportscripts $customimportscripts = null,
?Ajaxadmin $ajax = null, ?Customalias $customalias = null, ?Sql $sql = null,
?Mysqlsettings $mysqlsettings = null, ?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->event = $event ?: Compiler::_('Event');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
$this->customtabs = $customtabs ?: Compiler::_('Model.Customtabs');
$this->tabs = $tabs ?: Compiler::_('Model.Tabs');
$this->fields = $fields ?: Compiler::_('Model.Fields');
$this->history = $history ?: Compiler::_('Model.Historyadminview');
$this->permissions = $permissions ?: Compiler::_('Model.Permissions');
$this->conditions = $conditions ?: Compiler::_('Model.Conditions');
$this->relations = $relations ?: Compiler::_('Model.Relations');
$this->linkedviews = $linkedviews ?: Compiler::_('Model.Linkedviews');
$this->javascript = $javascript ?: Compiler::_('Model.Javascriptadminview');
$this->css = $css ?: Compiler::_('Model.Cssadminview');
$this->php = $php ?: Compiler::_('Model.Phpadminview');
$this->custombuttons = $custombuttons ?: Compiler::_('Model.Custombuttons');
$this->customimportscripts = $customimportscripts ?: Compiler::_('Model.Customimportscripts');
$this->ajax = $ajax ?: Compiler::_('Model.Ajaxadmin');
$this->customalias = $customalias ?: Compiler::_('Model.Customalias');
$this->sql = $sql ?: Compiler::_('Model.Sql');
$this->mysqlsettings = $mysqlsettings ?: Compiler::_('Model.Mysqlsettings');
$this->db = $db ?: Factory::getDbo();
}
/**
* Get Admin View Data
*
* @param int $id The view ID
*
* @return object|null The view data
* @since 3.2.0
*/
public function get(int $id): ?object
{
if (!isset($this->data[$id]))
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->select(
$this->db->quoteName(
array(
'b.addfields',
'b.id',
'c.addconditions',
'c.id',
'r.addrelations',
't.tabs'
), array(
'addfields',
'addfields_id',
'addconditions',
'addconditions_id',
'addrelations',
'customtabs'
)
)
);
$query->from('#__componentbuilder_admin_view AS a');
$query->join(
'LEFT',
$this->db->quoteName('#__componentbuilder_admin_fields', 'b')
. ' ON (' . $this->db->quoteName('a.id') . ' = '
. $this->db->quoteName('b.admin_view') . ')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_admin_fields_conditions', 'c'
) . ' ON (' . $this->db->quoteName('a.id') . ' = '
. $this->db->quoteName('c.admin_view') . ')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_admin_fields_relations', 'r'
) . ' ON (' . $this->db->quoteName('a.id') . ' = '
. $this->db->quoteName('r.admin_view') . ')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_admin_custom_tabs', 't'
) . ' ON (' . $this->db->quoteName('a.id') . ' = '
. $this->db->quoteName('t.admin_view') . ')'
);
$query->where($this->db->quoteName('a.id') . ' = ' . (int) $id);
// for plugin event TODO change event api signatures
$component_context = $this->config->component_context;
// Trigger Event: jcb_ce_onBeforeQueryViewData
$this->event->trigger(
'jcb_ce_onBeforeQueryViewData',
array(&$component_context, &$id, &$query, &$this->db)
);
// Reset the query using our newly populated query object.
$this->db->setQuery($query);
// Load the results as a list of stdClass objects (see later for more options on retrieving data).
$view = $this->db->loadObject();
// setup single view code names to use in storing the data
$view->name_single_code = 'oops_hmm_' . $id;
if (isset($view->name_single) && $view->name_single != 'null')
{
$view->name_single_code = StringHelper::safe(
$view->name_single
);
}
// setup list view code name to use in storing the data
$view->name_list_code = 'oops_hmmm_' . $id;
if (isset($view->name_list) && $view->name_list != 'null')
{
$view->name_list_code = StringHelper::safe(
$view->name_list
);
}
// check the length of the view name (+5 for com_ and _)
$name_length = $this->config->component_code_name_length + strlen(
(string) $view->name_single_code
) + 5;
// when the name is larger than 49 we need to add the assets' table name fix
if ($name_length > 49)
{
$this->config->set('add_assets_table_name_fix', true);
}
// setup token check
if (!isset($this->dispenser->hub['token']))
{
$this->dispenser->hub['token'] = [];
}
$this->dispenser->hub['token'][$view->name_single_code] = false;
$this->dispenser->hub['token'][$view->name_list_code] = false;
// set some placeholders
$this->placeholder->set('view', $view->name_single_code);
$this->placeholder->set('views', $view->name_list_code);
$this->placeholder->set('View', StringHelper::safe(
$view->name_single, 'F'
));
$this->placeholder->set('Views', StringHelper::safe(
$view->name_list, 'F'
));
$this->placeholder->set('VIEW', StringHelper::safe(
$view->name_single, 'U'
));
$this->placeholder->set('VIEWS', StringHelper::safe(
$view->name_list, 'U'
));
// for plugin event TODO change event api signatures
$placeholders = $this->placeholder->active;
$component_context = $this->config->component_context;
// Trigger Event: jcb_ce_onBeforeModelViewData
$this->event->trigger(
'jcb_ce_onBeforeModelViewData',
array(&$component_context, &$view, &$placeholders)
);
unset($placeholders);
// add the tables
$view->addtables = (isset($view->addtables)
&& JsonHelper::check($view->addtables))
? json_decode((string) $view->addtables, true) : null;
if (ArrayHelper::check($view->addtables))
{
$view->tables = array_values($view->addtables);
}
unset($view->addtables);
// set custom tabs
$this->customtabs->set($view);
// set the local tabs
$this->tabs->set($view);
// set permissions
$this->permissions->set($view);
// set fields
$this->fields->set($view);
// build update SQL
$this->history->set($view);
// set the conditions
$this->conditions->set($view);
// set the relations
$this->relations->set($view);
// set linked views
$this->linkedviews->set($view);
// set the lang target
$this->config->lang_target = 'admin';
if ($this->registry->get('builder.site_edit_view.' . $id, false))
{
$this->config->lang_target = 'both';
}
// set javascript
$this->javascript->set($view);
// set css
$this->css->set($view);
// set php
$this->php->set($view);
// set custom buttons
$this->custombuttons->set($view);
// set custom import scripts
$this->customimportscripts->set($view);
// set Ajax for this view
$this->ajax->set($view);
// activate alias builder
$this->customalias->set($view);
// set sql
$this->sql->set($view);
// set mySql Table Settings
$this->mysqlsettings->set($view);
// for plugin event TODO change event api signatures
$placeholders = $this->placeholder->active;
// Trigger Event: jcb_ce_onAfterModelViewData
$this->event->trigger(
'jcb_ce_onAfterModelViewData',
array(&$component_context, &$view, &$placeholders)
);
// clear placeholders
$this->placeholder->remove('view');
$this->placeholder->remove('views');
$this->placeholder->remove('View');
$this->placeholder->remove('Views');
$this->placeholder->remove('VIEW');
$this->placeholder->remove('VIEWS');
// store this view to class object
$this->data[$id] = $view;
}
// return the found view data
return $this->data[$id];
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,265 @@
<?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\Alias;
use Joomla\CMS\Factory;
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\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Model\Loader;
use VDM\Joomla\Componentbuilder\Compiler\Model\Libraries;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Alias Data Class
*
* @since 3.2.0
*/
class Data
{
/**
* 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
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Compiler Auto Loader
*
* @var Loader
* @since 3.2.0
*/
protected Loader $loader;
/**
* Compiler Libraries Model
*
* @var Libraries
* @since 3.2.0
*/
protected Libraries $libraries;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
* @param Registry|null $registry The compiler registry object.
* @param Customcode|null $customcode The compiler customcode object.
* @param Gui|null $gui The compiler customcode gui.
* @param Loader|null $load The compiler loader object.
* @param Libraries|null $libraries The compiler libraries model object.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry = null,
?Customcode $customcode = null, ?Gui $gui = null,
?Loader $loader = null, ?Libraries $libraries = null,
?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->loader = $loader ?: Compiler::_('Model.Loader');
$this->libraries = $libraries ?: Compiler::_('Model.Libraries');
$this->db = $db ?: Factory::getDbo();
}
/**
* Get Data by Alias
*
* @param string $alias The alias name
* @param string $table The table where to find the alias
* @param string $view The view code name
*
* @return array|null The data found with the alias
* @since 3.2.0
*/
public function get(string $alias, string $table, string $view): ?array
{
// if not set, get all keys in table and set by ID
$this->set($table);
// now check if key is found
$name = preg_replace("/[^A-Za-z]/", '', $alias);
if (($id = $this->registry->get('builder.data_with_alias_keys.' . $table . '.' . $name, null)) === null &&
($id = $this->registry->get('builder.data_with_alias_keys.' . $table . '.' . $alias, null)) === null)
{
return null;
}
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->from('#__componentbuilder_' . $table . ' AS a');
$query->where(
$this->db->quoteName('a.id') . ' = ' . (int) $id
);
// get the row
$this->db->setQuery($query);
$item = $this->db->loadObject();
// get the other target if both
$targets = [$this->config->build_target];
if ($this->config->lang_target === 'both')
{
$targets = ['site', 'admin'];
}
// we load this layout
$php_view = '';
if ($item->add_php_view == 1
&& StringHelper::check($item->php_view))
{
$php_view = $this->gui->set(
$this->customcode->update(base64_decode((string) $item->php_view)),
array(
'table' => $table,
'field' => 'php_view',
'id' => (int) $item->id,
'type' => 'php')
);
}
$content = $this->gui->set(
$this->customcode->update(base64_decode((string) $item->{$table})),
array(
'table' => $table,
'field' => $table,
'id' => (int) $item->id,
'type' => 'html')
);
// load all targets
foreach ($targets as $target)
{
// set libraries
$this->libraries->set($view, $item, $target);
// auto loaders
$this->loader->set($view, $content, $target);
$this->loader->set($view, $php_view, $target);
}
// load uikit version 2 if required
$this->loader->uikit($view, $content);
$this->loader->uikit($view, $php_view);
return [
'id' => $item->id,
'html' => $this->gui->set(
$content,
[
'table' => $table,
'field' => $table,
'id' => $item->id,
'type' => 'html'
]
),
'php_view' => $this->gui->set(
$php_view,
[
'table' => $table,
'field' => 'php_view',
'id' => $item->id,
'type' => 'php'
]
)
];
}
/**
* Load all alias and ID's of a table
*
* @param string $table The table where to find the alias
*
* @return void
* @since 3.2.0
*/
protected function set(string $table)
{
// now check if key is found
if (!$this->registry->get('builder.data_with_alias_keys.' . $table, null))
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select(array('a.id', 'a.alias'));
$query->from('#__componentbuilder_' . $table . ' AS a');
$this->db->setQuery($query);
$items = $this->db->loadObjectList();
// check if we have an array
if (ArrayHelper::check($items))
{
foreach ($items as $item)
{
// build the key
$k_ey = StringHelper::safe($item->alias);
$key = preg_replace("/[^A-Za-z]/", '', (string) $k_ey);
// set the keys
$this->registry->
set('builder.data_with_alias_keys.' . $table . '.' . $item->alias, $item->id);
$this->registry->
set('builder.data_with_alias_keys.' . $table . '.' . $k_ey, $item->id);
$this->registry->
set('builder.data_with_alias_keys.' . $table . '.' . $key, $item->id);
}
}
}
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,60 @@
<?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;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Component\Data;
use VDM\Joomla\Componentbuilder\Abstraction\BaseRegistry;
/**
* Compiler Component
*
* @since 3.2.0
*/
class Component extends BaseRegistry
{
/**
* Constructor
*
* @param Data|null $component The component data class.
*
* @since 3.2.0
*/
public function __construct(?Data $component = null)
{
$component = $component ?: Compiler::_('Component.Data');
parent::__construct($component->get());
}
/**
* getting any valid value
*
* @param string $path The value's key/path name
*
* @since 3.2.0
*/
public function __get(string $path)
{
// check if it has been set
if (($value = $this->get($path, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')
{
return $value;
}
return null;
}
}

View File

@ -0,0 +1,841 @@
<?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\Component;
use Joomla\CMS\Factory;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Component\Placeholder as ComponentPlaceholder;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Field as Field;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name as FieldName;
use VDM\Joomla\Componentbuilder\Compiler\Field\UniqueName;
use VDM\Joomla\Componentbuilder\Compiler\Model\Filesfolders;
use VDM\Joomla\Componentbuilder\Compiler\Model\Historycomponent;
use VDM\Joomla\Componentbuilder\Compiler\Model\Whmcs;
use VDM\Joomla\Componentbuilder\Compiler\Model\Sqltweaking;
use VDM\Joomla\Componentbuilder\Compiler\Model\Adminviews;
use VDM\Joomla\Componentbuilder\Compiler\Model\Siteviews;
use VDM\Joomla\Componentbuilder\Compiler\Model\Customadminviews;
use VDM\Joomla\Componentbuilder\Compiler\Model\Joomlamodules;
use VDM\Joomla\Componentbuilder\Compiler\Model\Joomlaplugins;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\GetHelper;
/**
* Compiler Component Data
*
* @since 3.2.0
*/
class Data
{
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Compiler Event
*
* @var EventInterface
* @since 3.2.0
*/
protected EventInterface $event;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* Compiler Component Placeholder
*
* @var ComponentPlaceholder
* @since 3.2.0
**/
protected ComponentPlaceholder $componentPlaceholder;
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Compiler Field
*
* @var Field
* @since 3.2.0
*/
protected Field $field;
/**
* Compiler field name
*
* @var FieldName
* @since 3.2.0
*/
protected FieldName $fieldName;
/**
* Compiler Field Unique Name
*
* @var UniqueName
* @since 3.2.0
**/
protected UniqueName $uniqueName;
/**
* Compiler Files Folders
*
* @var Filesfolders
* @since 3.2.0
*/
protected Filesfolders $filesFolders;
/**
* The modelling component history
*
* @var Historycomponent
* @since 3.2.0
*/
protected Historycomponent $history;
/**
* The modelling whmcs
*
* @var Whmcs
* @since 3.2.0
*/
protected Whmcs $whmcs;
/**
* The modelling Sql Tweaking
*
* @var Sqltweaking
* @since 3.2.0
*/
protected Sqltweaking $sqltweaking;
/**
* The modelling Admin Views
*
* @var Adminviews
* @since 3.2.0
*/
protected Adminviews $adminviews;
/**
* The modelling Site Views
*
* @var Siteviews
* @since 3.2.0
*/
protected Siteviews $siteviews;
/**
* The modelling Custom Admin Views
*
* @var Customadminviews
* @since 3.2.0
*/
protected Customadminviews $customadminviews;
/**
* The modelling Joomla Modules
*
* @var Joomlamodules
* @since 3.2.0
*/
protected Joomlamodules $modules;
/**
* The modelling Joomla Plugins
*
* @var Joomlaplugins
* @since 3.2.0
*/
protected Joomlaplugins $plugins;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
* @param EventInterface|null $event The compiler event api object.
* @param Placeholder|null $placeholder The compiler placeholder object.
* @param ComponentPlaceholder|null $componentPlaceholder The compiler component placeholder object.
* @param Dispenser|null $dispenser The compiler customcode dispenser object.
* @param Customcode|null $customcode The compiler customcode object.
* @param Gui|null $gui The compiler customcode gui.
* @param Field|null $field The compiler field object.
* @param FieldName|null $fieldName The compiler field name object.
* @param UniqueName|null $uniqueName The compiler field unique name object.
* @param Filesfolders|null $filesFolders The compiler files folders object.
* @param Historycomponent|null $history The modelling component history object.
* @param Whmcs|null $whmcs The modelling whmcs object.
* @param Sqltweaking|null $sqltweaking The modelling sql tweaking object.
* @param Adminviews|null $adminviews The modelling adminviews object.
* @param Siteviews|null $siteviews The modelling siteviews object.
* @param Customadminviews|null $customadminviews The modelling customadminviews object.
* @param Joomlamodules|null $modules The modelling modules object.
* @param Joomlaplugins|null $plugins The modelling plugins object.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?EventInterface $event = null,
?Placeholder $placeholder = null, ?ComponentPlaceholder $componentPlaceholder = null,
?Dispenser $dispenser = null, ?Customcode $customcode = null, ?Gui $gui = null,
?Field $field = null, ?FieldName $fieldName = null, ?UniqueName $uniqueName = null,
?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)
{
$this->config = $config ?: Compiler::_('Config');
$this->event = $event ?: Compiler::_('Event');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->componentPlaceholder = $componentPlaceholder ?: Compiler::_('Component.Placeholder');
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->field = $field ?: Compiler::_('Field');
$this->fieldName = $fieldName ?: Compiler::_('Field.Name');
$this->uniqueName = $uniqueName ?: Compiler::_('Field.Unique.Name');
$this->filesFolders = $filesFolders ?: Compiler::_('Model.Filesfolders');
$this->history = $history ?: Compiler::_('Model.Historycomponent');
$this->whmcs = $whmcs ?: Compiler::_('Model.Whmcs');
$this->sqltweaking = $sqltweaking ?: Compiler::_('Model.Sqltweaking');
$this->adminviews = $adminviews ?: Compiler::_('Model.Adminviews');
$this->siteviews = $siteviews ?: Compiler::_('Model.Siteviews');
$this->customadminviews = $customadminviews ?: Compiler::_('Model.Customadminviews');
$this->modules = $modules ?: Compiler::_('Model.Joomlamodules');
$this->plugins = $plugins ?: Compiler::_('Model.Joomlaplugins');
$this->db = $db ?: Factory::getDbo();
}
/**
* get current component data
*
* @return object|null The component data
* @since 3.2.0
*/
public function get(): ?object
{
// Create a new query object.
$query = $this->db->getQuery(true);
// selection
$selection = array(
'b.addadmin_views' => 'addadmin_views',
'b.id' => 'addadmin_views_id',
'h.addconfig' => 'addconfig',
'd.addcustom_admin_views' => 'addcustom_admin_views',
'g.addcustommenus' => 'addcustommenus',
'j.addfiles' => 'addfiles',
'j.addfolders' => 'addfolders',
'j.addfilesfullpath' => 'addfilesfullpath',
'j.addfoldersfullpath' => 'addfoldersfullpath',
'c.addsite_views' => 'addsite_views',
'l.addjoomla_plugins' => 'addjoomla_plugins',
'k.addjoomla_modules' => 'addjoomla_modules',
'i.dashboard_tab' => 'dashboard_tab',
'i.php_dashboard_methods' => 'php_dashboard_methods',
'i.params' => 'dashboard_params',
'i.id' => 'component_dashboard_id',
'f.sql_tweak' => 'sql_tweak',
'e.version_update' => 'version_update',
'e.id' => 'version_update_id'
);
$query->select('a.*');
$query->select(
$this->db->quoteName(
array_keys($selection), array_values($selection)
)
);
// from this table
$query->from('#__componentbuilder_joomla_component AS a');
// jointer-map
$joiners = array(
'b' => 'component_admin_views',
'c' => 'component_site_views',
'd' => 'component_custom_admin_views',
'e' => 'component_updates',
'f' => 'component_mysql_tweaks',
'g' => 'component_custom_admin_menus',
'h' => 'component_config',
'i' => 'component_dashboard',
'j' => 'component_files_folders',
'l' => 'component_plugins',
'k' => 'component_modules'
);
// load the joins
foreach ($joiners as $as => $join)
{
$query->join(
'LEFT',
$this->db->quoteName('#__componentbuilder_' . $join, $as)
. ' ON (' . $this->db->quoteName('a.id') . ' = '
. $this->db->quoteName($as . '.joomla_component') . ')'
);
}
$query->where(
$this->db->quoteName('a.id') . ' = ' . (int) $this->config->component_id
);
// for plugin event TODO change event api signatures
$component_context = $this->config->component_context;
$component_id = $this->config->component_id;
// Trigger Event: jcb_ce_onBeforeQueryComponentData
$this->event->trigger(
'jcb_ce_onBeforeQueryComponentData',
array(&$component_context, &$component_id, &$query,
&$this->db)
);
// Reset the query using our newly populated query object.
$this->db->setQuery($query);
// Load the results as a list of stdClass objects
$component = $this->db->loadObject();
// make sure we got a component loaded
if (!is_object($component) || !isset($component->system_name))
{
return null;
}
// Trigger Event: jcb_ce_onBeforeModelComponentData
$this->event->trigger(
'jcb_ce_onBeforeModelComponentData',
array(&$component_context, &$component)
);
// load the global placeholders
$this->placeholder->active = $this->componentPlaceholder->get();
// set component sales name
$component->sales_name = StringHelper::safe(
$component->system_name
);
// set the component name_code
$component->name_code = StringHelper::safe(
$component->name_code
);
// ensure version naming is correct
$this->config->set('component_version', preg_replace(
'/[^0-9.]+/', '', (string) $component->component_version
)
);
// set the website and autor for global use (default to VDM if not found)
$this->config->set('project_website', $component->website ?? 'https://dev.vdm.io');
$this->config->set('project_author', $component->author ?? 'VDM');
// set the files and folders
$this->filesFolders->set($component);
// set the uikit switch
$this->config->set('uikit', $component->adduikit);
// set whmcs links if needed
$this->whmcs->set($component);
// set the footable switch
if ($component->addfootable)
{
// force add footable
$this->config->set('footable ', true);
// add the version
$this->config->set('footable_version', (3 == $component->addfootable) ? 3 : 2);
}
// set the addcustommenus data
$component->addcustommenus = (isset($component->addcustommenus)
&& JsonHelper::check($component->addcustommenus))
? json_decode((string) $component->addcustommenus, true) : null;
if (ArrayHelper::check($component->addcustommenus))
{
$component->custommenus = array_values($component->addcustommenus);
}
unset($component->addcustommenus);
// set the sql tweak data
$this->sqltweaking->set($component);
// set the admin view data
$this->adminviews->set($component);
// set the site view data
$this->siteviews->set($component);
// set the custom_admin_views data
$this->customadminviews->set($component);
// set the config data
$component->addconfig = (isset($component->addconfig)
&& JsonHelper::check($component->addconfig))
? json_decode((string) $component->addconfig, true) : null;
if (ArrayHelper::check($component->addconfig))
{
$component->config = array_map(
function ($field) {
// make sure the alias and title is 0
$field['alias'] = 0;
$field['title'] = 0;
// set the field details
$this->field->set($field);
// set unique name counter
$this->uniqueName->set($field['base_name'], 'configs');
// return field
return $field;
}, array_values($component->addconfig)
);
// do some house cleaning (for fields)
foreach ($component->config as $field)
{
// so first we lock the field name in
$this->fieldName->get($field, 'configs');
}
// unset original value
unset($component->addconfig);
}
// set the add contributors
$component->addcontributors = (isset($component->addcontributors)
&& JsonHelper::check($component->addcontributors))
? json_decode((string) $component->addcontributors, true) : null;
if (ArrayHelper::check($component->addcontributors))
{
$this->config->set('add_contributors', true);
$component->contributors = array_values(
$component->addcontributors
);
}
unset($component->addcontributors);
// set the version updates
$component->version_update = (isset($component->version_update)
&& JsonHelper::check($component->version_update))
? json_decode((string) $component->version_update, true) : null;
if (ArrayHelper::check($component->version_update))
{
$component->version_update = array_values(
$component->version_update
);
}
// build update SQL
$this->history->set($component);
// set GUI mapper
$guiMapper = [
'table' => 'joomla_component',
'id' => (int) $this->config->component_id,
'field' => 'javascript',
'type' => 'js'
];
// add_javascript
if ($component->add_javascript == 1)
{
$this->dispenser->set(
$component->javascript,
'component_js',
null,
null,
$guiMapper
);
}
else
{
$this->dispenser->hub['component_js'] = '';
}
unset($component->javascript);
// add global CSS
$addGlobalCss = ['admin', 'site'];
foreach ($addGlobalCss as $area)
{
// add_css if found
if (isset($component->{'add_css_' . $area})
&& $component->{'add_css_' . $area} == 1
&& isset($component->{'css_' . $area})
&& StringHelper::check(
$component->{'css_' . $area}
))
{
$this->dispenser->set(
$component->{'css_' . $area},
'component_css_' . $area
);
}
else
{
$this->dispenser->hub['component_css_' . $area] = '';
}
unset($component->{'css_' . $area});
}
// set the lang target
$this->config->lang_target = 'admin';
// add PHP in ADMIN
$addScriptMethods = [
'php_preflight',
'php_postflight',
'php_method'
];
$addScriptTypes = [
'install',
'update',
'uninstall'
];
// update GUI mapper
$guiMapper['type'] = 'php';
foreach ($addScriptMethods as $scriptMethod)
{
foreach ($addScriptTypes as $scriptType)
{
if (isset(
$component->{'add_' . $scriptMethod . '_' . $scriptType}
)
&& $component->{'add_' . $scriptMethod . '_' . $scriptType}
== 1
&& StringHelper::check(
$component->{$scriptMethod . '_' . $scriptType}
))
{
// set GUI mapper field
$guiMapper['field'] = $scriptMethod . '_' . $scriptType;
$this->dispenser->set(
$component->{$scriptMethod . '_' . $scriptType},
$scriptMethod,
$scriptType,
null,
$guiMapper
);
}
else
{
$this->dispenser->hub[$scriptMethod][$scriptType] = '';
}
unset($component->{$scriptMethod . '_' . $scriptType});
}
}
// add_php_helper
if ($component->add_php_helper_admin == 1
&& StringHelper::check(
$component->php_helper_admin
))
{
$this->config->lang_target = 'admin';
// update GUI mapper
$guiMapper['field'] = 'php_helper_admin';
$guiMapper['prefix'] = PHP_EOL . PHP_EOL;
$this->dispenser->set(
$component->php_helper_admin,
'component_php_helper_admin',
null,
null,
$guiMapper
);
unset($guiMapper['prefix']);
}
else
{
$this->dispenser->hub['component_php_helper_admin'] = '';
}
unset($component->php_helper);
// add_admin_event
if ($component->add_admin_event == 1
&& StringHelper::check($component->php_admin_event))
{
$this->config->lang_target = 'admin';
// update GUI mapper field
$guiMapper['field'] = 'php_admin_event';
$this->dispenser->set(
$component->php_admin_event,
'component_php_admin_event',
null,
null,
$guiMapper
);
}
else
{
$this->dispenser->hub['component_php_admin_event'] = '';
}
unset($component->php_admin_event);
// add_php_helper_both
if ($component->add_php_helper_both == 1
&& StringHelper::check($component->php_helper_both))
{
$this->config->lang_target = 'both';
// update GUI mapper field
$guiMapper['field'] = 'php_helper_both';
$guiMapper['prefix'] = PHP_EOL . PHP_EOL;
$this->dispenser->set(
$component->php_helper_both,
'component_php_helper_both',
null,
null,
$guiMapper
);
unset($guiMapper['prefix']);
}
else
{
$this->dispenser->hub['component_php_helper_both'] = '';
}
// add_php_helper_site
if ($component->add_php_helper_site == 1
&& StringHelper::check($component->php_helper_site))
{
$this->config->lang_target = 'site';
// update GUI mapper field
$guiMapper['field'] = 'php_helper_site';
$guiMapper['prefix'] = PHP_EOL . PHP_EOL;
$this->dispenser->set(
$component->php_helper_site,
'component_php_helper_site',
null,
null,
$guiMapper
);
unset($guiMapper['prefix']);
}
else
{
$this->dispenser->hub['component_php_helper_site'] = '';
}
unset($component->php_helper);
// add_site_event
if ($component->add_site_event == 1
&& StringHelper::check($component->php_site_event))
{
$this->config->lang_target = 'site';
// update GUI mapper field
$guiMapper['field'] = 'php_site_event';
$this->dispenser->set(
$component->php_site_event,
'component_php_site_event',
null,
null,
$guiMapper
);
}
else
{
$this->dispenser->hub['component_php_site_event'] = '';
}
unset($component->php_site_event);
// add_sql
if ($component->add_sql == 1)
{
$this->dispenser->set(
$component->sql,
'sql',
'component_sql'
);
}
unset($component->sql);
// add_sql_uninstall
if ($component->add_sql_uninstall == 1)
{
$this->dispenser->set(
$component->sql_uninstall,
'sql_uninstall'
);
}
unset($component->sql_uninstall);
// bom
if (StringHelper::check($component->bom))
{
$this->config->set('bom_path',
$this->config->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/' . $component->bom
);
}
unset($component->bom);
// README
if ($component->addreadme)
{
$component->readme = $this->customcode->update(
base64_decode((string) $component->readme)
);
}
else
{
$component->readme = '';
}
// set lang now
$nowLang = $this->config->lang_target;
$this->config->lang_target = 'admin';
// dashboard methods
$component->dashboard_tab = (isset($component->dashboard_tab)
&& JsonHelper::check($component->dashboard_tab))
? json_decode((string) $component->dashboard_tab, true) : null;
if (ArrayHelper::check($component->dashboard_tab))
{
$component->dashboard_tab = array_map(
function ($array) {
$array['html'] = $this->customcode->update($array['html']);
return $array;
}, array_values($component->dashboard_tab)
);
}
else
{
$component->dashboard_tab = '';
}
// add the php of the dashboard if set
if (isset($component->php_dashboard_methods)
&& StringHelper::check(
$component->php_dashboard_methods
))
{
// load the php for the dashboard model
$component->php_dashboard_methods = $this->gui->set(
$this->customcode->update(
base64_decode((string) $component->php_dashboard_methods)
),
[
'table' => 'component_dashboard',
'field' => 'php_dashboard_methods',
'id' => (int) $component->component_dashboard_id,
'type' => 'php'
]
);
}
else
{
$component->php_dashboard_methods = '';
}
// reset back to now lang
$this->config->lang_target = $nowLang;
// add the update/sales server FTP details if that is the expected protocol
$serverArray = array('update_server', 'sales_server');
foreach ($serverArray as $server)
{
if ($component->{'add_' . $server} == 1
&& is_numeric(
$component->{$server}
)
&& $component->{$server} > 0)
{
// get the server protocol
$component->{$server . '_protocol'}
= GetHelper::var(
'server', (int) $component->{$server}, 'id', 'protocol'
);
}
else
{
$component->{$server} = 0;
// only change this for sales server (update server can be added loacaly to the zip file)
if ('sales_server' === $server)
{
$component->{'add_' . $server} = 0;
}
$component->{$server . '_protocol'} = 0;
}
}
// set the ignore folders for repo if found
if (isset($component->toignore)
&& StringHelper::check(
$component->toignore
))
{
if (strpos((string) $component->toignore, ',') !== false)
{
$component->toignore = array_map(
'trim', (array) explode(',', (string) $component->toignore)
);
}
else
{
$component->toignore = array(trim((string) $component->toignore));
}
}
else
{
// the default is to ignore the repo folder
$component->toignore = array('.git');
}
// set all modules
$this->modules->set($component);
// set all plugins
$this->plugins->set($component);
// Trigger Event: jcb_ce_onAfterModelComponentData
$this->event->trigger(
'jcb_ce_onAfterModelComponentData',
array(&$component_context, &$component)
);
// return found component data
return $component;
}
}

View File

@ -105,7 +105,7 @@ class Placeholder implements PlaceholderInterface
// open all the code // open all the code
foreach ($bucket as $key => &$code) foreach ($bucket as $key => &$code)
{ {
$code = base64_decode($code); $code = base64_decode((string) $code);
} }
} }
@ -126,7 +126,7 @@ class Placeholder implements PlaceholderInterface
)) !== false )) !== false
&& JsonHelper::check($_placeholders)) && JsonHelper::check($_placeholders))
{ {
$_placeholders = json_decode($_placeholders, true); $_placeholders = json_decode((string) $_placeholders, true);
if (ArrayHelper::check($_placeholders)) if (ArrayHelper::check($_placeholders))
{ {
foreach ($_placeholders as $row) foreach ($_placeholders as $row)

View File

@ -158,7 +158,7 @@ class Config extends BaseConfig
protected function getComponentcodenamelength(): int protected function getComponentcodenamelength(): int
{ {
// get component name length // get component name length
return strlen($this->component_code_name); return strlen((string) $this->component_code_name);
} }
/** /**

View File

@ -0,0 +1,406 @@
<?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;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Content;
/**
* Compiler Counter
*
* @since 3.2.0
*/
class Counter
{
/**
* The folder counter
*
* @var int
* @since 3.2.0
*/
public int $folder = 0;
/**
* The file counter
*
* @var int
* @since 3.2.0
*/
public int $file = 0;
/**
* The page counter
*
* @var int
* @since 3.2.0
*/
public int $page = 0;
/**
* The line counter
*
* @var int
* @since 3.2.0
*/
public int $line = 0;
/**
* The field counter
*
* @var int
* @since 3.2.0
*/
public int $field = 0;
/**
* The seconds counter
*
* @var int
* @since 3.2.0
*/
protected int $seconds = 0;
/**
* The actual seconds counter
*
* @var float
* @since 3.2.0
*/
protected float $actualSeconds = 0;
/**
* The folder seconds counter
*
* @var int
* @since 3.2.0
*/
protected int $folderSeconds = 0;
/**
* The file seconds counter
*
* @var int
* @since 3.2.0
*/
protected int $fileSeconds = 0;
/**
* The line seconds counter
*
* @var int
* @since 3.2.0
*/
protected int $lineSeconds = 0;
/**
* The seconds debugging counter
*
* @var float
* @since 3.2.0
*/
protected float $secondsDebugging = 0;
/**
* The seconds planning counter
*
* @var float
* @since 3.2.0
*/
protected float $secondsPlanning = 0;
/**
* The seconds mapping counter
*
* @var float
* @since 3.2.0
*/
protected float $secondsMapping = 0;
/**
* The seconds office counter
*
* @var float
* @since 3.2.0
*/
protected float $secondsOffice = 0;
/**
* The total hours counter
*
* @var int
* @since 3.2.0
*/
protected int $totalHours = 0;
/**
* The debugging hours counter
*
* @var int
* @since 3.2.0
*/
protected int $debuggingHours = 0;
/**
* The planning hours counter
*
* @var int
* @since 3.2.0
*/
protected int $planningHours = 0;
/**
* The mapping hours counter
*
* @var int
* @since 3.2.0
*/
protected int $mappingHours = 0;
/**
* The office hours counter
*
* @var int
* @since 3.2.0
*/
protected int $officeHours = 0;
/**
* The actual Total Hours counter
*
* @var int
* @since 3.2.0
*/
protected int $actualTotalHours = 0;
/**
* The actual hours spent counter
*
* @var int
* @since 3.2.0
*/
protected int $actualHoursSpent = 0;
/**
* The actual days spent counter
*
* @var int
* @since 3.2.0
*/
protected int $actualDaysSpent = 0;
/**
* The total days counter
*
* @var int
* @since 3.2.0
*/
protected int $totalDays = 0;
/**
* The actual Total Days counter
*
* @var int
* @since 3.2.0
*/
protected int $actualTotalDays = 0;
/**
* The project week time counter
*
* @var float
* @since 3.2.0
*/
protected float $projectWeekTime = 0;
/**
* The project month time counter
*
* @var float
* @since 3.2.0
*/
protected float $projectMonthTime = 0;
/**
* The compiler start timer
*
* @var float
* @since 3.2.0
*/
protected float $start = 0;
/**
* The compiler end timer
*
* @var float
* @since 3.2.0
*/
protected float $end = 0;
/**
* The compiler timer
*
* @var float
* @since 3.2.0
*/
protected float $timer = 0;
/**
* Compiler Content
*
* @var Content
* @since 3.2.0
**/
protected Content $content;
/**
* Constructor
*
* @param Content|null $content The compiler content object.
*
* @since 3.2.0
*/
public function __construct(?Content $content = null)
{
$this->content = $content ?: Compiler::_('Content');
}
/**
* Start the timer
*
* @return void
* @since 3.2.0
*/
public function start()
{
$this->start = microtime(true);
}
/**
* End the timer
*
* @return void
* @since 3.2.0
*/
public function end()
{
$this->end = microtime(true);
// calculate the lenght
$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);
}
/**
* Set all the time values
*
* @return void
* @since 3.2.0
*/
public function set()
{
// calculate all the values
$this->calculate();
// set some defaults
$this->content->set('LINE_COUNT', $this->line);
$this->content->set('FIELD_COUNT', $this->field);
$this->content->set('FILE_COUNT', $this->file);
$this->content->set('FOLDER_COUNT', $this->folder);
$this->content->set('PAGE_COUNT', $this->page);
$this->content->set('folders', $this->folderSeconds);
$this->content->set('foldersSeconds', $this->folderSeconds);
$this->content->set('files', $this->fileSeconds);
$this->content->set('filesSeconds', $this->fileSeconds);
$this->content->set('lines', $this->lineSeconds);
$this->content->set('linesSeconds', $this->lineSeconds);
$this->content->set('seconds', $this->actualSeconds);
$this->content->set('actualSeconds', $this->actualSeconds);
$this->content->set('totalHours', $this->totalHours);
$this->content->set('totalDays', $this->totalDays);
$this->content->set('debugging', $this->secondsDebugging);
$this->content->set('secondsDebugging', $this->secondsDebugging);
$this->content->set('planning', $this->secondsPlanning);
$this->content->set('secondsPlanning', $this->secondsPlanning);
$this->content->set('mapping', $this->secondsMapping);
$this->content->set('secondsMapping', $this->secondsMapping);
$this->content->set('office', $this->secondsOffice);
$this->content->set('secondsOffice', $this->secondsOffice);
$this->content->set('actualTotalHours', $this->actualTotalHours);
$this->content->set('actualTotalDays', $this->actualTotalDays);
$this->content->set('debuggingHours', $this->debuggingHours);
$this->content->set('planningHours', $this->planningHours);
$this->content->set('mappingHours', $this->mappingHours);
$this->content->set('officeHours', $this->officeHours);
$this->content->set('actualHoursSpent', $this->actualHoursSpent);
$this->content->set('actualDaysSpent', $this->actualDaysSpent);
$this->content->set('projectWeekTime', $this->projectWeekTime);
$this->content->set('projectMonthTime', $this->projectMonthTime);
// 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);
}
/**
* Calculate all the time values
*
* @return void
* @since 3.2.0
*/
protected function calculate()
{
// what is the size in terms of an A4 book
$this->page = round($this->line / 56);
// setup the unrealistic numbers
$this->folderSeconds = $this->folder * 5;
$this->fileSeconds = $this->file * 5;
$this->lineSeconds = $this->line * 10;
$this->seconds = $this->folderSeconds + $this->fileSeconds
+ $this->lineSeconds;
$this->totalHours = round($this->seconds / 3600);
$this->totalDays = round($this->totalHours / 8);
// setup the more realistic numbers
$this->secondsDebugging = $this->seconds / 4;
$this->secondsPlanning = $this->seconds / 7;
$this->secondsMapping = $this->seconds / 10;
$this->secondsOffice = $this->seconds / 6;
$this->actualSeconds = $this->folderSeconds + $this->fileSeconds
+ $this->lineSeconds + $this->secondsDebugging
+ $this->secondsPlanning + $this->secondsMapping
+ $this->secondsOffice;
$this->actualTotalHours = round($this->actualSeconds / 3600);
$this->actualTotalDays = round($this->actualTotalHours / 8);
$this->debuggingHours = round($this->secondsDebugging / 3600);
$this->planningHours = round($this->secondsPlanning / 3600);
$this->mappingHours = round($this->secondsMapping / 3600);
$this->officeHours = round($this->secondsOffice / 3600);
// the actual time spent
$this->actualHoursSpent = $this->actualTotalHours - $this->totalHours;
$this->actualDaysSpent = $this->actualTotalDays - $this->totalDays;
// calculate the projects actual time frame of completion
$this->projectWeekTime = round($this->actualTotalDays / 5, 1);
$this->projectMonthTime = round($this->actualTotalDays / 24, 1);
}
}

View File

@ -213,9 +213,9 @@ class Customcode implements CustomcodeInterface
$id = (int) $key; $id = (int) $key;
} }
elseif (StringHelper::check($key) elseif (StringHelper::check($key)
&& strpos($key, '+') === false) && strpos((string) $key, '+') === false)
{ {
$getFuncName = trim($key); $getFuncName = trim((string) $key);
if (!isset($this->functionNameMemory[$getFuncName])) if (!isset($this->functionNameMemory[$getFuncName]))
{ {
if (!$found_local = GetHelper::var( if (!$found_local = GetHelper::var(
@ -232,10 +232,10 @@ class Customcode implements CustomcodeInterface
} }
elseif (StringHelper::check($key) elseif (StringHelper::check($key)
&& strpos( && strpos(
$key, '+' (string) $key, '+'
) !== false) ) !== false)
{ {
$array = explode('+', $key); $array = explode('+', (string) $key);
// set ID // set ID
if (is_numeric($array[0])) if (is_numeric($array[0]))
{ {
@ -278,13 +278,11 @@ class Customcode implements CustomcodeInterface
// update the function values with the custom code key placeholders (this allow the use of [] + and , in the values) // 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->data[$id]['args'][$key]
= array_map( = array_map(
function ($_key) { fn($_key) => $this->placeholder->update(
return $this->placeholder->update(
$_key, $_key,
$this->keys $this->keys
); ), (array) explode(',', $array[1])
}, (array) explode(',', $array[1]) );
);
} }
elseif (StringHelper::check( elseif (StringHelper::check(
$array[1] $array[1]
@ -428,7 +426,7 @@ class Customcode implements CustomcodeInterface
// open the code // open the code
foreach ($bucket as $nr => &$customCode) foreach ($bucket as $nr => &$customCode)
{ {
$customCode['code'] = base64_decode($customCode['code']); $customCode['code'] = base64_decode((string) $customCode['code']);
// always insure that the external code is loaded // always insure that the external code is loaded
$customCode['code'] = $this->external->set( $customCode['code'] = $this->external->set(
$customCode['code'] $customCode['code']
@ -453,14 +451,14 @@ class Customcode implements CustomcodeInterface
if (isset($customCode['hashtarget'])) if (isset($customCode['hashtarget']))
{ {
$customCode['hashtarget'] = explode( $customCode['hashtarget'] = explode(
"__", $customCode['hashtarget'] "__", (string) $customCode['hashtarget']
); );
// is this a replace code, set end has array // is this a replace code, set end has array
if ($customCode['type'] == 1 if ($customCode['type'] == 1
&& strpos($customCode['hashendtarget'], '__') !== false) && strpos((string) $customCode['hashendtarget'], '__') !== false)
{ {
$customCode['hashendtarget'] = explode( $customCode['hashendtarget'] = explode(
"__", $customCode['hashendtarget'] "__", (string) $customCode['hashendtarget']
); );
// NOW see if this is an end of page target (TODO not sure if the string is always d41d8cd98f00b204e9800998ecf8427e) // NOW see if this is an end of page target (TODO not sure if the string is always d41d8cd98f00b204e9800998ecf8427e)
@ -581,9 +579,9 @@ class Customcode implements CustomcodeInterface
} }
// check what type of place holders we should load here // check what type of place holders we should load here
$placeholderType = (int) $item['comment_type'] . '2'; $placeholderType = (int) $item['comment_type'] . '2';
if (stripos($item['code'], Placefix::b() . 'view') !== false if (stripos((string) $item['code'], Placefix::b() . 'view') !== false
|| stripos($item['code'], Placefix::b() . 'sview') !== false || stripos((string) $item['code'], Placefix::b() . 'sview') !== false
|| stripos($item['code'], Placefix::b() . 'arg') !== false) || stripos((string) $item['code'], Placefix::b() . 'arg') !== false)
{ {
// if view is being set dynamicly then we can't update this code via IDE (TODO) // if view is being set dynamicly then we can't update this code via IDE (TODO)
$placeholderType = 3; $placeholderType = 3;

View File

@ -263,7 +263,7 @@ class Dispenser implements DispenserInterface
$script .= $prefix . str_replace( $script .= $prefix . str_replace(
array_keys($this->placeholder->active), array_keys($this->placeholder->active),
array_values($this->placeholder->active), array_values($this->placeholder->active),
$this->hub[$first][$second] (string) $this->hub[$first][$second]
) . $suffix; ) . $suffix;
// clear some memory // clear some memory
if ($unset) if ($unset)

View File

@ -135,18 +135,18 @@ class External implements ExternalInterface
// example: >{3|4 // example: >{3|4
// will cut 3 rows at top and 4 rows at bottom // will cut 3 rows at top and 4 rows at bottom
// if the external code has 8 or more lines // if the external code has 8 or more lines
if (($pos = strpos($target, '>{')) !== false) if (($pos = strpos((string) $target, '>{')) !== false)
{ {
// the length // the length
$target_len = strlen($target); $target_len = strlen((string) $target);
// where to cut // where to cut
$cutting = $target_len - $pos; $cutting = $target_len - $pos;
// get the sequence // get the sequence
$sequence = substr($target, "-$cutting"); $sequence = substr((string) $target, "-$cutting");
// remove from the URL // remove from the URL
$target_url = str_replace($sequence, '', $target); $target_url = str_replace($sequence, '', (string) $target);
// set the cut key for this target if not set // set the cut key for this target if not set
$this->cutter[trim($target)] = str_replace('>{', '', $sequence); $this->cutter[trim((string) $target)] = str_replace('>{', '', $sequence);
} }
else else
{ {

View File

@ -327,7 +327,7 @@ class Extractor implements ExtractorInterface
// make sure we have the path correct (the script file is not in admin path for example) // 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 // there may be more... will nead to keep our eye on this... since files could be moved during install
$file = str_replace('./', '', $file); # TODO (windows path issues) $file = str_replace('./', '', (string) $file); # TODO (windows path issues)
if ($file !== 'script.php') if ($file !== 'script.php')
{ {
@ -366,10 +366,10 @@ class Extractor implements ExtractorInterface
// check if the ending placeholder was found // check if the ending placeholder was found
if (isset($reading[$targetKey]) && $reading[$targetKey] if (isset($reading[$targetKey]) && $reading[$targetKey]
&& ((trim($lineContent) === $end && ((trim((string) $lineContent) === $end
|| strpos($lineContent, $end) !== false) || strpos((string) $lineContent, $end) !== false)
|| (trim($lineContent) === $endHTML || (trim((string) $lineContent) === $endHTML
|| strpos($lineContent, $endHTML) !== false))) || strpos((string) $lineContent, $endHTML) !== false)))
{ {
// trim the placeholder and if there is still data then load it // trim the placeholder and if there is still data then load it
if (isset($endReplace) if (isset($endReplace)
@ -411,7 +411,7 @@ class Extractor implements ExtractorInterface
$this->new[$pointer[$targetKey]][] $this->new[$pointer[$targetKey]][]
= $this->db->quote( = $this->db->quote(
base64_encode($c0de) base64_encode((string) $c0de)
); // 'code' ); // 'code'
if ($_type == 2) if ($_type == 2)
@ -438,7 +438,7 @@ class Extractor implements ExtractorInterface
$this->existing[$pointer[$targetKey]]['fields'][] $this->existing[$pointer[$targetKey]]['fields'][]
= $this->db->quoteName('code') . ' = ' = $this->db->quoteName('code') . ' = '
. $this->db->quote(base64_encode($c0de)); . $this->db->quote(base64_encode((string) $c0de));
if ($_type == 2) if ($_type == 2)
{ {
@ -490,8 +490,8 @@ class Extractor implements ExtractorInterface
// see if the custom code line starts now with PHP/JS comment type // see if the custom code line starts now with PHP/JS comment type
if ((!isset($reading[$targetKey]) || !$reading[$targetKey]) if ((!isset($reading[$targetKey]) || !$reading[$targetKey])
&& (($i === 1 && trim($lineContent) === $start) && (($i === 1 && trim((string) $lineContent) === $start)
|| strpos($lineContent, $start) !== false)) || strpos((string) $lineContent, $start) !== false))
{ {
$commentType = 1; // PHP/JS type $commentType = 1; // PHP/JS type
$startReplace = $start; $startReplace = $start;
@ -500,8 +500,8 @@ class Extractor implements ExtractorInterface
// see if the custom code line starts now with HTML comment type // see if the custom code line starts now with HTML comment type
elseif ((!isset($reading[$targetKey]) elseif ((!isset($reading[$targetKey])
|| !$reading[$targetKey]) || !$reading[$targetKey])
&& (($i === 1 && trim($lineContent) === $startHTML) && (($i === 1 && trim((string) $lineContent) === $startHTML)
|| strpos($lineContent, $startHTML) !== false)) || strpos((string) $lineContent, $startHTML) !== false))
{ {
$commentType = 2; // HTML type $commentType = 2; // HTML type
$startReplace = $startHTML; $startReplace = $startHTML;
@ -512,7 +512,7 @@ class Extractor implements ExtractorInterface
if ($commentType > 0) if ($commentType > 0)
{ {
// if we have all on one line we have a problem (don't load it TODO) // if we have all on one line we have a problem (don't load it TODO)
if (strpos($lineContent, $endReplace) !== false) if (strpos((string) $lineContent, (string) $endReplace) !== false)
{ {
// reset found comment type // reset found comment type
$commentType = 0; $commentType = 0;

View File

@ -158,7 +158,7 @@ class Paths
if (($path = $this->getModulePath($module_id)) !== false) if (($path = $this->getModulePath($module_id)) !== false)
{ {
// set the path // set the path
$local_paths['module_' . str_replace('/', '_', $path)] = $path; $local_paths['module_' . str_replace('/', '_', (string) $path)] = $path;
} }
} }
} }
@ -172,7 +172,7 @@ class Paths
if (($path = $this->getPluginPath($plugin_id)) !== false) if (($path = $this->getPluginPath($plugin_id)) !== false)
{ {
// set the path // set the path
$local_paths['plugin_' . str_replace('/', '_', $path)] = JPATH_ROOT . '/plugins/' . $path; $local_paths['plugin_' . str_replace('/', '_', (string) $path)] = JPATH_ROOT . '/plugins/' . $path;
} }
} }
} }
@ -207,7 +207,8 @@ class Paths
{ {
$addjoomla_modules = (JsonHelper::check( $addjoomla_modules = (JsonHelper::check(
$addjoomla_modules $addjoomla_modules
)) ? json_decode($addjoomla_modules, true) : null; )) ? json_decode((string) $addjoomla_modules, true) : null;
if (ArrayHelper::check($addjoomla_modules)) if (ArrayHelper::check($addjoomla_modules))
{ {
$joomla_modules = array_filter( $joomla_modules = array_filter(
@ -226,9 +227,7 @@ class Paths
if (ArrayHelper::check($joomla_modules)) if (ArrayHelper::check($joomla_modules))
{ {
return array_map( return array_map(
function ($array) { fn($array) => (int) $array['module'], $joomla_modules
return (int) $array['module'];
}, $joomla_modules
); );
} }
} }
@ -283,7 +282,7 @@ class Paths
$module->name $module->name
); );
// set module folder name // set module folder name
$module->folder_name = 'mod_' . strtolower($module->code_name); $module->folder_name = 'mod_' . strtolower((string) $module->code_name);
// set the lang key // set the lang key
$this->extractor->langKeys[strtoupper($module->folder_name)] = $this->extractor->langKeys[strtoupper($module->folder_name)] =
@ -322,7 +321,8 @@ class Paths
{ {
$addjoomla_plugins = (JsonHelper::check( $addjoomla_plugins = (JsonHelper::check(
$addjoomla_plugins $addjoomla_plugins
)) ? json_decode($addjoomla_plugins, true) : null; )) ? json_decode((string) $addjoomla_plugins, true) : null;
if (ArrayHelper::check($addjoomla_plugins)) if (ArrayHelper::check($addjoomla_plugins))
{ {
$joomla_plugins = array_filter( $joomla_plugins = array_filter(
@ -341,9 +341,7 @@ class Paths
if (ArrayHelper::check($joomla_plugins)) if (ArrayHelper::check($joomla_plugins))
{ {
return array_map( return array_map(
function ($array) { fn($array) => (int) $array['plugin'], $joomla_plugins
return (int) $array['plugin'];
}, $joomla_plugins
); );
} }
} }
@ -408,9 +406,9 @@ class Paths
); );
// set plugin folder name // set plugin folder name
$plugin->group = strtolower($plugin->group); $plugin->group = strtolower((string) $plugin->group);
// set plugin file name // set plugin file name
$plugin->file_name = strtolower($plugin->code_name); $plugin->file_name = strtolower((string) $plugin->code_name);
// set the lang key // set the lang key
$this->extractor->langKeys['PLG_' . strtoupper( $this->extractor->langKeys['PLG_' . strtoupper(

View File

@ -136,7 +136,7 @@ class Gui implements GuiInterface
$config['prefix'] = PHP_EOL; $config['prefix'] = PHP_EOL;
} }
// add placeholder based on type of code // add placeholder based on type of code
switch (strtolower($config['type'])) switch (strtolower((string) $config['type']))
{ {
// adding with html commenting // adding with html commenting
case 'html': case 'html':
@ -220,7 +220,7 @@ class Gui implements GuiInterface
$object = new \stdClass(); $object = new \stdClass();
$object->id = $id; $object->id = $id;
$object->{$field} = base64_encode( $object->{$field} = base64_encode(
$code (string) $code
); // (TODO) this may not always work... ); // (TODO) this may not always work...
// update the value in GUI // update the value in GUI
$this->db->updateObject( $this->db->updateObject(

View File

@ -0,0 +1,349 @@
<?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\Customview;
use Joomla\CMS\Factory;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Model\Libraries;
use VDM\Joomla\Componentbuilder\Compiler\Templatelayout\Data as Templatelayout;
use VDM\Joomla\Componentbuilder\Compiler\Dynamicget\Data as Dynamicget;
use VDM\Joomla\Componentbuilder\Compiler\Model\Loader;
use VDM\Joomla\Componentbuilder\Compiler\Model\Javascriptcustomview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Csscustomview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Phpcustomview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Ajaxcustomview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Custombuttons;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Unique;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Admin Custom View Data Class
*
* @since 3.2.0
*/
class Data
{
/**
* Admin views
*
* @var array
* @since 3.2.0
*/
protected array $data;
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Compiler Event
*
* @var EventInterface
* @since 3.2.0
*/
protected EventInterface $event;
/**
* 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 Libraries Model
*
* @var Libraries
* @since 3.2.0
*/
protected Libraries $libraries;
/**
* Compiler Template Layout
*
* @var Templatelayout
* @since 3.2.0
*/
protected Templatelayout $templateLayout;
/**
* Compiler Dynamic Get Data
*
* @var Dynamicget
* @since 3.2.0
*/
protected Dynamicget $dynamic;
/**
* Compiler Auto Loader
*
* @var Loader
* @since 3.2.0
*/
protected Loader $loader;
/**
* The modelling javascript
*
* @var Javascriptcustomview
* @since 3.2.0
*/
protected Javascriptcustomview $javascript;
/**
* The modelling css
*
* @var Csscustomview
* @since 3.2.0
*/
protected Csscustomview $css;
/**
* The modelling php admin view
*
* @var Phpcustomview
* @since 3.2.0
*/
protected Phpcustomview $php;
/**
* The modelling custom buttons
*
* @var Custombuttons
* @since 3.2.0
*/
protected Custombuttons $custombuttons;
/**
* The modelling ajax
*
* @var Ajaxcustomview
* @since 3.2.0
*/
protected Ajaxcustomview $ajax;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
* @param EventInterface|null $event The compiler event api object.
* @param Customcode|null $customcode The compiler customcode object.
* @param Gui|null $gui The compiler customcode gui.
* @param Libraries|null $libraries The compiler libraries model object.
* @param Templatelayout|null $templateLayout The compiler template layout object.
* @param Dynamicget|null $dynamic The compiler dynamic get data object.
* @param Loader|null $loader The compiler loader object.
* @param Javascriptcustomview|null $javascript The modelling javascript object.
* @param Csscustomview|null $css The modelling css object.
* @param Phpcustomview|null $php The modelling php admin view object.
* @param Ajaxcustomview|null $ajax The modelling ajax object.
* @param Custombuttons|null $custombuttons The modelling custombuttons object.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?EventInterface $event = null,
?Customcode $customcode = null, ?Gui $gui = null, ?Libraries $libraries = null,
?Templatelayout $templateLayout = null, ?Dynamicget $dynamic = null, ?Loader $loader = null,
?Javascriptcustomview $javascript = null, ?Csscustomview $css = null, ?Phpcustomview $php = null,
?Ajaxcustomview $ajax = null, ?Custombuttons $custombuttons = null, ?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->event = $event ?: Compiler::_('Event');
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->libraries = $libraries ?: Compiler::_('Model.Libraries');
$this->templateLayout = $templateLayout ?: Compiler::_('Templatelayout.Data');
$this->dynamic = $dynamic ?: Compiler::_('Dynamicget.Data');
$this->loader = $loader ?: Compiler::_('Model.Loader');
$this->javascript = $javascript ?: Compiler::_('Model.Javascriptcustomview');
$this->css = $css ?: Compiler::_('Model.Csscustomview');
$this->php = $php ?: Compiler::_('Model.Phpcustomview');
$this->ajax = $ajax ?: Compiler::_('Model.Ajaxcustomview');
$this->custombuttons = $custombuttons ?: Compiler::_('Model.Custombuttons');
$this->db = $db ?: Factory::getDbo();
}
/**
* Get all Custom View Data
*
* @param int $id The view ID
* @param string $table The view table
*
* @return object|null The view data
* @since 3.2.0
*/
public function get(int $id, string $table = 'site_view'): ?object
{
if (!isset($this->data[$id . $table]))
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->from('#__componentbuilder_' . $table . ' AS a');
$query->where($this->db->quoteName('a.id') . ' = ' . (int) $id);
// for plugin event TODO change event api signatures
$component_context = $this->config->component_context;
// Trigger Event: jcb_ce_onBeforeQueryCustomViewData
$this->event->trigger(
'jcb_ce_onBeforeQueryCustomViewData',
array(&$component_context, &$id, &$table, &$query, &$this->db)
);
// Reset the query using our newly populated query object.
$this->db->setQuery($query);
// Load the results as a list of stdClass objects (see later for more options on retrieving data).
$item = $this->db->loadObject();
// fix alias to use in code
$item->code = Unique::code(
StringHelper::safe($item->codename), $this->config->build_target
);
$item->Code = StringHelper::safe($item->code, 'F');
$item->CODE = StringHelper::safe($item->code, 'U');
// Trigger Event: jcb_ce_onBeforeModelCustomViewData
$this->event->trigger(
'jcb_ce_onBeforeModelCustomViewData',
array(&$component_context, &$item, &$id, &$table)
);
// set GUI mapper
$guiMapper = [
'table' => $table,
'id' => (int) $id,
'field' => 'default',
'type' => 'html'
];
// set the default data
$item->default = $this->gui->set(
$this->customcode->update(base64_decode((string) $item->default)),
$guiMapper
);
// load context if not set
if (!isset($item->context)
|| !StringHelper::check(
$item->context
))
{
$item->context = $item->code;
}
else
{
// always make sure context is a safe string
$item->context = StringHelper::safe($item->context);
}
// set the libraries
$this->libraries->set($item->code, $item);
// setup template and layout data
$this->templateLayout->set($item->default, $item->code);
// set uikit version 2
$this->loader->uikit($item->code, $item->default);
// auto loaders
$this->loader->set($item->code, $item->default);
// set the main get 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;
}
// set the custom_get data
$item->custom_get = (isset($item->custom_get)
&& JsonHelper::check($item->custom_get))
? json_decode((string) $item->custom_get, true) : null;
if (ArrayHelper::check($item->custom_get))
{
$item->custom_get = $this->dynamic->get(
$item->custom_get, $item->code, $item->context
);
}
// set php scripts
$this->php->set($item, $table);
// set javascript scripts
$this->javascript->set($item, $table);
// set css scripts
$this->css->set($item);
// set Ajax for this view
$this->ajax->set($item, $table);
// set the custom buttons
$this->custombuttons->set($item, $table);
// Trigger Event: jcb_ce_onAfterModelCustomViewData
$this->event->trigger(
'jcb_ce_onAfterModelCustomViewData',
array(&$component_context, &$item)
);
// set the found data
$this->data[$id . $table] = $item;
}
// return the found data
return $this->data[$id . $table];
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,324 @@
<?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\Dynamicget;
use Joomla\CMS\Factory;
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\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Model\Dynamicget;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Dynamic Get Data Class
*
* @since 3.2.0
*/
class Data
{
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => 'dynamic_get',
'id' => null,
'field' => null,
'type' => 'php'
];
/**
* 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 Customcode
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Compiler Dynamicget Model
*
* @var Dynamicget
* @since 3.2.0
*/
protected Dynamicget $dynamic;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
/**
* 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 Customcode|null $customcode The compiler customcode object.
* @param Dispenser|null $dispenser The compiler customcode dispenser object.
* @param Gui|null $gui The compiler customcode gui.
* @param Dynamicget|null $dynamic The compiler dynamicget modeller object.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry = null,
?EventInterface $event = null, ?Customcode $customcode = null,
?Dispenser $dispenser = null, ?Gui $gui = null,
?Dynamicget $dynamic = null, ?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->event = $event ?: Compiler::_('Event');
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->dynamic = $dynamic ?: Compiler::_('Model.Dynamicget');
$this->db = $db ?: Factory::getDbo();
}
/**
* Get Dynamic Get Data
*
* @param array $ids The ids of the dynamic get
* @param string $view_code The view code name
* @param string $context The context for events
*
* @return array|null array of object/s on success
* @since 3.2.0
*/
public function get(array $ids, string $view_code, string $context): ?array
{
if ($ids === [])
{
return null;
}
$ids = implode(',', $ids);
// for plugin event TODO change event api signatures
$component_context = $this->config->component_context;
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->from('#__componentbuilder_dynamic_get AS a');
$query->where('a.id IN (' . $ids . ')');
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
$results = $this->db->loadObjectList();
foreach ($results as $_nr => &$result)
{
// Trigger Event: jcb_ce_onBeforeModelDynamicGetData
$this->event->trigger(
'jcb_ce_onBeforeModelDynamicGetData',
array(&$component_context, &$result, &$result->id, &$view_code, &$context)
);
// set GUI mapper id
$this->guiMapper['id'] = (int) $result->id;
// add calculations if set
if ($result->addcalculation == 1
&& StringHelper::check(
$result->php_calculation
))
{
// set GUI mapper field
$guiMapper['field'] = 'php_calculation';
$result->php_calculation = $this->gui->set(
$this->customcode->update(
base64_decode((string) $result->php_calculation)
),
$this->guiMapper
);
}
// setup the router parse
if (isset($result->add_php_router_parse)
&& $result->add_php_router_parse == 1
&& isset($result->php_router_parse)
&& StringHelper::check(
$result->php_router_parse
))
{
// set GUI mapper field
$this->guiMapper['field'] = 'php_router_parse';
$result->php_router_parse = $this->gui->set(
$this->customcode->update(
base64_decode((string) $result->php_router_parse)
),
$this->guiMapper
);
}
else
{
$result->add_php_router_parse = 0;
}
// The array of the php scripts that should be added to the script builder
$phpSripts = [
'php_before_getitem',
'php_after_getitem',
'php_before_getitems',
'php_after_getitems',
'php_getlistquery'
];
// load the php scripts
foreach ($phpSripts as $script)
{
// add php script to the script builder
if (isset($result->{'add_' . $script})
&& $result->{'add_' . $script} == 1
&& isset($result->{$script})
&& StringHelper::check(
$result->{$script}
))
{
// move all main gets out to the custom script builder
if ($result->gettype <= 2)
{
// set GUI mapper field
$this->guiMapper['field'] = $script;
$this->guiMapper['prefix'] = PHP_EOL . PHP_EOL;
$this->dispenser->set(
$result->{$script},
$this->config->build_target . '_' . $script,
$view_code,
null,
$this->guiMapper,
true,
true,
true
);
unset($this->guiMapper['prefix']);
// remove from local item
unset($result->{$script});
unset($result->{'add_' . $script});
}
else
{
// set GUI mapper field
$this->guiMapper['field'] = $script;
$this->guiMapper['prefix'] = PHP_EOL;
// only for custom gets
$result->{$script} = $this->gui->set(
$this->customcode->update(
base64_decode((string) $result->{$script})
),
$this->guiMapper
);
unset($this->guiMapper['prefix']);
}
}
else
{
// remove from local item
unset($result->{$script});
unset($result->{'add_' . $script});
}
}
// set the getmethod code name
$result->key = StringHelper::safe(
$view_code . ' ' . $result->name . ' ' . $result->id
);
// set the dynamic get
$this->dynamic->set($result, $view_code, $context);
// load the events if any is set
if ($result->gettype == 1
&& JsonHelper::check(
$result->plugin_events
))
{
$result->plugin_events = json_decode(
(string) $result->plugin_events, true
);
}
else
{
$result->plugin_events = '';
}
// Trigger Event: jcb_ce_onAfterModelDynamicGetData
$this->event->trigger(
'jcb_ce_onAfterModelDynamicGetData',
array(&$component_context, &$result, &$result->id, &$view_code, &$context)
);
}
return $results;
}
return null;
}
}

View File

@ -0,0 +1,281 @@
<?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\Dynamicget;
use Joomla\CMS\Factory;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\Component\Helper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
/**
* Dynamic Get Selection Class
*
* @since 3.2.0
*/
class Selection
{
/**
* Admin view table names
*
* @var array
* @since 3.2.0
*/
protected array $name;
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
* @param Registry|null $registry The compiler registry object.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry = null,
?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->db = $db ?: Factory::getDbo();
}
/**
* Get Data Selection of the dynamic get
*
* @param string $methodKey The method unique key
* @param string $viewCode The code name of the view
* @param string $string The data string
* @param string $asset The asset in question
* @param string $as The as string
* @param string $type The target type (db||view)
* @param int|null $rowType The row type
*
* @return array|null the select query
* @since 3.2.0
*/
public function get(string $methodKey, string $viewCode,
string $string, string $asset, string $as, string $type, ?int $rowType = null): ?array
{
if (StringHelper::check($string))
{
if ('db' === $type)
{
$table = '#__' . $asset;
$queryName = $asset;
$view = '';
}
elseif ('view' === $type)
{
$view = $this->name($asset);
$table = '#__' . $this->config->component_code_name . '_' . $view;
$queryName = $view;
}
else
{
return null;
}
// just get all values from table if * is found
if ($string === '*' || strpos($string, '*') !== false)
{
if ($type == 'view')
{
// TODO move getViewTableColumns to its own class
$_string = Helper::_('getViewTableColumns',
[$asset, $as, $rowType]
);
}
else
{
// TODO move getDbTableColumns to its own class
$_string = Helper::_('getDbTableColumns',
[$asset, $as, $rowType]
);
}
// get only selected values
$lines = explode(PHP_EOL, (string) $_string);
// make sure to set the string to *
$string = '*';
}
else
{
// get only selected values
$lines = explode(PHP_EOL, $string);
}
// only continue if lines are available
if (ArrayHelper::check($lines))
{
$gets = [];
$keys = [];
// first load all options
foreach ($lines as $line)
{
if (strpos($line, 'AS') !== false)
{
$lineArray = explode("AS", $line);
}
elseif (strpos($line, 'as') !== false)
{
$lineArray = explode("as", $line);
}
else
{
$lineArray = array($line, null);
}
// set the get and key
$get = trim($lineArray[0]);
$key = trim($lineArray[1]);
// only add the view (we must adapt this)
if ($this->registry->exists('builder.get_as_lookup.' . $methodKey . '.' . $get)
&& 'a' != $as
&& is_numeric($rowType) && 1 == $rowType
&& 'view' === $type
&& strpos('#' . $key, '#' . $view . '_') === false)
{
// this is a problem (TODO) since we may want to not add the view name.
$key = $view . '_' . trim($key);
}
// continue only if we have get
if (StringHelper::check($get))
{
$gets[] = $this->db->quote($get);
if (StringHelper::check($key))
{
$this->registry->
set('builder.get_as_lookup.' . $methodKey . '.' . $get, $key);
}
else
{
$key = str_replace(
$as . '.', '', $get
);
$this->registry->
set('builder.get_as_lookup.' . $methodKey . '.' . $get, $key);
}
// set the keys
$keys[] = $this->db->quote(
$key
);
// make sure we have the view name
if (StringHelper::check($view))
{
// prep the field name
$field = str_replace($as . '.', '', $get);
// load to the site fields memory bucket
$this->registry->
set('builder.site_fields.' . $view . '.' . $field . '.' . $methodKey . '___' . $as,
['site' => $viewCode, 'get' => $get, 'as' => $as, 'key' => $key]);
}
}
}
if (ArrayHelper::check($gets)
&& ArrayHelper::check($keys))
{
// single joined selection needs the prefix to the values to avoid conflict in the names
// so we must still add then AS
if ($string == '*' && (is_null($rowType) || 1 != $rowType))
{
$querySelect = "\$query->select('" . $as . ".*');";
}
else
{
$querySelect = '$query->select($db->quoteName('
. PHP_EOL . Indent::_(3) . 'array(' . implode(
',', $gets
) . '),' . PHP_EOL . Indent::_(3) . 'array('
. implode(',', $keys) . ')));';
}
$queryFrom = '$db->quoteName(' . $this->db->quote($table)
. ', ' . $this->db->quote($as) . ')';
// return the select query
return [
'select' => $querySelect,
'from' => $queryFrom,
'name' => $queryName,
'table' => $table,
'type' => $type,
'select_gets' => $gets,
'select_keys' => $keys
];
}
}
}
return null;
}
/**
* Get the Admin view table name
*
* @param int $id The item id to add
*
* @return string the admin view code name
* @since 3.2.0
*/
protected function name(int $id): string
{
// get name if not set
if (!isset($this->name[$id]))
{
$this->name[$id] = StringHelper::safe(
GetHelper::var('admin_view', $id, 'id', 'name_single')
);
}
return $this->name[$id] ?? 'error';
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -26,8 +26,14 @@ use VDM\Joomla\Componentbuilder\Compiler\Service\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Service\Customcode; use VDM\Joomla\Componentbuilder\Compiler\Service\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Service\Power; use VDM\Joomla\Componentbuilder\Compiler\Service\Power;
use VDM\Joomla\Componentbuilder\Compiler\Service\Component; use VDM\Joomla\Componentbuilder\Compiler\Service\Component;
use VDM\Joomla\Componentbuilder\Compiler\Service\Adminview;
use VDM\Joomla\Componentbuilder\Compiler\Service\Library;
use VDM\Joomla\Componentbuilder\Compiler\Service\Customview;
use VDM\Joomla\Componentbuilder\Compiler\Service\Templatelayout;
use VDM\Joomla\Componentbuilder\Compiler\Service\Extension; use VDM\Joomla\Componentbuilder\Compiler\Service\Extension;
use VDM\Joomla\Componentbuilder\Compiler\Service\Field; 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\Interfaces\FactoryInterface; use VDM\Joomla\Componentbuilder\Interfaces\FactoryInterface;
@ -123,8 +129,14 @@ abstract class Factory implements FactoryInterface
->registerServiceProvider(new Customcode()) ->registerServiceProvider(new Customcode())
->registerServiceProvider(new Power()) ->registerServiceProvider(new Power())
->registerServiceProvider(new Component()) ->registerServiceProvider(new Component())
->registerServiceProvider(new Adminview())
->registerServiceProvider(new Library())
->registerServiceProvider(new Customview())
->registerServiceProvider(new Templatelayout())
->registerServiceProvider(new Extension()) ->registerServiceProvider(new Extension())
->registerServiceProvider(new Field()); ->registerServiceProvider(new Field())
->registerServiceProvider(new Joomlamodule())
->registerServiceProvider(new Joomlaplugin());
} }
} }

View File

@ -88,9 +88,10 @@ class CoreValidation implements CoreValidationInterface
} }
// remove the Rule.php from the name // remove the Rule.php from the name
$this->rules = array_map( function ($name): string { $this->rules = array_map(
return str_replace(array('./','Rule.php'), '', $name); fn($name): string => str_replace(array('./','Rule.php'), '', (string) $name),
}, $rules); $rules
);
} }
// return rules if found // return rules if found
@ -99,9 +100,10 @@ class CoreValidation implements CoreValidationInterface
// check if the names should be all lowercase // check if the names should be all lowercase
if ($lowercase) if ($lowercase)
{ {
return array_map( function($item): string { return array_map(
return strtolower($item); fn($item): string => strtolower((string) $item),
}, $this->rules); $this->rules
);
} }
return $this->rules; return $this->rules;
} }

View File

@ -0,0 +1,960 @@
<?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 Joomla\CMS\Factory;
use Joomla\CMS\Filter\OutputFilter;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Field;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name as FieldName;
use VDM\Joomla\Componentbuilder\Compiler\Model\Filesfolders;
use VDM\Joomla\Componentbuilder\Compiler\Model\Libraries;
use VDM\Joomla\Componentbuilder\Compiler\Dynamicget\Data as Dynamicget;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
/**
* Joomla Module Data Class
*
* @since 3.2.0
*/
class Data
{
/**
* Compiler Joomla Plugins Data
*
* @var array
* @since 3.2.0
*/
protected array $data = [];
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* 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 Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Compiler Language
*
* @var Language
* @since 3.2.0
**/
protected Language $language;
/**
* Compiler Field
*
* @var Field
* @since 3.2.0
*/
protected Field $field;
/**
* Compiler field name
*
* @var FieldName
* @since 3.2.0
*/
protected FieldName $fieldName;
/**
* Compiler Files Folders
*
* @var Filesfolders
* @since 3.2.0
*/
protected Filesfolders $filesFolders;
/**
* Compiler Libraries Model
*
* @var Libraries
* @since 3.2.0
*/
protected Libraries $libraries;
/**
* Compiler Dynamic Get Data
*
* @var Dynamicget
* @since 3.2.0
*/
protected Dynamicget $dynamic;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
* @param Customcode|null $customcode The compiler customcode object.
* @param Gui|null $gui The compiler customcode gui.
* @param Placeholder|null $placeholder The compiler placeholder object.
* @param Language|null $language The compiler Language object.
* @param Field|null $field The compiler field data object.
* @param FieldName|null $fieldName The compiler field name object.
* @param Filesfolders|null $filesFolders The compiler files folders object.
* @param Libraries|null $libraries The compiler libraries model object.
* @param Dynamicget|null $dynamic The compiler dynamic get data object.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Customcode $customcode = null,
?Gui $gui = null, ?Placeholder $placeholder = null,
?Language $language = null, ?Field $field = null, ?FieldName $fieldName = null,
?Filesfolders $filesFolders = null, ?Libraries $libraries = null,
?Dynamicget $dynamic = null, ?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->language = $language ?: Compiler::_('Language');
$this->field = $field ?: Compiler::_('Field');
$this->fieldName = $fieldName ?: Compiler::_('Field.Name');
$this->filesFolders = $filesFolders ?: Compiler::_('Model.Filesfolders');
$this->libraries = $libraries ?: Compiler::_('Model.Libraries');
$this->dynamic = $dynamic ?: Compiler::_('Dynamicget.Data');
$this->db = $db ?: Factory::getDbo();
}
/**
* Get the Joomla Module/s
*
* @param int|null $id the module id
*
* @return object|array|null if ID found it returns object, if no ID given it returns all set
* @since 3.2.0
*/
public function get(int $id = null)
{
if (is_null($id) && $this->exists())
{
return $this->data;
}
elseif ($this->exists($id))
{
return $this->data[$id];
}
return null;
}
/**
* Check if the Joomla Module/s exists
*
* @param int|null $id the module id
*
* @return bool if ID found it returns true, if no ID given it returns true if any are set
* @since 3.2.0
*/
public function exists(int $id = null): bool
{
if (is_null($id))
{
return ArrayHelper::check($this->data);
}
elseif (isset($this->data[$id]))
{
return true;
}
return $this->set($id);
}
/**
* Set the Joomla Module
*
* @param int $id the module id
*
* @return bool true on success
* @since 3.2.0
*/
public function set(int $id): bool
{
if (isset($this->data[$id]))
{
return true;
}
else
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->select(
$this->db->quoteName(
array(
'f.addfiles',
'f.addfolders',
'f.addfilesfullpath',
'f.addfoldersfullpath',
'f.addurls',
'u.version_update',
'u.id'
), array(
'addfiles',
'addfolders',
'addfilesfullpath',
'addfoldersfullpath',
'addurls',
'version_update',
'version_update_id'
)
)
);
// from these tables
$query->from('#__componentbuilder_joomla_module AS a');
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_module_updates', 'u'
) . ' ON (' . $this->db->quoteName('a.id') . ' = '
. $this->db->quoteName('u.joomla_module') . ')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_module_files_folders_urls', 'f'
) . ' ON (' . $this->db->quoteName('a.id') . ' = '
. $this->db->quoteName('f.joomla_module') . ')'
);
$query->where($this->db->quoteName('a.id') . ' = ' . (int) $id);
$query->where($this->db->quoteName('a.published') . ' >= 1');
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// get the module data
$module = $this->db->loadObject();
// tweak system to set stuff to the module domain
$_backup_target = $this->config->build_target;
$_backup_lang = $this->config->lang_target;
$_backup_langPrefix = $this->config->lang_prefix;
// set some keys
$module->target_type = 'M0dU|3';
$module->key = $module->id . '_' . $module->target_type;
// update to point to module
$this->config->build_target = $module->key;
$this->config->lang_target = $module->key;
// set version if not set
if (empty($module->module_version))
{
$module->module_version = '1.0.0';
}
// set target client
if ($module->target == 2)
{
$module->target_client = 'administrator';
}
else
{
// default is site area
$module->target_client = 'site';
}
// set GUI mapper
$guiMapper = array('table' => 'joomla_module',
'id' => (int) $id, 'type' => 'php');
// update the name if it has dynamic values
$module->name = $this->placeholder->update_(
$this->customcode->update($module->name)
);
// set safe class function name
$module->code_name
= ClassfunctionHelper::safe(
$module->name
);
// alias of code name
$module->class_name = $module->code_name;
// set official name
$module->official_name = StringHelper::safe(
$module->name, 'W'
);
$this->config->set('lang_prefix', 'MOD_' . strtoupper((string) $module->code_name));
// set lang prefix
$module->lang_prefix = $this->config->lang_prefix;
// set module class name
$module->class_helper_name = 'Mod' . ucfirst((string) $module->code_name)
. 'Helper';
$module->class_data_name = 'Mod' . ucfirst((string) $module->code_name)
. 'Data';
// set module install class name
$module->installer_class_name = 'mod_' . ucfirst(
(string) $module->code_name
) . 'InstallerScript';
// set module folder name
$module->folder_name = 'mod_' . strtolower((string) $module->code_name);
// set the zip name
$module->zip_name = $module->folder_name . '_v' . str_replace(
'.', '_', (string) $module->module_version
) . '__J' . $this->config->joomla_version;
// set module file name
$module->file_name = $module->folder_name;
// set module context
$module->context = $module->file_name . '.' . $module->id;
// set official_name lang strings
$this->language->set(
$module->key, $this->config->lang_prefix, $module->official_name
);
// set some placeholder for this module
$this->placeholder->set('Module_name', $module->official_name);
$this->placeholder->set('Module', ucfirst(
(string) $module->code_name
));
$this->placeholder->set('module', strtolower(
(string) $module->code_name
));
$this->placeholder->set('module.version', $module->module_version);
$this->placeholder->set('module_version', str_replace(
'.', '_', (string) $module->module_version
));
// set description (TODO) add description field to module
if (!isset($module->description)
|| !StringHelper::check(
$module->description
))
{
$module->description = '';
}
else
{
$module->description = $this->placeholder->update_(
$this->customcode->update($module->description)
);
$this->language->set(
$module->key, $module->lang_prefix . '_DESCRIPTION',
$module->description
);
$module->description = '<p>' . $module->description
. '</p>';
}
// get author name
$project_author = $this->config->project_author;
// set the description
$module->xml_description = "<h1>" . $module->official_name
. " (v." . $module->module_version
. ")</h1> <div style='clear: both;'></div>"
. $module->description . "<p>Created by <a href='" . trim(
(string) $this->config->project_website
) . "' target='_blank'>" . trim(
(string) OutputFilter::cleanText($project_author)
) . "</a><br /><small>Development started "
. Factory::getDate($module->created)->format("jS F, Y")
. "</small></p>";
// set xml description
$this->language->set(
$module->key, $module->lang_prefix . '_XML_DESCRIPTION',
$module->xml_description
);
// update the readme if set
if ($module->addreadme == 1 && !empty($module->readme))
{
$module->readme = $this->placeholder->update_(
$this->customcode->update(base64_decode((string) $module->readme))
);
}
else
{
$module->addreadme = 0;
unset($module->readme);
}
// get the custom_get
$module->custom_get = (isset($module->custom_get)
&& JsonHelper::check($module->custom_get))
? json_decode((string) $module->custom_get, true) : null;
if (ArrayHelper::check($module->custom_get))
{
$module->custom_get = $this->dynamic->get(
$module->custom_get, $module->key, $module->key
);
}
else
{
$module->custom_get = null;
}
// set helper class details
if ($module->add_class_helper >= 1
&& StringHelper::check(
$module->class_helper_code
))
{
if ($module->add_class_helper_header == 1
&& StringHelper::check(
$module->class_helper_header
))
{
// set GUI mapper field
$guiMapper['field'] = 'class_helper_header';
// base64 Decode code
$module->class_helper_header = PHP_EOL
. $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode(
(string) $module->class_helper_header
)
)
),
$guiMapper
) . PHP_EOL;
}
else
{
$module->add_class_helper_header = 0;
$module->class_helper_header = '';
}
// set GUI mapper field
$guiMapper['field'] = 'class_helper_code';
// base64 Decode code
$module->class_helper_code = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $module->class_helper_code)
)
),
$guiMapper
);
// set class type
if ($module->add_class_helper == 2)
{
$module->class_helper_type = 'abstract class ';
}
else
{
$module->class_helper_type = 'class ';
}
}
else
{
$module->add_class_helper = 0;
$module->class_helper_code = '';
$module->class_helper_header = '';
}
// base64 Decode mod_code
if (isset($module->mod_code)
&& StringHelper::check($module->mod_code))
{
// set GUI mapper field
$guiMapper['field'] = 'mod_code';
$module->mod_code = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $module->mod_code)
)
),
$guiMapper
);
}
else
{
$module->mod_code = "// get the module class sfx";
$module->mod_code .= PHP_EOL
. "\$moduleclass_sfx = htmlspecialchars(\$params->get('moduleclass_sfx'), ENT_COMPAT, 'UTF-8');";
$module->mod_code .= PHP_EOL . "// load the default Tmpl";
$module->mod_code .= PHP_EOL
. "require JModuleHelper::getLayoutPath('mod_"
. strtolower((string) $module->code_name)
. "', \$params->get('layout', 'default'));";
}
// base64 Decode default header
if (isset($module->default_header)
&& StringHelper::check(
$module->default_header
))
{
// set GUI mapper field
$guiMapper['field'] = 'default_header';
$module->default_header = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $module->default_header)
)
),
$guiMapper
);
}
else
{
$module->default_header = '';
}
// base64 Decode default
if (isset($module->default)
&& StringHelper::check($module->default))
{
// set GUI mapper field
$guiMapper['field'] = 'default';
$guiMapper['type'] = 'html';
$module->default = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $module->default)
)
),
$guiMapper
);
}
else
{
$module->default = '<h1>No Tmpl set</h1>';
}
// start the config array
$module->config_fields = [];
// create the form arrays
$module->form_files = [];
$module->fieldsets_label = [];
$module->fieldsets_paths = [];
$module->add_rule_path = [];
$module->add_field_path = [];
// set global fields rule to default component path
$module->fields_rules_paths = 1;
// set the fields data
$module->fields = (isset($module->fields)
&& JsonHelper::check($module->fields))
? json_decode((string) $module->fields, true) : null;
if (ArrayHelper::check($module->fields))
{
// ket global key
$key = $module->key;
$dynamic_fields = array('fieldset' => 'basic',
'fields_name' => 'params',
'file' => 'config');
foreach ($module->fields as $n => &$form)
{
if (isset($form['fields'])
&& ArrayHelper::check(
$form['fields']
))
{
// make sure the dynamic_field is set to dynamic_value by default
foreach (
$dynamic_fields as $dynamic_field =>
$dynamic_value
)
{
if (!isset($form[$dynamic_field])
|| !StringHelper::check(
$form[$dynamic_field]
))
{
$form[$dynamic_field] = $dynamic_value;
}
else
{
if ('fields_name' === $dynamic_field
&& strpos((string) $form[$dynamic_field], '.')
!== false)
{
$form[$dynamic_field]
= $form[$dynamic_field];
}
else
{
$form[$dynamic_field]
= StringHelper::safe(
$form[$dynamic_field]
);
}
}
}
// check if field is external form file
if (!isset($form['module']) || $form['module'] != 1)
{
// now build the form key
$unique = $form['file'] . $form['fields_name']
. $form['fieldset'];
}
else
{
// now build the form key
$unique = $form['fields_name']
. $form['fieldset'];
}
// set global fields rule path switches
if ($module->fields_rules_paths == 1
&& isset($form['fields_rules_paths'])
&& $form['fields_rules_paths'] == 2)
{
$module->fields_rules_paths = 2;
}
// set where to path is pointing
$module->fieldsets_paths[$unique]
= $form['fields_rules_paths'];
// check for extra rule paths
if (isset($form['addrulepath'])
&& ArrayHelper::check($form['addrulepath']))
{
foreach ($form['addrulepath'] as $add_rule_path)
{
if (StringHelper::check($add_rule_path['path']))
{
$module->add_rule_path[$unique] = $add_rule_path['path'];
}
}
}
// check for extra field paths
if (isset($form['addfieldpath'])
&& ArrayHelper::check($form['addfieldpath']))
{
foreach ($form['addfieldpath'] as $add_field_path)
{
if (StringHelper::check($add_field_path['path']))
{
$module->add_field_path[$unique] = $add_field_path['path'];
}
}
}
// add the label if set to lang
if (isset($form['label'])
&& StringHelper::check(
$form['label']
))
{
$module->fieldsets_label[$unique]
= $this->language->key($form['label']);
}
// build the fields
$form['fields'] = array_map(
function ($field) use ($key, $unique) {
// make sure the alias and title is 0
$field['alias'] = 0;
$field['title'] = 0;
// set the field details
$this->field->set(
$field, $key, $key, $unique
);
// update the default if set
if (StringHelper::check(
$field['custom_value']
)
&& isset($field['settings']))
{
if (($old_default
= GetHelper::between(
$field['settings']->xml,
'default="', '"', false
)) !== false)
{
// replace old default
$field['settings']->xml
= str_replace(
'default="' . $old_default
. '"', 'default="'
. $field['custom_value'] . '"',
(string) $field['settings']->xml
);
}
else
{
// add the default (hmmm not ideal but okay it should work)
$field['settings']->xml
= 'default="'
. $field['custom_value'] . '" '
. $field['settings']->xml;
}
}
unset($field['custom_value']);
// return field
return $field;
}, array_values($form['fields'])
);
// check if field is external form file
if (!isset($form['module']) || $form['module'] != 1)
{
// load the form file
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)
{
// so first we lock the field name in
$this->fieldName->get(
$field, $module->key, $unique
);
// add the fields to the global form file builder
$module->form_files[$form['file']][$form['fields_name']][$form['fieldset']][]
= $field;
}
// remove form
unset($module->fields[$n]);
}
else
{
// load the config form
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)
{
// so first we lock the field name in
$this->fieldName->get(
$field, $module->key, $unique
);
// add the fields to the config builder
$module->config_fields[$form['fields_name']][$form['fieldset']][]
= $field;
}
// remove form
unset($module->fields[$n]);
}
}
else
{
unset($module->fields[$n]);
}
}
}
unset($module->fields);
// set files and folders
$this->filesFolders->set($module);
// set libraries
$this->libraries->set($module->code_name, $module);
// add PHP in module install
$module->add_install_script = false;
$addScriptMethods = array('php_preflight',
'php_postflight',
'php_method');
$addScriptTypes = array('install', 'update',
'uninstall');
// the next are php placeholders
$guiMapper['type'] = 'php';
foreach ($addScriptMethods as $scriptMethod)
{
foreach ($addScriptTypes as $scriptType)
{
if (isset(
$module->{'add_' . $scriptMethod . '_'
. $scriptType}
)
&& $module->{'add_' . $scriptMethod . '_'
. $scriptType} == 1
&& StringHelper::check(
$module->{$scriptMethod . '_' . $scriptType}
))
{
// set GUI mapper field
$guiMapper['field'] = $scriptMethod . '_'
. $scriptType;
$module->{$scriptMethod . '_' . $scriptType} = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode(
(string) $module->{$scriptMethod . '_'
. $scriptType}
)
)
),
$guiMapper
);
$module->add_install_script = true;
}
else
{
unset($module->{$scriptMethod . '_' . $scriptType});
$module->{'add_' . $scriptMethod . '_'
. $scriptType}
= 0;
}
}
}
// add_sql
if ($module->add_sql == 1
&& StringHelper::check($module->sql))
{
$module->sql = $this->placeholder->update_(
$this->customcode->update(base64_decode((string) $module->sql))
);
}
else
{
unset($module->sql);
$module->add_sql = 0;
}
// add_sql_uninstall
if ($module->add_sql_uninstall == 1
&& StringHelper::check(
$module->sql_uninstall
))
{
$module->sql_uninstall = $this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $module->sql_uninstall)
)
);
}
else
{
unset($module->sql_uninstall);
$module->add_sql_uninstall = 0;
}
// update the URL of the update_server if set
if ($module->add_update_server == 1
&& StringHelper::check(
$module->update_server_url
))
{
$module->update_server_url = $this->placeholder->update_(
$this->customcode->update($module->update_server_url)
);
}
// add the update/sales server FTP details if that is the expected protocol
$serverArray = array('update_server', 'sales_server');
foreach ($serverArray as $server)
{
if ($module->{'add_' . $server} == 1
&& is_numeric(
$module->{$server}
)
&& $module->{$server} > 0)
{
// get the server protocol
$module->{$server . '_protocol'}
= GetHelper::var(
'server', (int) $module->{$server}, 'id', 'protocol'
);
}
else
{
$module->{$server} = 0;
// only change this for sales server (update server can be added loacaly to the zip file)
if ('sales_server' === $server)
{
$module->{'add_' . $server} = 0;
}
$module->{$server . '_protocol'} = 0;
}
}
// set the update server stuff (TODO)
// update_server_xml_path
// update_server_xml_file_name
// rest globals
$this->config->build_target = $_backup_target;
$this->config->lang_target = $_backup_lang;
$this->config->lang_prefix = $_backup_langPrefix;
$this->placeholder->remove('Module_name');
$this->placeholder->remove('Module');
$this->placeholder->remove('module');
$this->placeholder->remove('module.version');
$this->placeholder->remove('module_version');
$this->data[$id] = $module;
return true;
}
}
return false;
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,886 @@
<?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 Joomla\CMS\Factory;
use Joomla\CMS\Filter\OutputFilter;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Field;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name as FieldName;
use VDM\Joomla\Componentbuilder\Compiler\Model\Filesfolders;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
use VDM\Joomla\Utilities\String\PluginHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
/**
* Joomla Plugin Data Class
*
* @since 3.2.0
*/
class Data
{
/**
* Compiler Joomla Plugins Data
*
* @var array
* @since 3.2.0
*/
protected array $data = [];
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* 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 Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Compiler Language
*
* @var Language
* @since 3.2.0
**/
protected Language $language;
/**
* Compiler Field
*
* @var Field
* @since 3.2.0
*/
protected Field $field;
/**
* Compiler field name
*
* @var FieldName
* @since 3.2.0
*/
protected FieldName $fieldName;
/**
* Compiler Files Folders
*
* @var Filesfolders
* @since 3.2.0
*/
protected Filesfolders $filesFolders;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
* @param Customcode|null $customcode The compiler customcode object.
* @param Gui|null $gui The compiler customcode gui.
* @param Placeholder|null $placeholder The compiler placeholder object.
* @param Language|null $language The compiler Language object.
* @param Field|null $field The compiler field data object.
* @param FieldName|null $fieldName The compiler field name object.
* @param Filesfolders|null $filesFolders The compiler files folders object.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Customcode $customcode = null,
?Gui $gui = null, ?Placeholder $placeholder = null,
?Language $language = null, ?Field $field = null, ?FieldName $fieldName = null,
?Filesfolders $filesFolders = null, ?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->language = $language ?: Compiler::_('Language');
$this->field = $field ?: Compiler::_('Field');
$this->fieldName = $fieldName ?: Compiler::_('Field.Name');
$this->filesFolders = $filesFolders ?: Compiler::_('Model.Filesfolders');
$this->db = $db ?: Factory::getDbo();
}
/**
* Get the Joomla Plugin/s
*
* @param int|null $id the plugin id
*
* @return object|array|null if ID found it returns object, if no ID given it returns all set
* @since 3.2.0
*/
public function get(int $id = null)
{
if (is_null($id) && $this->exists())
{
return $this->data;
}
elseif ($this->exists($id))
{
return $this->data[$id];
}
return null;
}
/**
* Check if the Joomla Plugin/s exists
*
* @param int|null $id the plugin id
*
* @return bool if ID found it returns true, if no ID given it returns true if any are set
* @since 3.2.0
*/
public function exists(int $id = null): bool
{
if (is_null($id))
{
return ArrayHelper::check($this->data);
}
elseif (isset($this->data[$id]))
{
return true;
}
return $this->set($id);
}
/**
* Set the Joomla Plugin
*
* @param int $id the plugin id
*
* @return bool true on success
* @since 3.2.0
*/
public function set(int $id): bool
{
if (isset($this->data[$id]))
{
return true;
}
else
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->select(
$this->db->quoteName(
array(
'g.name',
'e.name',
'e.head',
'e.comment',
'e.id',
'f.addfiles',
'f.addfolders',
'f.addfilesfullpath',
'f.addfoldersfullpath',
'f.addurls',
'u.version_update',
'u.id'
), array(
'group',
'extends',
'class_head',
'comment',
'class_id',
'addfiles',
'addfolders',
'addfilesfullpath',
'addfoldersfullpath',
'addurls',
'version_update',
'version_update_id'
)
)
);
// from these tables
$query->from('#__componentbuilder_joomla_plugin AS a');
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_plugin_group', 'g'
) . ' ON (' . $this->db->quoteName('a.joomla_plugin_group')
. ' = ' . $this->db->quoteName('g.id') . ')'
);
$query->join(
'LEFT',
$this->db->quoteName('#__componentbuilder_class_extends', 'e')
. ' ON (' . $this->db->quoteName('a.class_extends') . ' = '
. $this->db->quoteName('e.id') . ')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_plugin_updates', 'u'
) . ' ON (' . $this->db->quoteName('a.id') . ' = '
. $this->db->quoteName('u.joomla_plugin') . ')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_joomla_plugin_files_folders_urls', 'f'
) . ' ON (' . $this->db->quoteName('a.id') . ' = '
. $this->db->quoteName('f.joomla_plugin') . ')'
);
$query->where($this->db->quoteName('a.id') . ' = ' . (int) $id);
$query->where($this->db->quoteName('a.published') . ' >= 1');
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// get the plugin data
$plugin = $this->db->loadObject();
// tweak system to set stuff to the plugin domain
$_backup_target = $this->config->build_target;
$_backup_lang = $this->config->lang_target;
$_backup_langPrefix = $this->config->lang_prefix;
// set some keys
$plugin->target_type = 'P|uG!n';
$plugin->key = $plugin->id . '_' . $plugin->target_type;
// update to point to plugin
$this->config->build_target = $plugin->key;
$this->config->lang_target = $plugin->key;
// set version if not set
if (empty($plugin->plugin_version))
{
$plugin->plugin_version = '1.0.0';
}
// set GUI mapper
$guiMapper = array('table' => 'joomla_plugin',
'id' => (int) $id, 'type' => 'php');
// update the name if it has dynamic values
$plugin->name = $this->placeholder->update_(
$this->customcode->update($plugin->name)
);
// update the name if it has dynamic values
$plugin->code_name
= ClassfunctionHelper::safe(
$plugin->name
);
// set official name
$plugin->official_name = ucwords(
$plugin->group . ' - ' . $plugin->name
);
// set lang prefix
$plugin->lang_prefix = PluginHelper::safeLangPrefix(
$plugin->code_name,
$plugin->group
);
// set langPrefix
$this->config->lang_prefix = $plugin->lang_prefix;
// set plugin class name
$plugin->class_name
= PluginHelper::safeClassName(
$plugin->code_name,
$plugin->group
);
// set plugin install class name
$plugin->installer_class_name
= PluginHelper::safeInstallClassName(
$plugin->code_name,
$plugin->group
);
// set plugin folder name
$plugin->folder_name
= PluginHelper::safeFolderName(
$plugin->code_name,
$plugin->group
);
// set the zip name
$plugin->zip_name = $plugin->folder_name . '_v' . str_replace(
'.', '_', (string) $plugin->plugin_version
) . '__J' . $this->config->joomla_version;
// set plugin file name
$plugin->file_name = strtolower((string) $plugin->code_name);
// set plugin context
$plugin->context = $plugin->folder_name . '.' . $plugin->id;
// set official_name lang strings
$this->language->set(
$plugin->key, $this->config->lang_prefix, $plugin->official_name
);
// set some placeholder for this plugin
$this->placeholder->set('Plugin_name', $plugin->official_name);
$this->placeholder->set('PLUGIN_NAME', $plugin->official_name);
$this->placeholder->set('Plugin', ucfirst((string) $plugin->code_name));
$this->placeholder->set('plugin', strtolower((string) $plugin->code_name));
$this->placeholder->set('Plugin_group', ucfirst((string) $plugin->group));
$this->placeholder->set('plugin_group', strtolower((string) $plugin->group));
$this->placeholder->set('plugin.version', $plugin->plugin_version);
$this->placeholder->set('VERSION', $plugin->plugin_version);
$this->placeholder->set('plugin_version', str_replace(
'.', '_', (string) $plugin->plugin_version
));
// set description
$this->placeholder->set('DESCRIPTION', '');
if (!isset($plugin->description)
|| !StringHelper::check(
$plugin->description
))
{
$plugin->description = '';
}
else
{
$plugin->description = $this->placeholder->update_(
$this->customcode->update($plugin->description)
);
$this->language->set(
$plugin->key, $plugin->lang_prefix . '_DESCRIPTION',
$plugin->description
);
// set description
$this->placeholder->set('DESCRIPTION', $plugin->description);
$plugin->description = '<p>' . $plugin->description . '</p>';
}
// get author name
$project_author = $this->config->project_author;
// we can only set these if the component was passed
$plugin->xml_description = "<h1>" . $plugin->official_name
. " (v." . $plugin->plugin_version
. ")</h1> <div style='clear: both;'></div>"
. $plugin->description . "<p>Created by <a href='" . trim(
(string) $this->config->project_website
) . "' target='_blank'>" . trim(
(string) OutputFilter::cleanText($project_author)
) . "</a><br /><small>Development started "
. Factory::getDate($plugin->created)->format("jS F, Y")
. "</small></p>";
// set xml discription
$this->language->set(
$plugin->key, $plugin->lang_prefix . '_XML_DESCRIPTION',
$plugin->xml_description
);
// update the readme if set
if ($plugin->addreadme == 1 && !empty($plugin->readme))
{
$plugin->readme = $this->placeholder->update_(
$this->customcode->update(base64_decode((string) $plugin->readme))
);
}
else
{
$plugin->addreadme = 0;
unset($plugin->readme);
}
// open some base64 strings
if (!empty($plugin->main_class_code))
{
// set GUI mapper field
$guiMapper['field'] = 'main_class_code';
// base64 Decode main_class_code.
$plugin->main_class_code = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->main_class_code)
)
),
$guiMapper
);
}
// set the head :)
if ($plugin->add_head == 1 && !empty($plugin->head))
{
// set GUI mapper field
$guiMapper['field'] = 'head';
// base64 Decode head.
$plugin->head = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->head)
)
),
$guiMapper
);
}
elseif (!empty($plugin->class_head))
{
// base64 Decode head.
$plugin->head = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->class_head)
)
),
array(
'table' => 'class_extends',
'field' => 'head',
'id' => (int) $plugin->class_id,
'type' => 'php')
);
}
unset($plugin->class_head);
// set the comment
if (!empty($plugin->comment))
{
// base64 Decode comment.
$plugin->comment = $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->comment)
)
),
array(
'table' => 'class_extends',
'field' => 'comment',
'id' => (int) $plugin->class_id,
'type' => 'php')
);
}
// start the config array
$plugin->config_fields = [];
// create the form arrays
$plugin->form_files = [];
$plugin->fieldsets_label = [];
$plugin->fieldsets_paths = [];
$plugin->add_rule_path = [];
$plugin->add_field_path = [];
// set global fields rule to default component path
$plugin->fields_rules_paths = 1;
// set the fields data
$plugin->fields = (isset($plugin->fields)
&& JsonHelper::check($plugin->fields))
? json_decode((string) $plugin->fields, true) : null;
if (ArrayHelper::check($plugin->fields))
{
// ket global key
$key = $plugin->key;
$dynamic_fields = array('fieldset' => 'basic',
'fields_name' => 'params',
'file' => 'config');
foreach ($plugin->fields as $n => &$form)
{
if (isset($form['fields'])
&& ArrayHelper::check(
$form['fields']
))
{
// make sure the dynamic_field is set to dynamic_value by default
foreach (
$dynamic_fields as $dynamic_field =>
$dynamic_value
)
{
if (!isset($form[$dynamic_field])
|| !StringHelper::check(
$form[$dynamic_field]
))
{
$form[$dynamic_field] = $dynamic_value;
}
else
{
if ('fields_name' === $dynamic_field
&& strpos((string) $form[$dynamic_field], '.')
!== false)
{
$form[$dynamic_field]
= $form[$dynamic_field];
}
else
{
$form[$dynamic_field]
= StringHelper::safe(
$form[$dynamic_field]
);
}
}
}
// check if field is external form file
if (!isset($form['plugin']) || $form['plugin'] != 1)
{
// now build the form key
$unique = $form['file'] . $form['fields_name']
. $form['fieldset'];
}
else
{
// now build the form key
$unique = $form['fields_name']
. $form['fieldset'];
}
// set global fields rule path switchs
if ($plugin->fields_rules_paths == 1
&& isset($form['fields_rules_paths'])
&& $form['fields_rules_paths'] == 2)
{
$plugin->fields_rules_paths = 2;
}
// set where to path is pointing
$plugin->fieldsets_paths[$unique]
= $form['fields_rules_paths'];
// add the label if set to lang
if (isset($form['label'])
&& StringHelper::check(
$form['label']
))
{
$plugin->fieldsets_label[$unique]
= $this->language->key($form['label']);
}
// check for extra rule paths
if (isset($form['addrulepath'])
&& ArrayHelper::check($form['addrulepath']))
{
foreach ($form['addrulepath'] as $add_rule_path)
{
if (StringHelper::check($add_rule_path['path']))
{
$plugin->add_rule_path[$unique] = $add_rule_path['path'];
}
}
}
// check for extra field paths
if (isset($form['addfieldpath'])
&& ArrayHelper::check($form['addfieldpath']))
{
foreach ($form['addfieldpath'] as $add_field_path)
{
if (StringHelper::check($add_field_path['path']))
{
$plugin->add_field_path[$unique] = $add_field_path['path'];
}
}
}
// build the fields
$form['fields'] = array_map(
function ($field) use ($key, $unique) {
// make sure the alias and title is 0
$field['alias'] = 0;
$field['title'] = 0;
// set the field details
$this->field->set(
$field, $key, $key, $unique
);
// update the default if set
if (StringHelper::check(
$field['custom_value']
)
&& isset($field['settings']))
{
if (($old_default
= GetHelper::between(
$field['settings']->xml,
'default="', '"', false
)) !== false)
{
// replace old default
$field['settings']->xml
= str_replace(
'default="' . $old_default
. '"', 'default="'
. $field['custom_value'] . '"',
(string) $field['settings']->xml
);
}
else
{
// add the default (hmmm not ideal but okay it should work)
$field['settings']->xml
= 'default="'
. $field['custom_value'] . '" '
. $field['settings']->xml;
}
}
unset($field['custom_value']);
// return field
return $field;
}, array_values($form['fields'])
);
// check if field is external form file
if (!isset($form['plugin']) || $form['plugin'] != 1)
{
// load the form file
if (!isset($plugin->form_files[$form['file']]))
{
$plugin->form_files[$form['file']]
= array();
}
if (!isset($plugin->form_files[$form['file']][$form['fields_name']]))
{
$plugin->form_files[$form['file']][$form['fields_name']]
= array();
}
if (!isset($plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']]))
{
$plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']]
= array();
}
// do some house cleaning (for fields)
foreach ($form['fields'] as $field)
{
// so first we lock the field name in
$this->fieldName->get(
$field, $plugin->key, $unique
);
// add the fields to the global form file builder
$plugin->form_files[$form['file']][$form['fields_name']][$form['fieldset']][]
= $field;
}
// remove form
unset($plugin->fields[$n]);
}
else
{
// load the config form
if (!isset($plugin->config_fields[$form['fields_name']]))
{
$plugin->config_fields[$form['fields_name']]
= array();
}
if (!isset($plugin->config_fields[$form['fields_name']][$form['fieldset']]))
{
$plugin->config_fields[$form['fields_name']][$form['fieldset']]
= array();
}
// do some house cleaning (for fields)
foreach ($form['fields'] as $field)
{
// so first we lock the field name in
$this->fieldName->get(
$field, $plugin->key, $unique
);
// add the fields to the config builder
$plugin->config_fields[$form['fields_name']][$form['fieldset']][]
= $field;
}
// remove form
unset($plugin->fields[$n]);
}
}
else
{
unset($plugin->fields[$n]);
}
}
}
unset($plugin->fields);
// set files and folders
$this->filesFolders->set($plugin);
// add PHP in plugin install
$plugin->add_install_script = false;
$addScriptMethods = array('php_preflight',
'php_postflight',
'php_method');
$addScriptTypes = array('install', 'update',
'uninstall');
foreach ($addScriptMethods as $scriptMethod)
{
foreach ($addScriptTypes as $scriptType)
{
if (isset(
$plugin->{'add_' . $scriptMethod . '_'
. $scriptType}
)
&& $plugin->{'add_' . $scriptMethod . '_'
. $scriptType} == 1
&& StringHelper::check(
$plugin->{$scriptMethod . '_' . $scriptType}
))
{
// set GUI mapper field
$guiMapper['field'] = $scriptMethod . '_'
. $scriptType;
$plugin->{$scriptMethod . '_' . $scriptType}
= $this->gui->set(
$this->placeholder->update_(
$this->customcode->update(
base64_decode(
(string) $plugin->{$scriptMethod . '_'
. $scriptType}
)
)
),
$guiMapper
);
$plugin->add_install_script = true;
}
else
{
unset($plugin->{$scriptMethod . '_' . $scriptType});
$plugin->{'add_' . $scriptMethod . '_'
. $scriptType}
= 0;
}
}
}
// add_sql
if ($plugin->add_sql == 1
&& StringHelper::check($plugin->sql))
{
$plugin->sql = $this->placeholder->update_(
$this->customcode->update(base64_decode((string) $plugin->sql))
);
}
else
{
unset($plugin->sql);
$plugin->add_sql = 0;
}
// add_sql_uninstall
if ($plugin->add_sql_uninstall == 1
&& StringHelper::check(
$plugin->sql_uninstall
))
{
$plugin->sql_uninstall = $this->placeholder->update_(
$this->customcode->update(
base64_decode((string) $plugin->sql_uninstall)
)
);
}
else
{
unset($plugin->sql_uninstall);
$plugin->add_sql_uninstall = 0;
}
// update the URL of the update_server if set
if ($plugin->add_update_server == 1
&& StringHelper::check(
$plugin->update_server_url
))
{
$plugin->update_server_url = $this->placeholder->update_(
$this->customcode->update($plugin->update_server_url)
);
}
// add the update/sales server FTP details if that is the expected protocol
$serverArray = array('update_server', 'sales_server');
foreach ($serverArray as $server)
{
if ($plugin->{'add_' . $server} == 1
&& is_numeric(
$plugin->{$server}
)
&& $plugin->{$server} > 0)
{
// get the server protocol
$plugin->{$server . '_protocol'}
= GetHelper::var(
'server', (int) $plugin->{$server}, 'id', 'protocol'
);
}
else
{
$plugin->{$server} = 0;
// only change this for sales server (update server can be added locally to the zip file)
if ('sales_server' === $server)
{
$plugin->{'add_' . $server} = 0;
}
$plugin->{$server . '_protocol'} = 0;
}
}
// set the update server stuff (TODO)
// update_server_xml_path
// update_server_xml_file_name
// rest globals
$this->config->build_target = $_backup_target;
$this->config->lang_target = $_backup_lang;
$this->config->set('lang_prefix', $_backup_langPrefix);
$this->placeholder->remove('Plugin_name');
$this->placeholder->remove('Plugin');
$this->placeholder->remove('plugin');
$this->placeholder->remove('Plugin_group');
$this->placeholder->remove('plugin_group');
$this->placeholder->remove('plugin.version');
$this->placeholder->remove('plugin_version');
$this->placeholder->remove('VERSION');
$this->placeholder->remove('DESCRIPTION');
$this->placeholder->remove('PLUGIN_NAME');
$this->data[$id] = $plugin;
return true;
}
}
return false;
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -104,9 +104,7 @@ class Extractor
{ {
// get targets to search for // get targets to search for
$lang_string_targets = array_filter( $lang_string_targets = array_filter(
$this->config->lang_string_targets, function ($get) use ($content): bool { $this->config->lang_string_targets, fn($get): bool => strpos($content, (string) $get) !== false
return strpos($content, $get) !== false;
}
); );
// check if we should continue // check if we should continue
if (ArrayHelper::check($lang_string_targets)) if (ArrayHelper::check($lang_string_targets))

View File

@ -0,0 +1,356 @@
<?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\Factory;
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\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Field\Data as FieldData;
use VDM\Joomla\Componentbuilder\Compiler\Model\Filesfolders;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Library Data Class
*
* @since 3.2.0
*/
class Data
{
/**
* 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
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Compiler Field Data
*
* @var FieldData
* @since 3.2.0
*/
protected FieldData $field;
/**
* Compiler Files Folders
*
* @var Filesfolders
* @since 3.2.0
*/
protected Filesfolders $filesFolders;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
* @param Registry|null $registry The compiler registry object.
* @param Customcode|null $customcode The compiler customcode object.
* @param Gui|null $gui The compiler customcode gui.
* @param FieldData|null $field The compiler field data object.
* @param Filesfolders|null $filesFolders The compiler files folders object.
* @param \JDatabaseDriver|null $db The database object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry = null,
?Customcode $customcode = null, ?Gui $gui = null,
?FieldData $field = null, ?Filesfolders $filesFolders = null,
?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->field = $field ?: Compiler::_('Field.Data');
$this->filesFolders = $filesFolders ?: Compiler::_('Model.Filesfolders');
$this->db = $db ?: Factory::getDbo();
}
/**
* Get Media Library Data and store globally in registry
*
* @param int $id the library id
*
* @return object|bool object on success
* @since 3.2.0
*/
public function get(int $id)
{
// check if the lib has already been set
if (!$this->registry->exists("builder.libraries.$id"))
{
// get some switches
$uikit = $this->config->get('uikit', 0);
$footable_version = $this->config->get('footable_version', 0);
// make sure we should continue and that the lib is not already being loaded
switch ($id)
{
case 1: // No Library
return false;
break;
case 3: // Uikit v3
if (2 == $uikit || 3 == $uikit)
{
// already being loaded
$this->registry->set("builder.libraries.$id", false);
}
break;
case 4: // Uikit v2
if (2 == $uikit || 1 == $uikit)
{
// already being loaded
$this->registry->set("builder.libraries.$id", false);
}
break;
case 5: // FooTable v2
if (2 == $footable_version)
{
// already being loaded
$this->registry->set("builder.libraries.$id", false);
}
break;
case 6: // FooTable v3
if (3 == $footable_version)
{
// already being loaded
$this->registry->set("builder.libraries.$id", false);
}
break;
}
}
// check if the lib has already been set
if (!$this->registry->exists("builder.libraries.$id"))
{
$query = $this->db->getQuery(true);
$query->select('a.*');
$query->select(
$this->db->quoteName(
array(
'a.id',
'a.name',
'a.how',
'a.type',
'a.addconditions',
'b.addconfig',
'c.addfiles',
'c.addfolders',
'c.addfilesfullpath',
'c.addfoldersfullpath',
'c.addurls',
'a.php_setdocument'
), array(
'id',
'name',
'how',
'type',
'addconditions',
'addconfig',
'addfiles',
'addfolders',
'addfilesfullpath',
'addfoldersfullpath',
'addurls',
'php_setdocument'
)
)
);
// from these tables
$query->from('#__componentbuilder_library AS a');
$query->join(
'LEFT',
$this->db->quoteName('#__componentbuilder_library_config', 'b')
. ' ON (' . $this->db->quoteName('a.id') . ' = '
. $this->db->quoteName('b.library') . ')'
);
$query->join(
'LEFT', $this->db->quoteName(
'#__componentbuilder_library_files_folders_urls', 'c'
) . ' ON (' . $this->db->quoteName('a.id') . ' = '
. $this->db->quoteName('c.library') . ')'
);
$query->where($this->db->quoteName('a.id') . ' = ' . (int) $id);
$query->where($this->db->quoteName('a.target') . ' = 1');
// Reset the query using our newly populated query object.
$this->db->setQuery($query);
// Load the results as a list of stdClass objects
$library = $this->db->loadObject();
// check if this lib uses build-in behaviour
if ($library->how == 4)
{
// fall back on build-in features
$buildin = [
3 => ['uikit' => 3],
4 => ['uikit' => 1],
5 => ['footable_version' => 2, 'footable' => true],
6 => ['footable_version' => 3, 'footable' => true]
];
if (isset($buildin[$library->id])
&& ArrayHelper::check(
$buildin[$library->id]
))
{
// set the lib switch
foreach ($buildin[$library->id] as $lib => $val)
{
// ---- we are targeting these ----
// $this->config->uikit
// $this->config->footable_version
// $this->config->footable
$this->config->set($lib, $val);
}
// since we are falling back on build-in feature
$library->how = 0;
}
else
{
// since we did not find build in behaviour we must load always.
$library->how = 1;
}
}
// check if this lib has dynamic behaviour
if ($library->how > 0)
{
// set files and folders
$this->filesFolders->set($library);
// add config fields only if needed
if ($library->how > 1)
{
// set the config data
$library->addconfig = (isset($library->addconfig)
&& JsonHelper::check(
$library->addconfig
)) ? json_decode((string) $library->addconfig, true) : null;
if (ArrayHelper::check($library->addconfig))
{
$library->config = array_map(
function ($array) {
$array['alias'] = 0;
$array['title'] = 0;
$array['settings'] = $this->field->get(
$array['field']
);
return $array;
}, array_values($library->addconfig)
);
}
}
// if this lib is controlled by custom script
if (3 == $library->how)
{
// set Needed PHP
if (isset($library->php_setdocument)
&& StringHelper::check(
$library->php_setdocument
))
{
$library->document = $this->gui->set(
$this->customcode->update(
base64_decode((string) $library->php_setdocument)
),
array(
'table' => 'library',
'field' => 'php_setdocument',
'id' => (int) $id,
'type' => 'php')
);
}
}
// if this lib is controlled by conditions
elseif (2 == $library->how)
{
// set the addconditions data
$library->addconditions = (isset($library->addconditions)
&& JsonHelper::check(
$library->addconditions
)) ? json_decode((string) $library->addconditions, true) : null;
if (ArrayHelper::check(
$library->addconditions
))
{
$library->conditions = array_values(
$library->addconditions
);
}
}
unset($library->php_setdocument);
unset($library->addconditions);
unset($library->addconfig);
// load to global lib
$this->registry->set("builder.libraries.$id", $library);
}
else
{
$this->registry->set("builder.libraries.$id", false);
}
}
// if set return
return $this->registry->get("builder.libraries.$id", false);
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,184 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Adminview\Data as Adminview;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
/**
* Model Admin Views Class
*
* @since 3.2.0
*/
class Adminviews
{
/**
* Component Admin view Data
*
* @var Adminview
* @since 3.2.0
**/
protected Adminview $admin;
/**
* Compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected Config $config;
/**
* Constructor
*
* @param Adminview|null $admin The admin view data object.
* @param Registry|null $registry The compiler registry object.
* @param Config|null $config The compiler config object.
*
* @since 3.2.0
*/
public function __construct(?Adminview $admin = null, ?Registry $registry = null, ?Config $config = null)
{
$this->admin = $admin ?: Compiler::_('Adminview.Data');
$this->registry = $registry ?: Compiler::_('Registry');
$this->config = $config ?: Compiler::_('Config');
}
/**
* Set admin view data
*
* @param object $item The extension data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->addadmin_views = (isset($item->addadmin_views)
&& JsonHelper::check($item->addadmin_views))
? json_decode((string) $item->addadmin_views, true) : null;
if (ArrayHelper::check($item->addadmin_views))
{
$this->config->lang_target = 'admin';
$this->config->build_target = 'admin';
// sort the views according to order
usort(
$item->addadmin_views, function ($a, $b) {
if ($a['order'] != 0 && $b['order'] != 0)
{
return $a['order'] - $b['order'];
}
elseif ($b['order'] != 0 && $a['order'] == 0)
{
return 1;
}
elseif ($a['order'] != 0 && $b['order'] == 0)
{
return 0;
}
return 1;
}
);
// build the admin_views settings
$item->admin_views = array_map(
function ($array) {
$array = array_map(
function ($value) {
if (!ArrayHelper::check($value)
&& !ObjectHelper::check($value)
&& strval($value) === strval(intval($value)))
{
return (int) $value;
}
return $value;
}, $array
);
// check if we must add to site
if (isset($array['edit_create_site_view'])
&& is_numeric(
$array['edit_create_site_view']
) && $array['edit_create_site_view'] > 0)
{
$this->registry->set('builder.site_edit_view.' . $array['adminview'], true);
$this->config->lang_target = 'both';
}
// set the import/export option for this view
if (isset($array['port']) && $array['port'])
{
$this->config->set('add_eximport', true);
}
// set the history tracking option for this view
if (isset($array['history']) && $array['history'])
{
$this->config->set('set_tag_history', true);
}
// set the custom field integration for this view
if (isset($array['joomla_fields']) && $array['joomla_fields'])
{
$this->config->set('set_joomla_fields', true);
}
// has become a legacy issue, can't remove this
$array['view'] = $array['adminview'];
// get the admin settings/data
$array['settings'] = $this->admin->get(
$array['view']
);
// set the filter option for this view
$this->registry-> // Side (old) [default for now]
set('builder.admin_filter_type.' . $array['settings']->name_list_code, 1);
if (isset($array['filter'])
&& is_numeric(
$array['filter']
) && $array['filter'] > 0)
{
$this->registry->
set('builder.admin_filter_type.' . $array['settings']->name_list_code,
(int) $array['filter']);
}
return $array;
}, array_values($item->addadmin_views)
);
}
}
}

View File

@ -0,0 +1,174 @@
<?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\Model;
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\Customcode\Dispenser;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model Admin Ajax Class
*
* @since 3.2.0
*/
class Ajaxadmin
{
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => 'admin_view',
'id' => null,
'field' => null,
'type' => 'php'
];
/**
* 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;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
* @param Registry|null $registry The compiler registry object.
* @param Dispenser|null $dispenser The compiler customcode dispenser
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry = null, ?Dispenser $dispenser = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
}
/**
* Set Ajax Code
*
* @param object $item The item data
* @param string $table The table
*
* @return void
* @since 3.2.0
*/
public function set(object &$item, string $table = 'admin_view')
{
// set some gui mapper values
$this->guiMapper['table'] = $table;
$this->guiMapper['id'] = (int) $item->id;
if (isset($item->add_php_ajax) && $item->add_php_ajax == 1)
{
// insure the token is added to edit view at least
$this->dispenser->hub['token'][$item->name_single_code]
= true;
$add_ajax_site = false;
if ($this->registry->get('builder.site_edit_view.' . $item->id, false))
{
// we should add this site ajax to front ajax
$add_ajax_site = true;
$this->config->set('add_site_ajax', true);
}
// check if controller input as been set
$item->ajax_input = (isset($item->ajax_input)
&& JsonHelper::check($item->ajax_input))
? json_decode((string) $item->ajax_input, true) : null;
if (ArrayHelper::check($item->ajax_input))
{
if ($add_ajax_site)
{
$this->dispenser->hub['site']['ajax_controller'][$item->name_single_code]
= array_values($item->ajax_input);
}
$this->dispenser->hub['admin']['ajax_controller'][$item->name_single_code]
= array_values($item->ajax_input);
$this->config->set('add_ajax', true);
unset($item->ajax_input);
}
if (StringHelper::check($item->php_ajaxmethod))
{
// make sure we are still in PHP
$this->guiMapper['type'] = 'php';
// update GUI mapper field
$this->guiMapper['field'] = 'php_ajaxmethod';
$this->dispenser->set(
$item->php_ajaxmethod,
'admin',
'ajax_model',
$item->name_single_code,
$this->guiMapper
);
if ($add_ajax_site)
{
$this->dispenser->set(
$item->php_ajaxmethod,
'site',
'ajax_model',
$item->name_single_code,
$this->guiMapper,
false,
false
);
}
// switch ajax on
$this->config->set('add_ajax', true);
// unset anyway
unset($item->php_ajaxmethod);
}
}
}
}

View File

@ -0,0 +1,151 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model Custom Ajax Custom View Class
*
* @since 3.2.0
*/
class Ajaxcustomview
{
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => 'site_view',
'id' => null,
'field' => null,
'type' => 'php'
];
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
* @param Dispenser|null $dispenser The compiler customcode dispenser
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Dispenser $dispenser = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
}
/**
* Set Ajax Code
*
* @param object $item The item data
* @param string $table The table
*
* @return void
* @since 3.2.0
*/
public function set(object &$item, string $table = 'site_view')
{
// add_Ajax for this view
if (isset($item->add_php_ajax) && $item->add_php_ajax == 1)
{
// set some gui mapper values
$this->guiMapper['table'] = $table;
$this->guiMapper['id'] = (int) $item->id;
// ajax target (since we only have two options really)
if ('site' === $this->config->build_target)
{
$target = 'site';
}
else
{
$target = 'admin';
}
$add_ajax_site = false;
// check if controller input as been set
$item->ajax_input = (isset($item->ajax_input)
&& JsonHelper::check($item->ajax_input))
? json_decode((string) $item->ajax_input, true) : null;
if (ArrayHelper::check($item->ajax_input))
{
$this->dispenser->hub[$target]['ajax_controller'][$item->code]
= array_values($item->ajax_input);
$add_ajax_site = true;
}
unset($item->ajax_input);
// load the ajax class mathods (if set)
if (StringHelper::check($item->php_ajaxmethod))
{
// set field
$this->guiMapper['field'] = 'php_ajaxmethod';
$this->dispenser->set(
$item->php_ajaxmethod,
$target,
'ajax_model',
$item->code,
$this->guiMapper
);
$add_ajax_site = true;
}
unset($item->php_ajaxmethod);
// should ajax be set
if ($add_ajax_site)
{
// turn on ajax area
if ('site' === $this->config->build_target)
{
$this->config->set('add_site_ajax', true);
}
else
{
$this->config->set('add_ajax', true);
}
}
}
}
}

View File

@ -0,0 +1,173 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Field\TypeName;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name as FieldName;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\FieldHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
/**
* Model Conditions Class
*
* @since 3.2.0
*/
class Conditions
{
/**
* Compiler Type Name
*
* @var TypeName
* @since 3.2.0
*/
protected TypeName $typeName;
/**
* Compiler Field Name
*
* @var FieldName
* @since 3.2.0
*/
protected FieldName $fieldName;
/**
* Constructor
*
* @param TypeName|null $typeName The compiler type name object.
* @param FieldName|null $fieldName The compiler field name object.
*
* @since 3.2.0
*/
public function __construct(?TypeName $typeName = null, ?FieldName $fieldName = null)
{
$this->typeName = $typeName ?: Compiler::_('Field.Type.Name');
$this->fieldName = $fieldName ?: Compiler::_('Field.Name');
}
/**
* Set the conditions
*
* @param object $item The view data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->addconditions = (isset($item->addconditions)
&& JsonHelper::check($item->addconditions))
? json_decode((string) $item->addconditions, true) : null;
if (ArrayHelper::check($item->addconditions))
{
$item->conditions = [];
$ne = 0;
foreach ($item->addconditions as $nr => $conditionValue)
{
if (ArrayHelper::check(
$conditionValue['target_field']
) && ArrayHelper::check($item->fields))
{
foreach ( $conditionValue['target_field'] as $fieldKey => $fieldId)
{
foreach ($item->fields as $fieldValues)
{
if ((int) $fieldValues['field'] == (int) $fieldId)
{
// load the field details
$required = GetHelper::between(
$fieldValues['settings']->xml,
'required="', '"'
);
$required = ($required === 'true'
|| $required === '1') ? 'yes' : 'no';
$filter = GetHelper::between(
$fieldValues['settings']->xml,
'filter="', '"'
);
$filter = StringHelper::check(
$filter
) ? $filter : 'none';
// set the field name
$conditionValue['target_field'][$fieldKey] = [
'name' => $this->fieldName->get(
$fieldValues, $item->name_list_code
),
'type' => $this->typeName->get(
$fieldValues
),
'required' => $required,
'filter' => $filter
];
break;
}
}
}
}
// load match field
if (ArrayHelper::check($item->fields)
&& isset($conditionValue['match_field']))
{
foreach ($item->fields as $fieldValue)
{
if ((int) $fieldValue['field'] == (int) $conditionValue['match_field'])
{
// set the type
$type = $this->typeName->get($fieldValue);
// set the field details
$conditionValue['match_name'] = $this->fieldName->get(
$fieldValue, $item->name_list_code
);
$conditionValue['match_type'] = $type;
$conditionValue['match_xml'] = $fieldValue['settings']->xml;
// if custom field load field being extended
if (!FieldHelper::check($type))
{
$conditionValue['match_extends'] = GetHelper::between(
$fieldValue['settings']->xml,
'extends="', '"'
);
}
else
{
$conditionValue['match_extends'] = '';
}
break;
}
}
}
// set condition values
$item->conditions[$ne] = $conditionValue;
$ne++;
}
}
unset($item->addconditions);
}
}

View File

@ -0,0 +1,90 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model CSS Admin View Class
*
* @since 3.2.0
*/
class Cssadminview
{
/**
* The areas add array
*
* @var array
* @since 3.2.0
*/
protected array $areas = [
'css_view', 'css_views'
];
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Constructor
*
* @param Dispenser|null $dispenser The compiler customcode dispenser
*
* @since 3.2.0
*/
public function __construct(?Dispenser $dispenser = null)
{
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
}
/**
* Set Admin View Css
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
foreach ($this->areas as $area)
{
if (isset($item->{'add_' . $area})
&& $item->{'add_' . $area} == 1
&& StringHelper::check($item->{$area}))
{
$this->dispenser->set(
$item->{$area},
$area,
$item->name_single_code,
null,
['prefix' => PHP_EOL],
true,
true,
true
);
unset($item->{$area});
}
}
}
}

View File

@ -0,0 +1,79 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model Css Custom View Class
*
* @since 3.2.0
*/
class Csscustomview
{
/**
* The areas add array
*
* @var array
* @since 3.2.0
*/
protected array $areas = ['css_document', 'css'];
/**
* Compiler Customcode Class
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Constructor
*
* @param Customcode|null $customcode The compiler customcode object.
*
* @since 3.2.0
*/
public function __construct(?Customcode $customcode = null)
{
$this->customcode = $customcode ?: Compiler::_('Customcode');
}
/**
* Set Css code
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
foreach ($this->areas as $area)
{
if (isset($item->{'add_' . $area})
&& $item->{'add_' . $area} == 1
&& StringHelper::check($item->{$area}))
{
$item->{$area} = $this->customcode->update(
base64_decode((string) $item->{$area})
);
}
}
}
}

View File

@ -0,0 +1,109 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customview\Data as Customview;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
/**
* Model Custom Admin Views Class
*
* @since 3.2.0
*/
class Customadminviews
{
/**
* Component custom admin view Data
*
* @var Customview
* @since 3.2.0
**/
protected Customview $customadmin;
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected Config $config;
/**
* Constructor
*
* @param Customview|null $customadmin The custom admin view data object.
* @param Config|null $config The compiler config object.
*
* @since 3.2.0
*/
public function __construct(?Customview $customadmin = null, ?Config $config = null)
{
$this->customadmin = $customadmin ?: Compiler::_('Customview.Data');
$this->config = $config ?: Compiler::_('Config');
}
/**
* Set custom admin view data
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->addcustom_admin_views = (isset($item->addcustom_admin_views)
&& JsonHelper::check($item->addcustom_admin_views))
? json_decode((string) $item->addcustom_admin_views, true) : null;
if (ArrayHelper::check($item->addcustom_admin_views))
{
$this->config->lang_target = 'admin';
$this->config->build_target = 'custom_admin';
// build the site_views settings
$item->custom_admin_views = array_map(
function ($array) {
// has become a legacy issue, can't remove this
$array['view'] = $array['customadminview'];
$array['settings'] = $this->customadmin->get(
$array['view'], 'custom_admin_view'
);
return array_map(
function ($value) {
if (!ArrayHelper::check($value)
&& !ObjectHelper::check($value)
&& strval($value) === strval(intval($value)))
{
return (int) $value;
}
return $value;
}, $array
);
}, array_values($item->addcustom_admin_views)
);
// unset original value
unset($item->addcustom_admin_views);
}
}
}

View File

@ -0,0 +1,110 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name as FieldName;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Model Custom Alias Class
*
* @since 3.2.0
*/
class Customalias
{
/**
* The compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The compiler field name
*
* @var FieldName
* @since 3.2.0
*/
protected FieldName $fieldName;
/**
* Constructor
*
* @param Config|null $config The compiler registry object.
* @param FieldName|null $fieldName The compiler field name object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?FieldName $fieldName = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->fieldName = $fieldName ?: Compiler::_('Field.Name');
}
/**
* Set activate alias builder
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
if (!$this->config->get('builder.custom_alias.' . $item->name_single_code, null)
&& isset($item->alias_builder_type) && 2 == $item->alias_builder_type
&& isset($item->alias_builder) && JsonHelper::check($item->alias_builder))
{
// get the aliasFields
$alias_fields = (array) json_decode((string) $item->alias_builder, true);
// get the active fields
$alias_fields = (array) array_filter(
$item->fields, function ($field) use ($alias_fields) {
// check if field is in view fields
if (in_array($field['field'], $alias_fields))
{
return true;
}
return false;
}
);
// check if all is well
if (ArrayHelper::check($alias_fields))
{
// load the field names
$this->config->set('builder.custom_alias.' . $item->name_single_code,
(array) array_map(
function ($field) use (&$item) {
return $this->fieldName->get(
$field, $item->name_list_code
);
}, $alias_fields
)
);
}
}
// unset
unset($item->alias_builder);
}
}

View File

@ -0,0 +1,158 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Templatelayout\Data as Templatelayout;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Model Custom Buttons Class
*
* @since 3.2.0
*/
class Custombuttons
{
/**
* The areas add array
*
* @var array
* @since 3.2.0
*/
protected array $areas = [
'php_model',
'php_controller',
'php_model_list',
'php_controller_list'
];
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => 'admin_view',
'id' => null,
'field' => null,
'type' => 'php'
];
/**
* 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 Template Layout
*
* @var Templatelayout
* @since 3.2.0
*/
protected Templatelayout $templateLayout;
/**
* Constructor
*
* @param Customcode|null $customcode The compiler customcode object.
* @param Gui|null $gui The compiler customcode gui.
* @param Templatelayout|null $templateLayout The compiler template layout object.
*
* @since 3.2.0
*/
public function __construct(?Customcode $customcode = null, ?Gui $gui = null,
?Templatelayout $templateLayout = null)
{
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->templateLayout = $templateLayout ?: Compiler::_('Templatelayout.Data');
}
/**
* Set Custom Buttons and Model/Controllers
*
* @param object $item The item data
* @param object $table The table
*
* @return void
* @since 3.2.0
*/
public function set(object &$item, string $table = 'admin_view')
{
if (isset($item->add_custom_button)
&& $item->add_custom_button == 1)
{
// set some gui mapper values
$this->guiMapper['table'] = $table;
$this->guiMapper['id'] = (int) $item->id;
// get the code
$code = $item->name_single_code ?? $item->code ?? 'error';
// set for the code
foreach ($this->areas as $area)
{
if (isset($item->{$area})
&& StringHelper::check(
$item->{$area}
))
{
// set field
$this->guiMapper['field'] = $area;
$item->{$area} = $this->gui->set(
$this->customcode->update(
base64_decode((string) $item->{$area})
),
$this->guiMapper
);
// check if we have template or layouts to load
$this->templateLayout->set(
$item->{$area}, $code
);
}
}
// set the button array
$item->custom_button = (isset($item->custom_button)
&& JsonHelper::check($item->custom_button))
? json_decode((string) $item->custom_button, true) : null;
if (ArrayHelper::check($item->custom_button))
{
$item->custom_buttons = array_values($item->custom_button);
}
unset($item->custom_button);
}
}
}

View File

@ -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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Model Custom Import Scripts Class
*
* @since 3.2.0
*/
class Customimportscripts
{
/**
* The areas add array
*
* @var array
* @since 3.2.0
*/
protected array $areas = [
'php_import_ext',
'php_import_display',
'php_import',
'php_import_setdata',
'php_import_save',
'php_import_headers',
'html_import_view'
];
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => 'admin_view',
'id' => null,
'field' => null,
'type' => 'php'
];
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Constructor
*
* @param Dispenser|null $dispenser The compiler customcode dispenser
*
* @since 3.2.0
*/
public function __construct(?Dispenser $dispenser = null)
{
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
}
/**
* Set Custom Import Scripts
*
* @param object $item The item data
* @param string $table The table
*
* @return void
* @since 3.2.0
*/
public function set(object &$item, string $table = 'admin_view')
{
// set custom import scripts
if (isset($item->add_custom_import)
&& $item->add_custom_import == 1)
{
// set some gui mapper values
$this->guiMapper['table'] = $table;
$this->guiMapper['id'] = (int) $item->id;
foreach ($this->areas as $area)
{
if (isset($item->$area)
&& StringHelper::check($item->$area))
{
// update GUI mapper field
$this->guiMapper['field'] = $area;
$this->guiMapper['type'] = 'php';
// Make sure html gets HTML comment for placeholder
if ('html_import_view' === $area)
{
$this->guiMapper['type'] = 'html';
}
$this->dispenser->set(
$item->$area,
$area,
'import_' . $item->name_list_code,
null,
$this->guiMapper
);
unset($item->$area);
}
else
{
// load the default TODO: convert getDynamicScripts to a class
$this->dispenser->hub[$area]['import_' . $item->name_list_code]
= Helper::_('getDynamicScripts', [$area, true]);
}
}
}
}
}

View File

@ -0,0 +1,242 @@
<?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\Model;
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\Language;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
/**
* Model Custom Tabs Class
*
* @since 3.2.0
*/
class Customtabs
{
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Compiler Language
*
* @var Language
* @since 3.2.0
**/
protected Language $language;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
*/
protected Placeholder $placeholder;
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
* @param Registry|null $registry The compiler registry object.
* @param Language|null $language The compiler Language object.
* @param Placeholder|null $placeholder The compiler placeholder object.
* @param Customcode|null $customcode The compiler customcode object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry = null,
?Language $language = null, ?Placeholder $placeholder = null, ?Customcode $customcode = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->language = $language ?: Compiler::_('Language');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->customcode = $customcode ?: Compiler::_('Customcode');
}
/**
* Set custom tabs
*
* @param object $item The view data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->customtabs = (isset($item->customtabs)
&& JsonHelper::check($item->customtabs))
? json_decode((string) $item->customtabs, true) : null;
if (ArrayHelper::check($item->customtabs))
{
// get the name
$name = $item->name_single_code;
// setup custom tabs to global data sets
$this->registry->set('builder.custom_tabs.' . $name,
array_map(
function ($tab) use (&$name) {
// set the view name
$tab['view'] = $name;
// load the dynamic data
$tab['html'] = $this->placeholder->update_(
$this->customcode->update($tab['html'])
);
// set the tab name
$tab['name'] = (isset($tab['name'])
&& StringHelper::check(
$tab['name']
)) ? $tab['name'] : 'Tab';
// set lang
$tab['lang'] = $this->config->lang_prefix . '_'
. StringHelper::safe(
$tab['view'], 'U'
) . '_' . StringHelper::safe(
$tab['name'], 'U'
);
$this->language->set(
'both', $tab['lang'], $tab['name']
);
// set code name
$tab['code'] = StringHelper::safe(
$tab['name']
);
// check if the permissions for the tab should be added
$_tab = '';
if (isset($tab['permission'])
&& $tab['permission'] == 1)
{
$_tab = Indent::_(1);
}
// check if the php of the tab is set, if not load it now
if (strpos((string) $tab['html'], 'bootstrap.addTab') === false
&& strpos((string) $tab['html'], 'bootstrap.endTab')
=== false)
{
// add the tab
$tmp = PHP_EOL . $_tab . Indent::_(1)
. "<?php echo JHtml::_('bootstrap.addTab', '"
. $tab['view'] . "Tab', '" . $tab['code']
. "', JT" . "ext::_('" . $tab['lang']
. "', true)); ?>";
$tmp .= PHP_EOL . $_tab . Indent::_(2)
. '<div class="row-fluid form-horizontal-desktop">';
$tmp .= PHP_EOL . $_tab . Indent::_(3)
. '<div class="span12">';
$tmp .= PHP_EOL . $_tab . Indent::_(4) . implode(
PHP_EOL . $_tab . Indent::_(4),
(array) explode(PHP_EOL, trim((string) $tab['html']))
);
$tmp .= PHP_EOL . $_tab . Indent::_(3) . '</div>';
$tmp .= PHP_EOL . $_tab . Indent::_(2) . '</div>';
$tmp .= PHP_EOL . $_tab . Indent::_(1)
. "<?php echo JHtml::_('bootstrap.endTab'); ?>";
// update html
$tab['html'] = $tmp;
}
else
{
$tab['html'] = PHP_EOL . $_tab . Indent::_(1)
. implode(
PHP_EOL . $_tab . Indent::_(1),
(array) explode(PHP_EOL, trim((string) $tab['html']))
);
}
// add the permissions if needed
if (isset($tab['permission'])
&& $tab['permission'] == 1)
{
$tmp = PHP_EOL . Indent::_(1)
. "<?php if (\$this->canDo->get('"
. $tab['view'] . "." . $tab['code']
. ".viewtab')) : ?>";
$tmp .= $tab['html'];
$tmp .= PHP_EOL . Indent::_(1) . "<?php endif; ?>";
// update html
$tab['html'] = $tmp;
// set lang for permissions
$tab['lang_permission'] = $tab['lang']
. '_TAB_PERMISSION';
$tab['lang_permission_desc'] = $tab['lang']
. '_TAB_PERMISSION_DESC';
$tab['lang_permission_title']
= $this->placeholder->get('Views') . ' View '
. $tab['name'] . ' Tab';
$this->language->set(
'both', $tab['lang_permission'],
$tab['lang_permission_title']
);
$this->language->set(
'both', $tab['lang_permission_desc'],
'Allow the users in this group to view '
. $tab['name'] . ' Tab of '
. $this->placeholder->get('views')
);
// set the sort key
$tab['sortKey']
= StringHelper::safe(
$tab['lang_permission_title']
);
}
// return tab
return $tab;
}, array_values($item->customtabs)
)
);
}
unset($item->customtabs);
}
}

View File

@ -0,0 +1,582 @@
<?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\Model;
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\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Dynamicget\Selection;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Model Dynamic Get Class
*
* @since 3.2.0
*/
class Dynamicget
{
/**
* The joint types
*
* @var array
* @since 3.2.0
*/
protected array $jointer = [
1 => 'LEFT',
2 => 'LEFT OUTER',
3 => 'INNER',
4 => 'RIGHT',
5 => 'RIGHT OUTER'
];
/**
* The operator types
*
* @var array
* @since 3.2.0
*/
protected array $operator = [
1 => '=',
2 => '!=',
3 => '<>',
4 => '>',
5 => '<',
6 => '>=',
7 => '<=',
8 => '!<',
9 => '!>',
10 => 'IN',
11 => 'NOT IN'
];
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => 'dynamic_get',
'id' => null,
'field' => null,
'type' => 'php'
];
/**
* 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
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Compiler Dynamic Get Selection
*
* @var Selection
* @since 3.2.0
**/
protected Selection $selection;
/**
* Constructor
*
* @param Config|null $config The compiler config.
* @param Registry|null $registry The compiler registry.
* @param Customcode|null $customcode The compiler customcode object.
* @param Gui|null $gui The compiler customcode gui.
* @param Placeholder|null $placeholder The compiler placeholder object.
* @param Selection|null $selection The compiler dynamic get selection object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry = null, ?Customcode $customcode = null,
?Gui $gui = null, ?Placeholder $placeholder = null, ?Selection $selection = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->selection = $selection ?: Compiler::_('Dynamicget.Selection');
}
/**
* Set Dynamic Get
*
* @param object $item The item data
* @param string $view_code The view code name
* @param string $context The context for events
*
* @return void
* @since 3.2.0
*/
public function set(object &$item, string $view_code, string $context)
{
// reset buckets
$item->main_get = [];
$item->custom_get = [];
// should joined and other tweaks be added
$add_tweaks_joints = true;
// set source data
switch ($item->main_source)
{
case 1:
// check if auto sync is set
if ($item->select_all == 1)
{
$item->view_selection = '*';
}
// set the view data
$item->main_get[0]['selection'] = $this->selection->get(
$item->key, $view_code,
$item->view_selection,
$item->view_table_main, 'a', 'view'
);
$item->main_get[0]['as'] = 'a';
$item->main_get[0]['key'] = $item->key;
$item->main_get[0]['context'] = $context;
unset($item->view_selection);
break;
case 2:
// check if auto sync is set
if ($item->select_all == 1)
{
$item->db_selection = '*';
}
// set the database data
$item->main_get[0]['selection'] = $this->selection->get(
$item->key, $view_code,
$item->db_selection,
$item->db_table_main, 'a', 'db'
);
$item->main_get[0]['as'] = 'a';
$item->main_get[0]['key'] = $item->key;
$item->main_get[0]['context'] = $context;
unset($item->db_selection);
break;
case 3:
// set GUI mapper field
$this->guiMapper['field'] = 'php_custom_get';
// get the custom query
$customQueryString
= $this->gui->set(
$this->customcode->update(
base64_decode((string) $item->php_custom_get)
),
$this->guiMapper
);
// get the table name
$_searchQuery
= GetHelper::between(
$customQueryString, '$query->from(', ')'
);
if (StringHelper::check(
$_searchQuery
)
&& strpos((string) $_searchQuery, '#__') !== false)
{
$_queryName = GetHelper::between(
$_searchQuery, '#__', "'"
);
if (!StringHelper::check(
$_queryName
))
{
$_queryName = GetHelper::between(
$_searchQuery, '#__', '"'
);
}
}
// set to blank if not found
if (!isset($_queryName)
|| !StringHelper::check(
$_queryName
))
{
$_queryName = '';
}
// set custom script
$item->main_get[0]['selection'] = [
'select' => $customQueryString,
'from' => '', 'table' => '', 'type' => '',
'name' => $_queryName];
$item->main_get[0]['as'] = 'a';
$item->main_get[0]['key'] = $item->key;
$item->main_get[0]['context'] = $context;
// do not add
$add_tweaks_joints = false;
break;
}
// only add if main source is not custom
if ($add_tweaks_joints)
{
// set join_view_table details
$item->join_view_table = json_decode(
(string) $item->join_view_table, true
);
if (ArrayHelper::check(
$item->join_view_table
))
{
// start the part of a table bucket
$_part_of_a = [];
// build relationship
$_relationship = array_map(
function ($op) use (&$_part_of_a) {
$bucket = array();
// array(on_field_as, on_field)
$bucket['on_field'] = array_map(
'trim',
explode('.', (string) $op['on_field'])
);
// array(join_field_as, join_field)
$bucket['join_field'] = array_map(
'trim',
explode('.', (string) $op['join_field'])
);
// triget filed that has table a relationship
if ($op['row_type'] == 1
&& ($bucket['on_field'][0] === 'a'
|| isset($_part_of_a[$bucket['on_field'][0]])
|| isset($_part_of_a[$bucket['join_field'][0]])))
{
$_part_of_a[$op['as']] = $op['as'];
}
return $bucket;
}, $item->join_view_table
);
// loop joints
foreach (
$item->join_view_table as $nr => &$option
)
{
if (StringHelper::check(
$option['selection']
))
{
// convert the type
$option['type']
= $this->jointer[$option['type']];
// convert the operator
$option['operator']
= $this->operator[$option['operator']];
// get the on field values
$on_field
= $_relationship[$nr]['on_field'];
// get the join field values
$join_field
= $_relationship[$nr]['join_field'];
// set selection
$option['selection']
= $this->selection->get(
$item->key,
$view_code,
$option['selection'],
$option['view_table'],
$option['as'],
'view',
$option['row_type']
);
$option['key'] = $item->key;
$option['context'] = $context;
// load to the getters
if ($option['row_type'] == 1)
{
$item->main_get[] = $option;
if ($on_field[0] === 'a'
|| isset($_part_of_a[$join_field[0]])
|| isset($_part_of_a[$on_field[0]]))
{
$this->registry->
set('builder.site_main_get.' . $this->config->build_target .
'.' . $view_code . '.' . $option['as'], $option['as']);
}
else
{
$this->registry->
set('builder.site_dynamic_get.' . $this->config->build_target .
'.' . $view_code . '.' . $option['as'] . '.' . $join_field[1], $on_field[0]);
}
}
elseif ($option['row_type'] == 2)
{
$item->custom_get[] = $option;
if ($on_field[0] != 'a')
{
$this->registry->
set('builder.site_dynamic_get.' . $this->config->build_target .
'.' . $view_code . '.' . $option['as'] . '.' . $join_field[1], $on_field[0]);
}
}
}
unset($item->join_view_table[$nr]);
}
}
unset($item->join_view_table);
// set join_db_table details
$item->join_db_table = json_decode(
(string) $item->join_db_table, true
);
if (ArrayHelper::check(
$item->join_db_table
))
{
// start the part of a table bucket
$_part_of_a = array();
// build relationship
$_relationship = array_map(
function ($op) use (&$_part_of_a) {
$bucket = array();
// array(on_field_as, on_field)
$bucket['on_field'] = array_map(
'trim',
explode('.', (string) $op['on_field'])
);
// array(join_field_as, join_field)
$bucket['join_field'] = array_map(
'trim',
explode('.', (string) $op['join_field'])
);
// triget filed that has table a relationship
if ($op['row_type'] == 1
&& ($bucket['on_field'][0] === 'a'
|| isset($_part_of_a[$bucket['on_field'][0]])
|| isset($_part_of_a[$bucket['join_field'][0]])))
{
$_part_of_a[$op['as']] = $op['as'];
}
return $bucket;
}, $item->join_db_table
);
// loop joints
foreach (
$item->join_db_table as $nr => &$option1
)
{
if (StringHelper::check(
$option1['selection']
))
{
// convert the type
$option1['type']
= $this->jointer[$option1['type']];
// convert the operator
$option1['operator']
= $this->operator[$option1['operator']];
// get the on field values
$on_field
= $_relationship[$nr]['on_field'];
// get the join field values
$join_field
= $_relationship[$nr]['join_field'];
// set selection
$option1['selection']
= $this->selection->get(
$item->key,
$view_code,
$option1['selection'],
$option1['db_table'],
$option1['as'],
'db',
$option1['row_type']
);
$option1['key'] = $item->key;
$option1['context'] = $context;
// load to the getters
if ($option1['row_type'] == 1)
{
$item->main_get[] = $option1;
if ($on_field[0] === 'a'
|| isset($_part_of_a[$join_field[0]])
|| isset($_part_of_a[$on_field[0]]))
{
$this->registry->
set('builder.site_main_get.' . $this->config->build_target .
'.' . $view_code . '.' . $option1['as'], $option1['as']);
}
else
{
$this->registry->
set('builder.site_dynamic_get.' . $this->config->build_target .
'.' . $view_code . '.' . $option1['as'] . '.' . $join_field[1], $on_field[0]);
}
}
elseif ($option1['row_type'] == 2)
{
$item->custom_get[] = $option1;
if ($on_field[0] != 'a')
{
$this->registry->
set('builder.site_dynamic_get.' . $this->config->build_target .
'.' . $view_code . '.' . $option1['as'] . '.' . $join_field[1], $on_field[0]);
}
}
}
unset($item->join_db_table[$nr]);
}
}
unset($item->join_db_table);
// set filter details
$item->filter = json_decode(
(string) $item->filter, true
);
if (ArrayHelper::check(
$item->filter
))
{
foreach ($item->filter as $nr => &$option2)
{
if (isset($option2['operator']))
{
$option2['operator'] = $this->operator[$option2['operator']];
$option2['state_key'] = $this->placeholder->update_(
$this->customcode->update(
$option2['state_key']
)
);
$option2['key'] = $item->key;
}
else
{
unset($item->filter[$nr]);
}
}
}
// set where details
$item->where = json_decode((string) $item->where, true);
if (ArrayHelper::check(
$item->where
))
{
foreach ($item->where as $nr => &$option3)
{
if (isset($option3['operator']))
{
$option3['operator']
= $this->operator[$option3['operator']];
}
else
{
unset($item->where[$nr]);
}
}
}
else
{
unset($item->where);
}
// set order details
$item->order = json_decode((string) $item->order, true);
if (!ArrayHelper::check(
$item->order
))
{
unset($item->order);
}
// set grouping
$item->group = json_decode((string) $item->group, true);
if (!ArrayHelper::check(
$item->group
))
{
unset($item->group);
}
// set global details
$item->global = json_decode(
(string) $item->global, true
);
if (!ArrayHelper::check(
$item->global
))
{
unset($item->global);
}
}
else
{
// when we have a custom query script we do not add the dynamic options
unset($item->join_view_table);
unset($item->join_db_table);
unset($item->filter);
unset($item->where);
unset($item->order);
unset($item->group);
unset($item->global);
}
}
}

View File

@ -0,0 +1,342 @@
<?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\Model;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Application\CMSApplication;
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\HistoryInterface;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Field;
use VDM\Joomla\Componentbuilder\Compiler\Field\Name as FieldName;
use VDM\Joomla\Componentbuilder\Compiler\Model\Updatesql;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\FieldHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
/**
* Model Fields Class
*
* @since 3.2.0
*/
class Fields
{
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Compiler History
*
* @var HistoryInterface
* @since 3.2.0
*/
protected HistoryInterface $history;
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Field
*
* @var Field
* @since 3.2.0
*/
protected Field $field;
/**
* Compiler Field Name
*
* @var FieldName
* @since 3.2.0
*/
protected FieldName $fieldName;
/**
* Compiler Update Sql
*
* @var UpdateSql
* @since 3.2.0
*/
protected UpdateSql $updateSql;
/**
* Application object.
*
* @var CMSApplication
* @since 3.2.0
**/
protected CMSApplication $app;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
* @param Registry|null $registry The compiler registry object.
* @param HistoryInterface|null $history The compiler history object.
* @param Customcode|null $customcode The compiler customcode object.
* @param Field|null $field The compiler field object.
* @param FieldName|null $fieldName The compiler field name object.
* @param UpdateSql|null $updateSql The compiler field name object.
* @param CMSApplication|null $app The app object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry = null,
?HistoryInterface $history = null, ?Customcode $customcode = null,
?Field $field = null, ?FieldName $fieldName = null,
?UpdateSql $updateSql = null, ?CMSApplication $app = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->history = $history ?: Compiler::_('History');
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->field = $field ?: Compiler::_('Field');
$this->fieldName = $fieldName ?: Compiler::_('Field.Name');
$this->updateSql = $updateSql ?: Compiler::_('Model.Updatesql');
$this->app = $app ?: Factory::getApplication();
}
/**
* Set fields
*
* @param object $item The view data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->fields = [];
$item->addfields = (isset($item->addfields)
&& JsonHelper::check($item->addfields))
? json_decode((string) $item->addfields, true) : null;
if (ArrayHelper::check($item->addfields))
{
$ignore_fields = [];
$default_fields = $this->config->default_fields;
// load the field data
$item->fields = array_map(
function ($field) use (
&$item, &$ignore_fields, &$default_fields
) {
// set the field details
$this->field->set(
$field, $item->name_single_code,
$item->name_list_code
);
// check if this field is a default field OR
// check if this is none database related field
if (in_array($field['base_name'], $default_fields)
|| FieldHelper::check($field['type_name'], 'spacer')
|| (isset($field['list']) && $field['list'] == 2)) // 2 = none database
{
$ignore_fields[$field['field']] = $field['field'];
}
// return field
return $field;
}, array_values($item->addfields)
);
// build update SQL
if ($old_view = $this->history->get(
'admin_fields', $item->addfields_id
))
{
// add new fields were added
if (isset($old_view->addfields)
&& JsonHelper::check(
$old_view->addfields
))
{
$this->updateSql->set(
json_decode((string) $old_view->addfields, true),
$item->addfields, 'field', $item->name_single_code,
$ignore_fields
);
}
// clear this data
unset($old_view);
}
// sort the fields according to order
usort(
$item->fields, function ($a, $b) {
if (isset($a['order_list']) && isset($b['order_list']))
{
if ($a['order_list'] != 0 && $b['order_list'] != 0)
{
return $a['order_list'] - $b['order_list'];
}
elseif ($b['order_list'] != 0 && $a['order_list'] == 0)
{
return 1;
}
elseif ($a['order_list'] != 0 && $b['order_list'] == 0)
{
return 0;
}
return 1;
}
return 0;
}
);
// do some house cleaning (for fields)
foreach ($item->fields as $field)
{
// so first we lock the field name in
$field_name = $this->fieldName->get(
$field, $item->name_list_code
);
// check if the field changed since the last compilation
// (default fields never change and are always added)
if (!isset($ignore_fields[$field['field']])
&& ObjectHelper::check(
$field['settings']->history
))
{
// check if the datatype changed
if (isset($field['settings']->history->datatype))
{
$this->updateSql->set(
$field['settings']->history->datatype,
$field['settings']->datatype, 'field.datatype',
$item->name_single_code . '.' . $field_name
);
}
// check if the datatype lenght changed
if (isset($field['settings']->history->datalenght)
&& isset($field['settings']->history->datalenght_other))
{
$this->updateSql->set(
$field['settings']->history->datalenght
. $field['settings']->history->datalenght_other,
$field['settings']->datalenght
. $field['settings']->datalenght_other,
'field.lenght',
$item->name_single_code . '.' . $field_name
);
}
// check if the name changed
if (isset($field['settings']->history->xml)
&& JsonHelper::check(
$field['settings']->history->xml
))
{
// only run if this is not an alias or a tag
if ((!isset($field['alias']) || !$field['alias'])
&& 'tag' !== $field['settings']->type_name)
{
// build temp field bucket
$tmpfield = array();
$tmpfield['settings'] = new \stdClass();
// convert the xml json string to normal string
$tmpfield['settings']->xml
= $this->customcode->update(
json_decode(
(string) $field['settings']->history->xml
)
);
// add properties from current field as it is generic
$tmpfield['settings']->properties
= $field['settings']->properties;
// add the old name
$tmpfield['settings']->name
= $field['settings']->history->name;
// add the field type from current field since it is generic
$tmpfield['settings']->type_name
= $field['settings']->type_name;
// get the old name
$old_field_name = $this->fieldName->get(
$tmpfield
);
// only run this if not a multi field
if ($this->registry->get('unique.names.' . $item->name_list_code . '.names.' . $field_name) === null)
{
// this only works when the field is
// not multiple of the same field
$this->updateSql->set(
$old_field_name, $field_name,
'field.name',
$item->name_single_code . '.'
. $field_name
);
}
elseif ($old_field_name !== $field_name)
{
// give a notice atleast that the multi fields
// could have changed and no DB update was done
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEFIELD_NOTICEHTHREE'),
'Notice'
);
$this->app->enqueueMessage(
Text::sprintf(
'You have a field called <b>%s</b> that has been added multiple times to the <b>%s</b> view, the name of that field has changed to <b>%s</b>. Normaly we would automaticly add the update SQL to your component, but with multiple fields this does not work automaticly since it could be that noting changed and it just seems like it did. Therefore you will have to do this manualy if it actualy did change!',
$field_name,
$item->name_single_code,
$old_field_name
), 'Notice'
);
}
// remove tmp
unset($tmpfield);
}
}
}
}
}
unset($item->addfields);
}
}

View File

@ -0,0 +1,81 @@
<?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\Model;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Model Files & Folders Class
*
* @since 3.2.0
*/
class Filesfolders
{
/**
* Compiler Files Folders
*
* @var array
* @since 3.2.0
*/
protected array $keys = [
'files' => 'files',
'folders' => 'folders',
'urls' => 'urls',
'filesfullpath' => 'files',
'foldersfullpath' => 'folders'
];
/**
* Set the file and folder data
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
foreach ($this->keys as $target => $value)
{
// set the add target data
$item->{'add' . $target} = (isset($item->{'add' . $target}) &&
JsonHelper::check($item->{'add' . $target})) ?
json_decode((string) $item->{'add' . $target}, true) : null;
// only continue if there are values
if (ArrayHelper::check($item->{'add' . $target}))
{
if (isset($item->{$value})
&& ArrayHelper::check($item->{$value}))
{
foreach ($item->{'add' . $target} as $taget)
{
$item->{$value}[] = $taget;
}
}
else
{
$item->{$value} = array_values(
$item->{'add' . $target}
);
}
}
unset($item->{'add' . $target});
}
}
}

View File

@ -0,0 +1,126 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HistoryInterface;
use VDM\Joomla\Componentbuilder\Compiler\Model\Updatesql;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model Admin View History Class
*
* @since 3.2.0
*/
class Historyadminview
{
/**
* The compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The compiler history
*
* @var HistoryInterface
* @since 3.2.0
*/
protected HistoryInterface $history;
/**
* The compiler update sql
*
* @var Updatesql
* @since 3.2.0
*/
protected Updatesql $updatesql;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
* @param HistoryInterface|null $history The compiler history object.
* @param Updatesql|null $updatesql The compiler updatesql object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?HistoryInterface $history = null,
?Updatesql $updatesql = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->history = $history ?: Compiler::_('History');
$this->updatesql = $updatesql ?: Compiler::_('Model.Updatesql');
}
/**
* check if an update SQL is needed
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
if ($old = $this->history->get('admin_view', $item->id))
{
// check if the view name changed
if (StringHelper::check($old->name_single))
{
$this->updatesql->set(
StringHelper::safe(
$old->name_single
), $item->name_single_code, 'table_name',
$item->name_single_code
);
}
// loop the mysql table settings
foreach ($this->config->mysql_table_keys as $mysql_table_key => $mysql_table_val)
{
// check if the table engine changed
if (isset($old->{'mysql_table_' . $mysql_table_key})
&& isset($item->{'mysql_table_' . $mysql_table_key}))
{
$this->updatesql->set(
$old->{'mysql_table_' . $mysql_table_key},
$item->{'mysql_table_' . $mysql_table_key},
'table_' . $mysql_table_key, $item->name_single_code
);
}
// check if there is no history on table engine, and it changed from the default/global
elseif (isset($item->{'mysql_table_' . $mysql_table_key})
&& StringHelper::check(
$item->{'mysql_table_' . $mysql_table_key}
)
&& !is_numeric(
$item->{'mysql_table_' . $mysql_table_key}
))
{
$this->updatesql->set(
$mysql_table_val['default'],
$item->{'mysql_table_' . $mysql_table_key},
'table_' . $mysql_table_key, $item->name_single_code
);
}
}
}
}
}

View File

@ -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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HistoryInterface;
use VDM\Joomla\Componentbuilder\Compiler\Model\Updatesql;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\JsonHelper;
/**
* Model Component History Class
*
* @since 3.2.0
*/
class Historycomponent
{
/**
* The compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The compiler history
*
* @var HistoryInterface
* @since 3.2.0
*/
protected HistoryInterface $history;
/**
* The compiler update sql
*
* @var Updatesql
* @since 3.2.0
*/
protected Updatesql $updatesql;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
* @param HistoryInterface|null $history The compiler history object.
* @param Updatesql|null $updatesql The compiler updatesql object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?HistoryInterface $history = null,
?Updatesql $updatesql = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->history = $history ?: Compiler::_('History');
$this->updatesql = $updatesql ?: Compiler::_('Model.Updatesql');
}
/**
* check if an update SQL is needed
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$old_admin_views = $this->history->get(
'component_admin_views', $item->addadmin_views_id
);
$old_component = $this->history->get(
'joomla_component', $this->config->component_id
);
if ($old_component || $old_admin_views)
{
if (ObjectHelper::check($old_admin_views))
{
// add new views if found
if (isset($old_admin_views->addadmin_views)
&& JsonHelper::check(
$old_admin_views->addadmin_views
))
{
$this->updatesql->set(
json_decode((string) $old_admin_views->addadmin_views, true),
$item->addadmin_views, 'adminview'
);
}
// check if a new version was manually set
if (ObjectHelper::check($old_component))
{
$old_component_version = preg_replace(
'/[^0-9.]+/', '', (string) $old_component->component_version
);
if ($old_component_version != $this->config->component_version)
{
// yes, this is a new version, this mean there may
// be manual sql and must be checked and updated
$item->old_component_version
= $old_component_version;
}
// clear this data
unset($old_component);
}
// clear this data
unset($old_admin_views);
}
}
// unset original value
unset($item->addadmin_views);
}
}

View File

@ -0,0 +1,128 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model Admin View Javascript Class
*
* @since 3.2.0
*/
class Javascriptadminview
{
/**
* The scripter add array
*
* @var array
* @since 3.2.0
*/
protected array $scripter = [
'javascript_view_file',
'javascript_view_footer',
'javascript_views_file',
'javascript_views_footer'
];
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => 'admin_view',
'id' => null,
'field' => null,
'type' => 'js',
'prefix' => PHP_EOL
];
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Constructor
*
* @param Dispenser|null $dispenser The compiler customcode dispenser
*
* @since 3.2.0
*/
public function __construct(?Dispenser $dispenser = null)
{
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
}
/**
* Set Admin View Javascript
*
* @param object $item The item data
* @param object $table The table
*
* @return void
* @since 3.2.0
*/
public function set(object &$item, string $table = 'admin_view')
{
// set some gui mapper values
$this->guiMapper['table'] = $table;
$this->guiMapper['id'] = (int) $item->id;
foreach ($this->scripter as $scripter)
{
if (isset($item->{'add_' . $scripter})
&& $item->{'add_' . $scripter} == 1
&& StringHelper::check($item->$scripter))
{
$scripter_target = str_replace(
'javascript_', '', (string) $scripter
);
// update GUI mapper field
$this->guiMapper['field'] = $scripter;
$this->dispenser->set(
$item->{$scripter},
$scripter_target,
$item->name_single_code,
null,
$this->guiMapper,
true,
true,
true
);
// check if a token must be set
if ((strpos((string) $item->$scripter, "token") !== false
|| strpos(
(string) $item->$scripter, "task=ajax"
) !== false) && !$this->dispenser->hub['token'][$item->name_single_code])
{
$this->dispenser->hub['token'][$item->name_single_code]
= true;
}
unset($item->{$scripter});
}
}
}
}

View File

@ -0,0 +1,116 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model Javascript Custom View Class
*
* @since 3.2.0
*/
class Javascriptcustomview
{
/**
* The areas add array
*
* @var array
* @since 3.2.0
*/
protected array $areas = [
'javascript_file',
'js_document'
];
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => null,
'id' => null,
'field' => null,
'type' => 'js'
];
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Constructor
*
* @param Customcode|null $customcode The compiler customcode object.
* @param Gui|null $gui The compiler customcode gui.
*
* @since 3.2.0
*/
public function __construct(?Customcode $customcode = null, ?Gui $gui = null)
{
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
}
/**
* Set Javascript code
*
* @param object $item The item data
* @param string $table The table
*
* @return void
* @since 3.2.0
*/
public function set(object &$item, string $table = 'site_view')
{
// set some gui mapper values
$this->guiMapper['table'] = $table;
$this->guiMapper['id'] = (int) $item->id;
foreach ($this->areas as $area)
{
if (isset($item->{'add_' . $area})
&& $item->{'add_' . $area} == 1
&& StringHelper::check($item->{$area}))
{
// update GUI mapper field
$this->guiMapper['field'] = $area;
$item->{$area} = $this->gui->set(
$this->customcode->update(
base64_decode((string) $item->{$area})
),
$this->guiMapper
);
}
}
}
}

View File

@ -0,0 +1,84 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\Data as Module;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\JsonHelper;
/**
* Model Joomla Modules Class
*
* @since 3.2.0
*/
class Joomlamodules
{
/**
* Compiler Joomla Module Data Class
*
* @var Module
* @since 3.2.0
*/
protected Module $module;
/**
* Constructor
*
* @param Module|null $module The compiler Joomla module data object.
*
* @since 3.2.0
*/
public function __construct(?Module $module = null)
{
$this->module = $module ?: Compiler::_('Joomlamodule.Data');
}
/**
* Set Joomla Module
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
// get all modules
$item->addjoomla_modules = (isset($item->addjoomla_modules)
&& JsonHelper::check($item->addjoomla_modules))
? json_decode((string) $item->addjoomla_modules, true) : null;
if (ArrayHelper::check($item->addjoomla_modules))
{
$joomla_modules = array_map(
function ($array) use (&$item) {
// only load the modules whose target association calls for it
if (!isset($array['target']) || $array['target'] != 2)
{
return $this->module->set(
$array['module'], $item
);
}
return null;
}, array_values($item->addjoomla_modules)
);
}
unset($item->addjoomla_modules);
}
}

View File

@ -0,0 +1,84 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Joomlaplugin\Data as Plugin;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\JsonHelper;
/**
* Model Joomla Plugins Class
*
* @since 3.2.0
*/
class Joomlaplugins
{
/**
* Compiler Joomla Plugin Data Class
*
* @var Plugin
* @since 3.2.0
*/
protected Plugin $plugin;
/**
* Constructor
*
* @param Plugin|null $plugin The compiler Joomla plugin data object.
*
* @since 3.2.0
*/
public function __construct(?Plugin $plugin = null)
{
$this->plugin = $plugin ?: Compiler::_('Joomlaplugin.Data');
}
/**
* Set Joomla Plugins
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
// get all plugins
$item->addjoomla_plugins = (isset($item->addjoomla_plugins)
&& JsonHelper::check($item->addjoomla_plugins))
? json_decode((string) $item->addjoomla_plugins, true) : null;
if (ArrayHelper::check($item->addjoomla_plugins))
{
$joomla_plugins = array_map(
function ($array) use (&$item) {
// only load the plugins whose target association calls for it
if (!isset($array['target']) || $array['target'] != 2)
{
return $this->plugin->set(
$array['plugin'], $item
);
}
return null;
}, array_values($item->addjoomla_plugins)
);
}
unset($item->addjoomla_plugins);
}
}

View File

@ -0,0 +1,115 @@
<?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\Model;
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\Library\Data as Library;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Model Libraries Class
*
* @since 3.2.0
*/
class Libraries
{
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Compiler Registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Compiler Library Data
*
* @var Library
* @since 3.2.0
*/
protected Library $library;
/**
* Constructor
*
* @param Config|null $config The compiler config.
* @param Registry|null $registry The compiler registry.
* @param Library|null $library The compiler library data object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry = null, ?Library $library = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->library = $library ?: Compiler::_('Library.Data');
}
/**
* Set Libraries
*
* @param string $key The key mapper
* @param object $item The item data
* @param string|null $target The area being targeted
*
* @return void
* @since 3.2.0
*/
public function set(string $key, object &$item, string $target = null)
{
// set the target
$target = $target ?: $this->config->build_target;
// make sure json become array
if (JsonHelper::check($item->libraries))
{
$item->libraries = json_decode((string) $item->libraries, true);
}
// if we have an array add it
if (ArrayHelper::check($item->libraries))
{
foreach ($item->libraries as $library)
{
if (!$this->registry->exists('builder.library_manager.' .
$target . '.' . $key . '.' . (int) $library) && $this->library->get((int) $library))
{
$this->registry->set('builder.library_manager.' .
$target . '.' . $key . '.' . (int) $library, true);
}
}
}
elseif (is_numeric($item->libraries)
&& !$this->registry->exists('builder.library_manager.' .
$target . '.' . $key . '.' . (int) $item->libraries)
&& $this->library->get((int) $item->libraries))
{
$this->registry->set('builder.library_manager.' .
$target . '.' . $key . '.' . (int) $item->libraries, true);
}
}
}

View File

@ -0,0 +1,76 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Model Linked Views Class
*
* @since 3.2.0
*/
class Linkedviews
{
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Constructor
*
* @param Registry|null $registry The compiler registry object.
*
* @since 3.2.0
*/
public function __construct(?Registry $registry = null)
{
$this->registry = $registry ?: Compiler::_('Registry');
}
/**
* Set the linked views
*
* @param object $item The view data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->addlinked_views = (isset($item->addlinked_views)
&& JsonHelper::check($item->addlinked_views))
? json_decode((string) $item->addlinked_views, true) : null;
if (ArrayHelper::check($item->addlinked_views))
{
// setup linked views to global data sets
$this->registry->set('builder.linked_admin_views.' . $item->name_single_code,
array_values(
$item->addlinked_views
)
);
}
unset($item->addlinked_views);
}
}

View File

@ -0,0 +1,185 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Utilities\Component\Helper;
/**
* Model Auto Loader Class
*
* @since 3.2.0
*/
class Loader
{
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
* @param Registry|null $registry The compiler registry object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
}
/**
* Automatically load some stuff
*
* @param string $key The key mapper
* @param string $content The content to search through
* @param string|null $target The area being targeted
*
* @return void
* @since 3.2.0
*/
public function set(string $key, string $content, ?string $target = null)
{
// set the target
$target = $target ?: $this->config->build_target;
// check for footable
if (!$this->registry->
exists('builder.footable_scripts.' . $target . '.' . $key))
{
if ($this->getFootableScripts($content))
{
$this->registry->
set('builder.footable_scripts.' . $target . '.' . $key, true);
$this->config->set('footable ', true);
}
}
// check for google chart
if (!$this->registry->
exists('builder.google_chart.' . $target . '.' . $key))
{
if ($this->getGoogleChart($content))
{
$this->registry->
set('builder.google_chart.' . $target . '.' . $key, true);
$this->config->set('google_chart', true);
}
}
// check for get module
if (!$this->registry->
exists('builder.get_module.' . $target . '.' . $key))
{
if ($this->getGetModule($content))
{
$this->registry->
set('builder.get_module.' . $target . '.' . $key, true);
}
}
}
/**
* Automatically load uikit version 2 data files
*
* @param string $key The key mapper
* @param string $content The content to search through
*
* @return void
* @since 3.2.0
*/
public function uikit(string $key, string $content)
{
// get/set uikit state
$uikit = false;
$uikit_ = $this->config->get('uikit', 0);
// add uikit if required
if (2 == $uikit_ || 1 == $uikit_)
{
$uikit = true;
}
// load uikit
if ($uikit)
{
// set uikit to views TODO: convert this getUikitComp to a class
if (($found = Helper::_('getUikitComp',
[$content, (array) $this->registry->get('builder.uikit_comp.' . $key, [])]
)) !== false)
{
$this->registry->set('builder.uikit_comp.' . $key, $found);
}
}
}
/**
* Check for footable scripts
*
* @param string $content The content to check
*
* @return boolean True if found
* @since 3.2.0
*/
protected function getFootableScripts(string &$content): bool
{
return strpos($content, 'footable') !== false;
}
/**
* Check for getModules script
*
* @param string $content The content to check
*
* @return boolean True if found
* @since 3.2.0
*/
protected function getGetModule(string &$content): bool
{
return strpos($content, 'this->getModules(') !== false;
}
/**
* Check for get Google Chart script
*
* @param string $content The content to check
*
* @return boolean True if found
* @since 3.2.0
*/
protected function getGoogleChart(string &$content): bool
{
return strpos($content, 'Chartbuilder(') !== false;
}
}

View File

@ -0,0 +1,95 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model MySQL Settings Class
*
* @since 3.2.0
*/
class Mysqlsettings
{
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* Compiler Registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Constructor
*
* @param Config|null $config The compiler config.
* @param Registry|null $registry The compiler registry.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
}
/**
* Set MySQL table settings
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
foreach (
$this->config->mysql_table_keys as $mysql_table_key => $mysql_table_val
)
{
if (isset($item->{'mysql_table_' . $mysql_table_key})
&& StringHelper::check(
$item->{'mysql_table_' . $mysql_table_key}
)
&& !is_numeric($item->{'mysql_table_' . $mysql_table_key}))
{
$this->registry->set('builder.mysql_table_setting.' . $item->name_single_code . '.' .
$mysql_table_key, $item->{'mysql_table_' . $mysql_table_key}
);
}
else
{
$this->registry->set('builder.mysql_table_setting.' . $item->name_single_code . '.' .
$mysql_table_key, $mysql_table_val['default']
);
}
// remove the table values since we moved to another object
unset($item->{'mysql_table_' . $mysql_table_key});
}
}
}

View File

@ -0,0 +1,49 @@
<?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\Model;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Model Permissions Class
*
* @since 3.2.0
*/
class Permissions
{
/**
* Set the local tabs
*
* @param object $item The view data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->addpermissions = (isset($item->addpermissions)
&& JsonHelper::check($item->addpermissions))
? json_decode((string) $item->addpermissions, true) : null;
if (ArrayHelper::check($item->addpermissions))
{
$item->permissions = array_values($item->addpermissions);
}
unset($item->addpermissions);
}
}

View File

@ -0,0 +1,139 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Templatelayout\Data as Templatelayout;
/**
* Model PHP Admin View Class
*
* @since 3.2.0
*/
class Phpadminview
{
/**
* The areas add array
*
* @var array
* @since 3.2.0
*/
protected array $areas = [
'php_getitem',
'php_before_save',
'php_save',
'php_getform',
'php_postsavehook',
'php_getitems',
'php_getitems_after_all',
'php_getlistquery',
'php_allowadd',
'php_allowedit',
'php_before_cancel',
'php_after_cancel',
'php_before_delete',
'php_after_delete',
'php_before_publish',
'php_after_publish',
'php_batchcopy',
'php_batchmove',
'php_document'
];
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => 'admin_view',
'id' => null,
'field' => null,
'type' => 'php'
];
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Compiler Template Layout Data
*
* @var Templatelayout
* @since 3.2.0
*/
protected Templatelayout $templateLayout;
/**
* Constructor
*
* @param Dispenser|null $dispenser The compiler customcode dispenser
* @param Templatelayout|null $templateLayout The template layout data
*
* @since 3.2.0
*/
public function __construct(?Dispenser $dispenser = null, ?Templatelayout $templateLayout = null)
{
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
$this->templateLayout = $templateLayout ?: Compiler::_('Templatelayout.Data');
}
/**
* Set PHP code
*
* @param object $item The item data
* @param string $table The table
*
* @return void
* @since 3.2.0
*/
public function set(object &$item, string $table = 'admin_view')
{
// set some gui mapper values
$this->guiMapper['table'] = $table;
$this->guiMapper['id'] = (int) $item->id;
foreach ($this->areas as $area)
{
if (isset($item->{'add_' . $area})
&& $item->{'add_' . $area} == 1)
{
// update GUI mapper field
$this->guiMapper['field'] = $area;
$this->dispenser->set(
$item->{$area},
$area,
$item->name_single_code,
null,
$this->guiMapper
);
// check if we have template or layouts to load
$this->templateLayout->set(
$item->{$area}, $item->name_single_code
);
unset($item->{$area});
}
}
}
}

View File

@ -0,0 +1,152 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
use VDM\Joomla\Componentbuilder\Compiler\Model\Loader;
use VDM\Joomla\Componentbuilder\Compiler\Templatelayout\Data as Templatelayout;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model PHP Custom View Class
*
* @since 3.2.0
*/
class Phpcustomview
{
/**
* The areas add array
*
* @var array
* @since 3.2.0
*/
protected array $areas = [
'php_view',
'php_jview',
'php_jview_display',
'php_document'
];
/**
* The gui mapper array
*
* @var array
* @since 3.2.0
*/
protected array $guiMapper = [
'table' => null,
'id' => null,
'field' => null,
'type' => 'php'
];
/**
* 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 Auto Loader
*
* @var Loader
* @since 3.2.0
*/
protected Loader $loader;
/**
* Compiler Template Layout Data
*
* @var Templatelayout
* @since 3.2.0
*/
protected Templatelayout $templateLayout;
/**
* Constructor
*
* @param Customcode|null $customcode The compiler customcode object.
* @param Gui|null $gui The compiler customcode gui.
* @param Loader|null $loader The compiler loader object.
* @param Templatelayout|null $templateLayout The template layout data.
*
* @since 3.2.0
*/
public function __construct(?Customcode $customcode = null, ?Gui $gui = null,
?Loader $loader = null, ?Templatelayout $templateLayout = null)
{
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->loader = $loader ?: Compiler::_('Model.Loader');
$this->templateLayout = $templateLayout ?: Compiler::_('Templatelayout.Data');
}
/**
* Set PHP code
*
* @param object $item The item data
* @param string $table The table
*
* @return void
* @since 3.2.0
*/
public function set(object &$item, string $table = 'site_view')
{
// set some gui mapper values
$this->guiMapper['table'] = $table;
$this->guiMapper['id'] = (int) $item->id;
foreach ($this->areas as $area)
{
if (isset($item->{'add_' . $area})
&& $item->{'add_' . $area} == 1
&& StringHelper::check($item->$area))
{
// update GUI mapper field
$this->guiMapper['field'] = $area;
$item->{$area} = $this->gui->set(
$this->customcode->update(
base64_decode((string) $item->{$area})
),
$this->guiMapper
);
// check if we have template or layouts to load
$this->templateLayout->set(
$item->{$area}, $item->code
);
// auto loaders
$this->loader->set($item->code, $item->{$area});
// set uikit version 2
$this->loader->uikit($item->code, $item->{$area});
}
}
}
}

View File

@ -0,0 +1,177 @@
<?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\Model;
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\Language;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model Relations Class
*
* @since 3.2.0
*/
class Relations
{
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Compiler Language
*
* @var Language
* @since 3.2.0
**/
protected Language $language;
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.0
*/
protected Customcode $customcode;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
* @param Registry|null $registry The compiler registry object.
* @param Language|null $language The compiler Language object.
* @param Customcode|null $customcode The compiler customcode object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry = null,
?Language $language = null, ?Customcode $customcode = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->language = $language ?: Compiler::_('Language');
$this->customcode = $customcode ?: Compiler::_('Customcode');
}
/**
* Set the relations
*
* @param object $item The view data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->addrelations = (isset($item->addrelations)
&& JsonHelper::check($item->addrelations))
? json_decode((string) $item->addrelations, true) : null;
if (ArrayHelper::check($item->addrelations))
{
foreach ($item->addrelations as $nr => $relationsValue)
{
// only add if list view field is selected and joined fields are set
if (isset($relationsValue['listfield'])
&& is_numeric(
$relationsValue['listfield']
)
&& $relationsValue['listfield'] > 0
&& isset($relationsValue['area'])
&& is_numeric($relationsValue['area'])
&& $relationsValue['area'] > 0)
{
// do a dynamic update on the set values
if (isset($relationsValue['set'])
&& StringHelper::check(
$relationsValue['set']
))
{
$relationsValue['set'] = $this->customcode->update(
$relationsValue['set']
);
}
// load the field relations
$this->registry->set('builder.field_relations.'
. $item->name_list_code . '.' . (int) $relationsValue['listfield']
. '.' . (int) $relationsValue['area'], $relationsValue);
// load the list joints
if (isset($relationsValue['joinfields'])
&& ArrayHelper::check(
$relationsValue['joinfields']
))
{
foreach ($relationsValue['joinfields'] as $join)
{
$this->registry->set('builder.list_join.' . $item->name_list_code . '.' . (int) $join, (int) $join);
}
}
// set header over-ride
if (isset($relationsValue['column_name'])
&& StringHelper::check(
$relationsValue['column_name']
))
{
$check_column_name = trim(
strtolower((string) $relationsValue['column_name'])
);
// confirm it should really make the over ride
if ('default' !== $check_column_name)
{
$column_name_lang = $this->config->lang_prefix . '_'
. StringHelper::safe(
$item->name_list_code, 'U'
) . '_' . StringHelper::safe(
$relationsValue['column_name'], 'U'
);
$this->language->set(
'admin', $column_name_lang,
$relationsValue['column_name']
);
$this->registry->set('builder.list_head_override.' .
$item->name_list_code . '.' . (int) $relationsValue['listfield'],
$column_name_lang
);
}
}
}
}
}
unset($item->addrelations);
}
}

View File

@ -0,0 +1,109 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customview\Data as Customview;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
/**
* Model Site Views Class
*
* @since 3.2.0
*/
class Siteviews
{
/**
* Component Site view Data
*
* @var Customview
* @since 3.2.0
**/
protected Customview $site;
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected Config $config;
/**
* Constructor
*
* @param Customview|null $site The site view data object.
* @param Config|null $config The compiler config object.
*
* @since 3.2.0
*/
public function __construct(?Customview $site = null, ?Config $config = null)
{
$this->site = $site ?: Compiler::_('Customview.Data');
$this->config = $config ?: Compiler::_('Config');
}
/**
* Set site view data
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->addsite_views = (isset($item->addsite_views)
&& JsonHelper::check($item->addsite_views))
? json_decode((string) $item->addsite_views, true) : null;
if (ArrayHelper::check($item->addsite_views))
{
$this->config->lang_target = 'site';
$this->config->build_target = 'site';
// build the site_views settings
$item->site_views = array_map(
function ($array) {
// has become a legacy issue, can't remove this
$array['view'] = $array['siteview'];
$array['settings'] = $this->site->get(
$array['view']
);
return array_map(
function ($value) {
if (!ArrayHelper::check($value)
&& !ObjectHelper::check($value)
&& strval($value) === strval(intval($value)))
{
return (int) $value;
}
return $value;
}, $array
);
}, array_values($item->addsite_views)
);
// unset original value
unset($item->addsite_views);
}
}
}

View File

@ -0,0 +1,97 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
use VDM\Joomla\Componentbuilder\Compiler\Model\Sqldump;
/**
* Model Sql Class
*
* @since 3.2.0
*/
class Sql
{
/**
* Compiler Customcode Dispenser
*
* @var Dispenser
* @since 3.2.0
*/
protected Dispenser $dispenser;
/**
* Compiler SQL Dump
*
* @var Sqldump
* @since 3.2.0
*/
protected Sqldump $dump;
/**
* Constructor
*
* @param Dispenser|null $dispenser The compiler customcode dispenser.
* @param Sqldump|null $dump The compiler SQL dump.
*
* @since 3.2.0
*/
public function __construct(?Dispenser $dispenser = null, ?Sqldump $dump = null)
{
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
$this->dump = $dump ?: Compiler::_('Model.Sqldump');
}
/**
* Set sql
*
* @param object $item The item data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
if (isset($item->add_sql) && $item->add_sql == 1 && isset($item->source))
{
if ($item->source == 1 && isset($item->tables) &&
($string = $this->dump->get(
$item->tables, $item->name_single_code, $item->id
)) !== null)
{
// build and add the SQL dump
// we add this directly to avoid
// dynamic set behaviour
// TODO: create a function in dispenser to manage these
$this->dispenser->hub['sql'][$item->name_single_code]
= $string;
}
elseif ($item->source == 2 && isset($item->sql))
{
// add the SQL dump string
$this->dispenser->set(
$item->sql,
'sql',
$item->name_single_code
);
}
}
unset($item->tables);
unset($item->sql);
}
}

View File

@ -0,0 +1,321 @@
<?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\Model;
use Joomla\CMS\Factory;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Utilities\StringHelper;
/**
* SQL Dump Class
*
* @since 3.2.0
*/
class Sqldump
{
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
/**
* Constructor
*
* @param Registry|null $registry The compiler registry object.
* @param \JDatabaseDriver|null $db The database object.
* @since 3.2.0
*/
public function __construct(?Registry $registry = null, ?\JDatabaseDriver $db = null)
{
$this->registry = $registry ?: Compiler::_('Registry');
$this->db = $db ?: Factory::getDbo();
}
/**
* Get SQL Dump
*
* @param array $tables The tables to use in build
* @param string $view The target view/table to dump in
* @param int $view_id The id of the target view
*
* @return string|null The data found with the alias
* @since 3.2.0
*/
public function get(array $tables, string $view, int $view_id): ?string
{
// first build a query statement to get all the data (insure it must be added - check the tweaking)
if (ArrayHelper::check($tables)
&& $this->registry-> // default is to add
get('builder.sql_tweak.' . (int) $view_id . '.add', true))
{
$counter = 'a';
// Create a new query object.
$query = $this->db->getQuery(true);
// switch to only trigger the run of the query if we have tables to query
$run_query = false;
foreach ($tables as $table)
{
if (isset($table['table']))
{
if ($counter === 'a')
{
// the main table fields
if (strpos((string) $table['sourcemap'], PHP_EOL) !== false)
{
$fields = explode(PHP_EOL, (string) $table['sourcemap']);
if (ArrayHelper::check($fields))
{
// reset array buckets
$sourceArray = array();
$targetArray = array();
foreach ($fields as $field)
{
if (strpos($field, "=>") !== false)
{
list($source, $target) = explode(
"=>", $field
);
$sourceArray[] = $counter . '.' . trim(
$source
);
$targetArray[] = trim($target);
}
}
if (ArrayHelper::check(
$sourceArray
)
&& ArrayHelper::check(
$targetArray
))
{
// add to query
$query->select(
$this->db->quoteName(
$sourceArray, $targetArray
)
);
$query->from(
'#__' . $table['table'] . ' AS a'
);
$run_query = true;
}
// we may need to filter the selection
if (($ids_ = $this->registry->
get('builder.sql_tweak.' . (int) $view_id . '.where', null)) !== null)
{
// add to query the where filter
$query->where(
'a.id IN (' . $ids_ . ')'
);
}
}
}
}
else
{
// the other tables
if (strpos((string) $table['sourcemap'], PHP_EOL) !== false)
{
$fields = explode(PHP_EOL, (string) $table['sourcemap']);
if (ArrayHelper::check($fields))
{
// reset array buckets
$sourceArray = array();
$targetArray = array();
foreach ($fields as $field)
{
if (strpos($field, "=>") !== false)
{
list($source, $target) = explode(
"=>", $field
);
$sourceArray[] = $counter . '.' . trim(
$source
);
$targetArray[] = trim($target);
}
if (strpos($field, "==") !== false)
{
list($aKey, $bKey) = explode(
"==", $field
);
// add to query
$query->join(
'LEFT', $this->db->quoteName(
'#__' . $table['table'],
$counter
) . ' ON (' . $this->db->quoteName(
'a.' . trim($aKey)
) . ' = ' . $this->db->quoteName(
$counter . '.' . trim($bKey)
) . ')'
);
}
}
if (ArrayHelper::check(
$sourceArray
)
&& ArrayHelper::check(
$targetArray
))
{
// add to query
$query->select(
$this->db->quoteName(
$sourceArray, $targetArray
)
);
}
}
}
}
$counter++;
}
else
{
// see where
// var_dump($view);
// jexit();
}
}
// check if we should run query
if ($run_query)
{
// now get the data
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// get the data
$data = $this->db->loadObjectList();
// start building the MySql dump
$dump = "--";
$dump .= PHP_EOL . "-- Dumping data for table `#__"
. Placefix::_("component") . "_" . $view
. "`";
$dump .= PHP_EOL . "--";
$dump .= PHP_EOL . PHP_EOL . "INSERT INTO `#__" . Placefix::_("component") . "_" . $view . "` (";
foreach ($data as $line)
{
$comaSet = 0;
foreach ($line as $fieldName => $fieldValue)
{
if ($comaSet == 0)
{
$dump .= $this->db->quoteName($fieldName);
}
else
{
$dump .= ", " . $this->db->quoteName(
$fieldName
);
}
$comaSet++;
}
break;
}
$dump .= ") VALUES";
$coma = 0;
foreach ($data as $line)
{
if ($coma == 0)
{
$dump .= PHP_EOL . "(";
}
else
{
$dump .= "," . PHP_EOL . "(";
}
$comaSet = 0;
foreach ($line as $fieldName => $fieldValue)
{
if ($comaSet == 0)
{
$dump .= $this->escape($fieldValue);
}
else
{
$dump .= ", " . $this->escape(
$fieldValue
);
}
$comaSet++;
}
$dump .= ")";
$coma++;
}
$dump .= ";";
// return build dump query
return $dump;
}
}
}
return null;
}
/**
* Escape the values for a SQL dump
*
* @param string|array $value the value to escape
*
* @return string|array on success with escaped string
* @since 3.2.0
*/
protected function escape($value)
{
// if array then return mapped
if (ArrayHelper::check($value))
{
return array_map(__METHOD__, $value);
}
// if string make sure it is correctly escaped
if (StringHelper::check($value) && !is_numeric($value))
{
return $this->db->quote($value);
}
// if empty value return place holder
if (empty($value))
{
return "''";
}
// if not array or string then return number
return $value;
}
}

View File

@ -0,0 +1,180 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
/**
* Model Sql Tweaking Class
*
* @since 3.2.0
*/
class Sqltweaking
{
/**
* Compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Constructor
*
* @param Registry|null $registry The compiler registry object.
*
* @since 3.2.0
*/
public function __construct(?Registry $registry = null)
{
$this->registry = $registry ?: Compiler::_('Registry');
}
/**
* Set sql tweaking if needed
*
* @param object $item The extension data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
// set the sql_tweak data
$item->sql_tweak = (isset($item->sql_tweak)
&& JsonHelper::check($item->sql_tweak))
? json_decode((string) $item->sql_tweak, true) : null;
if (ArrayHelper::check($item->sql_tweak))
{
// build the tweak settings
$this->tweak(
array_map(
fn($array) => array_map(
function ($value) {
if (!ArrayHelper::check($value)
&& !ObjectHelper::check(
$value
)
&& strval($value) === strval(
intval($value)
))
{
return (int) $value;
}
return $value;
}, $array
), array_values($item->sql_tweak)
)
);
}
unset($item->sql_tweak);
}
/**
* To limit the SQL Demo data build in the views
*
* @param array $settings Tweaking array.
*
* @return void
* @since 3.2.0
*/
protected function tweak($settings)
{
if (ArrayHelper::check($settings))
{
foreach ($settings as $setting)
{
// should sql dump be added
if (1 == $setting['add_sql'])
{
// add sql (by option)
if (2 == $setting['add_sql_options'])
{
// rest always
$id_array = array();
// by id (first remove backups)
$ids = $setting['ids'];
// now get the ids
if (strpos((string) $ids, ',') !== false)
{
$id_array = (array) array_map(
'trim', explode(',', (string) $ids)
);
}
else
{
$id_array[] = trim((string) $ids);
}
$id_array_new = array();
// check for ranges
foreach ($id_array as $key => $id)
{
if (strpos($id, '=>') !== false)
{
$id_range = (array) array_map(
'trim', explode('=>', $id)
);
unset($id_array[$key]);
// build range
if (count((array) $id_range) == 2)
{
$range = range(
$id_range[0], $id_range[1]
);
$id_array_new = [...$id_array_new, ...$range];
}
}
}
if (ArrayHelper::check($id_array_new))
{
$id_array = [...$id_array_new, ...$id_array];
}
// final fixing to array
if (ArrayHelper::check($id_array))
{
// unique
$id_array = array_unique($id_array, SORT_NUMERIC);
// sort
sort($id_array, SORT_NUMERIC);
// now set it to global
$this->registry->
set('builder.sql_tweak.' . (int) $setting['adminview'] . '.where', implode(',', $id_array));
}
}
}
else
{
// do not add sql dump options
$this->registry->
set('builder.sql_tweak.' . (int) $setting['adminview'] . '.add', false);
}
}
}
}
}

View File

@ -0,0 +1,71 @@
<?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\Model;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Model Tabs Class
*
* @since 3.2.0
*/
class Tabs
{
/**
* Set the local tabs
*
* @param object $item The view data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
$item->addtabs = (isset($item->addtabs)
&& JsonHelper::check($item->addtabs))
? json_decode((string) $item->addtabs, true) : null;
if (ArrayHelper::check($item->addtabs))
{
$nr = 1;
foreach ($item->addtabs as $tab)
{
$item->tabs[$nr] = trim((string) $tab['name']);
$nr++;
}
}
// if Details tab is not set, then set it here
if (!isset($item->tabs[1]))
{
$item->tabs[1] = 'Details';
}
// always make sure that publishing is lowercase
if (($removeKey = array_search(
'publishing', array_map('strtolower', $item->tabs)
)) !== false)
{
$item->tabs[$removeKey] = 'publishing';
}
// make sure to set the publishing tab (just in case we need it)
$item->tabs[15] = 'publishing';
unset($item->addtabs);
}
}

View File

@ -0,0 +1,259 @@
<?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\Model;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
/**
* Model Update sql Class
*
* @since 3.2.0
*/
class Updatesql
{
/**
* The admin view names
*
* @var array
* @since 3.2.0
*/
protected array $name = [];
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Constructor
*
* @param Registry|null $registry The compiler registry object.
*
* @since 3.2.0
*/
public function __construct(?Registry $registry = null)
{
$this->registry = $registry ?: Compiler::_('Registry');
}
/**
* check if an update SQL is needed
*
* @param mixed $old The old values
* @param mixed $new The new values
* @param string $type The type of values
* @param int|null $key The id/key where values changed
* @param array|null $ignore The ids to ignore
*
* @return void
* @since 3.2.0
*/
public function set($old, $new, string $type, ?int $key = null, ?array $ignore = null)
{
// check if there were new items added
if (ArrayHelper::check($new) && ArrayHelper::check($old))
{
// check if this is old repeatable field
if (isset($new[$type]))
{
foreach ($new[$type] as $item)
{
$newItem = true;
// check if this is an id to ignore
if (ArrayHelper::check($ignore)
&& in_array(
$item, $ignore
))
{
// don't add ignored ids
$newItem = false;
}
// check if this is old repeatable field
elseif (isset($old[$type])
&& ArrayHelper::check($old[$type]))
{
if (!in_array($item, $old[$type]))
{
// we have a new item, lets add to SQL
$this->add($type, $item, $key);
}
// add only once
$newItem = false;
}
elseif (!isset($old[$type]))
{
// we have new values
foreach ($old as $oldItem)
{
if (isset($oldItem[$type]))
{
if ($oldItem[$type] == $item[$type])
{
$newItem = false;
break;
}
}
else
{
$newItem = false;
break;
}
}
}
else
{
$newItem = false;
}
// add if new
if ($newItem)
{
// we have a new item, lets add to SQL
$this->add($type, $item[$type], $key);
}
}
}
else
{
foreach ($new as $item)
{
if (isset($item[$type]))
{
// search to see if this is a new value
$newItem = true;
// check if this is an id to ignore
if (ArrayHelper::check($ignore)
&& in_array($item[$type], $ignore))
{
// don't add ignored ids
$newItem = false;
}
// check if this is old repeatable field
elseif (isset($old[$type])
&& ArrayHelper::check($old[$type]))
{
if (in_array($item[$type], $old[$type]))
{
$newItem = false;
}
}
elseif (!isset($old[$type]))
{
// we have new values
foreach ($old as $oldItem)
{
if (isset($oldItem[$type]))
{
if ($oldItem[$type] == $item[$type])
{
$newItem = false;
break;
}
}
else
{
$newItem = false;
break;
}
}
}
else
{
$newItem = false;
}
// add if new
if ($newItem)
{
// we have a new item, lets add to SQL
$this->add($type, $item[$type], $key);
}
}
}
}
}
elseif ($key && ((StringHelper::check($new) && StringHelper::check($old))
|| (is_numeric($new) && is_numeric($old))) && $new !== $old)
{
// set at key
$this->registry->set('builder.update_sql.' . $type . '.' . $key, ['old' => $old, 'new' => $new]);
}
}
/**
* Set the add sql
*
* @param string $type The type of values
* @param int $item The item id to add
* @param int|null $key The id/key where values changed
*
* @return void
* @since 3.2.0
*/
protected function add(string $type, int $item, ?int $key = null)
{
// add key if found
if ($key)
{
$this->registry->set('builder.add_sql.' . $type . '.' . $key . '.' . $item, $item);
}
else
{
// convert admin view id to name
if ('adminview' === $type)
{
$this->registry->set('builder.add_sql.' . $type,
$this->name($item)
);
}
else
{
$this->registry->set('builder.add_sql.' . $type, $item);
}
}
}
/**
* Get the Admin view table name
*
* @param int $id The item id to add
*
* @return string the admin view code name
* @since 3.2.0
*/
protected function name(int $id): string
{
// get name if not set
if (!isset($this->name[$id]))
{
$this->name[$id] = StringHelper::safe(
GetHelper::var('admin_view', $id, 'id', 'name_single')
);
}
return $this->name[$id] ?? 'error';
}
}

View File

@ -0,0 +1,72 @@
<?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\Model;
use VDM\Joomla\Utilities\StringHelper;
/**
* Model Whmcs Class
*
* @since 3.2.0
*/
class Whmcs
{
/**
* Set whmcs links if needed
*
* @param object $item The extension data
*
* @return void
* @since 3.2.0
*/
public function set(object &$item)
{
if (1 == $item->add_license
&& (!isset($item->whmcs_buy_link)
|| !StringHelper::check(
$item->whmcs_buy_link
)))
{
// update with the whmcs url
if (isset($item->whmcs_url)
&& StringHelper::check($item->whmcs_url))
{
$item->whmcs_buy_link = $item->whmcs_url;
}
// use the company website
elseif (isset($item->website)
&& StringHelper::check($item->website))
{
$item->whmcs_buy_link = $item->website;
$item->whmcs_url = rtrim((string) $item->website, '/')
. '/whmcs';
}
// none set
else
{
$item->whmcs_buy_link = '#';
$item->whmcs_url = '#';
}
}
// since the license details are not set clear
elseif (0 == $item->add_license)
{
$item->whmcs_key = '';
$item->whmcs_buy_link = '';
$item->whmcs_url = '';
}
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -347,9 +347,7 @@ class Placeholder implements PlaceholderInterface
{ {
$this->active = array_filter( $this->active = array_filter(
$this->active, $this->active,
function (string $k) use ($_key) { fn(string $k) => preg_replace('/\d/', '', $k) !== $_key,
return preg_replace('/\d/', '', $k) !== $_key;
},
ARRAY_FILTER_USE_KEY ARRAY_FILTER_USE_KEY
); );
} }

View File

@ -125,9 +125,7 @@ class Reverse
// get targets to search for // get targets to search for
$lang_string_targets = array_filter( $lang_string_targets = array_filter(
$this->config->lang_string_targets, $this->config->lang_string_targets,
function ($get) use ($string) : bool { fn($get): bool => strpos($string, (string) $get) !== false
return strpos($string, $get) !== false;
}
); );
// check if we should continue // check if we should continue
if (ArrayHelper::check($lang_string_targets)) if (ArrayHelper::check($lang_string_targets))

View File

@ -455,7 +455,7 @@ class Power implements PowerInterface
$this->active[$guid]->file_name = array_pop($src_array); $this->active[$guid]->file_name = array_pop($src_array);
// namespace array // namespace array
$namespace_array = array_merge($path_array, $src_array); $namespace_array = [...$path_array, ...$src_array];
} }
else else
{ {
@ -483,12 +483,16 @@ class Power implements PowerInterface
} }
// make sure the arrays are namespace safe // make sure the arrays are namespace safe
$path_array = array_map(function ($val) { $path_array =
return $this->getCleanNamespace($val); array_map(
}, $path_array); fn($val) => $this->getCleanNamespace($val),
$namespace_array = array_map(function ($val) { $path_array
return $this->getCleanNamespace($val); );
}, $namespace_array); $namespace_array =
array_map(
fn($val) => $this->getCleanNamespace($val),
$namespace_array
);
// set the actual class namespace // set the actual class namespace
$this->active[$guid]->_namespace = implode('\\', $namespace_array); $this->active[$guid]->_namespace = implode('\\', $namespace_array);
@ -504,9 +508,12 @@ class Power implements PowerInterface
if (ArrayHelper::check($src_array)) if (ArrayHelper::check($src_array))
{ {
// make sure the arrays are namespace safe // make sure the arrays are namespace safe
$sub_folder = '/' . implode('/', array_map(function ($val) { $sub_folder = '/' . implode('/',
return $this->getCleanNamespace($val); array_map(
}, $src_array)); fn($val) => $this->getCleanNamespace($val),
$src_array
)
);
} }
// now we set the paths // now we set the paths
@ -565,10 +572,11 @@ class Power implements PowerInterface
if ($this->active[$guid]->load_selection) if ($this->active[$guid]->load_selection)
{ {
// load use ids // load use ids
array_map(function ($power) { array_map(
// just load it directly and be done with it // just load it directly and be done with it
return $this->set($power['load']); fn($power) => $this->set($power['load']),
}, $this->active[$guid]->load_selection); $this->active[$guid]->load_selection
);
} }
} }

View File

@ -131,9 +131,7 @@ class Autoloader
// NameSpace\SubName\SubSubName\ClassName // NameSpace\SubName\SubSubName\ClassName
// ^^^^^^^^^^^^^^^^^^^^^ // ^^^^^^^^^^^^^^^^^^^^^
uksort($this->power->namespace, function ($a, $b) { uksort($this->power->namespace, fn($a, $b) => strlen((string) $b) - strlen((string) $a));
return strlen($b) - strlen($a);
});
// counter to manage the comma in the actual array // counter to manage the comma in the actual array
$counter = 1; $counter = 1;

View File

@ -0,0 +1,78 @@
<?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\Adminview\Data as AdminviewData;
/**
* Compiler Adminview
*
* @since 3.2.0
*/
class Adminview 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(AdminviewData::class, 'Adminview.Data')
->share('Adminview.Data', [$this, 'getAdminviewData'], true);
}
/**
* Get the Compiler Adminview Data
*
* @param Container $container The DI container.
*
* @return AdminviewData
* @since 3.2.0
*/
public function getAdminviewData(Container $container): AdminviewData
{
return new AdminviewData(
$container->get('Config'),
$container->get('Registry'),
$container->get('Event'),
$container->get('Placeholder'),
$container->get('Customcode.Dispenser'),
$container->get('Model.Customtabs'),
$container->get('Model.Tabs'),
$container->get('Model.Fields'),
$container->get('Model.Historyadminview'),
$container->get('Model.Permissions'),
$container->get('Model.Conditions'),
$container->get('Model.Relations'),
$container->get('Model.Linkedviews'),
$container->get('Model.Javascriptadminview'),
$container->get('Model.Cssadminview'),
$container->get('Model.Phpadminview'),
$container->get('Model.Custombuttons'),
$container->get('Model.Customimportscripts'),
$container->get('Model.Ajaxadmin'),
$container->get('Model.Customalias'),
$container->get('Model.Sql'),
$container->get('Model.Mysqlsettings')
);
}
}

View File

@ -16,6 +16,7 @@ use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface; use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Config; use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Registry; use VDM\Joomla\Componentbuilder\Compiler\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Counter;
/** /**
@ -40,6 +41,9 @@ class Compiler implements ServiceProviderInterface
$container->alias(Registry::class, 'Registry') $container->alias(Registry::class, 'Registry')
->share('Registry', [$this, 'getRegistry'], true); ->share('Registry', [$this, 'getRegistry'], true);
$container->alias(Counter::class, 'Counter')
->share('Counter', [$this, 'getCounter'], true);
} }
/** /**
@ -67,6 +71,19 @@ class Compiler implements ServiceProviderInterface
{ {
return new Registry(); 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();
}
} }

View File

@ -14,7 +14,9 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service;
use Joomla\DI\Container; use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface; use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Component as ComponentObject;
use VDM\Joomla\Componentbuilder\Compiler\Component\Placeholder as ComponentPlaceholder; use VDM\Joomla\Componentbuilder\Compiler\Component\Placeholder as ComponentPlaceholder;
use VDM\Joomla\Componentbuilder\Compiler\Component\Data as ComponentData;
/** /**
@ -34,8 +36,29 @@ class Component implements ServiceProviderInterface
*/ */
public function register(Container $container) public function register(Container $container)
{ {
$container->alias(ComponentObject::class, 'Component')
->share('Component', [$this, 'getComponent'], true);
$container->alias(ComponentPlaceholder::class, 'Component.Placeholder') $container->alias(ComponentPlaceholder::class, 'Component.Placeholder')
->share('Component.Placeholder', [$this, 'getComponentPlaceholder'], true); ->share('Component.Placeholder', [$this, 'getComponentPlaceholder'], true);
$container->alias(ComponentData::class, 'Component.Data')
->share('Component.Data', [$this, 'getComponentData'], true);
}
/**
* Get the Component
*
* @param Container $container The DI container.
*
* @return ComponentObject
* @since 3.2.0
*/
public function getComponent(Container $container): ComponentObject
{
return new ComponentObject(
$container->get('Component.Data')
);
} }
/** /**
@ -51,6 +74,39 @@ class Component implements ServiceProviderInterface
return new ComponentPlaceholder( return new ComponentPlaceholder(
$container->get('Config') $container->get('Config')
); );
}
/**
* Get the Component Data
*
* @param Container $container The DI container.
*
* @return ComponentData
* @since 3.2.0
*/
public function getComponentData(Container $container): ComponentData
{
return new ComponentData(
$container->get('Config'),
$container->get('Event'),
$container->get('Placeholder'),
$container->get('Component.Placeholder'),
$container->get('Customcode.Dispenser'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Field'),
$container->get('Field.Name'),
$container->get('Field.Unique.Name'),
$container->get('Model.Filesfolders'),
$container->get('Model.Historycomponent'),
$container->get('Model.Whmcs'),
$container->get('Model.Sqltweaking'),
$container->get('Model.Adminviews'),
$container->get('Model.Siteviews'),
$container->get('Model.Customadminviews'),
$container->get('Model.Joomlamodules'),
$container->get('Model.Joomlaplugins')
);
} }
} }

View File

@ -0,0 +1,114 @@
<?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\Customview\Data as CustomviewData;
use VDM\Joomla\Componentbuilder\Compiler\Dynamicget\Data as DynamicgetData;
use VDM\Joomla\Componentbuilder\Compiler\Dynamicget\Selection as DynamicgetSelection;
/**
* Compiler Customview
*
* @since 3.2.0
*/
class Customview 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(CustomviewData::class, 'Customview.Data')
->share('Customview.Data', [$this, 'getCustomviewData'], true);
$container->alias(DynamicgetData::class, 'Dynamicget.Data')
->share('Dynamicget.Data', [$this, 'getDynamicgetData'], true);
$container->alias(DynamicgetSelection::class, 'Dynamicget.Selection')
->share('Dynamicget.Selection', [$this, 'getDynamicgetSelection'], true);
}
/**
* Get the Compiler Customview Data
*
* @param Container $container The DI container.
*
* @return CustomviewData
* @since 3.2.0
*/
public function getCustomviewData(Container $container): CustomviewData
{
return new CustomviewData(
$container->get('Config'),
$container->get('Event'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Model.Libraries'),
$container->get('Templatelayout.Data'),
$container->get('Dynamicget.Data'),
$container->get('Model.Loader'),
$container->get('Model.Javascriptcustomview'),
$container->get('Model.Csscustomview'),
$container->get('Model.Phpcustomview'),
$container->get('Model.Ajaxcustomview'),
$container->get('Model.Custombuttons')
);
}
/**
* Get the Compiler Dynamicget Data
*
* @param Container $container The DI container.
*
* @return DynamicgetData
* @since 3.2.0
*/
public function getDynamicgetData(Container $container): DynamicgetData
{
return new DynamicgetData(
$container->get('Config'),
$container->get('Registry'),
$container->get('Event'),
$container->get('Customcode'),
$container->get('Customcode.Dispenser'),
$container->get('Customcode.Gui'),
$container->get('Model.Dynamicget')
);
}
/**
* Get the Compiler Dynamicget Selection
*
* @param Container $container The DI container.
*
* @return DynamicgetSelection
* @since 3.2.0
*/
public function getDynamicgetSelection(Container $container): DynamicgetSelection
{
return new DynamicgetSelection(
$container->get('Config'),
$container->get('Registry')
);
}
}

View File

@ -0,0 +1,66 @@
<?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\Joomlamodule\Data as JoomlaModuleData;
/**
* Joomla Module Service Provider
*
* @since 3.2.0
*/
class Joomlamodule 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(JoomlaModuleData::class, 'Joomlamodule.Data')
->share('Joomlamodule.Data', [$this, 'getJoomlaModuleData'], true);
}
/**
* Get the Joomla Module Data
*
* @param Container $container The DI container.
*
* @return JoomlaModuleData
* @since 3.2.0
*/
public function getJoomlaModuleData(Container $container): JoomlaModuleData
{
return new JoomlaModuleData(
$container->get('Config'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Placeholder'),
$container->get('Language'),
$container->get('Field'),
$container->get('Field.Name'),
$container->get('Model.Filesfolders'),
$container->get('Model.Libraries'),
$container->get('Dynamicget.Data')
);
}
}

View File

@ -0,0 +1,64 @@
<?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\Joomlaplugin\Data as JoomlaPluginData;
/**
* Joomla Plugin Service Provider
*
* @since 3.2.0
*/
class Joomlaplugin 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(JoomlaPluginData::class, 'Joomlaplugin.Data')
->share('Joomlaplugin.Data', [$this, 'getJoomlaPluginData'], true);
}
/**
* Get the Joomla Plugin Data
*
* @param Container $container The DI container.
*
* @return JoomlaPluginData
* @since 3.2.0
*/
public function getJoomlaPluginData(Container $container): JoomlaPluginData
{
return new JoomlaPluginData(
$container->get('Config'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Placeholder'),
$container->get('Language'),
$container->get('Field'),
$container->get('Field.Name'),
$container->get('Model.Filesfolders')
);
}
}

View File

@ -0,0 +1,62 @@
<?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\Library\Data as LibraryData;
/**
* Compiler Library
*
* @since 3.2.0
*/
class Library 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(LibraryData::class, 'Library.Data')
->share('Library.Data', [$this, 'getLibraryData'], true);
}
/**
* Get the Compiler Library Data
*
* @param Container $container The DI container.
*
* @return LibraryData
* @since 3.2.0
*/
public function getLibraryData(Container $container): LibraryData
{
return new LibraryData(
$container->get('Config'),
$container->get('Registry'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Field.Data'),
$container->get('Model.Filesfolders')
);
}
}

View File

@ -15,6 +15,41 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service;
use Joomla\DI\Container; use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface; use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Server\Model\Load as ServerLoad; use VDM\Joomla\Componentbuilder\Server\Model\Load as ServerLoad;
use VDM\Joomla\Componentbuilder\Compiler\Model\Joomlaplugins;
use VDM\Joomla\Componentbuilder\Compiler\Model\Joomlamodules;
use VDM\Joomla\Componentbuilder\Compiler\Model\Historycomponent;
use VDM\Joomla\Componentbuilder\Compiler\Model\Customadminviews;
use VDM\Joomla\Componentbuilder\Compiler\Model\Ajaxcustomview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Javascriptcustomview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Csscustomview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Phpcustomview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Dynamicget;
use VDM\Joomla\Componentbuilder\Compiler\Model\Libraries;
use VDM\Joomla\Componentbuilder\Compiler\Model\Siteviews;
use VDM\Joomla\Componentbuilder\Compiler\Model\Permissions;
use VDM\Joomla\Componentbuilder\Compiler\Model\Historyadminview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Mysqlsettings;
use VDM\Joomla\Componentbuilder\Compiler\Model\Sql;
use VDM\Joomla\Componentbuilder\Compiler\Model\Customalias;
use VDM\Joomla\Componentbuilder\Compiler\Model\Ajaxadmin;
use VDM\Joomla\Componentbuilder\Compiler\Model\Customimportscripts;
use VDM\Joomla\Componentbuilder\Compiler\Model\Custombuttons;
use VDM\Joomla\Componentbuilder\Compiler\Model\Loader;
use VDM\Joomla\Componentbuilder\Compiler\Model\Phpadminview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Cssadminview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Javascriptadminview;
use VDM\Joomla\Componentbuilder\Compiler\Model\Linkedviews;
use VDM\Joomla\Componentbuilder\Compiler\Model\Relations;
use VDM\Joomla\Componentbuilder\Compiler\Model\Conditions;
use VDM\Joomla\Componentbuilder\Compiler\Model\Fields;
use VDM\Joomla\Componentbuilder\Compiler\Model\Updatesql;
use VDM\Joomla\Componentbuilder\Compiler\Model\Tabs;
use VDM\Joomla\Componentbuilder\Compiler\Model\Customtabs;
use VDM\Joomla\Componentbuilder\Compiler\Model\Adminviews;
use VDM\Joomla\Componentbuilder\Compiler\Model\Sqltweaking;
use VDM\Joomla\Componentbuilder\Compiler\Model\Sqldump;
use VDM\Joomla\Componentbuilder\Compiler\Model\Whmcs;
use VDM\Joomla\Componentbuilder\Compiler\Model\Filesfolders;
/** /**
@ -34,10 +69,674 @@ class Model implements ServiceProviderInterface
*/ */
public function register(Container $container) public function register(Container $container)
{ {
$container->alias(Joomlaplugins::class, 'Model.Joomlaplugins')
->share('Model.Joomlaplugins', [$this, 'getModelJoomlaplugins'], true);
$container->alias(Joomlamodules::class, 'Model.Joomlamodules')
->share('Model.Joomlamodules', [$this, 'getModelJoomlamodules'], true);
$container->alias(Historycomponent::class, 'Model.Historycomponent')
->share('Model.Historycomponent', [$this, 'getModelHistorycomponent'], true);
$container->alias(Customadminviews::class, 'Model.Customadminviews')
->share('Model.Customadminviews', [$this, 'getModelCustomadminviews'], true);
$container->alias(Ajaxcustomview::class, 'Model.Ajaxcustomview')
->share('Model.Ajaxcustomview', [$this, 'getModelAjaxcustomview'], true);
$container->alias(Javascriptcustomview::class, 'Model.Javascriptcustomview')
->share('Model.Javascriptcustomview', [$this, 'getModelJavascriptcustomview'], true);
$container->alias(Csscustomview::class, 'Model.Csscustomview')
->share('Model.Csscustomview', [$this, 'getModelCsscustomview'], true);
$container->alias(Phpcustomview::class, 'Model.Phpcustomview')
->share('Model.Phpcustomview', [$this, 'getModelPhpcustomview'], true);
$container->alias(Dynamicget::class, 'Model.Dynamicget')
->share('Model.Dynamicget', [$this, 'getModelDynamicget'], true);
$container->alias(Libraries::class, 'Model.Libraries')
->share('Model.Libraries', [$this, 'getModelLibraries'], true);
$container->alias(Siteviews::class, 'Model.Siteviews')
->share('Model.Siteviews', [$this, 'getModelSiteviews'], true);
$container->alias(Permissions::class, 'Model.Permissions')
->share('Model.Permissions', [$this, 'getModelPermissions'], true);
$container->alias(Historyadminview::class, 'Model.Historyadminview')
->share('Model.Historyadminview', [$this, 'getModelHistoryadminview'], true);
$container->alias(Mysqlsettings::class, 'Model.Mysqlsettings')
->share('Model.Mysqlsettings', [$this, 'getModelMysqlsettings'], true);
$container->alias(Sql::class, 'Model.Sql')
->share('Model.Sql', [$this, 'getModelSql'], true);
$container->alias(Customalias::class, 'Model.Customalias')
->share('Model.Customalias', [$this, 'getModelCustomalias'], true);
$container->alias(Ajaxadmin::class, 'Model.Ajaxadmin')
->share('Model.Ajaxadmin', [$this, 'getModelAjaxadmin'], true);
$container->alias(Customimportscripts::class, 'Model.Customimportscripts')
->share('Model.Customimportscripts', [$this, 'getModelCustomimportscripts'], true);
$container->alias(Custombuttons::class, 'Model.Custombuttons')
->share('Model.Custombuttons', [$this, 'getModelCustombuttons'], true);
$container->alias(Loader::class, 'Model.Loader')
->share('Model.Loader', [$this, 'getModelLoader'], true);
$container->alias(Phpadminview::class, 'Model.Phpadminview')
->share('Model.Phpadminview', [$this, 'getModelPhpadminview'], true);
$container->alias(Cssadminview::class, 'Model.Cssadminview')
->share('Model.Cssadminview', [$this, 'getModelCssadminview'], true);
$container->alias(Javascriptadminview::class, 'Model.Javascriptadminview')
->share('Model.Javascriptadminview', [$this, 'getModelJavascriptadminview'], true);
$container->alias(Linkedviews::class, 'Model.Linkedviews')
->share('Model.Linkedviews', [$this, 'getModelLinkedviews'], true);
$container->alias(Relations::class, 'Model.Relations')
->share('Model.Relations', [$this, 'getModelRelations'], true);
$container->alias(Conditions::class, 'Model.Conditions')
->share('Model.Conditions', [$this, 'getModelConditions'], true);
$container->alias(Fields::class, 'Model.Fields')
->share('Model.Fields', [$this, 'getModelFields'], true);
$container->alias(Updatesql::class, 'Model.Updatesql')
->share('Model.Updatesql', [$this, 'getModelUpdatesql'], true);
$container->alias(Tabs::class, 'Model.Tabs')
->share('Model.Tabs', [$this, 'getModelTabs'], true);
$container->alias(Customtabs::class, 'Model.Customtabs')
->share('Model.Customtabs', [$this, 'getModelCustomtabs'], true);
$container->alias(Adminviews::class, 'Model.Adminviews')
->share('Model.Adminviews', [$this, 'getModelAdminviews'], true);
$container->alias(Sqltweaking::class, 'Model.Sqltweaking')
->share('Model.Sqltweaking', [$this, 'getModelSqltweaking'], true);
$container->alias(Sqldump::class, 'Model.Sqldump')
->share('Model.Sqldump', [$this, 'getModelSqldump'], true);
$container->alias(Whmcs::class, 'Model.Whmcs')
->share('Model.Whmcs', [$this, 'getModelWhmcs'], true);
$container->alias(Filesfolders::class, 'Model.Filesfolders')
->share('Model.Filesfolders', [$this, 'getModelFilesfolders'], true);
$container->alias(ServerLoad::class, 'Model.Server.Load') $container->alias(ServerLoad::class, 'Model.Server.Load')
->share('Model.Server.Load', [$this, 'getServerLoad'], true); ->share('Model.Server.Load', [$this, 'getServerLoad'], true);
} }
/**
* Get the Joomla plugins Model
*
* @param Container $container The DI container.
*
* @return Joomlaplugins
* @since 3.2.0
*/
public function getModelJoomlaplugins(Container $container): Joomlaplugins
{
return new Joomlaplugins(
$container->get('Joomlaplugin.Data')
);
}
/**
* Get the Joomla modules Model
*
* @param Container $container The DI container.
*
* @return Joomlamodules
* @since 3.2.0
*/
public function getModelJoomlamodules(Container $container): Joomlamodules
{
return new Joomlamodules(
$container->get('Joomlamodule.Data')
);
}
/**
* Get the history component Model
*
* @param Container $container The DI container.
*
* @return Historycomponent
* @since 3.2.0
*/
public function getModelHistorycomponent(Container $container): Historycomponent
{
return new Historycomponent(
$container->get('Config'),
$container->get('History'),
$container->get('Model.Updatesql')
);
}
/**
* Get the custom admin views Model
*
* @param Container $container The DI container.
*
* @return Customadminviews
* @since 3.2.0
*/
public function getModelCustomadminviews(Container $container): Customadminviews
{
return new Customadminviews(
$container->get('Customview.Data'),
$container->get('Config')
);
}
/**
* Get the ajax custom view Model
*
* @param Container $container The DI container.
*
* @return Ajaxcustomview
* @since 3.2.0
*/
public function getModelAjaxcustomview(Container $container): Ajaxcustomview
{
return new Ajaxcustomview(
$container->get('Config'),
$container->get('Customcode.Dispenser')
);
}
/**
* Get the javascript custom view Model
*
* @param Container $container The DI container.
*
* @return Javascriptcustomview
* @since 3.2.0
*/
public function getModelJavascriptcustomview(Container $container): Javascriptcustomview
{
return new Javascriptcustomview(
$container->get('Customcode'),
$container->get('Customcode.Gui')
);
}
/**
* Get the css custom view Model
*
* @param Container $container The DI container.
*
* @return Csscustomview
* @since 3.2.0
*/
public function getModelCsscustomview(Container $container): Csscustomview
{
return new Csscustomview(
$container->get('Customcode')
);
}
/**
* Get the php custom view Model
*
* @param Container $container The DI container.
*
* @return Phpcustomview
* @since 3.2.0
*/
public function getModelPhpcustomview(Container $container): Phpcustomview
{
return new Phpcustomview(
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Model.Loader'),
$container->get('Templatelayout.Data')
);
}
/**
* Get the dynamic get Model
*
* @param Container $container The DI container.
*
* @return Dynamicget
* @since 3.2.0
*/
public function getModelDynamicget(Container $container): Dynamicget
{
return new Dynamicget(
$container->get('Config'),
$container->get('Registry'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Placeholder'),
$container->get('Dynamicget.Selection')
);
}
/**
* Get the libraries Model
*
* @param Container $container The DI container.
*
* @return Libraries
* @since 3.2.0
*/
public function getModelLibraries(Container $container): Libraries
{
return new Libraries(
$container->get('Config'),
$container->get('Registry'),
$container->get('Library.Data')
);
}
/**
* Get the site views Model
*
* @param Container $container The DI container.
*
* @return Siteviews
* @since 3.2.0
*/
public function getModelSiteviews(Container $container): Siteviews
{
return new Siteviews(
$container->get('Customview.Data'),
$container->get('Config')
);
}
/**
* Get the permissions Model
*
* @param Container $container The DI container.
*
* @return Permissions
* @since 3.2.0
*/
public function getModelPermissions(Container $container): Permissions
{
return new Permissions();
}
/**
* Get the admin view history Model
*
* @param Container $container The DI container.
*
* @return Historyadminview
* @since 3.2.0
*/
public function getModelHistoryadminview(Container $container): Historyadminview
{
return new Historyadminview(
$container->get('Config'),
$container->get('History'),
$container->get('Model.Updatesql')
);
}
/**
* Get the MySQL settings Model
*
* @param Container $container The DI container.
*
* @return Mysqlsettings
* @since 3.2.0
*/
public function getModelMysqlsettings(Container $container): Mysqlsettings
{
return new Mysqlsettings(
$container->get('Config'),
$container->get('Registry')
);
}
/**
* Get the Sql Model
*
* @param Container $container The DI container.
*
* @return Sql
* @since 3.2.0
*/
public function getModelSql(Container $container): Sql
{
return new Sql(
$container->get('Customcode.Dispenser'),
$container->get('Model.Sqldump')
);
}
/**
* Get the custom alias Model
*
* @param Container $container The DI container.
*
* @return Customalias
* @since 3.2.0
*/
public function getModelCustomalias(Container $container): Customalias
{
return new Customalias(
$container->get('Config'),
$container->get('Field.Name')
);
}
/**
* Get the Admin Ajax Model
*
* @param Container $container The DI container.
*
* @return Ajaxadmin
* @since 3.2.0
*/
public function getModelAjaxadmin(Container $container): Ajaxadmin
{
return new Ajaxadmin(
$container->get('Config'),
$container->get('Registry'),
$container->get('Customcode.Dispenser')
);
}
/**
* Get the custom import scripts Model
*
* @param Container $container The DI container.
*
* @return Customimportscripts
* @since 3.2.0
*/
public function getModelCustomimportscripts(Container $container): Customimportscripts
{
return new Customimportscripts(
$container->get('Customcode.Dispenser')
);
}
/**
* Get the custom import scripts Model
*
* @param Container $container The DI container.
*
* @return Custombuttons
* @since 3.2.0
*/
public function getModelCustombuttons(Container $container): Custombuttons
{
return new Custombuttons(
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Templatelayout.Data')
);
}
/**
* Get the Model Auto Loader
*
* @param Container $container The DI container.
*
* @return Loader
* @since 3.2.0
*/
public function getModelLoader(Container $container): Loader
{
return new Loader(
$container->get('Config'),
$container->get('Registry')
);
}
/**
* Get the php admin view Model
*
* @param Container $container The DI container.
*
* @return Phpadminview
* @since 3.2.0
*/
public function getModelPhpadminview(Container $container): Phpadminview
{
return new Phpadminview(
$container->get('Customcode.Dispenser'),
$container->get('Templatelayout.Data')
);
}
/**
* Get the Css Adminview Model
*
* @param Container $container The DI container.
*
* @return Cssadminview
* @since 3.2.0
*/
public function getModelCssadminview(Container $container): Cssadminview
{
return new Cssadminview(
$container->get('Customcode.Dispenser')
);
}
/**
* Get the Javascript Adminview Model
*
* @param Container $container The DI container.
*
* @return Javascriptadminview
* @since 3.2.0
*/
public function getModelJavascriptadminview(Container $container): Javascriptadminview
{
return new Javascriptadminview(
$container->get('Customcode.Dispenser')
);
}
/**
* Get the linked views Model
*
* @param Container $container The DI container.
*
* @return Linkedviews
* @since 3.2.0
*/
public function getModelLinkedviews(Container $container): Linkedviews
{
return new Linkedviews(
$container->get('Registry')
);
}
/**
* Get the relations Model
*
* @param Container $container The DI container.
*
* @return Relations
* @since 3.2.0
*/
public function getModelRelations(Container $container): Relations
{
return new Relations(
$container->get('Config'),
$container->get('Registry'),
$container->get('Language'),
$container->get('Customcode')
);
}
/**
* Get the conditions Model
*
* @param Container $container The DI container.
*
* @return Conditions
* @since 3.2.0
*/
public function getModelConditions(Container $container): Conditions
{
return new Conditions(
$container->get('Field.Type.Name'),
$container->get('Field.Name')
);
}
/**
* Get the fields Model
*
* @param Container $container The DI container.
*
* @return Fields
* @since 3.2.0
*/
public function getModelFields(Container $container): Fields
{
return new Fields(
$container->get('Config'),
$container->get('Registry'),
$container->get('History'),
$container->get('Customcode'),
$container->get('Field'),
$container->get('Field.Name'),
$container->get('Model.Updatesql')
);
}
/**
* Get the update sql Model
*
* @param Container $container The DI container.
*
* @return Updatesql
* @since 3.2.0
*/
public function getModelUpdatesql(Container $container): Updatesql
{
return new Updatesql(
$container->get('Registry')
);
}
/**
* Get the tabs Model
*
* @param Container $container The DI container.
*
* @return Updatesql
* @since 3.2.0
*/
public function getModelTabs(Container $container): Tabs
{
return new Tabs();
}
/**
* Get the custom tabs Model
*
* @param Container $container The DI container.
*
* @return Customtabs
* @since 3.2.0
*/
public function getModelCustomtabs(Container $container): Customtabs
{
return new Customtabs(
$container->get('Config'),
$container->get('Registry'),
$container->get('Language'),
$container->get('Placeholder'),
$container->get('Customcode')
);
}
/**
* Get the admin views Model
*
* @param Container $container The DI container.
*
* @return Adminviews
* @since 3.2.0
*/
public function getModelAdminviews(Container $container): Adminviews
{
return new Adminviews(
$container->get('Adminview.Data'),
$container->get('Registry'),
$container->get('Config')
);
}
/**
* Get the SQL tweaking Model
*
* @param Container $container The DI container.
*
* @return Sqltweaking
* @since 3.2.0
*/
public function getModelSqltweaking(Container $container): Sqltweaking
{
return new Sqltweaking(
$container->get('Registry')
);
}
/**
* Get the SQL dump Model
*
* @param Container $container The DI container.
*
* @return Sqldump
* @since 3.2.0
*/
public function getModelSqldump(Container $container): Sqldump
{
return new Sqldump(
$container->get('Registry')
);
}
/**
* Get the whmcs Model
*
* @param Container $container The DI container.
*
* @return Whmcs
* @since 3.2.0
*/
public function getModelWhmcs(Container $container): Whmcs
{
return new Whmcs();
}
/**
* Get the files folders Model
*
* @param Container $container The DI container.
*
* @return Filesfolders
* @since 3.2.0
*/
public function getModelFilesfolders(Container $container): Filesfolders
{
return new Filesfolders();
}
/** /**
* Get the Server Model Server Loader class * Get the Server Model Server Loader class
* *

View File

@ -0,0 +1,83 @@
<?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\Templatelayout\Data as TemplatelayoutData ;
use VDM\Joomla\Componentbuilder\Compiler\Alias\Data as AliasData;
/**
* Compiler Templatelayout
*
* @since 3.2.0
*/
class Templatelayout 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(TemplatelayoutData::class, 'Templatelayout.Data')
->share('Templatelayout.Data', [$this, 'getTemplatelayoutData'], true);
$container->alias(AliasData::class, 'Alias.Data')
->share('Alias.Data', [$this, 'getAliasData'], true);
}
/**
* Get the Compiler Templatelayout Data
*
* @param Container $container The DI container.
*
* @return TemplatelayoutData
* @since 3.2.0
*/
public function getTemplatelayoutData(Container $container): TemplatelayoutData
{
return new TemplatelayoutData(
$container->get('Config'),
$container->get('Registry'),
$container->get('Alias.Data')
);
}
/**
* Get the Compiler Alias Data
*
* @param Container $container The DI container.
*
* @return AliasData
* @since 3.2.0
*/
public function getAliasData(Container $container): AliasData
{
return new AliasData(
$container->get('Config'),
$container->get('Registry'),
$container->get('Customcode'),
$container->get('Customcode.Gui'),
$container->get('Model.Loader'),
$container->get('Model.Libraries')
);
}
}

View File

@ -0,0 +1,236 @@
<?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\Templatelayout;
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\Alias\Data as Aliasdata;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\GetHelper;
/**
* Template Layout Data Class
*
* @since 3.2.0
*/
class Data
{
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
*/
protected Config $config;
/**
* The compiler registry
*
* @var Registry
* @since 3.2.0
*/
protected Registry $registry;
/**
* Compiler Alias Data
*
* @var AliasData
* @since 3.2.0
*/
protected Aliasdata $alias;
/**
* Constructor
*
* @param Config|null $config The compiler config object.
* @param Registry|null $registry The compiler registry object.
* @param Aliasdata|null $alias The compiler alias data object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Registry $registry = null,
?Aliasdata $alias = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->registry = $registry ?: Compiler::_('Registry');
$this->alias = $alias ?: Compiler::_('Alias.Data');
}
/**
* Set Template and Layout Data
*
* @param string $content The content to check
* @param string $view The view code name
* @param bool $found The proof that something was found
* @param array $templates The option to pass templates keys (to avoid search)
* @param array $layouts The option to pass layout keys (to avoid search)
*
* @return bool if something was found true
* @since 3.2.0
*/
public function set(string $content, string $view, bool $found = false,
array $templates = [], array $layouts = []): bool
{
// to check inside the templates
$again = [];
// check if template keys were passed
if (!ArrayHelper::check($templates))
{
// set the Template data
$temp1 = GetHelper::allBetween(
$content, "\$this->loadTemplate('", "')"
);
$temp2 = GetHelper::allBetween(
$content, '$this->loadTemplate("', '")'
);
if (ArrayHelper::check($temp1)
&& ArrayHelper::check($temp2))
{
$templates = array_merge($temp1, $temp2);
}
else
{
if (ArrayHelper::check($temp1))
{
$templates = $temp1;
}
elseif (ArrayHelper::check($temp2))
{
$templates = $temp2;
}
}
}
// check if we found templates
if (ArrayHelper::check($templates, true))
{
foreach ($templates as $template)
{
if (!$this->registry->
get('builder.template_data.' . $this->config->build_target . '.' . $view . '.' . $template, null))
{
$data = $this->alias->get(
$template, 'template', $view
);
if (ArrayHelper::check($data))
{
// load it to the template data array
$this->registry->
set('builder.template_data.' . $this->config->build_target . '.' . $view . '.' . $template, $data);
// call self to get child data
$again[] = ['content' => $data['html'], 'view' => $view];
$again[] = ['content' => $data['php_view'], 'view' => $view];
}
}
// check if we have the template set (and nothing yet found)
if (!$found && $this->registry->
get('builder.template_data.' . $this->config->build_target . '.' . $view . '.' . $template, null))
{
// something was found
$found = true;
}
}
}
// check if layout keys were passed
if (!ArrayHelper::check($layouts))
{
// set the Layout data
$lay1 = GetHelper::allBetween(
$content, "JLayoutHelper::render('", "',"
);
$lay2 = GetHelper::allBetween(
$content, 'JLayoutHelper::render("', '",'
);
if (ArrayHelper::check($lay1)
&& ArrayHelper::check($lay2))
{
$layouts = array_merge($lay1, $lay2);
}
else
{
if (ArrayHelper::check($lay1))
{
$layouts = $lay1;
}
elseif (ArrayHelper::check($lay2))
{
$layouts = $lay2;
}
}
}
// check if we found layouts
if (ArrayHelper::check($layouts, true))
{
// get the other target if both
$_target = null;
if ($this->config->lang_target === 'both')
{
$_target = ($this->config->build_target === 'admin') ? 'site' : 'admin';
}
foreach ($layouts as $layout)
{
if (!$this->registry->
get('builder.layout_data.' . $this->config->build_target . '.' . $layout, null))
{
$data = $this->alias->get($layout, 'layout', $view);
if (ArrayHelper::check($data))
{
// load it to the layout data array
$this->registry->
set('builder.layout_data.' . $this->config->build_target . '.' . $layout, $data);
// check if other target is set
if ($this->config->lang_target === 'both' && $_target)
{
$this->registry->
set('builder.layout_data.' . $_target . '.' . $layout, $data);
}
// call self to get child data
$again[] = ['content' => $data['html'], 'view' => $view];
$again[] = ['content' => $data['php_view'], 'view' => $view];
}
}
// check if we have the layout set (and nothing yet found)
if (!$found && $this->registry->
get('builder.layout_data.' . $this->config->build_target . '.' . $layout, null))
{
// something was found
$found = true;
}
}
}
// check again
if (ArrayHelper::check($again))
{
foreach ($again as $go)
{
$found = $this->set(
$go['content'], $go['view'], $found
);
}
}
// return the proof that something was found
return $found;
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,83 @@
<?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;
/**
* The Field Helper
*
* @since 3.2.0
*/
abstract class FieldHelper
{
/**
* Field Grouping https://docs.joomla.org/Form_field
**/
protected static $fields = [
'default' => [
'accesslevel', 'cachehandler', 'calendar', 'captcha', 'category', 'checkbox', 'checkboxes', 'chromestyle',
'color', 'combo', 'componentlayout', 'contentlanguage', 'contenttype', 'databaseconnection', 'components',
'editor', 'editors', 'email', 'file', 'file', 'filelist', 'folderlist', 'groupedlist', 'headertag', 'helpsite', 'hidden', 'imagelist',
'integer', 'language', 'list', 'media', 'menu', 'modal_menu', 'menuitem', 'meter', 'modulelayout', 'moduleorder', 'moduleposition',
'moduletag', 'note', 'number', 'password', 'plugins', 'predefinedlist', 'radio', 'range', 'repeatable', 'rules',
'sessionhandler', 'spacer', 'sql', 'subform', 'tag', 'tel', 'templatestyle', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup'
],
'plain' => [
'cachehandler', 'calendar', 'checkbox', 'chromestyle', 'color', 'componentlayout', 'contenttype', 'editor', 'editors', 'captcha',
'email', 'file', 'headertag', 'helpsite', 'hidden', 'integer', 'language', 'media', 'menu', 'modal_menu', 'menuitem', 'meter', 'modulelayout', 'templatestyle',
'moduleorder', 'moduletag', 'number', 'password', 'range', 'rules', 'tag', 'tel', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup'
],
'option' => [
'accesslevel', 'category', 'checkboxes', 'combo', 'contentlanguage', 'databaseconnection', 'components',
'filelist', 'folderlist', 'imagelist', 'list', 'plugins', 'predefinedlist', 'radio', 'sessionhandler', 'sql', 'groupedlist'
],
'text' => [
'calendar', 'color', 'editor', 'email', 'number', 'password', 'range', 'tel', 'text', 'textarea', 'url'
],
'list' => [
'checkbox', 'checkboxes', 'list', 'radio', 'groupedlist', 'combo'
],
'dynamic' => [
'category', 'file', 'filelist', 'folderlist', 'headertag', 'imagelist', 'integer', 'media', 'meter', 'rules', 'tag', 'timezone', 'user'
],
'spacer' => [
'note', 'spacer'
],
'special' => [
'contentlanguage', 'moduleposition', 'plugin', 'repeatable', 'subform'
],
'search' => [
'editor', 'email', 'tel', 'text', 'textarea', 'url', 'subform'
]
];
/**
* Field Checker
*
* @param string $type The field type
* @param string $option The field grouping
*
* @return bool if the field was found
*/
public static function check(string $type, string $option = 'default'): bool
{
// now check
if (isset(self::$fields[$option]) &&
in_array($type, self::$fields[$option]))
{
return true;
}
return false;
}
}

Some files were not shown because too many files have changed in this diff Show More