Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
dcb4f86ee2
|
|||
e6c8805143
|
|||
5537a868e3
|
|||
f4fccfe761
|
|||
fca5bd5f42
|
|||
c53ece2a2d
|
|||
d757e14fac
|
|||
1dddba0fc8
|
|||
c5a85f167e
|
|||
4a32d3d50e
|
|||
0512af0f33
|
|||
abe9b5d227
|
|||
4928a8baaf
|
|||
f8ac247377
|
|||
e7500b76eb
|
|||
a0fda76abd
|
|||
154cd5ae1e | |||
d4ffc3addc
|
14
README.md
14
README.md
@ -9,7 +9,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo
|
||||
|
||||
Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have!
|
||||
|
||||
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (3.1.3) with **ALL** its features and **ALL** concepts totally open-source and free!
|
||||
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (3.1.8) with **ALL** its features and **ALL** concepts totally open-source and free!
|
||||
|
||||
> Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
|
||||
|
||||
@ -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*: 9th July, 2022
|
||||
+ *Version*: 3.1.3
|
||||
+ *Last Build*: 20th September, 2022
|
||||
+ *Version*: 3.1.8
|
||||
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
|
||||
+ *Line count*: **311259**
|
||||
+ *Field count*: **2002**
|
||||
+ *File count*: **2050**
|
||||
+ *Folder count*: **349**
|
||||
+ *Line count*: **331607**
|
||||
+ *Field count*: **2004**
|
||||
+ *File count*: **2170**
|
||||
+ *Folder count*: **376**
|
||||
|
||||
> 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)
|
||||
|
@ -9,7 +9,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo
|
||||
|
||||
Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have!
|
||||
|
||||
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (3.1.3) with **ALL** its features and **ALL** concepts totally open-source and free!
|
||||
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (3.1.8) with **ALL** its features and **ALL** concepts totally open-source and free!
|
||||
|
||||
> Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
|
||||
|
||||
@ -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*: 9th July, 2022
|
||||
+ *Version*: 3.1.3
|
||||
+ *Last Build*: 20th September, 2022
|
||||
+ *Version*: 3.1.8
|
||||
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
|
||||
+ *Line count*: **311259**
|
||||
+ *Field count*: **2002**
|
||||
+ *File count*: **2050**
|
||||
+ *Folder count*: **349**
|
||||
+ *Line count*: **331607**
|
||||
+ *Field count*: **2004**
|
||||
+ *File count*: **2170**
|
||||
+ *Folder count*: **376**
|
||||
|
||||
> 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)
|
||||
|
@ -498,6 +498,9 @@
|
||||
<action name="power.edit.state" title="COM_COMPONENTBUILDER_POWERS_EDIT_STATE" description="COM_COMPONENTBUILDER_POWERS_EDIT_STATE_DESC" />
|
||||
<action name="power.version" title="COM_COMPONENTBUILDER_POWERS_EDIT_VERSION" description="COM_COMPONENTBUILDER_POWERS_EDIT_VERSION_DESC" />
|
||||
<action name="power.submenu" title="COM_COMPONENTBUILDER_POWERS_SUBMENU" description="COM_COMPONENTBUILDER_POWERS_SUBMENU_DESC" />
|
||||
<action name="search.access" title="COM_COMPONENTBUILDER_SEARCH_ACCESS" description="COM_COMPONENTBUILDER_SEARCH_ACCESS_DESC" />
|
||||
<action name="search.compiler" title="COM_COMPONENTBUILDER_SEARCH_COMPILER_BUTTON_ACCESS" description="COM_COMPONENTBUILDER_SEARCH_COMPILER_BUTTON_ACCESS_DESC" />
|
||||
<action name="search.submenu" title="COM_COMPONENTBUILDER_SEARCH_SUBMENU" description="COM_COMPONENTBUILDER_SEARCH_SUBMENU_DESC" />
|
||||
<action name="server.access" title="COM_COMPONENTBUILDER_SERVERS_ACCESS" description="COM_COMPONENTBUILDER_SERVERS_ACCESS_DESC" />
|
||||
<action name="server.batch" title="COM_COMPONENTBUILDER_SERVERS_BATCH_USE" description="COM_COMPONENTBUILDER_SERVERS_BATCH_USE_DESC" />
|
||||
<action name="server.create" title="COM_COMPONENTBUILDER_SERVERS_CREATE" description="COM_COMPONENTBUILDER_SERVERS_CREATE_DESC" />
|
||||
|
13
admin/assets/css/search.css
Normal file
13
admin/assets/css/search.css
Normal file
@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
|
||||
/* CSS Document */
|
||||
|
||||
|
@ -20,7 +20,7 @@ defined('_JEXEC') or die('Restricted access');
|
||||
?>
|
||||
<img alt="<?php echo JText::_('COM_###COMPONENT###'); ?>" src="components/com_###component###/assets/images/vdm-component.###COMP_IMAGE_TYPE###">
|
||||
<ul class="list-striped">
|
||||
<li><b><?php echo JText::_('COM_###COMPONENT###_VERSION'); ?>:</b> <?php echo $this->manifest->version; ?> <span class="update-notice"></span></li>
|
||||
<li><b><?php echo JText::_('COM_###COMPONENT###_VERSION'); ?>:</b> <?php echo $this->manifest->version; ?> <span class="update-notice" id="component-update-notice"></span></li>
|
||||
<li><b><?php echo JText::_('COM_###COMPONENT###_DATE'); ?>:</b> <?php echo $this->manifest->creationDate; ?></li>
|
||||
<li><b><?php echo JText::_('COM_###COMPONENT###_AUTHOR'); ?>:</b> <a href="mailto:<?php echo $this->manifest->authorEmail; ?>"><?php echo $this->manifest->author; ?></a></li>
|
||||
<li><b><?php echo JText::_('COM_###COMPONENT###_WEBSITE'); ?>:</b> <a href="<?php echo $this->manifest->authorUrl; ?>" target="_blank"><?php echo $this->manifest->authorUrl; ?></a></li>
|
||||
|
@ -678,16 +678,6 @@
|
||||
size="60"
|
||||
default=""
|
||||
/>
|
||||
<field type="note" name="medium_key_note" class="alert alert-info" label="COM_COMPONENTBUILDER_CONFIG_MEDIUM_KEY_NOTE_LABEL" description="COM_COMPONENTBUILDER_CONFIG_MEDIUM_KEY_NOTE_DESC" />
|
||||
<field name="medium_key_path"
|
||||
type="text"
|
||||
label="COM_COMPONENTBUILDER_CONFIG_MEDIUM_KEY_LABEL"
|
||||
description="COM_COMPONENTBUILDER_CONFIG_MEDIUM_KEY_DESC"
|
||||
size="160"
|
||||
filter="PATH"
|
||||
hint="/home/user/hiddenfolder123/"
|
||||
default=""
|
||||
/>
|
||||
</fieldset>
|
||||
<fieldset
|
||||
name="compiler_custom_config"
|
||||
@ -930,11 +920,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 +963,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>
|
||||
|
@ -35,6 +35,7 @@ class ComponentbuilderControllerAjax extends BaseController
|
||||
$this->registerTask('getComponentDetails', 'ajax');
|
||||
$this->registerTask('getCronPath', 'ajax');
|
||||
$this->registerTask('getWiki', 'ajax');
|
||||
$this->registerTask('getVersion', 'ajax');
|
||||
$this->registerTask('getJCBpackageInfo', 'ajax');
|
||||
$this->registerTask('getCrowdinDetails', 'ajax');
|
||||
$this->registerTask('getModuleCode', 'ajax');
|
||||
@ -66,6 +67,8 @@ class ComponentbuilderControllerAjax extends BaseController
|
||||
$this->registerTask('fieldTypeProperties', 'ajax');
|
||||
$this->registerTask('getFieldPropertyDesc', 'ajax');
|
||||
$this->registerTask('getCodeGlueOptions', 'ajax');
|
||||
$this->registerTask('searchTable', 'ajax');
|
||||
$this->registerTask('updateTable', 'ajax');
|
||||
$this->registerTask('snippetDetails', 'ajax');
|
||||
$this->registerTask('setSnippetGithub', 'ajax');
|
||||
$this->registerTask('getSnippets', 'ajax');
|
||||
@ -295,6 +298,47 @@ class ComponentbuilderControllerAjax extends BaseController
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'getVersion':
|
||||
try
|
||||
{
|
||||
$versionValue = $jinput->get('version', NULL, 'INT');
|
||||
if($versionValue && $user->id != 0)
|
||||
{
|
||||
$result = $this->getModel('ajax')->getVersion($versionValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = false;
|
||||
}
|
||||
if($callback)
|
||||
{
|
||||
echo $callback . "(".json_encode($result).");";
|
||||
}
|
||||
elseif($returnRaw)
|
||||
{
|
||||
echo json_encode($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "(".json_encode($result).");";
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
if($callback)
|
||||
{
|
||||
echo $callback."(".json_encode($e).");";
|
||||
}
|
||||
elseif($returnRaw)
|
||||
{
|
||||
echo json_encode($e);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "(".json_encode($e).");";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'getJCBpackageInfo':
|
||||
try
|
||||
{
|
||||
@ -1589,6 +1633,99 @@ class ComponentbuilderControllerAjax extends BaseController
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'searchTable':
|
||||
try
|
||||
{
|
||||
$table_nameValue = $jinput->get('table_name', NULL, 'WORD');
|
||||
$search_valueValue = $jinput->get('search_value', NULL, 'RAW');
|
||||
$match_caseValue = $jinput->get('match_case', 0, 'INT');
|
||||
$whole_wordValue = $jinput->get('whole_word', 0, 'INT');
|
||||
$regex_searchValue = $jinput->get('regex_search', 0, 'INT');
|
||||
$component_idValue = $jinput->get('component_id', 0, 'INT');
|
||||
if($table_nameValue && $user->id != 0 && $search_valueValue)
|
||||
{
|
||||
$result = $this->getModel('ajax')->searchTable($table_nameValue, $search_valueValue, $match_caseValue, $whole_wordValue, $regex_searchValue, $component_idValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = false;
|
||||
}
|
||||
if($callback)
|
||||
{
|
||||
echo $callback . "(".json_encode($result).");";
|
||||
}
|
||||
elseif($returnRaw)
|
||||
{
|
||||
echo json_encode($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "(".json_encode($result).");";
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
if($callback)
|
||||
{
|
||||
echo $callback."(".json_encode($e).");";
|
||||
}
|
||||
elseif($returnRaw)
|
||||
{
|
||||
echo json_encode($e);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "(".json_encode($e).");";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'updateTable':
|
||||
try
|
||||
{
|
||||
$table_nameValue = $jinput->get('table_name', NULL, 'WORD');
|
||||
$search_valueValue = $jinput->get('search_value', NULL, 'RAW');
|
||||
$replace_valueValue = $jinput->get('replace_value', NULL, 'RAW');
|
||||
$match_caseValue = $jinput->get('match_case', 0, 'INT');
|
||||
$whole_wordValue = $jinput->get('whole_word', 0, 'INT');
|
||||
$regex_searchValue = $jinput->get('regex_search', 0, 'INT');
|
||||
$component_idValue = $jinput->get('component_id', 0, 'INT');
|
||||
if($table_nameValue && $user->id != 0 && $search_valueValue)
|
||||
{
|
||||
$result = $this->getModel('ajax')->updateTable($table_nameValue, $search_valueValue, $replace_valueValue, $match_caseValue, $whole_wordValue, $regex_searchValue, $component_idValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = false;
|
||||
}
|
||||
if($callback)
|
||||
{
|
||||
echo $callback . "(".json_encode($result).");";
|
||||
}
|
||||
elseif($returnRaw)
|
||||
{
|
||||
echo json_encode($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "(".json_encode($result).");";
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
if($callback)
|
||||
{
|
||||
echo $callback."(".json_encode($e).");";
|
||||
}
|
||||
elseif($returnRaw)
|
||||
{
|
||||
echo json_encode($e);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "(".json_encode($e).");";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'snippetDetails':
|
||||
try
|
||||
{
|
||||
|
@ -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();
|
||||
|
42
admin/controllers/search.php
Normal file
42
admin/controllers/search.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
use Joomla\CMS\MVC\Controller\BaseController;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
/**
|
||||
* Componentbuilder Search Base Controller
|
||||
*/
|
||||
class ComponentbuilderControllerSearch extends BaseController
|
||||
{
|
||||
public function __construct($config)
|
||||
{
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
public function dashboard()
|
||||
{
|
||||
$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder', false));
|
||||
return;
|
||||
}
|
||||
|
||||
public function openCompiler()
|
||||
{
|
||||
// Check for request forgeries
|
||||
JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
|
||||
// redirect to the libraries
|
||||
$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=compiler', false));
|
||||
return;
|
||||
}
|
||||
}
|
@ -20,6 +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\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();
|
||||
@ -29,6 +33,8 @@ ComponentbuilderHelper::autoLoader();
|
||||
*/
|
||||
class Compiler extends Infusion
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* The Temp path
|
||||
*
|
||||
@ -74,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
|
||||
@ -88,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);
|
||||
}
|
||||
@ -99,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
|
||||
);
|
||||
@ -118,7 +123,7 @@ class Compiler extends Infusion
|
||||
$this->writeFile($xmlPath, $componentXML);
|
||||
}
|
||||
// Trigger Event: jcb_ce_onBeforeUpdateFiles
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeUpdateFiles',
|
||||
array(&$this->componentContext, &$this)
|
||||
);
|
||||
@ -128,15 +133,15 @@ class Compiler extends Infusion
|
||||
return false;
|
||||
}
|
||||
// Trigger Event: jcb_ce_onBeforeGetCustomCode
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeGetCustomCode',
|
||||
array(&$this->componentContext, &$this)
|
||||
);
|
||||
// now insert into the new files
|
||||
if ($this->getCustomCode())
|
||||
if (CFactory::_('Customcode')->get())
|
||||
{
|
||||
// Trigger Event: jcb_ce_onBeforeAddCustomCode
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeAddCustomCode',
|
||||
array(&$this->componentContext, &$this)
|
||||
);
|
||||
@ -144,7 +149,7 @@ class Compiler extends Infusion
|
||||
$this->addCustomCode();
|
||||
}
|
||||
// Trigger Event: jcb_ce_onBeforeSetLangFileData
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeSetLangFileData',
|
||||
array(&$this->componentContext, &$this)
|
||||
);
|
||||
@ -183,7 +188,7 @@ class Compiler extends Infusion
|
||||
'because more then %s% of the strings have been translated.',
|
||||
$this->percentageLanguageAdd
|
||||
);
|
||||
if ($this->debugLinenr)
|
||||
if (CFactory::_('Config')->get('debug_line_nr', false))
|
||||
{
|
||||
$whyAddedLang = JText::_(
|
||||
'because the debugging mode is on. (debug line numbers)'
|
||||
@ -214,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 ($this->addAssetsTableFix)
|
||||
if (CFactory::_('Config')->add_assets_table_fix)
|
||||
{
|
||||
$this->app->enqueueMessage(
|
||||
JText::_('<hr /><h3>Assets Table Notice</h3>'), 'Notice'
|
||||
);
|
||||
$asset_table_fix_type = ($this->addAssetsTableFix == 2)
|
||||
$asset_table_fix_type = (CFactory::_('Config')->add_assets_table_fix == 2)
|
||||
? 'intelligent' : 'sql';
|
||||
$this->app->enqueueMessage(
|
||||
JText::sprintf(
|
||||
@ -244,7 +249,7 @@ class Compiler extends Infusion
|
||||
);
|
||||
}
|
||||
// set assets table name column warning if not set
|
||||
if (!$this->addAssetsTableFix && $this->addAssetsTableNameFix)
|
||||
if (!CFactory::_('Config')->add_assets_table_fix && $this->addAssetsTableNameFix)
|
||||
{
|
||||
// only add if not already added
|
||||
if ($this->accessSize < 30)
|
||||
@ -281,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)
|
||||
@ -322,7 +327,7 @@ class Compiler extends Infusion
|
||||
// add the mismatching issues
|
||||
foreach ($mismatch as $string)
|
||||
{
|
||||
$constant = $this->langPrefix . '_'
|
||||
$constant = CFactory::_('Config')->lang_prefix . '_'
|
||||
. StringHelper::safe($string, 'U');
|
||||
$this->app->enqueueMessage(
|
||||
JText::sprintf(
|
||||
@ -364,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 ($this->debugLinenr)
|
||||
{
|
||||
return ' [Compiler ' . $nr . ']';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dynamic data to the created fils
|
||||
*
|
||||
@ -597,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])
|
||||
@ -640,12 +627,12 @@ class Compiler extends Infusion
|
||||
protected function setFileContent(&$name, &$path, &$bom, $view = null)
|
||||
{
|
||||
// Trigger Event: jcb_ce_onBeforeSetFileContent
|
||||
$this->triggerEvent(
|
||||
CFactory::_('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'))
|
||||
@ -655,35 +642,35 @@ class Compiler extends Infusion
|
||||
// get content of the file
|
||||
$string = ComponentbuilderHelper::getFileContents($path);
|
||||
// Trigger Event: jcb_ce_onGetFileContents
|
||||
$this->triggerEvent(
|
||||
CFactory::_('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')->update($answer);
|
||||
}
|
||||
// Trigger Event: jcb_ce_onBeforeSetFileContent
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeWriteFileContent',
|
||||
array(&$this->componentContext, &$answer, &$name, &$path, &$bom,
|
||||
&$view)
|
||||
@ -804,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?
|
||||
@ -824,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'];
|
||||
}
|
||||
|
||||
@ -897,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();
|
||||
@ -907,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);
|
||||
}
|
||||
@ -915,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;
|
||||
}
|
||||
|
||||
@ -994,9 +981,9 @@ class Compiler extends Infusion
|
||||
// set the repo path
|
||||
$repoFullPath = $this->repoPath . '/com_'
|
||||
. $this->componentData->sales_name . '__joomla_'
|
||||
. $this->joomlaVersion;
|
||||
. CFactory::_('Config')->get('version', 3);
|
||||
// Trigger Event: jcb_ce_onBeforeUpdateRepo
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeUpdateRepo',
|
||||
array(&$this->componentContext, &$this->componentPath,
|
||||
&$repoFullPath, &$this->componentData)
|
||||
@ -1006,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::_('Event')->trigger(
|
||||
'jcb_ce_onAfterUpdateRepo',
|
||||
array(&$this->componentContext, &$this->componentPath,
|
||||
&$repoFullPath, &$this->componentData)
|
||||
@ -1025,9 +1012,9 @@ class Compiler extends Infusion
|
||||
// set the repo path
|
||||
$repoFullPath = $this->repoPath . '/'
|
||||
. $module->folder_name . '__joomla_'
|
||||
. $this->joomlaVersion;
|
||||
. CFactory::_('Config')->get('version', 3);
|
||||
// Trigger Event: jcb_ce_onBeforeUpdateRepo
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeUpdateRepo',
|
||||
array(&$module_context, &$module->folder_path,
|
||||
&$repoFullPath, &$module)
|
||||
@ -1041,7 +1028,7 @@ class Compiler extends Infusion
|
||||
$module->folder_path, $repoFullPath, '', true
|
||||
);
|
||||
// Trigger Event: jcb_ce_onAfterUpdateRepo
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onAfterUpdateRepo',
|
||||
array(&$module_context, &$module->folder_path,
|
||||
&$repoFullPath, &$module)
|
||||
@ -1062,9 +1049,9 @@ class Compiler extends Infusion
|
||||
// set the repo path
|
||||
$repoFullPath = $this->repoPath . '/'
|
||||
. $plugin->folder_name . '__joomla_'
|
||||
. $this->joomlaVersion;
|
||||
. CFactory::_('Config')->get('version', 3);
|
||||
// Trigger Event: jcb_ce_onBeforeUpdateRepo
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeUpdateRepo',
|
||||
array(&$plugin_context, &$plugin->folder_path,
|
||||
&$repoFullPath, &$plugin)
|
||||
@ -1078,7 +1065,7 @@ class Compiler extends Infusion
|
||||
$plugin->folder_path, $repoFullPath, '', true
|
||||
);
|
||||
// Trigger Event: jcb_ce_onAfterUpdateRepo
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onAfterUpdateRepo',
|
||||
array(&$plugin_context, &$plugin->folder_path,
|
||||
&$repoFullPath, &$plugin)
|
||||
@ -1097,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::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeZipComponent',
|
||||
array(&$this->componentContext, &$this->componentPath,
|
||||
&$this->filepath['component'], &$this->tempPath,
|
||||
@ -1112,7 +1099,7 @@ class Compiler extends Infusion
|
||||
if ($this->backupPath && $this->dynamicIntegration)
|
||||
{
|
||||
// Trigger Event: jcb_ce_onBeforeBackupZip
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeBackupZip', array(&$this->componentContext,
|
||||
&$this->filepath['component'],
|
||||
&$this->tempPath,
|
||||
@ -1134,7 +1121,7 @@ class Compiler extends Infusion
|
||||
if (isset($this->componentData->sales_server))
|
||||
{
|
||||
// Trigger Event: jcb_ce_onBeforeMoveToServer
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeMoveToServer',
|
||||
array(&$this->componentContext,
|
||||
&$this->filepath['component'], &$this->tempPath,
|
||||
@ -1150,7 +1137,7 @@ class Compiler extends Infusion
|
||||
}
|
||||
}
|
||||
// Trigger Event: jcb_ce_onAfterZipComponent
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onAfterZipComponent',
|
||||
array(&$this->componentContext, &$this->filepath['component'],
|
||||
&$this->tempPath, &$this->componentFolderName,
|
||||
@ -1189,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::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeZipModule',
|
||||
array(&$module_context, &$module->folder_path,
|
||||
&$this->filepath['modules'][$module->id],
|
||||
@ -1206,7 +1193,7 @@ class Compiler extends Infusion
|
||||
{
|
||||
$__module_context = 'module.' . $module_context;
|
||||
// Trigger Event: jcb_ce_onBeforeBackupZip
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeBackupZip',
|
||||
array(&$__module_context,
|
||||
&$this->filepath['modules'][$module->id],
|
||||
@ -1228,7 +1215,7 @@ class Compiler extends Infusion
|
||||
if (isset($module->sales_server))
|
||||
{
|
||||
// Trigger Event: jcb_ce_onBeforeMoveToServer
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeMoveToServer',
|
||||
array(&$__module_context,
|
||||
&$this->filepath['modules'][$module->id],
|
||||
@ -1245,7 +1232,7 @@ class Compiler extends Infusion
|
||||
}
|
||||
}
|
||||
// Trigger Event: jcb_ce_onAfterZipModule
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onAfterZipModule', array(&$module_context,
|
||||
&$this->filepath['modules'][$module->id],
|
||||
&$this->tempPath,
|
||||
@ -1283,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::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeZipPlugin',
|
||||
array(&$plugin_context, &$plugin->folder_path,
|
||||
&$this->filepath['plugins'][$plugin->id],
|
||||
@ -1300,7 +1287,7 @@ class Compiler extends Infusion
|
||||
{
|
||||
$__plugin_context = 'plugin.' . $plugin_context;
|
||||
// Trigger Event: jcb_ce_onBeforeBackupZip
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeBackupZip',
|
||||
array(&$__plugin_context,
|
||||
&$this->filepath['plugins'][$plugin->id],
|
||||
@ -1322,7 +1309,7 @@ class Compiler extends Infusion
|
||||
if (isset($plugin->sales_server))
|
||||
{
|
||||
// Trigger Event: jcb_ce_onBeforeMoveToServer
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeMoveToServer',
|
||||
array(&$__plugin_context,
|
||||
&$this->filepath['plugins'][$plugin->id],
|
||||
@ -1339,7 +1326,7 @@ class Compiler extends Infusion
|
||||
}
|
||||
}
|
||||
// Trigger Event: jcb_ce_onAfterZipPlugin
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onAfterZipPlugin', array(&$plugin_context,
|
||||
&$this->filepath['plugins'][$plugin->id],
|
||||
&$this->tempPath,
|
||||
@ -1357,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();
|
||||
@ -1470,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)
|
||||
{
|
||||
@ -1565,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
@ -20,6 +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\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;
|
||||
|
||||
|
||||
/**
|
||||
@ -28,6 +32,7 @@ use VDM\Joomla\Utilities\FileHelper;
|
||||
class Structure extends Get
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* The folder counter
|
||||
*
|
||||
@ -369,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 = $this->compilerPath . '/joomla_'
|
||||
. $this->joomlaVersions[$this->joomlaVersion]['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'
|
||||
. $this->joomlaVersion;
|
||||
. CFactory::_('Config')->joomla_version;
|
||||
$this->componentBackupName = 'com_'
|
||||
. $this->componentData->sales_name . '_v' . str_replace(
|
||||
'.', '_', $this->componentData->component_version
|
||||
) . '__J' . $this->joomlaVersion;
|
||||
) . '__J' . CFactory::_('Config')->joomla_version;
|
||||
$this->componentFolderName = 'com_'
|
||||
. $this->componentData->name_code . '_v' . str_replace(
|
||||
'.', '_', $this->componentData->component_version
|
||||
) . '__J' . $this->joomlaVersion;
|
||||
) . '__J' . CFactory::_('Config')->joomla_version;
|
||||
// set component folder path
|
||||
$this->componentPath = $this->compilerPath . '/'
|
||||
$this->componentPath = CFactory::_('Config')->get('compiler_path', JPATH_COMPONENT_ADMINISTRATOR . '/compiler') . '/'
|
||||
. $this->componentFolderName;
|
||||
// set the template path for custom
|
||||
$this->templatePathCustom = $this->params->get(
|
||||
@ -437,7 +436,7 @@ class Structure extends Get
|
||||
// set the Joomla Version Data
|
||||
$this->joomlaVersionData = $this->setJoomlaVersionData();
|
||||
// Trigger Event: jcb_ce_onAfterSetJoomlaVersionData
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onAfterSetJoomlaVersionData',
|
||||
array(&$this->componentContext, &$this->joomlaVersionData)
|
||||
);
|
||||
@ -465,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 ($this->debugLinenr)
|
||||
{
|
||||
return ' [Structure ' . $nr . ']';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Powers files, folders
|
||||
*
|
||||
@ -491,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::_('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)
|
||||
@ -529,11 +514,16 @@ class Structure extends Get
|
||||
. $power->file_name . '.php',
|
||||
'name' => $power->file_name . '.php',
|
||||
'zip' => $power->file_name . '.php');
|
||||
$bom = '<?php' . PHP_EOL . '// A POWER FILE' .
|
||||
PHP_EOL . Placefix::_h('BOM') . PHP_EOL;
|
||||
// add custom override if found
|
||||
if ($power->add_licensing_template == 2)
|
||||
{
|
||||
$bom = '<?php' . PHP_EOL . $power->licensing_template;
|
||||
}
|
||||
$this->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
|
||||
$bom . PHP_EOL . Placefix::_h('POWERCODE')
|
||||
);
|
||||
$this->newFiles[$power->key][] = $fileDetails;
|
||||
// count the file created
|
||||
@ -605,7 +595,7 @@ class Structure extends Get
|
||||
if (ArrayHelper::check($this->joomlaModules))
|
||||
{
|
||||
// Trigger Event: jcb_ce_onBeforeSetModules
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeBuildModules',
|
||||
array(&$this->componentContext, &$this->joomlaModules)
|
||||
);
|
||||
@ -618,7 +608,7 @@ class Structure extends Get
|
||||
))
|
||||
{
|
||||
// module path
|
||||
$module->folder_path = $this->compilerPath . '/'
|
||||
$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;
|
||||
@ -634,11 +624,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
|
||||
@ -653,7 +643,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 .
|
||||
@ -665,7 +655,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;
|
||||
@ -682,13 +672,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
|
||||
@ -716,11 +706,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
|
||||
@ -735,13 +725,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
|
||||
@ -769,7 +759,7 @@ class Structure extends Get
|
||||
$module->add_scripts_field = false;
|
||||
$field_script_bucket = array();
|
||||
// add any css from the fields
|
||||
if (($css = $this->getCustomScriptBuilder(
|
||||
if (($css = CFactory::_('Customcode.Dispenser')->get(
|
||||
'css_view', $module->key
|
||||
)) !== null
|
||||
&& StringHelper::check($css))
|
||||
@ -788,23 +778,23 @@ 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]);";
|
||||
}
|
||||
}
|
||||
// add any JavaScript from the fields
|
||||
if (($javascript = $this->getCustomScriptBuilder(
|
||||
if (($javascript = CFactory::_('Customcode.Dispenser')->get(
|
||||
'view_footer', $module->key
|
||||
)) !== null
|
||||
&& StringHelper::check($javascript))
|
||||
@ -823,16 +813,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]);";
|
||||
@ -889,7 +879,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
|
||||
. ' -->';
|
||||
@ -918,13 +908,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_'
|
||||
. $this->componentCodeName
|
||||
. CFactory::_('Config')->component_code_name
|
||||
. '/models/rules"';
|
||||
$xml .= PHP_EOL . $this->_t(1)
|
||||
$xml .= PHP_EOL . Indent::_(1)
|
||||
. 'addfieldpath="/administrator/components/com_'
|
||||
. $this->componentCodeName
|
||||
. CFactory::_('Config')->component_code_name
|
||||
. '/models/fields"';
|
||||
$xml .= PHP_EOL . '>';
|
||||
}
|
||||
@ -947,7 +937,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)
|
||||
@ -1001,30 +991,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
|
||||
@ -1032,25 +1022,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
|
||||
@ -1095,7 +1085,7 @@ class Structure extends Get
|
||||
$this->createFolder($module->folder_path . '/language');
|
||||
// also create the lang tag folder
|
||||
$this->createFolder(
|
||||
$module->folder_path . '/language/' . $this->langTag
|
||||
$module->folder_path . '/language/' . CFactory::_('Config')->get('lang_tag', 'en-GB')
|
||||
);
|
||||
// check if this lib has files
|
||||
if (isset($module->files)
|
||||
@ -1186,7 +1176,7 @@ class Structure extends Get
|
||||
if (ArrayHelper::check($this->joomlaPlugins))
|
||||
{
|
||||
// Trigger Event: jcb_ce_onBeforeSetPlugins
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeBuildPlugins',
|
||||
array(&$this->componentContext, &$this->joomlaPlugins)
|
||||
);
|
||||
@ -1199,7 +1189,7 @@ class Structure extends Get
|
||||
))
|
||||
{
|
||||
// plugin path
|
||||
$plugin->folder_path = $this->compilerPath . '/'
|
||||
$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;
|
||||
@ -1215,11 +1205,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
|
||||
@ -1246,13 +1236,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
|
||||
@ -1298,9 +1288,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 ' . $this->componentCodeName
|
||||
. ' form points to ' . CFactory::_('Config')->component_code_name
|
||||
. ' -->';
|
||||
// search if we must add the component path
|
||||
$add_component_path = false;
|
||||
@ -1327,13 +1317,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_'
|
||||
. $this->componentCodeName
|
||||
. CFactory::_('Config')->component_code_name
|
||||
. '/models/rules"';
|
||||
$xml .= PHP_EOL . $this->_t(1)
|
||||
$xml .= PHP_EOL . Indent::_(1)
|
||||
. 'addfieldpath="/administrator/components/com_'
|
||||
. $this->componentCodeName
|
||||
. CFactory::_('Config')->component_code_name
|
||||
. '/models/fields"';
|
||||
$xml .= PHP_EOL . '>';
|
||||
}
|
||||
@ -1356,7 +1346,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)
|
||||
@ -1392,30 +1382,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
|
||||
@ -1423,25 +1413,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
|
||||
@ -1486,7 +1476,7 @@ class Structure extends Get
|
||||
$this->createFolder($plugin->folder_path . '/language');
|
||||
// also creat the lang tag folder path
|
||||
$this->createFolder(
|
||||
$plugin->folder_path . '/language/' . $this->langTag
|
||||
$plugin->folder_path . '/language/' . CFactory::_('Config')->get('lang_tag', 'en-GB')
|
||||
);
|
||||
// check if this lib has files
|
||||
if (isset($plugin->files)
|
||||
@ -1602,7 +1592,7 @@ class Structure extends Get
|
||||
if (ArrayHelper::check($this->libraries))
|
||||
{
|
||||
// Trigger Event: jcb_ce_onBeforeSetLibraries
|
||||
$this->triggerEvent(
|
||||
CFactory::_('Event')->trigger(
|
||||
'jcb_ce_onBeforeSetLibraries',
|
||||
array(&$this->componentContext, &$this->libraries)
|
||||
);
|
||||
@ -1711,9 +1701,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>";
|
||||
}
|
||||
}
|
||||
@ -2071,7 +2060,7 @@ class Structure extends Get
|
||||
$this->joomlaVersionData->move->static
|
||||
))
|
||||
{
|
||||
$codeName = $this->componentCodeName;
|
||||
$codeName = CFactory::_('Config')->component_code_name;
|
||||
// TODO needs more looking at this must be dynamic actually
|
||||
$this->notNew[] = 'LICENSE.txt';
|
||||
// do license check
|
||||
@ -2288,16 +2277,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 . ">";
|
||||
}
|
||||
@ -2347,24 +2336,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
|
||||
);
|
||||
@ -2378,12 +2361,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);
|
||||
}
|
||||
}
|
||||
@ -2415,24 +2395,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);
|
||||
}
|
||||
}
|
||||
@ -2455,24 +2429,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);
|
||||
}
|
||||
}
|
||||
@ -2532,11 +2500,11 @@ class Structure extends Get
|
||||
}
|
||||
}
|
||||
// check if this has validation that should be moved
|
||||
if (isset($this->validationLinkedFields[$field['field']]))
|
||||
if (CFactory::_('Registry')->get('validation.linked.' . $field['field']) !== null)
|
||||
{
|
||||
$check = md5(
|
||||
$path . 'rule'
|
||||
. $this->validationLinkedFields[$field['field']]
|
||||
. CFactory::_('Registry')->get('validation.linked.' . $field['field'])
|
||||
);
|
||||
// lets check if we already moved this
|
||||
if (!isset($this->extentionTrackingFilesMoved[$check]))
|
||||
@ -2544,16 +2512,16 @@ class Structure extends Get
|
||||
// check files exist
|
||||
if (File::exists(
|
||||
$this->componentPath . '/admin/models/rules/'
|
||||
. $this->validationLinkedFields[$field['field']]
|
||||
. CFactory::_('Registry')->get('validation.linked.' . $field['field'])
|
||||
. '.php'
|
||||
))
|
||||
{
|
||||
// copy the custom field
|
||||
File::copy(
|
||||
$this->componentPath . '/admin/models/rules/'
|
||||
. $this->validationLinkedFields[$field['field']]
|
||||
. CFactory::_('Registry')->get('validation.linked.' . $field['field'])
|
||||
. '.php', $path . '/rules/'
|
||||
. $this->validationLinkedFields[$field['field']]
|
||||
. CFactory::_('Registry')->get('validation.linked.' . $field['field'])
|
||||
. '.php'
|
||||
);
|
||||
}
|
||||
@ -2592,7 +2560,7 @@ class Structure extends Get
|
||||
// setup the field
|
||||
$field = array();
|
||||
$field['field'] = $id;
|
||||
$this->setFieldDetails($field);
|
||||
CFactory::_('Field')->set($field);
|
||||
// move field and rules if needed
|
||||
$this->moveFieldsRules($field, $path);
|
||||
}
|
||||
@ -2879,7 +2847,7 @@ class Structure extends Get
|
||||
private function setJoomlaVersionData()
|
||||
{
|
||||
// option to load other settings
|
||||
$custom_settings = $this->templatePath . '/settings_' . $this->componentCodeName . '.json';
|
||||
$custom_settings = $this->templatePath . '/settings_' . CFactory::_('Config')->component_code_name . '.json';
|
||||
// set the version data
|
||||
if (File::exists($custom_settings))
|
||||
{
|
||||
@ -3122,8 +3090,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']);
|
||||
@ -3262,10 +3230,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
@ -56,6 +56,7 @@ spl_autoload_register(function ($class) {
|
||||
}
|
||||
});
|
||||
|
||||
use Joomla\CMS\Filesystem\File;
|
||||
use Joomla\CMS\Language\Language;
|
||||
use Joomla\Registry\Registry;
|
||||
use Joomla\String\StringHelper;
|
||||
@ -63,9 +64,8 @@ use Joomla\Utilities\ArrayHelper;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
use Joomla\Archive\Archive;
|
||||
use Joomla\CMS\Filesystem\File;
|
||||
use Joomla\CMS\Filesystem\Folder;
|
||||
use Joomla\Archive\Archive;
|
||||
use Joomla\CMS\Filesystem\Folder;
|
||||
use Joomla\CMS\Filesystem\Path;
|
||||
use VDM\Joomla\Utilities;
|
||||
|
||||
@ -3550,6 +3550,9 @@ abstract class ComponentbuilderHelper
|
||||
),
|
||||
'special' => array(
|
||||
'contentlanguage', 'moduleposition', 'plugin', 'repeatable', 'subform'
|
||||
),
|
||||
'search' => array(
|
||||
'editor', 'email', 'tel', 'text', 'textarea', 'url', 'subform'
|
||||
)
|
||||
);
|
||||
|
||||
@ -3678,30 +3681,34 @@ abstract class ComponentbuilderHelper
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* prepare base64 string for url
|
||||
**/
|
||||
public static function base64_urlencode($string, $encode = false)
|
||||
{
|
||||
if ($encode)
|
||||
{
|
||||
$string = base64_encode($string);
|
||||
}
|
||||
return str_replace(array('+', '/'), array('-', '_'), $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* prepare base64 string form url
|
||||
**/
|
||||
public static function base64_urldecode($string, $decode = false)
|
||||
{
|
||||
$string = str_replace(array('-', '_'), array('+', '/'), $string);
|
||||
if ($decode)
|
||||
{
|
||||
$string = base64_decode($string);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
/**
|
||||
* prepare base64 string for url
|
||||
*
|
||||
* @deprecate Use urlencode();
|
||||
*/
|
||||
public static function base64_urlencode($string, $encode = false)
|
||||
{
|
||||
if ($encode)
|
||||
{
|
||||
$string = base64_encode($string);
|
||||
}
|
||||
return str_replace(array('+', '/'), array('-', '_'), $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* prepare base64 string form url
|
||||
*
|
||||
* @deprecate
|
||||
*/
|
||||
public static function base64_urldecode($string, $decode = false)
|
||||
{
|
||||
$string = str_replace(array('-', '_'), array('+', '/'), $string);
|
||||
if ($decode)
|
||||
{
|
||||
$string = base64_decode($string);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -6314,6 +6321,11 @@ abstract class ComponentbuilderHelper
|
||||
{
|
||||
JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_COMPILER'), 'index.php?option=com_componentbuilder&view=compiler', $submenu === 'compiler');
|
||||
}
|
||||
// Access control (search.submenu).
|
||||
if ($user->authorise('search.submenu', 'com_componentbuilder'))
|
||||
{
|
||||
JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_SEARCH'), 'index.php?option=com_componentbuilder&view=search', $submenu === 'search');
|
||||
}
|
||||
if ($user->authorise('joomla_component.access', 'com_componentbuilder') && $user->authorise('joomla_component.submenu', 'com_componentbuilder'))
|
||||
{
|
||||
JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_JOOMLA_COMPONENTS'), 'index.php?option=com_componentbuilder&view=joomla_components', $submenu === 'joomla_components');
|
||||
|
@ -191,7 +191,7 @@ class Builder extends Mapping
|
||||
*/
|
||||
protected function setField(&$view, &$field)
|
||||
{
|
||||
if ($fieldType = $this->getFieldType($field['fieldType']))
|
||||
if ($fieldType = CFactory::_('Field.Type.Name')->get($field['fieldType']))
|
||||
{
|
||||
// set the field object
|
||||
$object = new stdClass();
|
||||
|
@ -1292,6 +1292,7 @@ COM_COMPONENTBUILDER_AJAX="Ajax"
|
||||
COM_COMPONENTBUILDER_ALIAS="Alias"
|
||||
COM_COMPONENTBUILDER_ALIGNMENT="Alignment"
|
||||
COM_COMPONENTBUILDER_ALL="All"
|
||||
COM_COMPONENTBUILDER_ALL_FOUND_INSTANCES_IN_S_WHERE_REPLACED="All found instances in %s where replaced"
|
||||
COM_COMPONENTBUILDER_ALL_IS_GOOD_PLEASE_CHECK_AGAIN_LATTER="All is good, please check again latter."
|
||||
COM_COMPONENTBUILDER_ALL_IS_GOOD_THERE_IS_NO_NOTICE_AT_THIS_TIME="All is good, there is no notice at this time."
|
||||
COM_COMPONENTBUILDER_ALL_OF_THESE_PACKAGES_ARE_A_FULLY_DEVELOPEDMAPPED_COMPONENTS_FOR_JCB_THEY_CAN_BE_SEEN_AS_DEMO_CONTENT_OR_BASE_IMAGES_FROM_WHICH_TO_START_YOUR_PROJECTBR_ALWAYS_MAKE_SURE_YOU_ARE_ON_THE_LATEST_VERSION_OF_JCB_BEFORE_IMPORTING_ANY_OF_THESE_PACKAGES_SHOULD_ANY_OF_THEM_FAIL_TO_IMPORT_A_S_PLEASE_LET_US_KNOWA="All of these packages are a fully developed/mapped components for JCB. They can be seen as demo content, or base images from which to start your project.<br />Always make sure you are on the latest version of JCB before importing any of these packages, should any of them fail to import <a %s >please let us know</a>."
|
||||
@ -3230,6 +3231,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 +3344,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."
|
||||
@ -3526,11 +3529,6 @@ COM_COMPONENTBUILDER_CONFIG_MAIL_CONFIGURATION="Mail Configuration"
|
||||
COM_COMPONENTBUILDER_CONFIG_MANAGE_JCB_PACKAGE_DIRECTORIES_DESCRIPTION="Here you can choose to manually select what directories should show, or turn them off altogether."
|
||||
COM_COMPONENTBUILDER_CONFIG_MANAGE_JCB_PACKAGE_DIRECTORIES_LABEL="Manage JCB Package Directories"
|
||||
COM_COMPONENTBUILDER_CONFIG_MANUAL_SELECTION="Manual Selection"
|
||||
COM_COMPONENTBUILDER_CONFIG_MEDIUM_KEY_DESC="Set the full path to where the key file must be stored. Make sure it is behind the root folder of your website, so that it is not public accessible."
|
||||
COM_COMPONENTBUILDER_CONFIG_MEDIUM_KEY_LABEL="Medium Key (Path)"
|
||||
COM_COMPONENTBUILDER_CONFIG_MEDIUM_KEY_NOTE_DESC="When using the medium encryption option, the system generates its own key and stores it in a file at the folder/path you set here.<br />Never change this key once it is set, or remove the key file! <b>DATA WILL GET CORRUPTED IF YOU DO!</b> Also make sure the full path to where the the key file should be stored, is behind the root folder of your website/system, so that it is not public accessible. Making a backup of this key file over a <b>secure connection</b> is recommended!"
|
||||
COM_COMPONENTBUILDER_CONFIG_MEDIUM_KEY_NOTE_LABEL="Medium Encryption"
|
||||
COM_COMPONENTBUILDER_CONFIG_MEDIUM_KEY_PATH_ERROR="Medium key path (for encryption of various fields) does not exist, or is not writable. Please check the path and update it in the global option of this component."
|
||||
COM_COMPONENTBUILDER_CONFIG_MENU_PREFIX_DESCRIPTION="Add the prefix you would like to use. Make sure that it is HTML Character Entities since it is being used in XML."
|
||||
COM_COMPONENTBUILDER_CONFIG_MENU_PREFIX_HINT="»"
|
||||
COM_COMPONENTBUILDER_CONFIG_MENU_PREFIX_LABEL="Prefix<br />
|
||||
@ -3604,8 +3602,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)"
|
||||
@ -5483,7 +5479,7 @@ COM_COMPONENTBUILDER_GET_SNIPPETS_TEMPLATES_BUTTON_ACCESS_DESC="Allows the users
|
||||
COM_COMPONENTBUILDER_GET_THE_SNIPPET_FROM_GITHUB_AND_INSTALL_IT_LOCALLY="Get the snippet from gitHub and install it locally"
|
||||
COM_COMPONENTBUILDER_GET_THE_SNIPPET_FROM_GITHUB_AND_UPDATE_THE_LOCAL_VERSION="Get the snippet from gitHub and update the local version"
|
||||
COM_COMPONENTBUILDER_GET_TOKEN="Get Token"
|
||||
COM_COMPONENTBUILDER_GET_TOKEN_FROM_VDM_FOR_UPDATES_AND_ADD_IT_TO_YOUR_GLOBAL_OPTIONS="Get token from VDM for updates, and add it to your global options"
|
||||
COM_COMPONENTBUILDER_GET_TOKEN_FROM_VDM_TO_GET_UPDATE_NOTICE_AND_ADD_IT_TO_YOUR_GLOBAL_OPTIONS="Get token from VDM to get update notice, and add it to your global options."
|
||||
COM_COMPONENTBUILDER_GLOBAL="Global"
|
||||
COM_COMPONENTBUILDER_GLUECODE="Glue/Code"
|
||||
COM_COMPONENTBUILDER_GREAT_THIS_FUNCTION_NAME_WILL_WORK="Great, this function name will work!"
|
||||
@ -5597,8 +5593,14 @@ 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_HTHREECUSTOM_CODES_WARNINGHTHREE="<hr /><h3>Custom Codes Warning</h3>"
|
||||
COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_ERRORHTHREE="<hr /><h3>External Code Error</h3>"
|
||||
COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_NOTICEHTHREE="<hr /><h3>External Code Notice</h3>"
|
||||
COM_COMPONENTBUILDER_HR_HTHREEEXTERNAL_CODE_WARNINGHTHREE="<hr /><h3>External Code Warning</h3>"
|
||||
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 +5609,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"
|
||||
@ -7787,6 +7790,7 @@ COM_COMPONENTBUILDER_NO_CRONJOB_PATH_FOUND_SINCE_INCORRECT_TYPE_REQUESTED="No cr
|
||||
COM_COMPONENTBUILDER_NO_DESCRIPTION_FOUND="No description found."
|
||||
COM_COMPONENTBUILDER_NO_FILES_LINKED="No Files Linked"
|
||||
COM_COMPONENTBUILDER_NO_FOUND="No Found"
|
||||
COM_COMPONENTBUILDER_NO_INSTANCES_WHERE_FOUND_S="No instances where found %s"
|
||||
COM_COMPONENTBUILDER_NO_ITEM_FOUND="No Item Found"
|
||||
COM_COMPONENTBUILDER_NO_KEYS_WERE_FOUND_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_SETTINGS_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_EXPORT_KEY="No keys were found. 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_NO_LANGUAGES_FOUND="No Languages Found"
|
||||
@ -7810,7 +7814,7 @@ COM_COMPONENTBUILDER_OPTIONS="Options"
|
||||
COM_COMPONENTBUILDER_ORDER_BEFORE="Order Before"
|
||||
COM_COMPONENTBUILDER_ORDER_IN_EDIT="Order in Edit"
|
||||
COM_COMPONENTBUILDER_ORDER_IN_LIST_VIEWS="Order in list views"
|
||||
COM_COMPONENTBUILDER_OUT_OF_DATE="Out of Date"
|
||||
COM_COMPONENTBUILDER_OUT_OF_DATE="Out of date"
|
||||
COM_COMPONENTBUILDER_OWNER_DETAILS_WAS_SET="Owner details was set"
|
||||
COM_COMPONENTBUILDER_OWNER_S="Owner: %s"
|
||||
COM_COMPONENTBUILDER_PACKAGE="Package"
|
||||
@ -7995,6 +7999,8 @@ COM_COMPONENTBUILDER_POWERS_SUBMENU_DESC="Allows the users in this group to subm
|
||||
COM_COMPONENTBUILDER_POWER_ABSTRACT_CLASS="abstract class"
|
||||
COM_COMPONENTBUILDER_POWER_ADD_HEAD_DESCRIPTION="You can add your own custom header script, combined with the default header script that make the extended class work."
|
||||
COM_COMPONENTBUILDER_POWER_ADD_HEAD_LABEL="Add Custom Class Header"
|
||||
COM_COMPONENTBUILDER_POWER_ADD_LICENSING_TEMPLATE_DESCRIPTION="The option to override the licensing template."
|
||||
COM_COMPONENTBUILDER_POWER_ADD_LICENSING_TEMPLATE_LABEL="Add Licensing Template"
|
||||
COM_COMPONENTBUILDER_POWER_AS_LABEL="as"
|
||||
COM_COMPONENTBUILDER_POWER_CLASS="class"
|
||||
COM_COMPONENTBUILDER_POWER_CODE="Code"
|
||||
@ -8025,6 +8031,17 @@ COM_COMPONENTBUILDER_POWER_IMPLEMENTS_CUSTOM_MESSAGE="Error! Please add the cust
|
||||
COM_COMPONENTBUILDER_POWER_IMPLEMENTS_DESCRIPTION="The interface(s), this class should implement."
|
||||
COM_COMPONENTBUILDER_POWER_IMPLEMENTS_LABEL="Implements interface(s)"
|
||||
COM_COMPONENTBUILDER_POWER_INTERFACE="interface"
|
||||
COM_COMPONENTBUILDER_POWER_LICENSING="Licensing"
|
||||
COM_COMPONENTBUILDER_POWER_LICENSING_TEMPLATE_HINT="/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 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
|
||||
*/"
|
||||
COM_COMPONENTBUILDER_POWER_LICENSING_TEMPLATE_LABEL="Licensing Template"
|
||||
COM_COMPONENTBUILDER_POWER_LOAD="Load"
|
||||
COM_COMPONENTBUILDER_POWER_LOAD_LABEL="load"
|
||||
COM_COMPONENTBUILDER_POWER_LOAD_POWERS_NOTE_DESCRIPTION="<p>When you would like to load a power to the project, but you do not want that power to be part of the <b>use namespace declarations</b> in the header of this power.</p>
|
||||
@ -8080,6 +8097,7 @@ COM_COMPONENTBUILDER_POWER_NOTE_LINKED_TO_NOTICE_DESCRIPTION="<div id='display_l
|
||||
COM_COMPONENTBUILDER_POWER_NOTE_LINKED_TO_NOTICE_LABEL="Linked To"
|
||||
COM_COMPONENTBUILDER_POWER_NOT_REQUIRED="Not Required"
|
||||
COM_COMPONENTBUILDER_POWER_ORDERING_LABEL="Ordering"
|
||||
COM_COMPONENTBUILDER_POWER_OVERRIDE="Override"
|
||||
COM_COMPONENTBUILDER_POWER_PERMISSION="Permissions"
|
||||
COM_COMPONENTBUILDER_POWER_POWER_VERSION_DESCRIPTION="Add Version Number Here"
|
||||
COM_COMPONENTBUILDER_POWER_POWER_VERSION_HINT="1.0.0"
|
||||
@ -8102,21 +8120,25 @@ COM_COMPONENTBUILDER_POWER_TRAIT="trait"
|
||||
COM_COMPONENTBUILDER_POWER_TYPE_DESCRIPTION="The type of power being build"
|
||||
COM_COMPONENTBUILDER_POWER_TYPE_LABEL="Type of Power"
|
||||
COM_COMPONENTBUILDER_POWER_USE="Use"
|
||||
COM_COMPONENTBUILDER_POWER_USE_GLOBAL="Use Global"
|
||||
COM_COMPONENTBUILDER_POWER_USE_LABEL="use"
|
||||
COM_COMPONENTBUILDER_POWER_USE_SELECTION_DESCRIPTION="Select namespace you want to use in your power."
|
||||
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"
|
||||
COM_COMPONENTBUILDER_README="Readme"
|
||||
COM_COMPONENTBUILDER_READY_TO_COMPILE_A_COMPONENT="Ready to compile a component"
|
||||
COM_COMPONENTBUILDER_REFRESH="Refresh"
|
||||
COM_COMPONENTBUILDER_REMOVE="Remove"
|
||||
@ -8133,7 +8155,15 @@ COM_COMPONENTBUILDER_RUN_EXPANSION="Run Expansion"
|
||||
COM_COMPONENTBUILDER_SAVE_SUCCESS="Great! Item successfully saved."
|
||||
COM_COMPONENTBUILDER_SAVE_WARNING="The value already existed so please select another."
|
||||
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_SEARCH="Search"
|
||||
COM_COMPONENTBUILDER_SEARCHABLE="Searchable"
|
||||
COM_COMPONENTBUILDER_SEARCH_ACCESS="Search Access"
|
||||
COM_COMPONENTBUILDER_SEARCH_ACCESS_DESC="Allows the users in this group to access search."
|
||||
COM_COMPONENTBUILDER_SEARCH_COMPILER_BUTTON_ACCESS="Search Compiler Button Access"
|
||||
COM_COMPONENTBUILDER_SEARCH_COMPILER_BUTTON_ACCESS_DESC="Allows the users in this group to access the compiler button."
|
||||
COM_COMPONENTBUILDER_SEARCH_DESC="JCB Search"
|
||||
COM_COMPONENTBUILDER_SEARCH_SUBMENU="Search Submenu"
|
||||
COM_COMPONENTBUILDER_SEARCH_SUBMENU_DESC="Allows the users in this group to submenu of Search"
|
||||
COM_COMPONENTBUILDER_SEE_ALL_IMPORT_INFO="See All Import Info"
|
||||
COM_COMPONENTBUILDER_SELECTION="selection"
|
||||
COM_COMPONENTBUILDER_SELECT_ADMIN_VIEW="Select Admin View"
|
||||
@ -8952,6 +8982,7 @@ COM_COMPONENTBUILDER_SUBMENU_LAYOUTS="Layouts"
|
||||
COM_COMPONENTBUILDER_SUBMENU_LIBRARIES="Libraries"
|
||||
COM_COMPONENTBUILDER_SUBMENU_PLACEHOLDERS="Placeholders"
|
||||
COM_COMPONENTBUILDER_SUBMENU_POWERS="Powers"
|
||||
COM_COMPONENTBUILDER_SUBMENU_SEARCH="Search"
|
||||
COM_COMPONENTBUILDER_SUBMENU_SERVERS="Servers"
|
||||
COM_COMPONENTBUILDER_SUBMENU_SITE_VIEWS="Site Views"
|
||||
COM_COMPONENTBUILDER_SUBMENU_SNIPPETS="Snippets"
|
||||
@ -8966,6 +8997,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."
|
||||
@ -9093,6 +9126,7 @@ COM_COMPONENTBUILDER_THERE_ARE_NO_NEW_SNIPPETS_AT_THIS_TIME="There are no new sn
|
||||
COM_COMPONENTBUILDER_THERE_ARE_NO_OUT_OF_DATE_SNIPPETS_AT_THIS_TIME="There are no out of date snippets at this time"
|
||||
COM_COMPONENTBUILDER_THERE_ARE_NO_SNIPPETS_TO_UPDATE_AT_THIS_TIME="There are no snippets to update at this time"
|
||||
COM_COMPONENTBUILDER_THERE_HAS_BEEN_AN_ERROR_IF_THIS_CONTINUES_PLEASE_INFORM_YOUR_SYSTEM_ADMINISTRATOR_OF_A_TYPE_ERROR_IN_THE_FIELDS_DISPLAY_REQUEST="There has been an error, if this continues please inform your system administrator of a type error in the fields display request!"
|
||||
COM_COMPONENTBUILDER_THERE_HAS_BEEN_AN_ERROR_PLEASE_TRY_AGAIN="There has been an error please try again"
|
||||
COM_COMPONENTBUILDER_THERE_WAS_AN_ERROR_GETTING_THE_PACKAGE_INFO="There was an error getting the package info."
|
||||
COM_COMPONENTBUILDER_THERE_WAS_A_PROBLEM_BNO_VIEW_OR_ID_FOUND_IN_SESSION_OR_VIEW_NOT_ALLOWED_TO_ACCESS_AREAB_WE_COULD_NOT_LOAD_ANY_LINKED_TO_VALUES_PLEASE_INFORM_YOUR_SYSTEM_ADMINISTRATOR="There was a problem, <b>no view or id found in session or view not allowed to access area</b>, we could not load any linked to values. Please inform your system administrator!"
|
||||
COM_COMPONENTBUILDER_THESE_ARE_THE_SAME_PACKAGES_FOUND_ON_A_S_GITHUBA_AND_CAN_BE_IMPORTED_BY_SIMPLY_MAKING_A_SELECTION_AND_THEN_CLICKING_THE_BGET_PACKAGEB_BUTTONBR_SOME_OF_THESE_PACKAGES_WOULD_REQUIRE_A_KEY_SINCE_THEY_ARE_NOT_FREE="These are the same packages found on <a %s >gitHub</a> and can be imported by simply making a selection and then clicking the <b>[Get Package]</b> button.<br />Some of these packages would require a key, since they are not free."
|
||||
@ -9109,12 +9143,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 & 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"
|
||||
@ -9345,8 +9384,11 @@ COM_COMPONENTBUILDER_WEBSITE_OF_S="Website of %s"
|
||||
COM_COMPONENTBUILDER_WEBSITE_S="Website: %s"
|
||||
COM_COMPONENTBUILDER_WE_DID_NOT_CHECK_THE_SNIPPET_IT_SELF_TO_SEE_IF_IT_CHANGED_WE_ONLY_WORK_ON_DATES="We did not check the snippet it self, to see if it changed. We only work on dates."
|
||||
COM_COMPONENTBUILDER_WE_FAILED_TO_MOVE_BSB="We failed to move <b>%s</b>!"
|
||||
COM_COMPONENTBUILDER_WE_FOUND_DYNAMIC_CODE_BALL_IN_ONE_LINEB_AND_IGNORED_IT_PLEASE_REVIEW_S_FOR_MORE_DETAILS="We found dynamic code <b>all in one line</b>, and ignored it! Please review (%s) for more details!"
|
||||
COM_COMPONENTBUILDER_WE_FOUND_SOME_INSTANCES_IN_S="We found some instances in %s"
|
||||
COM_COMPONENTBUILDER_WE_SUCCESSFULLY_MOVED_BSB="We successfully moved <b>%s</b>!"
|
||||
COM_COMPONENTBUILDER_WHILE_WE_DOWNLOAD_ALL_TWENTY_SIX_COMPILER_GIF_ANIMATIONS_RANDOMLY_USED_IN_THE_COMPILER_GUI_DURING_COMPILATION="While we download all 26 compiler GIF animations randomly used in the compiler GUI during compilation"
|
||||
COM_COMPONENTBUILDER_WIKI="Wiki"
|
||||
COM_COMPONENTBUILDER_YES="Yes"
|
||||
COM_COMPONENTBUILDER_YOUR_DATA_IS_ENCRYPTED_WITH_A_AES_ONE_HUNDRED_AND_TWENTY_EIGHT_BIT_ENCRYPTION_USING_THE_ABOVE_THIRTY_TWO_CHARACTER_KEY="Your data is encrypted with a AES 128 bit encryption using the above 32 character key."
|
||||
COM_COMPONENTBUILDER_YOUR_DATA_IS_ENCRYPTED_WITH_A_AES_ONE_HUNDRED_AND_TWENTY_EIGHT_BIT_ENCRYPTION_USING_THE_ABOVE_THIRTY_TWO_CHARACTER_KEY_WITHOUT_THIS_KEY_IT_WILL_TAKE_THE_CURRENT_TECHNOLOGY_WITH_A_BRUTE_FORCE_ATTACK_METHOD_MORE_THEN_A_HREFHTTPRANDOMIZECOMHOWLONGTOHACKPASS_TARGET_BLANK_TITLEHOW_LONG_TO_HACK_PASSSEVEN_HUNDRED_ZERO_ZERO_ZERO_ZERO_ZERO_ZERO_ZERO_ZERO_ZERO_ZEROA_YEARS_TO_CRACK_THEORETICALLY_UNLESS_THEY_HAVE_THIS_KEY_ABOVE_SO_DO_KEEP_IT_SAFE="Your data is encrypted with a AES 128 bit encryption using the above 32 character key. Without this key it will take the current technology with a brute force attack method more then <a href="http://random-ize.com/how-long-to-hack-pass/" target="_blank" title="How long to hack pass">700 000 000 000 000 000 000 000 000 000 000</a> years to crack theoretically. Unless they have this key above, so do keep it safe."
|
||||
|
@ -963,6 +963,7 @@ COM_COMPONENTBUILDER_MENU_LAYOUTS="Layouts"
|
||||
COM_COMPONENTBUILDER_MENU_LIBRARIES="Libraries"
|
||||
COM_COMPONENTBUILDER_MENU_PLACEHOLDERS="Placeholders"
|
||||
COM_COMPONENTBUILDER_MENU_POWERS="Powers"
|
||||
COM_COMPONENTBUILDER_MENU_SEARCH="Search"
|
||||
COM_COMPONENTBUILDER_MENU_SITE_VIEWS="Site Views"
|
||||
COM_COMPONENTBUILDER_MENU_SNIPPETS="Snippets"
|
||||
COM_COMPONENTBUILDER_MENU_TEMPLATES="Templates"
|
||||
@ -1017,6 +1018,12 @@ COM_COMPONENTBUILDER_POWERS_SUBMENU="Powers Submenu"
|
||||
COM_COMPONENTBUILDER_POWERS_SUBMENU_DESC="Allows the users in this group to submenu of power"
|
||||
COM_COMPONENTBUILDER_POWER_RUN_EXPANSION_BUTTON_ACCESS="Power Run Expansion Button Access"
|
||||
COM_COMPONENTBUILDER_POWER_RUN_EXPANSION_BUTTON_ACCESS_DESC="Allows the users in this group to access the run expansion button."
|
||||
COM_COMPONENTBUILDER_SEARCH_ACCESS="Search Access"
|
||||
COM_COMPONENTBUILDER_SEARCH_ACCESS_DESC="Allows the users in this group to access search."
|
||||
COM_COMPONENTBUILDER_SEARCH_COMPILER_BUTTON_ACCESS="Search Compiler Button Access"
|
||||
COM_COMPONENTBUILDER_SEARCH_COMPILER_BUTTON_ACCESS_DESC="Allows the users in this group to access the compiler button."
|
||||
COM_COMPONENTBUILDER_SEARCH_SUBMENU="Search Submenu"
|
||||
COM_COMPONENTBUILDER_SEARCH_SUBMENU_DESC="Allows the users in this group to submenu of Search"
|
||||
COM_COMPONENTBUILDER_SERVERS_ACCESS="Servers Access"
|
||||
COM_COMPONENTBUILDER_SERVERS_ACCESS_DESC="Allows the users in this group to access access servers"
|
||||
COM_COMPONENTBUILDER_SERVERS_BATCH_USE="Servers Batch Use"
|
||||
|
@ -29,10 +29,10 @@ $fields = $displayData->get($fields_tab_layout) ?: array(
|
||||
'name',
|
||||
'description',
|
||||
'extends',
|
||||
'implements_custom',
|
||||
'implements',
|
||||
'namespace',
|
||||
'extends_custom',
|
||||
'implements',
|
||||
'implements_custom',
|
||||
'namespace',
|
||||
'add_head'
|
||||
);
|
||||
|
||||
|
45
admin/layouts/power/licensing_fullwidth.php
Normal file
45
admin/layouts/power/licensing_fullwidth.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
// get the form
|
||||
$form = $displayData->getForm();
|
||||
|
||||
// get the layout fields override method name (from layout path/ID)
|
||||
$layout_path_array = explode('.', $this->getLayoutId());
|
||||
// Since we cannot pass the layout and tab names as parameters to the model method
|
||||
// this name combination of tab and layout in the method name is the only work around
|
||||
// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name.
|
||||
// example of layout name: details_left.php
|
||||
// example of method name: getFields_details_left()
|
||||
$fields_tab_layout = 'fields_' . $layout_path_array[1];
|
||||
|
||||
// get the fields
|
||||
$fields = $displayData->get($fields_tab_layout) ?: array(
|
||||
'add_licensing_template',
|
||||
'licensing_template'
|
||||
);
|
||||
|
||||
$hiddenFields = $displayData->get('hidden_fields') ?: array();
|
||||
|
||||
?>
|
||||
<?php if ($fields && count((array) $fields)) :?>
|
||||
<div class="form-vertical">
|
||||
<?php foreach($fields as $field): ?>
|
||||
<?php if (in_array($field, $hiddenFields)) : ?>
|
||||
<?php $form->setFieldAttribute($field, 'type', 'hidden'); ?>
|
||||
<?php endif; ?>
|
||||
<?php echo $form->renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
@ -16,6 +16,7 @@ use Joomla\CMS\MVC\Model\ListModel;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
use Joomla\Registry\Registry;
|
||||
use VDM\Gitea\Gitea;
|
||||
use VDM\Joomla\Componentbuilder\Search\Factory as SearchFactory;
|
||||
|
||||
/**
|
||||
* Componentbuilder Ajax List Model
|
||||
@ -305,15 +306,15 @@ class ComponentbuilderModelAjax extends ListModel
|
||||
}
|
||||
catch (DomainException $e)
|
||||
{
|
||||
return $this->getTokenFromVDM($e->getMessage());
|
||||
return $this->getTokenForWiki($e->getMessage());
|
||||
}
|
||||
catch (InvalidArgumentException $e)
|
||||
{
|
||||
return $this->getTokenFromVDM($e->getMessage());
|
||||
return $this->getTokenForWiki($e->getMessage());
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
return $this->getTokenFromVDM($e->getMessage());
|
||||
return $this->getTokenForWiki($e->getMessage());
|
||||
}
|
||||
|
||||
// get the html
|
||||
@ -322,10 +323,10 @@ class ComponentbuilderModelAjax extends ListModel
|
||||
return ['page' => $page];
|
||||
}
|
||||
|
||||
return $this->getTokenFromVDM();
|
||||
return $this->getTokenForWiki();
|
||||
}
|
||||
|
||||
protected function getTokenFromVDM($message = null)
|
||||
protected function getTokenForWiki($message = null)
|
||||
{
|
||||
if ($message)
|
||||
{
|
||||
@ -333,7 +334,94 @@ class ComponentbuilderModelAjax extends ListModel
|
||||
}
|
||||
|
||||
return ['error' => JText::_('COM_COMPONENTBUILDER_THE_WIKI_CAN_ONLY_BE_LOADED_WHEN_YOUR_JCB_SYSTEM_HAS_INTERNET_CONNECTION')];
|
||||
}
|
||||
}
|
||||
|
||||
public function getVersion($version = null)
|
||||
{
|
||||
// get the token if set
|
||||
$token = JComponentHelper::getParams('com_componentbuilder')->get('gitea_token', false);
|
||||
// only add if token is set
|
||||
if ($token)
|
||||
{
|
||||
// setup a registry
|
||||
$options = new Registry;
|
||||
$options->set('access.token', $token);
|
||||
// get the gitea http
|
||||
try
|
||||
{
|
||||
// get gitea object
|
||||
$gitea = new Gitea($options);
|
||||
// get a list of all the repos tags
|
||||
$tags = $gitea->repo->getListTags('joomla', 'Component-Builder');
|
||||
}
|
||||
catch (DomainException $e)
|
||||
{
|
||||
return $this->getTokenForVersion($e->getMessage());
|
||||
}
|
||||
catch (InvalidArgumentException $e)
|
||||
{
|
||||
return $this->getTokenForVersion($e->getMessage());
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
return $this->getTokenForVersion($e->getMessage());
|
||||
}
|
||||
// do we have tags returned
|
||||
if (isset($tags[0]) && isset($tags[0]->name))
|
||||
{
|
||||
// get the version
|
||||
$manifest = ComponentbuilderHelper::manifest();
|
||||
$local_version = (string) $manifest->version;
|
||||
$current_version = trim($tags[0]->name, 'vV');
|
||||
|
||||
// now check if this version is out dated
|
||||
if ($current_version === $local_version)
|
||||
{
|
||||
return ['notice' => '<small><span style="color:green;"><span class="icon-shield"></span>' . JText::_('COM_COMPONENTBUILDER_UP_TO_DATE') . '</span></small>'];
|
||||
}
|
||||
else
|
||||
{
|
||||
// check if this is beta version
|
||||
$current_array = array_map(function ($v) { return (int) $v; }, (array) explode('.', $current_version));
|
||||
$local_array = array_map(function ($v) { return (int) $v; }, (array) explode('.', $local_version));
|
||||
if (($local_array[0] > $current_array[0]) ||
|
||||
($local_array[0] == $current_array[0] && $local_array[1] > $current_array[1]) ||
|
||||
($local_array[0] == $current_array[0] && $local_array[1] == $current_array[1] && $local_array[2] > $current_array[2]))
|
||||
{
|
||||
return ['notice' => '<small><span style="color:#F7B033;"><span class="icon-wrench"></span>' . JText::_('COM_COMPONENTBUILDER_BETA_RELEASE') . '</span></small>'];
|
||||
}
|
||||
else
|
||||
{
|
||||
// download link of the latest version
|
||||
$download = "https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/" . $tags[0]->name . ".zip?access_token=" . $token;
|
||||
|
||||
return ['notice' => '<small><span style="color:red;"><span class="icon-warning-circle"></span>' . JText::_('COM_COMPONENTBUILDER_OUT_OF_DATE') . '!</span> <a style="color:green;" href="' .
|
||||
$download . '" title="' . JText::_('COM_COMPONENTBUILDER_YOU_CAN_DIRECTLY_DOWNLOAD_THE_LATEST_UPDATE_OR_USE_THE_JOOMLA_UPDATE_AREA') . '">' . JText::_('COM_COMPONENTBUILDER_DOWNLOAD_UPDATE') . '!</a></small>'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->getTokenForVersion();
|
||||
}
|
||||
|
||||
protected function getTokenForVersion($message = null)
|
||||
{
|
||||
// the URL
|
||||
$url = 'https://git.vdm.dev/user/settings/applications';
|
||||
// create link
|
||||
$a = '<small><a style="color:#F7B033;" href="' . $url . '" title="';
|
||||
$a_ = '">';
|
||||
$_a = '</a></small>';
|
||||
|
||||
if ($message)
|
||||
{
|
||||
return ['error' => $a . $message . $a_ . JText::_('COM_COMPONENTBUILDER_GET_TOKEN') . $_a];
|
||||
}
|
||||
|
||||
return ['error' => $a . JText::_('COM_COMPONENTBUILDER_GET_TOKEN_FROM_VDM_TO_GET_UPDATE_NOTICE_AND_ADD_IT_TO_YOUR_GLOBAL_OPTIONS') . $a_ . JText::_('COM_COMPONENTBUILDER_GET_TOKEN') . $_a];
|
||||
}
|
||||
|
||||
|
||||
// Used in joomla_module
|
||||
public function getModuleCode($data)
|
||||
@ -3517,6 +3605,82 @@ class ComponentbuilderModelAjax extends ListModel
|
||||
return false;
|
||||
}
|
||||
|
||||
// Used in search
|
||||
/**
|
||||
* Search for value in a table
|
||||
*
|
||||
* @param string $tableName The main table to search
|
||||
* @param string $searchValue The value to search for
|
||||
* @param int $matchCase The switch to control match case
|
||||
* @param int $wholeWord The switch to control whole word
|
||||
* @param int $regexSearch The switch to control regex search
|
||||
* @param int $componentId The option to filter by component
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function searchTable(string $tableName, string $searchValue,
|
||||
int $matchCase, int $wholeWord, int $regexSearch, int $componentId): ?array
|
||||
{
|
||||
// check if this is a valid table
|
||||
if (SearchFactory::_('Table')->exist($tableName))
|
||||
{
|
||||
// load the configurations
|
||||
SearchFactory::_('Config')->table_name = $tableName;
|
||||
SearchFactory::_('Config')->search_value = $searchValue;
|
||||
SearchFactory::_('Config')->match_case = $matchCase;
|
||||
SearchFactory::_('Config')->whole_word = $wholeWord;
|
||||
SearchFactory::_('Config')->regex_search = $regexSearch;
|
||||
SearchFactory::_('Config')->component_id = $componentId;
|
||||
|
||||
if (($items = SearchFactory::_('Agent')->find()) !== null)
|
||||
{
|
||||
return ['success' => JText::sprintf('COM_COMPONENTBUILDER_WE_FOUND_SOME_INSTANCES_IN_S', $tableName), 'items' => $items];
|
||||
}
|
||||
|
||||
return ['success' => JText::sprintf('COM_COMPONENTBUILDER_NO_INSTANCES_WHERE_FOUND_S', $tableName)];
|
||||
}
|
||||
|
||||
return ['error' => JText::_('COM_COMPONENTBUILDER_THERE_HAS_BEEN_AN_ERROR_PLEASE_TRY_AGAIN')];
|
||||
}
|
||||
|
||||
/**
|
||||
* Search and replace value in a table
|
||||
*
|
||||
* @param string $tableName The main table to search
|
||||
* @param string $searchValue The value to search for
|
||||
* @param string|null $replaceValue The value to replace search value
|
||||
* @param int $matchCase The switch to control match case
|
||||
* @param int $wholeWord The switch to control whole word
|
||||
* @param int $regexSearch The switch to control regex search
|
||||
* @param int $componentId The option to filter by component
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function updateTable(string $tableName, string $searchValue, ?string $replaceValue = null,
|
||||
int $matchCase, int $wholeWord, int $regexSearch, int $componentId): ?array
|
||||
{
|
||||
// check if this is a valid table
|
||||
if (SearchFactory('Table')->exist($tableName))
|
||||
{
|
||||
// load the configurations
|
||||
SearchFactory('Config')->table_name = $tableName;
|
||||
SearchFactory('Config')->search_value = $searchValue;
|
||||
SearchFactory('Config')->replace_value = $replaceValue;
|
||||
SearchFactory('Config')->match_case = $matchCase;
|
||||
SearchFactory('Config')->whole_word = $wholeWord;
|
||||
SearchFactory('Config')->regex_search = $regexSearch;
|
||||
SearchFactory('Config')->component_id = $componentId;
|
||||
|
||||
SearchFactory('Agent')->replace();
|
||||
|
||||
return ['success' => JText::sprintf('COM_COMPONENTBUILDER_ALL_FOUND_INSTANCES_IN_S_WHERE_REPLACED', $tableName)];
|
||||
}
|
||||
return ['error' => JText::_('COM_COMPONENTBUILDER_THERE_HAS_BEEN_AN_ERROR_PLEASE_TRY_AGAIN')];
|
||||
}
|
||||
|
||||
|
||||
// Used in get_snippets
|
||||
|
||||
public function getSnippets($libraries)
|
||||
|
@ -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;
|
||||
|
@ -36,6 +36,7 @@ class ComponentbuilderModelComponentbuilder extends ListModel
|
||||
$viewAccess = array(
|
||||
'compiler.submenu' => 'compiler.submenu',
|
||||
'compiler.dashboard_list' => 'compiler.dashboard_list',
|
||||
'search.submenu' => 'search.submenu',
|
||||
'get_snippets.submenu' => 'get_snippets.submenu',
|
||||
'get_snippets.dashboard_list' => 'get_snippets.dashboard_list',
|
||||
'joomla_component.create' => 'joomla_component.create',
|
||||
@ -416,90 +417,26 @@ class ComponentbuilderModelComponentbuilder extends ListModel
|
||||
$call_url = JUri::base() . 'index.php?option=com_componentbuilder&task=ajax.getWiki&format=json&raw=true&' . JSession::getFormToken() . '=1&name=Home';
|
||||
$document = JFactory::getDocument();
|
||||
$document->addScriptDeclaration('
|
||||
fetch("' . $call_url . '").then((response) => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
}).then((result) => {
|
||||
if (typeof result.page !== "undefined") {
|
||||
document.getElementById("wiki-md").innerHTML = result.page;
|
||||
} else if (typeof result.error !== "undefined") {
|
||||
document.getElementById("wiki-md-error").innerHTML = result.error
|
||||
}
|
||||
});');
|
||||
function getWikiPage(){
|
||||
|
||||
fetch("' . $call_url . '").then((response) => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
}).then((result) => {
|
||||
if (typeof result.page !== "undefined") {
|
||||
document.getElementById("wiki-md").innerHTML = result.page;
|
||||
} else if (typeof result.error !== "undefined") {
|
||||
document.getElementById("wiki-md-error").innerHTML = result.error
|
||||
}
|
||||
});
|
||||
}
|
||||
setTimeout(getWikiPage, 1000);');
|
||||
|
||||
return '<div id="wiki-md"><small>'.JText::_('COM_COMPONENTBUILDER_THE_WIKI_IS_LOADING').'.<span class="loading-dots">.</span></small></div><div id="wiki-md-error" style="color: red"></div>';
|
||||
}
|
||||
|
||||
|
||||
public function getGitea()
|
||||
{
|
||||
// get the document
|
||||
$document = JFactory::getDocument();
|
||||
// get the token if set
|
||||
$token = JComponentHelper::getParams('com_componentbuilder')->get('gitea_token', false);
|
||||
// only add if token is set
|
||||
if ($token)
|
||||
{
|
||||
// setup a registry
|
||||
$options = new Registry;
|
||||
$options->set('access.token', $token);
|
||||
// get the gitea http
|
||||
try
|
||||
{
|
||||
// get gitea object
|
||||
$gitea = new Gitea($options);
|
||||
// get a list of all the repos tags
|
||||
$tags = $gitea->repo->getListTags('joomla', 'Component-Builder');
|
||||
}
|
||||
catch (DomainException $m)
|
||||
{
|
||||
$token = false;
|
||||
}
|
||||
// get the document to load the scripts
|
||||
if ($token && isset($tags[0]) && isset($tags[0]->name))
|
||||
{
|
||||
// download link of the latest version
|
||||
$download = "https://git.vdm.dev/api/v1/repos/joomla/Component-Builder/archive/" . $tags[0]->name . ".zip?access_token=" . $token;
|
||||
// load the JavaScript to the page
|
||||
$document->addScriptDeclaration('
|
||||
jQuery(document).ready(function () {
|
||||
var activeVersion = "' . trim($tags[0]->name, 'vV') . '";
|
||||
if (activeVersion === manifest.version) {
|
||||
// local version is in sync with latest release
|
||||
jQuery(".update-notice").html("<small><span style=\'color:green;\'><span class=\'icon-shield\'></span>' . JText::_('COM_COMPONENTBUILDER_UP_TO_DATE') . '</span></small>");
|
||||
} else {
|
||||
// split versions in to array
|
||||
var activeVersionArray = activeVersion.split(".");
|
||||
var localVersionArray = manifest.version.split(".");
|
||||
if ((+localVersionArray[0] > +activeVersionArray[0]) ||
|
||||
(+localVersionArray[0] == +activeVersionArray[0] && +localVersionArray[1] > +activeVersionArray[1]) ||
|
||||
(+localVersionArray[0] == +activeVersionArray[0] && +localVersionArray[1] == +activeVersionArray[1] && +localVersionArray[2] > +activeVersionArray[2])) {
|
||||
// local version head latest release
|
||||
jQuery(".update-notice").html("<small><span style=\'color:#F7B033;\'><span class=\'icon-wrench\'></span>' . JText::_('COM_COMPONENTBUILDER_BETA_RELEASE') . '</span></small>");
|
||||
} else {
|
||||
// local version behind latest release
|
||||
jQuery(".update-notice").html("<small><span style=\'color:red;\'><span class=\'icon-warning-circle\'></span>' . JText::_('COM_COMPONENTBUILDER_OUT_OF_DATE') . '</span> <a style=\'color:green;\' href=\'' .
|
||||
$download . '\' title=\'' . JText::_('COM_COMPONENTBUILDER_YOU_CAN_DIRECTLY_DOWNLOAD_THE_LATEST_UPDATE_OR_USE_THE_JOOMLA_UPDATE_AREA') . '\'>' .
|
||||
JText::_('COM_COMPONENTBUILDER_DOWNLOAD_UPDATE') . '!</a></small>");
|
||||
}
|
||||
}
|
||||
});');
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
// the URL
|
||||
$url = 'https://git.vdm.dev/user/settings/applications';
|
||||
// give a notice to get the token
|
||||
$document->addScriptDeclaration(
|
||||
'jQuery(document).ready(function () {jQuery(".update-notice").html("<small><a style=\'color:#F7B033;\' href=\'' .
|
||||
$url . '\' title=\'' . JText::_('COM_COMPONENTBUILDER_GET_TOKEN_FROM_VDM_FOR_UPDATES_AND_ADD_IT_TO_YOUR_GLOBAL_OPTIONS') . '\'>' .
|
||||
JText::_('COM_COMPONENTBUILDER_GET_TOKEN') . '!</a></small>");});'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function getNoticeboard()
|
||||
{
|
||||
// get the document to load the scripts
|
||||
@ -590,5 +527,28 @@ jQuery(document).ready( function($) {
|
||||
});');
|
||||
|
||||
return '<div id="readme-md"><small>'.JText::_('COM_COMPONENTBUILDER_THE_README_IS_LOADING').'.<span class="loading-dots">.</span></small></div>';
|
||||
}
|
||||
}
|
||||
|
||||
public function getVersion()
|
||||
{
|
||||
// the call URL
|
||||
$call_url = JUri::base() . 'index.php?option=com_componentbuilder&task=ajax.getVersion&format=json&raw=true&' . JSession::getFormToken() . '=1&version=1';
|
||||
$document = JFactory::getDocument();
|
||||
$document->addScriptDeclaration('
|
||||
function getComponentVersionStatus() {
|
||||
fetch("' . $call_url . '").then((response) => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
}).then((result) => {
|
||||
if (typeof result.notice !== "undefined") {
|
||||
document.getElementById("component-update-notice").innerHTML = result.notice;
|
||||
} else if (typeof result.error !== "undefined") {
|
||||
document.getElementById("component-update-notice").innerHTML = result.error;
|
||||
}
|
||||
});
|
||||
}
|
||||
setTimeout(getComponentVersionStatus, 800);');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -202,44 +202,6 @@
|
||||
filter="raw"
|
||||
validate="code"
|
||||
/>
|
||||
<!-- Use_selection Field. Type: Subform. (joomla) -->
|
||||
<field
|
||||
type="subform"
|
||||
name="use_selection"
|
||||
label="COM_COMPONENTBUILDER_POWER_USE_SELECTION_LABEL"
|
||||
layout="joomla.form.field.subform.repeatable-table"
|
||||
multiple="true"
|
||||
buttons="add,remove,move"
|
||||
description="COM_COMPONENTBUILDER_POWER_USE_SELECTION_DESCRIPTION"
|
||||
icon="list"
|
||||
max="30"
|
||||
min="0"
|
||||
showon="type!:interface">
|
||||
<form hidden="true" name="list_use_selection_modal" repeat="true">
|
||||
<!-- Use Field. Type: Namespaces. (custom) -->
|
||||
<field
|
||||
type="namespaces"
|
||||
name="use"
|
||||
label="COM_COMPONENTBUILDER_POWER_USE_LABEL"
|
||||
class="list_class span12"
|
||||
multiple="false"
|
||||
default="0"
|
||||
button="false"
|
||||
/>
|
||||
<!-- As Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="as"
|
||||
label="COM_COMPONENTBUILDER_POWER_AS_LABEL"
|
||||
size="10"
|
||||
maxlength="50"
|
||||
default="default"
|
||||
class="text_area"
|
||||
filter="STRING"
|
||||
autocomplete="on"
|
||||
/>
|
||||
</form>
|
||||
</field>
|
||||
<!-- Description Field. Type: Textarea. (joomla) -->
|
||||
<field
|
||||
type="textarea"
|
||||
@ -252,6 +214,19 @@
|
||||
filter="HTML"
|
||||
hint="COM_COMPONENTBUILDER_POWER_DESCRIPTION_HINT"
|
||||
/>
|
||||
<!-- Licensing_template Field. Type: Textarea. (joomla) -->
|
||||
<field
|
||||
type="textarea"
|
||||
name="licensing_template"
|
||||
label="COM_COMPONENTBUILDER_POWER_LICENSING_TEMPLATE_LABEL"
|
||||
rows="10"
|
||||
cols="10"
|
||||
class="text_area span12"
|
||||
filter="RAW"
|
||||
hint="COM_COMPONENTBUILDER_POWER_LICENSING_TEMPLATE_HINT"
|
||||
validate="code"
|
||||
showon="add_licensing_template:2"
|
||||
/>
|
||||
<!-- Property_selection Field. Type: Subform. (joomla) -->
|
||||
<field
|
||||
type="subform"
|
||||
@ -297,8 +272,8 @@
|
||||
type="text"
|
||||
name="implements_custom"
|
||||
label="COM_COMPONENTBUILDER_POWER_IMPLEMENTS_CUSTOM_LABEL"
|
||||
size="10"
|
||||
maxlength="50"
|
||||
size="50"
|
||||
maxlength="150"
|
||||
description="COM_COMPONENTBUILDER_POWER_IMPLEMENTS_CUSTOM_DESCRIPTION"
|
||||
class="text_area span12"
|
||||
filter="STRING"
|
||||
@ -397,6 +372,59 @@
|
||||
required="false"
|
||||
validate="code"
|
||||
/>
|
||||
<!-- Add_licensing_template Field. Type: Radio. (joomla) -->
|
||||
<field
|
||||
type="radio"
|
||||
name="add_licensing_template"
|
||||
label="COM_COMPONENTBUILDER_POWER_ADD_LICENSING_TEMPLATE_LABEL"
|
||||
description="COM_COMPONENTBUILDER_POWER_ADD_LICENSING_TEMPLATE_DESCRIPTION"
|
||||
class="btn-group btn-group-yesno"
|
||||
default="1"
|
||||
required="true">
|
||||
<!-- Option Set. -->
|
||||
<option value="1">
|
||||
COM_COMPONENTBUILDER_POWER_USE_GLOBAL</option>
|
||||
<option value="2">
|
||||
COM_COMPONENTBUILDER_POWER_OVERRIDE</option>
|
||||
</field>
|
||||
<!-- Use_selection Field. Type: Subform. (joomla) -->
|
||||
<field
|
||||
type="subform"
|
||||
name="use_selection"
|
||||
label="COM_COMPONENTBUILDER_POWER_USE_SELECTION_LABEL"
|
||||
layout="joomla.form.field.subform.repeatable-table"
|
||||
multiple="true"
|
||||
buttons="add,remove,move"
|
||||
description="COM_COMPONENTBUILDER_POWER_USE_SELECTION_DESCRIPTION"
|
||||
icon="list"
|
||||
max="30"
|
||||
min="0"
|
||||
showon="type!:interface">
|
||||
<form hidden="true" name="list_use_selection_modal" repeat="true">
|
||||
<!-- Use Field. Type: Namespaces. (custom) -->
|
||||
<field
|
||||
type="namespaces"
|
||||
name="use"
|
||||
label="COM_COMPONENTBUILDER_POWER_USE_LABEL"
|
||||
class="list_class span12"
|
||||
multiple="false"
|
||||
default="0"
|
||||
button="false"
|
||||
/>
|
||||
<!-- As Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="as"
|
||||
label="COM_COMPONENTBUILDER_POWER_AS_LABEL"
|
||||
size="10"
|
||||
maxlength="50"
|
||||
default="default"
|
||||
class="text_area"
|
||||
filter="STRING"
|
||||
autocomplete="on"
|
||||
/>
|
||||
</form>
|
||||
</field>
|
||||
<!-- Guid Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
|
@ -33,10 +33,10 @@ class ComponentbuilderModelPower extends AdminModel
|
||||
'name',
|
||||
'description',
|
||||
'extends',
|
||||
'implements_custom',
|
||||
'implements',
|
||||
'namespace',
|
||||
'extends_custom',
|
||||
'implements',
|
||||
'implements_custom',
|
||||
'namespace',
|
||||
'add_head'
|
||||
),
|
||||
'right' => array(
|
||||
@ -58,6 +58,12 @@ class ComponentbuilderModelPower extends AdminModel
|
||||
'type',
|
||||
'power_version'
|
||||
)
|
||||
),
|
||||
'licensing' => array(
|
||||
'fullwidth' => array(
|
||||
'add_licensing_template',
|
||||
'licensing_template'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@ -178,6 +184,12 @@ class ComponentbuilderModelPower extends AdminModel
|
||||
$item->main_class_code = base64_decode($item->main_class_code);
|
||||
}
|
||||
|
||||
if (!empty($item->licensing_template))
|
||||
{
|
||||
// base64 Decode licensing_template.
|
||||
$item->licensing_template = base64_decode($item->licensing_template);
|
||||
}
|
||||
|
||||
if (!empty($item->head))
|
||||
{
|
||||
// base64 Decode head.
|
||||
@ -192,14 +204,6 @@ class ComponentbuilderModelPower extends AdminModel
|
||||
$item->load_selection = $load_selection->toArray();
|
||||
}
|
||||
|
||||
if (!empty($item->use_selection))
|
||||
{
|
||||
// Convert the use_selection field to an array.
|
||||
$use_selection = new Registry;
|
||||
$use_selection->loadString($item->use_selection);
|
||||
$item->use_selection = $use_selection->toArray();
|
||||
}
|
||||
|
||||
if (!empty($item->property_selection))
|
||||
{
|
||||
// Convert the property_selection field to an array.
|
||||
@ -224,6 +228,14 @@ class ComponentbuilderModelPower extends AdminModel
|
||||
$item->method_selection = $method_selection->toArray();
|
||||
}
|
||||
|
||||
if (!empty($item->use_selection))
|
||||
{
|
||||
// Convert the use_selection field to an array.
|
||||
$use_selection = new Registry;
|
||||
$use_selection->loadString($item->use_selection);
|
||||
$item->use_selection = $use_selection->toArray();
|
||||
}
|
||||
|
||||
|
||||
if (empty($item->id))
|
||||
{
|
||||
@ -1038,19 +1050,6 @@ class ComponentbuilderModelPower extends AdminModel
|
||||
$data['load_selection'] = '';
|
||||
}
|
||||
|
||||
// Set the use_selection items to data.
|
||||
if (isset($data['use_selection']) && is_array($data['use_selection']))
|
||||
{
|
||||
$use_selection = new JRegistry;
|
||||
$use_selection->loadArray($data['use_selection']);
|
||||
$data['use_selection'] = (string) $use_selection;
|
||||
}
|
||||
elseif (!isset($data['use_selection']))
|
||||
{
|
||||
// Set the empty use_selection to data
|
||||
$data['use_selection'] = '';
|
||||
}
|
||||
|
||||
// Set the property_selection items to data.
|
||||
if (isset($data['property_selection']) && is_array($data['property_selection']))
|
||||
{
|
||||
@ -1090,12 +1089,31 @@ class ComponentbuilderModelPower extends AdminModel
|
||||
$data['method_selection'] = '';
|
||||
}
|
||||
|
||||
// Set the use_selection items to data.
|
||||
if (isset($data['use_selection']) && is_array($data['use_selection']))
|
||||
{
|
||||
$use_selection = new JRegistry;
|
||||
$use_selection->loadArray($data['use_selection']);
|
||||
$data['use_selection'] = (string) $use_selection;
|
||||
}
|
||||
elseif (!isset($data['use_selection']))
|
||||
{
|
||||
// Set the empty use_selection to data
|
||||
$data['use_selection'] = '';
|
||||
}
|
||||
|
||||
// Set the main_class_code string to base64 string.
|
||||
if (isset($data['main_class_code']))
|
||||
{
|
||||
$data['main_class_code'] = base64_encode($data['main_class_code']);
|
||||
}
|
||||
|
||||
// Set the licensing_template string to base64 string.
|
||||
if (isset($data['licensing_template']))
|
||||
{
|
||||
$data['licensing_template'] = base64_encode($data['licensing_template']);
|
||||
}
|
||||
|
||||
// Set the head string to base64 string.
|
||||
if (isset($data['head']))
|
||||
{
|
||||
|
@ -158,6 +158,8 @@ class ComponentbuilderModelPowers extends ListModel
|
||||
continue;
|
||||
}
|
||||
|
||||
// remove dots
|
||||
$item->namespace = str_replace('.','\\', $item->namespace);
|
||||
}
|
||||
}
|
||||
|
||||
|
165
admin/models/search.php
Normal file
165
admin/models/search.php
Normal file
@ -0,0 +1,165 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
use Joomla\CMS\MVC\Model\ItemModel;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Componentbuilder\Search\Factory as SearchFactory;
|
||||
|
||||
/**
|
||||
* Componentbuilder Search Item Model
|
||||
*/
|
||||
class ComponentbuilderModelSearch extends ItemModel
|
||||
{
|
||||
/**
|
||||
* Model context string.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_context = 'com_componentbuilder.search';
|
||||
|
||||
/**
|
||||
* Model user data.
|
||||
*
|
||||
* @var strings
|
||||
*/
|
||||
protected $user;
|
||||
protected $userId;
|
||||
protected $guest;
|
||||
protected $groups;
|
||||
protected $levels;
|
||||
protected $app;
|
||||
protected $input;
|
||||
protected $uikitComp;
|
||||
|
||||
/**
|
||||
* @var object item
|
||||
*/
|
||||
protected $item;
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function populateState()
|
||||
{
|
||||
$this->app = JFactory::getApplication();
|
||||
$this->input = $this->app->input;
|
||||
// Get the item main id
|
||||
$id = $this->input->getInt('id', null);
|
||||
$this->setState('search.id', $id);
|
||||
|
||||
// Load the parameters.
|
||||
parent::populateState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get article data.
|
||||
*
|
||||
* @param integer $pk The id of the article.
|
||||
*
|
||||
* @return mixed Menu item data object on success, false on failure.
|
||||
*/
|
||||
public function getItem($pk = null)
|
||||
{
|
||||
$this->user = JFactory::getUser();
|
||||
// check if this user has permission to access item
|
||||
if (!$this->user->authorise('search.access', 'com_componentbuilder'))
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$app->enqueueMessage(JText::_('Not authorised!'), 'error');
|
||||
// redirect away if not a correct to cPanel/default view
|
||||
$app->redirect('index.php?option=com_componentbuilder');
|
||||
return false;
|
||||
}
|
||||
$this->userId = $this->user->get('id');
|
||||
$this->guest = $this->user->get('guest');
|
||||
$this->groups = $this->user->get('groups');
|
||||
$this->authorisedGroups = $this->user->getAuthorisedGroups();
|
||||
$this->levels = $this->user->getAuthorisedViewLevels();
|
||||
$this->initSet = true;
|
||||
|
||||
$pk = (!empty($pk)) ? $pk : (int) $this->getState('search.id');
|
||||
|
||||
$pk = $this->userId;
|
||||
|
||||
if ($this->_item === null)
|
||||
{
|
||||
$this->_item = array();
|
||||
}
|
||||
|
||||
if (!isset($this->_item[$pk]))
|
||||
{
|
||||
try
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get data
|
||||
// load the tables and components (soon)
|
||||
$data = ['tables' => SearchFactory::_('Table')->tables(), 'components' => null];
|
||||
|
||||
|
||||
if (empty($data))
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
// If no data is found redirect to default page and show warning.
|
||||
$app->enqueueMessage(JText::_('COM_COMPONENTBUILDER_NOT_FOUND_OR_ACCESS_DENIED'), 'warning');
|
||||
$app->redirect('index.php?option=com_componentbuilder');
|
||||
return false;
|
||||
}
|
||||
|
||||
// set data object to item.
|
||||
$this->_item[$pk] = $data;
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
if ($e->getCode() == 404)
|
||||
{
|
||||
// Need to go thru the error handler to allow Redirect to work.
|
||||
JError::raiseWarning(404, $e->getMessage());
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setError($e);
|
||||
$this->_item[$pk] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_item[$pk];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uikit needed components
|
||||
*
|
||||
* @return mixed An array of objects on success.
|
||||
*
|
||||
*/
|
||||
public function getUikitComp()
|
||||
{
|
||||
if (isset($this->uikitComp) && ComponentbuilderHelper::checkArray($this->uikitComp))
|
||||
{
|
||||
return $this->uikitComp;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
2
admin/sql/updates/mysql/3.1.5.sql
Normal file
2
admin/sql/updates/mysql/3.1.5.sql
Normal file
@ -0,0 +1,2 @@
|
||||
ALTER TABLE `#__componentbuilder_power` ADD `add_licensing_template` TINYINT(1) NOT NULL DEFAULT 1 AFTER `add_head`;
|
||||
ALTER TABLE `#__componentbuilder_power` ADD `licensing_template` TEXT NOT NULL AFTER `implements_custom`;
|
@ -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();
|
||||
|
@ -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',
|
||||
|
@ -38,58 +38,50 @@ defined('_JEXEC') or die('Restricted access');
|
||||
</div>
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'cpanel_tab', 'wiki', JText::_('Wiki', true)); ?>
|
||||
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'cpanel_tab', 'wiki', JText::_('COM_COMPONENTBUILDER_WIKI', true)); ?>
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<div class="span10">
|
||||
<?php echo JHtml::_('bootstrap.startAccordion', 'wiki_accordian', array('active' => 'wiki_one')); ?>
|
||||
<?php echo JHtml::_('bootstrap.addSlide', 'wiki_accordian', 'Tutorials', 'wiki_one'); ?>
|
||||
<?php echo $this->loadTemplate('wiki_tutorials');?>
|
||||
<?php echo JHtml::_('bootstrap.endSlide'); ?>
|
||||
<?php echo JHtml::_('bootstrap.endAccordion'); ?>
|
||||
</div>
|
||||
<div class="span2">
|
||||
<?php echo ComponentbuilderHelper::getDynamicContent('banner', '160-600'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'cpanel_tab', 'notice_board', JText::_('Notice Board', true)); ?>
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'cpanel_tab', 'notice_board', JText::_('COM_COMPONENTBUILDER_NOTICE_BOARD', true)); ?>
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<div class="span10">
|
||||
<?php echo JHtml::_('bootstrap.startAccordion', 'notice_board_accordian', array('active' => 'notice_board_one')); ?>
|
||||
<?php echo JHtml::_('bootstrap.addSlide', 'notice_board_accordian', 'Vast Development Method', 'notice_board_one'); ?>
|
||||
<?php echo $this->loadTemplate('notice_board_vast_development_method');?>
|
||||
<?php echo JHtml::_('bootstrap.endSlide'); ?>
|
||||
<?php echo JHtml::_('bootstrap.endAccordion'); ?>
|
||||
</div>
|
||||
<div class="span2">
|
||||
<?php echo ComponentbuilderHelper::getDynamicContent('banner', '160-600'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'cpanel_tab', 'readme', JText::_('Readme', true)); ?>
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'cpanel_tab', 'readme', JText::_('COM_COMPONENTBUILDER_README', true)); ?>
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<div class="span10">
|
||||
<?php echo JHtml::_('bootstrap.startAccordion', 'readme_accordian', array('active' => 'readme_one')); ?>
|
||||
<?php echo JHtml::_('bootstrap.addSlide', 'readme_accordian', 'Information', 'readme_one'); ?>
|
||||
<?php echo $this->loadTemplate('readme_information');?>
|
||||
<?php echo JHtml::_('bootstrap.endSlide'); ?>
|
||||
<?php echo JHtml::_('bootstrap.endAccordion'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'cpanel_tab', 'notice_board', JText::_('COM_COMPONENTBUILDER_NOTICE_BOARD', true)); ?>
|
||||
<div class="row-fluid">
|
||||
<div class="span10">
|
||||
<?php echo JHtml::_('bootstrap.startAccordion', 'notice_board_accordian', array('active' => 'notice_board_one')); ?>
|
||||
<?php echo JHtml::_('bootstrap.addSlide', 'notice_board_accordian', 'Vast Development Method', 'notice_board_one'); ?>
|
||||
<?php echo $this->loadTemplate('notice_board_vast_development_method');?>
|
||||
<?php echo JHtml::_('bootstrap.endSlide'); ?>
|
||||
<?php echo JHtml::_('bootstrap.addSlide', 'notice_board_accordian', 'JCB Pro Membership', 'notice_board_two'); ?>
|
||||
<?php echo $this->loadTemplate('notice_board_jcb_pro_membership');?>
|
||||
<?php echo JHtml::_('bootstrap.endSlide'); ?>
|
||||
<?php echo JHtml::_('bootstrap.endAccordion'); ?>
|
||||
</div>
|
||||
<div class="span2">
|
||||
<?php echo ComponentbuilderHelper::getDynamicContent('banner', '160-600'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
|
||||
<?php echo JHtml::_('bootstrap.endTabSet'); ?>
|
||||
|
@ -15,7 +15,7 @@ defined('_JEXEC') or die('Restricted access');
|
||||
?>
|
||||
<img alt="<?php echo JText::_('COM_COMPONENTBUILDER'); ?>" src="components/com_componentbuilder/assets/images/vdm-component.jpg">
|
||||
<ul class="list-striped">
|
||||
<li><b><?php echo JText::_('COM_COMPONENTBUILDER_VERSION'); ?>:</b> <?php echo $this->manifest->version; ?> <span class="update-notice"></span></li>
|
||||
<li><b><?php echo JText::_('COM_COMPONENTBUILDER_VERSION'); ?>:</b> <?php echo $this->manifest->version; ?> <span class="update-notice" id="component-update-notice"></span></li>
|
||||
<li><b><?php echo JText::_('COM_COMPONENTBUILDER_DATE'); ?>:</b> <?php echo $this->manifest->creationDate; ?></li>
|
||||
<li><b><?php echo JText::_('COM_COMPONENTBUILDER_AUTHOR'); ?>:</b> <a href="mailto:<?php echo $this->manifest->authorEmail; ?>"><?php echo $this->manifest->author; ?></a></li>
|
||||
<li><b><?php echo JText::_('COM_COMPONENTBUILDER_WEBSITE'); ?>:</b> <a href="<?php echo $this->manifest->authorUrl; ?>" target="_blank"><?php echo $this->manifest->authorUrl; ?></a></li>
|
||||
|
@ -29,9 +29,9 @@ class ComponentbuilderViewComponentbuilder extends JViewLegacy
|
||||
$this->icons = $this->get('Icons');
|
||||
$this->contributors = ComponentbuilderHelper::getContributors();
|
||||
$this->wiki = $this->get('Wiki');
|
||||
$this->gitea = $this->get('Gitea');
|
||||
$this->noticeboard = $this->get('Noticeboard');
|
||||
$this->readme = $this->get('Readme');
|
||||
$this->version = $this->get('Version');
|
||||
|
||||
// get the manifest details of the component
|
||||
$this->manifest = ComponentbuilderHelper::manifest();
|
||||
|
@ -64,6 +64,16 @@ $componentParams = $this->params; // will be removed just use $this->params inst
|
||||
</div>
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'powerTab', 'licensing', JText::_('COM_COMPONENTBUILDER_POWER_LICENSING', true)); ?>
|
||||
<div class="row-fluid form-horizontal-desktop">
|
||||
</div>
|
||||
<div class="row-fluid form-horizontal-desktop">
|
||||
<div class="span12">
|
||||
<?php echo JLayoutHelper::render('power.licensing_fullwidth', $this); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
|
||||
<?php $this->ignore_fieldsets = array('details','metadata','vdmmetadata','accesscontrol'); ?>
|
||||
<?php $this->tab_name = 'powerTab'; ?>
|
||||
<?php echo JLayoutHelper::render('joomla.edit.params', $this); ?>
|
||||
|
@ -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">
|
||||
|
1
admin/views/search/index.html
Normal file
1
admin/views/search/index.html
Normal file
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
75
admin/views/search/tmpl/default.php
Normal file
75
admin/views/search/tmpl/default.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
|
||||
JHtml::_('behavior.formvalidator');
|
||||
JHtml::_('formbehavior.chosen', 'select');
|
||||
JHtml::_('behavior.keepalive');
|
||||
use VDM\Joomla\Componentbuilder\Search\Factory as SearchFactory;
|
||||
?>
|
||||
<?php if ($this->canDo->get('search.access')): ?>
|
||||
<script type="text/javascript">
|
||||
Joomla.submitbutton = function(task) {
|
||||
if (task === 'search.back') {
|
||||
parent.history.back();
|
||||
return false;
|
||||
} else {
|
||||
var form = document.getElementById('adminForm');
|
||||
form.task.value = task;
|
||||
form.submit();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php $urlId = (isset($this->item->id)) ? '&id='. (int) $this->item->id : ''; ?>
|
||||
<form action="<?php echo JRoute::_('index.php?option=com_componentbuilder&view=search' . $urlId); ?>" method="post" name="adminForm" id="adminForm" class="form-validate" enctype="multipart/form-data">
|
||||
|
||||
<?php if(!empty( $this->sidebar)): ?>
|
||||
<div id="j-sidebar-container" class="span2">
|
||||
<?php echo $this->sidebar; ?>
|
||||
</div>
|
||||
<div id="j-main-container" class="span10">
|
||||
<?php else : ?>
|
||||
<div id="j-main-container">
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
// let's do some tests with the API
|
||||
$tableName = 'admin_view';
|
||||
$searchValue = '\b\w+Helper';
|
||||
// set the search configurations
|
||||
SearchFactory::_('Config')->table_name = $tableName;
|
||||
SearchFactory::_('Config')->search_value = $searchValue;
|
||||
SearchFactory::_('Config')->match_case = 1;
|
||||
SearchFactory::_('Config')->whole_word = 0;
|
||||
SearchFactory::_('Config')->regex_search = 1;
|
||||
SearchFactory::_('Config')->component_id = 0;
|
||||
|
||||
if (($items = SearchFactory::_('Agent')->find()) !== null)
|
||||
{
|
||||
echo JText::sprintf('COM_COMPONENTBUILDER_WE_FOUND_SOME_INSTANCES_IN_S', $tableName) . '<br /><pre>';
|
||||
var_dump($items);
|
||||
echo '</pre>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo JText::sprintf('COM_COMPONENTBUILDER_NO_INSTANCES_WHERE_FOUND_S', $tableName);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<input type="hidden" name="task" value="" />
|
||||
<?php echo JHtml::_('form.token'); ?>
|
||||
</form>
|
||||
<?php else: ?>
|
||||
<h1><?php echo JText::_('COM_COMPONENTBUILDER_NO_ACCESS_GRANTED'); ?></h1>
|
||||
<?php endif; ?>
|
||||
|
1
admin/views/search/tmpl/index.html
Normal file
1
admin/views/search/tmpl/index.html
Normal file
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
150
admin/views/search/view.html.php
Normal file
150
admin/views/search/view.html.php
Normal file
@ -0,0 +1,150 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
use Joomla\CMS\MVC\View\HtmlView;
|
||||
|
||||
/**
|
||||
* Componentbuilder Html View class for the Search
|
||||
*/
|
||||
class ComponentbuilderViewSearch extends HtmlView
|
||||
{
|
||||
// Overwriting JView display method
|
||||
function display($tpl = null)
|
||||
{
|
||||
// get component params
|
||||
$this->params = JComponentHelper::getParams('com_componentbuilder');
|
||||
// get the application
|
||||
$this->app = JFactory::getApplication();
|
||||
// get the user object
|
||||
$this->user = JFactory::getUser();
|
||||
// get global action permissions
|
||||
$this->canDo = ComponentbuilderHelper::getActions('search');
|
||||
// Initialise variables.
|
||||
$this->item = $this->get('Item');
|
||||
if ($this->getLayout() !== 'modal')
|
||||
{
|
||||
// Include helper submenu
|
||||
ComponentbuilderHelper::addSubmenu('search');
|
||||
JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=search');
|
||||
$this->sidebar = JHtmlSidebar::render();
|
||||
}
|
||||
|
||||
// We don't need toolbar in the modal window.
|
||||
if ($this->getLayout() !== 'modal')
|
||||
{
|
||||
// add the tool bar
|
||||
$this->addToolBar();
|
||||
}
|
||||
|
||||
// set the document
|
||||
$this->setDocument();
|
||||
|
||||
// Check for errors.
|
||||
if (count($errors = $this->get('Errors')))
|
||||
{
|
||||
throw new Exception(implode(PHP_EOL, $errors), 500);
|
||||
}
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the document
|
||||
*/
|
||||
protected function setDocument()
|
||||
{
|
||||
|
||||
// always make sure jquery is loaded.
|
||||
JHtml::_('jquery.framework');
|
||||
// Load the header checker class.
|
||||
require_once( JPATH_COMPONENT_ADMINISTRATOR.'/helpers/headercheck.php' );
|
||||
// Initialize the header checker.
|
||||
$HeaderCheck = new componentbuilderHeaderCheck;
|
||||
|
||||
// Load uikit options.
|
||||
$uikit = $this->params->get('uikit_load');
|
||||
// Set script size.
|
||||
$size = $this->params->get('uikit_min');
|
||||
// Set css style.
|
||||
$style = $this->params->get('uikit_style');
|
||||
|
||||
// The uikit css.
|
||||
if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3)
|
||||
{
|
||||
JHtml::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit'.$style.$size.'.css', ['version' => 'auto']);
|
||||
}
|
||||
// The uikit js.
|
||||
if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3)
|
||||
{
|
||||
JHtml::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit'.$size.'.js', ['version' => 'auto']);
|
||||
}
|
||||
// add the document default css file
|
||||
$this->document->addStyleSheet(JURI::root(true) .'/administrator/components/com_componentbuilder/assets/css/search.css', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting the toolbar
|
||||
*/
|
||||
protected function addToolBar()
|
||||
{
|
||||
// hide the main menu
|
||||
$this->app->input->set('hidemainmenu', true);
|
||||
// set the title
|
||||
if (isset($this->item->name) && $this->item->name)
|
||||
{
|
||||
$title = $this->item->name;
|
||||
}
|
||||
// Check for empty title and add view name if param is set
|
||||
if (empty($title))
|
||||
{
|
||||
$title = JText::_('COM_COMPONENTBUILDER_SEARCH');
|
||||
}
|
||||
// add title to the page
|
||||
JToolbarHelper::title($title,'search');
|
||||
// add cpanel button
|
||||
JToolBarHelper::custom('search.dashboard', 'grid-2', '', 'COM_COMPONENTBUILDER_DASH', false);
|
||||
if ($this->canDo->get('search.compiler'))
|
||||
{
|
||||
// add Compiler button.
|
||||
JToolBarHelper::custom('search.openCompiler', 'cogs custom-button-opencompiler', '', 'COM_COMPONENTBUILDER_COMPILER', false);
|
||||
}
|
||||
|
||||
// set help url for this view if found
|
||||
$this->help_url = ComponentbuilderHelper::getHelpUrl('search');
|
||||
if (ComponentbuilderHelper::checkString($this->help_url))
|
||||
{
|
||||
JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url);
|
||||
}
|
||||
|
||||
// add the options comp button
|
||||
if ($this->canDo->get('core.admin') || $this->canDo->get('core.options'))
|
||||
{
|
||||
JToolBarHelper::preferences('com_componentbuilder');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes a value for output in a view script.
|
||||
*
|
||||
* @param mixed $var The output to escape.
|
||||
*
|
||||
* @return mixed The escaped value.
|
||||
*/
|
||||
public function escape($var)
|
||||
{
|
||||
// use the helper htmlEscape method instead.
|
||||
return ComponentbuilderHelper::htmlEscape($var, $this->_charset);
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,15 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="component" version="4" method="upgrade">
|
||||
<name>COM_COMPONENTBUILDER</name>
|
||||
<creationDate>9th July, 2022</creationDate>
|
||||
<creationDate>20th September, 2022</creationDate>
|
||||
<author>Llewellyn van der Merwe</author>
|
||||
<authorEmail>joomla@vdm.io</authorEmail>
|
||||
<authorUrl>https://dev.vdm.io</authorUrl>
|
||||
<copyright>Copyright (C) 2015 Vast Development Method. All rights reserved.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<version>3.1.3</version>
|
||||
<version>3.1.8</version>
|
||||
<description>< is highly advanced tool that is truly able to build extremely complex components in a fraction of the time.
|
||||
|
||||
@ -74,6 +74,7 @@ Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/compo
|
||||
<submenu>
|
||||
<!-- Instead of link you can specify individual link attributes -->
|
||||
<menu option="com_componentbuilder" view="compiler">COM_COMPONENTBUILDER_MENU_COMPILER</menu>
|
||||
<menu option="com_componentbuilder" view="search">COM_COMPONENTBUILDER_MENU_SEARCH</menu>
|
||||
<menu option="com_componentbuilder" view="joomla_components">COM_COMPONENTBUILDER_MENU_JOOMLA_COMPONENTS</menu>
|
||||
<menu option="com_componentbuilder" view="joomla_modules">COM_COMPONENTBUILDER_MENU_JOOMLA_MODULES</menu>
|
||||
<menu option="com_componentbuilder" view="joomla_plugins">COM_COMPONENTBUILDER_MENU_JOOMLA_PLUGINS</menu>
|
||||
|
@ -1079,10 +1079,28 @@
|
||||
<element>pkg_component_builder</element>
|
||||
<type>package</type>
|
||||
<client>site</client>
|
||||
<version>3.1.3</version>
|
||||
<version>3.1.5</version>
|
||||
<infourl title="Component Builder!">https://dev.vdm.io</infourl>
|
||||
<downloads>
|
||||
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.1.3.zip</downloadurl>
|
||||
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.1.5.zip</downloadurl>
|
||||
</downloads>
|
||||
<tags>
|
||||
<tag>stable</tag>
|
||||
</tags>
|
||||
<maintainer>Llewellyn van der Merwe</maintainer>
|
||||
<maintainerurl>https://dev.vdm.io</maintainerurl>
|
||||
<targetplatform name="joomla" version="3.*"/>
|
||||
</update>
|
||||
<update>
|
||||
<name>Component Builder</name>
|
||||
<description>Builds Complex Joomla Components</description>
|
||||
<element>pkg_component_builder</element>
|
||||
<type>package</type>
|
||||
<client>site</client>
|
||||
<version>3.1.8</version>
|
||||
<infourl title="Component Builder!">https://dev.vdm.io</infourl>
|
||||
<downloads>
|
||||
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.1.8.zip</downloadurl>
|
||||
</downloads>
|
||||
<tags>
|
||||
<tag>stable</tag>
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?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
|
||||
*/
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2020
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Gitea;
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?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
|
||||
*/
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2020
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Gitea;
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?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
|
||||
*/
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2020
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Gitea;
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?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
|
||||
*/
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2020
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Gitea\Package\Repo;
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?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
|
||||
*/
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2020
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Gitea\Package\Repo;
|
||||
|
||||
|
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder;
|
||||
|
||||
|
||||
use Joomla\Registry\Registry;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\Input\Input;
|
||||
use VDM\Joomla\Utilities\Component\Helper;
|
||||
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
|
||||
|
||||
|
||||
/**
|
||||
* Configurations
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract class BaseConfig extends Registry
|
||||
{
|
||||
/**
|
||||
* 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.2.0
|
||||
*/
|
||||
protected Registry $params;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Input|null $input Input
|
||||
* @param Registry|null $params The component parameters
|
||||
*
|
||||
* @throws \Exception
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Input $input = null, ?Registry $params = null)
|
||||
{
|
||||
$this->input = $input ?: Factory::getApplication()->input;
|
||||
$this->params = $params ?: Helper::getParams('com_componentbuilder');
|
||||
|
||||
// use underscore as the separator
|
||||
$this->separator = '_';
|
||||
|
||||
// Instantiate the internal data object.
|
||||
$this->data = new \stdClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* setting any config value
|
||||
*
|
||||
* @param String $key The value's key/path name
|
||||
* @param mixed $value Optional default value, returned if the internal value is null.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __set($key, $value)
|
||||
{
|
||||
$this->set($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
// check if it has been set
|
||||
if (($value = $this->get($key, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(sprintf('Argument %s could not be found as function [%s], or path.', $key, $method));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a config 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Component;
|
||||
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use VDM\Joomla\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;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component\PlaceholderInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Get a Components Global Placeholders
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Placeholder implements PlaceholderInterface
|
||||
{
|
||||
/**
|
||||
* Placeholders
|
||||
*
|
||||
* @var array
|
||||
* @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(): array
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,421 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler;
|
||||
|
||||
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\BaseConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Configurations
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Config extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* 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
|
||||
)
|
||||
);
|
||||
|
||||
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'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
);
|
||||
|
||||
// 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;
|
||||
|
||||
return $add;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
|
||||
// get active value
|
||||
$add = ($value == 0) ? false : (
|
||||
($value == 1) ? true : (
|
||||
((int) GetHelper::var('joomla_component', $this->component_id, 'id', 'add_placeholders' ) == 1) ? true : false
|
||||
)
|
||||
);
|
||||
|
||||
return $add;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
|
||||
// get active value
|
||||
$add = ($value == 0) ? false : (
|
||||
($value == 1) ? true : (
|
||||
((int) GetHelper::var('joomla_component', $this->component_id, 'id', 'add_powers' ) == 1) ? true : false
|
||||
)
|
||||
);
|
||||
|
||||
return $add;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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';
|
||||
}
|
||||
|
||||
/**
|
||||
* get basic encryption switch
|
||||
*
|
||||
* @return bool Switch to control the encryption
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getBasicencryption(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* get medium encryption switch
|
||||
*
|
||||
* @return bool Switch to control the encryption
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getMediumencryption(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* get whmcs encryption switch
|
||||
*
|
||||
* @return bool Switch to control the encryption
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getWhmcsencryption(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,637 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler;
|
||||
|
||||
|
||||
use 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;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\CustomcodeInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Custom Code
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Customcode implements CustomcodeInterface
|
||||
{
|
||||
/**
|
||||
* 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(
|
||||
'[' => '[',
|
||||
']' => ']',
|
||||
',' => ',',
|
||||
'+' => '+',
|
||||
'=' => '='
|
||||
);
|
||||
|
||||
/**
|
||||
* 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 Extractor|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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update **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 update(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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 placeholders (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->get($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 get(?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)) !== false)
|
||||
{
|
||||
$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 (we do the other later when we add it to the correct position)
|
||||
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;
|
||||
}
|
||||
|
||||
// add to active set
|
||||
$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): string
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,284 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Customcode;
|
||||
|
||||
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Hash;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\LockBase;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode\DispenserInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Custom Code Dispenser
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Dispenser implements DispenserInterface
|
||||
{
|
||||
/**
|
||||
* Customcode Dispenser Hub
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public array $hub;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Compiler Customcode to Hash
|
||||
*
|
||||
* @var Hash
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Hash $hash;
|
||||
|
||||
/**
|
||||
* Compiler Customcode to LockBase
|
||||
*
|
||||
* @var LockBase
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected LockBase $base64;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @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 Hash|null $hash The compiler customcode hash object.
|
||||
* @param LockBase|null $base64 The compiler customcode lock base64 object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Placeholder $placeholder = null, ?Customcode $customcode = null,
|
||||
?Gui $gui = null, ?Hash $hash = null, ?LockBase $base64 = null)
|
||||
{
|
||||
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
|
||||
$this->customcode = $customcode ?: Compiler::_('Customcode');
|
||||
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
|
||||
$this->hash = $hash ?: Compiler::_('Customcode.Hash');
|
||||
$this->base64 = $base64 ?: Compiler::_('Customcode.LockBase');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the script for the customcode dispenser
|
||||
*
|
||||
* @param string $script The script
|
||||
* @param string $first The first key
|
||||
* @param string|null $second The second key (if not set we use only first key)
|
||||
* @param string|null $third The third key (if not set we use only first and second key)
|
||||
* @param array $config The config options
|
||||
* @param bool $base64 The switch to decode base64 the script
|
||||
* default: true
|
||||
* @param bool $dynamic The switch to dynamic update the script
|
||||
* default: true
|
||||
* @param bool $add The switch to add to exiting instead of replace
|
||||
* default: false
|
||||
*
|
||||
* @return bool true on success
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function set(&$script, string $first, ?string $second = null, ?string $third = null,
|
||||
array $config = array(), bool $base64 = true, bool $dynamic = true, bool $add = false): bool
|
||||
{
|
||||
// only load if we have a string
|
||||
if (!StringHelper::check($script))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// this needs refactoring (TODO)
|
||||
if (!isset($this->hub[$first])
|
||||
|| ($second
|
||||
&& !isset($this->hub[$first][$second])))
|
||||
{
|
||||
// check if the script first key is set
|
||||
if ($second && !isset($this->hub[$first]))
|
||||
{
|
||||
$this->hub[$first] = array();
|
||||
}
|
||||
elseif ($add && !$second
|
||||
&& !isset($this->hub[$first]))
|
||||
{
|
||||
$this->hub[$first] = '';
|
||||
}
|
||||
// check if the script second key is set
|
||||
if ($second && $third
|
||||
&& !isset($this->hub[$first][$second]))
|
||||
{
|
||||
$this->hub[$first][$second] = array();
|
||||
}
|
||||
elseif ($add && $second && !$third
|
||||
&& !isset($this->hub[$first][$second]))
|
||||
{
|
||||
$this->hub[$first][$second] = '';
|
||||
}
|
||||
// check if the script third key is set
|
||||
if ($add && $second && $third
|
||||
&& !isset($this->hub[$first][$second][$third]))
|
||||
{
|
||||
$this->hub[$first][$second][$third] = '';
|
||||
}
|
||||
}
|
||||
// prep the script string
|
||||
if ($base64 && $dynamic)
|
||||
{
|
||||
$script = $this->customcode->update(base64_decode($script));
|
||||
}
|
||||
elseif ($base64)
|
||||
{
|
||||
$script = base64_decode($script);
|
||||
}
|
||||
elseif ($dynamic) // this does not happen (just incase)
|
||||
{
|
||||
$script = $this->customcode->update($script);
|
||||
}
|
||||
// check if we still have a string
|
||||
if (StringHelper::check($script))
|
||||
{
|
||||
// now load the placeholder snippet if needed
|
||||
if ($base64 || $dynamic)
|
||||
{
|
||||
$script = $this->gui->set($script, $config);
|
||||
}
|
||||
// add Dynamic HASHING option of a file/string
|
||||
$script = $this->hash->set($script);
|
||||
// add base64 locking option of a string
|
||||
$script = $this->base64->set($script);
|
||||
// load the script
|
||||
if ($first && $second && $third)
|
||||
{
|
||||
// now act on loading option
|
||||
if ($add)
|
||||
{
|
||||
$this->hub[$first][$second][$third]
|
||||
.= $script;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->hub[$first][$second][$third]
|
||||
= $script;
|
||||
}
|
||||
}
|
||||
elseif ($first && $second)
|
||||
{
|
||||
// now act on loading option
|
||||
if ($add)
|
||||
{
|
||||
$this->hub[$first][$second] .= $script;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->hub[$first][$second] = $script;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// now act on loading option
|
||||
if ($add)
|
||||
{
|
||||
$this->hub[$first] .= $script;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->hub[$first] = $script;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the script from the customcode dispenser
|
||||
*
|
||||
* @param string $first The first key
|
||||
* @param string $second The second key
|
||||
* @param string $prefix The prefix to add in front of the script if found
|
||||
* @param string|null $note The switch/note to add to the script
|
||||
* @param bool $unset The switch to unset the value if found
|
||||
* @param mixed|null $default The switch/string to use as default return if script not found
|
||||
* @param string $suffix The suffix to add after the script if found
|
||||
*
|
||||
* @return mixed The string/script if found or the default value if not found
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(string $first, string $second, string $prefix = '', ?string $note = null,
|
||||
bool $unset = false, $default = null, string $suffix = '')
|
||||
{
|
||||
// default is to return an empty string
|
||||
$script = '';
|
||||
// check if there is any custom script
|
||||
if (isset($this->hub[$first][$second])
|
||||
&& StringHelper::check(
|
||||
$this->hub[$first][$second]
|
||||
))
|
||||
{
|
||||
// add not if set
|
||||
if ($note)
|
||||
{
|
||||
$script .= $note;
|
||||
}
|
||||
// load the actual script
|
||||
$script .= $prefix . str_replace(
|
||||
array_keys($this->placeholder->active),
|
||||
array_values($this->placeholder->active),
|
||||
$this->hub[$first][$second]
|
||||
) . $suffix;
|
||||
// clear some memory
|
||||
if ($unset)
|
||||
{
|
||||
unset($this->hub[$first][$second]);
|
||||
}
|
||||
}
|
||||
// if not found return default
|
||||
if (!StringHelper::check($script) && $default)
|
||||
{
|
||||
return $default;
|
||||
}
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,407 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\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;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode\ExternalInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler External Custom Code
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class External implements ExternalInterface
|
||||
{
|
||||
/**
|
||||
* 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 '';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,928 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Customcode;
|
||||
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\User\User;
|
||||
use Joomla\CMS\Filesystem\Folder;
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Extractor\Paths;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder\Reverse;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Component\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Path;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode\ExtractorInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Custom Code Extractor
|
||||
*
|
||||
* The custom script placeholders - we use the (xxx) to avoid detection it should be (***)
|
||||
* ##################################---> PHP/JS ---####################################
|
||||
*
|
||||
* New Insert Code = /xxx[INSERT>$$$$]xxx/ /xxx[/INSERT>$$$$]xxx/
|
||||
* New Replace Code = /xxx[REPLACE>$$$$]xxx/ /xxx[/REPLACE>$$$$]xxx/
|
||||
*
|
||||
* //////////////////////////////// when JCB adds it back //////////////////////////////////
|
||||
* JCB Add Inserted Code = /xxx[INSERTED$$$$]xxx//xx23xx/ /xxx[/INSERTED$$$$]xxx/
|
||||
* JCB Add Replaced Code = /xxx[REPLACED$$$$]xxx//xx25xx/ /xxx[/REPLACED$$$$]xxx/
|
||||
*
|
||||
* /////////////////////////////// changeing existing custom code /////////////////////////
|
||||
* Update Inserted Code = /xxx[INSERTED>$$$$]xxx//xx23xx/ /xxx[/INSERTED>$$$$]xxx/
|
||||
* Update Replaced Code = /xxx[REPLACED>$$$$]xxx//xx25xx/ /xxx[/REPLACED>$$$$]xxx/
|
||||
*
|
||||
* The custom script placeholders - we use the (==) to avoid detection it should be (--)
|
||||
* ###################################---> HTML ---#####################################
|
||||
*
|
||||
* New Insert Code = !==[INSERT>$$$$]==> !==[/INSERT>$$$$]==>
|
||||
* New Replace Code = !==[REPLACE>$$$$]==> !==[/REPLACE>$$$$]==>
|
||||
*
|
||||
* ///////////////////////////////// when JCB adds it back ///////////////////////////////
|
||||
* JCB Add Inserted Code =
|
||||
* JCB Add Replaced Code =
|
||||
*
|
||||
* //////////////////////////// changeing existing custom code ///////////////////////////
|
||||
* Update Inserted Code = !==[INSERTED>$$$$]==> !==[/INSERTED>$$$$]==>
|
||||
* Update Replaced Code = !==[REPLACED>$$$$]==> !==[/REPLACED>$$$$]==>
|
||||
*
|
||||
* ////////23 is the ID of the code in the system don't change it!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
*
|
||||
* More info read: https://git.vdm.dev/joomla/Component-Builder/wiki/TIPS:-Custom-Code
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Extractor implements ExtractorInterface
|
||||
{
|
||||
/**
|
||||
* The placeholder keys
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $PKeys
|
||||
= [
|
||||
1 => 'REPLACE<>$$$$]',
|
||||
2 => 'INSERT<>$$$$]',
|
||||
3 => 'REPLACED<>$$$$]',
|
||||
4 => 'INSERTED<>$$$$]'
|
||||
];
|
||||
|
||||
/**
|
||||
* The custom code in local files that already exist in system
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $existing = [];
|
||||
|
||||
/**
|
||||
* The custom code in local files that are new
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $new = [];
|
||||
|
||||
/**
|
||||
* The index of code already loaded
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $done = [];
|
||||
|
||||
/**
|
||||
* The search counter
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $counter = [1 => 0, 2 => 0];
|
||||
|
||||
/**
|
||||
* The file types to search
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $fileTypes = ['\.php', '\.js', '\.xml'];
|
||||
|
||||
/**
|
||||
* The local placeholders
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $placeholders;
|
||||
|
||||
/**
|
||||
* Today's date in SQL format
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected string $today;
|
||||
|
||||
/**
|
||||
* Compiler Config
|
||||
*
|
||||
* @var Config
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* Compiler Customcode Gui
|
||||
*
|
||||
* @var Gui
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Gui $gui;
|
||||
|
||||
/**
|
||||
* Compiler Customcode Extractor Paths
|
||||
*
|
||||
* @var Paths
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Paths $paths;
|
||||
|
||||
/**
|
||||
* Compiler Placeholder Reverse
|
||||
*
|
||||
* @var Reverse
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Reverse $reverse;
|
||||
|
||||
/**
|
||||
* Compiler Component Placeholder
|
||||
*
|
||||
* @var Placeholder
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Placeholder $componentPlaceholder;
|
||||
|
||||
/**
|
||||
* Current User Object
|
||||
*
|
||||
* @var User
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected User $user;
|
||||
|
||||
/**
|
||||
* 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 Gui|null $gui The compiler customcode gui object.
|
||||
* @param Paths|null $paths The compiler customcode extractor paths object.
|
||||
* @param Reverse|null $reverse The compiler placeholder reverse object.
|
||||
* @param Placeholder|null $placeholder The compiler component placeholder object.
|
||||
* @param User|null $user The current User 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, ?Gui $gui = null, ?Paths $paths = null,
|
||||
?Reverse $reverse = null, ?Placeholder $placeholder = null,
|
||||
?User $user = null, ?\JDatabaseDriver $db = null, ?CMSApplication $app = null)
|
||||
{
|
||||
$this->config = $config ?: Compiler::_('Config');
|
||||
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
|
||||
$this->paths = $paths ?: Compiler::_('Customcode.Extractor.Paths');
|
||||
$this->reverse = $reverse ?: Compiler::_('Placeholder.Reverse');
|
||||
$this->componentPlaceholder = $placeholder ?: Compiler::_('Component.Placeholder');
|
||||
$this->user = $user ?: Factory::getUser();
|
||||
$this->db = $db ?: Factory::getDbo();
|
||||
$this->app = $app ?: Factory::getApplication();
|
||||
|
||||
// set today's date
|
||||
$this->today = Factory::getDate()->toSql();
|
||||
|
||||
// set some local placeholders
|
||||
$placeholders = array_flip(
|
||||
$this->componentPlaceholder->get()
|
||||
);
|
||||
|
||||
$placeholders[StringHelper::safe(
|
||||
$this->config->component_code_name, 'F'
|
||||
) . 'Helper::'] = Placefix::_('Component') . 'Helper::';
|
||||
|
||||
$placeholders['COM_' . StringHelper::safe(
|
||||
$this->config->component_code_name, 'U'
|
||||
)] = 'COM_' . Placefix::_('COMPONENT');
|
||||
|
||||
$placeholders['com_' . $this->config->component_code_name] = 'com_' . Placefix::_('component');
|
||||
|
||||
// set the local placeholders
|
||||
$this->placeholders = array_reverse($placeholders, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* get the custom code from the local files
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// we must first store the current working directory
|
||||
$joomla = getcwd();
|
||||
|
||||
foreach ($this->paths->active as $target => $path)
|
||||
{
|
||||
// we are changing the working directory to the component path
|
||||
chdir($path);
|
||||
foreach ($this->fileTypes as $type)
|
||||
{
|
||||
// get a list of files in the current directory tree (only PHP, JS and XML for now)
|
||||
$files = Folder::files('.', $type, true, true);
|
||||
|
||||
// check if files found
|
||||
if (ArrayHelper::check($files))
|
||||
{
|
||||
foreach ($files as $file)
|
||||
{
|
||||
// search the file
|
||||
$this->searchFileContent($file, $target);
|
||||
|
||||
// insert new code
|
||||
$this->insert(100);
|
||||
|
||||
// update existing custom code
|
||||
$this->update(30);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// change back to Joomla working directory
|
||||
chdir($joomla);
|
||||
|
||||
// make sure all code is stored
|
||||
$this->insert();
|
||||
// update existing custom code
|
||||
$this->update();
|
||||
}
|
||||
|
||||
/**
|
||||
* search a file for placeholders and store result
|
||||
*
|
||||
* @param string $file The file path to search
|
||||
*
|
||||
* @return array on success
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function searchFileContent(&$file, &$target)
|
||||
{
|
||||
// we add a new search for the GUI CODE Blocks
|
||||
$this->gui->search($file, $this->placeholders, $this->today, $target);
|
||||
|
||||
// reset each time per file
|
||||
$loadEndFingerPrint = false;
|
||||
$endFingerPrint = [];
|
||||
$fingerPrint = [];
|
||||
$codeBucket = [];
|
||||
$pointer = [];
|
||||
$reading = [];
|
||||
$reader = 0;
|
||||
|
||||
// reset found Start type
|
||||
$commentType = 0;
|
||||
|
||||
// make sure we have the path correct (the script file is not in admin path for example)
|
||||
// there may be more... will nead to keep our eye on this... since files could be moved during install
|
||||
$file = str_replace('./', '', $file); # TODO (windows path issues)
|
||||
|
||||
if ($file !== 'script.php')
|
||||
{
|
||||
$path = $target . '/' . $file;
|
||||
}
|
||||
else
|
||||
{
|
||||
$path = $file;
|
||||
}
|
||||
|
||||
// now we go line by line
|
||||
foreach (new \SplFileObject($file) as $lineNumber => $lineContent)
|
||||
{
|
||||
// we must keep last few lines to dynamic find target entry later
|
||||
$fingerPrint[$lineNumber] = trim($lineContent);
|
||||
|
||||
// load the end fingerprint
|
||||
if ($loadEndFingerPrint)
|
||||
{
|
||||
$endFingerPrint[$lineNumber] = trim($lineContent);
|
||||
}
|
||||
|
||||
foreach ($this->PKeys as $type => $search)
|
||||
{
|
||||
$i = (int) ($type == 3 || $type == 4) ? 2 : 1;
|
||||
$_type = (int) ($type == 1 || $type == 3) ? 1 : 2;
|
||||
|
||||
if ($reader === 0 || $reader === $i)
|
||||
{
|
||||
$targetKey = $type;
|
||||
|
||||
$start = '/***[' . $search . '***/';
|
||||
$end = '/***[/' . $search . '***/';
|
||||
$startHTML = '<!--[' . $search . '-->';
|
||||
$endHTML = '<!--[/' . $search . '-->';
|
||||
|
||||
// check if the ending placeholder was found
|
||||
if (isset($reading[$targetKey]) && $reading[$targetKey]
|
||||
&& ((trim($lineContent) === $end
|
||||
|| strpos($lineContent, $end) !== false)
|
||||
|| (trim($lineContent) === $endHTML
|
||||
|| strpos($lineContent, $endHTML) !== false)))
|
||||
{
|
||||
// trim the placeholder and if there is still data then load it
|
||||
if (isset($endReplace)
|
||||
&& ($_line = $this->addLineChecker($endReplace, 2, $lineContent)) !== false)
|
||||
{
|
||||
$codeBucket[$pointer[$targetKey]][] = $_line;
|
||||
}
|
||||
|
||||
// deactivate the reader
|
||||
$reading[$targetKey] = false;
|
||||
|
||||
if ($_type == 2)
|
||||
{
|
||||
// deactivate search
|
||||
$reader = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// activate fingerPrint for replacement end target
|
||||
$loadEndFingerPrint = true;
|
||||
$backupTargetKey = $targetKey;
|
||||
$backupI = $i;
|
||||
}
|
||||
|
||||
// all new records we can do a bulk insert
|
||||
if ($i === 1)
|
||||
{
|
||||
// end the bucket info for this code block
|
||||
$this->new[$pointer[$targetKey]][]
|
||||
= $this->db->quote(
|
||||
(int) $lineNumber
|
||||
); // 'toline'
|
||||
|
||||
// first reverse engineer this code block
|
||||
$c0de = $this->reverse->engine(
|
||||
implode('', $codeBucket[$pointer[$targetKey]]),
|
||||
$this->placeholders, $target
|
||||
);
|
||||
|
||||
$this->new[$pointer[$targetKey]][]
|
||||
= $this->db->quote(
|
||||
base64_encode($c0de)
|
||||
); // 'code'
|
||||
|
||||
if ($_type == 2)
|
||||
{
|
||||
// load the last value
|
||||
$this->new[$pointer[$targetKey]][]
|
||||
= $this->db->quote(0); // 'hashendtarget'
|
||||
}
|
||||
}
|
||||
// the record already exist so we must update instead
|
||||
elseif ($i === 2)
|
||||
{
|
||||
// end the bucket info for this code block
|
||||
$this->existing[$pointer[$targetKey]]['fields'][]
|
||||
= $this->db->quoteName('to_line') . ' = '
|
||||
. $this->db->quote($lineNumber);
|
||||
|
||||
// first reverse engineer this code block
|
||||
$c0de = $this->reverse->engine(
|
||||
implode('', $codeBucket[$pointer[$targetKey]]),
|
||||
$this->placeholders, $target,
|
||||
$this->existing[$pointer[$targetKey]]['id']
|
||||
);
|
||||
|
||||
$this->existing[$pointer[$targetKey]]['fields'][]
|
||||
= $this->db->quoteName('code') . ' = '
|
||||
. $this->db->quote(base64_encode($c0de));
|
||||
|
||||
if ($_type == 2)
|
||||
{
|
||||
// load the last value
|
||||
$this->existing[$pointer[$targetKey]]['fields'][]
|
||||
= $this->db->quoteName('hashendtarget')
|
||||
. ' = ' . $this->db->quote(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check if the endfingerprint is ready to save
|
||||
if (count((array) $endFingerPrint) === 3)
|
||||
{
|
||||
$hashendtarget = '3__' . md5(
|
||||
implode('', $endFingerPrint)
|
||||
);
|
||||
|
||||
// all new records we can do a bulk insert
|
||||
if ($i === 1)
|
||||
{
|
||||
// load the last value
|
||||
$this->new[$pointer[$targetKey]][]
|
||||
= $this->db->quote(
|
||||
$hashendtarget
|
||||
); // 'hashendtarget'
|
||||
}
|
||||
// the record already exist so we must update
|
||||
elseif ($i === 2)
|
||||
{
|
||||
$this->existing[$pointer[$targetKey]]['fields'][]
|
||||
= $this->db->quoteName('hashendtarget') . ' = '
|
||||
. $this->db->quote($hashendtarget);
|
||||
}
|
||||
|
||||
// reset the needed values
|
||||
$endFingerPrint = [];
|
||||
$loadEndFingerPrint = false;
|
||||
|
||||
// deactivate reader (to allow other search)
|
||||
$reader = 0;
|
||||
}
|
||||
|
||||
// then read in the code
|
||||
if (isset($reading[$targetKey]) && $reading[$targetKey])
|
||||
{
|
||||
$codeBucket[$pointer[$targetKey]][] = $lineContent;
|
||||
}
|
||||
|
||||
// see if the custom code line starts now with PHP/JS comment type
|
||||
if ((!isset($reading[$targetKey]) || !$reading[$targetKey])
|
||||
&& (($i === 1 && trim($lineContent) === $start)
|
||||
|| strpos($lineContent, $start) !== false))
|
||||
{
|
||||
$commentType = 1; // PHP/JS type
|
||||
$startReplace = $start;
|
||||
$endReplace = $end;
|
||||
}
|
||||
// see if the custom code line starts now with HTML comment type
|
||||
elseif ((!isset($reading[$targetKey])
|
||||
|| !$reading[$targetKey])
|
||||
&& (($i === 1 && trim($lineContent) === $startHTML)
|
||||
|| strpos($lineContent, $startHTML) !== false))
|
||||
{
|
||||
$commentType = 2; // HTML type
|
||||
$startReplace = $startHTML;
|
||||
$endReplace = $endHTML;
|
||||
}
|
||||
|
||||
// check if the starting place holder was found
|
||||
if ($commentType > 0)
|
||||
{
|
||||
// if we have all on one line we have a problem (don't load it TODO)
|
||||
if (strpos($lineContent, $endReplace) !== false)
|
||||
{
|
||||
// reset found comment type
|
||||
$commentType = 0;
|
||||
$this->app->enqueueMessage(
|
||||
Text::_('COM_COMPONENTBUILDER_HR_HTHREECUSTOM_CODES_WARNINGHTHREE'),
|
||||
'Warning'
|
||||
);
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('COM_COMPONENTBUILDER_WE_FOUND_DYNAMIC_CODE_BALL_IN_ONE_LINEB_AND_IGNORED_IT_PLEASE_REVIEW_S_FOR_MORE_DETAILS',
|
||||
$path
|
||||
), 'Warning'
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
// do a quick check to insure we have an id
|
||||
$id = false;
|
||||
if ($i === 2)
|
||||
{
|
||||
$id = $this->getSystemID(
|
||||
$lineContent,
|
||||
array(1 => $start, 2 => $startHTML),
|
||||
$commentType
|
||||
);
|
||||
}
|
||||
|
||||
if ($i === 2 && $id > 0)
|
||||
{
|
||||
// make sure we update it only once even if found again.
|
||||
if (isset($this->done[$id]))
|
||||
{
|
||||
// reset found comment type
|
||||
$commentType = 0;
|
||||
continue;
|
||||
}
|
||||
// store the id to avoid duplication
|
||||
$this->done[$id] = (int) $id;
|
||||
}
|
||||
|
||||
// start replace
|
||||
$startReplace = $this->setStartReplace(
|
||||
$id, $commentType, $startReplace
|
||||
);
|
||||
|
||||
// set active reader (to lock out other search)
|
||||
$reader = $i;
|
||||
|
||||
// set pointer
|
||||
$pointer[$targetKey] = $this->counter[$i];
|
||||
|
||||
// activate the reader
|
||||
$reading[$targetKey] = true;
|
||||
|
||||
// start code bucket
|
||||
$codeBucket[$pointer[$targetKey]] = [];
|
||||
|
||||
// trim the placeholder and if there is still data then load it
|
||||
if ($_line = $this->addLineChecker(
|
||||
$startReplace, 1, $lineContent
|
||||
))
|
||||
{
|
||||
$codeBucket[$pointer[$targetKey]][] = $_line;
|
||||
}
|
||||
|
||||
// get the finger print around the custom code
|
||||
$inFinger = count($fingerPrint);
|
||||
$getFinger = $inFinger - 1;
|
||||
$hasharray = array_slice(
|
||||
$fingerPrint, -$inFinger, $getFinger, true
|
||||
);
|
||||
$hasleng = count($hasharray);
|
||||
$hashtarget = $hasleng . '__' . md5(
|
||||
implode('', $hasharray)
|
||||
);
|
||||
|
||||
// for good practice
|
||||
Path::fix($path);
|
||||
|
||||
// all new records we can do a bulk insert
|
||||
if ($i === 1 || !$id)
|
||||
{
|
||||
// start the bucket for this code
|
||||
$this->new[$pointer[$targetKey]] = [];
|
||||
$this->new[$pointer[$targetKey]][]
|
||||
= $this->db->quote(
|
||||
$path
|
||||
); // 'path'
|
||||
|
||||
$this->new[$pointer[$targetKey]][]
|
||||
= $this->db->quote(
|
||||
(int) $_type
|
||||
); // 'type'
|
||||
|
||||
$this->new[$pointer[$targetKey]][]
|
||||
= $this->db->quote(
|
||||
1
|
||||
); // 'target'
|
||||
|
||||
$this->new[$pointer[$targetKey]][]
|
||||
= $this->db->quote(
|
||||
$commentType
|
||||
); // 'comment_type'
|
||||
|
||||
$this->new[$pointer[$targetKey]][]
|
||||
= $this->db->quote(
|
||||
(int) $this->config->component_id
|
||||
); // 'component'
|
||||
|
||||
$this->new[$pointer[$targetKey]][]
|
||||
= $this->db->quote(
|
||||
1
|
||||
); // 'published'
|
||||
|
||||
$this->new[$pointer[$targetKey]][]
|
||||
= $this->db->quote(
|
||||
$this->today
|
||||
); // 'created'
|
||||
|
||||
$this->new[$pointer[$targetKey]][]
|
||||
= $this->db->quote(
|
||||
(int) $this->user->id
|
||||
); // 'created_by'
|
||||
|
||||
$this->new[$pointer[$targetKey]][]
|
||||
= $this->db->quote(
|
||||
1
|
||||
); // 'version'
|
||||
|
||||
$this->new[$pointer[$targetKey]][]
|
||||
= $this->db->quote(
|
||||
1
|
||||
); // 'access'
|
||||
|
||||
$this->new[$pointer[$targetKey]][]
|
||||
= $this->db->quote(
|
||||
$hashtarget
|
||||
); // 'hashtarget'
|
||||
|
||||
$this->new[$pointer[$targetKey]][]
|
||||
= $this->db->quote(
|
||||
(int) $lineNumber
|
||||
); // 'fromline'
|
||||
|
||||
}
|
||||
// the record already exist so we must update instead
|
||||
elseif ($i === 2 && $id > 0)
|
||||
{
|
||||
// start the bucket for this code
|
||||
$this->existing[$pointer[$targetKey]] = [];
|
||||
$this->existing[$pointer[$targetKey]]['id']
|
||||
= (int) $id;
|
||||
$this->existing[$pointer[$targetKey]]['conditions'] = [];
|
||||
$this->existing[$pointer[$targetKey]]['conditions'][]
|
||||
= $this->db->quoteName('id') . ' = '
|
||||
. $this->db->quote($id);
|
||||
$this->existing[$pointer[$targetKey]]['fields'] = [];
|
||||
$this->existing[$pointer[$targetKey]]['fields'][]
|
||||
= $this->db->quoteName('path') . ' = '
|
||||
. $this->db->quote($path);
|
||||
$this->existing[$pointer[$targetKey]]['fields'][]
|
||||
= $this->db->quoteName('type') . ' = '
|
||||
. $this->db->quote($_type);
|
||||
$this->existing[$pointer[$targetKey]]['fields'][]
|
||||
= $this->db->quoteName('comment_type') . ' = '
|
||||
. $this->db->quote($commentType);
|
||||
$this->existing[$pointer[$targetKey]]['fields'][]
|
||||
= $this->db->quoteName('component') . ' = '
|
||||
. $this->db->quote($this->config->component_id);
|
||||
$this->existing[$pointer[$targetKey]]['fields'][]
|
||||
= $this->db->quoteName('from_line') . ' = '
|
||||
. $this->db->quote($lineNumber);
|
||||
$this->existing[$pointer[$targetKey]]['fields'][]
|
||||
= $this->db->quoteName('modified') . ' = '
|
||||
. $this->db->quote($this->today);
|
||||
$this->existing[$pointer[$targetKey]]['fields'][]
|
||||
= $this->db->quoteName('modified_by') . ' = '
|
||||
. $this->db->quote($this->user->id);
|
||||
$this->existing[$pointer[$targetKey]]['fields'][]
|
||||
= $this->db->quoteName('hashtarget') . ' = '
|
||||
. $this->db->quote($hashtarget);
|
||||
}
|
||||
else // this should actualy never happen
|
||||
{
|
||||
// de activate the reader
|
||||
$reading[$targetKey] = false;
|
||||
$reader = 0;
|
||||
}
|
||||
|
||||
// reset found comment type
|
||||
$commentType = 0;
|
||||
// update the counter
|
||||
$this->counter[$i]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// make sure only a few lines is kept at a time
|
||||
if (count((array) $fingerPrint) > 10)
|
||||
{
|
||||
$fingerPrint = array_slice($fingerPrint, -6, 6, true);
|
||||
}
|
||||
}
|
||||
|
||||
// if the code is at the end of the page and there were not three more lines
|
||||
if (count((array) $endFingerPrint) > 0 || $loadEndFingerPrint)
|
||||
{
|
||||
if (count((array) $endFingerPrint) > 0)
|
||||
{
|
||||
$leng = count($endFingerPrint);
|
||||
$hashendtarget = $leng . '__' . md5(
|
||||
implode('', $endFingerPrint)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$hashendtarget = 0;
|
||||
}
|
||||
|
||||
// all new records we can do a buldk insert
|
||||
if ($backupI === 1)
|
||||
{
|
||||
// load the last value
|
||||
$this->new[$pointer[$backupTargetKey]][]
|
||||
= $this->db->quote($hashendtarget); // 'hashendtarget'
|
||||
}
|
||||
// the record already exist so we must use module to update
|
||||
elseif ($backupI === 2)
|
||||
{
|
||||
$this->existing[$pointer[$backupTargetKey]]['fields'][]
|
||||
= $this->db->quoteName('hashendtarget') . ' = '
|
||||
. $this->db->quote($hashendtarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert the code
|
||||
*
|
||||
* @param int $when To set when to update
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function insert(int $when = 1)
|
||||
{
|
||||
if (ArrayHelper::check($this->new) >= $when)
|
||||
{
|
||||
// Create a new query object.
|
||||
$query = $this->db->getQuery(true);
|
||||
$continue = false;
|
||||
// Insert columns.
|
||||
$columns = array('path', 'type', 'target', 'comment_type',
|
||||
'component', 'published', 'created', 'created_by',
|
||||
'version', 'access', 'hashtarget', 'from_line',
|
||||
'to_line', 'code', 'hashendtarget');
|
||||
// Prepare the insert query.
|
||||
$query->insert(
|
||||
$this->db->quoteName('#__componentbuilder_custom_code')
|
||||
);
|
||||
$query->columns($this->db->quoteName($columns));
|
||||
foreach ($this->new as $values)
|
||||
{
|
||||
if (count((array) $values) == 15)
|
||||
{
|
||||
$query->values(implode(',', $values));
|
||||
$continue = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO line mismatch... should not happen
|
||||
}
|
||||
}
|
||||
// clear the values array
|
||||
$this->new = [];
|
||||
if (!$continue)
|
||||
{
|
||||
return; // insure we don't continue if no values were loaded
|
||||
}
|
||||
// Set the query using our newly populated query object and execute it.
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the code
|
||||
*
|
||||
* @param int $when To set when to update
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function update(int $when = 1)
|
||||
{
|
||||
if (ArrayHelper::check($this->existing) >= $when)
|
||||
{
|
||||
foreach ($this->existing as $code)
|
||||
{
|
||||
// Create a new query object.
|
||||
$query = $this->db->getQuery(true);
|
||||
// Prepare the update query.
|
||||
$query->update(
|
||||
$this->db->quoteName('#__componentbuilder_custom_code')
|
||||
)->set($code['fields'])->where($code['conditions']);
|
||||
// Set the query using our newly populated query object and execute it.
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
}
|
||||
// clear the values array
|
||||
$this->existing = [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* set the start replace placeholder
|
||||
*
|
||||
* @param int $id The comment id
|
||||
* @param int $commentType The comment type
|
||||
* @param string $startReplace The main replace string
|
||||
*
|
||||
* @return string on success
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function setStartReplace(int $id, int $commentType, string $startReplace): string
|
||||
{
|
||||
if ($id > 0)
|
||||
{
|
||||
switch ($commentType)
|
||||
{
|
||||
case 1: // the PHP & JS type
|
||||
$startReplace .= '/*' . $id . '*/';
|
||||
break;
|
||||
case 2: // the HTML type
|
||||
$startReplace .= '<!--' . $id . '-->';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $startReplace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this line should be added
|
||||
*
|
||||
* @param string $replaceKey The key to remove from line
|
||||
* @param int $type The line type
|
||||
* @param string $lineContent The line to check
|
||||
*
|
||||
* @return bool|int true on success
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function addLineChecker(string $replaceKey, int $type, string $lineContent)
|
||||
{
|
||||
$check = explode($replaceKey, $lineContent);
|
||||
switch ($type)
|
||||
{
|
||||
case 1:
|
||||
// beginning of code
|
||||
if (isset($check[1]) && StringHelper::check($check[1]))
|
||||
{
|
||||
return trim($check[1]);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// end of code
|
||||
if (isset($check[0]) && StringHelper::check($check[0]))
|
||||
{
|
||||
return trim($check[0]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* search for the system id in the line given
|
||||
*
|
||||
* @param string $lineContent The file path to search
|
||||
* @param array $placeholders The values to search for
|
||||
* @param int $commentType The comment type
|
||||
*
|
||||
* @return mixed on success
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getSystemID(string &$lineContent, array $placeholders, int $commentType)
|
||||
{
|
||||
$trim = '/';
|
||||
if ($commentType == 2)
|
||||
{
|
||||
$trim = '<!--';
|
||||
}
|
||||
// remove place holder from content
|
||||
$string = trim(
|
||||
str_replace($placeholders[$commentType] . $trim, '', $lineContent)
|
||||
);
|
||||
// now get all numbers
|
||||
$numbers = [];
|
||||
preg_match_all('!\d+!', $string, $numbers);
|
||||
// return the first number
|
||||
if (isset($numbers[0])
|
||||
&& ArrayHelper::check(
|
||||
$numbers[0]
|
||||
))
|
||||
{
|
||||
return reset($numbers[0]);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,429 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Customcode\Extractor;
|
||||
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Filesystem\Folder;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
|
||||
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\Component\Placeholder as ComponentPlaceholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Language\Extractor;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Custom Code Paths
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Paths
|
||||
{
|
||||
/**
|
||||
* The local paths
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public array $active = [];
|
||||
|
||||
/**
|
||||
* Compiler Component Placeholder
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected array $componentPlaceholder;
|
||||
|
||||
/**
|
||||
* 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 Language Extractor
|
||||
*
|
||||
* @var Extractor
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Extractor $extractor;
|
||||
|
||||
/**
|
||||
* Database object to query local DB
|
||||
*
|
||||
* @var \JDatabaseDriver
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected \JDatabaseDriver $db;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config|null $config The compiler config object.
|
||||
* @param Placeholder|null $placeholder The compiler placeholder object.
|
||||
* @param ComponentPlaceholder|null $componentPlaceholder The compiler component placeholder object.
|
||||
* @param Customcode|null $customcode The compiler customcode object.
|
||||
* @param Extractor|null $extractor The compiler language extractor object.
|
||||
* @param \JDatabaseDriver|null $db The Database Driver object.
|
||||
*
|
||||
* @throws \Exception
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Config $config = null, ?Placeholder $placeholder = null,
|
||||
?ComponentPlaceholder $componentPlaceholder = null, ?Customcode $customcode = null,
|
||||
?Extractor $extractor = null, ?\JDatabaseDriver $db = null)
|
||||
{
|
||||
$this->config = $config ?: Compiler::_('Config');
|
||||
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
|
||||
/** @var ComponentPlaceholder $componentPlaceholder */
|
||||
$componentPlaceholder = $componentPlaceholder ?: Compiler::_('Component.Placeholder');
|
||||
$this->customcode = $customcode ?: Compiler::_('Customcode');
|
||||
$this->extractor = $extractor ?: Compiler::_('Language.Extractor');
|
||||
$this->db = $db ?: Factory::getDbo();
|
||||
|
||||
// load the placeholders to local array
|
||||
$this->componentPlaceholder = $componentPlaceholder->get();
|
||||
|
||||
// load the paths on initialization
|
||||
$this->load();
|
||||
}
|
||||
|
||||
/**
|
||||
* get the local installed path of this component
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function load()
|
||||
{
|
||||
// set the local paths to search
|
||||
$local_paths = array();
|
||||
|
||||
// admin path
|
||||
$local_paths['admin'] = JPATH_ADMINISTRATOR . '/components/com_'
|
||||
. $this->config->component_code_name;
|
||||
|
||||
// site path
|
||||
$local_paths['site'] = JPATH_ROOT . '/components/com_'
|
||||
. $this->config->component_code_name;
|
||||
|
||||
// media path
|
||||
$local_paths['media'] = JPATH_ROOT . '/media/com_'
|
||||
. $this->config->component_code_name;
|
||||
|
||||
// power path
|
||||
$local_paths['power'] = JPATH_ROOT . '/' . $this->config->get('jcb_powers_path', 'libraries/jcb_powers');
|
||||
|
||||
// lets also go over the REPOS - TODO
|
||||
|
||||
// Painful but we need to folder paths for the linked modules
|
||||
if (($module_ids = $this->getModuleIDs()) !== false)
|
||||
{
|
||||
foreach ($module_ids as $module_id)
|
||||
{
|
||||
// get the module folder path
|
||||
if (($path = $this->getModulePath($module_id)) !== false)
|
||||
{
|
||||
// set the path
|
||||
$local_paths['module_' . str_replace('/', '_', $path)] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Painful but we need to folder paths for the linked plugins
|
||||
if (($plugin_ids = $this->getPluginIDs()) !== false)
|
||||
{
|
||||
foreach ($plugin_ids as $plugin_id)
|
||||
{
|
||||
// get the plugin group and folder name
|
||||
if (($path = $this->getPluginPath($plugin_id)) !== false)
|
||||
{
|
||||
// set the path
|
||||
$local_paths['plugin_' . str_replace('/', '_', $path)] = JPATH_ROOT . '/plugins/' . $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check if the local install is found
|
||||
foreach ($local_paths as $key => $localPath)
|
||||
{
|
||||
if (!Folder::exists($localPath))
|
||||
{
|
||||
unset($local_paths[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
if (ArrayHelper::check($local_paths))
|
||||
{
|
||||
$this->active = $local_paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the Joomla Modules IDs
|
||||
*
|
||||
* @return mixed of IDs on success
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getModuleIDs()
|
||||
{
|
||||
if (($addjoomla_modules = GetHelper::var(
|
||||
'component_modules', $this->config->component_id, 'joomla_component',
|
||||
'addjoomla_modules'
|
||||
)) !== false)
|
||||
{
|
||||
$addjoomla_modules = (JsonHelper::check(
|
||||
$addjoomla_modules
|
||||
)) ? json_decode($addjoomla_modules, true) : null;
|
||||
if (ArrayHelper::check($addjoomla_modules))
|
||||
{
|
||||
$joomla_modules = array_filter(
|
||||
array_values($addjoomla_modules),
|
||||
function ($array) {
|
||||
// only load the modules whose target association call for it
|
||||
if (!isset($array['target']) || $array['target'] != 2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
);
|
||||
// if we have values we return IDs
|
||||
if (ArrayHelper::check($joomla_modules))
|
||||
{
|
||||
return array_map(
|
||||
function ($array) {
|
||||
return (int) $array['module'];
|
||||
}, $joomla_modules
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the Joomla module path
|
||||
*
|
||||
* @return mixed of module path and target site area on success
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getModulePath($id)
|
||||
{
|
||||
if (is_numeric($id) && $id > 0)
|
||||
{
|
||||
// Create a new query object.
|
||||
$query = $this->db->getQuery(true);
|
||||
|
||||
$query->select('a.*');
|
||||
$query->select(
|
||||
$this->db->quoteName(
|
||||
array(
|
||||
'a.name',
|
||||
'a.target'
|
||||
), array(
|
||||
'name',
|
||||
'target'
|
||||
)
|
||||
)
|
||||
);
|
||||
// from these tables
|
||||
$query->from('#__componentbuilder_joomla_module AS a');
|
||||
$query->where($this->db->quoteName('a.id') . ' = ' . (int) $id);
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
if ($this->db->getNumRows())
|
||||
{
|
||||
// get the module data
|
||||
$module = $this->db->loadObject();
|
||||
// update the name if it has dynamic values
|
||||
$module->name = $this->placeholder->update(
|
||||
$this->customcode->update($module->name),
|
||||
$this->componentPlaceholder
|
||||
);
|
||||
|
||||
// set safe class function name
|
||||
$module->code_name
|
||||
= ClassfunctionHelper::safe(
|
||||
$module->name
|
||||
);
|
||||
// set module folder name
|
||||
$module->folder_name = 'mod_' . strtolower($module->code_name);
|
||||
|
||||
// set the lang key
|
||||
$this->extractor->langKeys[strtoupper($module->folder_name)] =
|
||||
$module->id . '_M0dU|3';
|
||||
|
||||
// return the path
|
||||
if ($module->target == 2)
|
||||
{
|
||||
// administrator client area
|
||||
return JPATH_ADMINISTRATOR . '/modules/'
|
||||
. $module->folder_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
// default is the site client area
|
||||
return JPATH_ROOT . '/modules/' . $module->folder_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the Joomla plugins IDs
|
||||
*
|
||||
* @return mixed of IDs on success
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getPluginIDs()
|
||||
{
|
||||
if (($addjoomla_plugins = GetHelper::var(
|
||||
'component_plugins', $this->config->component_id, 'joomla_component',
|
||||
'addjoomla_plugins'
|
||||
)) !== false)
|
||||
{
|
||||
$addjoomla_plugins = (JsonHelper::check(
|
||||
$addjoomla_plugins
|
||||
)) ? json_decode($addjoomla_plugins, true) : null;
|
||||
if (ArrayHelper::check($addjoomla_plugins))
|
||||
{
|
||||
$joomla_plugins = array_filter(
|
||||
array_values($addjoomla_plugins),
|
||||
function ($array) {
|
||||
// only load the plugins whose target association call for it
|
||||
if (!isset($array['target']) || $array['target'] != 2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
);
|
||||
// if we have values we return IDs
|
||||
if (ArrayHelper::check($joomla_plugins))
|
||||
{
|
||||
return array_map(
|
||||
function ($array) {
|
||||
return (int) $array['plugin'];
|
||||
}, $joomla_plugins
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the Joomla plugin path
|
||||
*
|
||||
* @return mixed of plugin path on success
|
||||
* @deprecated 3.3
|
||||
*/
|
||||
protected function getPluginPath($id)
|
||||
{
|
||||
if (is_numeric($id) && $id > 0)
|
||||
{
|
||||
// Create a new query object.
|
||||
$query = $this->db->getQuery(true);
|
||||
|
||||
$query->select('a.*');
|
||||
$query->select(
|
||||
$this->db->quoteName(
|
||||
array(
|
||||
'a.name',
|
||||
'g.name'
|
||||
), array(
|
||||
'name',
|
||||
'group'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// from these tables
|
||||
$query->from('#__componentbuilder_joomla_plugin AS a');
|
||||
$query->join(
|
||||
'LEFT', $this->db->quoteName(
|
||||
'#__componentbuilder_joomla_plugin_group', 'g'
|
||||
) . ' ON (' . $this->db->quoteName('a.joomla_plugin_group')
|
||||
. ' = ' . $this->db->quoteName('g.id') . ')'
|
||||
);
|
||||
$query->where($this->db->quoteName('a.id') . ' = ' . (int) $id);
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
|
||||
if ($this->db->getNumRows())
|
||||
{
|
||||
// get the plugin data
|
||||
$plugin = $this->db->loadObject();
|
||||
|
||||
// update the name if it has dynamic values
|
||||
$plugin->name = $this->placeholder->update(
|
||||
$this->customcode->update($plugin->name),
|
||||
$this->componentPlaceholder
|
||||
);
|
||||
|
||||
// update the name if it has dynamic values
|
||||
$plugin->code_name
|
||||
= ClassfunctionHelper::safe(
|
||||
$plugin->name
|
||||
);
|
||||
|
||||
// set plugin folder name
|
||||
$plugin->group = strtolower($plugin->group);
|
||||
// set plugin file name
|
||||
$plugin->file_name = strtolower($plugin->code_name);
|
||||
|
||||
// set the lang key
|
||||
$this->extractor->langKeys['PLG_' . strtoupper(
|
||||
$plugin->group . '_' . $plugin->file_name
|
||||
)] = $plugin->id . '_P|uG!n';
|
||||
|
||||
// return the path
|
||||
return $plugin->group . '/' . $plugin->file_name;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,257 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\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;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode\GuiInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Gui Custom Code
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Gui implements GuiInterface
|
||||
{
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Customcode;
|
||||
|
||||
|
||||
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 Custom Code MD5
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Hash
|
||||
{
|
||||
/**
|
||||
* Compiler Placeholder
|
||||
*
|
||||
* @var Placeholder
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Placeholder $placeholder;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Placeholder|null $placeholder The compiler placeholder object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Placeholder $placeholder = null)
|
||||
{
|
||||
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the MD5 hashed string or file or string
|
||||
*
|
||||
* @param string $script The code string
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function set(string $script): string
|
||||
{
|
||||
// check if we should hash a string
|
||||
if (\strpos($script, 'HASH' . 'STRING((((') !== false)
|
||||
{
|
||||
// get the strings
|
||||
$values = GetHelper::allBetween(
|
||||
$script, 'HASH' . 'STRING((((', '))))'
|
||||
);
|
||||
$locker = array();
|
||||
// convert them
|
||||
foreach ($values as $value)
|
||||
{
|
||||
$locker['HASH' . 'STRING((((' . $value . '))))']
|
||||
= \md5($value);
|
||||
}
|
||||
|
||||
// update the script
|
||||
return $this->placeholder->update($script, $locker);
|
||||
}
|
||||
// check if we should hash a file
|
||||
if (\strpos($script, 'HASH' . 'FILE((((') !== false)
|
||||
{
|
||||
// get the strings
|
||||
$values = GetHelper::allBetween(
|
||||
$script, 'HASH' . 'FILE((((', '))))'
|
||||
);
|
||||
$locker = array();
|
||||
// convert them
|
||||
foreach ($values as $path)
|
||||
{
|
||||
// we first get the file if it exist
|
||||
if ($value = FileHelper::getContent($path))
|
||||
{
|
||||
// now we hash the file content
|
||||
$locker['HASH' . 'FILE((((' . $path . '))))']
|
||||
= \md5($value);
|
||||
}
|
||||
else
|
||||
{
|
||||
// could not retrieve the file so we show error
|
||||
$locker['HASH' . 'FILE((((' . $path . '))))']
|
||||
= 'ERROR';
|
||||
}
|
||||
}
|
||||
|
||||
// update the script
|
||||
return $this->placeholder->update($script, $locker);
|
||||
}
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Customcode;
|
||||
|
||||
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode\LockBaseInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Custom Code Base64
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class LockBase implements LockBaseInterface
|
||||
{
|
||||
/**
|
||||
* Compiler Placeholder
|
||||
*
|
||||
* @var Placeholder
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Placeholder $placeholder;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Placeholder|null $placeholder The compiler placeholder object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Placeholder $placeholder = null)
|
||||
{
|
||||
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a string as bsae64 (basic)
|
||||
*
|
||||
* @param string $script The code string
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function set(string $script): string
|
||||
{
|
||||
if (\strpos($script, 'LOCK'.'BASE64((((') !== false)
|
||||
{
|
||||
// get the strings
|
||||
$values = GetHelper::allBetween(
|
||||
$script, 'LOCK'.'BASE64((((', '))))'
|
||||
);
|
||||
$locker = array();
|
||||
// convert them
|
||||
foreach ($values as $value)
|
||||
{
|
||||
$locker['LOCK'.'BASE64((((' . $value . '))))']
|
||||
= "base64_decode( preg_replace('/\s+/', ''," .
|
||||
PHP_EOL . Indent::_(2) . "'" .
|
||||
\wordwrap(
|
||||
\base64_encode($value), 64, PHP_EOL . Indent::_(2), true
|
||||
) .
|
||||
"'))";
|
||||
}
|
||||
|
||||
// update the script
|
||||
return $this->placeholder->update($script, $locker);
|
||||
}
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,371 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Extension\JoomlaThree;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Extension\InstallInterface;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
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.2.0
|
||||
*/
|
||||
class InstallScript implements GetScriptInterface
|
||||
{
|
||||
/**
|
||||
* The extension
|
||||
*
|
||||
* @var InstallInterface|Object
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected object $extension;
|
||||
|
||||
/**
|
||||
* The methods
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $methods = ['php_script', 'php_preflight', 'php_postflight', 'php_method'];
|
||||
|
||||
/**
|
||||
* The types
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $types = ['construct', 'install', 'update', 'uninstall', 'discover_install'];
|
||||
|
||||
/**
|
||||
* The construct bucket
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $construct = [];
|
||||
|
||||
/**
|
||||
* The install bucket
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $install = [];
|
||||
|
||||
/**
|
||||
* The update bucket
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $update = [];
|
||||
|
||||
/**
|
||||
* The uninstall bucket
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $uninstall = [];
|
||||
|
||||
/**
|
||||
* The preflight switch
|
||||
*
|
||||
* @var bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected bool $preflightActive = false;
|
||||
|
||||
/**
|
||||
* The preflight bucket
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $preflightBucket = ['install' => [], 'uninstall' => [], 'discover_install' => [], 'update' => []];
|
||||
|
||||
/**
|
||||
* The postflight switch
|
||||
*
|
||||
* @var bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected bool $postflightActive = false;
|
||||
|
||||
/**
|
||||
* The postflight bucket
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $postflightBucket = ['install' => [], 'uninstall' => [], 'discover_install' => [], 'update' => []];
|
||||
|
||||
/**
|
||||
* get install script
|
||||
*
|
||||
* @param Object $extension The extension object
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(object $extension): string
|
||||
{
|
||||
// loop over methods and types
|
||||
foreach ($this->methods as $method)
|
||||
{
|
||||
foreach ($this->types as $type)
|
||||
{
|
||||
if (isset($extension->{'add_' . $method . '_' . $type})
|
||||
&& $extension->{'add_' . $method . '_' . $type} == 1
|
||||
&& StringHelper::check(
|
||||
$extension->{$method . '_' . $type}
|
||||
))
|
||||
{
|
||||
// add to the main methods
|
||||
if ('php_method' === $method || 'php_script' === $method)
|
||||
{
|
||||
$this->{$type}[] = $extension->{$method . '_' . $type};
|
||||
}
|
||||
else
|
||||
{
|
||||
// get the flight key
|
||||
$flight = str_replace('php_', '', $method);
|
||||
// load the script to our bucket
|
||||
$this->{$flight . 'Bucket'}[$type][] = $extension->{$method . '_' . $type};
|
||||
// show that the method is active
|
||||
$this->{$flight . 'Active'} = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->extension = $extension;
|
||||
|
||||
// return the class
|
||||
return $this->build();
|
||||
}
|
||||
|
||||
/**
|
||||
* build the install class
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function build(): string
|
||||
{
|
||||
// start build
|
||||
$script = $this->head();
|
||||
|
||||
// load constructor if set
|
||||
$script .= $this->construct();
|
||||
|
||||
// load install method if set
|
||||
$script .= $this->main('install');
|
||||
|
||||
// load update method if set
|
||||
$script .= $this->main('update');
|
||||
|
||||
// load uninstall method if set
|
||||
$script .= $this->main('uninstall');
|
||||
|
||||
// load preflight method if set
|
||||
$script .= $this->flight('preflight');
|
||||
|
||||
// load postflight method if set
|
||||
$script .= $this->flight('postflight');
|
||||
|
||||
// close the class
|
||||
$script .= PHP_EOL . '}' . PHP_EOL;
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
/**
|
||||
* get install script head
|
||||
*
|
||||
* @return string
|
||||
* @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
|
||||
. ' script file.';
|
||||
$script .= PHP_EOL . ' *';
|
||||
$script .= PHP_EOL . ' * @package ' . $extension->class_name;
|
||||
$script .= PHP_EOL . ' */';
|
||||
$script .= PHP_EOL . 'class ' . $extension->installer_class_name;
|
||||
$script .= PHP_EOL . '{';
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
/**
|
||||
* get constructor
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function construct(): string
|
||||
{
|
||||
// return empty string if not set
|
||||
if (!ArrayHelper::check($this->construct))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
// the __construct script
|
||||
$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 . Indent::_(1) . ' */';
|
||||
$script .= PHP_EOL . Indent::_(1)
|
||||
. 'public function __construct($adapter)';
|
||||
$script .= PHP_EOL . Indent::_(1) . '{';
|
||||
$script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->construct);
|
||||
// close the function
|
||||
$script .= PHP_EOL . Indent::_(1) . '}';
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
/**
|
||||
* build main methods
|
||||
*
|
||||
* @param string $name the method being called
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function main(string $name): string
|
||||
{
|
||||
// return empty string if not set
|
||||
if (!ArrayHelper::check($this->{$name}))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
// load the install method
|
||||
$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 . Indent::_(1) . ' *';
|
||||
$script .= PHP_EOL . Indent::_(1)
|
||||
. ' * @return boolean True on success';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' */';
|
||||
$script .= PHP_EOL . Indent::_(1) . 'public function '
|
||||
. $name . '($adapter)';
|
||||
$script .= PHP_EOL . Indent::_(1) . '{';
|
||||
$script .= PHP_EOL . implode(PHP_EOL . PHP_EOL, $this->{$name});
|
||||
// return true
|
||||
if ('uninstall' !== $name)
|
||||
{
|
||||
$script .= PHP_EOL . Indent::_(2) . 'return true;';
|
||||
}
|
||||
// close the function
|
||||
$script .= PHP_EOL . Indent::_(1) . '}';
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
/**
|
||||
* build flight methods
|
||||
*
|
||||
* @param string $name the method being called
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function flight(string $name): string
|
||||
{
|
||||
// return empty string if not set
|
||||
if (empty($this->{$name . 'Active'}))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
// the pre/post function types
|
||||
$script = PHP_EOL . PHP_EOL . Indent::_(1) . '/**';
|
||||
$script .= PHP_EOL . Indent::_(1)
|
||||
. ' * Called before any type of action';
|
||||
$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 . Indent::_(1)
|
||||
. ' * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' *';
|
||||
$script .= PHP_EOL . Indent::_(1)
|
||||
. ' * @return boolean True on success';
|
||||
$script .= PHP_EOL . Indent::_(1) . ' */';
|
||||
$script .= PHP_EOL . Indent::_(1) . 'public function '
|
||||
. $name . '($route, $adapter)';
|
||||
$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 . Indent::_(2) . '//' . Line::_(__Line__, __Class__)
|
||||
.' the default for both install and update';
|
||||
$script .= PHP_EOL . Indent::_(2)
|
||||
. '$jversion = new JVersion();';
|
||||
$script .= PHP_EOL . Indent::_(2)
|
||||
. "if (!\$jversion->isCompatible('3.8.0'))";
|
||||
$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 . Indent::_(3) . 'return false;';
|
||||
$script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL;
|
||||
}
|
||||
|
||||
// now add the scripts
|
||||
foreach ($this->{$name . 'Bucket'} as $route => $_script)
|
||||
{
|
||||
if (ArrayHelper::check($_script))
|
||||
{
|
||||
// set the if and script
|
||||
$script .= PHP_EOL . Indent::_(2) . "if ('" . $route
|
||||
. "' === \$route)";
|
||||
$script .= PHP_EOL . Indent::_(2) . '{';
|
||||
$script .= PHP_EOL . implode(
|
||||
PHP_EOL . PHP_EOL, $_script
|
||||
);
|
||||
$script .= PHP_EOL . Indent::_(2) . '}' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
// return true
|
||||
$script .= PHP_EOL . Indent::_(2) . 'return true;';
|
||||
// close the function
|
||||
$script .= PHP_EOL . Indent::_(1) . '}';
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler;
|
||||
|
||||
|
||||
use 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\Compiler())
|
||||
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Compiler\Service\Event())
|
||||
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Compiler\Service\History())
|
||||
->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())
|
||||
->registerServiceProvider(new \VDM\Joomla\Componentbuilder\Compiler\Service\Field());
|
||||
|
||||
return $container;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Field\Data;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Field\Name;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Field\TypeName;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Field\UniqueName;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Field
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Field
|
||||
{
|
||||
/**
|
||||
* Compiler Field Data
|
||||
*
|
||||
* @var Data
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Data $data;
|
||||
|
||||
/**
|
||||
* Compiler Field Name
|
||||
*
|
||||
* @var Name
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Name $name;
|
||||
|
||||
/**
|
||||
* Compiler Field Type Name
|
||||
*
|
||||
* @var TypeName
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected TypeName $typeName;
|
||||
|
||||
/**
|
||||
* Compiler Field Unique Name
|
||||
*
|
||||
* @var UniqueName
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected UniqueName $uniqueName;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Data|null $data The compiler field data object.
|
||||
* @param Name|null $name The compiler field name object.
|
||||
* @param TypeName|null $typeName The compiler field type name object.
|
||||
* @param UniqueName|null $uniqueName The compiler field unique name object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Data $data = null, ?Name $name = null, ?TypeName $typeName = null, ?UniqueName $uniqueName = null)
|
||||
{
|
||||
$this->data = $data ?: Compiler::_('Field.Data');
|
||||
$this->name = $name ?: Compiler::_('Field.Name');
|
||||
$this->typeName = $typeName ?: Compiler::_('Field.Type.Name');
|
||||
$this->uniqueName = $uniqueName ?: Compiler::_('Field.Unique.Name');
|
||||
}
|
||||
|
||||
/**
|
||||
* set Field details
|
||||
*
|
||||
* @param array $field The field array.
|
||||
* @param string|null $singleViewName The single view name.
|
||||
* @param string|null $listViewName The list view name.
|
||||
* @param string $amicably The peaceful resolve.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function set(array &$field, ?string $singleViewName = null, ?string $listViewName = null, string $amicably = '')
|
||||
{
|
||||
// set hash
|
||||
static $hash = 123467890;
|
||||
|
||||
// load hash if not found
|
||||
if (!isset($field['hash']))
|
||||
{
|
||||
$field['hash'] = \md5($field['field'] . $hash);
|
||||
// increment hash
|
||||
$hash++;
|
||||
}
|
||||
|
||||
// set the settings
|
||||
if (!isset($field['settings']))
|
||||
{
|
||||
$field['settings'] = $this->data->get(
|
||||
$field['field'], $singleViewName, $listViewName
|
||||
);
|
||||
}
|
||||
|
||||
// set real field name
|
||||
if (!isset($field['base_name']))
|
||||
{
|
||||
$field['base_name'] = $this->name->get($field);
|
||||
}
|
||||
|
||||
// set code name for field type
|
||||
if (!isset($field['type_name']))
|
||||
{
|
||||
$field['type_name'] = $this->typeName->get($field);
|
||||
}
|
||||
|
||||
// check if value is array
|
||||
if (isset($field['permission'])
|
||||
&& !ArrayHelper::check($field['permission'])
|
||||
&& is_numeric($field['permission']) && $field['permission'] > 0)
|
||||
{
|
||||
$field['permission'] = array($field['permission']);
|
||||
}
|
||||
|
||||
// set unique name keeper
|
||||
if ($listViewName)
|
||||
{
|
||||
$this->uniqueName->set(
|
||||
$field['base_name'], $listViewName . $amicably
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,232 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Field;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Field Customcode
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Customcode
|
||||
{
|
||||
/**
|
||||
* Tracking the update of fields per/view
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $views;
|
||||
|
||||
/**
|
||||
* Compiler Customcode Dispenser
|
||||
*
|
||||
* @var Dispenser
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Dispenser $dispenser;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Dispenser|null $dispenser The compiler customcode dispenser object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Dispenser $dispenser = null)
|
||||
{
|
||||
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update field customcode
|
||||
*
|
||||
* @param int $id The field id
|
||||
* @param object $field The field object
|
||||
* @param string|null $singleViewName The view edit or single name
|
||||
* @param string|null $listViewName The view list name
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function update(int $id, object &$field, $singleViewName = null, $listViewName = null)
|
||||
{
|
||||
// check if we should load scripts for single view
|
||||
if ($singleViewName && StringHelper::check($singleViewName)
|
||||
&& !isset($this->views[$singleViewName][$id]))
|
||||
{
|
||||
// add_javascript_view_footer
|
||||
if ($field->add_javascript_view_footer == 1
|
||||
&& StringHelper::check(
|
||||
$field->javascript_view_footer
|
||||
))
|
||||
{
|
||||
$convert__ = true;
|
||||
if (isset($field->javascript_view_footer_decoded)
|
||||
&& $field->javascript_view_footer_decoded)
|
||||
{
|
||||
$convert__ = false;
|
||||
}
|
||||
$this->dispenser->set(
|
||||
$field->javascript_view_footer,
|
||||
'view_footer',
|
||||
$singleViewName,
|
||||
null,
|
||||
array(
|
||||
'table' => 'field',
|
||||
'id' => (int) $id,
|
||||
'field' => 'javascript_view_footer',
|
||||
'type' => 'js',
|
||||
'prefix' => PHP_EOL),
|
||||
$convert__,
|
||||
$convert__,
|
||||
true
|
||||
);
|
||||
if (!isset($field->javascript_view_footer_decoded))
|
||||
{
|
||||
$field->javascript_view_footer_decoded
|
||||
= true;
|
||||
}
|
||||
|
||||
if (strpos($field->javascript_view_footer, "token") !== false
|
||||
|| strpos($field->javascript_view_footer, "task=ajax") !== false)
|
||||
{
|
||||
if (!isset($this->dispenser->hub['token']))
|
||||
{
|
||||
$this->dispenser->hub['token'] = [];
|
||||
}
|
||||
if (!isset($this->dispenser->hub['token'][$singleViewName])
|
||||
|| !$this->dispenser->hub['token'][$singleViewName])
|
||||
{
|
||||
$this->dispenser->hub['token'][$singleViewName]
|
||||
= true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add_css_view
|
||||
if ($field->add_css_view == 1)
|
||||
{
|
||||
$convert__ = true;
|
||||
if (isset($field->css_view_decoded)
|
||||
&& $field->css_view_decoded)
|
||||
{
|
||||
$convert__ = false;
|
||||
}
|
||||
$this->dispenser->set(
|
||||
$field->css_view,
|
||||
'css_view',
|
||||
$singleViewName,
|
||||
null,
|
||||
array('prefix' => PHP_EOL),
|
||||
$convert__,
|
||||
$convert__,
|
||||
true
|
||||
);
|
||||
if (!isset($field->css_view_decoded))
|
||||
{
|
||||
$field->css_view_decoded = true;
|
||||
}
|
||||
}
|
||||
|
||||
// add this only once to single view.
|
||||
$this->views[$singleViewName][$id] = true;
|
||||
}
|
||||
|
||||
// check if we should load scripts for list views
|
||||
if ($listViewName && StringHelper::check($listViewName)
|
||||
&& !isset($this->views[$listViewName][$id]))
|
||||
{
|
||||
// add_javascript_views_footer
|
||||
if ($field->add_javascript_views_footer == 1
|
||||
&& StringHelper::check(
|
||||
$field->javascript_views_footer
|
||||
))
|
||||
{
|
||||
$convert__ = true;
|
||||
if (isset($field->javascript_views_footer_decoded)
|
||||
&& $field->javascript_views_footer_decoded)
|
||||
{
|
||||
$convert__ = false;
|
||||
}
|
||||
$this->dispenser->set(
|
||||
$field->javascript_views_footer,
|
||||
'views_footer',
|
||||
$singleViewName,
|
||||
null,
|
||||
array(
|
||||
'table' => 'field',
|
||||
'id' => (int) $id,
|
||||
'field' => 'javascript_views_footer',
|
||||
'type' => 'js',
|
||||
'prefix' => PHP_EOL),
|
||||
$convert__,
|
||||
$convert__,
|
||||
true
|
||||
);
|
||||
if (!isset($field->javascript_views_footer_decoded))
|
||||
{
|
||||
$field->javascript_views_footer_decoded = true;
|
||||
}
|
||||
if (strpos($field->javascript_views_footer, "token") !== false
|
||||
|| strpos($field->javascript_views_footer, "task=ajax") !== false)
|
||||
{
|
||||
if (!isset($this->dispenser->hub['token']))
|
||||
{
|
||||
$this->dispenser->hub['token'] = [];
|
||||
}
|
||||
if (!isset($this->dispenser->hub['token'][$listViewName])
|
||||
|| !$this->dispenser->hub['token'][$listViewName])
|
||||
{
|
||||
$this->dispenser->hub['token'][$listViewName]
|
||||
= true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add_css_views
|
||||
if ($field->add_css_views == 1)
|
||||
{
|
||||
$convert__ = true;
|
||||
if (isset($field->css_views_decoded)
|
||||
&& $field->css_views_decoded)
|
||||
{
|
||||
$convert__ = false;
|
||||
}
|
||||
$this->dispenser->set(
|
||||
$field->css_views,
|
||||
'css_views',
|
||||
$singleViewName,
|
||||
null,
|
||||
array('prefix' => PHP_EOL),
|
||||
$convert__,
|
||||
$convert__,
|
||||
true
|
||||
);
|
||||
if (!isset($field->css_views_decoded))
|
||||
{
|
||||
$field->css_views_decoded = true;
|
||||
}
|
||||
}
|
||||
|
||||
// add this only once to list view.
|
||||
$this->views[$listViewName][$id] = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,329 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Field;
|
||||
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HistoryInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Field\Customcode as FieldCustomcode;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Field\Validation;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Field Data
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Data
|
||||
{
|
||||
/**
|
||||
* Compiler Fields
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $fields;
|
||||
|
||||
/**
|
||||
* Compiler Config
|
||||
*
|
||||
* @var Config
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* Compiler Event
|
||||
*
|
||||
* @var EventInterface
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected EventInterface $event;
|
||||
|
||||
/**
|
||||
* Compiler History
|
||||
*
|
||||
* @var HistoryInterface
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected HistoryInterface $history;
|
||||
|
||||
/**
|
||||
* Compiler Placeholder
|
||||
*
|
||||
* @var Placeholder
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Placeholder $placeholder;
|
||||
|
||||
/**
|
||||
* Compiler Customcode
|
||||
*
|
||||
* @var Customcode
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Customcode $customcode;
|
||||
|
||||
/**
|
||||
* Compiler Field Customcode
|
||||
*
|
||||
* @var FieldCustomcode
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected FieldCustomcode $fieldCustomcode;
|
||||
|
||||
/**
|
||||
* Compiler Field Validation
|
||||
*
|
||||
* @var Validation
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Validation $validation;
|
||||
|
||||
/**
|
||||
* Database object to query local DB
|
||||
*
|
||||
* @var \JDatabaseDriver
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected \JDatabaseDriver $db;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Config|null $config The compiler config object.
|
||||
* @param EventInterface|null $event The compiler event api object.
|
||||
* @param HistoryInterface|null $history The compiler history object.
|
||||
* @param Placeholder|null $placeholder The compiler placeholder object.
|
||||
* @param Customcode|null $customcode The compiler customcode object.
|
||||
* @param FieldCustomcode|null $fieldCustomcode The field customcode object.
|
||||
* @param Validation|null $validation The field validation rule object.
|
||||
* @param \JDatabaseDriver|null $db The database object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Config $config = null, ?EventInterface $event = null, ?HistoryInterface $history = null,
|
||||
?Placeholder $placeholder = null, ?Customcode $customcode = null, ?FieldCustomcode $fieldCustomcode = null,
|
||||
?Validation $validation = null, ?\JDatabaseDriver $db = null)
|
||||
{
|
||||
$this->config = $config ?: Compiler::_('Config');
|
||||
$this->event = $event ?: Compiler::_('Event');
|
||||
$this->history = $history ?: Compiler::_('History');
|
||||
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
|
||||
$this->customcode = $customcode ?: Compiler::_('Customcode');
|
||||
$this->fieldCustomcode = $fieldCustomcode ?: Compiler::_('Field.Customcode');
|
||||
$this->validation = $validation ?: Compiler::_('Field.Validation');
|
||||
$this->db = $db ?: Factory::getDbo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all Field Data
|
||||
*
|
||||
* @param int $id The field ID
|
||||
* @param string|null $singleViewName The view edit or single name
|
||||
* @param string|null $listViewName The view list name
|
||||
*
|
||||
* @return object|null The field data
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(int $id, ?string $singleViewName = null, ?string $listViewName = null): ?object
|
||||
{
|
||||
if ($id > 0 && !isset($this->fields[$id]))
|
||||
{
|
||||
// Create a new query object.
|
||||
$query = $this->db->getQuery(true);
|
||||
|
||||
// Select all the values in the field
|
||||
$query->select('a.*');
|
||||
$query->select(
|
||||
$this->db->quoteName(
|
||||
array('c.name', 'c.properties'),
|
||||
array('type_name', 'properties')
|
||||
)
|
||||
);
|
||||
$query->from('#__componentbuilder_field AS a');
|
||||
$query->join(
|
||||
'LEFT',
|
||||
$this->db->quoteName('#__componentbuilder_fieldtype', 'c')
|
||||
. ' ON (' . $this->db->quoteName('a.fieldtype') . ' = '
|
||||
. $this->db->quoteName('c.id') . ')'
|
||||
);
|
||||
$query->where(
|
||||
$this->db->quoteName('a.id') . ' = ' . $this->db->quote($id)
|
||||
);
|
||||
|
||||
// TODO we need to update the event signatures
|
||||
$context = $this->config->component_context;
|
||||
|
||||
// Trigger Event: jcb_ce_onBeforeQueryFieldData
|
||||
$this->event->trigger(
|
||||
'jcb_ce_onBeforeQueryFieldData',
|
||||
array(&$context, &$id, &$query, &$this->db)
|
||||
);
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
if ($this->db->getNumRows())
|
||||
{
|
||||
// Load the results as a list of stdClass objects (see later for more options on retrieving data).
|
||||
$field = $this->db->loadObject();
|
||||
|
||||
// Trigger Event: jcb_ce_onBeforeModelFieldData
|
||||
$this->event->trigger(
|
||||
'jcb_ce_onBeforeModelFieldData',
|
||||
array(&$context, &$field)
|
||||
);
|
||||
|
||||
// adding a fix for the changed name of type to fieldtype
|
||||
$field->type = $field->fieldtype;
|
||||
|
||||
// load the values form params
|
||||
$field->xml = $this->customcode->update(json_decode($field->xml));
|
||||
|
||||
// check if we have validate (validation rule and set it if found)
|
||||
$this->validation->set($id, $field->xml);
|
||||
|
||||
// load the type values form type params
|
||||
$field->properties = (isset($field->properties)
|
||||
&& JsonHelper::check($field->properties))
|
||||
? json_decode($field->properties, true) : null;
|
||||
if (ArrayHelper::check($field->properties))
|
||||
{
|
||||
$field->properties = array_values($field->properties);
|
||||
}
|
||||
|
||||
// check if we have WHMCS encryption
|
||||
if (4 == $field->store
|
||||
&& !$this->config->whmcs_encryption)
|
||||
{
|
||||
$this->config->whmcs_encryption = true;
|
||||
}
|
||||
// check if we have basic encryption
|
||||
elseif (3 == $field->store
|
||||
&& !$this->config->basic_encryption)
|
||||
{
|
||||
$this->config->basic_encryption = true;
|
||||
}
|
||||
// check if we have better encryption
|
||||
elseif (5 == $field->store
|
||||
&& $this->config->medium_encryption)
|
||||
{
|
||||
$this->config->medium_encryption = true;
|
||||
}
|
||||
// check if we have better encryption
|
||||
elseif (6 == $field->store
|
||||
&& StringHelper::check(
|
||||
$field->on_get_model_field
|
||||
)
|
||||
&& StringHelper::check(
|
||||
$field->on_save_model_field
|
||||
))
|
||||
{
|
||||
// add only if string lenght found
|
||||
if (StringHelper::check(
|
||||
$field->initiator_on_save_model
|
||||
))
|
||||
{
|
||||
$field->initiator_save_key = md5(
|
||||
$field->initiator_on_save_model
|
||||
);
|
||||
$field->initiator_save = explode(
|
||||
PHP_EOL, $this->placeholder->update(
|
||||
$this->customcode->update(
|
||||
base64_decode(
|
||||
$field->initiator_on_save_model
|
||||
)
|
||||
), $this->placeholder->active
|
||||
)
|
||||
);
|
||||
}
|
||||
if (StringHelper::check(
|
||||
$field->initiator_on_save_model
|
||||
))
|
||||
{
|
||||
$field->initiator_get_key = md5(
|
||||
$field->initiator_on_get_model
|
||||
);
|
||||
$field->initiator_get = explode(
|
||||
PHP_EOL, $this->placeholder->update(
|
||||
$this->customcode->update(
|
||||
base64_decode(
|
||||
$field->initiator_on_get_model
|
||||
)
|
||||
), $this->placeholder->active
|
||||
)
|
||||
);
|
||||
}
|
||||
// set the field modeling
|
||||
$field->model_field['save'] = explode(
|
||||
PHP_EOL, $this->placeholder->update(
|
||||
$this->customcode->update(
|
||||
base64_decode($field->on_save_model_field)
|
||||
), $this->placeholder->active
|
||||
)
|
||||
);
|
||||
$field->model_field['get'] = explode(
|
||||
PHP_EOL, $this->placeholder->update(
|
||||
$this->customcode->update(
|
||||
base64_decode($field->on_get_model_field)
|
||||
), $this->placeholder->active
|
||||
)
|
||||
);
|
||||
// remove the original values
|
||||
unset(
|
||||
$field->on_save_model_field,
|
||||
$field->on_get_model_field,
|
||||
$field->initiator_on_save_model,
|
||||
$field->initiator_on_get_model
|
||||
);
|
||||
}
|
||||
|
||||
// get the last used version
|
||||
$field->history = $this->history->get('field', $id);
|
||||
|
||||
// Trigger Event: jcb_ce_onAfterModelFieldData
|
||||
$this->event->trigger(
|
||||
'jcb_ce_onAfterModelFieldData',
|
||||
array(&$context, &$field)
|
||||
);
|
||||
|
||||
$this->fields[$id] = $field;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($id > 0 && isset($this->fields[$id]))
|
||||
{
|
||||
// update the customcode of the field
|
||||
$this->fieldCustomcode->update($id, $this->fields[$id], $singleViewName, $listViewName);
|
||||
|
||||
// return the field
|
||||
return $this->fields[$id];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Field;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Field Database Name
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class DatabaseName
|
||||
{
|
||||
/**
|
||||
* The compiler registry
|
||||
*
|
||||
* @var Registry
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Registry $registry;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Registry|null $config The compiler registry object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Registry $registry = null)
|
||||
{
|
||||
$this->registry = $registry ?: Compiler::_('Registry');
|
||||
}
|
||||
|
||||
/**
|
||||
* get the field database name and AS prefix
|
||||
*
|
||||
* @param string $nameListCode The list view name
|
||||
* @param int $fieldId The field ID
|
||||
* @param string $targetArea The area being targeted
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(string $nameListCode, int $fieldId, string $targetArea = 'builder.list'): ?string
|
||||
{
|
||||
if (($fields = $this->registry->get("${targetArea}.${nameListCode}")) !== null)
|
||||
{
|
||||
if ($fieldId < 0)
|
||||
{
|
||||
switch ($fieldId)
|
||||
{
|
||||
case -1:
|
||||
return 'a.id';
|
||||
case -2:
|
||||
return 'a.ordering';
|
||||
case -3:
|
||||
return 'a.published';
|
||||
}
|
||||
}
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
if ($field['id'] == $fieldId)
|
||||
{
|
||||
// now check if this is a category
|
||||
if ($field['type'] === 'category')
|
||||
{
|
||||
return 'c.title';
|
||||
}
|
||||
// set the custom code
|
||||
elseif (ArrayHelper::check(
|
||||
$field['custom']
|
||||
))
|
||||
{
|
||||
return $field['custom']['db'] . "."
|
||||
. $field['custom']['text'];
|
||||
}
|
||||
else
|
||||
{
|
||||
return 'a.' . $field['code'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Field\JoomlaThree;
|
||||
|
||||
|
||||
use Joomla\CMS\Filesystem\Folder;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreValidationInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Core Joomla Field Validation Rules
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class CoreValidation implements CoreValidationInterface
|
||||
{
|
||||
/**
|
||||
* Local Core Joomla Rules
|
||||
*
|
||||
* @var array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected ?array $rules = null;
|
||||
|
||||
/**
|
||||
* Local Core Joomla Rules Path
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected string $path;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// set the path to the form validation rules
|
||||
$this->path = JPATH_LIBRARIES . '/src/Form/Rule';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Array of Existing Validation Rule Names
|
||||
*
|
||||
* @param bool $lowercase Switch to set rules lowercase
|
||||
*
|
||||
* @return array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(bool $lowercase = false): array
|
||||
{
|
||||
if (!$this->rules)
|
||||
{
|
||||
// check if the path exist
|
||||
if (!Folder::exists($this->path))
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
// we must first store the current working directory
|
||||
$joomla = getcwd();
|
||||
|
||||
// go to that folder
|
||||
chdir($this->path);
|
||||
|
||||
// load all the files in this path
|
||||
$rules = Folder::files('.', '\.php', true, true);
|
||||
|
||||
// change back to Joomla working directory
|
||||
chdir($joomla);
|
||||
|
||||
// make sure we have an array
|
||||
if (!ArrayHelper::check($rules))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// remove the Rule.php from the name
|
||||
$this->rules = array_map( function ($name) {
|
||||
return str_replace(array('./','Rule.php'), '', $name);
|
||||
}, $rules);
|
||||
}
|
||||
|
||||
// return rules if found
|
||||
if (is_array($this->rules))
|
||||
{
|
||||
// check if the names should be all lowercase
|
||||
if ($lowercase)
|
||||
{
|
||||
return array_map( function($item) {
|
||||
return strtolower($item);
|
||||
}, $this->rules);
|
||||
}
|
||||
return $this->rules;
|
||||
}
|
||||
|
||||
// return empty array
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,234 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Field;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\String\TypeHelper;
|
||||
use VDM\Joomla\Utilities\String\FieldHelper;
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Field\UniqueName;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Field Name
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Name
|
||||
{
|
||||
/**
|
||||
* The compiler registry
|
||||
*
|
||||
* @var Registry
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Registry $registry;
|
||||
|
||||
/**
|
||||
* Unique Field Names
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $unique;
|
||||
|
||||
/**
|
||||
* Compiler Placeholder
|
||||
*
|
||||
* @var Placeholder
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Placeholder $placeholder;
|
||||
|
||||
/**
|
||||
* Compiler Field Unique Name
|
||||
*
|
||||
* @var UniqueName
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected UniqueName $uniqueName;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Placeholder|null $placeholder The compiler component placeholder object.
|
||||
* @param UniqueName|null $uniqueName The compiler field unique name object.
|
||||
* @param Registry|null $registry The compiler registry object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Placeholder $placeholder = null, ?UniqueName $uniqueName = null, ?Registry $registry = null)
|
||||
{
|
||||
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
|
||||
$this->uniqueName = $uniqueName ?: Compiler::_('Field.Unique.Name');
|
||||
$this->registry = $registry ?: Compiler::_('Registry');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the field's actual name
|
||||
*
|
||||
* @param array $field The field array
|
||||
* @param string|null $listViewName The list view name
|
||||
* @param string $amicably The peaceful resolve (for fields in subforms in same view :)
|
||||
*
|
||||
* @return string Success returns field name
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(array &$field, ?string $listViewName = null, string $amicably = ''): string
|
||||
{
|
||||
// return the unique name if already set
|
||||
if ($listViewName && StringHelper::check($listViewName)
|
||||
&& isset($field['hash'])
|
||||
&& isset(
|
||||
$this->unique[$listViewName . $amicably . $field['hash']]
|
||||
))
|
||||
{
|
||||
return $this->unique[$listViewName . $amicably . $field['hash']];
|
||||
}
|
||||
|
||||
// always make sure we have a field name and type
|
||||
if (!isset($field['settings']) || !isset($field['settings']->type_name)
|
||||
|| !isset($field['settings']->name))
|
||||
{
|
||||
return 'error';
|
||||
}
|
||||
|
||||
// set the type name
|
||||
$type_name = TypeHelper::safe(
|
||||
$field['settings']->type_name
|
||||
);
|
||||
|
||||
// set the name of the field
|
||||
$name = FieldHelper::safe($field['settings']->name);
|
||||
|
||||
// check that we have the properties
|
||||
if (ArrayHelper::check($field['settings']->properties))
|
||||
{
|
||||
foreach ($field['settings']->properties as $property)
|
||||
{
|
||||
if ($property['name'] === 'name')
|
||||
{
|
||||
// if category then name must be catid (only one per view)
|
||||
if ($type_name === 'category')
|
||||
{
|
||||
// quick check if this is a category linked to view page
|
||||
$requeSt_id = GetHelper::between(
|
||||
$field['settings']->xml, 'name="', '"'
|
||||
);
|
||||
if (strpos($requeSt_id, '_request_id') !== false
|
||||
|| strpos($requeSt_id, '_request_catid') !== false)
|
||||
{
|
||||
// keep it then, don't change
|
||||
$name = $this->placeholder->update(
|
||||
$requeSt_id, $this->placeholder->active
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$name = 'catid';
|
||||
}
|
||||
|
||||
// if list view name is set
|
||||
if (StringHelper::check($listViewName))
|
||||
{
|
||||
// check if we should use another Text Name as this views name
|
||||
$otherName = $this->placeholder->update(
|
||||
GetHelper::between(
|
||||
$field['settings']->xml, 'othername="', '"'
|
||||
), $this->placeholder->active
|
||||
);
|
||||
$otherViews = $this->placeholder->update(
|
||||
GetHelper::between(
|
||||
$field['settings']->xml, 'views="', '"'
|
||||
), $this->placeholder->active
|
||||
);
|
||||
$otherView = $this->placeholder->update(
|
||||
GetHelper::between(
|
||||
$field['settings']->xml, 'view="', '"'
|
||||
), $this->placeholder->active
|
||||
);
|
||||
// This is to link other view category
|
||||
if (StringHelper::check($otherName)
|
||||
&& StringHelper::check(
|
||||
$otherViews
|
||||
) && StringHelper::check(
|
||||
$otherView
|
||||
))
|
||||
{
|
||||
// set other category details
|
||||
$this->registry->set("category.other.name.${listViewName}", [
|
||||
'name' => FieldHelper::safe(
|
||||
$otherName
|
||||
),
|
||||
'views' => StringHelper::safe(
|
||||
$otherViews
|
||||
),
|
||||
'view' => StringHelper::safe(
|
||||
$otherView
|
||||
)
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if tag is set then enable all tag options for this view (only one per view)
|
||||
elseif ($type_name === 'tag')
|
||||
{
|
||||
$name = 'tags';
|
||||
}
|
||||
// if the field is set as alias it must be called alias
|
||||
elseif (isset($field['alias']) && $field['alias'])
|
||||
{
|
||||
$name = 'alias';
|
||||
}
|
||||
else
|
||||
{
|
||||
// get value from xml
|
||||
$xml = FieldHelper::safe(
|
||||
$this->placeholder->update(
|
||||
GetHelper::between(
|
||||
$field['settings']->xml, 'name="', '"'
|
||||
), $this->placeholder->active
|
||||
)
|
||||
);
|
||||
// check if a value was found
|
||||
if (StringHelper::check($xml))
|
||||
{
|
||||
$name = $xml;
|
||||
}
|
||||
}
|
||||
// exit foreach loop
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return the value unique
|
||||
if (StringHelper::check($listViewName) && isset($field['hash']))
|
||||
{
|
||||
$this->unique[$listViewName . $amicably . $field['hash']]
|
||||
= $this->uniqueName->get($name, $listViewName . $amicably);
|
||||
|
||||
// now return the unique name
|
||||
return $this->unique[$listViewName . $amicably . $field['hash']];
|
||||
}
|
||||
|
||||
// fall back to global
|
||||
return $name;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Field;
|
||||
|
||||
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\ObjectHelper;
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Utilities\String\TypeHelper;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Field Type Name
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class TypeName
|
||||
{
|
||||
/**
|
||||
* Get the field's actual type
|
||||
*
|
||||
* @param object $field The field object
|
||||
*
|
||||
* @return string Success returns field type
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(&$field)
|
||||
{
|
||||
// check if we have done this already
|
||||
if (isset($field['type_name']))
|
||||
{
|
||||
return $field['type_name'];
|
||||
}
|
||||
|
||||
// check that we have the properties
|
||||
if (isset($field['settings'])
|
||||
&& ObjectHelper::check(
|
||||
$field['settings']
|
||||
)
|
||||
&& isset($field['settings']->properties)
|
||||
&& ArrayHelper::check(
|
||||
$field['settings']->properties
|
||||
))
|
||||
{
|
||||
// search for own custom fields
|
||||
if (strpos($field['settings']->type_name, '@') !== false)
|
||||
{
|
||||
// set own custom field
|
||||
$field['settings']->own_custom = $field['settings']->type_name;
|
||||
$field['settings']->type_name = 'Custom';
|
||||
}
|
||||
|
||||
// set the type name
|
||||
$type_name = TypeHelper::safe(
|
||||
$field['settings']->type_name
|
||||
);
|
||||
|
||||
// if custom (we must use the xml value)
|
||||
if (strtolower($type_name) === 'custom'
|
||||
|| strtolower($type_name) === 'customuser')
|
||||
{
|
||||
$type = TypeHelper::safe(
|
||||
GetHelper::between(
|
||||
$field['settings']->xml, 'type="', '"'
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// loop over properties looking for the type value
|
||||
foreach ($field['settings']->properties as $property)
|
||||
{
|
||||
if ($property['name']
|
||||
=== 'type') // type field is never adjustable (unless custom)
|
||||
{
|
||||
// force the default value
|
||||
if (isset($property['example'])
|
||||
&& StringHelper::check(
|
||||
$property['example']
|
||||
))
|
||||
{
|
||||
$type = TypeHelper::safe(
|
||||
$property['example']
|
||||
);
|
||||
}
|
||||
// fall back on the xml settings (not ideal)
|
||||
else
|
||||
{
|
||||
$type = TypeHelper::safe(
|
||||
GetHelper::between(
|
||||
$field['settings']->xml, 'type="', '"'
|
||||
)
|
||||
);
|
||||
}
|
||||
// exit foreach loop
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// check if the value is set
|
||||
if (isset($type) && StringHelper::check($type))
|
||||
{
|
||||
return $type;
|
||||
}
|
||||
// fallback on type name set in name field (not ideal)
|
||||
else
|
||||
{
|
||||
return $type_name;
|
||||
}
|
||||
}
|
||||
|
||||
// fall back to text
|
||||
return 'text';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Field;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Utilities\String\FieldHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Field Unique Name
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class UniqueName
|
||||
{
|
||||
/**
|
||||
* The compiler registry
|
||||
*
|
||||
* @var Registry
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Registry $registry;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Registry|null $registry The compiler registry object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Registry $registry = null)
|
||||
{
|
||||
$this->registry = $registry ?: Compiler::_('Registry');
|
||||
}
|
||||
|
||||
/**
|
||||
* Count how many times the same field is used per view
|
||||
*
|
||||
* @param string $name The name of the field
|
||||
* @param string $view The name of the view
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function set(string $name, string $view)
|
||||
{
|
||||
if (($number = $this->registry->get("unique.names.${view}.counter.${name}")) === null)
|
||||
{
|
||||
$this->registry->set("unique.names.${view}.counter.${name}", 1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// count how many times the field is used
|
||||
$this->registry->set("unique.names.${view}.counter.${name}", ++$number);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Naming each field with an unique name
|
||||
*
|
||||
* @param string $name The name of the field
|
||||
* @param string $view The name of the view
|
||||
*
|
||||
* @return string the name
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(string $name, string $view): string
|
||||
{
|
||||
// only increment if the field name is used multiple times
|
||||
if ($this->registry->get("unique.names.${view}.counter.${name}") > 1)
|
||||
{
|
||||
$counter = 1;
|
||||
// set the unique name
|
||||
$unique_name = FieldHelper::safe(
|
||||
$name . '_' . $counter
|
||||
);
|
||||
|
||||
while ($this->registry->get("unique.names.${view}.names.${unique_name}") !== null)
|
||||
{
|
||||
// increment the number
|
||||
$counter++;
|
||||
// try again
|
||||
$unique_name = FieldHelper::safe(
|
||||
$name . '_' . $counter
|
||||
);
|
||||
}
|
||||
|
||||
// set the new name number
|
||||
$this->registry->set("unique.names.${view}.names.${unique_name}", $counter);
|
||||
|
||||
// return the unique name
|
||||
return $unique_name;
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,168 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Field;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Registry;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field\CoreValidationInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Field Validation Rules
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Validation
|
||||
{
|
||||
/**
|
||||
* Compiler registry
|
||||
*
|
||||
* @var Registry
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Registry $registry;
|
||||
|
||||
/**
|
||||
* Compiler Gui
|
||||
*
|
||||
* @var Gui
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Gui $gui;
|
||||
|
||||
/**
|
||||
* Compiler Placeholder
|
||||
*
|
||||
* @var Placeholder
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Placeholder $placeholder;
|
||||
|
||||
/**
|
||||
* Compiler Customcode
|
||||
*
|
||||
* @var Customcode
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Customcode $customcode;
|
||||
|
||||
/**
|
||||
* Compiler Field Core Validation
|
||||
*
|
||||
* @var CoreValidationInterface
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected CoreValidationInterface $validation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Registry|null $registry The compiler registry object.
|
||||
* @param Gui|null $gui The compiler customcode gui object.
|
||||
* @param Placeholder|null $placeholder The compiler placeholder object.
|
||||
* @param Customcode|null $customcode The compiler customcode object.
|
||||
* @param CoreValidationInterface|null $validation The core validation rule object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Registry $registry = null, ?Gui $gui = null, ?Placeholder $placeholder = null,
|
||||
?Customcode $customcode = null, ?CoreValidationInterface $validation = null)
|
||||
{
|
||||
$this->registry = $registry ?: Compiler::_('Registry');
|
||||
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
|
||||
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
|
||||
$this->customcode = $customcode ?: Compiler::_('Customcode');
|
||||
$this->validation = $validation ?: Compiler::_('Field.Core.Validation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the validation rule
|
||||
*
|
||||
* @param int $id The field id
|
||||
* @param string $field The field string
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function set(int $id, string $field)
|
||||
{
|
||||
// check if we have validate (validation rule set)
|
||||
$validation_rule = GetHelper::between(
|
||||
$field, 'validate="', '"'
|
||||
);
|
||||
|
||||
if (StringHelper::check($validation_rule))
|
||||
{
|
||||
// make sure it is lowercase
|
||||
$validation_rule = StringHelper::safe(
|
||||
$validation_rule
|
||||
);
|
||||
|
||||
// link this field to this validation (don't move this down)
|
||||
$this->registry->set("validation.linked.${id}", $validation_rule);
|
||||
|
||||
// make sure it is not already set
|
||||
if ($this->registry->get("validation.rules.${validation_rule}") === null)
|
||||
{
|
||||
// get joomla core validation names and make sure this rule is not a core validation rule
|
||||
if (!in_array($validation_rule, (array) $this->validation->get(true)))
|
||||
{
|
||||
// get the class methods for this rule if it exists
|
||||
if (($php_code = GetHelper::var(
|
||||
'validation_rule', $validation_rule, 'name', 'php'
|
||||
)) !== false)
|
||||
{
|
||||
// open and set the validation rule
|
||||
$this->registry->set("validation.rules.${validation_rule}",
|
||||
$this->gui->set(
|
||||
$this->placeholder->update(
|
||||
$this->customcode->update(
|
||||
base64_decode(
|
||||
$php_code
|
||||
)
|
||||
), $this->placeholder->active
|
||||
),
|
||||
array(
|
||||
'table' => 'validation_rule',
|
||||
'field' => 'php',
|
||||
'id' => GetHelper::var(
|
||||
'validation_rule',
|
||||
$validation_rule, 'name', 'id'
|
||||
),
|
||||
'type' => 'php'
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO set the notice that this validation rule is custom and was not found
|
||||
$this->registry->remove("validation.linked.${id}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// remove link (we only want custom validations linked)
|
||||
$this->registry->remove("validation.linked.${id}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Component;
|
||||
|
||||
|
||||
/**
|
||||
* Component Placeholder Interface
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
interface PlaceholderInterface
|
||||
{
|
||||
/**
|
||||
* get all System Placeholders
|
||||
*
|
||||
* @return array The global placeholders
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(): array;
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode;
|
||||
|
||||
|
||||
/**
|
||||
* Customcode Dispenser Interface
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
interface DispenserInterface
|
||||
{
|
||||
/**
|
||||
* Set the script for the customcode dispenser
|
||||
*
|
||||
* @param string $script The script
|
||||
* @param string $first The first key
|
||||
* @param string|null $second The second key (if not set we use only first key)
|
||||
* @param string|null $third The third key (if not set we use only first and second key)
|
||||
* @param array $config The config options
|
||||
* @param bool $base64 The switch to decode base64 the script
|
||||
* default: true
|
||||
* @param bool $dynamic The switch to dynamic update the script
|
||||
* default: true
|
||||
* @param bool $add The switch to add to exiting instead of replace
|
||||
* default: false
|
||||
*
|
||||
* @return bool true on success
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function set(&$script, string $first, ?string $second = null, ?string $third = null,
|
||||
array $config = array(), bool $base64 = true, bool $dynamic = true, bool $add = false): bool;
|
||||
|
||||
/**
|
||||
* Get the script from the customcode dispenser
|
||||
*
|
||||
* @param string $first The first key
|
||||
* @param string $second The second key
|
||||
* @param string $prefix The prefix to add in front of the script if found
|
||||
* @param string|null $note The switch/note to add to the script
|
||||
* @param bool $unset The switch to unset the value if found
|
||||
* @param mixed|null $default The switch/string to use as default return if script not found
|
||||
* @param string $suffix The suffix to add after the script if found
|
||||
*
|
||||
* @return mixed The string/script if found or the default value if not found
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(string $first, string $second, string $prefix = '', ?string $note = null,
|
||||
bool $unset = false, $default = null, string $suffix = '');
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode;
|
||||
|
||||
|
||||
/**
|
||||
* Customcode External Interface
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
interface ExternalInterface
|
||||
{
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode;
|
||||
|
||||
|
||||
/**
|
||||
* Customcode Extractor Interface
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
interface ExtractorInterface
|
||||
{
|
||||
/**
|
||||
* get the custom code from the local files
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function run();
|
||||
}
|
||||
|
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode;
|
||||
|
||||
|
||||
/**
|
||||
* Customcode Gui Interface
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
interface GuiInterface
|
||||
{
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode;
|
||||
|
||||
|
||||
/**
|
||||
* Customcode LockBase Interface
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
interface LockBaseInterface
|
||||
{
|
||||
/**
|
||||
* Set a string as bsae64 (basic)
|
||||
*
|
||||
* @param string $script The code string
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function set(string $script): string;
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Customcode Interface
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
interface CustomcodeInterface
|
||||
{
|
||||
/**
|
||||
* Update **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 update(string $string, int $debug = 0): string;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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 get(?array $ids = null, bool $setLang = true, $debug = 0): bool;
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Events Interface
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
interface EventInterface
|
||||
{
|
||||
/**
|
||||
* Trigger an event
|
||||
*
|
||||
* @param string $event The event to trigger
|
||||
* @param mixed $data The values to pass to the event/plugin
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function trigger(string $event, $data);
|
||||
}
|
||||
|
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Extension;
|
||||
|
||||
|
||||
/**
|
||||
* The properties an extension should have to be passed to the InstallScript class
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Field;
|
||||
|
||||
|
||||
/**
|
||||
* Field Joomla Core Validation Interface
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
interface CoreValidationInterface
|
||||
{
|
||||
/**
|
||||
* Get the Array of Existing Validation Rule Names
|
||||
*
|
||||
* @param bool $lowercase Switch to set rules lowercase
|
||||
*
|
||||
* @return array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(bool $lowercase = false): array;
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces;
|
||||
|
||||
|
||||
/**
|
||||
* The functions a get script should have
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
interface GetScriptInterface
|
||||
{
|
||||
/**
|
||||
* get code to use
|
||||
*
|
||||
* @param Object $code The code object
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(object $extension): string;
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler History Interface
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
interface HistoryInterface
|
||||
{
|
||||
/**
|
||||
* Get Item History object
|
||||
*
|
||||
* @param string $type The type of item
|
||||
* @param int $id The item ID
|
||||
*
|
||||
* @return ?object The history item object
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(string $type, int $id): ?object;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Language Interface
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
interface LanguageInterface
|
||||
{
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Placeholder Interface
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
interface PlaceholderInterface
|
||||
{
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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 with start and end keys
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function keys(int $type, ?int $id = null): array;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Power Interface
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
interface PowerInterface
|
||||
{
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\JoomlaThree;
|
||||
|
||||
|
||||
use Joomla\Registry\Registry;
|
||||
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 mixed $data The values to pass to the event/plugin
|
||||
*
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function trigger(string $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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,232 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\JoomlaThree;
|
||||
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\HistoryInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler History
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class History implements HistoryInterface
|
||||
{
|
||||
/**
|
||||
* History Item Object
|
||||
*
|
||||
* @var object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected ?object $tmp;
|
||||
|
||||
/**
|
||||
* Compiler Config
|
||||
*
|
||||
* @var Config
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* Database object to query local DB
|
||||
*
|
||||
* @var \JDatabaseDriver
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected \JDatabaseDriver $db;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Config|null $config The compiler config object.
|
||||
* @param \JDatabaseDriver|null $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 Item History object
|
||||
*
|
||||
* @param string $type The type of item
|
||||
* @param int $id The item ID
|
||||
*
|
||||
* @return ?object The history
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(string $type, int $id): ?object
|
||||
{
|
||||
// quick class object to store old history object
|
||||
$this->tmp = null;
|
||||
// Create a new query object.
|
||||
$query = $this->db->getQuery(true);
|
||||
|
||||
$query->select('h.*');
|
||||
$query->from('#__ucm_history AS h');
|
||||
$query->where(
|
||||
$this->db->quoteName('h.ucm_item_id') . ' = ' . (int) $id
|
||||
);
|
||||
// Join over the content type for the type id
|
||||
$query->join(
|
||||
'LEFT', '#__content_types AS ct ON ct.type_id = h.ucm_type_id'
|
||||
);
|
||||
$query->where(
|
||||
'ct.type_alias = ' . $this->db->quote(
|
||||
'com_componentbuilder.' . $type
|
||||
)
|
||||
);
|
||||
$query->order('h.save_date DESC');
|
||||
$this->db->setQuery($query, 0, 1);
|
||||
$this->db->execute();
|
||||
if ($this->db->getNumRows())
|
||||
{
|
||||
// new version of this item found
|
||||
// so we need to mark it as the last compiled version
|
||||
$newActive = $this->db->loadObject();
|
||||
// set the new version watch
|
||||
$this->set($newActive, 1);
|
||||
}
|
||||
// Get last compiled verion
|
||||
$query = $this->db->getQuery(true);
|
||||
|
||||
$query->select('h.*');
|
||||
$query->from('#__ucm_history AS h');
|
||||
$query->where(
|
||||
$this->db->quoteName('h.ucm_item_id') . ' = ' . (int) $id
|
||||
);
|
||||
$query->where('h.keep_forever = 1');
|
||||
$query->where('h.version_note LIKE ' . $this->db->quote('%component%'));
|
||||
// make sure it does not return the active version
|
||||
if (isset($newActive) && isset($newActive->version_id))
|
||||
{
|
||||
$query->where('h.version_id != ' . (int) $newActive->version_id);
|
||||
}
|
||||
// Join over the content type for the type id
|
||||
$query->join(
|
||||
'LEFT', '#__content_types AS ct ON ct.type_id = h.ucm_type_id'
|
||||
);
|
||||
$query->where(
|
||||
'ct.type_alias = ' . $this->db->quote(
|
||||
'com_componentbuilder.' . $type
|
||||
)
|
||||
);
|
||||
$query->order('h.save_date DESC');
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
if ($this->db->getNumRows())
|
||||
{
|
||||
// the old active version was found
|
||||
// so we may need to do an SQL update
|
||||
// and unmark the old compiled version
|
||||
$oldActives = $this->db->loadObjectList();
|
||||
foreach ($oldActives as $oldActive)
|
||||
{
|
||||
// remove old version watch
|
||||
$this->set($oldActive, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// return the last used history record or null.
|
||||
return $this->tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Item History Watch
|
||||
*
|
||||
* @param Object $object The history object
|
||||
* @param int $action The action to take
|
||||
* 0 = remove watch
|
||||
* 1 = add watch
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function set(object $object, int $action): bool
|
||||
{
|
||||
// check the note
|
||||
if (JsonHelper::check($object->version_note))
|
||||
{
|
||||
$version_note = json_decode($object->version_note, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$version_note = array('component' => array());
|
||||
}
|
||||
// set watch
|
||||
switch ($action)
|
||||
{
|
||||
case 0:
|
||||
// remove watch
|
||||
if (isset($version_note['component'])
|
||||
&& ($key = array_search(
|
||||
$this->config->component_id, $version_note['component']
|
||||
)) !== false)
|
||||
{
|
||||
// last version that was used to build/compile
|
||||
$this->tmp = json_decode($object->version_data);
|
||||
// remove it from this component
|
||||
unset($version_note['component'][$key]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// since it was not found, no need to update anything
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
// add watch
|
||||
if (!in_array($this->config->component_id, $version_note['component']))
|
||||
{
|
||||
$version_note['component'][] = $this->config->component_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
// since it is there already, no need to update anything
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// check if we need to still keep this locked
|
||||
if (isset($version_note['component'])
|
||||
&& ArrayHelper::check($version_note['component']))
|
||||
{
|
||||
// insure component ids are only added once per item
|
||||
$version_note['component'] = array_unique(
|
||||
$version_note['component']
|
||||
);
|
||||
// we may change this, little risky (but since JCB does not have history notes it should be okay for now)
|
||||
$object->version_note = json_encode($version_note);
|
||||
$object->keep_forever = '1';
|
||||
}
|
||||
else
|
||||
{
|
||||
$object->version_note = '';
|
||||
$object->keep_forever = '0';
|
||||
}
|
||||
|
||||
// run the update
|
||||
return $this->db->updateObject('#__ucm_history', $object, 'version_id');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,202 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler;
|
||||
|
||||
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\LanguageInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Language Content
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Language implements LanguageInterface
|
||||
{
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user