Properly handle saving/getting URLs
This commit is contained in:
parent
add02b208d
commit
11f9266f10
@ -134,6 +134,16 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6 col-sm-12">
|
<div class="col-md-6 col-sm-12">
|
||||||
|
<h4>URL[!]</h4>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="image-type" class="col-md-4 col-sm-12 control-label">URL[!]</label>
|
||||||
|
<div class="col-md-8 col-sm-12">
|
||||||
|
<input type="text" name="url" class="form-control"
|
||||||
|
data-error="<?php echo htmlspecialchars($hesklang['this_field_is_required']); ?>"
|
||||||
|
placeholder="<?php echo 'URL'; ?>" required>
|
||||||
|
<div class="help-block with-errors"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<h4>Image[!]</h4>
|
<h4>Image[!]</h4>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="image-type" class="col-md-4 col-sm-12 control-label">Image Type[!]</label>
|
<label for="image-type" class="col-md-4 col-sm-12 control-label">Image Type[!]</label>
|
||||||
|
@ -10,7 +10,7 @@ class CustomNavElementGateway extends CommonDao {
|
|||||||
function getAllCustomNavElements($heskSettings) {
|
function getAllCustomNavElements($heskSettings) {
|
||||||
$this->init();
|
$this->init();
|
||||||
|
|
||||||
$columns = '`t1`.`id`, `t1`.`image_url`, `t1`.`font_icon`, `t1`.`place`, `t2`.`language`, `t2`.`text`, `t2`.`subtext`';
|
$columns = '`t1`.`id`, `t1`.`image_url`, `t1`.`font_icon`, `t1`.`place`, `t1`.`url`, `t2`.`language`, `t2`.`text`, `t2`.`subtext`';
|
||||||
|
|
||||||
$rs = hesk_dbQuery("SELECT {$columns} FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "custom_nav_element` AS `t1`
|
$rs = hesk_dbQuery("SELECT {$columns} FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "custom_nav_element` AS `t1`
|
||||||
INNER JOIN `" . hesk_dbEscape($heskSettings['db_pfix']) . "custom_nav_element_to_text` AS `t2`
|
INNER JOIN `" . hesk_dbEscape($heskSettings['db_pfix']) . "custom_nav_element_to_text` AS `t2`
|
||||||
@ -33,6 +33,7 @@ class CustomNavElementGateway extends CommonDao {
|
|||||||
$element->place = intval($row['place']);
|
$element->place = intval($row['place']);
|
||||||
$element->imageUrl = $row['image_url'];
|
$element->imageUrl = $row['image_url'];
|
||||||
$element->fontIcon = $row['font_icon'];
|
$element->fontIcon = $row['font_icon'];
|
||||||
|
$element->url = $row['url'];
|
||||||
$element->text = array();
|
$element->text = array();
|
||||||
$element->subtext = array();
|
$element->subtext = array();
|
||||||
}
|
}
|
||||||
@ -103,6 +104,7 @@ class CustomNavElementGateway extends CommonDao {
|
|||||||
hesk_dbQuery("UPDATE `" . hesk_dbEscape($heskSettings['db_pfix']) . "custom_nav_element`
|
hesk_dbQuery("UPDATE `" . hesk_dbEscape($heskSettings['db_pfix']) . "custom_nav_element`
|
||||||
SET `image_url` = {$imageUrl},
|
SET `image_url` = {$imageUrl},
|
||||||
`font_icon` = {$fontIcon},
|
`font_icon` = {$fontIcon},
|
||||||
|
`url` = '" . hesk_dbEscape($element->url) . "',
|
||||||
`place` = " . intval($element->place) .
|
`place` = " . intval($element->place) .
|
||||||
" WHERE `id` = " . intval($element->id));
|
" WHERE `id` = " . intval($element->id));
|
||||||
|
|
||||||
@ -117,7 +119,7 @@ class CustomNavElementGateway extends CommonDao {
|
|||||||
function createCustomNavElement($element, $heskSettings) {
|
function createCustomNavElement($element, $heskSettings) {
|
||||||
$this->init();
|
$this->init();
|
||||||
|
|
||||||
$rs = hesk_dbQuery("SELECT MAX(`sort`) FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "custom_nav_element`
|
$rs = hesk_dbQuery("SELECT MAX(`sort`) AS `sort` FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "custom_nav_element`
|
||||||
WHERE `place` = " . intval($element->place));
|
WHERE `place` = " . intval($element->place));
|
||||||
$maxSort = hesk_dbFetchAssoc($rs);
|
$maxSort = hesk_dbFetchAssoc($rs);
|
||||||
$sortValue = intval($maxSort['sort']) + 1;
|
$sortValue = intval($maxSort['sort']) + 1;
|
||||||
@ -125,8 +127,8 @@ class CustomNavElementGateway extends CommonDao {
|
|||||||
$imageUrl = $element->imageUrl == null ? 'NULL' : "'" . hesk_dbEscape($element->imageUrl) . "'";
|
$imageUrl = $element->imageUrl == null ? 'NULL' : "'" . hesk_dbEscape($element->imageUrl) . "'";
|
||||||
$fontIcon = $element->fontIcon == null ? 'NULL' : "'" . hesk_dbEscape($element->fontIcon) . "'";
|
$fontIcon = $element->fontIcon == null ? 'NULL' : "'" . hesk_dbEscape($element->fontIcon) . "'";
|
||||||
hesk_dbQuery("INSERT INTO `" . hesk_dbEscape($heskSettings['db_pfix']) . "custom_nav_element`
|
hesk_dbQuery("INSERT INTO `" . hesk_dbEscape($heskSettings['db_pfix']) . "custom_nav_element`
|
||||||
(`image_url`, `font_icon`, `place`, `sort`)
|
(`image_url`, `font_icon`, `place`, `sort`, `url`)
|
||||||
VALUES ({$imageUrl}, {$fontIcon}, " . intval($element->place) . ", " . $sortValue . ")");
|
VALUES ({$imageUrl}, {$fontIcon}, " . intval($element->place) . ", " . $sortValue . ", '" . hesk_dbEscape($element->url) . "')");
|
||||||
|
|
||||||
$element->id = hesk_dbInsertID();
|
$element->id = hesk_dbInsertID();
|
||||||
|
|
||||||
|
@ -69,13 +69,15 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var id = parseInt($modal.find('input[name="id"]').val());
|
var id = parseInt($modal.find('input[name="id"]').val());
|
||||||
|
var navUrl = $modal.find('input[name="url"]').val();
|
||||||
|
|
||||||
var data = {
|
var data = {
|
||||||
place: place,
|
place: place,
|
||||||
text: text,
|
text: text,
|
||||||
subtext: subtext,
|
subtext: subtext,
|
||||||
imageUrl: imageUrl,
|
imageUrl: imageUrl,
|
||||||
fontIcon: fontIcon
|
fontIcon: fontIcon,
|
||||||
|
url: navUrl
|
||||||
};
|
};
|
||||||
|
|
||||||
var url = heskUrl + '/api/v1-internal/custom-navigation/';
|
var url = heskUrl + '/api/v1-internal/custom-navigation/';
|
||||||
@ -136,7 +138,7 @@ function loadTable(modalToClose) {
|
|||||||
if (lastElement !== null) {
|
if (lastElement !== null) {
|
||||||
//-- Hide the down arrow on the last element
|
//-- Hide the down arrow on the last element
|
||||||
$('[data-value="' + lastElement.id + '"]').parent().parent()
|
$('[data-value="' + lastElement.id + '"]').parent().parent()
|
||||||
.find('[data-direction="down"]').find('i').removeClass('fa-arrow-down');
|
.find('[data-direction="down"]').css('visibility', 'hidden');
|
||||||
lastElement = null;
|
lastElement = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +158,7 @@ function loadTable(modalToClose) {
|
|||||||
$template.find('span[data-property="image-or-font"]').text(this.imageUrl);
|
$template.find('span[data-property="image-or-font"]').text(this.imageUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
$template.find('span[data-property="url"]').text(places[this.url]);
|
$template.find('span[data-property="url"]').text(this.url);
|
||||||
|
|
||||||
var text = '';
|
var text = '';
|
||||||
$.each(this.text, function(key, value) {
|
$.each(this.text, function(key, value) {
|
||||||
@ -174,7 +176,7 @@ function loadTable(modalToClose) {
|
|||||||
$template.find('ul[data-property="subtext"]').html(subtext);
|
$template.find('ul[data-property="subtext"]').html(subtext);
|
||||||
|
|
||||||
if (first) {
|
if (first) {
|
||||||
$template.find('[data-direction="up"]').find('i').removeClass('fa-arrow-up');
|
$template.find('[data-direction="up"]').css('visibility', 'hidden');
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +193,7 @@ function loadTable(modalToClose) {
|
|||||||
$('#table-body').append('<tr><td colspan="6" class="bg-gray"><i><b>' + places[2] + '</b></i></td></tr>');
|
$('#table-body').append('<tr><td colspan="6" class="bg-gray"><i><b>' + places[2] + '</b></i></td></tr>');
|
||||||
$('#table-body').append('<tr><td colspan="6">' + notFoundText + '</td></tr>');
|
$('#table-body').append('<tr><td colspan="6">' + notFoundText + '</td></tr>');
|
||||||
}
|
}
|
||||||
if (currentPlace === 2) {
|
if (currentPlace === 1 || currentPlace === 2) {
|
||||||
$('#table-body').append('<tr><td colspan="6" class="bg-gray"><i><b>' + places[3] + '</b></i></td></tr>');
|
$('#table-body').append('<tr><td colspan="6" class="bg-gray"><i><b>' + places[3] + '</b></i></td></tr>');
|
||||||
$('#table-body').append('<tr><td colspan="6">' + notFoundText + '</td></tr>');
|
$('#table-body').append('<tr><td colspan="6">' + notFoundText + '</td></tr>');
|
||||||
}
|
}
|
||||||
@ -199,7 +201,7 @@ function loadTable(modalToClose) {
|
|||||||
if (lastElement) {
|
if (lastElement) {
|
||||||
//-- Hide the down arrow on the last element
|
//-- Hide the down arrow on the last element
|
||||||
$('[data-value="' + lastElement.id + '"]').parent().parent()
|
$('[data-value="' + lastElement.id + '"]').parent().parent()
|
||||||
.find('[data-direction="down"]').find('i').removeClass('fa-arrow-down');
|
.find('[data-direction="down"]').css('visibility', 'hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modalToClose !== undefined) {
|
if (modalToClose !== undefined) {
|
||||||
@ -228,6 +230,7 @@ function bindEditModal() {
|
|||||||
|
|
||||||
$modal.find('select[name="place"]').val(element.place);
|
$modal.find('select[name="place"]').val(element.place);
|
||||||
$modal.find('input[name="id"]').val(element.id);
|
$modal.find('input[name="id"]').val(element.id);
|
||||||
|
$modal.find('input[name="url"]').val(element.url);
|
||||||
var $textLanguages = $modal.find('[data-text-language]');
|
var $textLanguages = $modal.find('[data-text-language]');
|
||||||
$.each($textLanguages, function() {
|
$.each($textLanguages, function() {
|
||||||
var language = $(this).data('text-language');
|
var language = $(this).data('text-language');
|
||||||
@ -290,6 +293,7 @@ function bindCreateModal() {
|
|||||||
$modal.find('input[name="image-url"]').val('');
|
$modal.find('input[name="image-url"]').val('');
|
||||||
$modal.find('#font-icon-group').hide();
|
$modal.find('#font-icon-group').hide();
|
||||||
$modal.find('#image-url-group').show();
|
$modal.find('#image-url-group').show();
|
||||||
|
$modal.find('input[name="url"]').val('');
|
||||||
|
|
||||||
$modal.modal('show');
|
$modal.modal('show');
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user