Update master #1

Merged
root merged 49 commits from joomla/Component-Builder:master into master 2024-02-06 12:33:45 +00:00
25 changed files with 1222 additions and 232 deletions
Showing only changes of commit d4843d6696 - Show all commits

View File

@ -140,13 +140,13 @@ 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*: 6th October, 2022
+ *Last Build*: 20th October, 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*: **331795**
+ *Line count*: **332785**
+ *Field count*: **2004**
+ *File count*: **2172**
+ *File count*: **2173**
+ *Folder count*: **378**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com).

View File

@ -140,13 +140,13 @@ 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*: 6th October, 2022
+ *Last Build*: 20th October, 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*: **331795**
+ *Line count*: **332785**
+ *Field count*: **2004**
+ *File count*: **2172**
+ *File count*: **2173**
+ *Folder count*: **378**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com).

312
admin/assets/js/search.js Normal file
View File

@ -0,0 +1,312 @@
/**
* @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
*/
/* JS Document */
/**
* JS Function to execute the search
*/
const doSearch = async (signal, tables) => {
try {
let searchValue = document.querySelector('input[name="search_value"]').value;
let replaceValue = document.querySelector('input[name="replace_value"]').value;
// Display 'loading' message in search results message div
document.getElementById('search-mssg-box').innerHTML =
'<progress id="search-loading-progressbar" class="uk-progress" value="10" max="100" style="width: 200px; display: inline-block; margin: 0 !important;"></progress>' +
' <div id="search-loading-spinner" style="margin: -4px 12px 0;" uk-spinner="ratio: 0.8"></div>' +
' <span id="search-loading-percent">0%</span> ' +
'Loading for search text: <b style="font-size: 2em;">' + searchValue + '</b>'
;
// Clear results table
let search_loading_percent = document.getElementById('search-loading-percent');
let tbl_obj_body = document.getElementById('search-results-tbl-tbody');
tbl_obj_body.innerHTML = '';
let abort_this_search_value = false;
let total = 0;
let index;
for (index = 0; index < searchTables.length; index++) {
const formData = new FormData();
let tableName = searchTables[index];
formData.append('table_name', '');
formData.append('search_value', searchValue);
formData.append('replace_value', replaceValue);
formData.append('match_case', document.querySelector('input[name="match_case"]').checked ? 1 : 0);
formData.append('whole_word', document.querySelector('input[name="whole_word"]').checked ? 1 : 0);
formData.append('regex_search', document.querySelector('input[name="regex_search"]').checked ? 1 : 0);
formData.append('table_name', tableName);
let url = document.getElementById('adminForm').getAttribute('action') + '&layout=dosearch';
let options = {
signal: signal,
method: 'POST', // *GET, POST, PUT, DELETE, etc.
body: formData
}
if (abort_this_search_value) {
console.log('Aborting this searchValue:' + searchValue);
break;
}
console.log(total + ' -- SEARCHING: ' + searchValue + ' @[' + tableName + ']');
const response = await fetch(url, options)
// Note: response.text() is a promise ...
.then(response => {
total++;
//console.log(total + ' ' + sTables.length);
if (sTables.length == total) setTimeout(function () {
document.getElementById('search-mssg-box').innerHTML = '<div class="alert alert-success" role="alert"><strong>Enter</strong> your text.</div>';
}, 200);
response.text().then(data => {
console.log('++ Fetched for ' + searchValue + ' [' + tableName + ']');
let percent = 100.0 * (total / sTables.length);
search_loading_percent.innerHTML = '' + percent.toFixed(2) + '%';
document.getElementById('search-loading-progressbar').value = percent;
let use_json = false, json_data = false, items = false;
if (use_json) {
try {
json_data = data ? JSON.parse(data) : false;
items = json_data ? json_data.items : false;
} catch (error) {
console.log(error);
}
}
// Very fast and low memory display HTML table row prepared server-side via PHP instead of JS !!
if (!json_data) {
tbl_obj_body.innerHTML = tbl_obj_body.innerHTML + data;
}
// Very slow fast and very high memory: Display HTML table rows by creating them now in browser (client-side) via JS instead of using PHP
if (json_data && items) {
let table_rows = '';
for (const [row_num, row_field_vals] of Object.entries(items)) {
for (const [fname, fvals] of Object.entries(row_field_vals)) {
for (const [line, fval] of Object.entries(fvals)) {
let lnk = 'getFSText(this, \'' + tableName + '\', ' + row_num + ', \'' + fname + '\', line)';
let val = fval;
val = val.replaceAll(marker_start, '<b>');
val = val.replaceAll(marker_end, '</b>');
table_rows = table_rows + '<tr onclick="' + lnk + '; return false" style="cursor: pointer;">' +
'<td>' + val + '</td>' +
'<td>' + tableName + '</td>' +
'<td>' + fname + '</td>' +
'<td>' + row_num + '</td>' +
'<td>' + line + '</td>' +
'</tr>';
}
}
}
tbl_obj_body.innerHTML = tbl_obj_body.innerHTML + table_rows;
} // END IF json_data && items
});
})
.catch(error => {
total++;
if (sTables.length == total) document.getElementById('search-mssg-box').innerHTML = '<div class="alert alert-success" role="alert"><strong>Enter</strong> your text.</div>';
// Stop further searches for this search value
if (error.name === "AbortError") abort_this_search_value = true;
error.name === "AbortError"
? console.log(" ... ABORTED fetch() for: " + searchValue)
: console.log(error.toString());
});
}
} catch (error) {
console.log(error);
} finally {
// Executed regardless if we caught the error
}
};
/**
* JS Function to execute the search
*/
const getFSText = async (el, table_name, row_id, field_name, line) => {
let sibling = el.parentNode.firstElementChild;
do {
sibling != el
? sibling.classList.remove('active')
: sibling.classList.add('active');
} while (sibling = sibling.nextElementSibling);
try {
const formData = new FormData();
formData.append('table_name', table_name);
formData.append('get_full_search_text', 1);
formData.append('row_id', row_id);
formData.append('field_name', field_name);
//let url = `https://jsonplaceholder.typicode.com/posts/${searchValue}`,
let url = document.getElementById('adminForm').getAttribute('action') + '&layout=dosearch';
let options = {
method: 'POST', // *GET, POST, PUT, DELETE, etc.
mode: 'cors', // no-cors, *cors, same-origin
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
credentials: 'same-origin', // include, *same-origin, omit
/*
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json', //'application/x-www-form-urlencoded',
},*/
redirect: 'follow', // manual, *follow, error
referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
// body: JSON.stringify(formData) // body data type must match "Content-Type" header
body: formData
}
// Clear full text box
document.getElementById('match-full-text-box').innerHTML = 'Loading ...';
const response = await fetch(url, options)
// Note: response.text() is a promise ...
.then(response => {
response.text().then(data => {
console.log("Fetched full text for row: " + row_id + ' field name: ' + field_name + ' for Table: ' + table_name);
document.getElementById('match-full-text-box').innerHTML = '<div id="match-full-text-header">'
+ table_name + ' @ ' + field_name + ': ' + row_id + '</div><textarea id="match-full-text">' + data + '</textarea>';
document.getElementById('match-full-text-box').style.display = '';
attachCodeMirror(jQuery('#match-full-text'), null);
cm_toggle_fully_searchable('match-full-text', 1);
cm_jumpToLine('match-full-text', line);
//cm_toggle_plain_textarea('match-full-text-box', 1);
});
})
.catch(error => {
// Stop further searches for this search value
if (error.name === "AbortError") abort_this_search_value = true;
error.name === "AbortError"
? console.log(" ... ABORTED fetch() for: " + searchValue)
: console.log(error.toString());
});
} catch (error) {
console.log(error);
} finally {
// Executed regardless if we caught the error
}
};
const cm_jumpToLine = function (tag_id, row)
{
console.log('#' + tag_id);
let codeMirrorEl = jQuery('#' + tag_id).next('.CodeMirror');
if (!codeMirrorEl.length) return;
let codeMirrorRef = jQuery('#' + tag_id).next('.CodeMirror').get(0).CodeMirror;
let t = codeMirrorRef.charCoords({line: row, ch: 0}, "local").top;
let middleHeight = codeMirrorRef.getScrollerElement().offsetHeight / 2;
codeMirrorRef.scrollTo(null, t - middleHeight - 5);
}
/* Attach CodeMirror with optional settings */
const cm_toggle_fully_searchable = function (el, toggle)
{
if (typeof CodeMirror === 'undefined') {alert('CodeMirror not loaded'); return;}
jQuery([el]).each(function(i, tag_id) {
let codeMirrorEl = jQuery('#' + tag_id).next('.CodeMirror');
if (!codeMirrorEl.length) return;
let codeMirrorRef = jQuery('#' + tag_id).next('.CodeMirror').get(0).CodeMirror;
codeMirrorRef.setOption('viewportMargin', toggle ? '9999' : '');
});
}
const cm_toggle_plain_textarea = function (el, toggle)
{
if (typeof CodeMirror === 'undefined') {alert('CodeMirror not loaded'); return;}
jQuery([el]).each(function(i, tag_id) {
let codeMirrorEl = jQuery('#' + tag_id).next('.CodeMirror');
if (toggle) {
let options = jQuery('#' + tag_id).data('options');
options.viewportMargin = jQuery('#cm_toggle_fully_searchable_btn input').prop('checked') ? '9999' : '';
jQuery('#' + tag_id).prev('p').show();
attachCodeMirror(jQuery('#' + tag_id), options);
}
else if (codeMirrorEl.length)
{
let codeMirrorRef = codeMirrorEl.get(0).CodeMirror;
jQuery('#' + tag_id).prev('p').hide();
jQuery('#' + tag_id).css({width: '100%', height: '400px'});
codeMirrorRef.toTextArea();
// Remove codemirror container in case that removing it failed
if (jQuery('#' + tag_id).next('.CodeMirror').length) {
jQuery('#' + tag_id).next('.CodeMirror').remove();
}
}
});
}
const attachCodeMirror = function (txtareas, CMoptions, mode)
{
CMoptions = typeof CMoptions!=='undefined' && CMoptions ? CMoptions : {
mode: mode || 'application/x-httpd-php',
indentUnit: 2,
lineNumbers: true,
matchBrackets: true,
lineWrapping: true,
onCursorActivity: function(CM)
{
CM.setLineClass(hlLine, null);
hlLine = CM.setLineClass(CM.getCursor().line, 'activeline');
}
};
var editor, theArea;
txtareas.each(function(i, txtarea)
{
theArea = jQuery(txtarea);
theArea.removeClass(); // Remove all classes from the textarea
editor = CodeMirror.fromTextArea(theArea.get(0), CMoptions);
editor.refresh();
});
return txtareas.length==1 ? editor : true;
}
/**
* JS Function to execute (A) on search text change , (B) on search options changes
*/
const onChange = () => {
const searchValue = searchValueInp.value;
if (searchValue.length > 2) {
// Cancel any ongoing requests
if (controller) controller.abort();
// Create new controller and issue new request
controller = new AbortController();
doSearch(controller.signal, sTables);
} else {
// Clear any message in search results message div
//document.getElementById('search-mssg-box').innerHTML = '';
}
};
const previewReplace = () => {
const replaceValue = replaceValueInp.value;
console.log(replaceValueInp);
if (replaceValue.length) {
document.getElementById('search-mssg-box').innerHTML = replaceValue;
}
}
// Do the search on key up of search or replace input element
searchValueInp.onkeyup = onChange;
replaceValueInp.onkeyup = previewReplace;
// Do the search on key up of search input element
caseSensitiveLbl.onchange = onChange;
completeWordLbl.onchange = onChange;
regexpSearchLbl.onchange = onChange;

