Moves multiple class methods to their own power classes. Moves many compiler config values to its own config class. Updated the Expantion method to use the new config class.

This commit is contained in:
Llewellyn van der Merwe 2022-08-30 17:28:41 +02:00
parent f8ac247377
commit 4928a8baaf
Signed by: Llewellyn
GPG Key ID: A9201372263741E7
58 changed files with 14568 additions and 12580 deletions

View File

@ -140,14 +140,14 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 21st August, 2022
+ *Last Build*: 30th August, 2022
+ *Version*: 3.1.5
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **312270**
+ *Line count*: **319334**
+ *Field count*: **2002**
+ *File count*: **2057**
+ *Folder count*: **351**
+ *File count*: **2087**
+ *Folder count*: **359**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com).
> Developed by [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)

View File

@ -140,14 +140,14 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 21st August, 2022
+ *Last Build*: 30th August, 2022
+ *Version*: 3.1.5
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **312270**
+ *Line count*: **319334**
+ *Field count*: **2002**
+ *File count*: **2057**
+ *Folder count*: **351**
+ *File count*: **2087**
+ *Folder count*: **359**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com).
> Developed by [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)

View File

@ -930,11 +930,11 @@
min="1"
showon="development_method:2">
<form hidden="true" name="list_expansion_modal" repeat="true">
<!-- Component Field. Type: Joomlacomponent. (custom) -->
<!-- Component_id Field. Type: Joomlacomponent. (custom) -->
<field
type="joomlacomponent"
name="component"
label="COM_COMPONENTBUILDER_CONFIG_COMPONENT_LABEL"
name="component_id"
label="COM_COMPONENTBUILDER_CONFIG_COMPONENT_ID_LABEL"
class="list_class"
multiple="false"
default="0"
@ -973,14 +973,14 @@
description="COM_COMPONENTBUILDER_CONFIG_REPOSITORY_DESCRIPTION"
class="inputbox"
/>
<!-- Placeholders Field. Type: Checkbox. (joomla) -->
<!-- Add_placeholders Field. Type: Checkbox. (joomla) -->
<field
type="checkbox"
name="placeholders"
label="COM_COMPONENTBUILDER_CONFIG_PLACEHOLDERS_LABEL"
name="add_placeholders"
label="COM_COMPONENTBUILDER_CONFIG_ADD_PLACEHOLDERS_LABEL"
value="1"
default=""
description="COM_COMPONENTBUILDER_CONFIG_PLACEHOLDERS_DESCRIPTION"
description="COM_COMPONENTBUILDER_CONFIG_ADD_PLACEHOLDERS_DESCRIPTION"
class="inputbox"
/>
</form>

View File

