Fix the linked [new] button to use the correct init_default params. Fix the Components list view to better display long website urls. Fix language text area css. #1264. Refactor the JS selText method. Add fix for empty currentFullPath in the Structuresingle class. Fix the buildSelectPart method to not access an empty select value in the Queries class. Fix that ensure that we always load and int into loadUserById. Fix the subform permission behaviour to use removeField. Add version 6 to the version 5 update server, for easier upgrade path. Fixed linked admin views with New and New & Close buttons to correctly initialize fields using global unique IDs and default conventions. Resolved missing language strings when linked admin views are also configured as site edit views. Corrected misconfiguration of the isModal property for site-linked views to default to false since modals are not yet supported on the site area. Enhanced security in edit views by moving access validation into the model, ensuring protection even when Joomla bypasses the controller layer. Added user access verification logic in the model to prevent unauthorized direct item loading. Refactored the view class to introduce a class constructor that initializes key dependencies more reliably. Began aligning the view class structure with Joomla 6's updated MVC architecture for future compatibility. Improved initialization handling in the view to reduce dependency errors during rendering. Fixed a bug caused by missing option settings in the model configuration. Updated and refined the site view class for greater consistency with backend view logic. Continued progressive improvements across view classes to ensure compatibility with Joomla's evolving MVC patterns. Fix permission issue in the list view. #1266. Refactor the list view buttons. Refactor the getActions helper method. Rename Custom Buttons tab to Toolbar for clearer grouping of toolbar functions. #1268. Add options for overriding default toolbars in all Admin, Site, and Custom Admin Views. #1268. Refactor toolbar into version specific classes to resolve getToolbar errors. #1267. Add method to unify getDatabase handling across Joomla versions and prevent undefined method calls. #1270. Fix php8.3 deprecation warnings in compiler templates. #1265. Refactor and enhance the JCB Email Helper class for a more robust and maintainable design. Fix an issue where the Email Helper send() function was executed twice. Fix a issue where layouts added to the PHP Ajax Model were not loaded during compilation. Add new functionality to the toolbar override system, enabling the inclusion of custom buttons via placeholders. Fix the Compiler success message to display both build seconds and project weeks. Add Development Valuation Model to calculate JCB component pricing. Add functionality to push JCB packages to Self hosted Git system that uses a self signed SSL. Add functionality that will include Validation Rules linked to fields in JCB packages. #1273. Refactor and Improve Router Helper Class to new standard Site Router practice. Refactor and Improve JCB Search engine for better searching of JCB areas. Fix bug in the search editor in JCB Search Engine. Fix issue where Custom Gets linked to a Site view did not ship correctly with JCB packages. #1272. Fix issue where the Icon linked to a Custom Admin Menu did not ship with JCB packages. #1271. Fix and Improve Normalize Class to better handle different files Linked to JCB packages. #1274. Remove batch feature from JCB compiler Templates due to lack of use and outdated code. Refactor Utilities/Response classes for Joomla 6+ compatibility and improved version-agnostic behavior. Refactor the File Upload Manager to achieve improved maintainability, greater customization flexibility, and easier extensibility. Refactor the Item Importer to improve data management, structural clarity, and long-term maintainability of the import process. Add a Pull button to all main JCB entities, allowing a complete reset of a selected entity together with all entities linked to it, from a selected remote repository. Add functionality to the compiler to automatically pull missing entities from a remote repository when they are referenced by a component but not present locally in JCB. Refactor the Packaging Engine into separate set and get classes to improve separation of concerns, readability, and overall maintainability. Refactor and restructure the demo console item import plugin to improve usability, maintainability, and reusability across other areas of JCB. Refactor the Compiler to remove deprecated code paths and legacy classes that are no longer maintained. Add new Compiler Classes to modernise ancient tech previously embedded in the compiler and replace it with a clean, modern architecture. Add a dedicated CLI plugin to the JCB core, enabling direct interaction with JCB through the Joomla CLI console. Add structured CLI commands and options to Init, Reset, Push, and Pull JCB entities via the Joomla CLI. Add full support for compiling Components directly via the CLI, enabling automated and headless build workflows. Add functionality to place Super Power classes into the component src folder for both Admin and Site areas, using the correct namespaced structure. Add functionality to the CLI compiler to directly install compiled components and apply compiler options used during compilation. Add functionality to the compiler to automatically pull a missing component from a remote repository when a compilation is triggered and the component is not locally available. Add functionality to add and replace classes in module and plugin src folders that are linked to a component, when using correct namespace resolution. Add a Documentation tab to the Joomla Component Builder dashboard. Fix an issue with the JCB version notice on Joomla 5. Fix an issue where components without a component image failed to compile successfully. #1282. Add functionality for importing translated language strings directly into the Language Translations area of JCB. Fix issue where the Language Translations export button was not displayed due to recent toolbar changes. Fix a bug that caused language filters to malfunction because of a broken field configuration. #1278. Fix issue where components without a layout added to the Component failed to compile correctly. #1132.
444 lines
15 KiB
PHP
444 lines
15 KiB
PHP
<?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
|
|
*/
|
|
|
|
use Joomla\CMS\Factory;
|
|
use Joomla\CMS\Language\Text;
|
|
use Joomla\CMS\HTML\HTMLHelper as Html;
|
|
use Joomla\CMS\Layout\LayoutHelper;
|
|
use Joomla\CMS\Router\Route;
|
|
use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
|
|
use VDM\Joomla\Utilities\ArrayHelper;
|
|
use Joomla\CMS\Uri\Uri;
|
|
|
|
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
|
|
$wa = $this->getDocument()->getWebAssetManager();
|
|
$wa->useScript('keepalive')->useScript('form.validate');
|
|
Html::_('bootstrap.tooltip');
|
|
use Joomla\CMS\Session\Session;
|
|
|
|
// No direct access to this file
|
|
defined('_JEXEC') or die;
|
|
|
|
// allow main menu selection
|
|
$this->app->getInput()->set('hidemainmenu', false);
|
|
|
|
// set the basu URL
|
|
$url_base = Uri::base() . 'index.php?option=com_componentbuilder';
|
|
$url_search = $url_base . '&view=search';
|
|
|
|
// get main search input field
|
|
$search_value = $this->form->getField('search_value');
|
|
|
|
?>
|
|
<?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 : ''; ?>
|
|
|
|
<div class="main-card p-md-3">
|
|
<?php if ($this->form): ?>
|
|
<form action="<?php echo Route::_($url_search); ?>" method="post"
|
|
name="adminForm" id="adminForm" class="form-validate" enctype="multipart/form-data">
|
|
<div class="row col-md-12">
|
|
<div class="row" id="search_progress_block" style="display: none">
|
|
<div class="uk-progress uk-progress-striped uk-active">
|
|
<div id="search_progress_bar" class="uk-progress-bar" style="width: 0%;">0%</div>
|
|
</div>
|
|
</div>
|
|
<div class="row" id="replace_progress_block" style="display: none">
|
|
<div class="uk-progress uk-progress-small uk-progress-danger uk-progress-striped uk-active">
|
|
<div id="replace_progress_bar" class="uk-progress-bar" style="width: 0%;"></div>
|
|
</div>
|
|
</div>
|
|
<div class="row" id="search_details_block" style="display: none">
|
|
<span id="search_details">
|
|
<span class="search_details_title"><?php echo Text::_('COM_COMPONENTBUILDER_SEARCHED_FOR'); ?></span>:
|
|
[<span id="searched" class="found_code">....</span>]
|
|
</span>
|
|
<span id="replace_details" style="display: none">
|
|
<span class="search_details_title"><?php echo Text::_('COM_COMPONENTBUILDER_REPLACED_WITH'); ?></span>:
|
|
[<span id="replaced" class="found_code">....</span>]
|
|
</span>
|
|
<div class="btn-group" style="float: right;">
|
|
<button style="display: none;" type="button" onclick="replaceAllCheck();" class="update_all_block hasTooltip btn button-new btn-danger"
|
|
title="<?php echo Text::_('COM_COMPONENTBUILDER_UPDATE_ALL_ITEMS_FOUND_WITH_THIS_DATABASE_SEARCH_WITH_THE_REPLACE_VALUE'); ?>">
|
|
<span class="icon-database icon-white" aria-hidden="true"></span>
|
|
<?php echo Text::_('COM_COMPONENTBUILDER_UPDATE_ALL'); ?>
|
|
</button>
|
|
<button type="button" onclick="showSearch();" class="btn button-new btn-success">
|
|
<span class="icon-search icon-white" aria-hidden="true"></span>
|
|
<?php echo Text::_('COM_COMPONENTBUILDER_SEARCH_DATABASE_AGAIN'); ?>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="row" id="search_settings_block">
|
|
<div class="col-md-7">
|
|
<div class="my-md-2">
|
|
<?php echo $this->form->renderField('type_search'); ?>
|
|
<div class="btn-wrapper input-group">
|
|
<?php echo $search_value->input; ?>
|
|
<button id="start_search_button" onclick="startSearch(this, true);" type="button" class="btn btn-outline-success button-select hasTooltip"
|
|
title="<?php echo Html::_('tooltipText', 'COM_COMPONENTBUILDER_START_A_SEARCH'); ?>"
|
|
aria-label="<?php echo Text::_('COM_COMPONENTBUILDER_START_A_SEARCH'); ?>">
|
|
<span class="icon-search" aria-hidden="true"></span>
|
|
</button>
|
|
<button id="stop_search_button" onclick="stopSearch();" type="button" class="btn btn-danger button-select hasTooltip" style="display: none"
|
|
title="<?php echo Html::_('tooltipText', 'COM_COMPONENTBUILDER_STOP_A_SEARCH'); ?>"
|
|
aria-label="<?php echo Text::_('COM_COMPONENTBUILDER_STOP_A_SEARCH'); ?>">
|
|
<span class="icon-stop" aria-hidden="true"></span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="my-md-2">
|
|
<?php echo $this->form->renderField('replace_value'); ?>
|
|
</div>
|
|
<div class="update_all_block" style="display: none;">
|
|
<button type="button" onclick="replaceAllCheck();" class="hasTooltip btn btn-small button-new btn-danger col-md-12"
|
|
title="<?php echo Text::_('COM_COMPONENTBUILDER_UPDATE_ALL_ITEMS_FOUND_WITH_THIS_DATABASE_SEARCH_WITH_THE_REPLACE_VALUE'); ?>">
|
|
<span class="icon-database icon-white" aria-hidden="true"></span>
|
|
<?php echo Text::_('COM_COMPONENTBUILDER_UPDATE_ALL'); ?>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<?php echo $this->form->renderFieldset('settings'); ?>
|
|
</div>
|
|
</div>
|
|
<div class="row" id="search_results_block">
|
|
<hr>
|
|
<div id="search_results_table_block">
|
|
<?php echo LayoutHelper::render('table', [
|
|
'id' => 'search_results_table',
|
|
'headers' => $this->table_headers,
|
|
'items' => 7,
|
|
'init' => false,
|
|
'table_class' => "table table-striped",
|
|
'table_container_class' => "overflow-x-auto"
|
|
]); ?>
|
|
</div>
|
|
</div>
|
|
<div class="row" id="item_view_block">
|
|
<div id="item_notice_block" style="display: none">
|
|
<hr>
|
|
<span id="item_edit_button"></span>
|
|
<?php echo Text::_('COM_COMPONENTBUILDER_TABLE'); ?>: <b><span id="item_table_name">
|
|
</span></b>(<?php echo Text::_('COM_COMPONENTBUILDER_ID'); ?>:<b><span id="item_row_id">
|
|
</span></b>) |
|
|
<?php echo Text::_('COM_COMPONENTBUILDER_FIELD'); ?>: <b><span id="item_field_name">
|
|
</span></b>(<?php echo Text::_('COM_COMPONENTBUILDER_LINE'); ?>:<b><span id="item_line_number">
|
|
</span></b>)
|
|
<button type="button" id="item_button_update" onclick="" class="hasTooltip btn btn-small button-new btn-success"
|
|
title="<?php echo Text::_('COM_COMPONENTBUILDER_SAVE_ALL_CHANGES_MADE_TO_THE_SELECTED_ITEM'); ?>">
|
|
<?php echo Text::_('COM_COMPONENTBUILDER_SAVE_ITEM'); ?>
|
|
</button>
|
|
</div>
|
|
<hr>
|
|
<?php echo $this->form->getInput('item_code'); ?>
|
|
</div>
|
|
</div>
|
|
<input type="hidden" name="task" value="" />
|
|
<?php echo Html::_('form.token'); ?>
|
|
</form>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php if (isset($this->item['tables']) && ArrayHelper::check($this->item['tables'])) : ?>
|
|
<script>
|
|
// To class="uk-autoload uk-progress" UIkit.notify
|
|
|
|
// get search table values
|
|
const searchTables = <?php echo json_encode($this->item['tables']); ?>;
|
|
|
|
// the search Ajax URLs
|
|
const UrlAjax = '<?php echo $url_base; ?>&format=json&raw=true&<?php echo Session::getFormToken(); ?>=1&task=ajax.';
|
|
|
|
// the search URL
|
|
const UrlSearch = '<?php echo $url_search; ?>';
|
|
|
|
// make sure our controller is set
|
|
let controller = null;
|
|
let controller_replace = null;
|
|
|
|
// some counters
|
|
var fieldCount = 0;
|
|
var lineCount = 0;
|
|
|
|
// start search time keepers
|
|
var startSearchTime, endSearchTime;
|
|
|
|
// active edit button of row selected
|
|
var editButtonSelected;
|
|
|
|
// get search progress area
|
|
const searchProgressObject = document.getElementById("search_progress_block");
|
|
const searchProgressBarObject = document.getElementById("search_progress_bar");
|
|
const replaceProgressObject = document.getElementById("replace_progress_block");
|
|
const replaceProgressBarObject = document.getElementById("replace_progress_bar");
|
|
|
|
// get search settings area
|
|
const searchSettingsObject = document.getElementById("search_settings_block");
|
|
const searchDetailsObject = document.getElementById("search_details_block");
|
|
const searchedObject = document.getElementById("searched");
|
|
|
|
// get replace settings area
|
|
const replaceDetailsObject = document.getElementById("replace_details");
|
|
const replacedObject = document.getElementById("replaced");
|
|
|
|
// set the search mode objects
|
|
const modeObject = document.getElementById("type_search");
|
|
const typeSearchObject = document.getElementById("type_search0");
|
|
const typeReplaceObject = document.getElementById("type_search1");
|
|
const typeSearchLabelObject = document.querySelector('[for=type_search0]');
|
|
const typeReplaceLabelObject = document.querySelector('[for=type_search1]');
|
|
|
|
// search buttons
|
|
const startSearchButton = document.getElementById("start_search_button");
|
|
const stopSearchButton = document.getElementById("stop_search_button");
|
|
|
|
// set the search settings objects
|
|
const searchObject = document.getElementById("search_value");
|
|
const replaceObject = document.getElementById("replace_value");
|
|
const matchObject = document.getElementById("search_behaviour0");
|
|
const wholeObject = document.getElementById("search_behaviour1");
|
|
const regexObject = document.getElementById("search_behaviour2");
|
|
const tableObject = document.getElementById("table_name");
|
|
|
|
// Do the search on key up of search or replace input elements
|
|
searchObject.onkeyup = startSearch;
|
|
|
|
// when the made changes and there is replace value do search
|
|
modeObject.onchange = startSearch;
|
|
replaceObject.onkeyup = startSearch;
|
|
|
|
// Do the search on key up of search input elements
|
|
matchObject.onchange = startSearch;
|
|
wholeObject.onchange = startSearch;
|
|
regexObject.onchange = startSearch;
|
|
tableObject.onchange = startSearch;
|
|
|
|
// set the item notice area
|
|
const itemNoticeObject = document.getElementById("item_notice_block");
|
|
const itemEditButtonObject = document.getElementById("item_edit_button");
|
|
const itemTableNameObject = document.getElementById("item_table_name");
|
|
const itemRowIdObject = document.getElementById("item_row_id");
|
|
const itemFieldNameObject = document.getElementById("item_field_name");
|
|
const itemLineNumberObject = document.getElementById("item_line_number");
|
|
|
|
// set the update buttons
|
|
const buttonUpdateItemObject = document.getElementById("item_button_update");
|
|
const buttonUpdateAllObject = document.querySelectorAll(".update_all_block");
|
|
|
|
// Define editorObject globally
|
|
var editorObject = null;
|
|
var editorPromise = null;
|
|
|
|
/**
|
|
* Internal function that attempts to obtain the editor instance,
|
|
* retrying until it is found or a timeout is reached.
|
|
*
|
|
* @param {number} retry
|
|
* @returns {Promise<object|null>}
|
|
*/
|
|
async function SetEditor(retry = 0) {
|
|
|
|
// Already loaded?
|
|
if (editorObject) {
|
|
return editorObject;
|
|
}
|
|
|
|
// --- NEW API: JoomlaEditor.get('item_code') ----------------------------
|
|
try {
|
|
const instance = JoomlaEditor.get('item_code');
|
|
if (instance) {
|
|
editorObject = instance;
|
|
return instance;
|
|
}
|
|
} catch (e) {
|
|
// JoomlaEditor not ready; expected
|
|
}
|
|
|
|
// NEW API fallback: getActive()
|
|
try {
|
|
const active = JoomlaEditor.getActive();
|
|
if (active && active.getId && active.getId() === 'item_code') {
|
|
editorObject = active;
|
|
return active;
|
|
}
|
|
} catch (e2) {
|
|
// JoomlaEditor not ready; expected
|
|
}
|
|
|
|
// --- SILENT LEGACY API (NO WARNINGS) ----------------------------------
|
|
try {
|
|
if (
|
|
typeof Joomla !== "undefined" &&
|
|
Joomla.editors &&
|
|
Joomla.editors.instances
|
|
) {
|
|
// Bypass the proxy "get" trap — SILENT MODE
|
|
const raw = Reflect.get(
|
|
Joomla.editors.instances,
|
|
'item_code',
|
|
Joomla.editors.instances
|
|
);
|
|
|
|
if (raw) {
|
|
editorObject = raw;
|
|
return raw;
|
|
}
|
|
}
|
|
} catch (e3) {
|
|
// JoomlaEditor not ready; un-expected
|
|
}
|
|
|
|
// --- RETRY -------------------------------------------------------------
|
|
if (retry < 20) {
|
|
await new Promise(r => setTimeout(r, 250)); // wait for Joomla to load CodeMirror
|
|
return SetEditor(retry + 1);
|
|
}
|
|
|
|
console.warn('Editor instance not found after retries.');
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Retrieve the editor instance. Waits if needed.
|
|
*
|
|
* @returns {Promise<object|null>}
|
|
*/
|
|
async function GetEditor() {
|
|
|
|
if (editorObject) {
|
|
return editorObject;
|
|
}
|
|
|
|
if (editorPromise) {
|
|
return editorPromise;
|
|
}
|
|
|
|
editorPromise = SetEditor(0);
|
|
|
|
const result = await editorPromise;
|
|
|
|
editorPromise = null;
|
|
|
|
return result;
|
|
}
|
|
|
|
// configurations of the table
|
|
const tableConfigObject = {
|
|
responsive: true,
|
|
order: [[ 2, "asc" ]],
|
|
select: true,
|
|
paging: true,
|
|
deferRender: true,
|
|
lengthMenu: [5, 10, 20 ,50, 80, 100, 150, 200, 500, 1000, 1500, 2000],
|
|
pageLength: 80,
|
|
// pagingType: "scrolling", // NOT YET
|
|
scrollY: 170,
|
|
columnDefs: [
|
|
{ 'targets': [ 0 ], 'visible': false, 'searchable': false },
|
|
{ 'targets': [ 0, 1 ], type: 'html' },
|
|
{ responsivePriority: 1, targets: 1 },
|
|
{ responsivePriority: 2, targets: 2 },
|
|
{ responsivePriority: 3, targets: 3 }
|
|
],
|
|
columns: [
|
|
{
|
|
data: 'edit'
|
|
},
|
|
{
|
|
data: 'code'
|
|
},
|
|
{
|
|
data: 'table'
|
|
},
|
|
{
|
|
data: 'field'
|
|
},
|
|
{
|
|
data: 'id',
|
|
width: "15px",
|
|
className: "small_column"
|
|
},
|
|
{
|
|
data: 'line',
|
|
width: "15px",
|
|
className: "small_column"
|
|
}
|
|
]
|
|
};
|
|
|
|
// set some table object
|
|
var tableSearchObject;
|
|
var tableLengthObject;
|
|
var tableActiveObject;
|
|
|
|
// The Result Table Code
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
|
|
// init the table
|
|
let searchResultsTable = new DataTable('#search_results_table', tableConfigObject);
|
|
|
|
searchResultsTable.on( 'select', function ( e, dt, type, indexes ) {
|
|
if ( type === 'row' ) {
|
|
// get the data from the row
|
|
let data = searchResultsTable.rows( indexes ).data();
|
|
|
|
// get the item data
|
|
let item_id = data[0].id;
|
|
let item_table = data[0].table;
|
|
let item_field = data[0].field;
|
|
let item_line = data[0].line;
|
|
|
|
// set the active edit button
|
|
editButtonSelected = data[0].edit;
|
|
// set active row
|
|
tableActiveObject = searchResultsTable.row( indexes );
|
|
|
|
// get selected item
|
|
getSelectedItem(item_table, item_id, item_field, item_line);
|
|
|
|
// hide the search settings
|
|
hideSearch();
|
|
}
|
|
});
|
|
|
|
searchResultsTable.on( 'deselect', function ( e, dt, type, indexes ) {
|
|
if ( type === 'row' ) {
|
|
clearSelectedItem(false);
|
|
}
|
|
});
|
|
|
|
// set the table search object
|
|
tableSearchObject = document.getElementById("search_results_table_filter");
|
|
tableLengthObject = document.getElementById("search_results_table_length");
|
|
|
|
showSearch();
|
|
<?php if (strlen($this->urlvalues['search_value'] ?? '') > 0): ?>
|
|
startSearch(null, true);
|
|
<?php endif; ?>
|
|
});
|
|
</script>
|
|
<?php endif; ?>
|
|
<?php else: ?>
|
|
<h1><?php echo Text::_('COM_COMPONENTBUILDER_NO_ACCESS_GRANTED'); ?></h1>
|
|
<?php endif; ?>
|