View File

@ -69,6 +69,9 @@ class ComponentbuilderControllerAjax extends BaseController
$this->registerTask('getCodeGlueOptions', 'ajax');
$this->registerTask('searchTable', 'ajax');
$this->registerTask('updateTable', 'ajax');
$this->registerTask('getSearchValue', 'ajax');
$this->registerTask('getReplaceValue', 'ajax');
$this->registerTask('setValue', 'ajax');
$this->registerTask('snippetDetails', 'ajax');
$this->registerTask('setSnippetGithub', 'ajax');
$this->registerTask('getSnippets', 'ajax');
@ -1726,6 +1729,142 @@ class ComponentbuilderControllerAjax extends BaseController
}
}
break;
case 'getSearchValue':
try
{
$field_nameValue = $jinput->get('field_name', NULL, 'WORD');
$row_idValue = $jinput->get('row_id', NULL, 'INT');
$table_nameValue = $jinput->get('table_name', NULL, 'WORD');
if($field_nameValue && $user->id != 0 && $row_idValue && $table_nameValue)
{
$result = $this->getModel('ajax')->getSearchValue($field_nameValue, $row_idValue, $table_nameValue);
}
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 'getReplaceValue':
try
{
$field_nameValue = $jinput->get('field_name', NULL, 'WORD');
$row_idValue = $jinput->get('row_id', NULL, 'INT');
$line_nrValue = $jinput->get('line_nr', 0, 'STRING');
$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');
if($field_nameValue && $user->id != 0 && $row_idValue && $table_nameValue && $search_valueValue)
{
$result = $this->getModel('ajax')->getReplaceValue($field_nameValue, $row_idValue, $line_nrValue, $table_nameValue, $search_valueValue, $replace_valueValue, $match_caseValue, $whole_wordValue, $regex_searchValue);
}
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 'setValue':
try
{
$valueValue = $jinput->get('value', NULL, 'RAW');
$row_idValue = $jinput->get('row_id', NULL, 'INT');
$field_nameValue = $jinput->get('field_name', NULL, 'WORD');
$table_nameValue = $jinput->get('table_name', NULL, 'WORD');
if($valueValue && $user->id != 0 && $row_idValue && $field_nameValue && $table_nameValue)
{
$result = $this->getModel('ajax')->setValue($valueValue, $row_idValue, $field_nameValue, $table_nameValue);
}
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
{

View File

@ -51,7 +51,7 @@ class ComponentbuilderControllerCompiler extends AdminController
*
* @return true on success
*/
public function getCompilerAnimations()
public function getDynamicContent()
{
// Check for request forgeries
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
@ -65,7 +65,7 @@ class ComponentbuilderControllerCompiler extends AdminController
{
// get the model
$model = $this->getModel('compiler');
if ($model->getCompilerAnimations($message))
if ($model->getDynamicContent($message))
{
$message = JText::_('COM_COMPONENTBUILDER_BALL_THE_COMPILER_ANIMATIONS_WERE_SUCCESSFULLY_DOWNLOADED_TO_THIS_JOOMLA_INSTALLB');
$this->setRedirect($redirect_url, $message, 'message');

View File

@ -1331,6 +1331,7 @@ COM_COMPONENTBUILDER_BASIC_TUTORIAL_ON_GIT_BSB="Basic Tutorial on git: <b>%s</b>
COM_COMPONENTBUILDER_BBEST_TO_NOT_CONTINUEBBR_WE_COULD_NOT_LOAD_THE_CHECKSUM_FOR_THIS_PACKAGE_AND_SO_NO_VALIDATION_WAS_POSSIBLE_THIS_MAY_BE_DUE_TO_YOUR_NETWORK_OR_A_CHANGE_TO_THAT_PACKAGE_NAME="<b>Best to not continue!</b><br />We could not load the checksum for this package, and so no validation was possible. This may be due to your network, or a change to that package name."
COM_COMPONENTBUILDER_BBEST_TO_NOT_CONTINUEBBR_YOU_CAN_REFRESH_AND_TRY_AGAINBR_BUT_NOTE_THAT_THIS_PACKAGE_BFAILEDB_CHECKSUM_VALIDATION_THIS_COULD_BE_A_SERIOUS_SECURITY_BREACH_DO_NOT_CONTINUE="<b>Best to not continue!</b><br />You can Refresh and try again.<br />But note that this package <b>FAILED</b> checksum validation, this could be a serious security breach! DO NOT CONTINUE!!!"
COM_COMPONENTBUILDER_BCUSTOM_FILESB_NOT_MOVED_TO_CORRECT_LOCATION="<b>Custom files</b> not moved to correct location!"
COM_COMPONENTBUILDER_BEHAVIOUR="Behaviour"
COM_COMPONENTBUILDER_BEHIND="Behind"
COM_COMPONENTBUILDER_BEHIND_MEANS_YOUR_BLOCAL_SNIPPETB_WITH_THE_SAME_NAME_LIBRARY_AND_TYPE_HAS_A_BOLDER_MODIFIED_DATEB_THEN_THE_COMMUNITY_SNIPPET_WITH_THE_SAME_NAME_LIBRARY_AND_TYPE="Behind means your <b>local snippet</b> (with the same name, library and type) has a <b>older modified date</b> then the community snippet (with the same name, library and type)."
COM_COMPONENTBUILDER_BETA_RELEASE="Beta Release"
@ -1721,6 +1722,7 @@ COM_COMPONENTBUILDER_COMPONENTS_ADMIN_VIEWS_N_ITEMS_UNFEATURED="%s Components Ad
COM_COMPONENTBUILDER_COMPONENTS_ADMIN_VIEWS_N_ITEMS_UNFEATURED_1="%s Component Admin Views unfeatured."
COM_COMPONENTBUILDER_COMPONENTS_ADMIN_VIEWS_N_ITEMS_UNPUBLISHED="%s Components Admin Views unpublished."
COM_COMPONENTBUILDER_COMPONENTS_ADMIN_VIEWS_N_ITEMS_UNPUBLISHED_1="%s Component Admin Views unpublished."
COM_COMPONENTBUILDER_COMPONENTS_BR_SMALLDISABLED_SOONSMALL="Components <br /><small>(disabled... soon!)</small>"
COM_COMPONENTBUILDER_COMPONENTS_CONFIG="Components Config"
COM_COMPONENTBUILDER_COMPONENTS_CONFIG_ACCESS="Components Config Access"
COM_COMPONENTBUILDER_COMPONENTS_CONFIG_ACCESS_DESC="Allows the users in this group to access access components config"
@ -4717,6 +4719,8 @@ COM_COMPONENTBUILDER_EMLICENSEEM_BSB="<em>License:</em> <b>%s</b>"
COM_COMPONENTBUILDER_EMOWNEREM_BSB="<em>Owner:</em> <b>%s</b>"
COM_COMPONENTBUILDER_EMPTY_TRASH="Empty trash"
COM_COMPONENTBUILDER_EMWEBSITEEM_BSB="<em>Website:</em> <b>%s</b>"
COM_COMPONENTBUILDER_ENTER_YOUR_REPLACE_TEXT="Enter your replace text"
COM_COMPONENTBUILDER_ENTER_YOUR_SEARCH_TEXT="Enter your search text."
COM_COMPONENTBUILDER_EQUAL="Equal"
COM_COMPONENTBUILDER_EQUAL_MEANS_THAT_THE_COMMUNITY_SNIPPET_WITH_THE_SAME_NAME_LIBRARY_AND_TYPE_AND_YOUR_LOCAL_SNIPPET_WITH_THE_SAME_NAME_LIBRARY_AND_TYPE_HAS_THE_SAME_BCREATIONB_AND_BMODIFIED_DATEB="Equal means that the community snippet (with the same name, library and type) and your local snippet (with the same name, library and type) has the same <b>creation</b> and <b>modified date</b>."
COM_COMPONENTBUILDER_ERROR="Error"
@ -5444,7 +5448,9 @@ COM_COMPONENTBUILDER_FOLDER_BSB_WAS_MOVED_TO_BSB="Folder <b>%s</b> was moved to
COM_COMPONENTBUILDER_FOLDER_BSB_WAS_NOT_MOVED_TO_BSB="Folder <b>%s</b> was not moved to <b>%s</b>"
COM_COMPONENTBUILDER_FORCE_LOCAL_UPDATE="Force Local Update"
COM_COMPONENTBUILDER_FORCE_THAT_THIS_JCB_PACKAGE_IMPORT_SEARCH_FOR_LOCAL_ITEMS_TO_BE_DONE_WITH_GUID_VALUE_ONLY_IF_BMERGEB_IS_SET_TO_YES_ABOVE="Force that this JCB package import (search for local items) to be done with GUID value only, if <b>Merge</b> is set to yes above."
COM_COMPONENTBUILDER_FOUND_TEXT="Found Text"
COM_COMPONENTBUILDER_FREEOPEN="Free/Open"
COM_COMPONENTBUILDER_FULL_TEXT="Full Text"
COM_COMPONENTBUILDER_FULL_WIDTH_IN_TAB="Full Width in Tab"
COM_COMPONENTBUILDER_FUNCTION_NAME_ALREADY_TAKEN_PLEASE_TRY_AGAIN="Function name already taken, please try again."
COM_COMPONENTBUILDER_GENERAL_OVERVIEW_OF_HOW_THINGS_WORK_BSB="General overview of how things work: <b>%s</b>"
@ -5587,6 +5593,8 @@ COM_COMPONENTBUILDER_HELP_DOCUMENT_URL_MESSAGE="Error! Please add url here."
COM_COMPONENTBUILDER_HELP_DOCUMENT_VERSION_DESC="A count of the number of times this Help Document has been revised."
COM_COMPONENTBUILDER_HELP_DOCUMENT_VERSION_LABEL="Version"
COM_COMPONENTBUILDER_HELP_MANAGER="Help"
COM_COMPONENTBUILDER_HERE_YOU_CAN_ENTER_THE_REPLACE_TEXT_THAT_YOU_WOULD_LIKE_TO_USE_AS_REPLACEMENT_FOR_THE_SEARCH_TEXT_FOUND="Here you can enter the replace text that you would like to use as replacement for the search text found."
COM_COMPONENTBUILDER_HERE_YOU_CAN_ENTER_YOUR_SEARCH_TEXT="Here you can enter your search text."
COM_COMPONENTBUILDER_HFOUR_CLASSNAVHEADERCOPYRIGHTHFOURPSP="<h4 class="nav-header">Copyright</h4><p>%s</p>"
COM_COMPONENTBUILDER_HFOUR_CLASSNAVHEADERLICENSEHFOURPSP="<h4 class="nav-header">License</h4><p>%s</p>"
COM_COMPONENTBUILDER_HI="Hi"
@ -7738,6 +7746,7 @@ COM_COMPONENTBUILDER_LIBRARY_VERSION_DESC="A count of the number of times this L
COM_COMPONENTBUILDER_LIBRARY_VERSION_LABEL="Version"
COM_COMPONENTBUILDER_LICENSE="License"
COM_COMPONENTBUILDER_LICENSE_S="License: %s"
COM_COMPONENTBUILDER_LINE="Line"
COM_COMPONENTBUILDER_LINK="Link"
COM_COMPONENTBUILDER_LINK_LOCAL_DYNAMIC="Link & Local (dynamic)"
COM_COMPONENTBUILDER_LINK_TO_THE_CONTRIBUTOR="Link to the contributor"
@ -7749,6 +7758,7 @@ COM_COMPONENTBUILDER_LOCAL_GET="Local (get)"
COM_COMPONENTBUILDER_LOCAL_SNIPPET="Local snippet"
COM_COMPONENTBUILDER_MAIN_MENU="Main Menu"
COM_COMPONENTBUILDER_MATCH_BEHAVIOUR="Match Behaviour"
COM_COMPONENTBUILDER_MATCH_CASE="Match Case"
COM_COMPONENTBUILDER_MATCH_FIELD="Match Field"
COM_COMPONENTBUILDER_MATCH_OPTIONS="Match Options"
COM_COMPONENTBUILDER_MAX_LENGTH_ONLY_FOUR_TEXT_FIELD="Max Length (only 4 text_field)"
@ -7756,6 +7766,7 @@ COM_COMPONENTBUILDER_MERGE="Merge"
COM_COMPONENTBUILDER_METHODS="Methods"
COM_COMPONENTBUILDER_MINIFY_JAVASCRIPT="Minify JavaScript"
COM_COMPONENTBUILDER_MIN_LENGTH_ONLY_FOUR_TEXT_FIELD="Min Length (only 4 text_field)"
COM_COMPONENTBUILDER_MODE="Mode"
COM_COMPONENTBUILDER_MODEL_AFTER_MODELLING="Model (after modelling)"
COM_COMPONENTBUILDER_MODEL_BEFORE_MODELLING="Model (before modelling)"
COM_COMPONENTBUILDER_MODULE="Module"
@ -8141,9 +8152,11 @@ 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_REGEX_SEARCH="Regex Search"
COM_COMPONENTBUILDER_REMOVE="Remove"
COM_COMPONENTBUILDER_REMOVING_ALL_ZIP_PACKAGES_FROM_THE_TEMPORARY_FOLDER_OF_THE_JOOMLA_INSTALL="Removing all zip packages from the temporary folder of the Joomla install"
COM_COMPONENTBUILDER_RENAME="Rename"
COM_COMPONENTBUILDER_REPLACE="Replace"
COM_COMPONENTBUILDER_REPORT_AN_ISSUE_BSB="Report an issue: <b>%s</b>"
COM_COMPONENTBUILDER_REQUIRES_THE_VALUE_ENTERED_BE_ONE_OF_THE_OPTIONS_IN_AN_ELEMENT_OF_TYPEQUOTLISTQUOT_THAT_IS_THAT_THE_ELEMENT_IS_A_SELECT_LIST="Requires the value entered be one of the options in an element of type=&quot;list&quot;: that is, that the element is a select list."
COM_COMPONENTBUILDER_REQUIRES_THE_VALUE_TO_BE_A_TELEPHONE_NUMBER_COMPLYING_WITH_THE_STANDARDS_OF_NANPA_ITUT_TRECEONE_HUNDRED_AND_SIXTY_FOUR_OR_IETF_RFCFOUR_THOUSAND_NINE_HUNDRED_AND_THIRTY_THREE="Requires the value to be a Telephone number complying with the standards of nanpa, ITU-T T-REC-E.164 or ietf rfc4933."
@ -8162,6 +8175,7 @@ COM_COMPONENTBUILDER_SEARCH_ACCESS_DESC="Allows the users in this group to acces
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_OR_SEARCH_AND_REPLACE="Search, or Search and Replace"
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"
@ -8175,8 +8189,10 @@ COM_COMPONENTBUILDER_SELECT_A_SNIPPET="select a snippet"
COM_COMPONENTBUILDER_SELECT_COMPONENT="Select Component"
COM_COMPONENTBUILDER_SELECT_EXTENSION="Select Extension"
COM_COMPONENTBUILDER_SELECT_THE_COMPONENT_TO_COMPILE="Select the component to compile"
COM_COMPONENTBUILDER_SELECT_THE_COMPONENT_TO_SEARCH="Select the component to search"
COM_COMPONENTBUILDER_SELECT_THE_COMPONENT_YOUR_WOULD_LIKE_TO_IMPORT="Select the component your would like to import."
COM_COMPONENTBUILDER_SELECT_THE_PACKAGE_TO_IMPORT="Select the package to import"
COM_COMPONENTBUILDER_SELECT_THE_TABLE_TO_SEARCH="Select the table to search"
COM_COMPONENTBUILDER_SERVER="Server"
COM_COMPONENTBUILDER_SERVERS="Servers"
COM_COMPONENTBUILDER_SERVERS_ACCESS="Servers Access"
@ -8317,6 +8333,7 @@ COM_COMPONENTBUILDER_SERVER_VERSION_DESC="A count of the number of times this Se
COM_COMPONENTBUILDER_SERVER_VERSION_LABEL="Version"
COM_COMPONENTBUILDER_SET_A_CLASS_VALUE_FOR_THE_LIST_VIEW_OF_THIS_FIELD="Set a class value for the list view of this field."
COM_COMPONENTBUILDER_SET_CUSTOM="Set Custom"
COM_COMPONENTBUILDER_SET_THE_SEARCH_BEHAVIOUR_HERE="Set the search behaviour here."
COM_COMPONENTBUILDER_SHARE_SNIPPETS="Share Snippets"
COM_COMPONENTBUILDER_SHOULD_JCB_ADD_ANY_POWERS_THAT_ARE_CONNECTED_TO_THIS_COMPONENT_THIS_MAY_BE_HELPFUL_IF_YOU_ARE_LOADING_POWERS_VIA_ANOTHER_COMPONENT_AND_WOULD_LIKE_TO_AVOID_ADDING_IT_TO_BOTH_JUST_REMEMBER_THAT_IN_THIS_CASE_YOU_NEED_TO_LOAD_THE_POWERS_VIA_A_PLUGIN="Should JCB add any powers that are connected to this component? This may be helpful if you are loading powers via another component, and would like to avoid adding it to both, just remember that in this case you need to load the powers via a plugin."
COM_COMPONENTBUILDER_SHOULD_JCB_INSERT_THE_CUSTOM_CODE_PLACEHOLDERS_THIS_IS_ONLY_APPLICABLE_IF_THIS_COMPONENT_HAS_CUSTOM_CODE="Should JCB insert the custom code placeholders? This is only applicable if this component has custom code."
@ -9000,6 +9017,8 @@ COM_COMPONENTBUILDER_S_S_NUMBER_BSB_COULD_NOT_BE_DOWNLOADED_SUCCESSFULLY_TO_THIS
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="Table"
COM_COMPONENTBUILDER_TABLES="Tables"
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."
COM_COMPONENTBUILDER_TARGET_BEHAVIOUR="Target Behaviour"
@ -9388,6 +9407,7 @@ COM_COMPONENTBUILDER_WE_FOUND_DYNAMIC_CODE_BALL_IN_ONE_LINEB_AND_IGNORED_IT_PLEA
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_WHOLE_WORD="Whole Word"
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."
@ -9421,6 +9441,7 @@ COM_COMPONENTBUILDER_YOU_WILL_NEED_TO_KNOW_HOW_S_WORKS_BASIC_YOU_WILL_ALSO_NEED_
COM_COMPONENTBUILDER_ZIPPED_FILE_LOCATION="Zipped File Location"
COM_COMPONENTBUILDER__ADD_YOUR_PHP_SCRIPT_HERE="// Add your php script here"
COM_COMPONENTBUILDER__HAS_BEEN_CHECKED_OUT_BY_S="% has been checked out by %s"
COM_COMPONENTBUILDER__SEARCH_ALL_="- Search All -"
COM_COMPONENTBUILDER__SELECT_COMPONENT_="- Select Component -"
COM_COMPONENTBUILDER__SELECT_PACKAGE_="- Select Package -"
COM_COMPONENTBUILDER__SINCE_YOU_DONT_HAVE_PERMISSION_TO_CREATE_S=", since you don't have permission to create %s!"

View File

@ -3662,24 +3662,109 @@ class ComponentbuilderModelAjax extends ListModel
int $matchCase, int $wholeWord, int $regexSearch, int $componentId): ?array
{
// check if this is a valid table
if (SearchFactory('Table')->exist($tableName))
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::_('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();
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')];
}
/**
* Get a selected search value from a given table and row
*
* @param string $fieldName The field key
* @param int $rowId The item ID
* @param string $tableName The table
*
* @return array
* @since 3.2.0
**/
public function getSearchValue(string $fieldName, int $rowId, string $tableName): array
{
// check if this is a valid table and field
if ($rowId > 0 && SearchFactory('Table')->exist($tableName, $fieldName) &&
($value = SearchFactory('Agent')->getValue($fieldName, $rowId, 0, $tableName)) !== null)
{
// load the value
return ['value' => $value];
}
return ['error' => JText::_('COM_COMPONENTBUILDER_THERE_HAS_BEEN_AN_ERROR_PLEASE_TRY_AGAIN')];
}
/**
* Get a replaced search value from a given table and row
*
* @param string $fieldName The field key
* @param int $rowId The item ID
* @param mixed $line The line line
* @param string $tableName The table
* @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
*
* @return array
* @since 3.2.0
**/
public function getReplaceValue(string $fieldName, int $rowId, $line, string $tableName,
string $searchValue, ?string $replaceValue = null, int $matchCase, int $wholeWord, int $regexSearch): array
{
// check if this is a valid table and field
if ($rowId > 0 && SearchFactory('Table')->exist($tableName, $fieldName))
{
// 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;
// load the value
if (($value = SearchFactory('Agent')->getValue($fieldName, $rowId, $line, $tableName, true)) !== null)
{
return ['value' => $value];
}
}
return ['error' => JText::_('COM_COMPONENTBUILDER_THERE_HAS_BEEN_AN_ERROR_PLEASE_TRY_AGAIN')];
}
/**
* Set selected search value in a given table and row
*
* @param mixed $value The field value
* @param int $rowId The item ID
* @param string $fieldName The field key
* @param string $tableName The table
*
* @return array
* @since 3.2.0
**/
public function setValue($value, int $rowId, string $fieldName, string $tableName): array
{
// check if this is a valid table and field
if ($rowId > 0 && SearchFactory('Table')->exist($tableName, $fieldName) &&
SearchFactory('Agent')->setValue($value, $rowId, $fieldName, $tableName))
{
return ['success' => JText::sprintf(
'<b>%s</b> (%s:%s) was successfully updated!',
$tableName, $rowId, $fieldName)];
}
return ['error' => JText::_('COM_COMPONENTBUILDER_THERE_HAS_BEEN_AN_ERROR_PLEASE_TRY_AGAIN')];
}
// Used in get_snippets

View File

@ -139,69 +139,6 @@ class ComponentbuilderModelCompiler extends ListModel
public $compiler;
public function getComponents()
{
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Order it by the ordering field.
$query->select($db->quoteName(array('id', 'system_name'),array('id', 'name')));
$query->from($db->quoteName('#__componentbuilder_joomla_component'));
$query->where($db->quoteName('published') . ' = 1');
$query->order('modified DESC');
$query->order('created DESC');
// Reset the query using our newly populated query object.
$db->setQuery($query);
// return the result
return $db->loadObjectList();
}
public function getCompilerAnimations(&$errorMessage)
{
// convert error message to array
$errorMessage = array();
$searchArray = array(
// add banners (width - height)
'banner' => array(
'728-90',
'160-600'
),
// The build-gif by size (width - height)
'builder-gif' => array(
'480-540'
)
);
// start search, and get
foreach ($searchArray as $type => $sizes)
{
// per size
foreach ($sizes as $size)
{
// get size
if (($set_size = ComponentbuilderHelper::getDynamicContentSize($type, $size)) !== 0)
{
// we loop over all type size artwork
for ($target = 1; $target <= $set_size; $target++)
{
if (!ComponentbuilderHelper::getDynamicContent($type, $size, false, 0, $target))
{
$errorMessage[] = JText::sprintf('COM_COMPONENTBUILDER_S_S_NUMBER_BSB_COULD_NOT_BE_DOWNLOADED_SUCCESSFULLY_TO_THIS_JOOMLA_INSTALL', $type, $size, $target);
}
}
}
}
}
// check if we had any errors
if (ComponentbuilderHelper::checkArray($errorMessage))
{
// flatten the error message array
$errorMessage = implode('<br />', $errorMessage);
return false;
}
return true;
}
public function builder()
{
// run compiler
@ -360,4 +297,90 @@ class ComponentbuilderModelCompiler extends ListModel
return $result;
}
/**
* Get all components in the system
*
* @return array
* @since 3.2.0
**/
public function getComponents(): array
{
// Get a db connection.
$db = $this->getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Select only id and system name
$query->select($db->quoteName(array('id', 'system_name'),array('id', 'name')));
$query->from($db->quoteName('#__componentbuilder_joomla_component'));
// only the active components
$query->where($db->quoteName('published') . ' = 1');
// Order it by the ordering field.
$query->order('modified DESC');
$query->order('created DESC');
// Reset the query using our newly populated query object.
$db->setQuery($query);
// return the result
return $db->loadObjectList();
}
/**
* Get all dynamic content
*
* @return bool
* @since 3.2.0
**/
public function getDynamicContent(&$errorMessage): bool
{
// convert error message to array
$errorMessage = [];
$searchArray = [
// add banners (width - height)
'banner' => [
'728-90',
'160-600'
],
// The build-gif by size (width - height)
'builder-gif' => [
'480-540'
]
];
// start search, and get
foreach ($searchArray as $type => $sizes)
{
// per size
foreach ($sizes as $size)
{
// get size
if (($set_size = ComponentbuilderHelper::getDynamicContentSize($type, $size)) !== 0)
{
// we loop over all type size artwork
for ($target = 1; $target <= $set_size; $target++)
{
if (!ComponentbuilderHelper::getDynamicContent($type, $size, false, 0, $target))
{
$errorMessage[] = JText::sprintf('COM_COMPONENTBUILDER_S_S_NUMBER_BSB_COULD_NOT_BE_DOWNLOADED_SUCCESSFULLY_TO_THIS_JOOMLA_INSTALL', $type, $size, $target);
}
}
}
}
}
// check if we had any errors
if (ComponentbuilderHelper::checkArray($errorMessage))
{
// flatten the error message array
$errorMessage = implode('<br />', $errorMessage);
return false;
}
return true;
}
}

View File

@ -114,8 +114,8 @@ class ComponentbuilderModelSearch extends ItemModel
$query = $db->getQuery(true);
// Get data
// load the tables and components (soon)
$data = ['tables' => SearchFactory::_('Table')->tables(), 'components' => null];
// load the tables and components
$data = ['tables' => SearchFactory::_('Table')->tables(), 'components' => $this->getComponents()];
if (empty($data))
@ -162,4 +162,38 @@ class ComponentbuilderModelSearch extends ItemModel
}
return false;
}
/**
* Get all components in the system
*
* @return array
* @since 3.2.0
**/
public function getComponents(): array
{
// Get a db connection.
$db = $this->getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Select only id and system name
$query->select($db->quoteName(array('id', 'system_name'),array('id', 'name')));
$query->from($db->quoteName('#__componentbuilder_joomla_component'));
// only the active components
$query->where($db->quoteName('published') . ' = 1');
// Order it by the ordering field.
$query->order('modified DESC');
$query->order('created DESC');
// Reset the query using our newly populated query object.
$db->setQuery($query);
// return the result
return $db->loadObjectList();
}
}

File diff suppressed because one or more lines are too long

View File

@ -25,7 +25,6 @@ $selectNotice .= '<p>' . JText::_('COM_COMPONENTBUILDER_PLEASE_SELECT_A_COMPONEN
$noticeboardOptions = array('vdm', 'pro');
?>
<?php if ($this->canDo->get('compiler.access')): ?>
<form action="<?php echo JRoute::_('index.php?option=com_componentbuilder&view=compiler'); ?>" method="post" name="adminForm" id="adminForm" class="form-validate" enctype="multipart/form-data">
<script type="text/javascript">
Joomla.submitbutton = function(task, key)
@ -129,20 +128,22 @@ jQuery('<div id="compiling"></div>')
<?php if (ComponentbuilderHelper::checkString($this->SuccessMessage)): ?>
<div class="alert alert-success">
<button type="button" class="close" data-dismiss="alert">×</button>
<?= $this->SuccessMessage; ?>
<?php echo $this->SuccessMessage; ?>
</div>
<?php endif; ?>
<form action="<?php echo JRoute::_('index.php?option=com_componentbuilder&view=compiler'); ?>"
method="post" name="adminForm" id="adminForm" class="form-validate" enctype="multipart/form-data">
<div id="form" >
<div class="span4">
<h3><?= JText::_('COM_COMPONENTBUILDER_READY_TO_COMPILE_A_COMPONENT') ?></h3>
<h3><?php echo JText::_('COM_COMPONENTBUILDER_READY_TO_COMPILE_A_COMPONENT'); ?></h3>
<div id="compilerForm">
<div>
<span class="notice" style="display:none; color:red;"><?= JText::_('COM_COMPONENTBUILDER_YOU_MUST_SELECT_A_COMPONENT') ?></span><br />
<?php if ($this->form): ?>
<?php foreach ($this->form as $field): ?>
<span class="notice" style="display:none; color:red;"><?php echo JText::_('COM_COMPONENTBUILDER_YOU_MUST_SELECT_A_COMPONENT'); ?></span><br />
<?php if ($this->Form): ?>
<?php foreach ($this->Form as $field): ?>
<div class="control-group">
<div class="control-label"><?= $field->label ?></div>
<div class="controls"><?= $field->input ?></div>
<div class="control-label"><?php echo $field->label; ?></div>
<div class="controls"><?php echo $field->input; ?></div>
</div>
<?php endforeach; ?>
<?php endif; ?>
@ -150,50 +151,53 @@ jQuery('<div id="compiling"></div>')
<br />
<div class="clearfix"></div>
<button class="btn btn-small btn-success" onclick="Joomla.submitbutton('compiler.compiler')"><span class="icon-cog icon-white"></span>
<?= JText::_('COM_COMPONENTBUILDER_COMPILE_COMPONENT') ?>
<?php echo JText::_('COM_COMPONENTBUILDER_COMPILE_COMPONENT'); ?>
</button>
<input type="hidden" name="install_item_id" value="0">
<input type="hidden" name="version" value="3" />
</div>
</div>
<div class="span7">
<div id="component-details"><?= $selectNotice ?></div>
<?= JLayoutHelper::render('jcbnoticeboardtabs', array('id' => 'noticeboard' , 'active' => $noticeboardOptions[array_rand($noticeboardOptions)])) ?>
<div id="component-details"><?php echo $selectNotice; ?></div>
<?php echo JLayoutHelper::render('jcbnoticeboardtabs', array('id' => 'noticeboard' , 'active' => $noticeboardOptions[array_rand($noticeboardOptions)])); ?>
</div>
</div>
<div id="get-compiler-animations" style="display:none;">
<h1><?= JText::_('COM_COMPONENTBUILDER_PLEASE_WAIT') ?></h1>
<h4><?= JText::_('COM_COMPONENTBUILDER_WHILE_WE_DOWNLOAD_ALL_TWENTY_SIX_COMPILER_GIF_ANIMATIONS_RANDOMLY_USED_IN_THE_COMPILER_GUI_DURING_COMPILATION') ?> <span class="loading-dots">.</span></h4>
<h1><?php echo JText::_('COM_COMPONENTBUILDER_PLEASE_WAIT'); ?></h1>
<h4><?php echo JText::_('COM_COMPONENTBUILDER_WHILE_WE_DOWNLOAD_ALL_TWENTY_SIX_COMPILER_GIF_ANIMATIONS_RANDOMLY_USED_IN_THE_COMPILER_GUI_DURING_COMPILATION'); ?> <span class="loading-dots">.</span></h4>
<div class="clearfix"></div>
</div>
<div id="clear" style="display:none;">
<h1><?= JText::_('COM_COMPONENTBUILDER_PLEASE_WAIT') ?></h1>
<h4><?= JText::_('COM_COMPONENTBUILDER_REMOVING_ALL_ZIP_PACKAGES_FROM_THE_TEMPORARY_FOLDER_OF_THE_JOOMLA_INSTALL') ?> <span class="loading-dots">.</span></h4>
<h1><?php echo JText::_('COM_COMPONENTBUILDER_PLEASE_WAIT'); ?></h1>
<h4><?php echo JText::_('COM_COMPONENTBUILDER_REMOVING_ALL_ZIP_PACKAGES_FROM_THE_TEMPORARY_FOLDER_OF_THE_JOOMLA_INSTALL'); ?> <span class="loading-dots">.</span></h4>
<div class="clearfix"></div>
</div>
<div id="compiler" style="display:none;">
<div id="compiler-spinner" class="span4" style="display:none;">
<h3><?= JText::sprintf('COM_COMPONENTBUILDER_S_PLEASE_WAIT', $this->user->name) ?></h3>
<p style="font-size: smaller;"><?= JText::_('COM_COMPONENTBUILDER_THIS_MAY_TAKE_A_WHILE_DEPENDING_ON_THE_SIZE_OF_YOUR_PROJECT') ?></p>
<p><b><span class="component-name"><?= JText::_('COM_COMPONENTBUILDER_THE_COMPONENT') ?></span></b> <?= JText::_('COM_COMPONENTBUILDER_IS_BEING_COMPILED') ?> <span class="loading-dots">.</span></p>
<div style="text-align: center;"><?= ComponentbuilderHelper::getDynamicContent('builder-gif', $this->builder_gif_size) ?></div>
<h3><?php echo JText::sprintf('COM_COMPONENTBUILDER_S_PLEASE_WAIT', $this->user->name); ?></h3>
<p style="font-size: smaller;"><?php echo JText::_('COM_COMPONENTBUILDER_THIS_MAY_TAKE_A_WHILE_DEPENDING_ON_THE_SIZE_OF_YOUR_PROJECT'); ?></p>
<p><b><span class="component-name"><?php echo JText::_('COM_COMPONENTBUILDER_THE_COMPONENT'); ?></span></b> <?php echo JText::_('COM_COMPONENTBUILDER_IS_BEING_COMPILED'); ?> <span class="loading-dots">.</span></p>
<div style="text-align: center;"><?php echo ComponentbuilderHelper::getDynamicContent('builder-gif', $this->builder_gif_size); ?></div>
<div class="clearfix"></div>
</div>
<div id="compiler-notice" class="span7" style="display:none;">
<?= JLayoutHelper::render('jcbnoticeboard' . $noticeboardOptions[array_rand($noticeboardOptions)], null) ?>
<div><?= ComponentbuilderHelper::getDynamicContent('banner', '728-90') ?></div>
<?php echo JLayoutHelper::render('jcbnoticeboard' . $noticeboardOptions[array_rand($noticeboardOptions)], null); ?>
<div><?php echo ComponentbuilderHelper::getDynamicContent('banner', '728-90'); ?></div>
</div>
</div>
<input type="hidden" name="task" value="" />
<?php echo JHtml::_('form.token'); ?>
</form>
</div>
<script type="text/javascript">
// token
var token = '<?= JSession::getFormToken() ?>';
var all_is_good = '<?= JText::_('COM_COMPONENTBUILDER_ALL_IS_GOOD_THERE_IS_NO_NOTICE_AT_THIS_TIME') ?>';
var token = '<?php echo JSession::getFormToken(); ?>';
var all_is_good = '<?php echo JText::_('COM_COMPONENTBUILDER_ALL_IS_GOOD_THERE_IS_NO_NOTICE_AT_THIS_TIME'); ?>';
jQuery('#compilerForm').on('change', '#component_id',function (e)
{
var component = jQuery('#component_id').val();
if(component == "") {
jQuery('#component-details').html("<?= $selectNotice ?>");
jQuery('#component-details').html("<?php echo $selectNotice; ?>");
jQuery("#noticeboard").show();
jQuery('.notice').show();
} else {
@ -233,9 +237,6 @@ function JRouter(link) {
return url+link;
}
</script>
<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; ?>

View File

@ -40,11 +40,18 @@ class ComponentbuilderViewCompiler extends HtmlView
JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=compiler');
$this->sidebar = JHtmlSidebar::render();
}
// get the success message if set
$this->SuccessMessage = $this->app->getUserState('com_componentbuilder.success_message', false);
// get active components
$this->Components = $this->get('Components');
$this->form = $this->setForm();
// get the needed form fields
$this->Form = $this->getDynamicForm();
// set the compiler artwork from global settings
$this->builder_gif_size = $this->params->get('builder_gif_size', '480-272');
// only run these checks if he has access
if ($this->canDo->get('compiler.compiler_animations'))
{
@ -96,7 +103,14 @@ class ComponentbuilderViewCompiler extends HtmlView
// JLayoutHelper::render('sectionjcb', [?]); // added to ensure the layout are loaded
// JLayoutHelper::render('repeatablejcb', [?]); // added to ensure the layout are loaded
public function setForm()
/**
* Get the dynamic build form fields needed on the page
*
* @return array|null The array of form fields
*
* @since 3.2.0
*/
public function getDynamicForm(): ?array
{
if(ComponentbuilderHelper::checkArray($this->Components))
{
@ -209,9 +223,11 @@ class ComponentbuilderViewCompiler extends HtmlView
// return the form array
return $form;
}
return false;
return null;
}
/**
* Prepares the document
*/
@ -396,7 +412,7 @@ class ComponentbuilderViewCompiler extends HtmlView
if ($this->canDo->get('compiler.compiler_animations'))
{
// add Compiler Animations button.
JToolBarHelper::custom('compiler.getCompilerAnimations', 'download custom-button-getcompileranimations', '', 'COM_COMPONENTBUILDER_COMPILER_ANIMATIONS', false);
JToolBarHelper::custom('compiler.getDynamicContent', 'download custom-button-getdynamiccontent', '', 'COM_COMPONENTBUILDER_COMPILER_ANIMATIONS', false);
}
if ($this->canDo->get('compiler.clear_tmp'))
{

View File

@ -17,6 +17,10 @@ JHtml::_('behavior.formvalidator');
JHtml::_('formbehavior.chosen', 'select');
JHtml::_('behavior.keepalive');
use VDM\Joomla\Componentbuilder\Search\Factory as SearchFactory;
$this->app->input->set('hidemainmenu', false);
$selectNotice = '<h3>' . JText::_('COM_COMPONENTBUILDER_HI') . ' ' . $this->user->name . '</h3>';
$selectNotice .= '<p>' . JText::_('COM_COMPONENTBUILDER_ENTER_YOUR_SEARCH_TEXT') . '</p>';
?>
<?php if ($this->canDo->get('search.access')): ?>
<script type="text/javascript">
@ -32,7 +36,6 @@ use VDM\Joomla\Componentbuilder\Search\Factory as SearchFactory;
}
</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">
@ -42,33 +45,55 @@ use VDM\Joomla\Componentbuilder\Search\Factory as SearchFactory;
<?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);
}
?>
<?php if ($this->form): ?>
<form action="<?php echo JRoute::_('index.php?option=com_componentbuilder&view=search'); ?>" method="post"
name="adminForm" id="adminForm" class="form-validate" enctype="multipart/form-data">
<div class="form-horizontal">
<div class="row-fluid">
<div class="span8">
<?php echo $this->form->renderField('type_search'); ?>
<?php echo $this->form->renderField('search_value'); ?>
<?php echo $this->form->renderField('replace_value'); ?>
</div>
<div class="span3">
<?php echo $this->form->renderFieldset('settings'); ?>
</div>
</div>
<div class="row-fluid" id="search_view">
<div id="search-results-tbl-box">
<table id="search-results-tbl" class="table">
<thead>
<tr>
<th><?php echo JText::_('COM_COMPONENTBUILDER_FOUND_TEXT'); ?></th>
<th><?php echo JText::_('COM_COMPONENTBUILDER_TABLE'); ?></th>
<th><?php echo JText::_('COM_COMPONENTBUILDER_FIELD'); ?></th>
<th><?php echo JText::_('ID'); ?></th>
<th><?php echo JText::_('COM_COMPONENTBUILDER_LINE'); ?></th>
</tr>
</thead>
<tbody id="search-results-tbl-tbody"></tbody>
</table>
</div>
</div>
<div class="row-fluid" id="item_view" style="display: none;">
<?php echo $this->form->renderFieldset('view'); ?>
</div>
</div>
<input type="hidden" name="task" value="" />
<?php echo JHtml::_('form.token'); ?>
</form>
<?php endif; ?>
</div>
<?php if (isset($this->item['tables']) && ComponentbuilderHelper::checkArray($this->item['tables'])) : ?>
<script>
var searchTables = json_encode($this->item['tables']);
const searchValueInp = document.getElementById("search_value");
const replaceValueInp = document.getElementById("replace_value");
const caseSensitiveLbl = document.getElementById("match_case_lbl");
const completeWordLbl = document.getElementById("whole_word_lbl");
const regexpSearchLbl = document.getElementById("regex_search_lbl");
let controller = null;
</script>
<?php endif; ?>
<?php else: ?>
<h1><?php echo JText::_('COM_COMPONENTBUILDER_NO_ACCESS_GRANTED'); ?></h1>
<?php endif; ?>

View File

@ -13,6 +13,9 @@
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Form\Form;
use VDM\Joomla\Componentbuilder\Search\Factory as SearchFactory;
/**
* Componentbuilder Html View class for the Search
@ -40,6 +43,10 @@ class ComponentbuilderViewSearch extends HtmlView
$this->sidebar = JHtmlSidebar::render();
}
// get the needed form fields
$this->form = $this->getDynamicForm();
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')
{
@ -59,6 +66,184 @@ class ComponentbuilderViewSearch extends HtmlView
parent::display($tpl);
}
/**
* Get the dynamic build form fields needed on the page
*
* @return Form|null The array of form fields
*
* @since 3.2.0
*/
public function getDynamicForm(): ?Form
{
if(ComponentbuilderHelper::checkArray($this->item) &&
ComponentbuilderHelper::checkArray($this->item['tables']) &&
ComponentbuilderHelper::checkArray($this->item['components']))
{
// start the form
$form = new Form('Search');
$form->load('<form
addrulepath="/administrator/components/com_componentbuilder/models/rules"
addfieldpath="/administrator/components/com_componentbuilder/models/fields">
<fieldset name="search"></fieldset>
<fieldset name="settings"></fieldset>
<fieldset name="view"></fieldset>
</form>');
// Search Mode
$attributes = [
'type' => 'radio',
'name' => 'type_search',
'label' => 'COM_COMPONENTBUILDER_MODE',
'class' => 'btn-group',
'description' => 'COM_COMPONENTBUILDER_SEARCH_OR_SEARCH_AND_REPLACE',
'default' => '1'];
// set the mode options
$options = [
1 => 'COM_COMPONENTBUILDER_SEARCH',
2 => 'COM_COMPONENTBUILDER_REPLACE'];
// add to form
$xml = ComponentbuilderHelper::getFieldXML($attributes, $options);
if ($xml instanceof SimpleXMLElement)
{
$form->setField($xml, null, true, 'search');
}
// search text attributes
$attributes = [
'type' => 'text',
'name' => 'search_value',
'label' => 'COM_COMPONENTBUILDER_SEARCH',
'size' => 150,
'maxlength' => 200,
'description' => 'COM_COMPONENTBUILDER_HERE_YOU_CAN_ENTER_YOUR_SEARCH_TEXT',
'filter' => 'RAW',
'class' => 'search-value span12',
'hint' => 'COM_COMPONENTBUILDER_ENTER_YOUR_SEARCH_TEXT',
'autocomplete' => true];
// add to form
$xml = ComponentbuilderHelper::getFieldXML($attributes);
if ($xml instanceof SimpleXMLElement)
{
$form->setField($xml, null, true, 'search');
}
// replace text attributes
$attributes = [
'type' => 'text',
'name' => 'replace_value',
'label' => 'COM_COMPONENTBUILDER_REPLACE',
'size' => 150,
'maxlength' => 200,
'description' => 'COM_COMPONENTBUILDER_HERE_YOU_CAN_ENTER_THE_REPLACE_TEXT_THAT_YOU_WOULD_LIKE_TO_USE_AS_REPLACEMENT_FOR_THE_SEARCH_TEXT_FOUND',
'filter' => 'RAW',
'class' => 'replace-value span12',
'hint' => 'COM_COMPONENTBUILDER_ENTER_YOUR_REPLACE_TEXT',
'autocomplete' => true,
'showon' => 'type_search:2'];
// add to form
$xml = ComponentbuilderHelper::getFieldXML($attributes);
if ($xml instanceof SimpleXMLElement)
{
$form->setField($xml, null, true, 'search');
}
// Search Behaviour
$attributes = [
'type' => 'checkboxes',
'name' => 'search_behaviour',
'label' => 'COM_COMPONENTBUILDER_BEHAVIOUR',
'class' => 'btn-group',
'description' => 'COM_COMPONENTBUILDER_SET_THE_SEARCH_BEHAVIOUR_HERE'];
// set the mode options
$options = [
'match_case' => 'COM_COMPONENTBUILDER_MATCH_CASE',
'whole_word' => 'COM_COMPONENTBUILDER_WHOLE_WORD',
'regex_search' => 'COM_COMPONENTBUILDER_REGEX_SEARCH'];
// add to form
$xml = ComponentbuilderHelper::getFieldXML($attributes, $options);
if ($xml instanceof SimpleXMLElement)
{
$form->setField($xml, null, true, 'settings');
}
// component attributes
$attributes = [
'type' => 'list',
'name' => 'component_id',
'label' => 'COM_COMPONENTBUILDER_COMPONENTS_BR_SMALLDISABLED_SOONSMALL',
'class' => 'list_class',
'description' => 'COM_COMPONENTBUILDER_SELECT_THE_COMPONENT_TO_SEARCH',
'required' => 'true',
'disable' => 'true',
'readonly' => 'true',
'default' => -1];
// start the component options
$options = [];
$options['-1'] = 'COM_COMPONENTBUILDER__SEARCH_ALL_';
// load component options from array
foreach($this->item['components'] as $component)
{
$options[(int) $component->id] = $this->escape($component->name);
}
// add to form
$xml = ComponentbuilderHelper::getFieldXML($attributes, $options);
if ($xml instanceof SimpleXMLElement)
{
$form->setField($xml, null, true, 'settings');
}
// table attributes
$attributes = [
'type' => 'list',
'name' => 'table_name',
'label' => 'COM_COMPONENTBUILDER_TABLES',
'class' => 'list_class',
'description' => 'COM_COMPONENTBUILDER_SELECT_THE_TABLE_TO_SEARCH',
'required' => 'true',
'default' => -1];
// start the component options
$options = [];
$options['-1'] = 'COM_COMPONENTBUILDER__SEARCH_ALL_';
// load table options from array
foreach($this->item['tables'] as $table)
{
$options[$table] = $this->escape($table);
}
// add to form
$xml = ComponentbuilderHelper::getFieldXML($attributes, $options);
if ($xml instanceof SimpleXMLElement)
{
$form->setField($xml, null, true, 'settings');
}
// editor attributes
$attributes = [
'type' => 'editor',
'name' => 'full_text',
'label' => 'COM_COMPONENTBUILDER_FULL_TEXT',
'width' => '100%',
'height' => '450px',
'class' => 'full_text_editor',
'syntax' => 'php',
'buttons' => 'false',
'filter' => 'raw',
'editor' => 'codemirror|none'];
// add to form
$xml = ComponentbuilderHelper::getFieldXML($attributes, $options);
if ($xml instanceof SimpleXMLElement)
{
$form->setField($xml, null, true, 'view');
}
// return the form array
return $form;
}
return null;
}
/**
* Prepares the document
*/
@ -72,6 +257,9 @@ class ComponentbuilderViewSearch extends HtmlView
// Initialize the header checker.
$HeaderCheck = new componentbuilderHeaderCheck;
// Add View JavaScript File
$this->document->addScript(JURI::root(true) . "/administrator/components/com_componentbuilder/assets/js/search.js", (ComponentbuilderHelper::jVersion()->isCompatible("3.8.0")) ? array("version" => "auto") : "text/javascript");
// Load uikit options.
$uikit = $this->params->get('uikit_load');
// Set script size.
@ -89,6 +277,40 @@ class ComponentbuilderViewSearch extends HtmlView
{
JHtml::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit'.$size.'.js', ['version' => 'auto']);
}
// Load the script to find all uikit components needed.
if ($uikit != 2)
{
// Set the default uikit components in this view.
$uikitComp = array();
$uikitComp[] = 'uk-progress';
}
// Load the needed uikit components in this view.
if ($uikit != 2 && isset($uikitComp) && ComponentbuilderHelper::checkArray($uikitComp))
{
// load just in case.
jimport('joomla.filesystem.file');
// loading...
foreach ($uikitComp as $class)
{
foreach (ComponentbuilderHelper::$uk_components[$class] as $name)
{
// check if the CSS file exists.
if (File::exists(JPATH_ROOT.'/media/com_componentbuilder/uikit-v2/css/components/'.$name.$style.$size.'.css'))
{
// load the css.
JHtml::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/'.$name.$style.$size.'.css', ['version' => 'auto']);
}
// check if the JavaScript file exists.
if (File::exists(JPATH_ROOT.'/media/com_componentbuilder/uikit-v2/js/components/'.$name.$size.'.js'))
{
// load the js.
JHtml::_('script', 'media/com_componentbuilder/uikit-v2/js/components/'.$name.$size.'.js', ['version' => 'auto'], ['type' => 'text/javascript', 'async' => 'async']);
}
}
}
}
// 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');
}

View File

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

View File

@ -175,7 +175,7 @@ class Power implements PowerInterface
*
* @param string $guid The global unique id of the power
*
* @return bool
* @return bool true on successful setting of a power
* @since 3.2.0
*/
protected function set(string $guid): bool
@ -190,39 +190,52 @@ class Power implements PowerInterface
// Create a new query object.
$query = $this->db->getQuery(true);
// select all values
$query->select('a.*');
// from these tables
// from this table
$query->from('#__componentbuilder_power AS a');
$query->where($this->db->quoteName('a.guid') . ' = ' . $this->db->quote($guid));
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// make sure that in recursion we
// don't try to load this power again
// since during the load of a power we also load
// all powers linked to it
$this->state[$guid] = true;
// get the power data
$this->active[$guid] = $this->db->loadObject();
// make sure to add any language strings found to all language files
// since we can't know where this is used at this point
$tmp_lang_target = $this->config->lang_target;
$this->config->lang_target = 'both';
// we set the fix usr if needed
$this->fixUrl
= '"index.php?option=com_componentbuilder&view=powers&task=power.edit&id='
. $this->active[$guid]->id . '" target="_blank"';
// set some keys
$this->active[$guid]->target_type = 'P0m3R!';
$this->active[$guid]->key = $this->active[$guid]->id . '_' . $this->active[$guid]->target_type;
// now set the name
$this->active[$guid]->name = $this->placeholder->update(
$this->customcode->update($this->active[$guid]->name),
$this->placeholder->active
);
// now set the code_name and class name
$this->active[$guid]->code_name = $this->active[$guid]->class_name = ClassfunctionHelper::safe(
$this->active[$guid]->name
);
// set official name
$this->active[$guid]->official_name = StringHelper::safe(
$this->active[$guid]->name, 'W'
@ -287,6 +300,7 @@ class Power implements PowerInterface
{
// set GUI mapper field
$guiMapper['field'] = 'head';
// base64 Decode code
$this->active[$guid]->head = $this->gui->set(
$this->placeholder->update(
@ -333,6 +347,7 @@ class Power implements PowerInterface
return true;
}
}
// we failed to get the power,
// so we raise an error message
// only if guid is valid
@ -343,6 +358,7 @@ class Power implements PowerInterface
'Error'
);
}
// let's not try again
$this->state[$guid] = false;

View File

@ -17,11 +17,11 @@ use VDM\Joomla\Componentbuilder\Search\Config;
/**
* Search Type Regex
* Search Engine
*
* @since 3.2.0
*/
abstract class Type
abstract class Engine
{
/**
* Search Config

View File

@ -19,6 +19,7 @@ use VDM\Joomla\Componentbuilder\Search\Database\Set;
use VDM\Joomla\Componentbuilder\Search\Agent\Find;
use VDM\Joomla\Componentbuilder\Search\Agent\Replace;
use VDM\Joomla\Componentbuilder\Search\Agent\Search;
use VDM\Joomla\Componentbuilder\Search\Agent\Update;
/**
@ -76,6 +77,14 @@ class Agent
*/
protected Search $search;
/**
* Update
*
* @var Update
* @since 3.2.0
*/
protected Update $update;
/**
* Constructor
*
@ -90,7 +99,7 @@ class Agent
*/
public function __construct(?Config $config = null, ?Get $get = null,
?Set$set = null, ?Find $find = null, ?Replace $replace = null,
?Search $search = null)
?Search $search = null, ?Update $update = null)
{
$this->config = $config ?: Factory::_('Config');
$this->get = $get ?: Factory::_('Get.Database');
@ -98,6 +107,65 @@ class Agent
$this->find = $find ?: Factory::_('Agent.Find');
$this->replace = $replace ?: Factory::_('Agent.Replace');
$this->search = $search ?: Factory::_('Agent.Search');
$this->update = $update ?: Factory::_('Agent.Update');
}
/**
* Get the value of a field in a row and table
*
* @param mixed $value The field value
* @param int $id The item ID
* @param string $field The field key
* @param mixed $line The field line
* @param string|null $table The table
* @param bool $update The switch to triger an update (default is false)
*
* @return mixed
* @since 3.2.0
*/
public function getValue(int $id, string $field, $line = null,
?string $table = null, bool $update = false)
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
if (($value = $this->get->value($id, $field, $table)) !== null)
{
// try to update the value if required
if ($update && ($updated_value = $this->update->value($value, $line)) !== null)
{
return $updated_value;
}
return $value;
}
return null;
}
/**
* Set the value of a field in a row and table
*
* @param mixed $value The field value
* @param int $id The item ID
* @param string $field The field key
* @param string|null $table The table
*
* @return bool
* @since 3.2.0
*/
public function setValue($value, int $id, string $field, ?string $table = null): bool
{
// set the table name
if (empty($table))
{
$table = $this->config->table_name;
}
return $this->set->value($value, $id, $field, $table);
}
/**

View File

@ -87,17 +87,17 @@ class Get implements GetInterface
}
/**
* Get values from a given table
* Get a value from a given table
* Example: $this->value(23, 'value_key', 'table_name');
*
* @param string $field The field key
* @param int $id The item ID
* @param string $field The field key
* @param string|null $table The table
*
* @return mixed
* @since 3.2.0
*/
public function value(string $field, int $id, string $table = null)
public function value(int $id, string $field, string $table = null)
{
// load the table
if (empty($table))

View File

@ -9,14 +9,14 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search\Type;
namespace VDM\Joomla\Componentbuilder\Search\Engine;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Search\Interfaces\SearchTypeInterface;
use VDM\Joomla\Componentbuilder\Search\Abstraction\Type;
use VDM\Joomla\Componentbuilder\Search\Abstraction\Engine;
/**
@ -24,7 +24,7 @@ use VDM\Joomla\Componentbuilder\Search\Abstraction\Type;
*
* @since 3.2.0
*/
class Basic extends Type implements SearchTypeInterface
class Basic extends Engine implements SearchTypeInterface
{
/**
* Regex Search Value

View File

@ -9,14 +9,14 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Componentbuilder\Search\Type;
namespace VDM\Joomla\Componentbuilder\Search\Engine;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Componentbuilder\Search\Interfaces\SearchTypeInterface;
use VDM\Joomla\Componentbuilder\Search\Abstraction\Type;
use VDM\Joomla\Componentbuilder\Search\Abstraction\Engine;
/**
@ -24,7 +24,7 @@ use VDM\Joomla\Componentbuilder\Search\Abstraction\Type;
*
* @since 3.2.0
*/
class Regex extends Type implements SearchTypeInterface
class Regex extends Engine implements SearchTypeInterface
{
/**
* Regex Search Value

View File

@ -17,8 +17,8 @@ use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Search\Config;
use VDM\Joomla\Componentbuilder\Search\Table;
use VDM\Joomla\Componentbuilder\Search\Interfaces\SearchTypeInterface as SearchEngine;
use VDM\Joomla\Componentbuilder\Search\Type\Regex;
use VDM\Joomla\Componentbuilder\Search\Type\Basic;
use VDM\Joomla\Componentbuilder\Search\Engine\Regex;
use VDM\Joomla\Componentbuilder\Search\Engine\Basic;
/**

View File

@ -2981,14 +2981,15 @@ class Table
}
/**
* Check if a table exist
* Check if a table (and field) exist
*
* @param string|null $table The area
* @param string|null $field The area
*
* @return bool
* @since 3.2.0
*/
public function exist(?string $table = null): bool
public function exist(?string $table = null, ?string $field = null): bool
{
// load the table
if (empty($table))
@ -2996,10 +2997,21 @@ class Table
$table = $this->config->table_name;
}
if (isset($table) && isset($this->tables[$table]))
if (is_string($table) && isset($this->tables[$table]))
{
// if we have a field
if (is_string($field))
{
if (isset($this->tables[$table][$field]))
{
return true;
}
}
else
{
return true;
}
}
return false;
}

View File

@ -33,11 +33,12 @@ abstract class GetHelper
* @param string $operator The operator between $whereString/field and $where/value
* @param string $main The component in which the table is found
*
* @return mix string/int/float
*
* @return mixed string/int/float
* @since 3.0.9
*/
public static function var($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = null)
public static function var(string $table, ?string $where = null,
string $whereString = 'user', string $what = 'id',
string $operator = '=', ?string $main = null)
{
if(empty($where))
{
@ -85,6 +86,7 @@ abstract class GetHelper
{
return $db->loadResult();
}
return false;
}
@ -99,11 +101,12 @@ abstract class GetHelper
* @param string $main The component in which the table is found
* @param bool $unique The switch to return a unique array
*
* @return array
*
* @return array|null
* @since 3.0.9
*/
public static function vars($table, $where = null, $whereString = 'user', $what = 'id', $operator = 'IN', $main = null, $unique = true)
public static function vars(string $table, ?string $where = null,
string $whereString = 'user', string $what = 'id', string $operator = 'IN',
?string $main = null, bool $unique = true): ?array
{
if(empty($where))
{
@ -166,7 +169,8 @@ abstract class GetHelper
return $db->loadColumn();
}
}
return false;
return null;
}
/**
@ -176,24 +180,26 @@ abstract class GetHelper
* @param string $start The starting value
* @param string $end The ending value
*
* @return array On success
*
* @return array|null On success
* @since 3.0.9
*/
public static function allBetween($content, $start, $end)
public static function allBetween(string $content, string $start, string $end): ?array
{
// reset bucket
$bucket = array();
$bucket = [];
for ($i = 0; ; $i++)
{
// search for string
$found = self::between($content, $start, $end);
if (StringHelper::check($found))
{
// add to bucket
$bucket[] = $found;
// build removal string
$remove = $start . $found . $end;
// remove from content
$content = str_replace($remove, '', $content);
}
@ -201,16 +207,23 @@ abstract class GetHelper
{
break;
}
// safety catch
if ($i == 500)
{
break;
}
}
// only return unique array of values
if (ArrayHelper::check($bucket))
{
return array_unique($bucket);
}
return null;
}
/**
* get a string between two other strings
*
@ -220,17 +233,19 @@ abstract class GetHelper
* @param string $default The default value if none found
*
* @return string On success / empty string on failure
*
* @since 3.0.9
*/
public static function between($content, $start, $end, $default = '')
public static function between(string $content, string $start, string $end, string $default = ''): string
{
$r = explode($start, $content);
if (isset($r[1]))
$array = explode($start, $content);
if (isset($array[1]) && strpos($array[1], $end) !== false)
{
$r = explode($end, $r[1]);
return $r[0];
$array = explode($end, $array[1]);
// return string found between
return $array[0];
}
return $default;
}