2022-09-14 15:40:02 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @package Joomla.Component.Builder
|
|
|
|
*
|
|
|
|
* @created 30th April, 2015
|
|
|
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
|
|
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
|
|
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
|
|
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
// No direct access to this file
|
|
|
|
defined('_JEXEC') or die('Restricted access');
|
|
|
|
|
2024-03-02 20:10:30 +00:00
|
|
|
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\Joomla\Utilities\ArrayHelper;
|
|
|
|
Html::addIncludePath(JPATH_COMPONENT.'/helpers/html');
|
|
|
|
Html::_('behavior.formvalidator');
|
|
|
|
Html::_('formbehavior.chosen', 'select');
|
|
|
|
Html::_('behavior.keepalive');
|
2022-10-20 14:40:18 +00:00
|
|
|
|
2022-11-04 20:18:05 +00:00
|
|
|
// allow main menu selection
|
2022-10-20 14:40:18 +00:00
|
|
|
$this->app->input->set('hidemainmenu', false);
|
2022-11-04 20:18:05 +00:00
|
|
|
|
|
|
|
// set the basu URL
|
|
|
|
$url_base = JUri::base() . 'index.php?option=com_componentbuilder';
|
2022-11-08 21:55:02 +00:00
|
|
|
$url_search = $url_base . '&view=search';
|
|
|
|
|
|
|
|
// get main search input field
|
|
|
|
$search_value = $this->form->getField('search_value');
|
2024-03-02 20:10:30 +00:00
|
|
|
|
2022-09-14 15:40:02 +00:00
|
|
|
?>
|
|
|
|
<?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 : ''; ?>
|
|
|
|
|
|
|
|
<?php if(!empty( $this->sidebar)): ?>
|
|
|
|
<div id="j-sidebar-container" class="span2">
|
|
|
|
<?php echo $this->sidebar; ?>
|
|
|
|
</div>
|
|
|
|
<div id="j-main-container" class="span10">
|
|
|
|
<?php else : ?>
|
|
|
|
<div id="j-main-container">
|
|
|
|
<?php endif; ?>
|
2022-10-20 14:40:18 +00:00
|
|
|
<?php if ($this->form): ?>
|
2022-11-04 20:18:05 +00:00
|
|
|
<form action="<?php echo JRoute::_($url_search); ?>" method="post"
|
2022-10-20 14:40:18 +00:00
|
|
|
name="adminForm" id="adminForm" class="form-validate" enctype="multipart/form-data">
|
|
|
|
<div class="form-horizontal">
|
2022-11-02 19:48:20 +00:00
|
|
|
<div class="row-fluid" 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>
|
2022-11-04 20:18:05 +00:00
|
|
|
<div class="row-fluid" 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>
|
2022-11-02 19:48:20 +00:00
|
|
|
<div class="row-fluid" id="search_details_block" style="display: none">
|
|
|
|
<span id="search_details">
|
2024-03-02 20:10:30 +00:00
|
|
|
<span class="search_details_title"><?php echo Text::_('COM_COMPONENTBUILDER_SEARCHED_FOR'); ?></span>:
|
2022-11-02 19:48:20 +00:00
|
|
|
[<span id="searched" class="found_code">....</span>]
|
|
|
|
</span>
|
|
|
|
<span id="replace_details" style="display: none">
|
2024-03-02 20:10:30 +00:00
|
|
|
<span class="search_details_title"><?php echo Text::_('COM_COMPONENTBUILDER_REPLACED_WITH'); ?></span>:
|
2022-11-02 19:48:20 +00:00
|
|
|
[<span id="replaced" class="found_code">....</span>]
|
|
|
|
</span>
|
2022-11-08 21:55:02 +00:00
|
|
|
<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"
|
2024-03-02 20:10:30 +00:00
|
|
|
title="<?php echo Text::_('COM_COMPONENTBUILDER_UPDATE_ALL_ITEMS_FOUND_WITH_THIS_DATABASE_SEARCH_WITH_THE_REPLACE_VALUE'); ?>">
|
2022-11-08 21:55:02 +00:00
|
|
|
<span class="icon-database icon-white" aria-hidden="true"></span>
|
2024-03-02 20:10:30 +00:00
|
|
|
<?php echo Text::_('COM_COMPONENTBUILDER_UPDATE_ALL'); ?>
|
2022-11-08 21:55:02 +00:00
|
|
|
</button>
|
|
|
|
<button type="button" onclick="showSearch();" class="btn button-new btn-success">
|
|
|
|
<span class="icon-search icon-white" aria-hidden="true"></span>
|
2024-03-02 20:10:30 +00:00
|
|
|
<?php echo Text::_('COM_COMPONENTBUILDER_SEARCH_DATABASE_AGAIN'); ?>
|
2022-11-08 21:55:02 +00:00
|
|
|
</button>
|
|
|
|
</div>
|
2022-11-02 19:48:20 +00:00
|
|
|
</div>
|
|
|
|
<div class="row-fluid" id="search_settings_block">
|
2022-10-30 22:34:54 +00:00
|
|
|
<div class="span7">
|
2022-10-20 14:40:18 +00:00
|
|
|
<?php echo $this->form->renderField('type_search'); ?>
|
2022-11-08 21:55:02 +00:00
|
|
|
<div class="btn-wrapper input-append">
|
|
|
|
<?php echo $search_value->input; ?>
|
|
|
|
<button id="start_search_button" onclick="startSearch(this, true);" type="button" class="btn hasTooltip"
|
2024-03-02 20:10:30 +00:00
|
|
|
title="<?php echo Html::_('tooltipText', 'COM_COMPONENTBUILDER_START_A_SEARCH'); ?>"
|
|
|
|
aria-label="<?php echo Text::_('COM_COMPONENTBUILDER_START_A_SEARCH'); ?>">
|
2022-11-08 21:55:02 +00:00
|
|
|
<span class="icon-search" aria-hidden="true"></span>
|
|
|
|
</button>
|
|
|
|
<button id="stop_search_button" onclick="stopSearch();" type="button" class="btn btn-danger hasTooltip" style="display: none"
|
2024-03-02 20:10:30 +00:00
|
|
|
title="<?php echo Html::_('tooltipText', 'COM_COMPONENTBUILDER_STOP_A_SEARCH'); ?>"
|
|
|
|
aria-label="<?php echo Text::_('COM_COMPONENTBUILDER_STOP_A_SEARCH'); ?>">
|
2022-11-08 21:55:02 +00:00
|
|
|
<span class="icon-stop" aria-hidden="true"></span>
|
|
|
|
</button>
|
|
|
|
</div>
|
2022-10-20 14:40:18 +00:00
|
|
|
<?php echo $this->form->renderField('replace_value'); ?>
|
2022-11-08 21:55:02 +00:00
|
|
|
<div class="update_all_block" style="display: none;">
|
|
|
|
<button type="button" onclick="replaceAllCheck();" class="hasTooltip btn btn-small button-new btn-danger span11"
|
2024-03-02 20:10:30 +00:00
|
|
|
title="<?php echo Text::_('COM_COMPONENTBUILDER_UPDATE_ALL_ITEMS_FOUND_WITH_THIS_DATABASE_SEARCH_WITH_THE_REPLACE_VALUE'); ?>">
|
2022-11-08 21:55:02 +00:00
|
|
|
<span class="icon-database icon-white" aria-hidden="true"></span>
|
2024-03-02 20:10:30 +00:00
|
|
|
<?php echo Text::_('COM_COMPONENTBUILDER_UPDATE_ALL'); ?>
|
2022-11-08 21:55:02 +00:00
|
|
|
</button>
|
|
|
|
</div>
|
2022-10-20 14:40:18 +00:00
|
|
|
</div>
|
2022-10-30 22:34:54 +00:00
|
|
|
<div class="span4">
|
2022-10-20 14:40:18 +00:00
|
|
|
<?php echo $this->form->renderFieldset('settings'); ?>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-11-02 19:48:20 +00:00
|
|
|
<div class="row-fluid" id="search_results_block">
|
2022-10-30 22:34:54 +00:00
|
|
|
<hr>
|
2022-11-02 19:48:20 +00:00
|
|
|
<div id="search_results_table_block">
|
2024-03-02 20:10:30 +00:00
|
|
|
<?php echo LayoutHelper::render('table', ['id' => 'search_results_table', 'headers' => $this->table_headers, 'items' => 7, 'init' => false]); ?>
|
2022-10-20 14:40:18 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-11-02 19:48:20 +00:00
|
|
|
<div class="row-fluid" id="item_view_block">
|
2022-11-08 21:55:02 +00:00
|
|
|
<div id="item_notice_block" style="display: none">
|
|
|
|
<hr>
|
|
|
|
<span id="item_edit_button"></span>
|
2024-03-02 20:10:30 +00:00
|
|
|
<?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">
|
2022-11-08 21:55:02 +00:00
|
|
|
</span></b>) |
|
2024-03-02 20:10:30 +00:00
|
|
|
<?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">
|
2022-11-08 21:55:02 +00:00
|
|
|
</span></b>)
|
|
|
|
<button type="button" id="item_button_update" onclick="" class="hasTooltip btn btn-small button-new btn-success"
|
2024-03-02 20:10:30 +00:00
|
|
|
title="<?php echo Text::_('COM_COMPONENTBUILDER_SAVE_ALL_CHANGES_MADE_TO_THE_SELECTED_ITEM'); ?>">
|
|
|
|
<?php echo Text::_('COM_COMPONENTBUILDER_SAVE_ITEM'); ?>
|
2022-11-08 21:55:02 +00:00
|
|
|
</button>
|
2022-11-02 19:48:20 +00:00
|
|
|
</div>
|
|
|
|
<hr>
|
|
|
|
<?php echo $this->form->getInput('item_code'); ?>
|
2022-10-20 14:40:18 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-11-12 20:42:08 +00:00
|
|
|
<input type="hidden" name="task" value="" />
|
2024-03-02 20:10:30 +00:00
|
|
|
<?php echo Html::_('form.token'); ?>
|
2022-10-20 14:40:18 +00:00
|
|
|
</form>
|
|
|
|
<?php endif; ?>
|
|
|
|
</div>
|
2023-10-18 07:26:30 +00:00
|
|
|
<?php if (isset($this->item['tables']) && ArrayHelper::check($this->item['tables'])) : ?>
|
2022-10-20 14:40:18 +00:00
|
|
|
<script>
|
2022-11-02 19:48:20 +00:00
|
|
|
// 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
|
2022-11-04 20:18:05 +00:00
|
|
|
const UrlAjax = '<?php echo $url_base; ?>&format=json&raw=true&<?php echo JSession::getFormToken(); ?>=1&task=ajax.';
|
|
|
|
|
|
|
|
// the search URL
|
|
|
|
const UrlSearch = '<?php echo $url_search; ?>';
|
2022-11-02 19:48:20 +00:00
|
|
|
|
|
|
|
// make sure our controller is set
|
|
|
|
let controller = null;
|
2022-11-04 20:18:05 +00:00
|
|
|
let controller_replace = null;
|
|
|
|
|
|
|
|
// some counters
|
|
|
|
var fieldCount = 0;
|
|
|
|
var lineCount = 0;
|
2022-11-02 19:48:20 +00:00
|
|
|
|
|
|
|
// 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");
|
2022-11-04 20:18:05 +00:00
|
|
|
const replaceProgressObject = document.getElementById("replace_progress_block");
|
|
|
|
const replaceProgressBarObject = document.getElementById("replace_progress_bar");
|
2022-11-02 19:48:20 +00:00
|
|
|
|
|
|
|
// 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");
|
|
|
|
|
2022-11-04 20:18:05 +00:00
|
|
|
// set the search mode objects
|
2022-11-02 19:48:20 +00:00
|
|
|
const modeObject = document.getElementById("type_search");
|
2022-11-04 20:18:05 +00:00
|
|
|
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]');
|
2022-09-16 21:41:41 +00:00
|
|
|
|
2022-11-08 21:55:02 +00:00
|
|
|
// search buttons
|
|
|
|
const startSearchButton = document.getElementById("start_search_button");
|
|
|
|
const stopSearchButton = document.getElementById("stop_search_button");
|
|
|
|
|
2022-11-02 19:48:20 +00:00
|
|
|
// 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");
|
2022-10-30 22:34:54 +00:00
|
|
|
|
2022-11-02 19:48:20 +00:00
|
|
|
// Do the search on key up of search or replace input elements
|
2022-11-08 21:55:02 +00:00
|
|
|
searchObject.onkeyup = startSearch;
|
2022-10-30 22:34:54 +00:00
|
|
|
|
2022-11-02 19:48:20 +00:00
|
|
|
// when the made changes and there is replace value do search
|
2022-11-08 21:55:02 +00:00
|
|
|
modeObject.onchange = startSearch;
|
|
|
|
replaceObject.onkeyup = startSearch;
|
2022-10-30 22:34:54 +00:00
|
|
|
|
2022-11-02 19:48:20 +00:00
|
|
|
// Do the search on key up of search input elements
|
2022-11-08 21:55:02 +00:00
|
|
|
matchObject.onchange = startSearch;
|
|
|
|
wholeObject.onchange = startSearch;
|
|
|
|
regexObject.onchange = startSearch;
|
|
|
|
tableObject.onchange = startSearch;
|
2022-10-30 22:34:54 +00:00
|
|
|
|
2022-11-02 19:48:20 +00:00
|
|
|
// 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");
|
2022-10-30 22:34:54 +00:00
|
|
|
|
2022-11-02 19:48:20 +00:00
|
|
|
// set the update buttons
|
|
|
|
const buttonUpdateItemObject = document.getElementById("item_button_update");
|
2022-11-08 21:55:02 +00:00
|
|
|
const buttonUpdateAllObject = document.querySelectorAll(".update_all_block");
|
2022-10-30 22:34:54 +00:00
|
|
|
|
2022-11-02 19:48:20 +00:00
|
|
|
// get the editor
|
|
|
|
var editorObject;
|
|
|
|
|
|
|
|
// set some global objects
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
2022-10-30 22:34:54 +00:00
|
|
|
// get the editor
|
2022-11-02 19:48:20 +00:00
|
|
|
editorObject = Joomla.editors.instances['item_code'];
|
|
|
|
});
|
|
|
|
|
|
|
|
// configurations of the table
|
|
|
|
const tableConfigObject = {
|
|
|
|
responsive: true,
|
|
|
|
order: [[ 2, "asc" ]],
|
|
|
|
select: true,
|
|
|
|
paging: true,
|
2022-11-08 21:55:02 +00:00
|
|
|
deferRender: true,
|
2022-11-02 19:48:20 +00:00
|
|
|
lengthMenu: [5, 10, 20 ,50, 80, 100, 150, 200, 500, 1000, 1500, 2000],
|
|
|
|
pageLength: 80,
|
2022-11-08 21:55:02 +00:00
|
|
|
// pagingType: "scrolling", // NOT YET
|
2022-11-02 19:48:20 +00:00
|
|
|
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();
|
|
|
|
}
|
2022-10-30 22:34:54 +00:00
|
|
|
});
|
|
|
|
|
2022-11-02 19:48:20 +00:00
|
|
|
searchResultsTable.on( 'deselect', function ( e, dt, type, indexes ) {
|
|
|
|
if ( type === 'row' ) {
|
|
|
|
clearSelectedItem(false);
|
|
|
|
}
|
2022-10-30 22:34:54 +00:00
|
|
|
});
|
2022-11-02 19:48:20 +00:00
|
|
|
|
|
|
|
// set the table search object
|
|
|
|
tableSearchObject = document.getElementById("search_results_table_filter");
|
|
|
|
tableLengthObject = document.getElementById("search_results_table_length");
|
|
|
|
|
|
|
|
showSearch();
|
2022-11-20 08:51:56 +00:00
|
|
|
<?php if (strlen($this->urlvalues['search_value']) > 0): ?>
|
|
|
|
startSearch(null, true);
|
2022-11-02 19:48:20 +00:00
|
|
|
<?php endif; ?>
|
|
|
|
});
|
2022-10-20 14:40:18 +00:00
|
|
|
</script>
|
|
|
|
<?php endif; ?>
|
2022-09-14 15:40:02 +00:00
|
|
|
<?php else: ?>
|
2024-03-02 20:10:30 +00:00
|
|
|
<h1><?php echo Text::_('COM_COMPONENTBUILDER_NO_ACCESS_GRANTED'); ?></h1>
|
2022-09-14 15:40:02 +00:00
|
|
|
<?php endif; ?>
|