@ -14,6 +14,7 @@ defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\MVC\Controller\AdminController;
use Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory;
/**
* Compiler Admin Controller
@ -89,20 +90,10 @@ class ComponentbuilderControllerCompiler extends AdminController
// currently only those with admin access can compile a component
if($user->authorise('core.manage', 'com_componentbuilder'))
{
// get the post values
$jinput = JFactory::getApplication()->input;
$componentId = $jinput->post->get('component', 0, 'INT');
$version = $jinput->post->get('version', 0, 'INT');
$addBackup = $jinput->post->get('backup', 0, 'INT');
$addRepo = $jinput->post->get('repository', 0, 'INT');
$addPlaceholders = $jinput->post->get('placeholders', 2, 'INT');
$addPowers = $jinput->post->get('powers', 2, 'INT');
$debugLinenr = $jinput->post->get('debuglinenr', 2, 'INT');
$minify = $jinput->post->get('minify', 2, 'INT');
// include component compiler
require_once JPATH_ADMINISTRATOR.'/components/com_componentbuilder/helpers/compiler.php';
$model = $this->getModel('compiler');
if ($model->builder($version, $componentId, $addBackup, $addRepo, $addPlaceholders, $addPowers, $debugLinenr, $minify))
if ($model->builder())
{
$cache = JFactory::getCache('mod_menu');
$cache->clean();
@ -123,7 +114,7 @@ class ComponentbuilderControllerCompiler extends AdminController
$redirect_url = $app->getUserState('com_componentbuilder.redirect_url');
// get system messages
$message = $app->getUserState('com_componentbuilder.message');
if (empty($redirect_url) && $componentId > 0)
if (empty($redirect_url) && CFactory::_('Config')->component_id > 0)
{
// start new message
$message = array();

View File

@ -20,7 +20,10 @@ use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Utilities\MathHelper;
use VDM\Joomla\Componentbuilder\Factory\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
// Use the component builder autoloader
ComponentbuilderHelper::autoLoader();
@ -30,6 +33,8 @@ ComponentbuilderHelper::autoLoader();
*/
class Compiler extends Infusion
{
/**
* The Temp path
*
@ -75,13 +80,13 @@ class Compiler extends Infusion
// to check the compiler speed
$this->time_start = microtime(true);
// first we run the perent constructors
if (parent::__construct($config))
if (parent::__construct())
{
// set temp directory
$comConfig = JFactory::getConfig();
$this->tempPath = $comConfig->get('tmp_path');
// set some folder paths in relation to distribution
if ($config['backup'])
if (CFactory::_('Config')->backup)
{
$this->backupPath = $this->params->get(
'backup_folder_path', $this->tempPath
@ -89,7 +94,7 @@ class Compiler extends Infusion
$this->dynamicIntegration = true;
}
// set local repos switch
if ($config['repository'])
if (CFactory::_('Config')->repository)
{
$this->repoPath = $this->params->get('git_folder_path', null);
}
@ -100,8 +105,7 @@ class Compiler extends Infusion
$this->removeFolder($this->componentPath . '/site');
// clear form component xml
$xmlPath = $this->componentPath . '/'
. $this->fileContentStatic[$this->hhh . 'component'
. $this->hhh] . '.xml';
. $this->fileContentStatic[Placefix::_h('component')] . '.xml';
$componentXML = ComponentbuilderHelper::getFileContents(
$xmlPath
);
@ -119,7 +123,7 @@ class Compiler extends Infusion
$this->writeFile($xmlPath, $componentXML);
}
// Trigger Event: jcb_ce_onBeforeUpdateFiles
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeUpdateFiles',
array(&$this->componentContext, &$this)
);
@ -129,15 +133,15 @@ class Compiler extends Infusion
return false;
}
// Trigger Event: jcb_ce_onBeforeGetCustomCode
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeGetCustomCode',
array(&$this->componentContext, &$this)
);
// now insert into the new files
if ($this->getCustomCode())
if (CFactory::_('Customcode')->load())
{
// Trigger Event: jcb_ce_onBeforeAddCustomCode
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeAddCustomCode',
array(&$this->componentContext, &$this)
);
@ -145,7 +149,7 @@ class Compiler extends Infusion
$this->addCustomCode();
}
// Trigger Event: jcb_ce_onBeforeSetLangFileData
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeSetLangFileData',
array(&$this->componentContext, &$this)
);
@ -184,7 +188,7 @@ class Compiler extends Infusion
'because more then %s&#37; of the strings have been translated.',
$this->percentageLanguageAdd
);
if (Config::get('debug_line_nr', false))
if (CFactory::_('Config')->get('debug_line_nr', false))
{
$whyAddedLang = JText::_(
'because the debugging mode is on. (debug line numbers)'
@ -215,12 +219,12 @@ class Compiler extends Infusion
'The <b>SQL</b> fix updates the #__assets table\'s column size on installation of the component and reverses it back to the Joomla default on uninstall of the component.'
);
// set assets table rules column notice
if (Config::get('add_assets_table_fix'))
if (CFactory::_('Config')->add_assets_table_fix)
{
$this->app->enqueueMessage(
JText::_('<hr /><h3>Assets Table Notice</h3>'), 'Notice'
);
$asset_table_fix_type = (Config::get('add_assets_table_fix') == 2)
$asset_table_fix_type = (CFactory::_('Config')->add_assets_table_fix == 2)
? 'intelligent' : 'sql';
$this->app->enqueueMessage(
JText::sprintf(
@ -245,7 +249,7 @@ class Compiler extends Infusion
);
}
// set assets table name column warning if not set
if (!Config::get('add_assets_table_fix') && $this->addAssetsTableNameFix)
if (!CFactory::_('Config')->add_assets_table_fix && $this->addAssetsTableNameFix)
{
// only add if not already added
if ($this->accessSize < 30)
@ -282,18 +286,18 @@ class Compiler extends Infusion
// if there are plugins zip them
$this->zipPlugins();
// do lang mismatch check
if (ArrayHelper::check($this->langMismatch))
if (ArrayHelper::check(CFactory::_('Language.Extractor')->langMismatch))
{
if (ArrayHelper::check($this->langMatch))
if (ArrayHelper::check(CFactory::_('Language.Extractor')->langMatch))
{
$mismatch = array_diff(
array_unique($this->langMismatch),
array_unique($this->langMatch)
array_unique(CFactory::_('Language.Extractor')->langMismatch),
array_unique(CFactory::_('Language.Extractor')->langMatch)
);
}
else
{
$mismatch = array_unique($this->langMismatch);
$mismatch = array_unique(CFactory::_('Language.Extractor')->langMismatch);
}
// set a notice if we have a mismatch
if (isset($mismatch)
@ -323,7 +327,7 @@ class Compiler extends Infusion
// add the mismatching issues
foreach ($mismatch as $string)
{
$constant = Config::get('lang_prefix') . '_'
$constant = CFactory::_('Config')->lang_prefix . '_'
. StringHelper::safe($string, 'U');
$this->app->enqueueMessage(
JText::sprintf(
@ -365,24 +369,6 @@ class Compiler extends Infusion
return false;
}
/**
* Set the line number in comments
*
* @param int $nr The line number
*
* @return void
*
*/
private function setLine($nr)
{
if (Config::get('debug_line_nr', false))
{
return ' [Compiler ' . $nr . ']';
}
return '';
}
/**
* Set the dynamic data to the created fils
*
@ -598,9 +584,9 @@ class Compiler extends Infusion
}
}
// do powers if found
if (ArrayHelper::check($this->powers))
if (ArrayHelper::check(CFactory::_('Power')->active))
{
foreach ($this->powers as $power)
foreach (CFactory::_('Power')->active as $power)
{
if (ObjectHelper::check($power)
&& isset($this->newFiles[$power->key])
@ -641,12 +627,12 @@ class Compiler extends Infusion
protected function setFileContent(&$name, &$path, &$bom, $view = null)
{
// Trigger Event: jcb_ce_onBeforeSetFileContent
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeSetFileContent',
array(&$this->componentContext, &$name, &$path, &$bom, &$view)
);
// set the file name
$this->fileContentStatic[$this->hhh . 'FILENAME' . $this->hhh] = $name;
$this->fileContentStatic[Placefix::_h('FILENAME')] = $name;
// check if the file should get PHP opening
$php = '';
if (ComponentbuilderHelper::checkFileType($name, 'php'))
@ -656,35 +642,35 @@ class Compiler extends Infusion
// get content of the file
$string = ComponentbuilderHelper::getFileContents($path);
// Trigger Event: jcb_ce_onGetFileContents
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onGetFileContents',
array(&$this->componentContext, &$string, &$name, &$path, &$bom,
&$view)
);
// see if we should add a BOM
if (strpos($string, $this->hhh . 'BOM' . $this->hhh) !== false)
if (strpos($string, Placefix::_h('BOM')) !== false)
{
list($wast, $code) = explode(
$this->hhh . 'BOM' . $this->hhh, $string
Placefix::_h('BOM'), $string
);
$string = $php . $bom . $code;
}
// set the answer
$answer = $this->setPlaceholders($string, $this->fileContentStatic, 3);
$answer = CFactory::_('Placeholder')->update($string, $this->fileContentStatic, 3);
// set the dynamic answer
if ($view)
{
$answer = $this->setPlaceholders(
$answer = CFactory::_('Placeholder')->update(
$answer, $this->fileContentDynamic[$view], 3
);
}
// check if this file needs extra care :)
if (isset($this->updateFileContent[$path]))
{
$answer = $this->setDynamicValues($answer);
$answer = CFactory::_('Customcode')->add($answer);
}
// Trigger Event: jcb_ce_onBeforeSetFileContent
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeWriteFileContent',
array(&$this->componentContext, &$answer, &$name, &$path, &$bom,
&$view)
@ -805,7 +791,7 @@ class Compiler extends Infusion
{
foreach ($data['config'] as $key => $value)
{
if ($this->hhh . 'VERSION' . $this->hhh === $key)
if (Placefix::_h('VERSION') === $key)
{
// hmm we sould in some way make it known that this version number
// is not in relation the the project but to the file only... any ideas?
@ -825,14 +811,14 @@ class Compiler extends Infusion
return true;
}
// else insure to reset to global
$this->fileContentStatic[$this->hhh . 'CREATIONDATE' . $this->hhh]
= $this->fileContentStatic[$this->hhh . 'CREATIONDATE' . $this->hhh
$this->fileContentStatic[Placefix::_h('CREATIONDATE')]
= $this->fileContentStatic[Placefix::_h('CREATIONDATE')
. 'GLOBAL'];
$this->fileContentStatic[$this->hhh . 'BUILDDATE' . $this->hhh]
= $this->fileContentStatic[$this->hhh . 'BUILDDATE' . $this->hhh
$this->fileContentStatic[Placefix::_h('BUILDDATE')]
= $this->fileContentStatic[Placefix::_h('BUILDDATE')
. 'GLOBAL'];
$this->fileContentStatic[$this->hhh . 'VERSION' . $this->hhh]
= $this->fileContentStatic[$this->hhh . 'VERSION' . $this->hhh
$this->fileContentStatic[Placefix::_h('VERSION')]
= $this->fileContentStatic[Placefix::_h('VERSION')
. 'GLOBAL'];
}
@ -898,9 +884,9 @@ class Compiler extends Infusion
{
// set readme data if not set already
if (!isset(
$this->fileContentStatic[$this->hhh . 'LINE_COUNT' . $this->hhh]
$this->fileContentStatic[Placefix::_h('LINE_COUNT')]
)
|| $this->fileContentStatic[$this->hhh . 'LINE_COUNT' . $this->hhh]
|| $this->fileContentStatic[Placefix::_h('LINE_COUNT')]
!= $this->lineCount)
{
$this->buildReadMeData();
@ -908,7 +894,7 @@ class Compiler extends Infusion
// get the file
$string = ComponentbuilderHelper::getFileContents($path);
// update the file
$answer = $this->setPlaceholders($string, $this->fileContentStatic);
$answer = CFactory::_('Placeholder')->update($string, $this->fileContentStatic);
// add to zip array
$this->writeFile($path, $answer);
}
@ -916,71 +902,71 @@ class Compiler extends Infusion
private function buildReadMeData()
{
// set some defaults
$this->fileContentStatic[$this->hhh . 'LINE_COUNT' . $this->hhh]
$this->fileContentStatic[Placefix::_h('LINE_COUNT')]
= $this->lineCount;
$this->fileContentStatic[$this->hhh . 'FIELD_COUNT' . $this->hhh]
$this->fileContentStatic[Placefix::_h('FIELD_COUNT')]
= $this->fieldCount;
$this->fileContentStatic[$this->hhh . 'FILE_COUNT' . $this->hhh]
$this->fileContentStatic[Placefix::_h('FILE_COUNT')]
= $this->fileCount;
$this->fileContentStatic[$this->hhh . 'FOLDER_COUNT' . $this->hhh]
$this->fileContentStatic[Placefix::_h('FOLDER_COUNT')]
= $this->folderCount;
$this->fileContentStatic[$this->hhh . 'PAGE_COUNT' . $this->hhh]
$this->fileContentStatic[Placefix::_h('PAGE_COUNT')]
= $this->pageCount;
$this->fileContentStatic[$this->hhh . 'folders' . $this->hhh]
$this->fileContentStatic[Placefix::_h('folders')]
= $this->folderSeconds;
$this->fileContentStatic[$this->hhh . 'foldersSeconds' . $this->hhh]
$this->fileContentStatic[Placefix::_h('foldersSeconds')]
= $this->folderSeconds;
$this->fileContentStatic[$this->hhh . 'files' . $this->hhh]
$this->fileContentStatic[Placefix::_h('files')]
= $this->fileSeconds;
$this->fileContentStatic[$this->hhh . 'filesSeconds' . $this->hhh]
$this->fileContentStatic[Placefix::_h('filesSeconds')]
= $this->fileSeconds;
$this->fileContentStatic[$this->hhh . 'lines' . $this->hhh]
$this->fileContentStatic[Placefix::_h('lines')]
= $this->lineSeconds;
$this->fileContentStatic[$this->hhh . 'linesSeconds' . $this->hhh]
$this->fileContentStatic[Placefix::_h('linesSeconds')]
= $this->lineSeconds;
$this->fileContentStatic[$this->hhh . 'seconds' . $this->hhh]
$this->fileContentStatic[Placefix::_h('seconds')]
= $this->actualSeconds;
$this->fileContentStatic[$this->hhh . 'actualSeconds' . $this->hhh]
$this->fileContentStatic[Placefix::_h('actualSeconds')]
= $this->actualSeconds;
$this->fileContentStatic[$this->hhh . 'totalHours' . $this->hhh]
$this->fileContentStatic[Placefix::_h('totalHours')]
= $this->totalHours;
$this->fileContentStatic[$this->hhh . 'totalDays' . $this->hhh]
$this->fileContentStatic[Placefix::_h('totalDays')]
= $this->totalDays;
$this->fileContentStatic[$this->hhh . 'debugging' . $this->hhh]
$this->fileContentStatic[Placefix::_h('debugging')]
= $this->secondsDebugging;
$this->fileContentStatic[$this->hhh . 'secondsDebugging' . $this->hhh]
$this->fileContentStatic[Placefix::_h('secondsDebugging')]
= $this->secondsDebugging;
$this->fileContentStatic[$this->hhh . 'planning' . $this->hhh]
$this->fileContentStatic[Placefix::_h('planning')]
= $this->secondsPlanning;
$this->fileContentStatic[$this->hhh . 'secondsPlanning' . $this->hhh]
$this->fileContentStatic[Placefix::_h('secondsPlanning')]
= $this->secondsPlanning;
$this->fileContentStatic[$this->hhh . 'mapping' . $this->hhh]
$this->fileContentStatic[Placefix::_h('mapping')]
= $this->secondsMapping;
$this->fileContentStatic[$this->hhh . 'secondsMapping' . $this->hhh]
$this->fileContentStatic[Placefix::_h('secondsMapping')]
= $this->secondsMapping;
$this->fileContentStatic[$this->hhh . 'office' . $this->hhh]
$this->fileContentStatic[Placefix::_h('office')]
= $this->secondsOffice;
$this->fileContentStatic[$this->hhh . 'secondsOffice' . $this->hhh]
$this->fileContentStatic[Placefix::_h('secondsOffice')]
= $this->secondsOffice;
$this->fileContentStatic[$this->hhh . 'actualTotalHours' . $this->hhh]
$this->fileContentStatic[Placefix::_h('actualTotalHours')]
= $this->actualTotalHours;
$this->fileContentStatic[$this->hhh . 'actualTotalDays' . $this->hhh]
$this->fileContentStatic[Placefix::_h('actualTotalDays')]
= $this->actualTotalDays;
$this->fileContentStatic[$this->hhh . 'debuggingHours' . $this->hhh]
$this->fileContentStatic[Placefix::_h('debuggingHours')]
= $this->debuggingHours;
$this->fileContentStatic[$this->hhh . 'planningHours' . $this->hhh]
$this->fileContentStatic[Placefix::_h('planningHours')]
= $this->planningHours;
$this->fileContentStatic[$this->hhh . 'mappingHours' . $this->hhh]
$this->fileContentStatic[Placefix::_h('mappingHours')]
= $this->mappingHours;
$this->fileContentStatic[$this->hhh . 'officeHours' . $this->hhh]
$this->fileContentStatic[Placefix::_h('officeHours')]
= $this->officeHours;
$this->fileContentStatic[$this->hhh . 'actualHoursSpent' . $this->hhh]
$this->fileContentStatic[Placefix::_h('actualHoursSpent')]
= $this->actualHoursSpent;
$this->fileContentStatic[$this->hhh . 'actualDaysSpent' . $this->hhh]
$this->fileContentStatic[Placefix::_h('actualDaysSpent')]
= $this->actualDaysSpent;
$this->fileContentStatic[$this->hhh . 'projectWeekTime' . $this->hhh]
$this->fileContentStatic[Placefix::_h('projectWeekTime')]
= $this->projectWeekTime;
$this->fileContentStatic[$this->hhh . 'projectMonthTime' . $this->hhh]
$this->fileContentStatic[Placefix::_h('projectMonthTime')]
= $this->projectMonthTime;
}
@ -995,9 +981,9 @@ class Compiler extends Infusion
// set the repo path
$repoFullPath = $this->repoPath . '/com_'
. $this->componentData->sales_name . '__joomla_'
. Config::get('version', 3);
. CFactory::_('Config')->get('version', 3);
// Trigger Event: jcb_ce_onBeforeUpdateRepo
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeUpdateRepo',
array(&$this->componentContext, &$this->componentPath,
&$repoFullPath, &$this->componentData)
@ -1007,7 +993,7 @@ class Compiler extends Infusion
// set the new data
Folder::copy($this->componentPath, $repoFullPath, '', true);
// Trigger Event: jcb_ce_onAfterUpdateRepo
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onAfterUpdateRepo',
array(&$this->componentContext, &$this->componentPath,
&$repoFullPath, &$this->componentData)
@ -1026,9 +1012,9 @@ class Compiler extends Infusion
// set the repo path
$repoFullPath = $this->repoPath . '/'
. $module->folder_name . '__joomla_'
. Config::get('version', 3);
. CFactory::_('Config')->get('version', 3);
// Trigger Event: jcb_ce_onBeforeUpdateRepo
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeUpdateRepo',
array(&$module_context, &$module->folder_path,
&$repoFullPath, &$module)
@ -1042,7 +1028,7 @@ class Compiler extends Infusion
$module->folder_path, $repoFullPath, '', true
);
// Trigger Event: jcb_ce_onAfterUpdateRepo
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onAfterUpdateRepo',
array(&$module_context, &$module->folder_path,
&$repoFullPath, &$module)
@ -1063,9 +1049,9 @@ class Compiler extends Infusion
// set the repo path
$repoFullPath = $this->repoPath . '/'
. $plugin->folder_name . '__joomla_'
. Config::get('version', 3);
. CFactory::_('Config')->get('version', 3);
// Trigger Event: jcb_ce_onBeforeUpdateRepo
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeUpdateRepo',
array(&$plugin_context, &$plugin->folder_path,
&$repoFullPath, &$plugin)
@ -1079,7 +1065,7 @@ class Compiler extends Infusion
$plugin->folder_path, $repoFullPath, '', true
);
// Trigger Event: jcb_ce_onAfterUpdateRepo
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onAfterUpdateRepo',
array(&$plugin_context, &$plugin->folder_path,
&$repoFullPath, &$plugin)
@ -1098,7 +1084,7 @@ class Compiler extends Infusion
$this->filepath['component'] = $this->tempPath . '/'
. $this->filepath['component-folder'] . '.zip';
// Trigger Event: jcb_ce_onBeforeZipComponent
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeZipComponent',
array(&$this->componentContext, &$this->componentPath,
&$this->filepath['component'], &$this->tempPath,
@ -1113,7 +1099,7 @@ class Compiler extends Infusion
if ($this->backupPath && $this->dynamicIntegration)
{
// Trigger Event: jcb_ce_onBeforeBackupZip
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeBackupZip', array(&$this->componentContext,
&$this->filepath['component'],
&$this->tempPath,
@ -1135,7 +1121,7 @@ class Compiler extends Infusion
if (isset($this->componentData->sales_server))
{
// Trigger Event: jcb_ce_onBeforeMoveToServer
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeMoveToServer',
array(&$this->componentContext,
&$this->filepath['component'], &$this->tempPath,
@ -1151,7 +1137,7 @@ class Compiler extends Infusion
}
}
// Trigger Event: jcb_ce_onAfterZipComponent
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onAfterZipComponent',
array(&$this->componentContext, &$this->filepath['component'],
&$this->tempPath, &$this->componentFolderName,
@ -1190,7 +1176,7 @@ class Compiler extends Infusion
$this->filepath['modules'][$module->id] = $this->tempPath
. '/' . $module->zip_name . '.zip';
// Trigger Event: jcb_ce_onBeforeZipModule
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeZipModule',
array(&$module_context, &$module->folder_path,
&$this->filepath['modules'][$module->id],
@ -1207,7 +1193,7 @@ class Compiler extends Infusion
{
$__module_context = 'module.' . $module_context;
// Trigger Event: jcb_ce_onBeforeBackupZip
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeBackupZip',
array(&$__module_context,
&$this->filepath['modules'][$module->id],
@ -1229,7 +1215,7 @@ class Compiler extends Infusion
if (isset($module->sales_server))
{
// Trigger Event: jcb_ce_onBeforeMoveToServer
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeMoveToServer',
array(&$__module_context,
&$this->filepath['modules'][$module->id],
@ -1246,7 +1232,7 @@ class Compiler extends Infusion
}
}
// Trigger Event: jcb_ce_onAfterZipModule
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onAfterZipModule', array(&$module_context,
&$this->filepath['modules'][$module->id],
&$this->tempPath,
@ -1284,7 +1270,7 @@ class Compiler extends Infusion
$this->filepath['plugins'][$plugin->id] = $this->tempPath
. '/' . $plugin->zip_name . '.zip';
// Trigger Event: jcb_ce_onBeforeZipPlugin
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeZipPlugin',
array(&$plugin_context, &$plugin->folder_path,
&$this->filepath['plugins'][$plugin->id],
@ -1301,7 +1287,7 @@ class Compiler extends Infusion
{
$__plugin_context = 'plugin.' . $plugin_context;
// Trigger Event: jcb_ce_onBeforeBackupZip
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeBackupZip',
array(&$__plugin_context,
&$this->filepath['plugins'][$plugin->id],
@ -1323,7 +1309,7 @@ class Compiler extends Infusion
if (isset($plugin->sales_server))
{
// Trigger Event: jcb_ce_onBeforeMoveToServer
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeMoveToServer',
array(&$__plugin_context,
&$this->filepath['plugins'][$plugin->id],
@ -1340,7 +1326,7 @@ class Compiler extends Infusion
}
}
// Trigger Event: jcb_ce_onAfterZipPlugin
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onAfterZipPlugin', array(&$plugin_context,
&$this->filepath['plugins'][$plugin->id],
&$this->tempPath,
@ -1358,9 +1344,9 @@ class Compiler extends Infusion
protected function addCustomCode()
{
// reset all these
$this->clearFromPlaceHolders('view');
$this->clearFromPlaceHolders('arg');
foreach ($this->customCode as $nr => $target)
CFactory::_('Placeholder')->clearType('view');
CFactory::_('Placeholder')->clearType('arg');
foreach (CFactory::_('Customcode')->active as $nr => $target)
{
// reset each time per custom code
$fingerPrint = array();
@ -1471,13 +1457,13 @@ class Compiler extends Infusion
}
if ($found)
{
$placeholder = $this->getPlaceHolder(
$placeholder = CFactory::_('Placeholder')->keys(
(int) $target['comment_type'] . $target['type'],
$target['id']
);
$data = $placeholder['start'] . PHP_EOL
. $this->setPlaceholders(
$target['code'], $this->placeholders
. CFactory::_('Placeholder')->update(
$target['code'], CFactory::_('Placeholder')->active
) . $placeholder['end'] . PHP_EOL;
if ($target['type'] == 2)
{
@ -1566,7 +1552,7 @@ class Compiler extends Infusion
$_commentType . PHP_EOL . $commentType, $code
) . $_commentType . PHP_EOL;
// get place holders
$placeholder = $this->getPlaceHolder(
$placeholder = CFactory::_('Placeholder')->keys(
(int) $target['comment_type'] . $target['type'], $target['id']
);
// build the data

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,10 @@ use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\ObjectHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Componentbuilder\Factory\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
/**
@ -29,6 +32,7 @@ use VDM\Joomla\Componentbuilder\Factory\Compiler\Config;
class Structure extends Get
{
/**
* The folder counter
*
@ -370,56 +374,50 @@ class Structure extends Get
/**
* Constructor
*/
public function __construct($config = array())
public function __construct()
{
// first we run the perent constructor
if (parent::__construct($config))
if (parent::__construct())
{
// set the standard admin file
$this->stdRootFiles[] = $this->componentData->name_code . '.php';
// set incase no extra admin folder are loaded
$this->fileContentStatic[$this->hhh . 'EXSTRA_ADMIN_FOLDERS'
. $this->hhh]
$this->fileContentStatic[Placefix::_h('EXSTRA_ADMIN_FOLDERS')]
= '';
// set incase no extra site folder are loaded
$this->fileContentStatic[$this->hhh . 'EXSTRA_SITE_FOLDERS'
. $this->hhh]
$this->fileContentStatic[Placefix::_h('EXSTRA_SITE_FOLDERS')]
= '';
// set incase no extra media folder are loaded
$this->fileContentStatic[$this->hhh . 'EXSTRA_MEDIA_FOLDERS'
. $this->hhh]
$this->fileContentStatic[Placefix::_h('EXSTRA_MEDIA_FOLDERS')]
= '';
// set incase no extra admin files are loaded
$this->fileContentStatic[$this->hhh . 'EXSTRA_ADMIN_FILES'
. $this->hhh]
$this->fileContentStatic[Placefix::_h('EXSTRA_ADMIN_FILES')]
= '';
// set incase no extra site files are loaded
$this->fileContentStatic[$this->hhh . 'EXSTRA_SITE_FILES'
. $this->hhh]
$this->fileContentStatic[Placefix::_h('EXSTRA_SITE_FILES')]
= '';
// set incase no extra media files are loaded
$this->fileContentStatic[$this->hhh . 'EXSTRA_MEDIA_FILES'
. $this->hhh]
$this->fileContentStatic[Placefix::_h('EXSTRA_MEDIA_FILES')]
= '';
// run global updater
ComponentbuilderHelper::runGlobalUpdater();
// set the template path
$this->templatePath = Config::get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/joomla_'
. $this->joomlaVersions[Config::get('version', 3)]['folder_key'];
$this->templatePath = CFactory::_('Config')->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/joomla_'
. $this->joomlaVersions[CFactory::_('Config')->joomla_version]['folder_key'];
// set some default names
$this->componentSalesName = 'com_'
. $this->componentData->sales_name . '__J'
. Config::get('version', 3);
. CFactory::_('Config')->joomla_version;
$this->componentBackupName = 'com_'
. $this->componentData->sales_name . '_v' . str_replace(
'.', '_', $this->componentData->component_version
) . '__J' . Config::get('version', 3);
) . '__J' . CFactory::_('Config')->joomla_version;
$this->componentFolderName = 'com_'
. $this->componentData->name_code . '_v' . str_replace(
'.', '_', $this->componentData->component_version
) . '__J' . Config::get('version', 3);
) . '__J' . CFactory::_('Config')->joomla_version;
// set component folder path
$this->componentPath = Config::get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
$this->componentPath = CFactory::_('Config')->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
. $this->componentFolderName;
// set the template path for custom
$this->templatePathCustom = $this->params->get(
@ -438,7 +436,7 @@ class Structure extends Get
// set the Joomla Version Data
$this->joomlaVersionData = $this->setJoomlaVersionData();
// Trigger Event: jcb_ce_onAfterSetJoomlaVersionData
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onAfterSetJoomlaVersionData',
array(&$this->componentContext, &$this->joomlaVersionData)
);
@ -466,24 +464,6 @@ class Structure extends Get
return false;
}
/**
* Set the line number in comments
*
* @param int $nr The line number
*
* @return string
*
*/
private function setLine($nr)
{
if (Config::get('debug_line_nr', false))
{
return ' [Structure ' . $nr . ']';
}
return '';
}
/**
* Build the Powers files, folders
*
@ -492,16 +472,20 @@ class Structure extends Get
*/
private function buildPowers()
{
if (ArrayHelper::check($this->powers))
if (ArrayHelper::check(CFactory::_('Power')->active))
{
// for plugin event TODO change event api signatures
$this->powers = CFactory::_('Power')->active;
// Trigger Event: jcb_ce_onBeforeSetModules
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeBuildPowers',
array(&$this->componentContext, &$this->powers)
);
// for plugin event TODO change event api signatures
CFactory::_('Power')->active = $this->powers;
// we track the creation of htaccess files
$htaccess = array();
foreach ($this->powers as $power)
foreach (CFactory::_('Power')->active as $power)
{
if (ObjectHelper::check($power)
&& isset($power->path)
@ -533,8 +517,8 @@ class Structure extends Get
$this->writeFile(
$fileDetails['path'],
'<?php' . PHP_EOL . '// A POWER FILE' .
PHP_EOL . $this->hhh . 'BOM' . $this->hhh . PHP_EOL .
PHP_EOL . $this->hhh . 'POWERCODE' . $this->hhh
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . Placefix::_h('POWERCODE')
);
$this->newFiles[$power->key][] = $fileDetails;
// count the file created
@ -606,7 +590,7 @@ class Structure extends Get
if (ArrayHelper::check($this->joomlaModules))
{
// Trigger Event: jcb_ce_onBeforeSetModules
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeBuildModules',
array(&$this->componentContext, &$this->joomlaModules)
);
@ -619,7 +603,7 @@ class Structure extends Get
))
{
// module path
$module->folder_path = Config::get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
$module->folder_path = CFactory::_('Config')->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
. $module->folder_name;
// set the module paths
$this->dynamicPaths[$module->key] = $module->folder_path;
@ -635,11 +619,11 @@ class Structure extends Get
$this->writeFile(
$fileDetails['path'],
'<?php' . PHP_EOL . '// main modfile' .
PHP_EOL . $this->hhh . 'BOM' . $this->hhh . PHP_EOL .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
"defined('_JEXEC') or die('Restricted access');"
. PHP_EOL .
$this->hhh . 'MODCODE' . $this->hhh
Placefix::_h('MODCODE')
);
$this->newFiles[$module->key][] = $fileDetails;
// count the file created
@ -654,7 +638,7 @@ class Structure extends Get
$this->writeFile(
$fileDetails['path'],
'<?php' . PHP_EOL . '// get data file' .
PHP_EOL . $this->hhh . 'BOM' . $this->hhh . PHP_EOL
PHP_EOL . Placefix::_h('BOM') . PHP_EOL
.
PHP_EOL . '// No direct access to this file'
. PHP_EOL .
@ -666,7 +650,7 @@ class Structure extends Get
' */' . PHP_EOL .
"class " . $module->class_data_name
. ' extends \JObject' . PHP_EOL .
"{" . $this->hhh . 'DYNAMICGETS' . $this->hhh . "}"
"{" . Placefix::_h('DYNAMICGETS') . "}"
. PHP_EOL
);
$this->newFiles[$module->key][] = $fileDetails;
@ -683,13 +667,13 @@ class Structure extends Get
$this->writeFile(
$fileDetails['path'],
'<?php' . PHP_EOL . '// helper file' .
PHP_EOL . $this->hhh . 'BOM' . $this->hhh . PHP_EOL
PHP_EOL . Placefix::_h('BOM') . PHP_EOL
.
PHP_EOL . '// No direct access to this file'
. PHP_EOL .
"defined('_JEXEC') or die('Restricted access');"
. PHP_EOL .
$this->hhh . 'HELPERCODE' . $this->hhh
Placefix::_h('HELPERCODE')
);
$this->newFiles[$module->key][] = $fileDetails;
// count the file created
@ -717,11 +701,11 @@ class Structure extends Get
$this->writeFile(
$fileDetails['path'],
'<?php' . PHP_EOL . '// default tmpl' .
PHP_EOL . $this->hhh . 'BOM' . $this->hhh . PHP_EOL .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
"defined('_JEXEC') or die('Restricted access');"
. PHP_EOL .
$this->hhh . 'MODDEFAULT' . $this->hhh
Placefix::_h('MODDEFAULT')
);
$this->newFiles[$module->key][] = $fileDetails;
// count the file created
@ -736,13 +720,13 @@ class Structure extends Get
$this->writeFile(
$fileDetails['path'],
'<?php' . PHP_EOL . '// Script template' .
PHP_EOL . $this->hhh . 'BOM' . $this->hhh . PHP_EOL
PHP_EOL . Placefix::_h('BOM') . PHP_EOL
.
PHP_EOL . '// No direct access to this file'
. PHP_EOL .
"defined('_JEXEC') or die('Restricted access');"
. PHP_EOL .
$this->hhh . 'INSTALLCLASS' . $this->hhh
Placefix::_h('INSTALLCLASS')
);
$this->newFiles[$module->key][] = $fileDetails;
// count the file created
@ -789,16 +773,16 @@ class Structure extends Get
'zip' => 'mod_admin.css');
$this->writeFile(
$fileDetails['path'],
$this->hhh . 'BOM' . $this->hhh . PHP_EOL
Placefix::_h('BOM') . PHP_EOL
. PHP_EOL . $css
);
$this->newFiles[$module->key][] = $fileDetails;
// count the file created
$this->fileCount++;
// add the field script
$field_script_bucket[] = $this->_t(2) . "//"
. $this->setLine(__LINE__) . " Custom CSS";
$field_script_bucket[] = $this->_t(2)
$field_script_bucket[] = Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Custom CSS";
$field_script_bucket[] = Indent::_(2)
. "\$document->addStyleSheet('" . $target_path
. "/modules/" . $module->folder_name
. "/css/mod_admin.css', ['version' => 'auto', 'relative' => true]);";
@ -824,16 +808,16 @@ class Structure extends Get
'zip' => 'mod_admin.js');
$this->writeFile(
$fileDetails['path'],
$this->hhh . 'BOM' . $this->hhh . PHP_EOL
Placefix::_h('BOM') . PHP_EOL
. PHP_EOL . $javascript
);
$this->newFiles[$module->key][] = $fileDetails;
// count the file created
$this->fileCount++;
// add the field script
$field_script_bucket[] = $this->_t(2) . "//"
. $this->setLine(__LINE__) . " Custom JS";
$field_script_bucket[] = $this->_t(2)
$field_script_bucket[] = Indent::_(2) . "//"
. Line::_(__Line__, __Class__) . " Custom JS";
$field_script_bucket[] = Indent::_(2)
. "\$document->addScript('" . $target_path
. "/modules/" . $module->folder_name
. "/js/mod_admin.js', ['version' => 'auto', 'relative' => true]);";
@ -890,7 +874,7 @@ class Structure extends Get
. '.xml');
// build basic XML
$xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= PHP_EOL . '<!--' . $this->setLine(__LINE__)
$xml .= PHP_EOL . '<!--' . Line::_(__Line__, __Class__)
. ' default paths of ' . $file
. ' form points to ' . $this->componentCodeName
. ' -->';
@ -919,13 +903,13 @@ class Structure extends Get
if ($add_component_path)
{
$xml .= PHP_EOL . '<form';
$xml .= PHP_EOL . $this->_t(1)
$xml .= PHP_EOL . Indent::_(1)
. 'addrulepath="/administrator/components/com_'
. Config::get('component_code_name')
. CFactory::_('Config')->component_code_name
. '/models/rules"';
$xml .= PHP_EOL . $this->_t(1)
$xml .= PHP_EOL . Indent::_(1)
. 'addfieldpath="/administrator/components/com_'
. Config::get('component_code_name')
. CFactory::_('Config')->component_code_name
. '/models/fields"';
$xml .= PHP_EOL . '>';
}
@ -948,7 +932,7 @@ class Structure extends Get
$field_name_inner = $field_names[1];
}
}
$xml .= PHP_EOL . $this->_t(1)
$xml .= PHP_EOL . Indent::_(1)
. '<fields name="' . $field_name_outer
. '">';
foreach ($fieldsets as $fieldset => $field)
@ -1002,30 +986,30 @@ class Structure extends Get
|| isset($module->add_field_path[$file . $field_name . $fieldset]))
{
$xml .= PHP_EOL . $this->_t(1) . '<!--'
. $this->setLine(__LINE__) . ' default paths of '
$xml .= PHP_EOL . Indent::_(1) . '<!--'
. Line::_(__Line__, __Class__) . ' default paths of '
. $fieldset . ' fieldset points to the module -->';
$xml .= PHP_EOL . $this->_t(1) . '<fieldset name="'
$xml .= PHP_EOL . Indent::_(1) . '<fieldset name="'
. $fieldset . '" label="' . $label . '"';
if (isset($module->add_rule_path[$file . $field_name . $fieldset]))
{
$xml .= PHP_EOL . $this->_t(2)
$xml .= PHP_EOL . Indent::_(2)
. 'addrulepath="' . $module->add_rule_path[$file . $field_name . $fieldset] . '"';
}
if (isset($module->add_field_path[$file . $field_name . $fieldset]))
{
$xml .= PHP_EOL . $this->_t(2)
$xml .= PHP_EOL . Indent::_(2)
. 'addfieldpath="' . $module->add_field_path[$file . $field_name . $fieldset] . '"';
}
$xml .= PHP_EOL . $this->_t(1) . '>';
$xml .= PHP_EOL . Indent::_(1) . '>';
}
else
{
$xml .= PHP_EOL . $this->_t(1) . '<fieldset name="'
$xml .= PHP_EOL . Indent::_(1) . '<fieldset name="'
. $fieldset . '" label="' . $label . '">';
}
// check if we have an inner field set
@ -1033,25 +1017,25 @@ class Structure extends Get
$field_name_inner
))
{
$xml .= PHP_EOL . $this->_t(1)
$xml .= PHP_EOL . Indent::_(1)
. '<fields name="'
. $field_name_inner . '">';
}
// add the placeholder of the fields
$xml .= $this->hhh . 'FIELDSET_' . $file
. $field_name . $fieldset . $this->hhh;
$xml .= Placefix::_h('FIELDSET_' . $file
. $field_name . $fieldset );
// check if we have an inner field set
if (StringHelper::check(
$field_name_inner
))
{
$xml .= PHP_EOL . $this->_t(1)
$xml .= PHP_EOL . Indent::_(1)
. '</fields>';
}
$xml .= PHP_EOL . $this->_t(1)
$xml .= PHP_EOL . Indent::_(1)
. '</fieldset>';
}
$xml .= PHP_EOL . $this->_t(1) . '</fields>';
$xml .= PHP_EOL . Indent::_(1) . '</fields>';
}
$xml .= PHP_EOL . '</form>';
// add xml to file
@ -1096,7 +1080,7 @@ class Structure extends Get
$this->createFolder($module->folder_path . '/language');
// also create the lang tag folder
$this->createFolder(
$module->folder_path . '/language/' . Config::get('lang_tag', 'en-GB')
$module->folder_path . '/language/' . CFactory::_('Config')->get('lang_tag', 'en-GB')
);
// check if this lib has files
if (isset($module->files)
@ -1187,7 +1171,7 @@ class Structure extends Get
if (ArrayHelper::check($this->joomlaPlugins))
{
// Trigger Event: jcb_ce_onBeforeSetPlugins
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeBuildPlugins',
array(&$this->componentContext, &$this->joomlaPlugins)
);
@ -1200,7 +1184,7 @@ class Structure extends Get
))
{
// plugin path
$plugin->folder_path = Config::get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
$plugin->folder_path = CFactory::_('Config')->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
. $plugin->folder_name;
// set the plugin paths
$this->dynamicPaths[$plugin->key] = $plugin->folder_path;
@ -1216,11 +1200,11 @@ class Structure extends Get
$this->writeFile(
$fileDetails['path'],
'<?php' . PHP_EOL . '// Plugin main class template' .
PHP_EOL . $this->hhh . 'BOM' . $this->hhh . PHP_EOL .
PHP_EOL . Placefix::_h('BOM') . PHP_EOL .
PHP_EOL . '// No direct access to this file' . PHP_EOL .
"defined('_JEXEC') or die('Restricted access');"
. PHP_EOL .
$this->hhh . 'MAINCLASS' . $this->hhh
Placefix::_h('MAINCLASS')
);
$this->newFiles[$plugin->key][] = $fileDetails;
// count the file created
@ -1247,13 +1231,13 @@ class Structure extends Get
$this->writeFile(
$fileDetails['path'],
'<?php' . PHP_EOL . '// Script template' .
PHP_EOL . $this->hhh . 'BOM' . $this->hhh . PHP_EOL
PHP_EOL . Placefix::_h('BOM') . PHP_EOL
.
PHP_EOL . '// No direct access to this file'
. PHP_EOL .
"defined('_JEXEC') or die('Restricted access');"
. PHP_EOL .
$this->hhh . 'INSTALLCLASS' . $this->hhh
Placefix::_h('INSTALLCLASS')
);
$this->newFiles[$plugin->key][] = $fileDetails;
// count the file created
@ -1299,9 +1283,9 @@ class Structure extends Get
. '.xml');
// biuld basic XML
$xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= PHP_EOL . '<!--' . $this->setLine(__LINE__)
$xml .= PHP_EOL . '<!--' . Line::_(__Line__, __Class__)
. ' default paths of ' . $file
. ' form points to ' . Config::get('component_code_name')
. ' form points to ' . CFactory::_('Config')->component_code_name
. ' -->';
// search if we must add the component path
$add_component_path = false;
@ -1328,13 +1312,13 @@ class Structure extends Get
if ($add_component_path)
{
$xml .= PHP_EOL . '<form';
$xml .= PHP_EOL . $this->_t(1)
$xml .= PHP_EOL . Indent::_(1)
. 'addrulepath="/administrator/components/com_'
. Config::get('component_code_name')
. CFactory::_('Config')->component_code_name
. '/models/rules"';
$xml .= PHP_EOL . $this->_t(1)
$xml .= PHP_EOL . Indent::_(1)
. 'addfieldpath="/administrator/components/com_'
. Config::get('component_code_name')
. CFactory::_('Config')->component_code_name
. '/models/fields"';
$xml .= PHP_EOL . '>';
}
@ -1357,7 +1341,7 @@ class Structure extends Get
$field_name_inner = $field_names[1];
}
}
$xml .= PHP_EOL . $this->_t(1)
$xml .= PHP_EOL . Indent::_(1)
. '<fields name="' . $field_name_outer
. '">';
foreach ($fieldsets as $fieldset => $field)
@ -1393,30 +1377,30 @@ class Structure extends Get
if (isset($plugin->add_rule_path[$file . $field_name . $fieldset])
|| isset($plugin->add_field_path[$file . $field_name . $fieldset]))
{
$xml .= PHP_EOL . $this->_t(1) . '<!--'
. $this->setLine(__LINE__) . ' default paths of '
$xml .= PHP_EOL . Indent::_(1) . '<!--'
. Line::_(__Line__, __Class__) . ' default paths of '
. $fieldset . ' fieldset points to the plugin -->';
$xml .= PHP_EOL . $this->_t(1) . '<fieldset name="'
$xml .= PHP_EOL . Indent::_(1) . '<fieldset name="'
. $fieldset . '" label="' . $label . '"';
if (isset($plugin->add_rule_path[$file . $field_name . $fieldset]))
{
$xml .= PHP_EOL . $this->_t(2)
$xml .= PHP_EOL . Indent::_(2)
. 'addrulepath="' . $plugin->add_rule_path[$file . $field_name . $fieldset] . '"';
}
if (isset($plugin->add_field_path[$file . $field_name . $fieldset]))
{
$xml .= PHP_EOL . $this->_t(2)
$xml .= PHP_EOL . Indent::_(2)
. 'addfieldpath="' . $plugin->add_field_path[$file . $field_name . $fieldset] . '"';
}
$xml .= PHP_EOL . $this->_t(1) . '>';
$xml .= PHP_EOL . Indent::_(1) . '>';
}
else
{
$xml .= PHP_EOL . $this->_t(1) . '<fieldset name="'
$xml .= PHP_EOL . Indent::_(1) . '<fieldset name="'
. $fieldset . '" label="' . $label . '">';
}
// check if we have an inner field set
@ -1424,25 +1408,25 @@ class Structure extends Get
$field_name_inner
))
{
$xml .= PHP_EOL . $this->_t(1)
$xml .= PHP_EOL . Indent::_(1)
. '<fields name="'
. $field_name_inner . '">';
}
// add the placeholder of the fields
$xml .= $this->hhh . 'FIELDSET_' . $file
. $field_name . $fieldset . $this->hhh;
$xml .= Placefix::_h('FIELDSET_' . $file
. $field_name . $fieldset );
// check if we have an inner field set
if (StringHelper::check(
$field_name_inner
))
{
$xml .= PHP_EOL . $this->_t(1)
$xml .= PHP_EOL . Indent::_(1)
. '</fields>';
}
$xml .= PHP_EOL . $this->_t(1)
$xml .= PHP_EOL . Indent::_(1)
. '</fieldset>';
}
$xml .= PHP_EOL . $this->_t(1) . '</fields>';
$xml .= PHP_EOL . Indent::_(1) . '</fields>';
}
$xml .= PHP_EOL . '</form>';
// add xml to file
@ -1487,7 +1471,7 @@ class Structure extends Get
$this->createFolder($plugin->folder_path . '/language');
// also creat the lang tag folder path
$this->createFolder(
$plugin->folder_path . '/language/' . Config::get('lang_tag', 'en-GB')
$plugin->folder_path . '/language/' . CFactory::_('Config')->get('lang_tag', 'en-GB')
);
// check if this lib has files
if (isset($plugin->files)
@ -1603,7 +1587,7 @@ class Structure extends Get
if (ArrayHelper::check($this->libraries))
{
// Trigger Event: jcb_ce_onBeforeSetLibraries
$this->triggerEvent(
CFactory::_J('Event')->trigger(
'jcb_ce_onBeforeSetLibraries',
array(&$this->componentContext, &$this->libraries)
);
@ -1712,9 +1696,8 @@ class Structure extends Get
if ($addLocalFolder)
{
// add folder to xml of media folders
$this->fileContentStatic[$this->hhh
. 'EXSTRA_MEDIA_FOLDERS' . $this->hhh]
.= PHP_EOL . $this->_t(2) . "<folder>"
$this->fileContentStatic[Placefix::_h('EXSTRA_MEDIA_FOLDERS')]
.= PHP_EOL . Indent::_(2) . "<folder>"
. $libFolder . "</folder>";
}
}
@ -2072,7 +2055,7 @@ class Structure extends Get
$this->joomlaVersionData->move->static
))
{
$codeName = Config::get('component_code_name');
$codeName = CFactory::_('Config')->component_code_name;
// TODO needs more looking at this must be dynamic actually
$this->notNew[] = 'LICENSE.txt';
// do license check
@ -2289,16 +2272,16 @@ class Structure extends Get
if ($add_to_extra)
{
// set the tab
$eTab = $this->_t(2);
$eTab = Indent::_(2);
if ('admin' === $checker[0])
{
$eTab = $this->_t(3);
$eTab = Indent::_(3);
}
// set the xml file
$this->fileContentStatic[$this->hhh . 'EXSTRA_'
$this->fileContentStatic[Placefix::_h('EXSTRA_'
. StringHelper::safe(
$checker[0], 'U'
) . '_' . $eNAME . $this->hhh]
) . '_' . $eNAME)]
.= PHP_EOL . $eTab . "<" . $ename . ">"
. $checker[1] . "</" . $ename . ">";
}
@ -2348,24 +2331,18 @@ class Structure extends Get
{
$target
= array('admin' => $view['settings']->name_list);
$config = array($this->hhh . 'CREATIONDATE'
. $this->hhh => $created,
$this->hhh . 'BUILDDATE'
. $this->hhh => $modified,
$this->hhh . 'VERSION'
. $this->hhh => $view['settings']->version);
$config = array(Placefix::_h('CREATIONDATE') => $created,
Placefix::_h('BUILDDATE') => $modified,
Placefix::_h('VERSION') => $view['settings']->version);
$this->buildDynamique($target, 'list', false, $config);
}
if ($view['settings']->name_single != 'null')
{
$target
= array('admin' => $view['settings']->name_single);
$config = array($this->hhh . 'CREATIONDATE'
. $this->hhh => $created,
$this->hhh . 'BUILDDATE'
. $this->hhh => $modified,
$this->hhh . 'VERSION'
. $this->hhh => $view['settings']->version);
$config = array(Placefix::_h('CREATIONDATE') => $created,
Placefix::_h('BUILDDATE') => $modified,
Placefix::_h('VERSION') => $view['settings']->version);
$this->buildDynamique(
$target, 'single', false, $config
);
@ -2379,12 +2356,9 @@ class Structure extends Get
// setup the front site edit-view files
$target
= array('site' => $view['settings']->name_single);
$config = array($this->hhh . 'CREATIONDATE'
. $this->hhh => $created,
$this->hhh . 'BUILDDATE'
. $this->hhh => $modified,
$this->hhh . 'VERSION'
. $this->hhh => $view['settings']->version);
$config = array(Placefix::_h('CREATIONDATE') => $created,
Placefix::_h('BUILDDATE') => $modified,
Placefix::_h('VERSION') => $view['settings']->version);
$this->buildDynamique($target, 'edit', false, $config);
}
}
@ -2416,24 +2390,18 @@ class Structure extends Get
{
// set list view
$target = array('site' => $view['settings']->code);
$config = array($this->hhh . 'CREATIONDATE'
. $this->hhh => $created,
$this->hhh . 'BUILDDATE'
. $this->hhh => $modified,
$this->hhh . 'VERSION'
. $this->hhh => $view['settings']->version);
$config = array(Placefix::_h('CREATIONDATE') => $created,
Placefix::_h('BUILDDATE') => $modified,
Placefix::_h('VERSION') => $view['settings']->version);
$this->buildDynamique($target, 'list', false, $config);
}
elseif ($view['settings']->main_get->gettype == 1)
{
// set single view
$target = array('site' => $view['settings']->code);
$config = array($this->hhh . 'CREATIONDATE'
. $this->hhh => $created,
$this->hhh . 'BUILDDATE'
. $this->hhh => $modified,
$this->hhh . 'VERSION'
. $this->hhh => $view['settings']->version);
$config = array(Placefix::_h('CREATIONDATE') => $created,
Placefix::_h('BUILDDATE') => $modified,
Placefix::_h('VERSION') => $view['settings']->version);
$this->buildDynamique($target, 'single', false, $config);
}
}
@ -2456,24 +2424,18 @@ class Structure extends Get
{
// set list view$view
$target = array('custom_admin' => $view['settings']->code);
$config = array($this->hhh . 'CREATIONDATE'
. $this->hhh => $created,
$this->hhh . 'BUILDDATE'
. $this->hhh => $modified,
$this->hhh . 'VERSION'
. $this->hhh => $view['settings']->version);
$config = array(Placefix::_h('CREATIONDATE') => $created,
Placefix::_h('BUILDDATE') => $modified,
Placefix::_h('VERSION') => $view['settings']->version);
$this->buildDynamique($target, 'list', false, $config);
}
elseif ($view['settings']->main_get->gettype == 1)
{
// set single view
$target = array('custom_admin' => $view['settings']->code);
$config = array($this->hhh . 'CREATIONDATE'
. $this->hhh => $created,
$this->hhh . 'BUILDDATE'
. $this->hhh => $modified,
$this->hhh . 'VERSION'
. $this->hhh => $view['settings']->version);
$config = array(Placefix::_h('CREATIONDATE') => $created,
Placefix::_h('BUILDDATE') => $modified,
Placefix::_h('VERSION') => $view['settings']->version);
$this->buildDynamique($target, 'single', false, $config);
}
}
@ -2880,7 +2842,7 @@ class Structure extends Get
private function setJoomlaVersionData()
{
// option to load other settings
$custom_settings = $this->templatePath . '/settings_' . Config::get('component_code_name') . '.json';
$custom_settings = $this->templatePath . '/settings_' . CFactory::_('Config')->component_code_name . '.json';
// set the version data
if (File::exists($custom_settings))
{
@ -3123,8 +3085,8 @@ class Structure extends Get
'//', '/', $custom['file']
);
// update the dynamic component name placholders in file names
$custom['path'] = $this->setPlaceholders(
$custom['path'], $this->placeholders
$custom['path'] = CFactory::_('Placeholder')->update(
$custom['path'], CFactory::_('Placeholder')->active
);
// get the path info
$pathInfo = pathinfo($custom['path']);
@ -3263,10 +3225,10 @@ class Structure extends Get
*/
protected function updateDynamicPath($path)
{
return $this->setPlaceholders(
$this->setPlaceholders(
return CFactory::_('Placeholder')->update(
CFactory::_('Placeholder')->update(
$path, ComponentbuilderHelper::$constantPaths
), $this->placeholders
), CFactory::_('Placeholder')->active
);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -3230,6 +3230,8 @@ COM_COMPONENTBUILDER_CONDITIONS="Conditions"
COM_COMPONENTBUILDER_CONFIG_ACTIVE="Active"
COM_COMPONENTBUILDER_CONFIG_ADD_MENU_PREFIX_DESCRIPTION="Would you like to add a prefix to the Joomla menu name of your components"
COM_COMPONENTBUILDER_CONFIG_ADD_MENU_PREFIX_LABEL="Add Menu Prefix"
COM_COMPONENTBUILDER_CONFIG_ADD_PLACEHOLDERS_DESCRIPTION="Should JCB insert the custom code placeholders? This is only applicable if this component has custom code."
COM_COMPONENTBUILDER_CONFIG_ADD_PLACEHOLDERS_LABEL="Add Custom Code Placeholders"
COM_COMPONENTBUILDER_CONFIG_ADMIN_CUSTOM_TABS_TABS="Admin Custom Tabs (tabs)"
COM_COMPONENTBUILDER_CONFIG_ADMIN_FIELDS_ADDFIELDS="Admin Fields (addfields)"
COM_COMPONENTBUILDER_CONFIG_ADMIN_FIELDS_CONDITIONS_ADDCONDITIONS="Admin Fields Conditions (addconditions)"
@ -3341,12 +3343,12 @@ COM_COMPONENTBUILDER_CONFIG_COMPILER_FOLDER_PATH_LABEL="Compiler Folder Path"
COM_COMPONENTBUILDER_CONFIG_COMPILER_FOLDER_PATH_MESSAGE="Error! Please add some text here."
COM_COMPONENTBUILDER_CONFIG_COMPILER_PLUGIN_DESCRIPTION="Select the plugin you would like to use in JCB's compiler"
COM_COMPONENTBUILDER_CONFIG_COMPILER_PLUGIN_LABEL="Activate Compiler Plugins"
COM_COMPONENTBUILDER_CONFIG_COMPONENT="Component"
COM_COMPONENTBUILDER_CONFIG_COMPONENT_ADMIN_VIEWS_ADDADMIN_VIEWS="Component Admin Views (addadmin_views)"
COM_COMPONENTBUILDER_CONFIG_COMPONENT_CUSTOM_ADMIN_MENUS_ADDCUSTOMMENUS="Component Custom Admin Menus (addcustommenus)"
COM_COMPONENTBUILDER_CONFIG_COMPONENT_CUSTOM_ADMIN_VIEWS_ADDCUSTOM_ADMIN_VIEWS="Component Custom Admin Views (addcustom_admin_views)"
COM_COMPONENTBUILDER_CONFIG_COMPONENT_DASHBOARD_DASHBOARD_TAB="Component Dashboard (dashboard_tab)"
COM_COMPONENTBUILDER_CONFIG_COMPONENT_LABEL="Component"
COM_COMPONENTBUILDER_CONFIG_COMPONENT_ID="Component Id"
COM_COMPONENTBUILDER_CONFIG_COMPONENT_ID_LABEL="Component"
COM_COMPONENTBUILDER_CONFIG_COMPONENT_SITE_VIEWS_ADDSITE_VIEWS="Component Site Views (addsite_views)"
COM_COMPONENTBUILDER_CONFIG_COMPONENT_UPDATES_VERSION_UPDATE="Component Updates (version_update)"
COM_COMPONENTBUILDER_CONFIG_CRONJOB_BACKUP_FOLDER_PATH_DESCRIPTION="Here you can set the path to where all components are backed up to."
@ -3604,8 +3606,6 @@ COM_COMPONENTBUILDER_CONFIG_PACKAGE_NAME_PLAEHOLDERS_LABEL="Package Name Placeho
COM_COMPONENTBUILDER_CONFIG_PERCENTAGELANGUAGEADD_DESCRIPTION="Select percentage any language should be translated before the system should add the language to the component during compilation."
COM_COMPONENTBUILDER_CONFIG_PERCENTAGELANGUAGEADD_LABEL="Add Language if %? ready."
COM_COMPONENTBUILDER_CONFIG_PHP_MAIL="PHP Mail"
COM_COMPONENTBUILDER_CONFIG_PLACEHOLDERS_DESCRIPTION="Should JCB insert the custom code placeholders? This is only applicable if this component has custom code."
COM_COMPONENTBUILDER_CONFIG_PLACEHOLDERS_LABEL="Add Custom Code Placeholders"
COM_COMPONENTBUILDER_CONFIG_REMOTE_SERVER="Remote Server"
COM_COMPONENTBUILDER_CONFIG_REPEATABLETABLE_JOOMLA="Repeatable-table (joomla)"
COM_COMPONENTBUILDER_CONFIG_REPEATABLE_JOOMLA="Repeatable (Joomla)"
@ -5597,8 +5597,13 @@ COM_COMPONENTBUILDER_HI="Hi"
COM_COMPONENTBUILDER_HIDE_ONLY="Hide Only"
COM_COMPONENTBUILDER_HIDE_TOGGLE="Hide Toggle"
COM_COMPONENTBUILDER_HOW_TO_GET_A_S_FREE_KEYSA_FROM_VDM="How to get <a %s >free keys</a> from VDM."
COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_ERRORHTHREE="<hr /><h3>External Code Error</h3>"
COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_NOTICEHTHREE="<hr /><h3>External Code Notice</h3>"
COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_WARNINGHTHREE="<hr /><h3>External Code Warning</h3>"
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_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_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. 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_HTWOCURL_NOT_FOUNDHTWOPPLEASE_SETUP_CURL_ON_YOUR_SYSTEM_OR_BCOMPONENTBUILDERB_WILL_NOT_FUNCTION_CORRECTLYP="<h2>Curl Not Found!</h2><p>Please setup curl on your system, or <b>componentbuilder</b> will not function correctly!</p>"
COM_COMPONENTBUILDER_HTWODATA_IS_CORRUPTHTWOTHIS_COULD_BE_DUE_TO_BKEY_ERRORB_OR_BROKEN_PACKAGE="<h2>Data is corrupt!</h2>This could be due to <b>key error</b>, or broken package!"
COM_COMPONENTBUILDER_HTWODATA_IS_CORRUPTHTWOTHIS_COULD_BE_DUE_TO_BROKEN_PACKAGE="<h2>Data is corrupt!</h2>This could be due to broken package!"
@ -5607,6 +5612,7 @@ COM_COMPONENTBUILDER_HTWOWE_COULD_NOT_OPEN_THE_PACKAGEHTWOTHIS_COULD_BE_DUE_TO_T
COM_COMPONENTBUILDER_IAUTHORI_BSB="<i>Author:</i> <b>%s</b>"
COM_COMPONENTBUILDER_ICOMPANYI_BSB="<i>Company:</i> <b>%s</b>"
COM_COMPONENTBUILDER_ICON="Icon"
COM_COMPONENTBUILDER_ID_MISMATCH_WAS_DETECTED_WITH_THE_SSSS_GUI_CODE_FIELD_SO_THE_PLACEHOLDER_WAS_NOT_SET="ID mismatch was detected with the %s.%s.%s.%s GUI code field. So the placeholder was not set."
COM_COMPONENTBUILDER_IEMAILI_BSB="<i>Email:</i> <b>%s</b>"
COM_COMPONENTBUILDER_IMPORT_BY_GUID_ONLY="Import by GUID only!"
COM_COMPONENTBUILDER_IMPORT_CONTINUE="Continue"
@ -8108,12 +8114,14 @@ COM_COMPONENTBUILDER_POWER_USE_SELECTION_LABEL="Use Selection"
COM_COMPONENTBUILDER_POWER_VERSION_DESC="A count of the number of times this Power has been revised."
COM_COMPONENTBUILDER_POWER_VERSION_LABEL="Version"
COM_COMPONENTBUILDER_POWER_YES="Yes"
COM_COMPONENTBUILDER_PPOWER_BGUIDSB_NOT_FOUNDP="<p>Power <b>guid:%s</b> not found!</p>"
COM_COMPONENTBUILDER_PROPERTIES="Properties"
COM_COMPONENTBUILDER_PROPERTIESBR_SMALLHERE_YOU_CAN_SET_THE_PROPERTIES_FOR_THIS_FIELDSMALL="Properties<br /><small>Here you can set the properties for this field.</small>"
COM_COMPONENTBUILDER_PROPERTY="Property"
COM_COMPONENTBUILDER_PROPERTY_ALREADY_SELECTED_TRY_ANOTHER="Property already selected, try another."
COM_COMPONENTBUILDER_PROPERTY_NAME="Property Name"
COM_COMPONENTBUILDER_PROPERTY_VALUE="Property Value"
COM_COMPONENTBUILDER_PS_NAMING_MISMATCH_ERROR_SPPTHE_S_NAME_IS_BSB_AND_THE_ENDING_FILE_NAME_IN_THE_NAMESPACE_IS_BSB_THIS_IS_BAD_CONVENTION_PLEASE_SEE_A_HREFS_PSRFOURA_FOR_MORE_INFOPPA_HREFSCLICK_HEREA_TO_FIX_THIS_ISSUEP="<p>%s naming mismatch error (%s)</p><p>The %s name is <b>%s</b> and the ending file name in the namespace is <b>%s</b>. This is bad convention, please see <a href=%s >psr-4</a> for more info.</p><p><a href=%s>Click here</a> to fix this issue.</p>"
COM_COMPONENTBUILDER_PUBLIC_ACCESS="Public Access"
COM_COMPONENTBUILDER_PUBLISHED="Published"
COM_COMPONENTBUILDER_PUBLISHING="Publishing"
@ -8967,6 +8975,8 @@ COM_COMPONENTBUILDER_S_BEING_IMPORTED="%s Being Imported"
COM_COMPONENTBUILDER_S_NOT_LINKED="%s Not Linked"
COM_COMPONENTBUILDER_S_PLEASE_WAIT="%s, please wait!"
COM_COMPONENTBUILDER_S_S_NUMBER_BSB_COULD_NOT_BE_DOWNLOADED_SUCCESSFULLY_TO_THIS_JOOMLA_INSTALL="%s (%s) number <b>%s</b> could not be downloaded successfully to this Joomla Install!"
COM_COMPONENTBUILDER_S_WE_DETECTED_A_CHANGE_IN_BEXTERNALCODEB_BUT_YOU_DO_NOT_HAVE_PERMISSION_TO_ALLOW_THIS_CHANGE_SO_BSB_WAS_REMOVED_FROM_THE_COMPILATION_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFOBR_SMALLADMIN_ACCESS_REQUIREDSMALL="%s, we detected a change in <b>EXTERNALCODE</b>, but you do not have permission to allow this change so <b>%s</b> was removed from the compilation. Please contact your system administrator for more info!<br /><small>(admin access required)</small>"
COM_COMPONENTBUILDER_S_WE_DETECTED_BNEW_EXTERNALCODEB_BUT_YOU_DO_NOT_HAVE_PERMISSION_TO_ALLOW_THIS_NEW_CODESTRING_SO_BSB_WAS_REMOVED_FROM_THE_COMPILATION_PLEASE_CONTACT_YOU_SYSTEM_ADMINISTRATOR_FOR_MORE_INFOBR_SMALLADMIN_ACCESS_REQUIREDSMALL="%s, we detected <b>NEW EXTERNALCODE</b>, but you do not have permission to allow this new code/string so <b>%s</b> was removed from the compilation. Please contact you system administrator for more info!<br /><small>(admin access required)</small>"
COM_COMPONENTBUILDER_TAB="Tab"
COM_COMPONENTBUILDER_TABLE_BSB_NOT_FOUND_IN_THE_LOCAL_DATABASE_SO_ITS_VALUES_COULD_NOT_BE_IMPORTED_PLEASE_UPDATE_YOUR_JCB_INSTALL_AND_TRY_AGAIN="Table <b>%s</b> not found in the local database so its values could not be imported, please update your JCB install and try again."
COM_COMPONENTBUILDER_TABLE_BSB_NOT_FOUND_IN_THE_LOCAL_DATABASE_SO_ITS_VALUES_COULD_NOT_BE_IMPORTED_THE_WHOLE_POWERS_FEATURE_IS_ONLY_AVAILABLE_TO_A_HREFSPRO_MEMBERSA_AT_THIS_TIME="Table <b>%s</b> not found in the local database so its values could not be imported. The whole powers feature is only available to <a href=%s>PRO Members</a> at this time."
@ -9110,12 +9120,17 @@ COM_COMPONENTBUILDER_THE_BNONE_DBB_OPTION_WILL_REMOVE_THIS_FIELD_FROM_BEING_SAVE
COM_COMPONENTBUILDER_THE_BONLY_IN_ADMIN_LIST_VIEWB_OPTION_WILL_ONLY_ADD_THIS_FIELD_TO_THE_ADMIN_LIST_VIEW_NOT_TO_ANY_LINKED_VIEWS="The <b>Only in Admin List View</b> option will only Add this field to the admin list view, not to any linked views."
COM_COMPONENTBUILDER_THE_BONLY_IN_LINKED_LIST_VIEWSB_OPTION_WILL_ONLY_ADD_THIS_FIELD_TO_THE_LINKED_LIST_VIEW_IF_THIS_VIEW_GETS_LINKED_TO_OTHER_VIEW_NOT_TO_THIS_ADMIN_LIST_VIEW="The <b>Only in Linked List Views</b> option will only Add this field to the linked list view, if this view gets linked to other view, not to this admin list view."
COM_COMPONENTBUILDER_THE_BPHPSECLIBNETSFTPB_LIBRARYCLASS_IS_NOT_AVAILABLE_THIS_LIBRARYCLASS_SHOULD_HAVE_BEEN_ADDED_TO_YOUR_BLIBRARIESVDM_IOVENDORB_FOLDER_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFO="The <b>phpseclib\NET\SFTP</b> library\class is not available! This library\class should have been added to your <b>libraries/vdm_io/vendor</b> folder. Please contact your system administrator for more info"
COM_COMPONENTBUILDER_THE_BSB_CUT_SEQUENCE_FAILED_ON_THE_RETURNED_EXTERNAL_CODESTRING_AS_MORE_LINES_HAS_TO_BE_CUT_THEN_WAS_FOUND_IN_THE_CODESTRING_WE_HAVE_COMPLETELY_REMOVED_THE_CODE_PLEASE_CHECK_THIS_CODESTRING="The <b>%s</b> cut sequence failed on the returned external code/string as more lines has to be cut then was found in the code/string. We have completely removed the code. Please check this code/string!"
COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_PATH_ON_BSB_SERVER="The <b>%s</b> file could not be moved to <b>%s</b> path on <b>%s</b> server."
COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_SERVER="The <b>%s</b> file could not be moved to <b>%s</b> server."
COM_COMPONENTBUILDER_THE_BSB_IS_NOT_A_VALID_URLPATH="The <b>%s</b> is not a valid url/path!"
COM_COMPONENTBUILDER_THE_BSB_LIBRARYCLASS_IS_NOT_AVAILABLE_THIS_LIBRARYCLASS_SHOULD_HAVE_BEEN_ADDED_TO_YOUR_BLIBRARIESPHPSECLIBVENDORB_FOLDER_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFO="The <b>%s</b> library\class is not available! This library\class should have been added to your <b>libraries/phpseclib/vendor</b> folder. Please contact your system administrator for more info!"
COM_COMPONENTBUILDER_THE_BSB_LIBRARY_CAN_NOT_BE_DELETED_OR_THINGS_WILL_BREAK="The <b>%s</b> library can not be deleted, or things will break."
COM_COMPONENTBUILDER_THE_BSB_RETURNED_AN_INVALID_STRING="The <b>%s</b> returned an invalid string!"
COM_COMPONENTBUILDER_THE_BSHOW_IN_ALL_LIST_VIEWSB_OPTION_WILL_ADD_THIS_FIELD_TO_ALL_LIST_VIEWS_ADMIN_AMP_LINKED="The <b>Show in All List Views</b> option will Add this field to all list views, admin &amp; linked."
COM_COMPONENTBUILDER_THE_BSINGLE_FILTERB_SELECTION_OPTION_ALLOWS_THE_USER_TO_SELECT_JUST_ONE_VALUE_IN_THIS_FILTERFIELD="The <b>single filter</b> selection option allows the user to select just one value in this filter/field."
COM_COMPONENTBUILDER_THE_CODESTRING_FROM_BSB_HAS_BEEN_ADDED_FOR_THE_BFIRST_TIMEB_PLEASE_IINVESTIGATEI_TO_ENSURE_THE_CORRECT_CODESTRING_WAS_USED_BSHOULD_YOU_NOT_KNOW_ABOUT_THIS_NEW_EXTERNAL_CODESTRING_BEING_ADDED_THEN_THIS_IS_A_SERIOUS_DANGER_AND_REQUIRES_IMMEDIATE_ATTENTIONB_DO_NOT_IGNORE_THIS_WARNING_AS_IT_WILL_ONLY_SHOW_BONCEB="The code/string from <b>%s</b> has been added for the <b>first time</b>. Please <i>investigate</i> to ensure the correct code/string was used! <b>Should you not know about this NEW external code/string being added, then this is a serious danger! and requires immediate attention!</b> Do not ignore this warning as it will only show <b>once</b>."
COM_COMPONENTBUILDER_THE_CODESTRING_FROM_BSB_HAS_BEEN_BCHANGEDB_SINCE_THE_LAST_COMPILATION_PLEASE_INVESTIGATE_TO_ENSURE_THE_CHANGES_ARE_SAFE_BSHOULD_YOU_NOT_EXPECT_THIS_CHANGE_TO_THE_EXTERNAL_CODESTRING_BEING_ADDED_THEN_THIS_IS_A_SERIOUS_ISSUE_AND_REQUIRES_IMMEDIATE_ATTENTIONB_DO_NOT_IGNORE_THIS_WARNING_AS_IT_WILL_ONLY_SHOW_BONCEB="The code/string from <b>%s</b> has been <b>changed</b> since the last compilation. Please investigate to ensure the changes are safe! <b>Should you not expect this change to the external code/string being added, then this is a serious issue! and requires immediate attention!</b> Do not ignore this warning as it will only show <b>once</b>."
COM_COMPONENTBUILDER_THE_COMPONENT="The Component"
COM_COMPONENTBUILDER_THE_COMPONENT_ADMIN_VIEWS="The component admin views"
COM_COMPONENTBUILDER_THE_COMPONENT_CONFIG="The component config"

View File

@ -202,18 +202,10 @@ class ComponentbuilderModelCompiler extends ListModel
return true;
}
public function builder($version, $id, $backup, $repo, $addPlaceholders, $addPowers, $debugLinenr, $minify)
public function builder()
{
$set['version'] = $version;
$set['component'] = $id;
$set['backup'] = $backup;
$set['repository'] = $repo;
$set['placeholders'] = $addPlaceholders;
$set['powers'] = $addPowers;
$set['debuglinenr'] = $debugLinenr;
$set['minify'] = $minify;
// run compiler
$this->compiler = new Compiler($set);
$this->compiler = new Compiler();
if($this->compiler)
{
return true;

View File

@ -158,6 +158,8 @@ class ComponentbuilderModelPowers extends ListModel
continue;
}
// remove dots
$item->namespace = str_replace('.','\\', $item->namespace);
}
}

View File

@ -33,7 +33,7 @@ Joomla.submitbutton = function(task, key)
if (task == ''){
return false;
} else {
var component = jQuery('#component').val();
var component = jQuery('#component_id').val();
var isValid = true;
if(component == '' && task == 'compiler.compiler'){
@ -56,7 +56,7 @@ Joomla.submitbutton = function(task, key)
// some ui movements
if (task == 'compiler.compiler'){
// get the component name
let component_name = jQuery("#component option:selected").text();
let component_name = jQuery("#component_id option:selected").text();
// set the component name
jQuery(".component-name").text(component_name);
// wait a little since to much is happening...
@ -189,9 +189,9 @@ jQuery('<div id="compiling"></div>')
// token
var token = '<?= JSession::getFormToken() ?>';
var all_is_good = '<?= JText::_('COM_COMPONENTBUILDER_ALL_IS_GOOD_THERE_IS_NO_NOTICE_AT_THIS_TIME') ?>';
jQuery('#compilerForm').on('change', '#component',function (e)
jQuery('#compilerForm').on('change', '#component_id',function (e)
{
var component = jQuery('#component').val();
var component = jQuery('#component_id').val();
if(component == "") {
jQuery('#component-details').html("<?= $selectNotice ?>");
jQuery("#noticeboard").show();

View File

@ -133,7 +133,7 @@ class ComponentbuilderViewCompiler extends HtmlView
// placeholders attributes
$attributes = array(
'type' => 'radio',
'name' => 'placeholders',
'name' => 'add_placeholders',
'label' => 'COM_COMPONENTBUILDER_ADD_CUSTOM_CODE_PLACEHOLDERS',
'class' => 'btn-group btn-group-yesno',
'description' => 'COM_COMPONENTBUILDER_SHOULD_JCB_INSERT_THE_CUSTOM_CODE_PLACEHOLDERS_THIS_IS_ONLY_APPLICABLE_IF_THIS_COMPONENT_HAS_CUSTOM_CODE',
@ -148,7 +148,7 @@ class ComponentbuilderViewCompiler extends HtmlView
// debuglinenr attributes
$attributes = array(
'type' => 'radio',
'name' => 'debuglinenr',
'name' => 'debug_line_nr',
'label' => 'COM_COMPONENTBUILDER_DEBUG_LINE_NUMBERS',
'class' => 'btn-group btn-group-yesno',
'description' => 'COM_COMPONENTBUILDER_ADD_CORRESPONDING_LINE_NUMBERS_TO_THE_DYNAMIC_COMMENTS_SO_TO_SEE_WHERE_IN_THE_COMPILER_THE_LINES_OF_CODE_WAS_BUILD_THIS_WILL_HELP_IF_YOU_NEED_TO_GET_MORE_TECHNICAL_WITH_AN_ISSUE_ON_GITHUB_OR_EVEN_FOR_YOUR_OWN_DEBUGGING',
@ -190,7 +190,7 @@ class ComponentbuilderViewCompiler extends HtmlView
// component attributes
$attributes = array(
'type' => 'list',
'name' => 'component',
'name' => 'component_id',
'label' => 'COM_COMPONENTBUILDER_COMPONENTS',
'class' => 'list_class',
'description' => 'COM_COMPONENTBUILDER_SELECT_THE_COMPONENT_TO_COMPILE',

View File

@ -71,7 +71,7 @@ $edit = "index.php?option=com_componentbuilder&view=powers&task=power.edit";
</div>
</td>
<td class="hidden-phone">
<?php echo $this->escape($item->namespace); ?>
<?php echo $item->namespace; ?>
</td>
<td class="hidden-phone">
<div><?php echo JText::_('COM_COMPONENTBUILDER_TYPE'); ?>:
@ -80,7 +80,8 @@ $edit = "index.php?option=com_componentbuilder&view=powers&task=power.edit";
<a href="index.php?option=com_componentbuilder&view=powers&task=power.edit&id=<?php echo $item->extends_id; ?>&return=<?php echo $this->return_here; ?>"><?php echo $this->escape($item->extends_name); ?></a>
<?php else: ?>
<?php echo $this->escape($item->extends_name); ?>
<?php endif; ?><?php endif; ?>
<?php endif; ?><?php elseif ($item->extends === '-1') : ?><br /><?php echo JText::_('COM_COMPONENTBUILDER_EXTENDS'); ?>:
<?php echo $this->escape($item->extends_custom); ?><?php endif; ?>
</div>
</td>
<td class="hidden-phone">

View File

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

View File

@ -0,0 +1,144 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
/**
* Get a Components Global Placeholders
*
* @since 3.2.0
*/
class Placeholder
{
/**
* Placeholders
*
* @var arraya
* @since 3.2.0
**/
protected $placeholders = null;
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected $config;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected $db;
/**
* Constructor.
*
* @param Config $config The compiler config object.
* @param \JDatabaseDriver $db The Database Driver object.
*
* @since 3.2.0
**/
public function __construct(?Config $config = null, ?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->db = $db ?: Factory::getDbo();
}
/**
* get all System Placeholders
*
* @return array The global placeholders
*
* @since 3.2.0
*/
public function get()
{
// set only once
if (is_array($this->placeholders))
{
return $this->placeholders;
}
// load the config
$config = $this->config;
// load the db
$db = $this->db;
// reset bucket
$bucket = array();
// Create a new query object.
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.target', 'a.value')));
// from these tables
$query->from('#__componentbuilder_placeholder AS a');
// Reset the query using our newly populated query object.
$db->setQuery($query);
// Load the items
$db->execute();
if ($db->getNumRows())
{
$bucket = $db->loadAssocList('target', 'value');
// open all the code
foreach ($bucket as $key => &$code)
{
$code = base64_decode($code);
}
}
// set component place holders
$bucket[Placefix::_h('component')] = $config->component_code_name;
$bucket[Placefix::_h('Component')] = StringHelper::safe($config->component_code_name, 'F');
$bucket[Placefix::_h('COMPONENT')] = StringHelper::safe($config->component_code_name, 'U');
$bucket[Placefix::_('component')] = $bucket[Placefix::_h('component')];
$bucket[Placefix::_('Component')] = $bucket[Placefix::_h('Component')];
$bucket[Placefix::_('COMPONENT')] = $bucket[Placefix::_h('COMPONENT')];
$bucket[Placefix::_h('LANG_PREFIX')] = $config->lang_prefix;
$bucket[Placefix::_('LANG_PREFIX')] = $bucket[Placefix::_h('LANG_PREFIX')];
// get the current components overrides
if (($_placeholders = GetHelper::var(
'component_placeholders', $config->component_id,
'joomla_component', 'addplaceholders'
)) !== false
&& JsonHelper::check($_placeholders))
{
$_placeholders = json_decode($_placeholders, true);
if (ArrayHelper::check($_placeholders))
{
foreach ($_placeholders as $row)
{
$bucket[$row['target']] = $row['value'];
}
}
}
$this->placeholders = $bucket;
return $bucket;
}
}

View File

@ -12,167 +12,492 @@
namespace VDM\Joomla\Componentbuilder\Compiler;
use Joomla\Registry\Registry;
use Joomla\Registry\Registry;
use Joomla\CMS\Factory;
use Joomla\Input\Input;
use VDM\Joomla\Utilities\Component\Helper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
/**
* Compiler Configurations Registry
* Compiler Configurations
*
* @since 3.1.6
* @since 3.2.0
*/
class Config extends Registry implements \JsonSerializable, \ArrayAccess, \IteratorAggregate, \Countable
{
/**
* Hold a JInput object for easier access to the input variables.
*
* @var Input
* @since 3.2.0
*/
protected $input;
/**
* The Params
*
* @var Registry
* @since 3.1.6
* @since 3.2.0
*/
protected Registry $params;
/**
* Constructor
*
* @param array $config The data to bind to the new Config object.
* @param Registry $params The component parameters
* @param Input|null $input Input
* @param Registry|null $params The component parameters
*
* @since 3.1.6
* @throws \Exception
* @since 3.2.0
*/
public function __construct(array $config, ?Registry $params = null)
public function __construct(?Input $input = null, ?Registry $params = null)
{
// Set the params
$this->input = $input ?: Factory::getApplication()->input;
$this->params = $params ?: Helper::getParams('com_componentbuilder');
// Instantiate the internal data object.
$this->data = new \stdClass;
// use underscore as the separator
$this->separator = '_';
// Load the config to the data object
$this->bindData($this->data, $this->modelConfig($config));
// Instantiate the internal data object.
$this->data = new \stdClass();
}
/**
* model the configuration data array
* setting any config value
*
* @param array $config The data to bind to the new Config object.
* @param String $key The value's key/path name
* @param mixed $value Optional default value, returned if the internal value is null.
*
* @return array
* @since 3.1.6
* @since 3.2.0
*/
protected function modelConfig(array $config): array
public function __set($key, $value)
{
// we do not yet have this set as an option
$config['remove_line_breaks']
= 2; // 2 is global (use the components value)
$this->set($key, $value);
}
// set the minfy switch of the JavaScript
$config['minify'] = (isset($config['minify']) && $config['minify'] != 2)
? $config['minify'] : $this->params->get('minify', 0);
/**
* getting any valid value
*
* @param String $key The value's key/path name
*
* @since 3.2.0
* @throws \InvalidArgumentException If $key is not a valid function name.
*/
public function __get($key)
{
// function name with no underscores
$method = 'get' . ucfirst(ClassfunctionHelper::safe(str_replace('_', '', $key)));
// set the global language
$config['lang_tag'] = $this->params->get('language', 'en-GB');
if (($value = $this->get($key, '__N0T_S3T_')) !== '__N0T_S3T_')
{
return $value;
}
elseif (method_exists($this, $method))
{
$value = $this->{$method}();
// check if we have Tidy enabled
$config['tidy'] = extension_loaded('Tidy');
$this->set($key, $value);
// set the field type builder
$config['field_builder_type'] = $this->params->get(
'compiler_field_builder_type', 2
return $value;
}
throw new \InvalidArgumentException(sprintf('Argument %s could not be found as function [%s], or path.', $key, $method));
}
/**
* Get a registry value.
*
* @param string $path Registry path (e.g. joomla.content.showauthor)
* @param mixed $default Optional default value, returned if the internal value is null.
*
* @return mixed Value of entry or null
*
* @since 3.2.0
*/
public function get($path, $default = null)
{
// function name with no underscores
$method = 'get' . ucfirst(ClassfunctionHelper::safe(str_replace('_', '', $path)));
// check if it has been set
if (($value = parent::get($path, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')
{
return $value;
}
elseif (method_exists($this, $method))
{
$value = $this->{$method}();
$this->set($path, $value);
return $value;
}
return $default;
}
/**
* get posted component id
*
* @return int Component id
* @since 3.2.0
*/
protected function getComponentid(): int
{
return $this->input->post->get('component_id', 0, 'INT');
}
/**
* get components code name
*
* @return string The components code name
* @since 3.2.0
*/
protected function getComponentcodename(): string
{
// get components code name
return StringHelper::safe(GetHelper::var(
'joomla_component', $this->component_id, 'id', 'name_code'
));
}
/**
* get component context
*
* @return string The component context
* @since 3.2.0
*/
protected function getComponentcontext(): string
{
// get component context
return $this->component_code_name . '.' . $this->component_id;
}
/**
* get component code name length
*
* @return int The component code name length
* @since 3.2.0
*/
protected function getComponentcodenamelength(): int
{
// get component name length
return strlen($this->component_code_name);
}
/**
* get posted Joomla version
*
* @return int Joomla version code
* @since 3.2.0
*/
protected function getJoomlaversion(): int
{
return $this->input->post->get('joomla_version', 3, 'INT');
}
/**
* get posted Joomla version name
*
* @return string Joomla version code name
* @since 3.2.0
*/
protected function getJoomlaversionname(): string
{
return StringHelper::safe($this->joomla_version);
}
/**
* get indentation value
*
* @return string Indentation value
* @since 3.2.0
*/
protected function getIndentationvalue(): string
{
return "\t"; // TODO add to GUI as an Global Option?
}
/**
* get posted backup switch
*
* @return int Backup switch number
* @since 3.2.0
*/
protected function getBackup(): int
{
return $this->input->post->get('backup', 0, 'INT');
}
/**
* get posted repository switch
*
* @return int Repository switch number
* @since 3.2.0
*/
protected function getRepository(): int
{
return $this->input->post->get('repository', 0, 'INT');
}
/**
* get posted debuglinenr switch
*
* @return int Debuglinenr switch number
* @since 3.2.0
*/
protected function getDebuglinenr(): int
{
// get posted value
$value = $this->input->post->get('debug_line_nr', 2, 'INT');
// get active value
$add = ($value == 0) ? false : (
($value == 1) ? true : (
((int) GetHelper::var('joomla_component', $this->component_id, 'id', 'debug_linenr' ) == 1) ? true : false
)
);
// load the compiler path
$config['compiler_path'] = $this->params->get(
return $add;
}
/**
* get posted minify switch
*
* @return int Minify switch number
* @since 3.2.0
*/
protected function getMinify(): int
{
$minify = $this->input->post->get('minify', 2, 'INT');
// if value is 2 use global value
$minify = ($minify != 2) ? $minify : $this->params->get('minify', 0);
return $minify;
}
/**
* get posted remove line breaks switch
*
* @return bool Remove line breaks switch number
* @since 3.2.0
*/
protected function getRemovelinebreaks(): bool
{
$value = 2; // 2 is global (use the components value) TODO: get from post
// get active value
$remove = ($value == 0) ? false : (
($value == 1) ? true : (
((int) GetHelper::var('joomla_component', $this->component_id, 'id', 'remove_line_breaks' ) == 1) ? true : false
)
);
return $remove;
}
/**
* get system tidy state
*
* @return bool Tidy is active
* @since 3.2.0
*/
protected function getTidy(): bool
{
// check if we have Tidy enabled
return \extension_loaded('Tidy');
}
/**
* get language tag
*
* @return string The active language tag
* @since 3.2.0
*/
protected function getLangtag(): string
{
// get the global language
return $this->params->get('language', 'en-GB');
}
/**
* get language prefix
*
* @return string The language prefix
* @since 3.2.0
*/
protected function getLangprefix(): string
{
// get components code name
return 'COM_' . StringHelper::safe(GetHelper::var(
'joomla_component', $this->component_id, 'id', 'name_code'
), 'U');
}
/**
* get language target
*
* @return string The language active target
* @since 3.2.0
*/
protected function getLangtarget(): string
{
// we start with admin
// but this is a switch value and is changed many times
return 'admin';
}
/**
* get language string targets
*
* @return array The language prefix
* @since 3.2.0
*/
protected function getLangstringtargets(): array
{
// these strings are used to search for language strings in all content
return array_values($this->lang_string_key_targets);
}
/**
* get language string targets (by key name)
*
* @return array The language prefix
* @since 3.2.0
*/
protected function getLangstringkeytargets(): array
{
// these strings are used to search for language strings in all content
return [
'jjt' => 'Joomla' . '.JText._(',
'js' => 'JText:' . ':script(',
't' => 'Text:' . ':_(', // namespace and J version will be found
'ts' => 'Text:' . ':sprintf(', // namespace and J version will be found
'jt' => 'JustTEXT:' . ':_('
];
}
/**
* get field builder type
*
* @return int The field builder type
* @since 3.2.0
*/
protected function getFieldbuildertype(): int
{
// get the field type builder
return $this->params->get(
'compiler_field_builder_type', 2
);
}
/**
* get compiler path
*
* @return string The compiler path
* @since 3.2.0
*/
protected function getCompilerpath(): string
{
// get the compiler path
return $this->params->get(
'compiler_folder_path',
JPATH_COMPONENT_ADMINISTRATOR . '/compiler'
);
}
// load the jcb powers path
$config['jcb_powers_path'] = $this->params->get(
'jcb_powers_path',
'libraries/jcb_powers');
/**
* get jcb powers path
*
* @return string The jcb powers path
* @since 3.2.0
*/
protected function getJcbpowerspath(): string
{
// get jcb powers path
return $this->params->get('jcb_powers_path', 'libraries/jcb_powers');
}
// set the component ID
$config['component_id'] = (int)$config['component'];
// TODO set up stream correctly
unset($config['component']);
/**
* get switch to add assets table fix
*
* @return int Switch number to add assets table fix
* @since 3.2.0
*/
protected function getAddassetstablefix(): int
{
// get global add assets table fix
$global = $this->params->get(
'assets_table_fix', 1
);
// set this components code name
if ($name_code = GetHelper::var(
'joomla_component', $config['component_id'], 'id', 'name_code'
)) {
// set lang prefix
$config['lang_prefix'] = 'COM_' . StringHelper::safe(
$name_code, 'U'
);
// get component value
$add = (($add_assets_table_fix = (int) GetHelper::var(
'joomla_component', $this->component_id, 'id',
'assets_table_fix'
)) == 3) ? $global : $add_assets_table_fix;
// set component code name
$config['component_code_name'] = StringHelper::safe(
$name_code
);
return $add;
}
// set component context
$config['component_context'] = $config['component_code_name'] . '.'
. $config['component_id'];
/**
* get switch add placeholders
*
* @return bool Switch to add placeholders
* @since 3.2.0
*/
protected function getAddplaceholders(): bool
{
// get posted value
$value = $this->input->post->get('add_placeholders', 2, 'INT');
// set the component name length
$config['component_code_name_length'] = strlen(
$config['component_code_name']
);
// get active value
$add = ($value == 0) ? false : (
($value == 1) ? true : (
((int) GetHelper::var('joomla_component', $this->component_id, 'id', 'add_placeholders' ) == 1) ? true : false
)
);
// add assets table fix
$global = (int)$this->params->get(
'assets_table_fix', 1
);
$config['add_assets_table_fix'] = (($add_assets_table_fix
= (int)GetHelper::var(
'joomla_component', $config['component_id'], 'id',
'assets_table_fix'
)) == 3) ? $global : $add_assets_table_fix;
return $add;
}
// set if language strings line breaks should be removed
$global = ((int)GetHelper::var(
'joomla_component', $config['component_id'], 'id',
'remove_line_breaks'
) == 1) ? true : false;
$config['remove_line_breaks'] = ((int)$config['remove_line_breaks']
== 0)
? false
: (((int)$config['remove_line_breaks'] == 1) ? true
: $global);
/**
* get switch add power
*
* @return bool Switch to add power
* @since 3.2.0
*/
protected function getAddpower(): bool
{
// get posted value
$value = $this->input->post->get('powers', 2, 'INT');
// set if placeholders should be added to customcode
$global = ((int)GetHelper::var(
'joomla_component', $config['component_id'], 'id',
'add_placeholders'
) == 1) ? true : false;
$config['add_placeholders'] = ((int)$config['placeholders'] == 0)
? false
: (((int)$config['placeholders'] == 1) ? true : $global);
// TODO set up stream correctly
unset($config['placeholders']);
// get active value
$add = ($value == 0) ? false : (
($value == 1) ? true : (
((int) GetHelper::var('joomla_component', $this->component_id, 'id', 'add_powers' ) == 1) ? true : false
)
);
// set if line numbers should be added to comments
$global = ((int)GetHelper::var(
'joomla_component', $config['component_id'], 'id',
'debug_linenr'
) == 1) ? true : false;
$config['debug_line_nr'] = ((int)$config['debuglinenr'] == 0) ? false
: (((int)$config['debuglinenr'] == 1) ? true : $global);
return $add;
}
// set if powers should be added to component (default is true)
$global = ((int)GetHelper::var(
'joomla_component', $config['component_id'], 'id',
'add_powers'
) == 1) ? true : false;
$config['add_power'] = (isset($config['powers']) && (int)$config['powers'] == 0)
? false : ((isset($config['powers']) && (int)$config['powers'] == 1) ? true : $global);
// TODO set up stream correctly
unset($config['powers']);
}
return $config;
}
/**
* get switch build target switch
*
* @return string Switch to control the build flow
* @since 3.2.0
*/
protected function getBuildtarget(): string
{
// we start with admin
// but this is a switch value and is changed many times
return 'admin';
}
}

View File

@ -0,0 +1,635 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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 Joomla\CMS\Factory;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language\Extractor;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\External;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
/**
* Compiler Custom Code
*
* @since 3.2.0
*/
class Customcode
{
/**
* The function name memory ids
*
* @var array
* @since 3.2.0
**/
public array $functionNameMemory = [];
/**
* The active custom code
*
* @var array
* @since 3.2.0
*/
public $active = [];
/**
* The custom code memory
*
* @var array
* @since 3.2.0
*/
public $memory = [];
/**
* The placeholders for custom code keys
*
* @var array
*/
protected $keys
= array(
'&#91;' => '[',
'&#93;' => ']',
'&#44;' => ',',
'&#43;' => '+',
'&#61;' => '='
);
/**
* The custom code to be added
*
* @var array
* @since 3.2.0
*/
protected $data = [];
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected Config $config;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Compiler Language Extractor
*
* @var Extractor
* @since 3.2.0
**/
protected Extractor $extractor;
/**
* Compiler Custom Code External
*
* @var External
* @since 3.2.0
**/
protected External $external;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected $db;
/**
* Constructor.
*
* @param Config|null $config The compiler config object.
* @param Placeholder|null $placeholder The compiler placeholder object.
* @param Extract|null $extractor The compiler language extractor object.
* @param External|null $external The compiler external custom code object.
* @param \JDatabaseDriver $db The Database Driver object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Placeholder $placeholder = null,
?Extractor $extractor = null, ?External $external = null, ?\JDatabaseDriver $db = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->extractor = $extractor ?: Compiler::_('Language.Extractor');
$this->external = $external ?: Compiler::_('Customcode.External');
$this->db = $db ?: Factory::getDbo();
}
/**
* Set the **ALL** dynamic values in a strings here
*
* @param string $string The content to check
* @param int $debug The switch to debug the update
* We can now at any time debug the
* dynamic build values if it gets broken
*
* @return string
* @since 3.2.0
*/
public function add(string $string, int $debug = 0): string
{
if (StringHelper::check($string))
{
$string = $this->extractor->engine(
$this->set(
$this->external->set($string, $debug), $debug
)
);
}
// if debug
if ($debug)
{
jexit();
}
return $string;
}
/**
* We start set the custom code data & can load it in to string
*
* @param string $string The content to check
* @param int $debug The switch to debug the update
* @param int|null $not The not switch
*
* @return string
* @since 3.2.0
*/
public function set(string $string, int $debug = 0, ?int $not = null): string
{
// insure the code is loaded
$loaded = false;
// check if content has custom code place holder
if (strpos($string, '[CUSTO' . 'MCODE=') !== false)
{
// if debug
if ($debug)
{
echo 'Custom Code String:';
var_dump($string);
}
// the ids found in this content
$bucket = array();
$found = GetHelper::allBetween(
$string, '[CUSTO' . 'MCODE=', ']'
);
if (ArrayHelper::check($found))
{
foreach ($found as $key)
{
// if debug
if ($debug)
{
echo '$key before update:';
var_dump($key);
}
// check if we have args
if (is_numeric($key))
{
$id = (int) $key;
}
elseif (StringHelper::check($key)
&& strpos(
$key, '+'
) === false)
{
$getFuncName = trim($key);
if (!isset($this->functionNameMemory[$getFuncName]))
{
if (!$found_local = GetHelper::var(
'custom_code', $getFuncName, 'function_name',
'id'
))
{
continue;
}
$this->functionNameMemory[$getFuncName]
= $found_local;
}
$id = (int) $this->functionNameMemory[$getFuncName];
}
elseif (StringHelper::check($key)
&& strpos(
$key, '+'
) !== false)
{
$array = explode('+', $key);
// set ID
if (is_numeric($array[0]))
{
$id = (int) $array[0];
}
elseif (StringHelper::check($array[0]))
{
$getFuncName = trim($array[0]);
if (!isset($this->functionNameMemory[$getFuncName]))
{
if (!$found_local
= GetHelper::var(
'custom_code', $getFuncName,
'function_name', 'id'
))
{
continue;
}
$this->functionNameMemory[$getFuncName]
= $found_local;
}
$id = (int) $this->functionNameMemory[$getFuncName];
}
else
{
continue;
}
// load args for this ID
if (isset($array[1]))
{
if (!isset($this->data[$id]['args']))
{
$this->data[$id]['args'] = array();
}
// only load if not already loaded
if (!isset($this->data[$id]['args'][$key]))
{
if (strpos($array[1], ',') !== false)
{
// update the function values with the custom code key placholdres (this allow the use of [] + and , in the values)
$this->data[$id]['args'][$key]
= array_map(
function ($_key) {
return $this->placeholder->update(
$_key,
$this->keys
);
}, (array) explode(',', $array[1])
);
}
elseif (StringHelper::check(
$array[1]
))
{
$this->data[$id]['args'][$key]
= array();
// update the function values with the custom code key placeholders (this allow the use of [] + and , in the values)
$this->data[$id]['args'][$key][]
= $this->placeholder->update(
$array[1],
$this->keys
);
}
}
}
}
else
{
continue;
}
// make sure to remove the not if set
if ($not && is_numeric($not) && $not > 0 && $not == $id)
{
continue;
}
$bucket[$id] = $id;
}
}
// if debug
if ($debug)
{
echo 'Bucket:';
var_dump($bucket);
}
// check if any custom code placeholders where found
if (ArrayHelper::check($bucket))
{
$_tmpLang = $this->config->lang_target;
// insure we add the langs to both site and admin
$this->config->lang_target = 'both';
// now load the code to memory
$loaded = $this->load($bucket, false, $debug);
// revert lang to current setting
$this->config->lang_target = $_tmpLang;
}
// if debug
if ($debug)
{
echo 'Loaded:';
var_dump($loaded);
}
// when the custom code is loaded
if ($loaded === true)
{
$string = $this->insert($bucket, $string, $debug);
}
// if debug
if ($debug)
{
echo 'Custom Code String After Update:';
var_dump($string);
}
}
return $string;
}
/**
* Load the custom code from the system
*
* @param array|null $ids The custom code ides if known
* @param bool $setLang The set lang switch
* @param int $debug The switch to debug the update
*
* @return bool
* @since 3.2.0
*/
public function load(?array $ids = null, bool $setLang = true, $debug = 0): bool
{
// should the result be stored in memory
$loadInMemory = false;
// Create a new query object.
$query = $this->db->getQuery(true);
$query->from(
$this->db->quoteName('#__componentbuilder_custom_code', 'a')
);
if (ArrayHelper::check($ids))
{
if ($idArray = $this->check($ids))
{
$query->select(
$this->db->quoteName(
array('a.id', 'a.code', 'a.comment_type')
)
);
$query->where(
$this->db->quoteName('a.id') . ' IN (' . implode(
',', $idArray
) . ')'
);
$query->where(
$this->db->quoteName('a.target') . ' = 2'
); // <--- to load the correct target
$loadInMemory = true;
}
else
{
// all values are already in memory continue
return true;
}
}
else
{
$query->select(
$this->db->quoteName(
array('a.id', 'a.code', 'a.comment_type', 'a.component',
'a.from_line', 'a.hashtarget', 'a.hashendtarget',
'a.path', 'a.to_line', 'a.type')
)
);
$query->where(
$this->db->quoteName('a.component') . ' = '
. (int) $this->config->component_id
);
$query->where(
$this->db->quoteName('a.target') . ' = 1'
); // <--- to load the correct target
$query->order(
$this->db->quoteName('a.from_line') . ' ASC'
); // <--- insure we always add code from top of file
// reset custom code
$this->active = array();
}
$query->where($this->db->quoteName('a.published') . ' >= 1');
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
$bucket = $this->db->loadAssocList('id');
// open the code
foreach ($bucket as $nr => &$customCode)
{
$customCode['code'] = base64_decode($customCode['code']);
// always insure that the external code is loaded
$customCode['code'] = $this->external->set(
$customCode['code']
);
// set the lang only if needed
if ($setLang)
{
$customCode['code'] = $this->extractor->engine(
$customCode['code']
);
}
// check for more custom code (since this is a custom code placeholder)
else
{
$customCode['code'] = $this->set(
$customCode['code'], $debug, $nr
);
}
// build the hash array
if (isset($customCode['hashtarget']))
{
$customCode['hashtarget'] = explode(
"__", $customCode['hashtarget']
);
// is this a replace code, set end has array
if ($customCode['type'] == 1
&& strpos(
$customCode['hashendtarget'], '__'
) !== false)
{
$customCode['hashendtarget'] = explode(
"__", $customCode['hashendtarget']
);
// NOW see if this is an end of page target (TODO not sure if the string is always d41d8cd98f00b204e9800998ecf8427e)
// I know this fix is not air-tight, but it should work as the value of an empty line when md5'ed is ^^^^
// Then if the line number is only >>>one<<< it is almost always end of the page.
// So I am using those two values to detect end of page replace ending, to avoid mismatching the ending target hash.
if ($customCode['hashendtarget'][0] == 1
&& 'd41d8cd98f00b204e9800998ecf8427e'
=== $customCode['hashendtarget'][1])
{
// unset since this will force the replacement unto end of page.
unset($customCode['hashendtarget']);
}
}
}
}
// load this code into memory if needed
if ($loadInMemory === true)
{
$this->memory = $this->memory + $bucket;
}
$this->active = array_merge($this->active, $bucket);
return true;
}
return false;
}
/**
* Insert the custom code into the string
*
* @param array|null $ids The custom code ides if known
* @param string $string The string to insert custom code into
* @param int $debug The switch to debug the update
*
* @return string on success
* @since 3.2.0
*/
protected function insert(array $ids, string $string, int $debug = 0)
{
$code = array();
// load the code
foreach ($ids as $id)
{
$this->buildPlaceholders(
$this->memory[$id], $code, $debug
);
}
// if debug
if ($debug)
{
echo 'Place holders to Update String:';
var_dump($code);
echo 'Custom Code String Before Update:';
var_dump($string);
}
// now update the string
return $this->placeholder->update($string, $code);
}
/**
* Build custom code placeholders
*
* @param array $item The memory item
* @param array $code The custom code bucket
* @param int $debug The switch to debug the update
*
* @return void
* @since 3.2.0
*/
protected function buildPlaceholders(array $item, array &$code, int $debug = 0)
{
// check if there is args for this code
if (isset($this->data[$item['id']]['args'])
&& ArrayHelper::check(
$this->data[$item['id']]['args']
))
{
// since we have args we cant update this code via IDE (TODO)
$placeholder = $this->placeholder->keys(3, null);
// if debug
if ($debug)
{
echo 'Custom Code Placeholders:';
var_dump($placeholder);
}
// we have args and so need to load each
foreach (
$this->data[$item['id']]['args'] as $key => $args
)
{
$this->placeholder->setType('arg', $args);
// if debug
if ($debug)
{
echo 'Custom Code Global Placeholders:';
var_dump($this->placeholder->active);
}
$code['[CUSTOM' . 'CODE=' . $key . ']'] = $placeholder['start']
. PHP_EOL . $this->placeholder->update(
$item['code'], $this->placeholder->active
) . $placeholder['end'];
}
// always clear the args
$this->placeholder->clearType('arg');
}
else
{
if (($keyPlaceholder = array_search(
$item['id'], $this->functionNameMemory
)) === false)
{
$keyPlaceholder = $item['id'];
}
// check what type of place holders we should load here
$placeholderType = (int) $item['comment_type'] . '2';
if (stripos($item['code'], Placefix::b() . 'view') !== false
|| stripos($item['code'], Placefix::b() . 'sview') !== false
|| stripos($item['code'], Placefix::b() . 'arg') !== false)
{
// if view is being set dynamicly then we can't update this code via IDE (TODO)
$placeholderType = 3;
}
// if now ars were found, clear it
$this->placeholder->clearType('arg');
// load args for this code
$placeholder = $this->placeholder->keys(
$placeholderType, $item['id']
);
$code['[CUSTOM' . 'CODE=' . $keyPlaceholder . ']']
= $placeholder['start'] . PHP_EOL
. $this->placeholder->update(
$item['code'], $this->placeholder->active
) . $placeholder['end'];
}
}
/**
* check if we already have these ids in local memory
*
* @param array $ids The custom code ids
*
* @return Mixed
* @since 3.2.0
*/
protected function check(array $ids)
{
// reset custom code
$this->active = [];
foreach ($ids as $pointer => $id)
{
if (isset($this->memory[$id]))
{
$this->active[] = $this->memory[$id];
unset($ids[$pointer]);
}
}
// check if any ids left to fetch
if (ArrayHelper::check($ids))
{
return $ids;
}
return false;
}
}

View File

@ -0,0 +1,406 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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\Customcode;
use Joomla\CMS\Factory;
use Joomla\CMS\User\User;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Filesystem\Path;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
/**
* Compiler External Custom Code
*
* @since 3.2.0
*/
class External
{
/**
* The external code/string to be added
*
* @var array
* @since 3.2.0
*/
protected array $code = [];
/**
* The external code/string cutter
*
* @var array
* @since 3.2.0
*/
protected array $cutter = [];
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
/**
* User object
*
* @var User
* @since 3.2.0
**/
protected User $user;
/**
* Database object to query local DB
*
* @var CMSApplication
* @since 3.2.0
**/
protected CMSApplication $app;
/**
* Constructor.
*
* @param Placeholder|null $placeholder The compiler placeholder object.
* @param \JDatabaseDriver|null $db The Database Driver object.
* @param User|null $user The User object.
* @param CMSApplication|null $app The CMS Application object.
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?Placeholder $placeholder = null,
?\JDatabaseDriver $db = null, ?User $user = null, ?CMSApplication $app = null)
{
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->db = $db ?: Factory::getDbo();
$this->user = $user ?: Factory::getUser();
$this->app = $app ?: Factory::getApplication();
}
/**
* Set the external code string & load it in to string
*
* @param string $string The content to check
* @param int $debug The switch to debug the update
*
* @return string
* @since 3.2.0
*/
public function set(string $string, int $debug = 0): string
{
// check if content has custom code placeholder
if (strpos($string, '[EXTERNA' . 'LCODE=') !== false)
{
// if debug
if ($debug)
{
echo 'External Code String:';
var_dump($string);
}
// target content
$bucket = array();
$found = GetHelper::allBetween(
$string, '[EXTERNA' . 'LCODE=', ']'
);
if (ArrayHelper::check($found))
{
// build local bucket
foreach ($found as $target)
{
// check for cutting sequence
// example: >{3|4
// will cut 3 rows at top and 4 rows at bottom
// if the external code has 8 or more lines
if (($pos = strpos($target, '>{')) !== false)
{
// the length
$target_len = strlen($target);
// where to cut
$cutting = $target_len - $pos;
// get the sequence
$sequence = substr($target, "-$cutting");
// remove from the URL
$target_url = str_replace($sequence, '', $target);
// set the cut key for this target if not set
$this->cutter[trim($target)] = str_replace('>{', '', $sequence);
}
else
{
$target_url = $target;
}
// check if the target is valid URL or path
if ((!filter_var($target_url, FILTER_VALIDATE_URL) === false
&& FileHelper::exists($target_url))
|| (Path::clean($target_url) === $target_url
&& FileHelper::exists($target_url)))
{
$this->getCode($target, $bucket);
}
// give notice that target is not a valid url/path
else
{
// set key
$key = '[EXTERNA' . 'LCODE=' . $target . ']';
// set the notice
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_WARNINGHTHREE'
), 'Warning'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_THE_BSB_IS_NOT_A_VALID_URLPATH',
$key
), 'Warning'
);
// remove the placeholder
$bucket[$key] = '';
}
}
// now update local string if bucket has values
if (ArrayHelper::check($bucket))
{
$string = $this->placeholder->update($string, $bucket);
}
}
// if debug
if ($debug)
{
echo 'External Code String After Update:';
var_dump($string);
}
}
return $string;
}
/**
* Get the External Code/String
*
* @param string $string The content to check
* @param array $bucket The Placeholders bucket
*
* @return void
* @since 3.2.0
*/
protected function getCode(string $target, array &$bucket)
{
// set URL key
$target_key = trim($target);
// set key
$key = '[EXTERNA' . 'LCODE=' . $target . ']';
// remove the cut sequence from the url
if (isset($this->cutter[$target_key]))
{
// remove from the URL
$target_url = trim(str_replace('>{' . $this->cutter[$target_key], '', $target));
}
else
{
$target_url = trim($target);
}
// check if we already fetched this
if (!isset($this->code[$target_key]))
{
// get the data string (code)
$this->code[$target_key]
= FileHelper::getContent($target_url);
// check if we must cut this
if (isset($this->cutter[$target_key]) &&
$this->cutter[$target_key])
{
$this->code[$target_key] = $this->cut(
$this->code[$target_key],
$this->cutter[$target_key],
$key
);
}
// did we get any value
if (StringHelper::check(
$this->code[$target_key]
))
{
// check for changes
$live_hash = md5($this->code[$target_key]);
// check if it exists local
if ($hash = GetHelper::var(
'external_code', $target_key, 'target', 'hash'
))
{
// must be an admin make a change to use EXTERNAL code (we may add a custom access switch - use ADMIN for now)
if ($hash !== $live_hash && $this->user->authorise(
'core.admin', 'com_componentbuilder'
))
{
// update the hash since it changed
$object = new stdClass();
$object->target = $target_key;
$object->hash = $live_hash;
// update local hash
$this->db->updateObject(
'#__componentbuilder_external_code', $object,
'target'
);
// give notice of the change
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_WARNINGHTHREE'),
'Warning'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_THE_CODESTRING_FROM_BSB_HAS_BEEN_BCHANGEDB_SINCE_THE_LAST_COMPILATION_PLEASE_INVESTIGATE_TO_ENSURE_THE_CHANGES_ARE_SAFE_BSHOULD_YOU_NOT_EXPECT_THIS_CHANGE_TO_THE_EXTERNAL_CODESTRING_BEING_ADDED_THEN_THIS_IS_A_SERIOUS_ISSUE_AND_REQUIRES_IMMEDIATE_ATTENTIONB_DO_NOT_IGNORE_THIS_WARNING_AS_IT_WILL_ONLY_SHOW_BONCEB',
$key
), 'Warning'
);
}
elseif ($hash !== $live_hash)
{
// set the notice
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_ERRORHTHREE'),
'Error'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_S_WE_DETECTED_A_CHANGE_IN_BEXTERNALCODEB_BUT_YOU_DO_NOT_HAVE_PERMISSION_TO_ALLOW_THIS_CHANGE_SO_BSB_WAS_REMOVED_FROM_THE_COMPILATION_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFOBR_SMALLADMIN_ACCESS_REQUIREDSMALL',
$this->user->get('name'), $key
), 'Error'
);
// remove the code/string
$this->code[$target_key] = '';
}
}
// only an admin can add new EXTERNAL code (we may add a custom access switch - use ADMIN for now)
elseif ($this->user->authorise(
'core.admin', 'com_componentbuilder'
))
{
// add the hash to track changes
$object = new stdClass();
$object->target = $target_key;
$object->hash = $live_hash;
// insert local hash
$this->db->insertObject(
'#__componentbuilder_external_code', $object
);
// give notice the first time this is added
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_NOTICEHTHREE'),
'Warning'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_THE_CODESTRING_FROM_BSB_HAS_BEEN_ADDED_FOR_THE_BFIRST_TIMEB_PLEASE_IINVESTIGATEI_TO_ENSURE_THE_CORRECT_CODESTRING_WAS_USED_BSHOULD_YOU_NOT_KNOW_ABOUT_THIS_NEW_EXTERNAL_CODESTRING_BEING_ADDED_THEN_THIS_IS_A_SERIOUS_DANGER_AND_REQUIRES_IMMEDIATE_ATTENTIONB_DO_NOT_IGNORE_THIS_WARNING_AS_IT_WILL_ONLY_SHOW_BONCEB',
$key
), 'Warning'
);
}
else
{
// set the notice
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_ERRORHTHREE'),
'Error'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_S_WE_DETECTED_BNEW_EXTERNALCODEB_BUT_YOU_DO_NOT_HAVE_PERMISSION_TO_ALLOW_THIS_NEW_CODESTRING_SO_BSB_WAS_REMOVED_FROM_THE_COMPILATION_PLEASE_CONTACT_YOU_SYSTEM_ADMINISTRATOR_FOR_MORE_INFOBR_SMALLADMIN_ACCESS_REQUIREDSMALL',
$this->user->get('name'), $key
), 'Error'
);
// remove the code/string
$this->code[$target_key] = '';
}
}
else
{
// set notice that we could not get a valid string from the target
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_WARNINGHTHREE'), 'Error'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_THE_BSB_RETURNED_AN_INVALID_STRING', $key
), 'Error'
);
}
}
// add to local bucket
if (isset($this->code[$target_key]))
{
// update the placeholder with the external code string
$bucket[$key] = $this->code[$target_key];
}
else
{
// remove the placeholder
$bucket[$key] = '';
}
}
/**
* Cut the External Code/String
*
* @param string $string The content to cut
* @param string $sequence The cutting sequence
* @param string $key The content key
*
* @return string
* @since 3.2.0
*/
protected function cut(string $string, string $sequence, string $key): string
{
// we first break the string up in rows
$rows = (array) explode(PHP_EOL, $string);
// get the cutting sequence
$cutter = (array) explode('|', $sequence);
// we only continue if we have more rows than we have to cut
if (array_sum($cutter) < ArrayHelper::check($rows))
{
// remove the rows at the bottom if needed
if (isset($cutter[1]) && $cutter[1] > 0)
{
array_splice($rows, "-$cutter[1]");
}
// remove the rows at the top if needed
if ($cutter[0] > 0)
{
$rows = array_splice($rows, $cutter[0]);
}
// return the remaining rows
return implode(PHP_EOL, $rows);
}
// we set an error message about too few lines to cut
$this->app->enqueueMessage(
Text::_('COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_NOTICEHTHREE'),
'Error'
);
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_THE_BSB_CUT_SEQUENCE_FAILED_ON_THE_RETURNED_EXTERNAL_CODESTRING_AS_MORE_LINES_HAS_TO_BE_CUT_THEN_WAS_FOUND_IN_THE_CODESTRING_WE_HAVE_COMPLETELY_REMOVED_THE_CODE_PLEASE_CHECK_THIS_CODESTRING',
$key
), 'Error'
);
return '';
}
}

