Improved the custom code area to now allow custom code in custom code with the help of placheholders. Removed the static wiki page, and relinked to the github wiki.

This commit is contained in:
2018-11-27 15:05:47 +02:00
parent 180f1cec6d
commit a52d230aeb
13 changed files with 93 additions and 416 deletions

View File

@ -2276,6 +2276,13 @@ class ComponentbuilderModelAjax extends JModelList
'views' => 'libraries',
'not_base64' => array(),
'name' => 'name'
),
// #__componentbuilder_custom_code (m)
'custom_code' => array(
'search' => array('id', 'system_name', 'code'),
'views' => 'custom_codes',
'not_base64' => array(),
'name' => 'system_name'
)
);

View File

@ -441,8 +441,9 @@ class ComponentbuilderModelComponentbuilder extends JModelList
public function getWiki()
{
JFactory::getDocument()->addScriptDeclaration('
var gewiki = "'. JURI::root() . 'administrator/components/com_componentbuilder/wiki_menu.txt";
$document = JFactory::getDocument();
$document->addScriptDeclaration('
var gewiki = "https://raw.githubusercontent.com/wiki/vdm-io/Joomla-Component-Builder/Home.md";
jQuery(document).ready(function () {
jQuery.get(gewiki)
.success(function(wiki) {
@ -453,9 +454,10 @@ class ComponentbuilderModelComponentbuilder extends JModelList
});
});');
return '<div id="wiki-md"><small>'.JText::_('COM_COMPONENTBUILDER_THE_TEXT_IS_LOADING').'.<span class="loading-dots">.</span></small></div>';
return '<div id="wiki-md"><small>'.JText::_('COM_COMPONENTBUILDER_THE_WIKI_IS_LOADING').'.<span class="loading-dots">.</span></small></div>';
}
public function getNoticeboard()
{

View File

@ -825,6 +825,39 @@ class ComponentbuilderModelCustom_code extends JModelAdmin
$data['metadata'] = (string) $metadata;
}
// few checks with the new option of using custom code in custom code
if (isset($data['code']) && ($placholders = ComponentbuilderHelper::getAllBetween($data['code'], '[CUSTOM' . 'CODE=', ']'))
&& ComponentbuilderHelper::checkArray($placholders))
{
// make sure custom code as Hash (automation) target does not have other custom code placeholders
if (isset($data['target']) && 1 == $data['target'])
{
foreach ($placholders as $placholder)
{
$data['code'] = str_replace('[CUSTOM' . 'CODE=' . $placholder . ']', '', $data['code']);
}
// set title
$title = (count($placholders) == 1) ? JText::_('COM_COMPONENTBUILDER_PLACEHOLDER_REMOVED') : JText::_('COM_COMPONENTBUILDER_PLACEHOLDERS_REMOVED');
// show message that we have had to remove the custom placeholders
JFactory::getApplication()->enqueueMessage(JText::sprintf('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', $title), 'Warning');
}
// make sure that the same custom code is not added to itself
else
{
foreach ($placholders as $placholder)
{
if (strpos($placholder, $data['function_name']) !== false)
{
$data['code'] = str_replace('[CUSTOM' . 'CODE=' . $placholder . ']', '', $data['code']);
// show message that we have had to remove the custom placeholders
JFactory::getApplication()->enqueueMessage(JText::_('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'), 'Warning');
// stop the loop :)
break;
}
}
}
}
// Set the code string to base64 string.
if (isset($data['code']))
{

View File

@ -308,8 +308,8 @@ function usedin(functioName, ide) {
jQuery('#note-usedin-not').hide();
jQuery('#note-usedin-found').hide();
jQuery('#loading-usedin').show();
var targets = ['a','b','c','d','e','f','g','h','i','j','k','l']; // if you update this, also update (below 11) & [customcode-codeUsedInHtmlNote]!
var targetNumber = 11;
var targets = ['a','b','c','d','e','f','g','h','i','j','k','l','m']; // if you update this, also update (below 11) & [customcode-codeUsedInHtmlNote]!
var targetNumber = 12;
var run = 0;
var usedinChecker = setInterval(function(){
var target = targets[run];

View File

@ -1727,6 +1727,13 @@ class ComponentbuilderModelJoomla_components extends JModelList
'views' => 'libraries',
'not_base64' => array(),
'name' => 'name'
),
// #__componentbuilder_custom_code (m)
'custom_code' => array(
'search' => array('id', 'system_name', 'code'),
'views' => 'custom_codes',
'not_base64' => array(),
'name' => 'system_name'
)
);