diff --git a/TEST b/TEST new file mode 100644 index 00000000..e69de29b diff --git a/models/media_model.php b/models/media_model.php index ebb6f44c..27369bd0 100644 --- a/models/media_model.php +++ b/models/media_model.php @@ -1166,20 +1166,24 @@ public function validate($args = []) return array(false,$item['local_id'],'The category selected is no longer valid.'); } //T The country selected is no longer valid. - $this->db->where('country_id', $item['country']); - $exists = $this->db->get_one('countries'); - if (!empty($item['country']) && !$exists) { - return array(false,$item['local_id'],'The country selected is no longer valid.'); + if(!empty($item['country'])) { + $this->db->where('country_id', $item['country']); + $exists = $this->db->get_one('countries'); + if (!$exists) { + return array(false,$item['local_id'],'The country selected is no longer valid.'); + } } //T The genre selected is no longer valid. if (!empty($item['genre_id']) && !$this->db->id_exists('media_genres', $item['genre_id'])) { return array(false,$item['local_id'],'The genre selected is no longer valid.'); } //T The language selected is no longer valid. - $this->db->where('language_id', $item['language']); - $exists = $this->db->get_one('languages'); - if (!empty($item['language']) && !$exists) { - return array(false,$item['local_id'],'The language selected is no longer valid.'); + if(!empty($item['language'])) { + $this->db->where('language_id', $item['language']); + $exists = $this->db->get_one('languages'); + if (!$exists) { + return array(false,$item['local_id'],'The language selected is no longer valid.'); + } } //T The media status is not valid. diff --git a/ui/fields/media.js b/ui/fields/media.js index 61799053..8f9f19bd 100644 --- a/ui/fields/media.js +++ b/ui/fields/media.js @@ -21,20 +21,20 @@ class OBFieldMedia extends OBField { #init; connectedCallback() { - this.#mediaItems = []; - this.#mediaContent = {}; + this.#mediaItems = []; + this.#mediaContent = {}; - this.#recordData = []; - this.#recordUrl = ""; + this.#recordData = []; + this.#recordUrl = ""; this.#mediaRecorder = null; - this.#blob = null; - this.#playback = null; - this.#duration = 0.0; - this.#waveformWidth = 350; + this.#blob = null; + this.#playback = null; + this.#duration = 0.0; + this.#waveformWidth = 350; this.#waveformHeight = 100; - this.#trimStart = 0.0; - this.#trimEnd = 0.0; + this.#trimStart = 0.0; + this.#trimEnd = 0.0; this.renderComponent(); @@ -59,18 +59,16 @@ class OBFieldMedia extends OBField { `)} - ${ - this.dataset.status === "cached" - ? html` + ${this.dataset.status === "cached" + ? html` ` - : html`` - } + : html`` + } - ${ - (this.#mediaItems.length === 0 && this.dataset.hasOwnProperty('single') && this.dataset.hasOwnProperty('record')) + ${(this.#mediaItems.length === 0 && this.dataset.hasOwnProperty('single') && this.dataset.hasOwnProperty('record')) ? html`
Trim Start @@ -274,7 +272,7 @@ class OBFieldMedia extends OBField { onDragStart(event) { let editable = this.root.querySelector("#media.media-editable"); - if (! editable) { + if (!editable) { return false; } @@ -284,7 +282,7 @@ class OBFieldMedia extends OBField { onDragEnd(event) { let editable = this.root.querySelector("#media.media-editable"); - if (! editable) { + if (!editable) { return false; } @@ -292,14 +290,14 @@ class OBFieldMedia extends OBField { } onMouseUp(event) { - if (! window.dragHelperData || ! window.dragHelperData[0].classList.contains("sidebar_search_media_result")) { + if (!window.dragHelperData || !window.dragHelperData[0].classList.contains("sidebar_search_media_result")) { return false; } var selectedMedia = this.#mediaItems; Object.keys(window.dragHelperData).forEach((key) => { - if (! window.dragHelperData[key].dataset) { + if (!window.dragHelperData[key].dataset) { return false; } @@ -394,7 +392,7 @@ class OBFieldMedia extends OBField { console.error(`The following getUserMedia error occurred: ${err}`); } - this.#mediaRecorder = navigator.mediaDevices.getUserMedia({audio: true}).then(onSuccess, onError); + this.#mediaRecorder = navigator.mediaDevices.getUserMedia({ audio: true }).then(onSuccess, onError); } else { // TODO: Update element look. console.error('getUserMedia not supported on your browser!'); @@ -451,8 +449,8 @@ class OBFieldMedia extends OBField { return response.json(); }).then((data) => { const fileKey = data.file_key; - const fileId = data.file_id; - const date = new Date(); + const fileId = data.file_id; + const date = new Date(); const dateStr = date.getFullYear() + "-" + ('0' + (date.getMonth() + 1)).slice(-2) + "-" + ('0' + date.getDate()).slice(-2); const media = OB.API.postPromise('media', 'save', { @@ -464,7 +462,7 @@ class OBFieldMedia extends OBField { title: "Media Field Recording " + dateStr, local_id: 1, status: "private", - language: 25571, + // language: 25571, is_copyright_owner: 1, is_approved: 1, dynamic_select: 0, @@ -474,7 +472,7 @@ class OBFieldMedia extends OBField { } }); media.then((data) => { - if (! data.status) { + if (!data.status) { console.error(data.msg); } else { this.value = data.data; @@ -531,7 +529,7 @@ class OBFieldMedia extends OBField { let blockStart = blockSize * i; let sum = 0; for (let j = 0; j < blockSize; j++) { - sum = sum + Math.abs(rawData[blockStart + j]); + sum = sum + Math.abs(rawData[blockStart + j]); } if (max < (sum / blockSize)) { max = sum / blockSize; @@ -542,12 +540,12 @@ class OBFieldMedia extends OBField { canvasCtx.clearRect(0, 0, width, height); canvasCtx.fillStyle = "rgb(200, 200, 200)"; canvasCtx.fillRect(0, 0, width, height); - + canvasCtx.lineWidth = 0.1; canvasCtx.strokeStyle = "rgb(0, 0, 0)"; - + canvasCtx.beginPath(); - + const sliceWidth = (width * 1.0) / samples; let x = 0; @@ -565,7 +563,7 @@ class OBFieldMedia extends OBField { } canvasCtx.stroke(); - + // copy to waveform-unedited to use for overwriting any potential changes // from trim const canvasUnedited = this.root.querySelector('#waveform-unedited');