View File

@ -0,0 +1,256 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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\Customcode;
use Joomla\CMS\Factory;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Language\Text;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Utilities\FileHelper;
use VDM\Joomla\Utilities\String\FieldHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder\Reverse;
/**
* Compiler Gui Custom Code
*
* @since 3.2.0
*/
class Gui
{
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected Config $config;
/**
* Compiler Placeholder Reverse
*
* @var Reverse
* @since 3.2.0
**/
protected Reverse $reverse;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
/**
* Database object to query local DB
*
* @var CMSApplication
* @since 3.2.0
**/
protected CMSApplication $app;
/**
* Constructor.
*
* @param Config|null $config The compiler config object.
* @param Reverse|null $reverse The compiler placeholder reverse object.
* @param \JDatabaseDriver|null $db The Database Driver object.
* @param CMSApplication|null $app The CMS Application object.
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Reverse $reverse = null,
?\JDatabaseDriver $db = null, ?CMSApplication $app = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->reverse = $reverse ?: Compiler::_('Placeholder.Reverse');
$this->db = $db ?: Factory::getDbo();
$this->app = $app ?: Factory::getApplication();
}
/**
* Set the JCB GUI code placeholder
*
* @param string $string The code string
* @param array $config The placeholder config values
*
* @return string
* @since 3.2.0
*/
public function set(string $string, array $config): string
{
if (StringHelper::check($string))
{
if ($this->config->get('add_placeholders', false)
&& $this->check($string) && ArrayHelper::check($config)
&& isset($config['table']) && StringHelper::check($config['table'])
&& isset($config['field']) && StringHelper::check($config['field'])
&& isset($config['type']) && StringHelper::check($config['type'])
&& isset($config['id']) && is_numeric($config['id']))
{
// if we have a key we must get the ID
if (isset($config['key']) && StringHelper::check($config['key']) && $config['key'] !== 'id')
{
if (($id = GetHelper::var($config['table'], $config['id'], $config['key'], 'id')) !== false && is_numeric($id))
{
$config['id'] = $id;
}
else
{
// we must give a error message to inform the user of this issue. (should never happen)
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_ID_MISMATCH_WAS_DETECTED_WITH_THE_SSSS_GUI_CODE_FIELD_SO_THE_PLACEHOLDER_WAS_NOT_SET',
$config['table'], $config['field'],
$config['key'], $config['id']
), 'Error'
);
// check some config
if (!isset($config['prefix']))
{
$config['prefix'] = '';
}
return $config['prefix'] . $string;
}
}
// check some config
if (!isset($config['prefix']))
{
$config['prefix'] = PHP_EOL;
}
// add placeholder based on type of code
switch (strtolower($config['type']))
{
// adding with html commenting
case 'html':
$front = $config['prefix'] . '<!--' . '[JCBGUI.';
$sufix = '$$$$]-->' . PHP_EOL;
$back = '<!--[/JCBGUI' . $sufix;
break;
// adding with php commenting
default:
$front = $config['prefix'] . '/***' . '[JCBGUI.';
$sufix = '$$$$]***/' . PHP_EOL;
$back = '/***[/JCBGUI' . $sufix;
break;
}
return $front . $config['table'] . '.' . $config['field'] . '.'
. $config['id'] . '.' . $sufix . $string . $back;
}
// check some config
if (!isset($config['prefix']))
{
$config['prefix'] = '';
}
return $config['prefix'] . $string;
}
return $string;
}
/**
* search a file for gui code blocks that were updated in the IDE
*
* @param string $file The file path to search
* @param array $placeholders The values to replace in the code being stored
* @param string $today The date for today
* @param string $target The target path type
*
* @return void
* @since 3.2.0
*/
public function search(string &$file, array &$placeholders, string &$today, string &$target)
{
// get file content
$file_conent = FileHelper::getContent($file);
$guiCode = array();
// we add a new search for the GUI CODE Blocks
$guiCode[] = GetHelper::allBetween(
$file_conent, '/***[JCB' . 'GUI<>', '/***[/JCBGUI' . '$$$$]***/'
);
$guiCode[] = GetHelper::allBetween(
$file_conent, '<!--[JCB' . 'GUI<>', '<!--[/JCBGUI' . '$$$$]-->'
);
if (($guiCode = ArrayHelper::merge($guiCode)) !== false
&& ArrayHelper::check($guiCode, true))
{
foreach ($guiCode as $code)
{
$first_line = strtok($code, PHP_EOL);
// get the GUI target details
$query = explode('.', trim($first_line, '.'));
// only continue if we have 3 values in the query
if (is_array($query) && count($query) >= 3)
{
// cleanup the newlines around the code
$code = trim(str_replace($first_line, '', $code), PHP_EOL)
. PHP_EOL;
// set the ID
$id = (int) $query[2];
// make the field name save
$field = FieldHelper::safe($query[1]);
// make the table name save
$table = StringHelper::safe($query[0]);
// reverse placeholder as much as we can
$code = $this->reverse->engine(
$code, $placeholders, $target, $id, $field, $table
);
// update the GUI/Tables/Database
$object = new \stdClass();
$object->id = $id;
$object->{$field} = base64_encode(
$code
); // (TODO) this may not always work...
// update the value in GUI
$this->db->updateObject(
'#__componentbuilder_' . (string) $table, $object, 'id'
);
}
}
}
}
/**
* search a code to see if there is already any custom
* code or other reasons not to add the GUI code placeholders
*
* @param string $code The code to check
*
* @return bool true if GUI code placeholders can be added
* @since 3.2.0
*/
protected function check(string &$code): bool
{
// check for customcode placeholders
if (strpos($code, '$$$$') !== false)
{
// we do not add GUI wrapper placeholder to code
// that already has any customcode placeholders
return false;
}
return true;
}
}

