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 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>
|
||||
<div class="form-group">
|
||||
<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) {
|
||||
$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`
|
||||
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->imageUrl = $row['image_url'];
|
||||
$element->fontIcon = $row['font_icon'];
|
||||
$element->url = $row['url'];
|
||||
$element->text = array();
|
||||
$element->subtext = array();
|
||||
}
|
||||
@ -103,6 +104,7 @@ class CustomNavElementGateway extends CommonDao {
|
||||
hesk_dbQuery("UPDATE `" . hesk_dbEscape($heskSettings['db_pfix']) . "custom_nav_element`
|
||||
SET `image_url` = {$imageUrl},
|
||||
`font_icon` = {$fontIcon},
|
||||
`url` = '" . hesk_dbEscape($element->url) . "',
|
||||
`place` = " . intval($element->place) .
|
||||
" WHERE `id` = " . intval($element->id));
|
||||
|
||||
@ -117,7 +119,7 @@ class CustomNavElementGateway extends CommonDao {
|
||||
function createCustomNavElement($element, $heskSettings) {
|
||||
$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));
|
||||
$maxSort = hesk_dbFetchAssoc($rs);
|
||||
$sortValue = intval($maxSort['sort']) + 1;
|
||||
@ -125,8 +127,8 @@ class CustomNavElementGateway extends CommonDao {
|
||||
$imageUrl = $element->imageUrl == null ? 'NULL' : "'" . hesk_dbEscape($element->imageUrl) . "'";
|
||||
$fontIcon = $element->fontIcon == null ? 'NULL' : "'" . hesk_dbEscape($element->fontIcon) . "'";
|
||||
hesk_dbQuery("INSERT INTO `" . hesk_dbEscape($heskSettings['db_pfix']) . "custom_nav_element`
|
||||
(`image_url`, `font_icon`, `place`, `sort`)
|
||||
VALUES ({$imageUrl}, {$fontIcon}, " . intval($element->place) . ", " . $sortValue . ")");
|
||||
(`image_url`, `font_icon`, `place`, `sort`, `url`)
|
||||
VALUES ({$imageUrl}, {$fontIcon}, " . intval($element->place) . ", " . $sortValue . ", '" . hesk_dbEscape($element->url) . "')");
|
||||
|
||||
$element->id = hesk_dbInsertID();
|
||||
|
||||
|
@ -69,13 +69,15 @@ $(document).ready(function() {
|
||||
}
|
||||
|
||||
var id = parseInt($modal.find('input[name="id"]').val());
|
||||
var navUrl = $modal.find('input[name="url"]').val();
|
||||
|
||||
var data = {
|
||||
place: place,
|
||||
text: text,
|
||||
subtext: subtext,
|
||||
imageUrl: imageUrl,
|
||||
fontIcon: fontIcon
|
||||
fontIcon: fontIcon,
|
||||
url: navUrl
|
||||
};
|
||||
|
||||
var url = heskUrl + '/api/v1-internal/custom-navigation/';
|
||||
@ -136,7 +138,7 @@ function loadTable(modalToClose) {
|
||||
if (lastElement !== null) {
|
||||
//-- Hide the down arrow on the last element
|
||||
$('[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;
|
||||
}
|
||||
|
||||
@ -156,7 +158,7 @@ function loadTable(modalToClose) {
|
||||
$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 = '';
|
||||
$.each(this.text, function(key, value) {
|
||||
@ -174,7 +176,7 @@ function loadTable(modalToClose) {
|
||||
$template.find('ul[data-property="subtext"]').html(subtext);
|
||||
|
||||
if (first) {
|
||||
$template.find('[data-direction="up"]').find('i').removeClass('fa-arrow-up');
|
||||
$template.find('[data-direction="up"]').css('visibility', 'hidden');
|
||||
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">' + 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">' + notFoundText + '</td></tr>');
|
||||
}
|
||||
@ -199,7 +201,7 @@ function loadTable(modalToClose) {
|
||||
if (lastElement) {
|
||||
//-- Hide the down arrow on the last element
|
||||
$('[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) {
|
||||
@ -228,6 +230,7 @@ function bindEditModal() {
|
||||
|
||||
$modal.find('select[name="place"]').val(element.place);
|
||||
$modal.find('input[name="id"]').val(element.id);
|
||||
$modal.find('input[name="url"]').val(element.url);
|
||||
var $textLanguages = $modal.find('[data-text-language]');
|
||||
$.each($textLanguages, function() {
|
||||
var language = $(this).data('text-language');
|
||||
@ -290,6 +293,7 @@ function bindCreateModal() {
|
||||
$modal.find('input[name="image-url"]').val('');
|
||||
$modal.find('#font-icon-group').hide();
|
||||
$modal.find('#image-url-group').show();
|
||||
$modal.find('input[name="url"]').val('');
|
||||
|
||||
$modal.modal('show');
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user