Permalink
Browse files

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.
  • Loading branch information...
Llewellynvdm committed Nov 27, 2018
1 parent 180f1ce commit a52d230aebaed859ce966598a3cdfe410f4cca61
@@ -133,13 +133,13 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 8th November, 2018
+ *Last Build*: 27th November, 2018
+ *Version*: 2.9.7
+ *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **195853**
+ *Line count*: **195519**
+ *Field count*: **1087**
+ *File count*: **1277**
+ *File count*: **1275**
+ *Folder count*: **201**
> This **component** was build with a Joomla [Automated Component Builder](http://joomlacomponentbuilder.com).
@@ -133,13 +133,13 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 8th November, 2018
+ *Last Build*: 27th November, 2018
+ *Version*: 2.9.7
+ *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **195853**
+ *Line count*: **195519**
+ *Field count*: **1087**
+ *File count*: **1277**
+ *File count*: **1275**
+ *Folder count*: **201**
> This **component** was build with a Joomla [Automated Component Builder](http://joomlacomponentbuilder.com).

This file was deleted.

Oops, something went wrong.
@@ -4781,7 +4781,7 @@ protected function getExternalCodeString($target, &$bucket)
* @return string
*
*/
public function setCustomCodeData($string, $debug = 0)
public function setCustomCodeData($string, $debug = 0, $not = null)
{
// insure the code is loaded
$loaded = false;
@@ -4880,6 +4880,11 @@ public function setCustomCodeData($string, $debug = 0)
{
continue;
}
// make sure to remove the not if set
if ($not && is_numeric($not) && $not > 0 && $not == $id)
{
continue;
}
$bucket[$id] = $id;
}
}
@@ -4896,7 +4901,7 @@ public function setCustomCodeData($string, $debug = 0)
// insure we add the langs to both site and admin
$this->lang = 'both';
// now load the code to memory
$loaded = $this->getCustomCode($bucket, false);
$loaded = $this->getCustomCode($bucket, false, $debug);
// revert lang to current setting
$this->lang = $_tmpLang;
}
@@ -4939,6 +4944,7 @@ protected function insertCustomCode($string, $debug = 0)
echo '$this->customCode:';
var_dump($this->customCode);
}
// load the code
foreach ($this->customCode as $item)
{
$this->buildCustomCodePlaceholders($item, $code, $debug);
@@ -5418,7 +5424,7 @@ protected function setUpdateExistingLangStrings($id, $components, $published, $t
* @return void
*
*/
public function getCustomCode($ids = null, $setLang = true)
public function getCustomCode($ids = null, $setLang = true, $debug = 0)
{
// should the result be stored in memory
$loadInMemory = false;
@@ -5427,7 +5433,7 @@ public function getCustomCode($ids = null, $setLang = true)
$query->from($this->db->quoteName('#__componentbuilder_custom_code', 'a'));
if (ComponentbuilderHelper::checkArray($ids))
{
if ($idArray = $this->customCodeMemory($ids))
if ($idArray = $this->checkCustomCodeMemory($ids))
{
$query->select($this->db->quoteName(array('a.id', 'a.code', 'a.comment_type')));
$query->where($this->db->quoteName('a.id') . ' IN (' . implode(',', $idArray) . ')');
@@ -5466,6 +5472,11 @@ public function getCustomCode($ids = null, $setLang = true)
{
$customCode['code'] = $this->setLangStrings($customCode['code']);
}
// check for more custom code (since this is a custom code placeholder)
else
{
$customCode['code'] = $this->setCustomCodeData($customCode['code'], $debug, $nr);
}
if (isset($customCode['hashtarget']))
{
$customCode['hashtarget'] = explode("__", $customCode['hashtarget']);
@@ -5492,7 +5503,7 @@ public function getCustomCode($ids = null, $setLang = true)
* @return void
*
*/
protected function customCodeMemory($ids)
protected function checkCustomCodeMemory($ids)
{
// reset custom code
$this->customCode = array();
@@ -3710,6 +3710,7 @@ COM_COMPONENTBUILDER_CUSTOM_CODE_NOTE_PLACEHOLDERS_EXPLAINED_DESCRIPTION="<div c
<div id='usedin-j' style='display:none;'><h2>Templates</h2><div id='area-j'></div></div>
<div id='usedin-k' style='display:none;'><h2>Layouts</h2><div id='area-k'></div></div>
<div id='usedin-l' style='display:none;'><h2>Libraries</h2><div id='area-l'></div></div>
<div id='usedin-m' style='display:none;'><h2>Custom Code</h2><div id='area-m'></div></div>
<div id='loading-usedin' style='display: none;'><h2>Scanning Database<span class='loading-dots'>..</span></h2></div>
<div id='note-usedin-found' style='display: none;'><small>You can edit the above areas where this code is used.</small></div>
<div id='note-usedin-not' style='display: none;'><small>This code is not used in any area of the JCB custom code blocks at this time.</small></div>
@@ -4698,6 +4699,8 @@ 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_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_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!"
@@ -5993,6 +5996,8 @@ COM_COMPONENTBUILDER_PAIDLOCKED="Paid/Locked"
COM_COMPONENTBUILDER_PATH_CODESCODE="Path: <code>%s</code>"
COM_COMPONENTBUILDER_PATH_TO_THE_ZIPPED_PACKAGE_IS_CODESCODE_BR_S_S="Path to the zipped package is: <code>%s</code> <br />%s %s"
COM_COMPONENTBUILDER_PERMISSIONS="Permissions"
COM_COMPONENTBUILDER_PLACEHOLDERS_REMOVED="Placeholders Removed!"
COM_COMPONENTBUILDER_PLACEHOLDER_REMOVED="Placeholder Removed!"
COM_COMPONENTBUILDER_PLACES_ACROSS_JCB_WHERE_THIS_S_IS_LINKED="Places across JCB where this %s is linked."
COM_COMPONENTBUILDER_PLEASE_ADD_FILES_TO_S="Please add files to (%s)"
COM_COMPONENTBUILDER_PLEASE_ADD_FOLDERS_TO_S="Please add folders to (%s)"
@@ -7058,8 +7063,8 @@ COM_COMPONENTBUILDER_THE_SEARCH_FOR_THE_SNIPPETS_ARE_CASE_SENSITIVE_SO_IF_YOU_CH
COM_COMPONENTBUILDER_THE_SERVER_DETAILS_FOR_BID_SB_COULD_NOT_BE_RETRIEVED="The server details for <b>(ID: %s)</b> could not be retrieved!"
COM_COMPONENTBUILDER_THE_SNIPPETS_WERE_SUCCESSFULLY_EXPORTED="The Snippets Were Successfully Exported!"
COM_COMPONENTBUILDER_THE_SNIPPET_WAS_SUCCESSFULLY_EXPORTED="The Snippet Was Successfully Exported!"
COM_COMPONENTBUILDER_THE_TEXT_IS_LOADING="The text is loading"
COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DOES_NOT_EXIST="The url (%s) set to retrieve the packages does not exist!"
COM_COMPONENTBUILDER_THE_WIKI_IS_LOADING="The wiki is loading"
COM_COMPONENTBUILDER_THIS_BSB_IS_NOT_LINKED_TO_ANY_OTHER_AREAS_OF_JCB_AT_THIS_TIME="This <b>%s</b> is not linked to any other areas of JCB at this time!"
COM_COMPONENTBUILDER_THIS_PACKAGE_BPASSEDB_THE_CHECKSUM_VALIDATIONBR_BR_SMALLMANUALLY_ALSO_VALIDATE_THAT_THE_CORRECT_CHECKSUM_WAS_USEDSMALLBR_THIS_CHECKSUM_BSB_MUST_BE_THE_SAME_AS_THE_ONE_FOUND_A_S_SA="This package <b>PASSED</b> the checksum validation!<br /><br /><small>Manually also validate that the correct checksum was used.</small><br />This checksum: <b>%s</b> must be the same as the one found @ <a %s %s</a>"
COM_COMPONENTBUILDER_THIS_PACKAGE_HAS_NO_KEY="This package has no key."
@@ -2276,6 +2276,13 @@ protected function searchOpenBase64(&$value, &$target)
'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'
)
);
@@ -441,8 +441,9 @@ public function getGithub()
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 @@ public function getWiki()
});
});');
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()
{
@@ -825,6 +825,39 @@ public function save($data)
$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']))
{
@@ -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];
@@ -1727,6 +1727,13 @@ protected function searchOpenBase64(&$value, &$target)
'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'
)
);
Oops, something went wrong.

0 comments on commit a52d230

Please sign in to comment.