View File

@ -9,41 +9,29 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Extension;
namespace VDM\Joomla\Componentbuilder\Compiler\Extension\JoomlaThree;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\InstallInterface;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Line;
use VDM\Joomla\Componentbuilder\Tab;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\GetScriptInterface;
/**
* Loading the Extension Installation Script Class
*
* @since 3.1.5
* @since 3.2.0
*/
class InstallScript
class InstallScript implements GetScriptInterface
{
/**
* The Line numbering Methods
*
* @since 3.1.5
*/
use Line;
/**
* The Tab Adding Method
*
* @since 3.1.5
*/
use Tab;
/**
* The extension
*
* @var object
* @since 3.1.5
* @var InstallInterface|Object
* @since 3.2.0
*/
protected object $extension;
@ -51,7 +39,7 @@ class InstallScript
* The methods
*
* @var array
* @since 3.1.5
* @since 3.2.0
*/
protected array $methods = ['php_script', 'php_preflight', 'php_postflight', 'php_method'];
@ -59,7 +47,7 @@ class InstallScript
* The types
*
* @var array
* @since 3.1.5
* @since 3.2.0
*/
protected array $types = ['construct', 'install', 'update', 'uninstall', 'discover_install'];
@ -67,7 +55,7 @@ class InstallScript
* The construct bucket
*
* @var array
* @since 3.1.5
* @since 3.2.0
*/
protected array $construct = [];
@ -75,7 +63,7 @@ class InstallScript
* The install bucket
*
* @var array
* @since 3.1.5
* @since 3.2.0
*/
protected array $install = [];
@ -83,7 +71,7 @@ class InstallScript
* The update bucket
*
* @var array
* @since 3.1.5
* @since 3.2.0
*/
protected array $update = [];
@ -91,7 +79,7 @@ class InstallScript
* The uninstall bucket
*
* @var array
* @since 3.1.5
* @since 3.2.0
*/
protected array $uninstall = [];
@ -99,7 +87,7 @@ class InstallScript
* The preflight switch
*
* @var bool
* @since 3.1.5
* @since 3.2.0
*/
protected bool $preflightActive = false;
@ -107,7 +95,7 @@ class InstallScript
* The preflight bucket
*
* @var array
* @since 3.1.5
* @since 3.2.0
*/
protected array $preflightBucket = ['install' => [], 'uninstall' => [], 'discover_install' => [], 'update' => []];
@ -115,7 +103,7 @@ class InstallScript
* The postflight switch
*
* @var bool
* @since 3.1.5
* @since 3.2.0
*/
protected bool $postflightActive = false;
@ -123,15 +111,19 @@ class InstallScript
* The postflight bucket
*
* @var array
* @since 3.1.5
* @since 3.2.0
*/
protected array $postflightBucket = ['install' => [], 'uninstall' => [], 'discover_install' => [], 'update' => []];
/**
* Constructor
* @since 3.1.5
* get install script
*
* @param Object $extension The extension object
*
* @return string
* @since 3.2.0
*/
public function __construct(object $extension)
public function get(object $extension): string
{
// loop over methods and types
foreach ($this->methods as $method)
@ -163,16 +155,7 @@ class InstallScript
}
$this->extension = $extension;
}
/**
* get install script
*
* @return string
* @since 3.1.5
*/
public function get(): string
{
// return the class
return $this->build();
}
@ -181,7 +164,7 @@ class InstallScript
* build the install class
*
* @return string
* @since 3.1.5
* @since 3.2.0
*/
protected function build(): string
{
@ -216,12 +199,13 @@ class InstallScript
* get install script head
*
* @return string
* @since 3.1.5
* @since 3.2.0
*/
protected function head(): string
{
// get the extension
$extension = $this->extension;
// start build
$script = PHP_EOL . '/**';
$script .= PHP_EOL . ' * ' . $extension->official_name
@ -239,7 +223,7 @@ class InstallScript
* get constructor
*
* @return string
* @since 3.1.5
* @since 3.2.0
*/
protected function construct(): string
{
@ -250,18 +234,18 @@ class InstallScript
}
// the __construct script
$script = PHP_EOL . PHP_EOL . $this->_t(1) . '/**';
$script .= PHP_EOL . $this->_t(1) . ' * Constructor';
$script .= PHP_EOL . $this->_t(1) . ' *';
$script .= PHP_EOL . $this->_t(1)
$script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
$script .= PHP_EOL . Indent::_(1) . ' * Constructor';
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1)
. ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script';
$script .= PHP_EOL . $this->_t(1) . ' */';
$script .= PHP_EOL . $this->_t(1)
$script .= PHP_EOL . Indent::_(1) . ' */';
$script .= PHP_EOL . Indent::_(1)
. 'public function __construct($adapter)';
$script .= PHP_EOL . $this->_t(1) . '{';
$script .= PHP_EOL . Indent::_(1) . '{';
$script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->construct);
// close the function
$script .= PHP_EOL . $this->_t(1) . '}';
$script .= PHP_EOL . Indent::_(1) . '}';
return $script;
}
@ -272,7 +256,7 @@ class InstallScript
* @param string $name the method being called
*
* @return string
* @since 3.1.5
* @since 3.2.0
*/
protected function main(string $name): string
{
@ -282,26 +266,26 @@ class InstallScript
return '';
}
// load the install method
$script = PHP_EOL . PHP_EOL . $this->_t(1) . '/**';
$script .= PHP_EOL . $this->_t(1) . " * Called on $name";
$script .= PHP_EOL . $this->_t(1) . ' *';
$script .= PHP_EOL . $this->_t(1)
$script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
$script .= PHP_EOL . Indent::_(1) . " * Called on $name";
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1)
. ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script';
$script .= PHP_EOL . $this->_t(1) . ' *';
$script .= PHP_EOL . $this->_t(1)
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1)
. ' * @return boolean True on success';
$script .= PHP_EOL . $this->_t(1) . ' */';
$script .= PHP_EOL . $this->_t(1) . 'public function '
$script .= PHP_EOL . Indent::_(1) . ' */';
$script .= PHP_EOL . Indent::_(1) . 'public function '
. $name . '($adapter)';
$script .= PHP_EOL . $this->_t(1) . '{';
$script .= PHP_EOL . Indent::_(1) . '{';
$script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->{$name});
// return true
if ('uninstall' !== $name)
{
$script .= PHP_EOL . $this->_t(2) . 'return true;';
$script .= PHP_EOL . Indent::_(2) . 'return true;';
}
// close the function
$script .= PHP_EOL . $this->_t(1) . '}';
$script .= PHP_EOL . Indent::_(1) . '}';
return $script;
}
@ -312,7 +296,7 @@ class InstallScript
* @param string $name the method being called
*
* @return string
* @since 3.1.5
* @since 3.2.0
*/
protected function flight(string $name): string
{
@ -323,42 +307,40 @@ class InstallScript
}
// the pre/post function types
$script = PHP_EOL . PHP_EOL . $this->_t(1) . '/**';
$script .= PHP_EOL . $this->_t(1)
$script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
$script .= PHP_EOL . Indent::_(1)
. ' * Called before any type of action';
$script .= PHP_EOL . $this->_t(1) . ' *';
$script .= PHP_EOL . $this->_t(1)
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1)
. ' * @param string $route Which action is happening (install|uninstall|discover_install|update)';
$script .= PHP_EOL . $this->_t(1)
$script .= PHP_EOL . Indent::_(1)
. ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script';
$script .= PHP_EOL . $this->_t(1) . ' *';
$script .= PHP_EOL . $this->_t(1)
$script .= PHP_EOL . Indent::_(1) . ' *';
$script .= PHP_EOL . Indent::_(1)
. ' * @return boolean True on success';
$script .= PHP_EOL . $this->_t(1) . ' */';
$script .= PHP_EOL . $this->_t(1) . 'public function '
$script .= PHP_EOL . Indent::_(1) . ' */';
$script .= PHP_EOL . Indent::_(1) . 'public function '
. $name . '($route, $adapter)';
$script .= PHP_EOL . $this->_t(1) . '{';
$script .= PHP_EOL . $this->_t(2) . '//' . $this->setLine(
__LINE__
) . ' get application';
$script .= PHP_EOL . $this->_t(2)
$script .= PHP_EOL . Indent::_(1) . '{';
$script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__)
. ' get application';
$script .= PHP_EOL . Indent::_(2)
. '$app = JFactory::getApplication();' . PHP_EOL;
// add the default version check (TODO) must make this dynamic
if ('preflight' === $name)
{
$script .= PHP_EOL . $this->_t(2) . '//' . $this->setLine(
__LINE__
) . ' the default for both install and update';
$script .= PHP_EOL . $this->_t(2)
$script .= PHP_EOL . Indent::_(2) . '//' . Line::_(__Line__, __Class__)
.' the default for both install and update';
$script .= PHP_EOL . Indent::_(2)
. '$jversion = new JVersion();';
$script .= PHP_EOL . $this->_t(2)
$script .= PHP_EOL . Indent::_(2)
. "if (!\$jversion->isCompatible('3.8.0'))";
$script .= PHP_EOL . $this->_t(2) . '{';
$script .= PHP_EOL . $this->_t(3)
$script .= PHP_EOL . Indent::_(2) . '{';
$script .= PHP_EOL . Indent::_(3)
. "\$app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error');";
$script .= PHP_EOL . $this->_t(3) . 'return false;';
$script .= PHP_EOL . $this->_t(2) . '}' . PHP_EOL;
$script .= PHP_EOL . Indent::_(3) . 'return false;';
$script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL;
}
// now add the scripts
@ -367,22 +349,23 @@ class InstallScript
if (ArrayHelper::check($_script))
{
// set the if and script
$script .= PHP_EOL . $this->_t(2) . "if ('" . $route
$script .= PHP_EOL . Indent::_(2) . "if ('" . $route
. "' === \$route)";
$script .= PHP_EOL . $this->_t(2) . '{';
$script .= PHP_EOL . Indent::_(2) . '{';
$script .= PHP_EOL . implode(
PHP_EOL . PHP_EOL, $_script
);
$script .= PHP_EOL . $this->_t(2) . '}' . PHP_EOL;
$script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL;
}
}
// return true
$script .= PHP_EOL . $this->_t(2) . 'return true;';
$script .= PHP_EOL . Indent::_(2) . 'return true;';
// close the function
$script .= PHP_EOL . $this->_t(1) . '}';
$script .= PHP_EOL . Indent::_(1) . '}';
return $script;
}
}
}

View File

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

View File

@ -0,0 +1,111 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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 Joomla\DI\Container;
/**
* Compiler Factory
*
* @since 3.2.0
*/
abstract class Factory
{
/**
* Global Compiler Container
*
* @var Container
* @since 3.2.0
**/
protected static $container = null;
/**
* Current Joomla Version Being Build
*
* @var int
* @since 3.2.0
**/
protected static $JoomlaVersion;
/**
* Get any class from the compiler container
*
* @param string $key The container class key
*
* @return Mixed
* @since 3.2.0
*/
public static function _($key)
{
return self::getContainer()->get($key);
}
/**
* Get version specific class from the compiler container
*
* @param string $key The container class key
*
* @return Mixed
* @since 3.2.0
*/
public static function _J($key)
{
if (empty(self::$JoomlaVersion))
{
self::$JoomlaVersion = self::getContainer()->get('Config')->joomla_version;
}
return self::getContainer()->get('J' . self::$JoomlaVersion . '.' . $key);
}
/**
* Get a the global compiler container
*
* @return Container
* @since 3.2.0
*/
public static function getContainer(): Container
{
if (!self::$container)
{
self::$container = self::createContainer();
}
return self::$container;
}
/**
* Create a container object
*
* @return Container
* @since 3.2.0
*/
protected static function createContainer(): Container
{
$container = (new Container())
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Compiler\Service\Config())
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Compiler\Service\Event())
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Compiler\Service\Language())
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Compiler\Service\Placeholder())
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Compiler\Service\Customcode())
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Compiler\Service\Power())
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Compiler\Service\Component())
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Compiler\Service\Extension());
return $container;
}
}

View File

@ -0,0 +1,33 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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\Interfaces;
/**
* Compiler Events Interface
*
* @since 3.2.0
*/
interface EventInterface
{
/**
* Trigger an event
*
* @param string $event The event to trigger
* @param mix $data The values to pass to the event/plugin
*
* @return void
* @since 3.2.0
*/
public function trigger(string $event, $data);
}

View File

@ -9,35 +9,24 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder;
use VDM\Joomla\Componentbuilder\Factory\Compiler\Config;
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces;
/**
* Add line comment
* The functions a get script should have
*
* @since 3.1.5
* @since 3.2.0
*/
trait Line
interface GetScriptInterface
{
/**
* Set the line number in comments
* get code to use
*
* @param int $nr The line number
* @param Object $code The code object
*
* @return string
* @since 3.1.5
* @since 3.2.0
*/
private function setLine(int $nr): string
{
if (Config::get('debug_line_nr', false))
{
return ' [' . get_called_class() . ' ' . $nr . ']';
}
return '';
}
public function get(object $extension): string;
}

View File

@ -0,0 +1,44 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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\Interfaces;
/**
* The properties an extension should have to be passed to the InstallScript class
*/
interface InstallInterface
{
/**
* The extension official name
*
* @return string
* @since 3.2.0
*/
public function getOfficialName(): string;
/**
* The extension class name
*
* @return string
* @since 3.2.0
*/
public function getClassName(): string;
/**
* The extension installer class name
*
* @return string
* @since 3.2.0
*/
public function getInstallerClassName(): string;
}

View File

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

View File

@ -0,0 +1,98 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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\JoomlaThree;
use VDM\Joomla\Utilities\Component\Helper;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
/**
* Compiler Events
*
* @since 3.2.0
*/
class Event implements EventInterface
{
/**
* event plugin trigger switch
*
* @var boolean
* @since 3.2.0
*/
protected $activePlugins = false;
/**
* Constructor
*
* @param Registry|null $params The component parameters
*
* @since 3.2.0
*/
public function __construct(?Registry $params = null)
{
// Set the params
$params = $params ?: Helper::getParams('com_componentbuilder');
// get active plugins
if (($plugins = $params->get('compiler_plugin', false))
!== false)
{
foreach ($plugins as $plugin)
{
// get possible plugins
if (\JPluginHelper::isEnabled('extension', $plugin))
{
// Import the appropriate plugin group.
\JPluginHelper::importPlugin('extension', $plugin);
// activate events
$this->activePlugins = true;
}
}
}
}
/**
* Trigger and event
*
* @param string $event The event to trigger
* @param mix $data The values to pass to the event/plugin
*
* @return void
* @since 3.2.0
*/
public function trigger($event, $data)
{
// only execute if plugins were loaded (active)
if ($this->activePlugins)
{
// Get the dispatcher.
$dispatcher = \JEventDispatcher::getInstance();
// Trigger this compiler event.
$results = $dispatcher->trigger($event, $data);
// Check for errors encountered while trigger the event
if (count((array) $results) && in_array(false, $results, true))
{
// Get the last error.
$error = $dispatcher->getError();
if (!($error instanceof \Exception))
{
throw new \Exception($error);
}
}
}
}
}

View File

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

View File

@ -0,0 +1,201 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
/**
* Compiler Language Content
*
* @since 3.2.0
*/
class Language
{
/**
* The language content
*
* @var array
* @since 3.2.0
**/
protected array $content = [];
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected Config $config;
/**
* Constructor.
*
* @param Config|null $config The compiler config object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null)
{
$this->config = $config ?: Compiler::_('Config');
}
/**
* Get the language string key
*
* @param string $string The plan text string (English)
*
* @return string The key language string (all uppercase)
* @since 3.2.0
*/
public function key($string): string
{
// this is there to insure we don't break already added Language strings
if (StringHelper::safe($string, 'U', '_', false, false)
=== $string)
{
return false;
}
// build language key
$key_lang = $this->config->lang_prefix . '_' . StringHelper::safe(
$string, 'U'
);
// set the language string
$this->set($this->config->lang_target, $key_lang, $string);
return $key_lang;
}
/**
* check if the language string exist
*
* @param string $target The target area for the language string
* @param string|null $language The language key string
*
* @return bool
* @since 3.2.0
*/
public function exist(string $target, ?string $language = null): bool
{
if ($language)
{
return isset($this->content[$target][$language]);
}
return isset($this->content[$target]);
}
/**
* get the language string
*
* @param string $target The target area for the language string
* @param string|null $language The language key string
*
* @return Mixed The language string found or empty string if none is found
* @since 3.2.0
*/
public function get(string $target, string $language): string
{
if (isset($this->content[$target][$language]))
{
return $this->content[$target][$language];
}
return '';
}
/**
* get target array
*
* @param string $target The target area for the language string
*
* @return array The target array or empty array if none is found
* @since 3.2.0
*/
public function getTarget(string $target): array
{
if (isset($this->content[$target]) && ArrayHelper::check($this->content[$target]))
{
return $this->content[$target];
}
return [];
}
/**
* set target array
*
* @param string $target The target area for the language string
* @param array|null $content The language content string
*
* @return void
* @since 3.2.0
*/
public function setTarget(string $target, ?array $content)
{
$this->content[$target] = $content;
}
/**
* set the language content values to language content array
*
* @param string $target The target area for the language string
* @param string $language The language key string
* @param string $string The language string
* @param bool $addPrefix The switch to add langPrefix
*
* @return void
* @since 3.2.0
*/
public function set(string $target, string $language, string $string, bool $addPrefix = false)
{
if ($addPrefix && empty(
$this->content[$target][$this->config->lang_prefix . '_' . $language]
))
{
$this->content[$target][$this->config->lang_prefix . '_' . $language]
= $this->fix($string);
}
elseif (empty($this->content[$target][$language]))
{
$this->content[$target][$language] = $this->fix(
$string
);
}
}
/**
* We need to remove all text breaks from all language strings
*
* @param string $string The language string
*
* @return string
* @since 3.2.0
*/
protected function fix(string $string): string
{
if ($this->config->remove_line_breaks)
{
return trim(str_replace(array(PHP_EOL, "\r", "\n"), '', $string));
}
return trim($string);
}
}

View File

@ -0,0 +1,254 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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\Language;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language;
/**
* Compiler Language Extractor
*
* @since 3.2.0
*/
class Extractor
{
/**
* The lang keys for extensions
*
* @var array
* @since 3.2.0
**/
public array $langKeys = [];
/**
* The Language JS matching check
*
* @var array
* @since 3.2.0
**/
public array $langMismatch = [];
/**
* The Language SC matching check
*
* @var array
* @since 3.2.0
**/
public array $langMatch = [];
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected Config $config;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Compiler Language
*
* @var Language
* @since 3.2.0
**/
protected Language $language;
/**
* Constructor.
*
* @param Config|null $config The compiler config object.
* @param Language|null $language The compiler Language object.
* @param Placeholder|null $placeholder The compiler placeholder object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Language $language = null, ?Placeholder $placeholder = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->language = $language ?: Compiler::_('Language');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
}
/**
* Extract Language Strings
*
* @param string $content The content
*
* @return string The content with the updated Language place holder
* @since 3.2.0
*/
public function engine(string $content): string
{
// get targets to search for
$lang_string_targets = array_filter(
$this->config->lang_string_targets, function ($get) use ($content) {
if (strpos($content, $get) !== false)
{
return true;
}
return false;
}
);
// check if we should continue
if (ArrayHelper::check($lang_string_targets))
{
// insure string is not broken
$content = $this->placeholder->update($content, $this->placeholder->active);
// reset some buckets
$lang_holders = array();
$lang_check = array();
$lang_only = array();
$js_text = array();
$sc_text = array();
// first get the Joomla .JText._()
if (in_array('Joomla' . '.JText._(', $lang_string_targets))
{
$js_text[] = GetHelper::allBetween(
$content, "Joomla" . ".JText._('", "'"
);
$js_text[] = GetHelper::allBetween(
$content, 'Joomla' . '.JText._("', '"'
);
// combine into one array
$js_text = ArrayHelper::merge($js_text);
// we need to add a check to insure these JavaScript lang matchup
if (ArrayHelper::check(
$js_text
)) //<-- not really needed hmmm
{
// load the JS text to mismatch array
$lang_check[] = $js_text;
$this->langMismatch = ArrayHelper::merge(
array($js_text, $this->langMismatch)
);
}
}
// now get the JText: :script()
if (in_array('JText:' . ':script(', $lang_string_targets))
{
$sc_text[] = GetHelper::allBetween(
$content, "JText:" . ":script('", "'"
);
$sc_text[] = GetHelper::allBetween(
$content, 'JText:' . ':script("', '"'
);
// combine into one array
$sc_text = ArrayHelper::merge($sc_text);
// we need to add a check to insure these JavaScript lang matchup
if (ArrayHelper::check($sc_text))
{
// load the Script text to match array
$lang_check[] = $sc_text;
$this->langMatch = ArrayHelper::merge(
array($sc_text, $this->langMatch)
);
}
}
// now do the little trick for JustTEXT: :_('Just uppercase text');
if (in_array('JustTEXT:' . ':_(', $lang_string_targets))
{
$lang_only[] = GetHelper::allBetween(
$content, "JustTEXT:" . ":_('", "')"
);
$lang_only[] = GetHelper::allBetween(
$content, 'JustTEXT:' . ':_("', '")'
);
// merge lang only
$lang_only = ArrayHelper::merge($lang_only);
}
// set language data
foreach ($lang_string_targets as $lang_string_target)
{
// need some special treatment here
if ($lang_string_target === 'Joomla' . '.JText._('
|| $lang_string_target === 'JText:' . ':script('
|| $lang_string_target === 'JustTEXT:' . ':_(')
{
continue;
}
$lang_check[] = GetHelper::allBetween(
$content, $lang_string_target . "'", "'"
);
$lang_check[] = GetHelper::allBetween(
$content, $lang_string_target . '"', '"'
);
}
// the normal loading of the language strings
$lang_check = ArrayHelper::merge($lang_check);
if (ArrayHelper::check(
$lang_check
)) //<-- not really needed hmmm
{
foreach ($lang_check as $string)
{
if ($key_lang = $this->language->key($string))
{
// load the language targets
foreach ($lang_string_targets as $lang_string_target)
{
// need some special treatment here
if ($lang_string_target === 'JustTEXT:' . ':_(')
{
continue;
}
$lang_holders[$lang_string_target . "'" . $string
. "'"]
= $lang_string_target . "'" . $key_lang . "'";
$lang_holders[$lang_string_target . '"' . $string
. '"']
= $lang_string_target . '"' . $key_lang . '"';
}
}
}
}
// the uppercase loading only (for arrays and other tricks)
if (ArrayHelper::check($lang_only))
{
foreach ($lang_only as $string)
{
if ($key_lang = $this->language->key($string))
{
// load the language targets
$lang_holders["JustTEXT:" . ":_('" . $string . "')"]
= "'" . $key_lang . "'";
$lang_holders['JustTEXT:' . ':_("' . $string . '")']
= '"' . $key_lang . '"';
}
}
}
// only continue if we have value to replace
if (ArrayHelper::check($lang_holders))
{
$content = $this->placeholder->update($content, $lang_holders);
}
}
return $content;
}
}

View File

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

View File

@ -0,0 +1,262 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
/**
* Compiler Placeholder
*
* @since 3.2.0
*/
class Placeholder
{
/**
* The active placeholders
*
* @var array
* @since 3.2.0
**/
public array $active = [];
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected Config $config;
/**
* Constructor.
*
* @param Config|null $config The compiler config object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null)
{
$this->config = $config ?: Compiler::_('Config');
}
/**
* Set a type of placeholder with set of values
*
* @param string $key The main string for placeholder key
* @param array $values The values to add
*
* @return void
* @since 3.2.0
*/
public function setType(string $key, array $values)
{
// always fist reset the type
$this->clearType($key);
// only add if there are values
if (ArrayHelper::check($values))
{
$number = 0;
foreach ($values as $value)
{
$this->active[Placefix::_($key . $number)]
= $value;
$number++;
}
}
}
/**
* Remove a type of placeholder by main key
*
* @param string $key The main string for placeholder key
*
* @return void
* @since 3.2.0
*/
public function clearType(string $key)
{
$key = Placefix::_($key);
$this->active = array_filter(
$this->active,
function(string $k) use($key){
return preg_replace('/\d/', '', $k) !== $key;
},
ARRAY_FILTER_USE_KEY
);
}
/**
* Update the data with the placeholders
*
* @param string $data The actual data
* @param array $placeholder The placeholders
* @param int $action The action to use
*
* THE ACTION OPTIONS ARE
* 1 -> Just replace (default)
* 2 -> Check if data string has placeholders
* 3 -> Remove placeholders not in data string
*
* @return string
* @since 3.2.0
*/
public function update(string $data, array &$placeholder, int $action = 1): string
{
// make sure the placeholders is an array
if (!ArrayHelper::check($placeholder))
{
// This is an error, (TODO) actualy we need to add a kind of log here to know that this happened
return $data;
}
// continue with the work of replacement
if (1 == $action) // <-- just replace (default)
{
return str_replace(
array_keys($placeholder), array_values($placeholder), $data
);
}
elseif (2 == $action) // <-- check if data string has placeholders
{
$replace = false;
foreach ($placeholder as $key => $val)
{
if (strpos($data, $key) !== false)
{
$replace = true;
break;
}
}
// only replace if the data has these placeholder values
if ($replace === true)
{
return str_replace(
array_keys($placeholder), array_values($placeholder), $data
);
}
}
elseif (3 == $action) // <-- remove placeholders not in data string
{
$replace = $placeholder;
foreach ($replace as $key => $val)
{
if (strpos($data, $key) === false)
{
unset($replace[$key]);
}
}
// only replace if the data has these placeholder values
if (ArrayHelper::check($replace))
{
return str_replace(
array_keys($replace), array_values($replace), $data
);
}
}
return $data;
}
/**
* return the placeholders for inserted and replaced code
*
* @param int $type The type of placement
* @param int|null $id The code id in the system
*
* @return array on success
* @since 3.2.0
*/
public function keys(int $type, ?int $id = null)
{
switch ($type)
{
case 3:
return [ 'start' => "", 'end' => ""];
break;
case 11:
//***[REPLACED$$$$]***//**1**/
if ($this->config->get('add_placeholders', false) === true)
{
return [
'start' => '/***[REPLACED$$$$]***//**' . $id . '**/',
'end' => '/***[/REPLACED$$$$]***/'
];
}
else
{
return [ 'start' => "", 'end' => ""];
}
break;
case 12:
//***[INSERTED$$$$]***//**1**/
if ($this->config->get('add_placeholders', false) === true)
{
return [
'start' => '/***[INSERTED$$$$]***//**' . $id . '**/',
'end' => '/***[/INSERTED$$$$]***/'
];
}
else
{
return [ 'start' => "", 'end' => ""];
}
break;
case 21:
//<!--[REPLACED$$$$]--><!--1-->
if ($this->config->get('add_placeholders', false) === true)
{
return [
'start' => '<!--[REPLACED$$$$]--><!--' . $id . '-->',
'end' => '<!--[/REPLACED$$$$]-->'
];
}
else
{
return [ 'start' => "", 'end' => ""];
}
break;
case 22:
//<!--[INSERTED$$$$]--><!--1-->
if ($this->config->get('add_placeholders', false) === true)
{
return [
'start' => '<!--[INSERTED$$$$]--><!--' . $id . '-->',
'end' => '<!--[/INSERTED$$$$]-->'
];
}
else
{
return [ 'start' => "", 'end' => ""];
}
break;
case 33:
return ['start' => Placefix::h(), 'end' => Placefix::h()];
break;
case 66:
return ['start' => Placefix::b(), 'end' => Placefix::d()];
break;
}
return false;
}
}

View File

@ -0,0 +1,243 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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\Placeholder;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\GetHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Language;
use VDM\Joomla\Componentbuilder\Compiler\Language\Extractor;
/**
* Compiler Placeholder Reverse
*
* @since 3.2.0
*/
class Reverse
{
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected Config $config;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Compiler Language
*
* @var Language
* @since 3.2.0
**/
protected Language $language;
/**
* Compiler Language Extractor
*
* @var Extractor
* @since 3.2.0
**/
protected Extractor $extractor;
/**
* Constructor.
*
* @param Config|null $config The compiler config object.
* @param Placeholder|null $placeholder The compiler placeholder object.
* @param Language|null $language The compiler language object.
* @param Extract|null $extractor The compiler language extractor object.
*
* @since 3.2.0
*/
public function __construct(
?Config $config = null, ?Placeholder $placeholder = null,
?Language $language = null, ?Extractor $extractor = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->language = $language ?: Compiler::_('Language');
$this->extractor = $extractor ?: Compiler::_('Language.Extractor');
}
/**
* Reverse Engineer the dynamic placeholders (TODO hmmmm this is not ideal)
*
* @param string $string The string to revers
* @param array $placeholders The values to search for
* @param string $target The target path type
* @param int|null $id The custom code id
* @param string $field The field name
* @param string $table The table name
*
* @return string
* @since 3.2.0
*/
public function engine(string $string, array &$placeholders,
string $target, ?int $id = null, $field = 'code', $table = 'custom_code'): string
{
// get local code if set
if ($id > 0 && $code = base64_decode(
GetHelper::var($table, $id, 'id', $field)
))
{
$string = $this->setReverse(
$string, $code, $target
);
}
return $this->placeholder->update($string, $placeholders, 2);
}
/**
* Set the language strings for the reveres process
*
* @param string $updateString The string to update
* @param string $string The string to use language update
* @param string $target The target path type
*
* @return string
* @since 3.2.0
*/
protected function setReverse(string $updateString, string $string, string $target): string
{
// get targets to search for
$lang_string_targets = array_filter(
$this->config->lang_string_targets, function ($get) use ($string) {
if (strpos($string, $get) !== false)
{
return true;
}
return false;
}
);
// check if we should continue
if (ArrayHelper::check($lang_string_targets))
{
// start lang holder
$lang_holders = array();
// set the lang for both since we don't know what area is being targeted
$_tmp = $this->config->lang_target;
// set the lang based on target
if (strpos($target, 'module') !== false)
{
// backup lang prefix
$_tmp_lang_prefix = $this->config->lang_prefix;
// set the new lang prefix
$lang_prefix = strtoupper(
str_replace('module', 'mod', $target)
);
$this->config->set('lang_prefix', $lang_prefix);
// now set the lang
if (isset($this->extractor->langKeys[$this->config->lang_prefix]))
{
$this->config->lang_target = $this->extractor->langKeys[$this->config->lang_prefix];
}
else
{
$this->config->lang_target = 'module';
}
}
elseif (strpos($target, 'plugin') !== false)
{
// backup lang prefix
$_tmp_lang_prefix = $this->config->lang_prefix;
// set the new lang prefix
$lang_prefix = strtoupper(
str_replace('plugin', 'plg', $target)
);
$this->config->set('lang_prefix', $lang_prefix);
// now set the lang
if (isset($this->extractor->langKeys[$this->config->lang_prefix]))
{
$this->config->lang_target = $this->extractor->langKeys[$this->config->lang_prefix];
}
else
{
$this->config->lang_target = 'plugin';
}
}
else
{
$this->config->lang_target = 'both';
}
// set language data
foreach ($lang_string_targets as $lang_string_target)
{
$lang_check[] = GetHelper::allBetween(
$string, $lang_string_target . "'", "'"
);
$lang_check[] = GetHelper::allBetween(
$string, $lang_string_target . "'", "'"
);
}
// merge arrays
$lang_array = ArrayHelper::merge($lang_check);
// continue only if strings were found
if (ArrayHelper::check(
$lang_array
)) //<-- not really needed hmmm
{
foreach ($lang_array as $lang)
{
$_key_lang = StringHelper::safe($lang, 'U');
// this is there to insure we dont break already added Language strings
if ($_key_lang === $lang)
{
continue;
}
// build lang key
$key_lang = $this->config->lang_prefix . '_' . $_key_lang;
// set lang content string
$this->language->set($this->config->lang_target, $key_lang, $lang);
// reverse the placeholders
foreach ($lang_string_targets as $lang_string_target)
{
$lang_holders[$lang_string_target . "'" . $key_lang . "'"]
= $lang_string_target . "'" . $lang . "'";
$lang_holders[$lang_string_target . '"' . $key_lang . '"']
= $lang_string_target . '"' . $lang . '"';
}
}
// return the found placeholders
$updateString = $this->placeholder->replace(
$updateString, $lang_holders
);
}
// reset the lang
$this->config->lang_target = $_tmp;
// also rest the lang prefix if set
if (isset($_tmp_lang_prefix))
{
$lang_prefix = $_tmp_lang_prefix;
$this->config->set('lang_prefix', $_tmp_lang_prefix);
}
}
return $updateString;
}
}

View File

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

View File

@ -0,0 +1,517 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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 Joomla\CMS\Factory;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Language\Text;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\GuidHelper;
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
use VDM\Joomla\Utilities\String\NamespaceHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Config;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
/**
* Compiler Power
*
* @since 3.2.0
*/
class Power
{
/**
* All loaded powers
*
* @var array
* @since 3.2.0
**/
public array $active = [];
/**
* The state of all loaded powers
*
* @var array
* @since 3.2.0
**/
protected array $state = [];
/**
* Compiler Config
*
* @var Config
* @since 3.2.0
**/
protected Config $config;
/**
* Compiler Placeholder
*
* @var Placeholder
* @since 3.2.0
**/
protected Placeholder $placeholder;
/**
* Compiler Customcode
*
* @var Customcode
* @since 3.2.0
**/
protected Customcode $customcode;
/**
* Compiler Customcode in Gui
*
* @var Gui
* @since 3.2.0
**/
protected Gui $gui;
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
**/
protected \JDatabaseDriver $db;
/**
* Database object to query local DB
*
* @var CMSApplication
* @since 3.2.0
**/
protected CMSApplication $app;
/**
* Constructor.
*
* @param Config|null $config The compiler config object.
* @param Placeholder|null $placeholder The compiler placeholder object.
* @param Customcode|null $customcode The compiler customcode object.
* @param Gui|null $gui The compiler customcode gui object.
* @param \JDatabaseDriver|null $db The Database Driver object.
* @param CMSApplication|null $app The CMS Application object.
*
* @since 3.2.0
*/
public function __construct(?Config $config = null, ?Placeholder $placeholder = null,
?Customcode $customcode = null, ?Gui $gui = null,
?\JDatabaseDriver $db = null, ?CMSApplication $app = null)
{
$this->config = $config ?: Compiler::_('Config');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->customcode = $customcode ?: Compiler::_('Customcode');
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
$this->db = $db ?: Factory::getDbo();
$this->app = $app ?: Factory::getApplication();
}
/**
* load all the powers linked to this component
*
* @param array $guids The global unique ids of the linked powers
*
* @return void
* @since 3.2.0
*/
public function load(array $guids)
{
if (ArrayHelper::check($guids))
{
foreach ($guids as $guid => $build)
{
$this->get($guid, $build);
}
}
}
/**
* Get a power
*
* @param string $guid The global unique id of the power
* @param int $build Force build switch (to override global switch)
*
* @return mixed
* @since 3.2.0
*/
public function get(string $guid, int $build = 0)
{
if (($this->config->get('add_power', true) || $build == 1) && $this->set($guid))
{
return $this->active[$guid];
}
return false;
}
/**
* Set a power
*
* @param string $guid The global unique id of the power
*
* @return bool
* @since 3.2.0
*/
protected function set(string $guid): bool
{
// check if we have been here before
if (isset($this->state[$guid]))
{
return $this->state[$guid];
}
elseif (GuidHelper::valid($guid))
{
// Create a new query object.
$query = $this->db->getQuery(true);
$query->select('a.*');
// from these tables
$query->from('#__componentbuilder_power AS a');
$query->where($this->db->quoteName('a.guid') . ' = ' . $this->db->quote($guid));
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// make sure that in recursion we
// don't try to load this power again
$this->state[$guid] = true;
// get the power data
$this->active[$guid] = $this->db->loadObject();
// make sure to add any language strings found to all language files
// since we can't know where this is used at this point
$tmp_lang_target = $this->config->lang_target;
$this->config->lang_target = 'both';
// we set the fix usr if needed
$fix_url
= '"index.php?option=com_componentbuilder&view=powers&task=power.edit&id='
. $this->active[$guid]->id . '" target="_blank"';
// set some keys
$this->active[$guid]->target_type = 'P0m3R!';
$this->active[$guid]->key = $this->active[$guid]->id . '_' . $this->active[$guid]->target_type;
// now set the name
$this->active[$guid]->name = $this->placeholder->update(
$this->customcode->add($this->active[$guid]->name),
$this->placeholder->active
);
// now set the code_name and class name
$this->active[$guid]->code_name = $this->active[$guid]->class_name = ClassfunctionHelper::safe(
$this->active[$guid]->name
);
// set official name
$this->active[$guid]->official_name = StringHelper::safe(
$this->active[$guid]->name, 'W'
);
// set namespace
$this->active[$guid]->namespace = $this->placeholder->update(
$this->active[$guid]->namespace, $this->placeholder->active
);
// validate namespace
if (strpos($this->active[$guid]->namespace, '\\') === false)
{
// we raise an error message
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_HTHREES_NAMESPACE_ERROR_SHTHREEPYOU_MUST_ATLEAST_HAVE_TWO_SECTIONS_IN_YOUR_NAMESPACE_YOU_JUST_HAVE_ONE_THIS_IS_AN_UNACCEPTABLE_ACTION_PLEASE_SEE_A_HREFS_PSRFOURA_FOR_MORE_INFOPPTHIS_S_WAS_THEREFORE_REMOVED_A_HREFSCLICK_HEREA_TO_FIX_THIS_ISSUEP',
ucfirst($this->active[$guid]->type), $this->active[$guid]->name, $this->active[$guid]->namespace,
'"https://www.php-fig.org/psr/psr-4/" target="_blank"', $this->active[$guid]->type,
$fix_url),
'Error'
);
$this->state[$guid] = false;
unset($this->active[$guid]);
// reset back to starting value
$this->config->lang_target = $tmp_lang_target;
// we break out here
return false;
}
else
{
// setup the path array
$path_array = (array) explode('\\', $this->active[$guid]->namespace);
// make sure all sub folders in src dir is set and remove all characters that will not work in folders naming
$this->active[$guid]->namespace = NamespaceHelper::safe(str_replace('.', '\\', $this->active[$guid]->namespace));
// make sure it has two or more
if (ArrayHelper::check($path_array) <= 1)
{
// we raise an error message
$this->app->enqueueMessage(
Text::sprintf('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',
ucfirst($this->active[$guid]->type), $this->active[$guid]->name, $this->active[$guid]->namespace,
'"https://www.php-fig.org/psr/psr-4/" target="_blank"', $this->active[$guid]->type,
$fix_url),
'Error'
);
$this->state[$guid] = false;
unset($this->active[$guid]);
// reset back to starting value
$this->config->lang_target = $tmp_lang_target;
// we break out here
return false;
}
// get the file and class name (the last value in array)
$file_name = array_pop($path_array);
// src array bucket
$src_array = array();
// do we have src folders
if (strpos($file_name, '.') !== false)
{
// we have src folders in the namespace
$src_array = (array) explode('.', $file_name);
// get the file and class name (the last value in array)
$this->active[$guid]->file_name = array_pop($src_array);
// namespace array
$namespace_array = array_merge($path_array, $src_array);
}
else
{
// set the file name
$this->active[$guid]->file_name = $file_name;
// namespace array
$namespace_array = $path_array;
}
// the last value is the same as the class name
if ($this->active[$guid]->file_name !== $this->active[$guid]->class_name)
{
// we raise an error message
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_PS_NAMING_MISMATCH_ERROR_SPPTHE_S_NAME_IS_BSB_AND_THE_ENDING_FILE_NAME_IN_THE_NAMESPACE_IS_BSB_THIS_IS_BAD_CONVENTION_PLEASE_SEE_A_HREFS_PSRFOURA_FOR_MORE_INFOPPA_HREFSCLICK_HEREA_TO_FIX_THIS_ISSUEP',
ucfirst($this->active[$guid]->type), $this->active[$guid]->name, $this->active[$guid]->type, $this->active[$guid]->class_name, $this->active[$guid]->file_name,
'"https://www.php-fig.org/psr/psr-4/" target="_blank"',
$fix_url),
'Error'
);
$this->state[$guid] = false;
unset($this->active[$guid]);
// reset back to starting value
$this->config->lang_target = $tmp_lang_target;
// we break out here
return false;
}
// make sure the arrays are namespace safe
$path_array = array_map(function ($val) {
return NamespaceHelper::safe($val);
}, $path_array);
$namespace_array = array_map(function ($val) {
return NamespaceHelper::safe($val);
}, $namespace_array);
// set the actual class namespace
$this->active[$guid]->_namespace = implode('\\', $namespace_array);
// prefix values
$this->active[$guid]->_namespace_prefix = $path_array;
// get the parent folder (the first value in array)
$prefix_folder = implode('.', $path_array);
// make sub folders if still found
$sub_folder = '';
if (ArrayHelper::check($src_array))
{
// make sure the arrays are namespace safe
$sub_folder = '/' . implode('/', array_map(function ($val) {
return NamespaceHelper::safe($val);
}, $src_array));
}
// now we set the paths
$this->active[$guid]->path_jcb = $this->config->get('jcb_powers_path', 'libraries/jcb_powers');
$this->active[$guid]->path_parent = $this->active[$guid]->path_jcb . '/' . $prefix_folder;
$this->active[$guid]->path = $this->active[$guid]->path_parent . '/src' . $sub_folder;
}
// load use ids
$use = array();
$as = array();
// check if we have use selection
$this->active[$guid]->use_selection = (isset($this->active[$guid]->use_selection)
&& JsonHelper::check(
$this->active[$guid]->use_selection
)) ? json_decode($this->active[$guid]->use_selection, true) : null;
if ($this->active[$guid]->use_selection)
{
$use = array_values(array_map(function ($u) use(&$as) {
// track the AS options
if (empty($u['as']))
{
$as[$u['use']] = 'default';
}
else
{
$as[$u['use']] = (string) $u['as'];
}
// return the guid
return $u['use'];
}, $this->active[$guid]->use_selection));
}
// check if we have load selection
$this->active[$guid]->load_selection = (isset($this->active[$guid]->load_selection)
&& JsonHelper::check(
$this->active[$guid]->load_selection
)) ? json_decode($this->active[$guid]->load_selection, true) : null;
if ($this->active[$guid]->load_selection)
{
// load use ids
array_map(function ($l) {
// just load it directly and be done with it
return $this->set($l['load']);
}, $this->active[$guid]->load_selection);
}
// see if we have implements
$this->active[$guid]->implement_names = array();
// does this implement
$this->active[$guid]->implements = (isset($this->active[$guid]->implements)
&& JsonHelper::check(
$this->active[$guid]->implements
)) ? json_decode($this->active[$guid]->implements, true) : null;
if ($this->active[$guid]->implements)
{
foreach ($this->active[$guid]->implements as $implement)
{
if ($implement == -1
&& StringHelper::check($this->active[$guid]->implements_custom))
{
$this->active[$guid]->implement_names[] = $this->placeholder->update(
$this->customcode->add($this->active[$guid]->implements_custom),
$this->placeholder->active
);
// just add this once
unset($this->active[$guid]->implements_custom);
}
// does this extend existing
elseif (GuidHelper::valid($implement))
{
// check if it was set
if ($this->set($implement))
{
// get the name
$this->active[$guid]->implement_names[] = $this->get($implement, 1)->class_name;
// add to use
$use[] = $implement;
}
}
}
}
// does this extend something
$this->active[$guid]->extends_name = null;
// we first check for custom extending options
if ($this->active[$guid]->extends == -1
&& StringHelper::check($this->active[$guid]->extends_custom))
{
$this->active[$guid]->extends_name = $this->placeholder->update(
$this->customcode->add($this->active[$guid]->extends_custom),
$this->placeholder->active
);
// just add once
unset($this->active[$guid]->extends_custom);
}
// does this extend existing
elseif (GuidHelper::valid($this->active[$guid]->extends))
{
// check if it was set
if ($this->set($this->active[$guid]->extends))
{
// get the name
$this->active[$guid]->extends_name = $this->get($this->active[$guid]->extends, 1)->class_name;
// add to use
$use[] = $this->active[$guid]->extends;
}
}
// set GUI mapper
$guiMapper = array('table' => 'power', 'id' => (int) $this->active[$guid]->id, 'type' => 'php');
// add the header script
if ($this->active[$guid]->add_head == 1)
{
// set GUI mapper field
$guiMapper['field'] = 'head';
// base64 Decode code
$this->active[$guid]->head = $this->gui->set(
$this->placeholder->update(
$this->customcode->add(
base64_decode(
$this->active[$guid]->head
)
), $this->placeholder->active
),
$guiMapper
) . PHP_EOL;
}
// now add all the extra use statements
if (ArrayHelper::check($use))
{
foreach (array_unique($use) as $u)
{
if ($this->set($u))
{
$add_use = $this->get($u, 1)->namespace;
// check if it is already added manually, you know how some people are
if (strpos($this->active[$guid]->head, $add_use) === false)
{
// check if it has an AS option
if (isset($as[$u]) && StringHelper::check($as[$u]) && $as[$u] !== 'default')
{
$this->active[$guid]->head .= 'use ' . $add_use . ' as ' . $as[$u] . ';' . PHP_EOL;
}
else
{
$this->active[$guid]->head .= 'use ' . $add_use . ';' . PHP_EOL;
}
}
}
}
}
// now set the description
$this->active[$guid]->description = (StringHelper::check($this->active[$guid]->description)) ? $this->placeholder->update(
$this->customcode->add($this->active[$guid]->description),
$this->placeholder->active
) : '';
// add the main code if set
if (StringHelper::check($this->active[$guid]->main_class_code))
{
// set GUI mapper field
$guiMapper['field'] = 'main_class_code';
// base64 Decode code
$this->active[$guid]->main_class_code = $this->gui->set(
$this->placeholder->update(
$this->customcode->add(
base64_decode(
$this->active[$guid]->main_class_code
)
), $this->placeholder->active
),
$guiMapper
);
}
// reset back to starting value
$this->config->lang_target = $tmp_lang_target;
return true;
}
}
// we failed to get the power,
// so we raise an error message
// only if guid is valid
if (GuidHelper::valid($guid))
{
$this->app->enqueueMessage(
Text::sprintf('COM_COMPONENTBUILDER_PPOWER_BGUIDSB_NOT_FOUNDP', $guid),
'Error'
);
}
// let's not try again
$this->state[$guid] = false;
return false;
}
}

View File

@ -0,0 +1,56 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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\Component\Placeholder as ComponentPlaceholder;
/**
* Component Service Provider
*
* @since 3.2.0
*/
class Component 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(ComponentPlaceholder::class, 'Component.Placeholder')
->share('Component.Placeholder', [$this, 'getComponentPlaceholder'], true);
}
/**
* Get the Component Placeholders
*
* @param Container $container The DI container.
*
* @return ComponentPlaceholder
* @since 3.2.0
*/
public function getComponentPlaceholder(Container $container): ComponentPlaceholder
{
return new ComponentPlaceholder(
$container->get('Config')
);
}
}

View File

@ -0,0 +1,54 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Compiler\Config as CompilerConfig;
/**
* Compiler Config Service Provider
*
* @since 3.2.0
*/
class Config 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(CompilerConfig::class, 'Config')
->share('Config', [$this, 'getConfig'], true);
}
/**
* Get the Compiler Configurations
*
* @param Container $container The DI container.
*
* @return CompilerConfig
* @since 3.2.0
*/
public function getConfig(Container $container): CompilerConfig
{
return new CompilerConfig();
}
}

View File

@ -0,0 +1,99 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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\Customcode as CompilerCustomcode;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\External;
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
/**
* Compiler Custom Code Service Provider
*
* @since 3.2.0
*/
class Customcode 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(CompilerCustomcode::class, 'Customcode')
->share('Customcode', [$this, 'getCustomcode'], true);
$container->alias(External::class, 'Customcode.External')
->share('Customcode.External', [$this, 'getExternal'], true);
$container->alias(Gui::class, 'Customcode.Gui')
->share('Customcode.Gui', [$this, 'getGui'], true);
}
/**
* Get the Compiler Customcode
*
* @param Container $container The DI container.
*
* @return CompilerCustomcode
* @since 3.2.0
*/
public function getCustomcode(Container $container): CompilerCustomcode
{
return new CompilerCustomcode(
$container->get('Config'),
$container->get('Placeholder'),
$container->get('Language.Extractor'),
$container->get('Customcode.External')
);
}
/**
* Get the Compiler Customcode External
*
* @param Container $container The DI container.
*
* @return External
* @since 3.2.0
*/
public function getExternal(Container $container): External
{
return new External(
$container->get('Placeholder')
);
}
/**
* Get the Compiler Customcode Gui
*
* @param Container $container The DI container.
*
* @return Gui
* @since 3.2.0
*/
public function getGui(Container $container): Gui
{
return new Gui(
$container->get('Config'),
$container->get('Placeholder.Reverse')
);
}
}

View File

@ -0,0 +1,55 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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\Interfaces\EventInterface;
use VDM\Joomla\Componentbuilder\Compiler\JoomlaThree\Event as J3Event;
/**
* Event Service Provider
*
* @since 3.2.0
*/
class Event 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(J3Event::class, 'J3.Event')
->share('J3.Event', [$this, 'getJ3Event'], true);
}
/**
* Get the Joomla 3 Event
*
* @param Container $container The DI container.
*
* @return EventInterface
* @since 3.2.0
*/
public function getJ3Event(Container $container): EventInterface
{
return new J3Event();
}
}

View File

@ -0,0 +1,55 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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\Interfaces\GetScriptInterface;
use VDM\Joomla\Componentbuilder\Compiler\Extension\JoomlaThree\InstallScript as J3InstallScript;
/**
* Extension Script Service Provider
*
* @since 3.2.0
*/
class Extension 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(J3InstallScript::class, 'J3.Extension.InstallScript')
->share('J3.Extension.InstallScript', [$this, 'getJ3ExtensionInstallScript'], true);
}
/**
* Get the Joomla 3 Extension Install Script
*
* @param Container $container The DI container.
*
* @return GetScriptInterface
* @since 3.2.0
*/
public function getJ3ExtensionInstallScript(Container $container): GetScriptInterface
{
return new J3InstallScript();
}
}

View File

@ -0,0 +1,78 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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\Language as CompilerLanguage;
use VDM\Joomla\Componentbuilder\Compiler\Language\Extractor;
/**
* Compiler Language Service Provider
*
* @since 3.2.0
*/
class Language 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(CompilerLanguage::class, 'Language')
->share('Language', [$this, 'getLanguage'], true);
$container->alias(Extractor::class, 'Language.Extractor')
->share('Language.Extractor', [$this, 'getLanguageExtractor'], true);
}
/**
* Get the Compiler Language
*
* @param Container $container The DI container.
*
* @return CompilerLanguage
* @since 3.2.0
*/
public function getLanguage(Container $container): CompilerLanguage
{
return new CompilerLanguage(
$container->get('Config')
);
}
/**
* Get the Compiler Language Extractor
*
* @param Container $container The DI container.
*
* @return Extractor
* @since 3.2.0
*/
public function getLanguageExtractor(Container $container): Extractor
{
return new Extractor(
$container->get('Config'),
$container->get('Language'),
$container->get('Placeholder')
);
}
}

View File

@ -0,0 +1,78 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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\Placeholder as CompilerPlaceholder;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder\Reverse;
/**
* Compiler Placeholder Service Provider
*
* @since 3.2.0
*/
class Placeholder 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(CompilerPlaceholder::class, 'Placeholder')
->share('Placeholder', [$this, 'getPlaceholder'], true);
$container->alias(Reverse::class, 'Placeholder.Reverse')
->share('Placeholder.Reverse', [$this, 'getPlaceholderReverse'], true);
}
/**
* Get the Compiler Placeholder
*
* @param Container $container The DI container.
*
* @return CompilerPlaceholder
* @since 3.2.0
*/
public function getPlaceholder(Container $container): CompilerPlaceholder
{
return new CompilerPlaceholder(
$container->get('Config')
);
}
/**
* Get the Compiler Placeholder Reverse
*
* @param Container $container The DI container.
*
* @return Worker
* @since 3.2.0
*/
public function getPlaceholderReverse(Container $container): Reverse
{
return new Reverse(
$container->get('Config'),
$container->get('Placeholder'),
$container->get('Language'),
$container->get('Language.Extractor')
);
}
}

View File

@ -0,0 +1,59 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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\Power as CompilerPower;
/**
* Compiler Power Service Provider
*
* @since 3.2.0
*/
class Power 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(CompilerPower::class, 'Power')
->share('Power', [$this, 'getPower'], true);
}
/**
* Get the Compiler Power
*
* @param Container $container The DI container.
*
* @return CompilerPower
* @since 3.2.0
*/
public function getPower(Container $container): CompilerPower
{
return new CompilerPower(
$container->get('Config'),
$container->get('Placeholder'),
$container->get('Customcode'),
$container->get('Customcode.Gui')
);
}
}

View File

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

View File

@ -0,0 +1,90 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Utilities;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
/**
* The Indentation Factory
*
* @since 3.2.0
*/
abstract class Indent
{
/**
* Spacer bucket (to speed-up the build)
*
* @var array
* @since 3.2.0
*/
private static array $bucket = [];
/**
* The indentation string
*
* @var string
* @since 3.2.0
*/
private static string $indent;
/**
* Set the space
*
* @param int $nr The number of spaces
*
* @return string
* @since 3.2.0
*/
public function _(int $nr): string
{
// check if we already have the string
if (!isset(self::$bucket[$nr]))
{
// get the string
self::$bucket[$nr] = str_repeat(self::indent(), (int) $nr);
}
// return stored indentation
return self::$bucket[$nr];
}
/**
* Get the indentation string
*
* @return string
* @since 3.2.0
*/
private static function indent(): string
{
if (empty(self::$indent))
{
self::init();
}
return self::$indent;
}
/**
* The constructor for indent
*
* @return void
* @since 3.2.0
*/
private static function init()
{
// the default is TAB
self::$indent = Compiler::_('Config')->indentation_value;
}
}

View File

@ -0,0 +1,79 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Compiler\Utilities;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
/**
* The Debug Line Number Factory
*
* @since 3.2.0
*/
abstract class Line
{
/**
* Should we add debug lines
*
* @since 3.2.0
**/
private static $add = 'check';
/**
* Set the line number in comments
*
* @param int $nr The line number
* @param string $class The class name
*
* @return string
* @since 3.2.0
*/
public static function _(int $nr, string $class): string
{
if (self::add())
{
return ' [' . $class . ' ' . $nr . ']';
}
return '';
}
/**
* Check if we should add the line number
*
* @return bool
* @since 3.2.0
*/
private static function add(): bool
{
if (!is_bool(self::$add))
{
self::init();
}
return self::$add;
}
/**
* The constructor for add
*
* @return void
* @since 3.2.0
*/
private static function init()
{
self::$add = Compiler::_('Config')->debug_line_nr;
}
}

View File

@ -0,0 +1,106 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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 Placeholder Prefix and Suffix Factory
*
* @since 3.2.0
*/
abstract class Placefix
{
/**
* The hash prefix and suffix
*
* @var string
* @since 3.2.0
**/
private static $hhh = '#' . '#' . '#';
/**
* The open prefix
*
* @var string
* @since 3.2.0
**/
private static $bbb = '[' . '[' . '[';
/**
* The close suffix
*
* @var string
* @since 3.2.0
**/
private static $ddd = ']' . ']' . ']';
/**
* Get a prefix and suffix added to given string
*
* @param string $class The class name
*
* @return string
* @since 3.2.0
*/
public static function _(string $string): string
{
return self::b() . $string . self::d();
}
/**
* Get a open prefix
*
* @return string
* @since 3.2.0
*/
public static function b(): string
{
return self::$bbb;
}
/**
* Get a close suffix
*
* @return string
* @since 3.2.0
*/
public static function d(): string
{
return self::$ddd;
}
/**
* Get a hash prefix and suffix added to given string
*
* @param string $class The class name
*
* @return string
* @since 3.2.0
*/
public static function _h(string $string): string
{
return self::h() . $string . self::h();
}
/**
* Get a hash-fix
*
* @return string
* @since 3.2.0
*/
public static function h(): string
{
return self::$hhh;
}
}

View File

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

View File

@ -1,257 +0,0 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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\Factory\Compiler;
use Joomla\CMS\Factory;
use Joomla\Registry\Registry;
use VDM\Joomla\Componentbuilder\Compiler\Config as CompilerConfig;
use VDM\Joomla\Utilities\ArrayHelper;
/**
* Factory to load the compiler config
*/
abstract class Config
{
/**
* Global Config object
*
* @var CompilerConfig
* @since 3.1.6
**/
protected static $CompilerConfig = null;
/**
* Get a value.
*
* @param string $path Registry path (e.g. version)
* @param mixed $default Optional default value, returned if the internal value is null.
*
* @return mixed Value of entry or null
*
* @since 3.1.6
*/
public static function get(string $path, $default = null)
{
// check that if we already have config registry set
if (!self::$CompilerConfig)
{
// create config registry
self::$CompilerConfig = self::create();
}
// return the value or default if none is found
return self::$CompilerConfig->get($path, $default);
}
/**
* Check if a registry path exists.
*
* @param string $path Registry path (e.g. guid.main.0.path)
*
* @return boolean
*
* @since 3.1.6
*/
public static function exists($path)
{
// check that if we already have config registry set
if (!self::$CompilerConfig)
{
// create config registry
self::$CompilerConfig = self::create();
}
// check if exists
return self::$CompilerConfig->exists($path);
}
/**
* Method to extract a sub-registry from path
*
* @param string $path Registry path (e.g. guid.main)
*
* @return Registry Registry object (empty if no data is present)
*
* @since 3.1.6
*/
public function extract($path)
{
if (!self::exists($path))
{
// create config registry
return new Registry();
}
return self::$CompilerConfig->extract($path);
}
/**
* Gets this object represented as an ArrayIterator.
*
* This allows the data properties to be accessed via a foreach statement.
*
* @return \ArrayIterator This object represented as an ArrayIterator.
*
* @see IteratorAggregate::getIterator()
* @since 3.1.6
*/
#[\ReturnTypeWillChange]
public static function getIterator()
{
// check that if we already have config registry set
if (!self::$CompilerConfig)
{
// create config registry
self::$CompilerConfig = self::create();
}
return self::$CompilerConfig->getIterator();
}
/**
* Set a registry value.
*
* @param string $path Registry Path (e.g. guid.main.0.url)
* @param mixed $value Value of entry
* @param string $separator The key separator
*
* @return mixed The value of the that has been set.
*
* @since 3.1.6
*/
public static function set($path, $value, $separator = null)
{
// check that if we already have config registry set
if (!self::$CompilerConfig)
{
// create config registry
self::$CompilerConfig = self::create();
}
self::$CompilerConfig->set($path, $value, $separator);
}
/**
* Delete a registry value
*
* @param string $path Registry Path (e.g. guid.main.0.url)
*
* @return mixed The value of the removed node or null if not set
*
* @since 3.1.6
*/
public static function remove($path)
{
// check that if we already have config registry set
if (!self::$CompilerConfig)
{
// create config registry
self::$CompilerConfig = self::create();
}
// remove the actual value
return self::$CompilerConfig->remove($path);
}
/**
* Transforms a namespace to an array
*
* @return array An associative array holding the namespace data
*
* @since 3.1.6
*/
public static function toArray()
{
// check that if we already have config registry set
if (!self::$CompilerConfig)
{
// create config registry
self::$CompilerConfig = self::create();
}
return self::$CompilerConfig->toArray();
}
/**
* Transforms a namespace to an object
*
* @return object An an object holding the namespace data
*
* @since 3.1.6
*/
public static function toObject()
{
// check that if we already have config registry set
if (!self::$CompilerConfig)
{
// create config registry
self::$CompilerConfig = self::create();
}
return self::$CompilerConfig->toObject();
}
/**
* Initialize a CompilerConfig object if id does not exist.
*
* Returns the global {@link CompilerConfig} object, only creating it if it doesn't already exist.
*
* @param array $config The data to bind to the new Config object.
*
*
* @return CompilerConfig object
*
* @see Session
* @since 3.1.6
**/
public static function init($config = null): CompilerConfig
{
if (!self::$CompilerConfig)
{
self::$CompilerConfig = self::create($config);
}
return self::$CompilerConfig;
}
/**
* Create a CompilerConfig object
*
* @param array $config The data to bind to the new Config object.
*
* @return CompilerConfig object
* @since 3.1.6
* @throws \Exception
**/
protected static function create($config = null): CompilerConfig
{
// get the session
$session = Factory::getSession();
// check if we have config
if (ArrayHelper::check($config))
{
// save for later should we call this out of scope
$session->set('Componentbuilder.Compiler.Config', $config);
}
// if not found try loading it from the session
elseif (($config = $session->get('Componentbuilder.Compiler.Config', false)) === false)
{
throw new \Exception('Compiler configuration not found.');
}
return new CompilerConfig($config);
}
}

View File

@ -1,58 +0,0 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @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;
/**
* Adds Tabs
*
* @since 3.1.5
*/
trait Tab
{
/**
* Tab/spacer bucket (to speed-up the build)
*
* @var array
* @since 3.1.5
*/
protected $tabSpacerBucket = array();
/**
* Set tab/spacer
*
* @var string
* @since 3.1.5
*/
protected $tabSpacer = "\t";
/**
* Set the tab/space
*
* @param int $nr The number of tag/space
*
* @return string
* @since 3.1.5
*/
public function _t(int $nr) : string
{
// check if we already have the string
if (!isset($this->tabSpacerBucket[$nr]))
{
// get the string
$this->tabSpacerBucket[$nr] = str_repeat($this->tabSpacer, (int) $nr);
}
// return stored string
return $this->tabSpacerBucket[$nr];
}
}

View File

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

View File

@ -41,9 +41,15 @@ COM_COMPONENTBUILDER_FREEOPEN="Free/Open"
COM_COMPONENTBUILDER_GREAT_THIS_PLACEHOLDER_WILL_WORK="Great, this placeholder will work!"
COM_COMPONENTBUILDER_HFOUR_CLASSNAVHEADERCOPYRIGHTHFOURPSP="<h4 class="nav-header">Copyright</h4><p>%s</p>"
COM_COMPONENTBUILDER_HFOUR_CLASSNAVHEADERLICENSEHFOURPSP="<h4 class="nav-header">License</h4><p>%s</p>"
COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_ERRORHTHREE="<hr /><h3>External Code Error</h3>"
COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_NOTICEHTHREE="<hr /><h3>External Code Notice</h3>"
COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_WARNINGHTHREE="<hr /><h3>External Code Warning</h3>"
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_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. 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_HTWOCURL_NOT_FOUNDHTWOPPLEASE_SETUP_CURL_ON_YOUR_SYSTEM_OR_BCOMPONENTBUILDERB_WILL_NOT_FUNCTION_CORRECTLYP="<h2>Curl Not Found!</h2><p>Please setup curl on your system, or <b>componentbuilder</b> will not function correctly!</p>"
COM_COMPONENTBUILDER_IAUTHORI_BSB="<i>Author:</i> <b>%s</b>"
COM_COMPONENTBUILDER_ICOMPANYI_BSB="<i>Company:</i> <b>%s</b>"
COM_COMPONENTBUILDER_ID_MISMATCH_WAS_DETECTED_WITH_THE_SSSS_GUI_CODE_FIELD_SO_THE_PLACEHOLDER_WAS_NOT_SET="ID mismatch was detected with the %s.%s.%s.%s GUI code field. So the placeholder was not set."
COM_COMPONENTBUILDER_IEMAILI_BSB="<i>Email:</i> <b>%s</b>"
COM_COMPONENTBUILDER_IWEBSITEI_BSB="<i>Website:</i> <b>%s</b>"
COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BUILDER_BACKUP_KEY="Joomla Component Builder - Backup Key"
@ -66,19 +72,28 @@ COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS_NOT_FOUND="Package owner details not
COM_COMPONENTBUILDER_PACKAGE_OWNER_NOT_SET="Package Owner Not Set"
COM_COMPONENTBUILDER_PAIDLOCKED="Paid/Locked"
COM_COMPONENTBUILDER_PLUGIN="Plugin"
COM_COMPONENTBUILDER_PPOWER_BGUIDSB_NOT_FOUNDP="<p>Power <b>guid:%s</b> not found!</p>"
COM_COMPONENTBUILDER_PROPERTY="Property"
COM_COMPONENTBUILDER_PS_NAMING_MISMATCH_ERROR_SPPTHE_S_NAME_IS_BSB_AND_THE_ENDING_FILE_NAME_IN_THE_NAMESPACE_IS_BSB_THIS_IS_BAD_CONVENTION_PLEASE_SEE_A_HREFS_PSRFOURA_FOR_MORE_INFOPPA_HREFSCLICK_HEREA_TO_FIX_THIS_ISSUEP="<p>%s naming mismatch error (%s)</p><p>The %s name is <b>%s</b> and the ending file name in the namespace is <b>%s</b>. This is bad convention, please see <a href=%s >psr-4</a> for more info.</p><p><a href=%s>Click here</a> to fix this issue.</p>"
COM_COMPONENTBUILDER_SBR_YOU_CAN_ADD_A_BGITHUB_ACCESS_TOKENB_TO_COMPONENTBUILDER_GLOBAL_OPTIONS_TO_MAKE_AUTHENTICATED_REQUESTS_TO_GITHUB_AN_ACCESS_TOKEN_WITH_ONLY_PUBLIC_ACCESS_WILL_DO_TO_RETRIEVE_S="%s<br />You can add a <b>gitHub Access Token</b> to Componentbuilder global options to make authenticated requests to gitHub. An access token with only public access will do to retrieve %s."
COM_COMPONENTBUILDER_SELECT_EXTENSION="Select Extension"
COM_COMPONENTBUILDER_SINCE_THE_OWNER_DETAILS_ARE_DISPLAYED_DURING_BIMPORT_PROCESSB_BEFORE_ADDING_THE_KEY_THIS_WAY_IF_THE_USERDEV_BDOES_NOTB_HAVE_THE_KEY_THEY_CAN_SEE_BWHERE_TO_GET_ITB="Since the owner details are displayed during <b>import process</b> before adding the key, this way if the user/dev <b>does not</b> have the key they can see <b>where to get it</b>."
COM_COMPONENTBUILDER_SINCE_THE_OWNER_DETAILS_ARE_DISPLAYED_DURING_IMPORT_PROCESS_BEFORE_ADDING_THE_KEY_THIS_WAY_IF_THE_USERDEV_DOES_NOT_HAVE_THE_KEY_THEY_CAN_SEE_WHERE_TO_GET_IT="Since the owner details are displayed during import process before adding the key, this way if the user/dev does not have the key they can see where to get it."
COM_COMPONENTBUILDER_SORRY_THIS_PLACEHOLDER_IS_ALREADY_IN_USE="Sorry this placeholder is already in use!"
COM_COMPONENTBUILDER_SORRY_THIS_PLACEHOLDER_IS_ALREADY_IN_USE_IN_THE_COMPILER="Sorry this placeholder is already in use in the compiler!"
COM_COMPONENTBUILDER_S_WE_DETECTED_A_CHANGE_IN_BEXTERNALCODEB_BUT_YOU_DO_NOT_HAVE_PERMISSION_TO_ALLOW_THIS_CHANGE_SO_BSB_WAS_REMOVED_FROM_THE_COMPILATION_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFOBR_SMALLADMIN_ACCESS_REQUIREDSMALL="%s, we detected a change in <b>EXTERNALCODE</b>, but you do not have permission to allow this change so <b>%s</b> was removed from the compilation. Please contact your system administrator for more info!<br /><small>(admin access required)</small>"
COM_COMPONENTBUILDER_S_WE_DETECTED_BNEW_EXTERNALCODEB_BUT_YOU_DO_NOT_HAVE_PERMISSION_TO_ALLOW_THIS_NEW_CODESTRING_SO_BSB_WAS_REMOVED_FROM_THE_COMPILATION_PLEASE_CONTACT_YOU_SYSTEM_ADMINISTRATOR_FOR_MORE_INFOBR_SMALLADMIN_ACCESS_REQUIREDSMALL="%s, we detected <b>NEW EXTERNALCODE</b>, but you do not have permission to allow this new code/string so <b>%s</b> was removed from the compilation. Please contact you system administrator for more info!<br /><small>(admin access required)</small>"
COM_COMPONENTBUILDER_THAT_MEANS_ANYONE_WHO_HAS_THIS_PACKAGE_CAN_INSTALL_IT_INTO_JCB_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_BSETTINGSB_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_BEXPORT_KEYB="That means anyone who has this package can install it into JCB. To add an export key simply open the component, go to the tab called <b>settings</b>, bottom right there is a field called <b>Export Key</b>."
COM_COMPONENTBUILDER_THAT_MEANS_ANYONE_WHO_HAS_THIS_PACKAGE_CAN_INSTALL_IT_INTO_JCB_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_SETTINGS_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_EXPORT_KEY="That means anyone who has this package can install it into JCB. To add an export key simply open the component, go to the tab called settings, bottom right there is a field called Export Key."
COM_COMPONENTBUILDER_THE_BPHPSECLIBNETSFTPB_LIBRARYCLASS_IS_NOT_AVAILABLE_THIS_LIBRARYCLASS_SHOULD_HAVE_BEEN_ADDED_TO_YOUR_BLIBRARIESVDM_IOVENDORB_FOLDER_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFO="The <b>phpseclib\NET\SFTP</b> library\class is not available! This library\class should have been added to your <b>libraries/vdm_io/vendor</b> folder. Please contact your system administrator for more info"
COM_COMPONENTBUILDER_THE_BSB_CUT_SEQUENCE_FAILED_ON_THE_RETURNED_EXTERNAL_CODESTRING_AS_MORE_LINES_HAS_TO_BE_CUT_THEN_WAS_FOUND_IN_THE_CODESTRING_WE_HAVE_COMPLETELY_REMOVED_THE_CODE_PLEASE_CHECK_THIS_CODESTRING="The <b>%s</b> cut sequence failed on the returned external code/string as more lines has to be cut then was found in the code/string. We have completely removed the code. Please check this code/string!"
COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_PATH_ON_BSB_SERVER="The <b>%s</b> file could not be moved to <b>%s</b> path on <b>%s</b> server."
COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_SERVER="The <b>%s</b> file could not be moved to <b>%s</b> server."
COM_COMPONENTBUILDER_THE_BSB_IS_NOT_A_VALID_URLPATH="The <b>%s</b> is not a valid url/path!"
COM_COMPONENTBUILDER_THE_BSB_LIBRARYCLASS_IS_NOT_AVAILABLE_THIS_LIBRARYCLASS_SHOULD_HAVE_BEEN_ADDED_TO_YOUR_BLIBRARIESPHPSECLIBVENDORB_FOLDER_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFO="The <b>%s</b> library\class is not available! This library\class should have been added to your <b>libraries/phpseclib/vendor</b> folder. Please contact your system administrator for more info!"
COM_COMPONENTBUILDER_THE_BSB_RETURNED_AN_INVALID_STRING="The <b>%s</b> returned an invalid string!"
COM_COMPONENTBUILDER_THE_CODESTRING_FROM_BSB_HAS_BEEN_ADDED_FOR_THE_BFIRST_TIMEB_PLEASE_IINVESTIGATEI_TO_ENSURE_THE_CORRECT_CODESTRING_WAS_USED_BSHOULD_YOU_NOT_KNOW_ABOUT_THIS_NEW_EXTERNAL_CODESTRING_BEING_ADDED_THEN_THIS_IS_A_SERIOUS_DANGER_AND_REQUIRES_IMMEDIATE_ATTENTIONB_DO_NOT_IGNORE_THIS_WARNING_AS_IT_WILL_ONLY_SHOW_BONCEB="The code/string from <b>%s</b> has been added for the <b>first time</b>. Please <i>investigate</i> to ensure the correct code/string was used! <b>Should you not know about this NEW external code/string being added, then this is a serious danger! and requires immediate attention!</b> Do not ignore this warning as it will only show <b>once</b>."
COM_COMPONENTBUILDER_THE_CODESTRING_FROM_BSB_HAS_BEEN_BCHANGEDB_SINCE_THE_LAST_COMPILATION_PLEASE_INVESTIGATE_TO_ENSURE_THE_CHANGES_ARE_SAFE_BSHOULD_YOU_NOT_EXPECT_THIS_CHANGE_TO_THE_EXTERNAL_CODESTRING_BEING_ADDED_THEN_THIS_IS_A_SERIOUS_ISSUE_AND_REQUIRES_IMMEDIATE_ATTENTIONB_DO_NOT_IGNORE_THIS_WARNING_AS_IT_WILL_ONLY_SHOW_BONCEB="The code/string from <b>%s</b> has been <b>changed</b> since the last compilation. Please investigate to ensure the changes are safe! <b>Should you not expect this change to the external code/string being added, then this is a serious issue! and requires immediate attention!</b> Do not ignore this warning as it will only show <b>once</b>."
COM_COMPONENTBUILDER_THE_FTP_CONNECTION_FOR_BSB_COULD_NOT_BE_MADE_PLEASE_CHECK_YOUR_SIGNATURE_DETAILS="The FTP connection for <b>%s</b> could not be made. Please check your signature details!"
COM_COMPONENTBUILDER_THE_FTP_SIGNATURE_FOR_BSB_WAS_NOT_WELL_FORMED_PLEASE_CHECK_YOUR_SIGNATURE_DETAILS="The FTP signature for <b>%s</b> was not well formed, please check your signature details!"
COM_COMPONENTBUILDER_THE_LOGIN_TO_BSB_HAS_FAILED_PLEASE_CHECK_THAT_YOUR_DETAILS_ARE_CORRECT="The login to <b>%s</b> has failed, please check that your details are correct!"

View File

@ -14,6 +14,7 @@ defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\MVC\Model\ItemModel;
use Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory;
/**
* Componentbuilder Api Item Model
@ -193,14 +194,14 @@ class ComponentbuilderModelApi extends ItemModel
public function compileInstall($component)
{
$values = array(
'version' => 3,
'install' => 1,
'component' => 0,
'joomla_version' => 3,
'install' => 0,
'component_id' => 0,
'backup' => 0,
'repository' => 0,
'placeholders' => 2,
'debuglinenr' => 2,
'minify' => 2
'add_placeholders' => 0,
'debug_line_nr' => 0,
'minify' => 0
);
// set the values
foreach ($values as $key => $val)
@ -211,16 +212,18 @@ class ComponentbuilderModelApi extends ItemModel
}
}
// make sure we have a component
if (isset($values['component']) && $values['component'] > 1)
if (isset($values['component_id']) && $values['component_id'] > 1)
{
// make sure the component is published
$published = ComponentbuilderHelper::getVar('joomla_component', (int) $values['component'], 'id', 'published');
$published = ComponentbuilderHelper::getVar('joomla_component', (int) $values['component_id'], 'id', 'published');
// make sure the component is checked in
$checked_out = ComponentbuilderHelper::getVar('joomla_component', (int) $values['component'], 'id', 'checked_out');
$checked_out = ComponentbuilderHelper::getVar('joomla_component', (int) $values['component_id'], 'id', 'checked_out');
if (1 == $published && $checked_out == 0)
{
// load the config values
CFactory::_('Config')->loadArray($values, true);
// start up Compiler
$this->compiler = new Compiler($values);
$this->compiler = new Compiler();
if($this->compiler)
{
// component was compiled
@ -228,12 +231,12 @@ class ComponentbuilderModelApi extends ItemModel
// get compiler model to run the installer
$model = ComponentbuilderHelper::getModel('compiler', JPATH_COMPONENT_ADMINISTRATOR);
// now install components
if (1 == $values['install'] && $model->install($this->compiler->componentFolderName.'.zip'))
if (1 == CFactory::_('Config')->install && $model->install($this->compiler->componentFolderName.'.zip'))
{
// component was installed
$this->messages[] = JText::sprintf('COM_COMPONENTBUILDER_THE_S_WAS_SUCCESSFULLY_INSTALLED_AND_REMOVED_FROM_TEMP_FOLDER', $this->compiler->componentFolderName);
}
elseif (1 != $values['install'])
elseif (1 != CFactory::_('Config')->install)
{
jimport('joomla.filesystem.file');
$config = JFactory::getConfig();