File manager - Edit - /home/opticamezl/www/newok/com_languages.tar
Back
joomla.asset.json 0000644 00000005300 15172554240 0010041 0 ustar 00 { "$schema": "https://developer.joomla.org/schemas/json-schema/web_assets.json", "name": "com_languages", "version": "4.0.0", "description": "Joomla CMS", "license": "GPL-2.0-or-later", "assets": [ { "name": "com_languages.overrider", "type": "preset", "dependencies": [ "com_languages.overrider#style", "com_languages.overrider#script" ] }, { "name": "com_languages.admin-language-edit-change-flag.es5", "type": "script", "uri": "com_languages/admin-language-edit-change-flag-es5.min.js", "dependencies": [ "core" ], "attributes": { "nomodule": true, "defer": true }, "version": "c34dab0b90251907118d49b239f4640cbe87c78a" }, { "name": "com_languages.admin-override-edit-refresh-searchstring.es5", "type": "script", "uri": "com_languages/admin-override-edit-refresh-searchstring-es5.min.js", "dependencies": [ "core" ], "attributes": { "nomodule": true, "defer": true }, "version": "68b0a31acc446863c2c05ba5d99c11cc7699bd42" }, { "name": "com_languages.admin-override-edit-refresh-searchstring", "type": "script", "uri": "com_languages/admin-override-edit-refresh-searchstring.min.js", "dependencies": [ "com_languages.admin-override-edit-refresh-searchstring.es5" ], "attributes": { "type": "module" }, "version": "c0ecf5fb3a0df8a0ea36a4b7505e5835cfa42285" }, { "name": "com_languages.admin-language-edit-change-flag", "type": "script", "uri": "com_languages/admin-language-edit-change-flag.min.js", "dependencies": [ "com_languages.admin-language-edit-change-flag.es5" ], "attributes": { "type": "module" }, "version": "f56defffd530b649285e57fa31e0dd600f9ae2c9" }, { "name": "com_languages.overrider", "type": "style", "uri": "com_languages/overrider.min.css", "version": "490c9a9733ada84ea36c3ea08c0750b4e81580d7" }, { "name": "com_languages.overrider.es5", "type": "script", "uri": "com_languages/overrider-es5.min.js", "dependencies": [ "core" ], "attributes": { "nomodule": true, "defer": true }, "version": "a6ffb2b277ab2cbb0d1d13b39b912079069295d2" }, { "name": "com_languages.overrider", "type": "script", "uri": "com_languages/overrider.min.js", "dependencies": [ "com_languages.overrider.es5" ], "attributes": { "type": "module" }, "version": "72c4d238d2a1de5fbd2fc97760bf6cc8ea24a38b" } ] } css/overrider.css 0000644 00000001277 15172554240 0010063 0 ustar 00 /** * @package Joomla.Administrator * @subpackage com_languages * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ #overrider-spinner, #overrider-spinner-btn, #refresh-status, #more-results, #language-results, #results-container { display: none; } #overrider-spinner.show, #more-results.show, #results-container.show, #language-results.show { display: grid; } #refresh-status.show { display: block; } #overrider-spinner-btn.show { display: inline-block; } #refresh-status { flex-basis: 100%; } .result-key { color:#666; } .result-string { padding-inline-start: 20px; } css/overrider.min.css 0000644 00000000646 15172554240 0010644 0 ustar 00 @charset "UTF-8";#overrider-spinner,#overrider-spinner-btn,#refresh-status,#more-results,#language-results,#results-container{display:none}#overrider-spinner.show,#more-results.show,#results-container.show,#language-results.show{display:grid}#refresh-status.show{display:block}#overrider-spinner-btn.show{display:inline-block}#refresh-status{flex-basis:100%}.result-key{color:#666}.result-string{padding-inline-start:20px} css/overrider.min.css.gz 0000644 00000000333 15172554240 0011254 0 ustar 00 � m�Mj�@F�R2tg�S�MW=As��G�L5F�3w/4C��������~���^6��/x�|�xBr(�#1�Tk]��u M6MZ��(�:��� ��d�)�%F����Ș�5[�y�-h�*����k���Og/]��1���2I����9^��J���5oo��sC��4Msǚ��ϣu��CQk��ڷz��_��'ߦ js/admin-language-edit-change-flag.min.js.gz 0000644 00000000602 15172554240 0014650 0 ustar 00 � u��N[1F�y���,�ªJh��(U H)k0���?��8!�@�����3��0�o&u��� �T����/��0�*�l�4�"a�������f�۩ǔ��*e{����`, py}�1k7��;��-��R�3H�&�c(���Og��'��i��#)ݶ�-FZ�BG#g?�W��%�b�$����"�<��y���:�p炶��;>���"��`j���i���֤Xh��V��'Z{m�P+� =J�3,�L�O�_�Hˎ\����/�Au�6� �S�_�� �:݄��ym�K��CiN�+��c�� �w��*!g%&��os�Ib�Qei�o�Ƅ��Sы����W=6 js/admin-language-edit-change-flag-es5.min.js 0000644 00000001136 15172554240 0014726 0 ustar 00 (function(){"use strict";/** * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */document.addEventListener("DOMContentLoaded",function(){document.getElementById("jform_image").addEventListener("change",function(a){var r=a.currentTarget,t=r.value,e=document.getElementById("flag").querySelector("img"),n=Joomla.getOptions("system.paths").rootFull+"/media/mod_languages/images/"+t+".gif";t?(e.setAttribute("src",n),e.setAttribute("alt",t)):(e.removeAttribute("src"),e.setAttribute("alt",""))},!1)})})(); js/overrider-es5.min.js.gz 0000644 00000002571 15172554240 0011424 0 ustar 00 � �W�o�6~�_��� �2��i��uIj�)�����aF:[liR%ON2��@I�YN3�ow�}w ���Qh�%�-x����^y�������y����� 3P�X�&�#���w�b�"f�wxxϾh=��i3��p%Eʂ�y���w �ާ�N�ػ��0Vh���$G0}�x�g�������M�*�\p�M��e֏�,�KL�e9����l*Ԭ��8�� q/��������1�FH�~�A�,�́���k&��$�A���E� cD�[�����K��w�֖sm`6�h[L��kJq��i����w��ڼ:=� �h���0^�lm�̎�cn[ y� ��\ �h�2�Q�c}���k_g<N�^eg�#��~��l[��QK4,���Ka��$ �M�=��b��`1X�F��P <�,����}0��|"���|�Gn�F���ƿ?�f�1�b�"�0�I�|�oH�O��ޒ�|�®���eR��}�0\�Z��8k{��Z�����-���|��%64�<Z�w7R ���d�gi�&�\/`�ޖ�c�ӫ��F�x@6 ���jryr}~{r>O>_��?F�����h���`|3�F��/h���0f��[T������ۡQ��!�+�t_֗�0���,����ygdYAᮂC�����+��u����:�d1�2 �-�8 1js"e@��[�}ͦ�x�n��Y� (�� T�=K�L�+�j&��C`�u�Zp)B�fu��6x��� -,�4���E*����%y�X�&(�� j'�=�R�C���NY�:�u�F�����oa۪���!��LD:��r�,�OD��k�m��}��7��7��7���� �p���9�͔eBY0Xa���vQ��]`� *rR�fwβDX~'!�ܒ��5�^�^�� ��io���`6x��3�Ϲbh���Y�œ:��.�v�Nt�_ω� G�&@@�( ߵ� q�#D$$$;t�i��u�4բ#,vgF�Y�t~�}�v���;��ô��ޒ����������|�v�M?ق�K� H�4әv�;fl�L LIH����� ��T���X��T�C7�2����3U��n35X �������|L��c[h�4C�H��THp�F\%�Ο������2R�r%P�p.�b�,r�e�b/n���Z{ZC{b۬J��J-�y�e��r���p ���5g�+��.��8��^FU���h0�����s�j.)�����V��kNa� v�G�Z^�}�m�E������p�n+�s�6y��5�W�l�>8������Z.5O !am�Ԧo��ޛ��%����s�}wD����k�+� js/admin-override-edit-refresh-searchstring-es5.min.js 0000644 00000001345 15172554240 0016760 0 ustar 00 (function(){"use strict";/** * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */document.addEventListener("DOMContentLoaded",function(){document.getElementById("jform_searchstring").addEventListener("focus",function(e){var r=e.srcElement;if(!Joomla.overrider.states.refreshed){var t=document.getElementById("overrider-spinner").getAttribute("data-search-string-expired");t&&(Joomla.overrider.refreshCache(),Joomla.overrider.states.refreshed=!0)}r.classList.remove("invalid")},!1),document.getElementById("more-results-button").addEventListener("click",function(){Joomla.overrider.searchStrings(Joomla.overrider.states.more)},!1)})})(); js/admin-language-edit-change-flag.js 0000644 00000001442 15172554240 0013452 0 ustar 00 /** * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ document.addEventListener('DOMContentLoaded', () => { document.getElementById('jform_image').addEventListener('change', ({ currentTarget }) => { const flagSelectedValue = currentTarget.value; const flagimage = document.getElementById('flag').querySelector('img'); const src = `${Joomla.getOptions('system.paths').rootFull}/media/mod_languages/images/${flagSelectedValue}.gif`; if (flagSelectedValue) { flagimage.setAttribute('src', src); flagimage.setAttribute('alt', flagSelectedValue); } else { flagimage.removeAttribute('src'); flagimage.setAttribute('alt', ''); } }, false); }); js/admin-override-edit-refresh-searchstring-es5.js 0000644 00000001655 15172554240 0016202 0 ustar 00 (function () { 'use strict'; /** * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ document.addEventListener('DOMContentLoaded', function () { document.getElementById('jform_searchstring').addEventListener('focus', function (_ref) { var srcElement = _ref.srcElement; if (!Joomla.overrider.states.refreshed) { var expired = document.getElementById('overrider-spinner').getAttribute('data-search-string-expired'); if (expired) { Joomla.overrider.refreshCache(); Joomla.overrider.states.refreshed = true; } } srcElement.classList.remove('invalid'); }, false); document.getElementById('more-results-button').addEventListener('click', function () { Joomla.overrider.searchStrings(Joomla.overrider.states.more); }, false); }); })(); js/overrider-es5.min.js 0000644 00000010237 15172554240 0011003 0 ustar 00 (function(){"use strict";/** * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */(function(n,e){var f=function(){function g(){this.states={refreshing:!1,refreshed:!1,counter:0,searchString:"",searchType:"value"},this.spinner=e.getElementById("overrider-spinner"),this.spinnerBtn=e.getElementById("overrider-spinner-btn"),this.moreResults=e.getElementById("more-results"),this.moreResultsButton=e.getElementById("more-results-button"),this.resultsContainer=e.getElementById("results-container"),this.refreshStatus=e.getElementById("refresh-status")}var c=g.prototype;return c.refreshCache=function(){var a=this;this.states.refreshing=!0,this.refreshStatus.classList.add("show"),n.request({url:"index.php?option=com_languages&task=strings.refresh&format=json",method:"POST",headers:{"Content-Type":"application/json"},onSuccess:function(s){s.error&&s.message&&alert(s.message),s.messages&&n.renderMessages(s.messages),a.refreshStatus.classList.remove("show"),a.states.refreshing=!1},onError:function(){alert(n.Text._("COM_LANGUAGES_VIEW_OVERRIDE_REQUEST_ERROR")),a.refreshStatus.classList.remove("show")}})},c.searchStrings=function(a){var r=this;if(!this.states.refreshing){var s=e.getElementById("jform_searchstring"),u=e.getElementById("jform_searchtype");if(!a){this.states.searchString=s.value,this.states.searchType=u.value||"value";var o=[].slice.call(e.querySelectorAll(".language-results"));o.forEach(function(t){t.parentNode.removeChild(t)})}if(!this.states.searchString){s.classList.add("invalid");return}if(a)this.spinnerBtn.classList.add("show");else{this.moreResults.classList.remove("show");var h=[].slice.call(e.querySelectorAll("#results-container div.language-results"));h.forEach(function(t){t.parentNode.removeChild(t)}),this.resultsContainer.classList.add("show"),this.spinner.classList.add("show")}n.request({url:"index.php?option=com_languages&task=strings.search&format=json&searchstring="+this.states.searchString+"&searchtype="+this.states.searchType+"&more="+a,method:"POST",headers:{"Content-Type":"application/json"},onSuccess:function(l){var i=JSON.parse(l);i.error&&i.message&&alert(i.message),i.messages&&n.renderMessages(i.messages),i.data&&(i.data.results&&n.overrider.insertResults(i.data.results),i.data.more?(r.states.more=i.data.more,r.moreResultsButton.disabled=!1,r.moreResults.classList.add("show")):(r.moreResultsButton.disabled=!0,r.moreResults.classList.remove("show"))),r.spinnerBtn.classList.remove("show"),r.spinner.classList.remove("show")},onError:function(){alert(n.Text._("COM_LANGUAGES_VIEW_OVERRIDE_REQUEST_ERROR")),r.moreResultsButton.disabled=!0,r.moreResults.classList.remove("show"),r.resultsContainer.classList.remove("show")}})}},c.insertResults=function(a){var r=this;this.states.counter+=1;var s=e.createElement("div");if(s.setAttribute("id","language-results"+this.states.counter),s.classList.add("language-results"),s.classList.add("list-group"),s.classList.add("mb-2"),s.classList.add("show"),a.forEach(function(o,h){var t=e.createElement("a");t.setAttribute("onclick","Joomla.overrider.selectString("+r.states.counter+h+");"),t.setAttribute("href","#"),t.classList.add("list-group-item"),t.classList.add("list-group-item-action"),t.classList.add("flex-column"),t.classList.add("align-items-start");var l=e.createElement("div");l.setAttribute("id","override_key"+r.states.counter+h),l.setAttribute("title",o.file),l.classList.add("result-key"),l.innerHTML=n.sanitizeHtml(o.constant);var i=e.createElement("div");i.setAttribute("id","override_string"+r.states.counter+h),i.classList.add("result-string"),i.innerHTML=n.sanitizeHtml(o.string),t.appendChild(l),t.appendChild(i),s.appendChild(t)}),!a.length){var u=e.createElement("div");u.innerText=n.Text._("COM_LANGUAGES_VIEW_OVERRIDE_NO_RESULTS"),s.appendChild(u)}this.moreResults&&this.moreResults.parentNode.insertBefore(s,this.moreResults)},c.selectString=function(a){e.getElementById("jform_key").value=e.getElementById("override_key"+a).innerHTML,e.getElementById("jform_override").value=e.getElementById("override_string"+a).innerHTML},g}();e.addEventListener("DOMContentLoaded",function(){n.overrider=new f})})(Joomla,document)})(); js/admin-language-edit-change-flag-es5.js 0000644 00000001623 15172554240 0014145 0 ustar 00 (function () { 'use strict'; /** * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ document.addEventListener('DOMContentLoaded', function () { document.getElementById('jform_image').addEventListener('change', function (_ref) { var currentTarget = _ref.currentTarget; var flagSelectedValue = currentTarget.value; var flagimage = document.getElementById('flag').querySelector('img'); var src = Joomla.getOptions('system.paths').rootFull + "/media/mod_languages/images/" + flagSelectedValue + ".gif"; if (flagSelectedValue) { flagimage.setAttribute('src', src); flagimage.setAttribute('alt', flagSelectedValue); } else { flagimage.removeAttribute('src'); flagimage.setAttribute('alt', ''); } }, false); }); })(); js/admin-override-edit-refresh-searchstring-es5.min.js.gz 0000644 00000000641 15172554240 0017375 0 ustar 00 � ��Ak1��c�dv�$�ҭK[�')���,�z��J�hv�����&�$�7!�{�'Yv���A�g�%���-�b:��`_ll��o+�sחW�� �ؑE�5�H)�e�>U�m�8��v;�cSi��`U{�!! ���/���dj��mjoauz푒��!Ԇ� H��Z�w��G�d����s��|�Q���x��ơ٫�/�-����i�x(#5���PB� ��ym�^9�z� �P'�'�r���G"�tbØ4aI�*tG%��"�H����f�2��t�R8�&?2�G�[O�*��B��8m�[�T�!g�K�'mk��Ђ&lb�R�Л�;���JegC4�0'L]�)�t�1�[������W�e;]r&y}Xx�ګ����L@��� js/overrider.js 0000644 00000017771 15172554240 0007541 0 ustar 00 /** * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ ((Joomla, document) => { class Overrider { constructor() { this.states = { refreshing: false, refreshed: false, counter: 0, searchString: '', searchType: 'value' }; this.spinner = document.getElementById('overrider-spinner'); this.spinnerBtn = document.getElementById('overrider-spinner-btn'); this.moreResults = document.getElementById('more-results'); this.moreResultsButton = document.getElementById('more-results-button'); this.resultsContainer = document.getElementById('results-container'); this.refreshStatus = document.getElementById('refresh-status'); } /** * Method for refreshing the database cache of known language strings via Ajax * * @return void * * @since 2.5 */ refreshCache() { this.states.refreshing = true; this.refreshStatus.classList.add('show'); Joomla.request({ url: 'index.php?option=com_languages&task=strings.refresh&format=json', method: 'POST', headers: { 'Content-Type': 'application/json' }, onSuccess: response => { if (response.error && response.message) { alert(response.message); } if (response.messages) { Joomla.renderMessages(response.messages); } this.refreshStatus.classList.remove('show'); this.states.refreshing = false; }, onError: () => { alert(Joomla.Text._('COM_LANGUAGES_VIEW_OVERRIDE_REQUEST_ERROR')); this.refreshStatus.classList.remove('show'); } }); } /** * Method for searching known language strings via Ajax * * @param more Determines the limit start of the results * * @return void * * @since 2.5 */ searchStrings(more) { // Prevent searching if the cache is refreshed at the moment if (this.states.refreshing) { return; } const formSearchString = document.getElementById('jform_searchstring'); const formSearchType = document.getElementById('jform_searchtype'); // Only update the used searchstring and searchtype if the search button // was used to start the search (that will be the case if 'more' is null) if (!more) { this.states.searchString = formSearchString.value; this.states.searchType = formSearchType.value || 'value'; // Remove the old results const oldResults = [].slice.call(document.querySelectorAll('.language-results')); oldResults.forEach(result => { result.parentNode.removeChild(result); }); } if (!this.states.searchString) { formSearchString.classList.add('invalid'); return; } if (more) { // If 'more' is greater than 0 we have already displayed some results for // the current searchstring, so display the spinner at the more link this.spinnerBtn.classList.add('show'); } else { // Otherwise it is a new searchstring and we have to remove all previous results first this.moreResults.classList.remove('show'); const childs = [].slice.call(document.querySelectorAll('#results-container div.language-results')); childs.forEach(child => { child.parentNode.removeChild(child); }); this.resultsContainer.classList.add('show'); this.spinner.classList.add('show'); } Joomla.request({ url: `index.php?option=com_languages&task=strings.search&format=json&searchstring=${this.states.searchString}&searchtype=${this.states.searchType}&more=${more}`, method: 'POST', headers: { 'Content-Type': 'application/json' }, onSuccess: resp => { const response = JSON.parse(resp); if (response.error && response.message) { alert(response.message); } if (response.messages) { Joomla.renderMessages(response.messages); } if (response.data) { if (response.data.results) { Joomla.overrider.insertResults(response.data.results); } if (response.data.more) { // If there are more results than the sent ones // display the more link this.states.more = response.data.more; this.moreResultsButton.disabled = false; this.moreResults.classList.add('show'); } else { this.moreResultsButton.disabled = true; this.moreResults.classList.remove('show'); } } this.spinnerBtn.classList.remove('show'); this.spinner.classList.remove('show'); }, onError: () => { alert(Joomla.Text._('COM_LANGUAGES_VIEW_OVERRIDE_REQUEST_ERROR')); this.moreResultsButton.disabled = true; this.moreResults.classList.remove('show'); this.resultsContainer.classList.remove('show'); } }); } /** * Method inserting the received results into the results container * * @param results An array of search result objects * * @return void * * @since 2.5 */ insertResults(results) { // For creating an individual ID for each result we use a counter this.states.counter += 1; // Create a container into which all the results will be inserted const resultsDiv = document.createElement('div'); resultsDiv.setAttribute('id', `language-results${this.states.counter}`); resultsDiv.classList.add('language-results'); resultsDiv.classList.add('list-group'); resultsDiv.classList.add('mb-2'); resultsDiv.classList.add('show'); // Create some elements for each result and insert it into the container results.forEach((item, index) => { const a = document.createElement('a'); a.setAttribute('onclick', `Joomla.overrider.selectString(${this.states.counter}${index});`); a.setAttribute('href', '#'); a.classList.add('list-group-item'); a.classList.add('list-group-item-action'); a.classList.add('flex-column'); a.classList.add('align-items-start'); const key = document.createElement('div'); key.setAttribute('id', `override_key${this.states.counter}${index}`); key.setAttribute('title', item.file); key.classList.add('result-key'); key.innerHTML = Joomla.sanitizeHtml(item.constant); const string = document.createElement('div'); string.setAttribute('id', `override_string${this.states.counter}${index}`); string.classList.add('result-string'); string.innerHTML = Joomla.sanitizeHtml(item.string); a.appendChild(key); a.appendChild(string); resultsDiv.appendChild(a); }); // If there aren't any results display an appropriate message if (!results.length) { const noresult = document.createElement('div'); noresult.innerText = Joomla.Text._('COM_LANGUAGES_VIEW_OVERRIDE_NO_RESULTS'); resultsDiv.appendChild(noresult); } if (this.moreResults) { this.moreResults.parentNode.insertBefore(resultsDiv, this.moreResults); } } /** * Inserts a specific constant/value pair into the form and scrolls the page back to the top * * @param id The ID of the element which was selected for insertion * * @return void * * @since 2.5 */ // eslint-disable-next-line class-methods-use-this selectString(id) { document.getElementById('jform_key').value = document.getElementById(`override_key${id}`).innerHTML; document.getElementById('jform_override').value = document.getElementById(`override_string${id}`).innerHTML; } } document.addEventListener('DOMContentLoaded', () => { Joomla.overrider = new Overrider(); }); })(Joomla, document); js/admin-override-edit-refresh-searchstring.min.js 0000644 00000001244 15172554240 0016264 0 ustar 00 /** * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */document.addEventListener("DOMContentLoaded",()=>{document.getElementById("jform_searchstring").addEventListener("focus",({srcElement:e})=>{Joomla.overrider.states.refreshed||document.getElementById("overrider-spinner").getAttribute("data-search-string-expired")&&(Joomla.overrider.refreshCache(),Joomla.overrider.states.refreshed=!0),e.classList.remove("invalid")},!1),document.getElementById("more-results-button").addEventListener("click",()=>{Joomla.overrider.searchStrings(Joomla.overrider.states.more)},!1)}); js/admin-language-edit-change-flag.min.js 0000644 00000001066 15172554240 0014236 0 ustar 00 /** * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */document.addEventListener("DOMContentLoaded",()=>{document.getElementById("jform_image").addEventListener("change",({currentTarget:a})=>{const t=a.value,e=document.getElementById("flag").querySelector("img"),s=`${Joomla.getOptions("system.paths").rootFull}/media/mod_languages/images/${t}.gif`;t?(e.setAttribute("src",s),e.setAttribute("alt",t)):(e.removeAttribute("src"),e.setAttribute("alt",""))},!1)}); js/overrider.min.js.gz 0000644 00000002473 15172554240 0010733 0 ustar 00 � �W[S�8~�0j�c���>�5]�J'�n݇��D�'��"��q����N��:۷X�s�Χ����7ޮ�g�'F�R��z�~�:P^Og&�#���w�b�"Nlso���}�z,9�ftT��"e��<����;�K�Kv#E�+��Zy�=m<�̡g���i��bx�o�ݽ 0!��hKn��g�VM�6�a*,��l4304`S�F͝�����}�:S��Z�&N{h�!����d�e$K�����%a OΓ��)#0�J���T��jܠ�[���.�L��1u҆)�5'�V/�5n ��yuz�rQ���0��<���!����-ͫ�S���4�Գhg��=+��O���T�f�{�Yfd���=���z�B�(���j��X���l���͘c��jE�1`��&���]�0����q� �$|2�"��0��eq�61:�!c��}dc�������� ���]&*sQ�<�Y�|=��%�V�b��� ��v��9�\��Ǘg��g�^��y��~�k��=���w[]�zW�V����S�9͗��Hgb��I `f�a1ޞ�A�7ׯ~�l%�!A]�衻��q����"���7\�#^�+����YGs,�R��g`z ��ұ�as�=�-eCmZ<N�,�p /uU�NS!��Ҝ�pg[�t&�gB�)�"!�,b���~���:�lG�����/�W�z��� �9l���gx���2m��h��Ͷ�,���X��P���N�~ )�j�d�ϽΥ+��@�C;')�NR����s$e�Hʲ�#����1o��Z�yL(+��i�]H��2�EI��[�>��o$$��A������� _���n� /1�P���W��/J�ő�|V{��@���,ql�#T��DLK�#q�!D$$�3̻:����Ĺ�M5:�bcdt6���o����ZP]�CE�r#GN�\���U,E|K��j�^̓-�����>�w3��Á��U���! �[�D[�m��+T<v�S�9�p߈��Ƶb.�H>�� Za@nÀ���*�[x�^� Q�r6�x-��[x NZ짫�vd��J���p,Ί���y��g(_�gsH��X����,�\/�d*)�Z�~�:H/��2 j�)�`̷e��YE���N���]��zd�nN�uv� �Z�"J�9��6� jsk��� �m�!�Ɨ��枹�|@�*ns97z��V\�9�Ʒ��С������E��5O !a�l,=���;O�4�A�&a���]K���� js/admin-override-edit-refresh-searchstring.js 0000644 00000001470 15172554240 0015503 0 ustar 00 /** * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ document.addEventListener('DOMContentLoaded', () => { document.getElementById('jform_searchstring').addEventListener('focus', ({ srcElement }) => { if (!Joomla.overrider.states.refreshed) { const expired = document.getElementById('overrider-spinner').getAttribute('data-search-string-expired'); if (expired) { Joomla.overrider.refreshCache(); Joomla.overrider.states.refreshed = true; } } srcElement.classList.remove('invalid'); }, false); document.getElementById('more-results-button').addEventListener('click', () => { Joomla.overrider.searchStrings(Joomla.overrider.states.more); }, false); }); js/overrider.min.js 0000644 00000010007 15172554240 0010304 0 ustar 00 /** * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */((r,e)=>{class o{constructor(){this.states={refreshing:!1,refreshed:!1,counter:0,searchString:"",searchType:"value"},this.spinner=e.getElementById("overrider-spinner"),this.spinnerBtn=e.getElementById("overrider-spinner-btn"),this.moreResults=e.getElementById("more-results"),this.moreResultsButton=e.getElementById("more-results-button"),this.resultsContainer=e.getElementById("results-container"),this.refreshStatus=e.getElementById("refresh-status")}refreshCache(){this.states.refreshing=!0,this.refreshStatus.classList.add("show"),r.request({url:"index.php?option=com_languages&task=strings.refresh&format=json",method:"POST",headers:{"Content-Type":"application/json"},onSuccess:t=>{t.error&&t.message&&alert(t.message),t.messages&&r.renderMessages(t.messages),this.refreshStatus.classList.remove("show"),this.states.refreshing=!1},onError:()=>{alert(r.Text._("COM_LANGUAGES_VIEW_OVERRIDE_REQUEST_ERROR")),this.refreshStatus.classList.remove("show")}})}searchStrings(t){if(this.states.refreshing)return;const i=e.getElementById("jform_searchstring"),a=e.getElementById("jform_searchtype");if(t||(this.states.searchString=i.value,this.states.searchType=a.value||"value",[].slice.call(e.querySelectorAll(".language-results")).forEach(s=>{s.parentNode.removeChild(s)})),!this.states.searchString){i.classList.add("invalid");return}t?this.spinnerBtn.classList.add("show"):(this.moreResults.classList.remove("show"),[].slice.call(e.querySelectorAll("#results-container div.language-results")).forEach(s=>{s.parentNode.removeChild(s)}),this.resultsContainer.classList.add("show"),this.spinner.classList.add("show")),r.request({url:`index.php?option=com_languages&task=strings.search&format=json&searchstring=${this.states.searchString}&searchtype=${this.states.searchType}&more=${t}`,method:"POST",headers:{"Content-Type":"application/json"},onSuccess:n=>{const s=JSON.parse(n);s.error&&s.message&&alert(s.message),s.messages&&r.renderMessages(s.messages),s.data&&(s.data.results&&r.overrider.insertResults(s.data.results),s.data.more?(this.states.more=s.data.more,this.moreResultsButton.disabled=!1,this.moreResults.classList.add("show")):(this.moreResultsButton.disabled=!0,this.moreResults.classList.remove("show"))),this.spinnerBtn.classList.remove("show"),this.spinner.classList.remove("show")},onError:()=>{alert(r.Text._("COM_LANGUAGES_VIEW_OVERRIDE_REQUEST_ERROR")),this.moreResultsButton.disabled=!0,this.moreResults.classList.remove("show"),this.resultsContainer.classList.remove("show")}})}insertResults(t){this.states.counter+=1;const i=e.createElement("div");if(i.setAttribute("id",`language-results${this.states.counter}`),i.classList.add("language-results"),i.classList.add("list-group"),i.classList.add("mb-2"),i.classList.add("show"),t.forEach((a,n)=>{const s=e.createElement("a");s.setAttribute("onclick",`Joomla.overrider.selectString(${this.states.counter}${n});`),s.setAttribute("href","#"),s.classList.add("list-group-item"),s.classList.add("list-group-item-action"),s.classList.add("flex-column"),s.classList.add("align-items-start");const l=e.createElement("div");l.setAttribute("id",`override_key${this.states.counter}${n}`),l.setAttribute("title",a.file),l.classList.add("result-key"),l.innerHTML=r.sanitizeHtml(a.constant);const h=e.createElement("div");h.setAttribute("id",`override_string${this.states.counter}${n}`),h.classList.add("result-string"),h.innerHTML=r.sanitizeHtml(a.string),s.appendChild(l),s.appendChild(h),i.appendChild(s)}),!t.length){const a=e.createElement("div");a.innerText=r.Text._("COM_LANGUAGES_VIEW_OVERRIDE_NO_RESULTS"),i.appendChild(a)}this.moreResults&&this.moreResults.parentNode.insertBefore(i,this.moreResults)}selectString(t){e.getElementById("jform_key").value=e.getElementById(`override_key${t}`).innerHTML,e.getElementById("jform_override").value=e.getElementById(`override_string${t}`).innerHTML}}e.addEventListener("DOMContentLoaded",()=>{r.overrider=new o})})(Joomla,document); js/admin-language-edit-change-flag-es5.min.js.gz 0000644 00000000617 15172554240 0015350 0 ustar 00 � u�OoZ1��|��lx�kr�B�?J#**ў#�o1��l�^CQ�w�H�*���jV�ͨuMNBNJ?`-E88�q;`]�8�� ����g�`���\�\[��<9��m�h�~o�s�5���GT�R! ����pE��F�^�bp�������Cf�V��P�`1��nV3#�e öˮ���خ��(�"9~Y^Os���mG6OJ��y�Y���0�ޯ3�����P�@u�<=aY���<��UfJ�ò'id�fgc��&�ƭ���ͯJ|XQ$'��ޣn�����<�r{ + ˡ�fkeSP�Y��G������6�j=���Giq$#4>�q,�B�I��]RX�a�t�\�Q��/�>�������͙>�Vz<�TDv^ js/admin-override-edit-refresh-searchstring.min.js.gz 0000644 00000000606 15172554240 0016704 0 ustar 00 � ��AO1���Ȏv�TAAm�� P)�r�I��k�Ƴ俣MV\ �����=�d<����<��T � .�ο�C���%�pg��r�h5|���|9�l�[��R�N���[o1f �����L���*x��C�>E��D#]AF��|:�_�4?���l[cdm��uy�3��R�|����,�NR]�+6ȳ������I�NT��h�V��ǍP�خ�m�(�K&;�/q�;��vH���l�&\� �����wQ�#�P�����W-�ΰ)t��ħ�:�NO��!ujl�R���>9SjL�}[MX���3�;�v�ɹ*�V�aI���\��)~��6x�oX�G�}��_�Ǡ���N]�� �Nј� js/overrider-es5.js 0000644 00000021562 15172554240 0010224 0 ustar 00 (function () { 'use strict'; /** * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ (function (Joomla, document) { var Overrider = /*#__PURE__*/function () { function Overrider() { this.states = { refreshing: false, refreshed: false, counter: 0, searchString: '', searchType: 'value' }; this.spinner = document.getElementById('overrider-spinner'); this.spinnerBtn = document.getElementById('overrider-spinner-btn'); this.moreResults = document.getElementById('more-results'); this.moreResultsButton = document.getElementById('more-results-button'); this.resultsContainer = document.getElementById('results-container'); this.refreshStatus = document.getElementById('refresh-status'); } /** * Method for refreshing the database cache of known language strings via Ajax * * @return void * * @since 2.5 */ var _proto = Overrider.prototype; _proto.refreshCache = function refreshCache() { var _this = this; this.states.refreshing = true; this.refreshStatus.classList.add('show'); Joomla.request({ url: 'index.php?option=com_languages&task=strings.refresh&format=json', method: 'POST', headers: { 'Content-Type': 'application/json' }, onSuccess: function onSuccess(response) { if (response.error && response.message) { alert(response.message); } if (response.messages) { Joomla.renderMessages(response.messages); } _this.refreshStatus.classList.remove('show'); _this.states.refreshing = false; }, onError: function onError() { alert(Joomla.Text._('COM_LANGUAGES_VIEW_OVERRIDE_REQUEST_ERROR')); _this.refreshStatus.classList.remove('show'); } }); } /** * Method for searching known language strings via Ajax * * @param more Determines the limit start of the results * * @return void * * @since 2.5 */; _proto.searchStrings = function searchStrings(more) { var _this2 = this; // Prevent searching if the cache is refreshed at the moment if (this.states.refreshing) { return; } var formSearchString = document.getElementById('jform_searchstring'); var formSearchType = document.getElementById('jform_searchtype'); // Only update the used searchstring and searchtype if the search button // was used to start the search (that will be the case if 'more' is null) if (!more) { this.states.searchString = formSearchString.value; this.states.searchType = formSearchType.value || 'value'; // Remove the old results var oldResults = [].slice.call(document.querySelectorAll('.language-results')); oldResults.forEach(function (result) { result.parentNode.removeChild(result); }); } if (!this.states.searchString) { formSearchString.classList.add('invalid'); return; } if (more) { // If 'more' is greater than 0 we have already displayed some results for // the current searchstring, so display the spinner at the more link this.spinnerBtn.classList.add('show'); } else { // Otherwise it is a new searchstring and we have to remove all previous results first this.moreResults.classList.remove('show'); var childs = [].slice.call(document.querySelectorAll('#results-container div.language-results')); childs.forEach(function (child) { child.parentNode.removeChild(child); }); this.resultsContainer.classList.add('show'); this.spinner.classList.add('show'); } Joomla.request({ url: "index.php?option=com_languages&task=strings.search&format=json&searchstring=" + this.states.searchString + "&searchtype=" + this.states.searchType + "&more=" + more, method: 'POST', headers: { 'Content-Type': 'application/json' }, onSuccess: function onSuccess(resp) { var response = JSON.parse(resp); if (response.error && response.message) { alert(response.message); } if (response.messages) { Joomla.renderMessages(response.messages); } if (response.data) { if (response.data.results) { Joomla.overrider.insertResults(response.data.results); } if (response.data.more) { // If there are more results than the sent ones // display the more link _this2.states.more = response.data.more; _this2.moreResultsButton.disabled = false; _this2.moreResults.classList.add('show'); } else { _this2.moreResultsButton.disabled = true; _this2.moreResults.classList.remove('show'); } } _this2.spinnerBtn.classList.remove('show'); _this2.spinner.classList.remove('show'); }, onError: function onError() { alert(Joomla.Text._('COM_LANGUAGES_VIEW_OVERRIDE_REQUEST_ERROR')); _this2.moreResultsButton.disabled = true; _this2.moreResults.classList.remove('show'); _this2.resultsContainer.classList.remove('show'); } }); } /** * Method inserting the received results into the results container * * @param results An array of search result objects * * @return void * * @since 2.5 */; _proto.insertResults = function insertResults(results) { var _this3 = this; // For creating an individual ID for each result we use a counter this.states.counter += 1; // Create a container into which all the results will be inserted var resultsDiv = document.createElement('div'); resultsDiv.setAttribute('id', "language-results" + this.states.counter); resultsDiv.classList.add('language-results'); resultsDiv.classList.add('list-group'); resultsDiv.classList.add('mb-2'); resultsDiv.classList.add('show'); // Create some elements for each result and insert it into the container results.forEach(function (item, index) { var a = document.createElement('a'); a.setAttribute('onclick', "Joomla.overrider.selectString(" + _this3.states.counter + index + ");"); a.setAttribute('href', '#'); a.classList.add('list-group-item'); a.classList.add('list-group-item-action'); a.classList.add('flex-column'); a.classList.add('align-items-start'); var key = document.createElement('div'); key.setAttribute('id', "override_key" + _this3.states.counter + index); key.setAttribute('title', item.file); key.classList.add('result-key'); key.innerHTML = Joomla.sanitizeHtml(item.constant); var string = document.createElement('div'); string.setAttribute('id', "override_string" + _this3.states.counter + index); string.classList.add('result-string'); string.innerHTML = Joomla.sanitizeHtml(item.string); a.appendChild(key); a.appendChild(string); resultsDiv.appendChild(a); }); // If there aren't any results display an appropriate message if (!results.length) { var noresult = document.createElement('div'); noresult.innerText = Joomla.Text._('COM_LANGUAGES_VIEW_OVERRIDE_NO_RESULTS'); resultsDiv.appendChild(noresult); } if (this.moreResults) { this.moreResults.parentNode.insertBefore(resultsDiv, this.moreResults); } } /** * Inserts a specific constant/value pair into the form and scrolls the page back to the top * * @param id The ID of the element which was selected for insertion * * @return void * * @since 2.5 */ // eslint-disable-next-line class-methods-use-this ; _proto.selectString = function selectString(id) { document.getElementById('jform_key').value = document.getElementById("override_key" + id).innerHTML; document.getElementById('jform_override').value = document.getElementById("override_string" + id).innerHTML; }; return Overrider; }(); document.addEventListener('DOMContentLoaded', function () { Joomla.overrider = new Overrider(); }); })(Joomla, document); })(); languages.xml 0000644 00000002175 15172750553 0007253 0 ustar 00 <?xml version="1.0" encoding="UTF-8"?> <extension type="component" method="upgrade"> <name>com_languages</name> <author>Joomla! Project</author> <creationDate>2006-04</creationDate> <copyright>(C) 2006 Open Source Matters, Inc.</copyright> <license>GNU General Public License version 2 or later; see LICENSE.txt</license> <authorEmail>admin@joomla.org</authorEmail> <authorUrl>www.joomla.org</authorUrl> <version>4.0.0</version> <description>COM_LANGUAGES_XML_DESCRIPTION</description> <namespace path="src">Joomla\Component\Languages</namespace> <media destination="com_languages" folder="media"> <folder>css</folder> <folder>js</folder> </media> <administration> <files folder="admin"> <filename>access.xml</filename> <filename>config.xml</filename> <filename>languages.xml</filename> <folder>forms</folder> <folder>services</folder> <folder>src</folder> <folder>tmpl</folder> </files> <languages folder="admin"> <language tag="en-GB">language/en-GB/com_languages.ini</language> <language tag="en-GB">language/en-GB/com_languages.sys.ini</language> </languages> </administration> </extension> src/Model/LanguagesModel.php 0000644 00000016142 15172750553 0012011 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Administrator\Model; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\MVC\Factory\MVCFactoryInterface; use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\Table\Table; use Joomla\Database\DatabaseQuery; use Joomla\Database\ParameterType; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Languages Model Class * * @since 1.6 */ class LanguagesModel extends ListModel { /** * Constructor. * * @param array $config An optional associative array of configuration settings. * @param MVCFactoryInterface $factory The factory. * * @see \Joomla\CMS\MVC\Model\BaseDatabaseModel * @since 3.2 */ public function __construct($config = [], MVCFactoryInterface $factory = null) { if (empty($config['filter_fields'])) { $config['filter_fields'] = [ 'lang_id', 'a.lang_id', 'lang_code', 'a.lang_code', 'title', 'a.title', 'title_native', 'a.title_native', 'sef', 'a.sef', 'image', 'a.image', 'published', 'a.published', 'ordering', 'a.ordering', 'access', 'a.access', 'access_level', 'home', 'l.home', ]; } parent::__construct($config, $factory); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @param string $ordering An optional ordering field. * @param string $direction An optional direction (asc|desc). * * @return void * * @since 1.6 */ protected function populateState($ordering = 'a.ordering', $direction = 'asc') { // Load the parameters. $params = ComponentHelper::getParams('com_languages'); $this->setState('params', $params); // List state information. parent::populateState($ordering, $direction); } /** * Method to get a store id based on model configuration state. * * This is necessary because the model is used by the component and * different modules that might need different sets of data or different * ordering requirements. * * @param string $id A prefix for the store id. * * @return string A store id. * * @since 1.6 */ protected function getStoreId($id = '') { // Compile the store id. $id .= ':' . $this->getState('filter.search'); $id .= ':' . $this->getState('filter.access'); $id .= ':' . $this->getState('filter.published'); return parent::getStoreId($id); } /** * Method to build an SQL query to load the list data. * * @return DatabaseQuery An SQL query * * @since 1.6 */ protected function getListQuery() { // Create a new query object. $db = $this->getDatabase(); $query = $db->getQuery(true); // Select all fields from the languages table. $query->select( $this->getState( 'list.select', [ $db->quoteName('a') . '.*', ] ) ) ->select( [ $db->quoteName('l.home'), $db->quoteName('ag.title', 'access_level'), ] ) ->from($db->quoteName('#__languages', 'a')) ->join('LEFT', $db->quoteName('#__viewlevels', 'ag'), $db->quoteName('ag.id') . ' = ' . $db->quoteName('a.access')) ->join( 'LEFT', $db->quoteName('#__menu', 'l'), $db->quoteName('l.language') . ' = ' . $db->quoteName('a.lang_code') . ' AND ' . $db->quoteName('l.home') . ' = 1 AND ' . $db->quoteName('l.language') . ' <> ' . $db->quote('*') ); // Filter on the published state. $published = (string) $this->getState('filter.published'); if (is_numeric($published)) { $published = (int) $published; $query->where($db->quoteName('a.published') . ' = :published') ->bind(':published', $published, ParameterType::INTEGER); } elseif ($published === '') { $query->where($db->quoteName('a.published') . ' IN (0, 1)'); } // Filter by search in title. if ($search = $this->getState('filter.search')) { $search = '%' . str_replace(' ', '%', trim($search)) . '%'; $query->where($db->quoteName('a.title') . ' LIKE :search') ->bind(':search', $search); } // Filter by access level. if ($access = (int) $this->getState('filter.access')) { $query->where($db->quoteName('a.access') . ' = :access') ->bind(':access', $access, ParameterType::INTEGER); } // Add the list ordering clause. $query->order($db->quoteName($db->escape($this->getState('list.ordering', 'a.ordering'))) . ' ' . $db->escape($this->getState('list.direction', 'ASC'))); return $query; } /** * Set the published language(s). * * @param array $cid An array of language IDs. * @param integer $value The value of the published state. * * @return boolean True on success, false otherwise. * * @since 1.6 */ public function setPublished($cid, $value = 0) { return Table::getInstance('Language', 'Joomla\\CMS\\Table\\')->publish($cid, $value); } /** * Method to delete records. * * @param array $pks An array of item primary keys. * * @return boolean Returns true on success, false on failure. * * @since 1.6 */ public function delete($pks) { // Sanitize the array. $pks = (array) $pks; // Get a row instance. $table = Table::getInstance('Language', 'Joomla\\CMS\\Table\\'); // Iterate the items to delete each one. foreach ($pks as $itemId) { if (!$table->delete((int) $itemId)) { $this->setError($table->getError()); return false; } } // Clean the cache. $this->cleanCache(); return true; } /** * Custom clean cache method, 2 places for 2 clients. * * @param string $group Optional cache group name. * @param integer $clientId No longer used, will be removed without replacement * @deprecated 4.3 will be removed in 6.0 * * @return void * * @since 1.6 */ protected function cleanCache($group = null, $clientId = 0) { parent::cleanCache('_system'); parent::cleanCache('com_languages'); } } src/Model/OverridesModel.php 0000644 00000020224 15172750553 0012041 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Administrator\Model; use Joomla\CMS\Factory; use Joomla\CMS\Language\LanguageHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Factory\MVCFactoryInterface; use Joomla\CMS\MVC\Model\ListModel; use Joomla\Filesystem\File; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Languages Overrides Model * * @since 2.5 */ class OverridesModel extends ListModel { /** * Constructor. * * @param array $config An optional associative array of configuration settings. * @param MVCFactoryInterface $factory The factory. * * @see \Joomla\CMS\MVC\Model\BaseDatabaseModel * @since 2.5 */ public function __construct($config = [], MVCFactoryInterface $factory = null) { if (empty($config['filter_fields'])) { $config['filter_fields'] = [ 'key', 'text', ]; } parent::__construct($config, $factory); } /** * Retrieves the overrides data * * @param boolean $all True if all overrides shall be returned without considering pagination, defaults to false * * @return array Array of objects containing the overrides of the override.ini file * * @since 2.5 */ public function getOverrides($all = false) { // Get a storage key. $store = $this->getStoreId(); // Try to load the data from internal storage. if (!empty($this->cache[$store])) { return $this->cache[$store]; } $client = strtoupper($this->getState('filter.client')); // Parse the override.ini file in order to get the keys and strings. $fileName = constant('JPATH_' . $client) . '/language/overrides/' . $this->getState('filter.language') . '.override.ini'; $strings = LanguageHelper::parseIniFile($fileName); // Delete the override.ini file if empty. if (file_exists($fileName) && $strings === []) { File::delete($fileName); } // Filter the loaded strings according to the search box. $search = $this->getState('filter.search'); if ($search != '') { $search = preg_quote($search, '~'); $matchvals = preg_grep('~' . $search . '~i', $strings); $matchkeys = array_intersect_key($strings, array_flip(preg_grep('~' . $search . '~i', array_keys($strings)))); $strings = array_merge($matchvals, $matchkeys); } // Consider the ordering if ($this->getState('list.ordering') == 'text') { if (strtoupper($this->getState('list.direction')) == 'DESC') { arsort($strings); } else { asort($strings); } } else { if (strtoupper($this->getState('list.direction')) == 'DESC') { krsort($strings); } else { ksort($strings); } } // Consider the pagination. if (!$all && $this->getState('list.limit') && $this->getTotal() > $this->getState('list.limit')) { $strings = array_slice($strings, $this->getStart(), $this->getState('list.limit'), true); } // Add the items to the internal cache. $this->cache[$store] = $strings; return $this->cache[$store]; } /** * Method to get the total number of overrides. * * @return integer The total number of overrides. * * @since 2.5 */ public function getTotal() { // Get a storage key. $store = $this->getStoreId('getTotal'); // Try to load the data from internal storage if (!empty($this->cache[$store])) { return $this->cache[$store]; } // Add the total to the internal cache. $this->cache[$store] = count($this->getOverrides(true)); return $this->cache[$store]; } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @param string $ordering An optional ordering field. * @param string $direction An optional direction (asc|desc). * * @return void * * @since 2.5 */ protected function populateState($ordering = 'key', $direction = 'asc') { // We call populate state first so that we can then set the filter.client and filter.language properties in afterwards parent::populateState($ordering, $direction); $app = Factory::getApplication(); if ($app->isClient('api')) { return; } $language_client = $this->getUserStateFromRequest('com_languages.overrides.language_client', 'language_client', '', 'cmd'); $client = substr($language_client, -1); $language = substr($language_client, 0, -1); // Sets the search filter. $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); $this->setState('filter.search', $search); $this->setState('language_client', $language . $client); $this->setState('filter.client', $client ? 'administrator' : 'site'); $this->setState('filter.language', $language); // Add the 'language_client' value to the session to display a message if none selected $app->setUserState('com_languages.overrides.language_client', $language . $client); // Add filters to the session because they won't be stored there by 'getUserStateFromRequest' if they aren't in the current request. $app->setUserState('com_languages.overrides.filter.client', $client); $app->setUserState('com_languages.overrides.filter.language', $language); } /** * Method to delete one or more overrides. * * @param array $cids Array of keys to delete. * * @return integer Number of successfully deleted overrides, boolean false if an error occurred. * * @since 2.5 */ public function delete($cids) { // Check permissions first. if (!$this->getCurrentUser()->authorise('core.delete', 'com_languages')) { $this->setError(Text::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED')); return false; } $app = Factory::getApplication(); if ($app->isClient('api')) { $cids = (array) $cids; $client = $this->getState('filter.client'); } else { $filterclient = Factory::getApplication()->getUserState('com_languages.overrides.filter.client'); $client = $filterclient == 0 ? 'site' : 'administrator'; } // Parse the override.ini file in order to get the keys and strings. $fileName = constant('JPATH_' . strtoupper($client)) . '/language/overrides/' . $this->getState('filter.language') . '.override.ini'; $strings = LanguageHelper::parseIniFile($fileName); // Unset strings that shall be deleted foreach ($cids as $key) { if (isset($strings[$key])) { unset($strings[$key]); } } // Write override.ini file with the strings. if (LanguageHelper::saveToIniFile($fileName, $strings) === false) { return false; } $this->cleanCache(); return count($cids); } /** * Removes all of the cached strings from the table. * * @return boolean result of operation * * @since 3.4.2 */ public function purge() { $db = $this->getDatabase(); // Note: TRUNCATE is a DDL operation // This may or may not mean depending on your database try { $db->truncateTable('#__overrider'); } catch (\RuntimeException $e) { return $e; } Factory::getApplication()->enqueueMessage(Text::_('COM_LANGUAGES_VIEW_OVERRIDES_PURGE_SUCCESS')); } } src/Model/InstalledModel.php 0000644 00000025751 15172750553 0012030 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Administrator\Model; use Joomla\CMS\Application\ApplicationHelper; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; use Joomla\CMS\Filesystem\Folder; use Joomla\CMS\Language\LanguageHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Factory\MVCFactoryInterface; use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\Table\Table; use Joomla\Utilities\ArrayHelper; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Languages Component Languages Model * * @since 1.6 */ class InstalledModel extends ListModel { /** * @var object user object */ protected $user = null; /** * @var string option name */ protected $option = null; /** * @var array languages description */ protected $data = null; /** * @var integer total number of languages */ protected $total = null; /** * @var string language path */ protected $path = null; /** * Constructor. * * @param array $config An optional associative array of configuration settings. * @param MVCFactoryInterface $factory The factory. * * @see \Joomla\CMS\MVC\Model\BaseDatabaseModel * @since 3.2 */ public function __construct($config = [], MVCFactoryInterface $factory = null) { if (empty($config['filter_fields'])) { $config['filter_fields'] = [ 'name', 'nativeName', 'language', 'author', 'published', 'version', 'creationDate', 'author', 'authorEmail', 'extension_id', 'client_id', ]; } parent::__construct($config, $factory); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @param string $ordering An optional ordering field. * @param string $direction An optional direction (asc|desc). * * @return void * * @since 1.6 */ protected function populateState($ordering = 'name', $direction = 'asc') { // Load the filter state. $this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string')); // Special case for client id. $clientId = (int) $this->getUserStateFromRequest($this->context . '.client_id', 'client_id', 0, 'int'); $clientId = (!in_array($clientId, [0, 1])) ? 0 : $clientId; $this->setState('client_id', $clientId); // Load the parameters. $params = ComponentHelper::getParams('com_languages'); $this->setState('params', $params); // List state information. parent::populateState($ordering, $direction); } /** * Method to get a store id based on model configuration state. * * This is necessary because the model is used by the component and * different modules that might need different sets of data or different * ordering requirements. * * @param string $id A prefix for the store id. * * @return string A store id. * * @since 1.6 */ protected function getStoreId($id = '') { // Compile the store id. $id .= ':' . $this->getState('client_id'); $id .= ':' . $this->getState('filter.search'); return parent::getStoreId($id); } /** * Method to get the client object. * * @return object * * @since 1.6 */ public function getClient() { return ApplicationHelper::getClientInfo($this->getState('client_id', 0)); } /** * Method to get the option. * * @return object * * @since 1.6 */ public function getOption() { $option = $this->getState('option'); return $option; } /** * Method to get Languages item data. * * @return array * * @since 1.6 */ public function getData() { // Fetch language data if not fetched yet. if (is_null($this->data)) { $this->data = []; $isCurrentLanguageRtl = Factory::getLanguage()->isRtl(); $params = ComponentHelper::getParams('com_languages'); $installedLanguages = LanguageHelper::getInstalledLanguages(null, true, true, null, null, null); // Compute all the languages. foreach ($installedLanguages as $clientId => $languages) { $defaultLanguage = $params->get(ApplicationHelper::getClientInfo($clientId)->name, 'en-GB'); foreach ($languages as $lang) { $row = new \stdClass(); $row->language = $lang->element; $row->name = $lang->metadata['name']; $row->nativeName = $lang->metadata['nativeName'] ?? '-'; $row->client_id = (int) $lang->client_id; $row->extension_id = (int) $lang->extension_id; $row->author = $lang->manifest['author']; $row->creationDate = $lang->manifest['creationDate']; $row->authorEmail = $lang->manifest['authorEmail']; $row->version = $lang->manifest['version']; $row->published = $defaultLanguage === $row->language ? 1 : 0; $row->checked_out = null; // Fix wrongly set parentheses in RTL languages if ($isCurrentLanguageRtl) { $row->name = html_entity_decode($row->name . '‎', ENT_QUOTES, 'UTF-8'); $row->nativeName = html_entity_decode($row->nativeName . '‎', ENT_QUOTES, 'UTF-8'); } $this->data[] = $row; } } } $installedLanguages = array_merge($this->data); // Process filters. $clientId = (int) $this->getState('client_id'); $search = $this->getState('filter.search'); foreach ($installedLanguages as $key => $installedLanguage) { // Filter by client id. if (in_array($clientId, [0, 1])) { if ($installedLanguage->client_id !== $clientId) { unset($installedLanguages[$key]); continue; } } // Filter by search term. if (!empty($search)) { if ( stripos($installedLanguage->name, $search) === false && stripos($installedLanguage->nativeName, $search) === false && stripos($installedLanguage->language, $search) === false ) { unset($installedLanguages[$key]); } } } // Process ordering. $listOrder = $this->getState('list.ordering', 'name'); $listDirn = $this->getState('list.direction', 'ASC'); $installedLanguages = ArrayHelper::sortObjects($installedLanguages, $listOrder, strtolower($listDirn) === 'desc' ? -1 : 1, true, true); // Process pagination. $limit = (int) $this->getState('list.limit', 25); // Sets the total for pagination. $this->total = count($installedLanguages); if ($limit !== 0) { $start = (int) $this->getState('list.start', 0); return array_slice($installedLanguages, $start, $limit); } return $installedLanguages; } /** * Method to get the total number of Languages items. * * @return integer * * @since 1.6 */ public function getTotal() { if (is_null($this->total)) { $this->getData(); } return $this->total; } /** * Method to set the default language. * * @param integer $cid Id of the language to publish. * * @return boolean * * @since 1.6 */ public function publish($cid) { if ($cid) { $client = $this->getClient(); $params = ComponentHelper::getParams('com_languages'); $params->set($client->name, $cid); $table = Table::getInstance('extension', 'Joomla\\CMS\\Table\\'); $id = $table->find(['element' => 'com_languages']); // Load. if (!$table->load($id)) { $this->setError($table->getError()); return false; } $table->params = (string) $params; // Pre-save checks. if (!$table->check()) { $this->setError($table->getError()); return false; } // Save the changes. if (!$table->store()) { $this->setError($table->getError()); return false; } } else { $this->setError(Text::_('COM_LANGUAGES_ERR_NO_LANGUAGE_SELECTED')); return false; } // Clean the cache of com_languages and component cache. $this->cleanCache(); $this->cleanCache('_system'); return true; } /** * Method to get the folders. * * @return array Languages folders. * * @since 1.6 */ protected function getFolders() { if (is_null($this->folders)) { $path = $this->getPath(); $this->folders = Folder::folders($path, '.', false, false, ['.svn', 'CVS', '.DS_Store', '__MACOSX', 'pdf_fonts', 'overrides']); } return $this->folders; } /** * Method to get the path. * * @return string The path to the languages folders. * * @since 1.6 */ protected function getPath() { if (is_null($this->path)) { $client = $this->getClient(); $this->path = LanguageHelper::getLanguagePath($client->path); } return $this->path; } /** * Method to switch the administrator language. * * @param string $cid The language tag. * * @return boolean * * @since 3.5 */ public function switchAdminLanguage($cid) { if ($cid) { $client = $this->getClient(); if ($client->name == 'administrator') { Factory::getApplication()->setUserState('application.lang', $cid); } } else { Factory::getApplication()->enqueueMessage(Text::_('COM_LANGUAGES_ERR_NO_LANGUAGE_SELECTED'), 'error'); return false; } return true; } } src/Model/LanguageModel.php 0000644 00000017316 15172750553 0011632 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Administrator\Model; use Joomla\CMS\Application\ApplicationHelper; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Factory\MVCFactoryInterface; use Joomla\CMS\MVC\Model\AdminModel; use Joomla\CMS\Object\CMSObject; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Table\Table; use Joomla\Utilities\ArrayHelper; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Languages Component Language Model * * @since 1.5 */ class LanguageModel extends AdminModel { /** * Constructor. * * @param array $config An optional associative array of configuration settings. * @param MVCFactoryInterface $factory The factory. * * @see \Joomla\CMS\MVC\Model\BaseDatabaseModel * @since 3.2 */ public function __construct($config = [], MVCFactoryInterface $factory = null) { $config = array_merge( [ 'event_after_save' => 'onExtensionAfterSave', 'event_before_save' => 'onExtensionBeforeSave', 'events_map' => [ 'save' => 'extension', ], ], $config ); parent::__construct($config, $factory); } /** * Override to get the table. * * @param string $name Name of the table. * @param string $prefix Table name prefix. * @param array $options Array of options. * * @return Table * * @since 1.6 */ public function getTable($name = '', $prefix = '', $options = []) { return Table::getInstance('Language', 'Joomla\\CMS\\Table\\'); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @return void * * @since 1.6 */ protected function populateState() { $app = Factory::getApplication(); $params = ComponentHelper::getParams('com_languages'); // Load the User state. $langId = $app->getInput()->getInt('lang_id'); $this->setState('language.id', $langId); // Load the parameters. $this->setState('params', $params); } /** * Method to get a member item. * * @param integer $langId The id of the member to get. * * @return mixed User data object on success, false on failure. * * @since 1.0 */ public function getItem($langId = null) { $langId = (!empty($langId)) ? $langId : (int) $this->getState('language.id'); // Get a member row instance. $table = $this->getTable(); // Attempt to load the row. $return = $table->load($langId); // Check for a table object error. if ($return === false && $table->getError()) { $this->setError($table->getError()); return false; } // Set a valid accesslevel in case '0' is stored due to a bug in the installation SQL (was fixed with PR 2714). if ($table->access == '0') { $table->access = (int) Factory::getApplication()->get('access'); } $properties = $table->getProperties(1); $value = ArrayHelper::toObject($properties, CMSObject::class); return $value; } /** * Method to get the group form. * * @param array $data Data for the form. * @param boolean $loadData True if the form is to load its own data (default case), false if not. * * @return \Joomla\CMS\Form\Form|bool A Form object on success, false on failure. * * @since 1.6 */ public function getForm($data = [], $loadData = true) { // Get the form. $form = $this->loadForm('com_languages.language', 'language', ['control' => 'jform', 'load_data' => $loadData]); if (empty($form)) { return false; } return $form; } /** * Method to get the data that should be injected in the form. * * @return mixed The data for the form. * * @since 1.6 */ protected function loadFormData() { // Check the session for previously entered form data. $data = Factory::getApplication()->getUserState('com_languages.edit.language.data', []); if (empty($data)) { $data = $this->getItem(); } $this->preprocessData('com_languages.language', $data); return $data; } /** * Method to save the form data. * * @param array $data The form data. * * @return boolean True on success. * * @since 1.6 */ public function save($data) { $langId = (!empty($data['lang_id'])) ? $data['lang_id'] : (int) $this->getState('language.id'); $isNew = true; PluginHelper::importPlugin($this->events_map['save']); $table = $this->getTable(); $context = $this->option . '.' . $this->name; // Load the row if saving an existing item. if ($langId > 0) { $table->load($langId); $isNew = false; } // Prevent white spaces, including East Asian double bytes. $spaces = ['/\xE3\x80\x80/', ' ']; $data['lang_code'] = str_replace($spaces, '', $data['lang_code']); // Prevent saving an incorrect language tag if (!preg_match('#\b([a-z]{2,3})[-]([A-Z]{2})\b#', $data['lang_code'])) { $this->setError(Text::_('COM_LANGUAGES_ERROR_LANG_TAG')); return false; } $data['sef'] = str_replace($spaces, '', $data['sef']); $data['sef'] = ApplicationHelper::stringURLSafe($data['sef']); // Prevent saving an empty url language code if ($data['sef'] === '') { $this->setError(Text::_('COM_LANGUAGES_ERROR_SEF')); return false; } // Bind the data. if (!$table->bind($data)) { $this->setError($table->getError()); return false; } // Check the data. if (!$table->check()) { $this->setError($table->getError()); return false; } // Trigger the before save event. $result = Factory::getApplication()->triggerEvent($this->event_before_save, [$context, &$table, $isNew]); // Check the event responses. if (in_array(false, $result, true)) { $this->setError($table->getError()); return false; } // Store the data. if (!$table->store()) { $this->setError($table->getError()); return false; } // Trigger the after save event. Factory::getApplication()->triggerEvent($this->event_after_save, [$context, &$table, $isNew]); $this->setState('language.id', $table->lang_id); // Clean the cache. $this->cleanCache(); return true; } /** * Custom clean cache method. * * @param string $group Optional cache group name. * @param integer $clientId No longer used, will be removed without replacement * @deprecated 4.3 will be removed in 6.0 * * @return void * * @since 1.6 */ protected function cleanCache($group = null, $clientId = 0) { parent::cleanCache('_system'); parent::cleanCache('com_languages'); } } src/Model/OverrideModel.php 0000644 00000016525 15172750553 0011667 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Administrator\Model; use Joomla\CMS\Factory; use Joomla\CMS\Filesystem\Path; use Joomla\CMS\Language\Language; use Joomla\CMS\Language\LanguageHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Model\AdminModel; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Languages Override Model * * @since 2.5 */ class OverrideModel extends AdminModel { /** * Method to get the record form. * * @param array $data Data for the form. * @param boolean $loadData True if the form is to load its own data (default case), false if not. * * @return \Joomla\CMS\Form\Form|bool A Form object on success, false on failure. * * @since 2.5 */ public function getForm($data = [], $loadData = true) { // Get the form. $form = $this->loadForm('com_languages.override', 'override', ['control' => 'jform', 'load_data' => $loadData]); if (empty($form)) { return false; } $client = $this->getState('filter.client', 'site'); $language = $this->getState('filter.language', 'en-GB'); $langName = Language::getInstance($language)->getName(); if (!$langName) { // If a language only exists in frontend, its metadata cannot be // loaded in backend at the moment, so fall back to the language tag. $langName = $language; } $form->setValue('client', null, Text::_('COM_LANGUAGES_VIEW_OVERRIDE_CLIENT_' . strtoupper($client))); $form->setValue('language', null, Text::sprintf('COM_LANGUAGES_VIEW_OVERRIDE_LANGUAGE', $langName, $language)); $form->setValue('file', null, Path::clean(constant('JPATH_' . strtoupper($client)) . '/language/overrides/' . $language . '.override.ini')); return $form; } /** * Method to get the data that should be injected in the form. * * @return mixed The data for the form. * * @since 2.5 */ protected function loadFormData() { // Check the session for previously entered form data. $data = Factory::getApplication()->getUserState('com_languages.edit.override.data', []); if (empty($data)) { $data = $this->getItem(); } $this->preprocessData('com_languages.override', $data); return $data; } /** * Method to get a single record. * * @param string $pk The key name. * * @return mixed Object on success, false otherwise. * * @since 2.5 */ public function getItem($pk = null) { $input = Factory::getApplication()->getInput(); $pk = !empty($pk) ? $pk : $input->get('id'); $fileName = constant('JPATH_' . strtoupper($this->getState('filter.client'))) . '/language/overrides/' . $this->getState('filter.language', 'en-GB') . '.override.ini'; $strings = LanguageHelper::parseIniFile($fileName); $result = new \stdClass(); $result->key = ''; $result->override = ''; if (isset($strings[$pk])) { $result->key = $pk; $result->override = $strings[$pk]; } $oppositeFileName = constant('JPATH_' . strtoupper($this->getState('filter.client') == 'site' ? 'administrator' : 'site')) . '/language/overrides/' . $this->getState('filter.language', 'en-GB') . '.override.ini'; $oppositeStrings = LanguageHelper::parseIniFile($oppositeFileName); $result->both = isset($oppositeStrings[$pk]) && ($oppositeStrings[$pk] == $strings[$pk]); return $result; } /** * Method to save the form data. * * @param array $data The form data. * @param boolean $oppositeClient Indicates whether the override should not be created for the current client. * * @return boolean True on success, false otherwise. * * @since 2.5 */ public function save($data, $oppositeClient = false) { $app = Factory::getApplication(); if ($app->isClient('api')) { $client = $this->getState('filter.client'); $language = $this->getState('filter.language'); } else { $client = $app->getUserState('com_languages.overrides.filter.client', 0); $language = $app->getUserState('com_languages.overrides.filter.language', 'en-GB'); } // If the override should be created for both. if ($oppositeClient) { $client = 1 - $client; } // Return false if the constant is a reserved word, i.e. YES, NO, NULL, FALSE, ON, OFF, NONE, TRUE $reservedWords = ['YES', 'NO', 'NULL', 'FALSE', 'ON', 'OFF', 'NONE', 'TRUE']; if (in_array($data['key'], $reservedWords)) { $this->setError(Text::_('COM_LANGUAGES_OVERRIDE_ERROR_RESERVED_WORDS')); return false; } $client = $client ? 'administrator' : 'site'; // Parse the override.ini file in order to get the keys and strings. $fileName = constant('JPATH_' . strtoupper($client)) . '/language/overrides/' . $language . '.override.ini'; $strings = LanguageHelper::parseIniFile($fileName); if (isset($strings[$data['id']])) { // If an existent string was edited check whether // the name of the constant is still the same. if ($data['key'] == $data['id']) { // If yes, simply override it. $strings[$data['key']] = $data['override']; } else { // If no, delete the old string and prepend the new one. unset($strings[$data['id']]); $strings = [$data['key'] => $data['override']] + $strings; } } else { // If it is a new override simply prepend it. $strings = [$data['key'] => $data['override']] + $strings; } // Write override.ini file with the strings. if (LanguageHelper::saveToIniFile($fileName, $strings) === false) { return false; } // If the override should be stored for both clients save // it also for the other one and prevent endless recursion. if (isset($data['both']) && $data['both'] && !$oppositeClient) { return $this->save($data, true); } return true; } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @return void * * @since 2.5 */ protected function populateState() { $app = Factory::getApplication(); if ($app->isClient('api')) { return; } $client = $app->getUserStateFromRequest('com_languages.overrides.filter.client', 'filter_client', 0, 'int') ? 'administrator' : 'site'; $this->setState('filter.client', $client); $language = $app->getUserStateFromRequest('com_languages.overrides.filter.language', 'filter_language', 'en-GB', 'cmd'); $this->setState('filter.language', $language); } } src/Model/StringsModel.php 0000644 00000013510 15172750553 0011530 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Administrator\Model; use Joomla\CMS\Factory; use Joomla\CMS\Filesystem\Folder; use Joomla\CMS\Filesystem\Path; use Joomla\CMS\Filter\InputFilter; use Joomla\CMS\Language\LanguageHelper; use Joomla\CMS\MVC\Model\BaseDatabaseModel; use Joomla\Database\ParameterType; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Languages Strings Model * * @since 2.5 */ class StringsModel extends BaseDatabaseModel { /** * Method for refreshing the cache in the database with the known language strings. * * @return boolean|\Exception True on success, \Exception object otherwise. * * @since 2.5 */ public function refresh() { $app = Factory::getApplication(); $db = $this->getDatabase(); $app->setUserState('com_languages.overrides.cachedtime', null); // Empty the database cache first. try { $db->truncateTable('#__overrider'); } catch (\RuntimeException $e) { return $e; } // Create the insert query. $query = $db->getQuery(true) ->insert($db->quoteName('#__overrider')) ->columns( [ $db->quoteName('constant'), $db->quoteName('string'), $db->quoteName('file'), ] ); // Initialize some variables. $client = $app->getUserState('com_languages.overrides.filter.client', 'site') ? 'administrator' : 'site'; $language = $app->getUserState('com_languages.overrides.filter.language', 'en-GB'); $base = constant('JPATH_' . strtoupper($client)); $path = $base . '/language/' . $language; $files = []; // Parse common language directory. if (is_dir($path)) { $files = Folder::files($path, '.*ini$', false, true); } // Parse language directories of components. $files = array_merge($files, Folder::files($base . '/components', '.*ini$', 3, true)); // Parse language directories of modules. $files = array_merge($files, Folder::files($base . '/modules', '.*ini$', 3, true)); // Parse language directories of templates. $files = array_merge($files, Folder::files($base . '/templates', '.*ini$', 3, true)); // Parse language directories of plugins. $files = array_merge($files, Folder::files(JPATH_PLUGINS, '.*ini$', 4, true)); // Parse all found ini files and add the strings to the database cache. foreach ($files as $file) { // Only process if language file is for selected language if (strpos($file, $language, strlen($base)) === false) { continue; } $strings = LanguageHelper::parseIniFile($file); if ($strings) { $file = Path::clean($file); $query->clear('values') ->clear('bounded'); foreach ($strings as $key => $string) { $query->values(implode(',', $query->bindArray([$key, $string, $file], ParameterType::STRING))); } try { $db->setQuery($query); $db->execute(); } catch (\RuntimeException $e) { return $e; } } } // Update the cached time. $app->setUserState('com_languages.overrides.cachedtime.' . $client . '.' . $language, time()); return true; } /** * Method for searching language strings. * * @return array|\Exception Array of results on success, \Exception object otherwise. * * @since 2.5 */ public function search() { $results = []; $input = Factory::getApplication()->getInput(); $filter = InputFilter::getInstance(); $db = $this->getDatabase(); $searchTerm = $input->getString('searchstring'); $limitstart = $input->getInt('more'); try { $searchstring = '%' . $filter->clean($searchTerm, 'TRIM') . '%'; // Create the search query. $query = $db->getQuery(true) ->select( [ $db->quoteName('constant'), $db->quoteName('string'), $db->quoteName('file'), ] ) ->from($db->quoteName('#__overrider')); if ($input->get('searchtype') === 'constant') { $query->where($db->quoteName('constant') . ' LIKE :search'); } else { $query->where($db->quoteName('string') . ' LIKE :search'); } $query->bind(':search', $searchstring); // Consider the limitstart according to the 'more' parameter and load the results. $query->setLimit(10, $limitstart); $db->setQuery($query); $results['results'] = $db->loadObjectList(); // Check whether there are more results than already loaded. $query->clear('select') ->clear('limit') ->select('COUNT(' . $db->quoteName('id') . ')'); $db->setQuery($query); if ($db->loadResult() > $limitstart + 10) { // If this is set a 'More Results' link will be displayed in the view. $results['more'] = $limitstart + 10; } } catch (\RuntimeException $e) { return $e; } return $results; } } src/View/Override/HtmlView.php 0000644 00000007643 15172750553 0012320 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Administrator\View\Override; use Joomla\CMS\Factory; use Joomla\CMS\Helper\ContentHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\View\GenericDataException; use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Toolbar\ToolbarHelper; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * View to edit a language override * * @since 2.5 */ class HtmlView extends BaseHtmlView { /** * The form to use for the view. * * @var object * @since 2.5 */ protected $form; /** * The item to edit. * * @var object * @since 2.5 */ protected $item; /** * The model state. * * @var object * @since 2.5 */ protected $state; /** * Displays the view. * * @param string $tpl The name of the template file to parse * * @return void * * @since 2.5 */ public function display($tpl = null) { $this->form = $this->get('Form'); $this->item = $this->get('Item'); $this->state = $this->get('State'); $app = Factory::getApplication(); $languageClient = $app->getUserStateFromRequest('com_languages.overrides.language_client', 'language_client'); if ($languageClient == null) { $app->enqueueMessage(Text::_('COM_LANGUAGES_OVERRIDE_FIRST_SELECT_MESSAGE'), 'warning'); $app->redirect('index.php?option=com_languages&view=overrides'); } // Check for errors. if (count($errors = $this->get('Errors'))) { throw new GenericDataException(implode("\n", $errors)); } // Check whether the cache has to be refreshed. $cached_time = Factory::getApplication()->getUserState( 'com_languages.overrides.cachedtime.' . $this->state->get('filter.client') . '.' . $this->state->get('filter.language'), 0 ); if (time() - $cached_time > 60 * 5) { $this->state->set('cache_expired', true); } // Add strings for translations in \Javascript. Text::script('COM_LANGUAGES_VIEW_OVERRIDE_NO_RESULTS'); Text::script('COM_LANGUAGES_VIEW_OVERRIDE_REQUEST_ERROR'); $this->addToolbar(); parent::display($tpl); } /** * Adds the page title and toolbar. * * @return void * * @since 2.5 */ protected function addToolbar() { Factory::getApplication()->getInput()->set('hidemainmenu', true); $canDo = ContentHelper::getActions('com_languages'); $toolbar = Toolbar::getInstance(); ToolbarHelper::title(Text::_('COM_LANGUAGES_VIEW_OVERRIDE_EDIT_TITLE'), 'comments langmanager'); if ($canDo->get('core.edit')) { $toolbar->apply('override.apply'); } $saveGroup = $toolbar->dropdownButton('save-group'); $saveGroup->configure( function (Toolbar $childBar) use ($canDo) { if ($canDo->get('core.edit')) { $childBar->save('override.save'); } // This component does not support Save as Copy. if ($canDo->get('core.edit') && $canDo->get('core.create')) { $childBar->save2new('override.save2new'); } } ); if (empty($this->item->key)) { $toolbar->cancel('override.cancel', 'JTOOLBAR_CANCEL'); } else { $toolbar->cancel('override.cancel'); } $toolbar->divider(); $toolbar->help('Languages:_Edit_Override'); } } src/View/Multilangstatus/HtmlView.php 0000644 00000003321 15172750553 0013726 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Administrator\View\Multilangstatus; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Language\LanguageHelper; use Joomla\CMS\Language\Multilanguage; use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\Component\Languages\Administrator\Helper\MultilangstatusHelper; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Displays the multilang status. * * @since 1.7.1 */ class HtmlView extends BaseHtmlView { /** * Display the view. * * @param string $tpl The name of the template file to parse. * * @return void */ public function display($tpl = null) { $this->homes = MultilangstatusHelper::getHomes(); $this->language_filter = Multilanguage::isEnabled(); $this->switchers = MultilangstatusHelper::getLangswitchers(); $this->listUsersError = MultilangstatusHelper::getContacts(); $this->contentlangs = MultilangstatusHelper::getContentlangs(); $this->site_langs = LanguageHelper::getInstalledLanguages(0); $this->statuses = MultilangstatusHelper::getStatus(); $this->homepages = Multilanguage::getSiteHomePages(); $this->defaultHome = MultilangstatusHelper::getDefaultHomeModule(); $this->default_lang = ComponentHelper::getParams('com_languages')->get('site', 'en-GB'); parent::display($tpl); } } src/View/Languages/HtmlView.php 0000644 00000007700 15172750553 0012441 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Administrator\View\Languages; use Joomla\CMS\Helper\ContentHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\View\GenericDataException; use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Toolbar\Button\DropdownButton; use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Toolbar\ToolbarHelper; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * HTML Languages View class for the Languages component. * * @since 1.6 */ class HtmlView extends BaseHtmlView { /** * An array of items * * @var array */ protected $items; /** * The pagination object * * @var \Joomla\CMS\Pagination\Pagination */ protected $pagination; /** * The model state * * @var \Joomla\CMS\Object\CMSObject * * @since 4.0.0 */ protected $state; /** * Form object for search filters * * @var \Joomla\CMS\Form\Form * * @since 4.0.0 */ public $filterForm; /** * The active search filters * * @var array * @since 4.0.0 */ public $activeFilters; /** * Display the view. * * @param string $tpl The name of the template file to parse. * * @return void */ public function display($tpl = null) { $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); // Check for errors. if (count($errors = $this->get('Errors'))) { throw new GenericDataException(implode("\n", $errors), 500); } $this->addToolbar(); parent::display($tpl); } /** * Add the page title and toolbar. * * @return void * * @since 1.6 */ protected function addToolbar(): void { $canDo = ContentHelper::getActions('com_languages'); $toolbar = Toolbar::getInstance(); ToolbarHelper::title(Text::_('COM_LANGUAGES_VIEW_LANGUAGES_TITLE'), 'comments langmanager'); if ($canDo->get('core.create')) { $toolbar->addNew('language.add'); } if ($canDo->get('core.edit.state')) { /** @var DropdownButton $dropdown */ $dropdown = $toolbar->dropdownButton('status-group', 'JTOOLBAR_CHANGE_STATUS') ->toggleSplit(false) ->icon('icon-ellipsis-h') ->buttonClass('btn btn-action') ->listCheck(true); $childBar = $dropdown->getChildToolbar(); $childBar->publish('languages.publish')->listCheck(true); $childBar->unpublish('languages.unpublish')->listCheck(true); if ($this->state->get('filter.published') != -2) { $childBar->trash('languages.trash')->listCheck(true); } } if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) { $toolbar->delete('languages.delete', 'JTOOLBAR_EMPTY_TRASH') ->message('JGLOBAL_CONFIRM_DELETE') ->listCheck(true); } if ($canDo->get('core.admin')) { // Add install languages link to the lang installer component. $toolbar->link('COM_LANGUAGES_INSTALL', 'index.php?option=com_installer&view=languages') ->icon('icon-upload'); $toolbar->divider(); $toolbar->preferences('com_languages'); $toolbar->divider(); } $toolbar->help('Languages:_Content'); } } src/View/Overrides/HtmlView.php 0000644 00000006145 15172750553 0012477 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Administrator\View\Overrides; use Joomla\CMS\Helper\ContentHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\View\GenericDataException; use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Toolbar\ToolbarHelper; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * View for language overrides list. * * @since 2.5 */ class HtmlView extends BaseHtmlView { /** * The items to list. * * @var array * @since 2.5 */ protected $items; /** * The pagination object. * * @var object * @since 2.5 */ protected $pagination; /** * The model state. * * @var object * @since 2.5 */ protected $state; /** * An array containing all frontend and backend languages * * @var array * @since 4.0.0 */ protected $languages; /** * Displays the view. * * @param string $tpl The name of the template file to parse. * * @return void * * @since 2.5 */ public function display($tpl = null) { $this->state = $this->get('State'); $this->items = $this->get('Overrides'); $this->languages = $this->get('Languages'); $this->pagination = $this->get('Pagination'); $this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); // Check for errors. if (count($errors = $this->get('Errors'))) { throw new GenericDataException(implode("\n", $errors)); } $this->addToolbar(); parent::display($tpl); } /** * Adds the page title and toolbar. * * @return void * * @since 2.5 */ protected function addToolbar() { // Get the results for each action $canDo = ContentHelper::getActions('com_languages'); $toolbar = Toolbar::getInstance(); ToolbarHelper::title(Text::_('COM_LANGUAGES_VIEW_OVERRIDES_TITLE'), 'comments langmanager'); if ($canDo->get('core.create')) { $toolbar->addNew('override.add'); } if ($canDo->get('core.delete') && $this->pagination->total) { $toolbar->delete('overrides.delete') ->message('JGLOBAL_CONFIRM_DELETE'); } if ($this->getCurrentUser()->authorise('core.admin')) { $toolbar->standardButton('purge', 'COM_LANGUAGES_VIEW_OVERRIDES_PURGE', 'overrides.purge') ->listCheck(false) ->icon('icon-refresh'); } if ($canDo->get('core.admin')) { $toolbar->preferences('com_languages'); } $toolbar->divider(); $toolbar->help('Languages:_Overrides'); } } src/View/Language/HtmlView.php 0000644 00000006504 15172750553 0012257 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Administrator\View\Language; use Joomla\CMS\Factory; use Joomla\CMS\Helper\ContentHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\View\GenericDataException; use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Object\CMSObject; use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Toolbar\ToolbarHelper; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * HTML View class for the Languages component. * * @since 1.5 */ class HtmlView extends BaseHtmlView { /** * The active item * * @var object */ public $item; /** * The Form object * * @var \Joomla\CMS\Form\Form */ public $form; /** * The model state * * @var CMSObject */ public $state; /** * The actions the user is authorised to perform * * @var CMSObject * * @since 4.0.0 */ protected $canDo; /** * Display the view. * * @param string $tpl The name of the template file to parse. * * @return void */ public function display($tpl = null) { $this->item = $this->get('Item'); $this->form = $this->get('Form'); $this->state = $this->get('State'); $this->canDo = ContentHelper::getActions('com_languages'); // Check for errors. if (count($errors = $this->get('Errors'))) { throw new GenericDataException(implode("\n", $errors), 500); } $this->addToolbar(); parent::display($tpl); } /** * Add the page title and toolbar. * * @return void * * @since 1.6 */ protected function addToolbar() { Factory::getApplication()->getInput()->set('hidemainmenu', 1); $isNew = empty($this->item->lang_id); $canDo = $this->canDo; $toolbar = Toolbar::getInstance(); ToolbarHelper::title( Text::_($isNew ? 'COM_LANGUAGES_VIEW_LANGUAGE_EDIT_NEW_TITLE' : 'COM_LANGUAGES_VIEW_LANGUAGE_EDIT_EDIT_TITLE'), 'comments-2 langmanager' ); if (($isNew && $canDo->get('core.create')) || (!$isNew && $canDo->get('core.edit'))) { $toolbar->apply('language.apply'); } $saveGroup = $toolbar->dropdownButton('save-group'); $saveGroup->configure( function (Toolbar $childBar) use ($canDo, $isNew) { if (($isNew && $canDo->get('core.create')) || (!$isNew && $canDo->get('core.edit'))) { $childBar->save('language.save'); } // If an existing item, can save to a copy only if we have create rights. if ($canDo->get('core.create')) { $childBar->save2new('language.save2new'); } } ); if ($isNew) { $toolbar->cancel('language.cancel'); } else { $toolbar->cancel('language.cancel'); } $toolbar->divider(); $toolbar->help('Languages:_Edit_Content_Language'); } } src/View/Installed/HtmlView.php 0000644 00000007250 15172750553 0012452 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Administrator\View\Installed; use Joomla\CMS\Helper\ContentHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\View\GenericDataException; use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Toolbar\ToolbarHelper; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Displays a list of the installed languages. * * @since 1.6 */ class HtmlView extends BaseHtmlView { /** * Option (component) name * * @var string */ protected $option = null; /** * The pagination object * * @var \Joomla\CMS\Pagination\Pagination */ protected $pagination; /** * Languages information * * @var array */ protected $rows = null; /** * The model state * * @var \Joomla\CMS\Object\CMSObject * * @since 4.0.0 */ protected $state; /** * Form object for search filters * * @var \Joomla\CMS\Form\Form * * @since 4.0.0 */ public $filterForm; /** * The active search filters * * @var array * @since 4.0.0 */ public $activeFilters; /** * Display the view. * * @param string $tpl The name of the template file to parse. * * @return void */ public function display($tpl = null) { $this->option = $this->get('Option'); $this->pagination = $this->get('Pagination'); $this->rows = $this->get('Data'); $this->total = $this->get('Total'); $this->state = $this->get('State'); $this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); // Check for errors. if (count($errors = $this->get('Errors'))) { throw new GenericDataException(implode("\n", $errors), 500); } $this->addToolbar(); parent::display($tpl); } /** * Add the page title and toolbar. * * @return void * * @since 1.6 */ protected function addToolbar() { $canDo = ContentHelper::getActions('com_languages'); $toolbar = Toolbar::getInstance(); if ((int) $this->state->get('client_id') === 1) { ToolbarHelper::title(Text::_('COM_LANGUAGES_VIEW_INSTALLED_ADMIN_TITLE'), 'comments langmanager'); } else { ToolbarHelper::title(Text::_('COM_LANGUAGES_VIEW_INSTALLED_SITE_TITLE'), 'comments langmanager'); } if ($canDo->get('core.edit.state')) { $toolbar->makeDefault('installed.setDefault'); $toolbar->divider(); } if ($canDo->get('core.admin')) { // Switch administrator language if ($this->state->get('client_id', 0) == 1) { $toolbar->standardButton('switch', 'COM_LANGUAGES_SWITCH_ADMIN', 'installed.switchadminlanguage') ->icon('icon-refresh') ->listCheck(true); $toolbar->divider(); } $toolbar->link('COM_LANGUAGES_INSTALL', 'index.php?option=com_installer&view=languages') ->icon('icon-upload'); $toolbar->divider(); $toolbar->preferences('com_languages'); $toolbar->divider(); } $toolbar->help('Languages:_Installed'); } } src/Service/HTML/Languages.php 0000644 00000004751 15172750553 0012137 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Administrator\Service\HTML; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Utility class working with languages * * @since 1.6 */ class Languages { /** * Method to generate an information about the default language. * * @param boolean $published True if the language is the default. * * @return string HTML code. */ public function published($published) { if (!$published) { return ' '; } return HTMLHelper::_('image', 'menu/icon-16-default.png', Text::_('COM_LANGUAGES_HEADING_DEFAULT'), null, true); } /** * Method to generate an input radio button. * * @param integer $rowNum The row number. * @param string $language Language tag. * * @return string HTML code. */ public function id($rowNum, $language) { return '<input' . ' class="form-check-input"' . ' type="radio"' . ' id="cb' . $rowNum . '"' . ' name="cid"' . ' value="' . htmlspecialchars($language, ENT_COMPAT, 'UTF-8') . '"' . ' onclick="Joomla.isChecked(this.checked);"' . '>'; } /** * Method to generate an array of clients. * * @return array of client objects. */ public function clients() { return [ HTMLHelper::_('select.option', 0, Text::_('JSITE')), HTMLHelper::_('select.option', 1, Text::_('JADMINISTRATOR')), ]; } /** * Returns an array of published state filter options. * * @return string The HTML code for the select tag. * * @since 1.6 */ public function publishedOptions() { // Build the active state filter options. $options = []; $options[] = HTMLHelper::_('select.option', '1', 'JPUBLISHED'); $options[] = HTMLHelper::_('select.option', '0', 'JUNPUBLISHED'); $options[] = HTMLHelper::_('select.option', '-2', 'JTRASHED'); $options[] = HTMLHelper::_('select.option', '*', 'JALL'); return $options; } } src/Controller/OverridesController.php 0000644 00000012033 15172750553 0014206 0 ustar 00 <?php /** * @package Joomla.API * @subpackage com_languages * * @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Api\Controller; use Joomla\CMS\Form\Form; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Controller\ApiController; use Joomla\CMS\MVC\Controller\Exception; use Joomla\String\Inflector; use Tobscure\JsonApi\Exception\InvalidParameterException; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * The overrides controller * * @since 4.0.0 */ class OverridesController extends ApiController { /** * The content type of the item. * * @var string * @since 4.0.0 */ protected $contentType = 'overrides'; /** * The default view for the display method. * * @var string * @since 3.0 */ protected $default_view = 'overrides'; /** * Basic display of an item view * * @param integer $id The primary key to display. Leave empty if you want to retrieve data from the request * * @return static A \JControllerLegacy object to support chaining. * * @since 4.0.0 */ public function displayItem($id = null) { $this->modelState->set('filter.language', $this->getLanguageFromInput()); $this->modelState->set('filter.client', $this->getClientFromInput()); return parent::displayItem($id); } /** * Basic display of a list view * * @return static A \JControllerLegacy object to support chaining. * * @since 4.0.0 */ public function displayList() { $this->modelState->set('filter.language', $this->getLanguageFromInput()); $this->modelState->set('filter.client', $this->getClientFromInput()); return parent::displayList(); } /** * Method to save a record. * * @param integer $recordKey The primary key of the item (if exists) * * @return integer The record ID on success, false on failure * * @since 4.0.0 */ protected function save($recordKey = null) { /** @var \Joomla\CMS\MVC\Model\AdminModel $model */ $model = $this->getModel(Inflector::singularize($this->contentType)); if (!$model) { throw new \RuntimeException(Text::_('JLIB_APPLICATION_ERROR_MODEL_CREATE')); } $model->setState('filter.language', $this->input->post->get('lang_code')); $model->setState('filter.client', $this->input->post->get('app')); $data = $this->input->get('data', json_decode($this->input->json->getRaw(), true), 'array'); // @todo: Not the cleanest thing ever but it works... Form::addFormPath(JPATH_COMPONENT_ADMINISTRATOR . '/forms'); // Validate the posted data. $form = $model->getForm($data, false); if (!$form) { throw new \RuntimeException(Text::_('JLIB_APPLICATION_ERROR_FORM_CREATE')); } // Test whether the data is valid. $validData = $model->validate($form, $data); // Check for validation errors. if ($validData === false) { $errors = $model->getErrors(); $messages = []; for ($i = 0, $n = \count($errors); $i < $n && $i < 3; $i++) { if ($errors[$i] instanceof \Exception) { $messages[] = "{$errors[$i]->getMessage()}"; } else { $messages[] = "{$errors[$i]}"; } } throw new InvalidParameterException(implode("\n", $messages)); } if (!isset($validData['tags'])) { $validData['tags'] = []; } if (!$model->save($validData)) { throw new Exception\Save(Text::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError())); } return $validData['key']; } /** * Removes an item. * * @param integer $id The primary key to delete item. * * @return void * * @since 4.0.0 */ public function delete($id = null) { $id = $this->input->get('id', '', 'string'); $this->input->set('model', $this->contentType); $this->modelState->set('filter.language', $this->getLanguageFromInput()); $this->modelState->set('filter.client', $this->getClientFromInput()); parent::delete($id); } /** * Get client code from input * * @return string * * @since 4.0.0 */ private function getClientFromInput() { return $this->input->exists('app') ? $this->input->get('app') : $this->input->post->get('app'); } /** * Get language code from input * * @return string * * @since 4.0.0 */ private function getLanguageFromInput() { return $this->input->exists('lang_code') ? $this->input->get('lang_code') : $this->input->post->get('lang_code'); } } src/Controller/LanguageController.php 0000644 00000002047 15172750553 0013773 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Administrator\Controller; use Joomla\CMS\MVC\Controller\FormController; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Languages list actions controller. * * @since 1.6 */ class LanguageController extends FormController { /** * Gets the URL arguments to append to an item redirect. * * @param int $recordId The primary key id for the item. * @param string $key The name of the primary key variable. * * @return string The arguments to append to the redirect URL. * * @since 1.6 */ protected function getRedirectToItemAppend($recordId = null, $key = 'lang_id') { return parent::getRedirectToItemAppend($recordId, $key); } } src/Controller/LanguagesController.php 0000644 00000001517 15172750553 0014157 0 ustar 00 <?php /** * @package Joomla.API * @subpackage com_languages * * @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Api\Controller; use Joomla\CMS\MVC\Controller\ApiController; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * The languages controller * * @since 4.0.0 */ class LanguagesController extends ApiController { /** * The content type of the item. * * @var string * @since 4.0.0 */ protected $contentType = 'languages'; /** * The default view for the display method. * * @var string * @since 3.0 */ protected $default_view = 'languages'; } src/Controller/OverrideController.php 0000644 00000015345 15172750553 0014034 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Administrator\Controller; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Controller\FormController; use Joomla\CMS\Router\Route; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Languages Override Controller * * @since 2.5 */ class OverrideController extends FormController { /** * Method to edit an existing override. * * @param string $key The name of the primary key of the URL variable (not used here). * @param string $urlVar The name of the URL variable if different from the primary key (not used here). * * @return void * * @since 2.5 */ public function edit($key = null, $urlVar = null) { // Do not cache the response to this, its a redirect $this->app->allowCache(false); $cid = (array) $this->input->post->get('cid', [], 'string'); $context = "$this->option.edit.$this->context"; // Get the constant name. $recordId = (count($cid) ? $cid[0] : $this->input->get('id')); // Access check. if (!$this->allowEdit()) { $this->setMessage(Text::_('JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED'), 'error'); $this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false)); return; } $this->app->setUserState($context . '.data', null); $this->setRedirect('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, 'id')); } /** * Method to save an override. * * @param string $key The name of the primary key of the URL variable (not used here). * @param string $urlVar The name of the URL variable if different from the primary key (not used here). * * @return void * * @since 2.5 */ public function save($key = null, $urlVar = null) { // Check for request forgeries. $this->checkToken(); $app = $this->app; $model = $this->getModel(); $data = $this->input->post->get('jform', [], 'array'); $context = "$this->option.edit.$this->context"; $task = $this->getTask(); $recordId = $this->input->get('id'); $data['id'] = $recordId; // Access check. if (!$this->allowSave($data, 'id')) { $this->setMessage(Text::_('JLIB_APPLICATION_ERROR_SAVE_NOT_PERMITTED'), 'error'); $this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false)); return; } // Validate the posted data. $form = $model->getForm($data, false); if (!$form) { $app->enqueueMessage($model->getError(), 'error'); return; } // Test whether the data is valid. $validData = $model->validate($form, $data); // Check for validation errors. if ($validData === false) { // Get the validation messages. $errors = $model->getErrors(); // Push up to three validation messages out to the user. for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) { if ($errors[$i] instanceof \Exception) { $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); } else { $app->enqueueMessage($errors[$i], 'warning'); } } // Save the data in the session. $app->setUserState($context . '.data', $data); // Redirect back to the edit screen. $this->setRedirect( Route::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, 'id'), false) ); return; } // Attempt to save the data. if (!$model->save($validData)) { // Save the data in the session. $app->setUserState($context . '.data', $validData); // Redirect back to the edit screen. $this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError()), 'error'); $this->setRedirect( Route::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, 'id'), false) ); return; } // Add message of success. $this->setMessage(Text::_('COM_LANGUAGES_VIEW_OVERRIDE_SAVE_SUCCESS')); // Redirect the user and adjust session state based on the chosen task. switch ($task) { case 'apply': // Set the record data in the session. $app->setUserState($context . '.data', null); // Redirect back to the edit screen $this->setRedirect( Route::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($validData['key'], 'id'), false) ); break; case 'save2new': // Clear the record id and data from the session. $app->setUserState($context . '.data', null); // Redirect back to the edit screen $this->setRedirect( Route::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend(null, 'id'), false) ); break; default: // Clear the record id and data from the session. $app->setUserState($context . '.data', null); // Redirect to the list screen. $this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false)); break; } } /** * Method to cancel an edit. * * @param string $key The name of the primary key of the URL variable (not used here). * * @return void * * @since 2.5 */ public function cancel($key = null) { $this->checkToken(); $context = "$this->option.edit.$this->context"; $this->app->setUserState($context . '.data', null); $this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false)); } } src/Controller/StringsController.php 0000644 00000007025 15172750553 0013702 0 ustar 00 <?php /** * @package Joomla.API * @subpackage com_languages * * @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Api\Controller; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Controller\ApiController; use Tobscure\JsonApi\Exception\InvalidParameterException; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * The strings controller * * @since 4.0.0 */ class StringsController extends ApiController { /** * The content type of the item. * * @var string * @since 4.0.0 */ protected $contentType = 'strings'; /** * The default view for the display method. * * @var string * @since 3.0 */ protected $default_view = 'strings'; /** * Search by languages constants * * @return static A \JControllerLegacy object to support chaining. * * @throws InvalidParameterException * @since 4.0.0 */ public function search() { $data = $this->input->get('data', json_decode($this->input->json->getRaw(), true), 'array'); if (!isset($data['searchstring']) || !\is_string($data['searchstring'])) { throw new InvalidParameterException("Invalid param 'searchstring'"); } if (!isset($data['searchtype']) || !\in_array($data['searchtype'], ['constant', 'value'])) { throw new InvalidParameterException("Invalid param 'searchtype'"); } $this->input->set('searchstring', $data['searchstring']); $this->input->set('searchtype', $data['searchtype']); $this->input->set('more', 0); $viewType = $this->app->getDocument()->getType(); $viewName = $this->input->get('view', $this->default_view); $viewLayout = $this->input->get('layout', 'default', 'string'); try { /** @var \Joomla\Component\Languages\Api\View\Strings\JsonapiView $view */ $view = $this->getView( $viewName, $viewType, '', ['base_path' => $this->basePath, 'layout' => $viewLayout, 'contentType' => $this->contentType] ); } catch (\Exception $e) { throw new \RuntimeException($e->getMessage()); } /** @var \Joomla\Component\Languages\Administrator\Model\StringsModel $model */ $model = $this->getModel($this->contentType, '', ['ignore_request' => true]); if (!$model) { throw new \RuntimeException(Text::_('JLIB_APPLICATION_ERROR_MODEL_CREATE')); } // Push the model into the view (as default) $view->setModel($model, true); $view->document = $this->app->getDocument(); $view->displayList(); return $this; } /** * Refresh cache * * @return static A \JControllerLegacy object to support chaining. * * @throws \Exception * @since 4.0.0 */ public function refresh() { /** @var \Joomla\Component\Languages\Administrator\Model\StringsModel $model */ $model = $this->getModel($this->contentType, '', ['ignore_request' => true]); if (!$model) { throw new \RuntimeException(Text::_('JLIB_APPLICATION_ERROR_MODEL_CREATE')); } $result = $model->refresh(); if ($result instanceof \Exception) { throw $result; } return $this; } } src/Controller/InstalledController.php 0000644 00000007022 15172750553 0014165 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Administrator\Controller; use Joomla\CMS\Factory; use Joomla\CMS\Language\Language; use Joomla\CMS\Language\LanguageHelper; use Joomla\CMS\Language\Multilanguage; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Controller\BaseController; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Languages Controller. * * @since 1.5 */ class InstalledController extends BaseController { /** * Task to set the default language. * * @return void */ public function setDefault() { // Check for request forgeries. $this->checkToken(); $cid = (string) $this->input->get('cid', '', 'string'); $model = $this->getModel('installed'); if ($model->publish($cid)) { // Switching to the new administrator language for the message if ($model->getState('client_id') == 1) { $language = Factory::getLanguage(); $newLang = Language::getInstance($cid); Factory::$language = $newLang; $this->app->loadLanguage($language = $newLang); $newLang->load('com_languages', JPATH_ADMINISTRATOR); } if (Multilanguage::isEnabled() && $model->getState('client_id') == 0) { $msg = Text::_('COM_LANGUAGES_MSG_DEFAULT_MULTILANG_SAVED'); $type = 'message'; } else { $msg = Text::_('COM_LANGUAGES_MSG_DEFAULT_LANGUAGE_SAVED'); $type = 'message'; } } else { $msg = $model->getError(); $type = 'error'; } $clientId = $model->getState('client_id'); $this->setRedirect('index.php?option=com_languages&view=installed&client=' . $clientId, $msg, $type); } /** * Task to switch the administrator language. * * @return void */ public function switchAdminLanguage() { // Check for request forgeries. $this->checkToken(); $cid = (string) $this->input->get('cid', '', 'string'); $model = $this->getModel('installed'); // Fetching the language name from the langmetadata.xml or xx-XX.xml respectively. $file = JPATH_ADMINISTRATOR . '/language/' . $cid . '/langmetadata.xml'; if (!is_file($file)) { $file = JPATH_ADMINISTRATOR . '/language/' . $cid . '/' . $cid . '.xml'; } $info = LanguageHelper::parseXMLLanguageFile($file); if ($model->switchAdminLanguage($cid)) { // Switching to the new language for the message $languageName = $info['nativeName']; $language = Factory::getLanguage(); $newLang = Language::getInstance($cid); Factory::$language = $newLang; $this->app->loadLanguage($language = $newLang); $newLang->load('com_languages', JPATH_ADMINISTRATOR); $msg = Text::sprintf('COM_LANGUAGES_MSG_SWITCH_ADMIN_LANGUAGE_SUCCESS', $languageName); $type = 'message'; } else { $msg = $model->getError(); $type = 'error'; } $this->setRedirect('index.php?option=com_languages&view=installed', $msg, $type); } } src/Controller/DisplayController.php 0000644 00000003653 15172750553 0013661 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Administrator\Controller; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Controller\BaseController; use Joomla\CMS\Router\Route; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Languages Controller. * * @since 1.5 */ class DisplayController extends BaseController { /** * @var string The default view. * @since 1.6 */ protected $default_view = 'installed'; /** * Method to display a view. * * @param boolean $cachable If true, the view output will be cached. * @param array $urlparams An array of safe URL parameters and their variable types, for valid values see {@link \JFilterInput::clean()}. * * @return static|boolean This object to support chaining or false on failure. * * @since 1.5 */ public function display($cachable = false, $urlparams = false) { $view = $this->input->get('view', $this->default_view); $layout = $this->input->get('layout', 'default'); $id = $this->input->getInt('id'); // Check for edit form. if ($view == 'language' && $layout == 'edit' && !$this->checkEditId('com_languages.edit.language', $id)) { // Somehow the person just went to the form - we don't allow that. if (!\count($this->app->getMessageQueue())) { $this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 'error'); } $this->setRedirect(Route::_('index.php?option=com_languages&view=languages', false)); return false; } return parent::display(); } } src/Field/LanguageclientField.php 0000644 00000004162 15172750553 0012772 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Administrator\Field; use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\LanguageHelper; use Joomla\CMS\Language\Text; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Client Language List field. * * @since 3.9.0 */ class LanguageclientField extends ListField { /** * The form field type. * * @var string * @since 3.9.0 */ protected $type = 'Languageclient'; /** * Cached form field options. * * @var array * @since 3.9.0 */ protected $cache = []; /** * Method to get the field options. * * @return array The field option objects. * * @since 3.9.0 */ protected function getOptions() { // Try to load the data from our mini-cache. if (!empty($this->cache)) { return $this->cache; } // Get all languages of frontend and backend. $languages = []; $site_languages = LanguageHelper::getKnownLanguages(JPATH_SITE); $admin_languages = LanguageHelper::getKnownLanguages(JPATH_ADMINISTRATOR); // Create a single array of them. foreach ($site_languages as $tag => $language) { $languages[$tag . '0'] = Text::sprintf('COM_LANGUAGES_VIEW_OVERRIDES_LANGUAGES_BOX_ITEM', $language['name'], Text::_('JSITE')); } foreach ($admin_languages as $tag => $language) { $languages[$tag . '1'] = Text::sprintf('COM_LANGUAGES_VIEW_OVERRIDES_LANGUAGES_BOX_ITEM', $language['name'], Text::_('JADMINISTRATOR')); } // Sort it by language tag and by client after that. ksort($languages); // Add the languages to the internal cache. $this->cache = array_merge(parent::getOptions(), $languages); return $this->cache; } } src/Extension/LanguagesComponent.php 0000644 00000002570 15172750553 0013627 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Administrator\Extension; use Joomla\CMS\Extension\BootableExtensionInterface; use Joomla\CMS\Extension\MVCComponent; use Joomla\CMS\HTML\HTMLRegistryAwareTrait; use Joomla\Component\Languages\Administrator\Service\HTML\Languages; use Psr\Container\ContainerInterface; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Component class for com_languages * * @since 4.0.0 */ class LanguagesComponent extends MVCComponent implements BootableExtensionInterface { use HTMLRegistryAwareTrait; /** * Booting the extension. This is the function to set up the environment of the extension like * registering new class loaders, etc. * * If required, some initial set up can be done from services of the container, eg. * registering HTML services. * * @param ContainerInterface $container The container * * @return void * * @since 4.0.0 */ public function boot(ContainerInterface $container) { $this->getRegistry()->register('languages', new Languages()); } } src/Helper/MultilangstatusHelper.php 0000644 00000026142 15172750553 0013642 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Administrator\Helper; use Joomla\CMS\Factory; use Joomla\CMS\Language\LanguageHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Log\Log; use Joomla\Registry\Registry; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Multilang status helper. * * @since 1.7.1 */ abstract class MultilangstatusHelper { /** * Method to get the number of published home pages. * * @return integer */ public static function getHomes() { // Check for multiple Home pages. $db = Factory::getDbo(); $query = $db->getQuery(true) ->select('COUNT(*)') ->from($db->quoteName('#__menu')) ->where( [ $db->quoteName('home') . ' = 1', $db->quoteName('published') . ' = 1', $db->quoteName('client_id') . ' = 0', ] ); $db->setQuery($query); return $db->loadResult(); } /** * Method to get the number of published language switcher modules. * * @return integer */ public static function getLangswitchers() { // Check if switcher is published. $db = Factory::getDbo(); $query = $db->getQuery(true) ->select('COUNT(*)') ->from($db->quoteName('#__modules')) ->where( [ $db->quoteName('module') . ' = ' . $db->quote('mod_languages'), $db->quoteName('published') . ' = 1', $db->quoteName('client_id') . ' = 0', ] ); $db->setQuery($query); return $db->loadResult(); } /** * Method to return a list of published content languages. * * @return array of language objects. */ public static function getContentlangs() { // Check for published Content Languages. $db = Factory::getDbo(); $query = $db->getQuery(true) ->select( [ $db->quoteName('lang_code'), $db->quoteName('published'), $db->quoteName('sef'), ] ) ->from($db->quoteName('#__languages')); $db->setQuery($query); return $db->loadObjectList(); } /** * Method to return combined language status. * * @return array of language objects. */ public static function getStatus() { // Check for combined status. $db = Factory::getDbo(); $query = $db->getQuery(true); // Select all fields from the languages table. $query->select( [ $db->quoteName('a') . '.*', $db->quoteName('a.published'), $db->quoteName('a.lang_code'), $db->quoteName('e.enabled'), $db->quoteName('e.element'), $db->quoteName('l.home'), $db->quoteName('l.published', 'home_published'), ] ) ->from($db->quoteName('#__languages', 'a')) ->join( 'LEFT', $db->quoteName('#__menu', 'l'), $db->quoteName('l.language') . ' = ' . $db->quoteName('a.lang_code') . ' AND ' . $db->quoteName('l.home') . ' = 1 AND ' . $db->quoteName('l.language') . ' <> ' . $db->quote('*') ) ->join('LEFT', $db->quoteName('#__extensions', 'e'), $db->quoteName('e.element') . ' = ' . $db->quoteName('a.lang_code')) ->where( [ $db->quoteName('e.client_id') . ' = 0', $db->quoteName('e.enabled') . ' = 1', $db->quoteName('e.state') . ' = 0', ] ); $db->setQuery($query); return $db->loadObjectList(); } /** * Method to return a list of contact objects. * * @return array of contact objects. */ public static function getContacts() { $db = Factory::getDbo(); $languages = count(LanguageHelper::getLanguages()); // Get the number of contact with all as language $alang = $db->getQuery(true) ->select('COUNT(*)') ->from($db->quoteName('#__contact_details', 'cd')) ->where( [ $db->quoteName('cd.user_id') . ' = ' . $db->quoteName('u.id'), $db->quoteName('cd.published') . ' = 1', $db->quoteName('cd.language') . ' = ' . $db->quote('*'), ] ); // Get the number of languages for the contact $slang = $db->getQuery(true) ->select('COUNT(DISTINCT ' . $db->quoteName('l.lang_code') . ')') ->from($db->quoteName('#__languages', 'l')) ->join('LEFT', $db->quoteName('#__contact_details', 'cd'), $db->quoteName('cd.language') . ' = ' . $db->quoteName('l.lang_code')) ->where( [ $db->quoteName('cd.user_id') . ' = ' . $db->quoteName('u.id'), $db->quoteName('cd.published') . ' = 1', $db->quoteName('l.published') . ' = 1', ] ); // Get the number of multiple contact/language $mlang = $db->getQuery(true) ->select('COUNT(*)') ->from($db->quoteName('#__languages', 'l')) ->join('LEFT', $db->quoteName('#__contact_details', 'cd'), $db->quoteName('cd.language') . ' = ' . $db->quoteName('l.lang_code')) ->where( [ $db->quoteName('cd.user_id') . ' = ' . $db->quoteName('u.id'), $db->quoteName('cd.published') . ' = 1', $db->quoteName('l.published') . ' = 1', ] ) ->group($db->quoteName('l.lang_code')) ->having('COUNT(*) > 1'); // Get the contacts $subQuery = $db->getQuery(true) ->select('1') ->from($db->quoteName('#__content', 'c')) ->where($db->quoteName('c.created_by') . ' = ' . $db->quoteName('u.id')); $query = $db->getQuery(true) ->select( [ $db->quoteName('u.name'), '(' . $alang . ') AS ' . $db->quoteName('alang'), '(' . $slang . ') AS ' . $db->quoteName('slang'), '(' . $mlang . ') AS ' . $db->quoteName('mlang'), ] ) ->from($db->quoteName('#__users', 'u')) ->join('LEFT', $db->quoteName('#__contact_details', 'cd'), $db->quoteName('cd.user_id') . ' = ' . $db->quoteName('u.id')) ->where('EXISTS (' . $subQuery . ')') ->group( [ $db->quoteName('u.id'), $db->quoteName('u.name'), ] ); $db->setQuery($query); $warnings = $db->loadObjectList(); foreach ($warnings as $index => $warn) { if ($warn->alang == 1 && $warn->slang == 0) { unset($warnings[$index]); } if ($warn->alang == 0 && $warn->slang == 0 && empty($warn->mlang)) { unset($warnings[$index]); } if ($warn->alang == 0 && $warn->slang == $languages && empty($warn->mlang)) { unset($warnings[$index]); } } return $warnings; } /** * Method to get the status of the module displaying the menutype of the default Home page set to All languages. * * @return boolean True if the module is published, false otherwise. * * @since 3.7.0 */ public static function getDefaultHomeModule() { // Find Default Home menutype. $db = Factory::getDbo(); $query = $db->getQuery(true) ->select($db->quoteName('menutype')) ->from($db->quoteName('#__menu')) ->where( [ $db->quoteName('home') . ' = 1', $db->quoteName('published') . ' = 1', $db->quoteName('client_id') . ' = 0', $db->quoteName('language') . ' = ' . $db->quote('*'), ] ); $db->setQuery($query); $menutype = $db->loadResult(); // Get published site menu modules titles. $query->clear() ->select($db->quoteName('title')) ->from($db->quoteName('#__modules')) ->where( [ $db->quoteName('module') . ' = ' . $db->quote('mod_menu'), $db->quoteName('published') . ' = 1', $db->quoteName('client_id') . ' = 0', ] ); $db->setQuery($query); $menutitles = $db->loadColumn(); // Do we have a published menu module displaying the default Home menu item set to all languages? foreach ($menutitles as $menutitle) { $module = self::getModule('mod_menu', $menutitle); $moduleParams = new Registry($module->params); $param = $moduleParams->get('menutype', ''); if ($param && $param != $menutype) { continue; } return true; } } /** * Get module by name * * @param string $moduleName The name of the module * @param string $instanceTitle The title of the module, optional * * @return \stdClass The Module object * * @since 3.7.0 */ public static function getModule($moduleName, $instanceTitle = null) { $db = Factory::getDbo(); $query = $db->getQuery(true) ->select( [ $db->quoteName('id'), $db->quoteName('title'), $db->quoteName('module'), $db->quoteName('position'), $db->quoteName('content'), $db->quoteName('showtitle'), $db->quoteName('params'), ] ) ->from($db->quoteName('#__modules')) ->where( [ $db->quoteName('module') . ' = :module', $db->quoteName('published') . ' = 1', $db->quoteName('client_id') . ' = 0', ] ) ->bind(':module', $moduleName); if ($instanceTitle) { $query->where($db->quoteName('title') . ' = :title') ->bind(':title', $instanceTitle); } $db->setQuery($query); try { $modules = $db->loadObject(); } catch (\RuntimeException $e) { Log::add(Text::sprintf('JLIB_APPLICATION_ERROR_MODULE_LOAD', $e->getMessage()), Log::WARNING, 'jerror'); } return $modules; } } src/Helper/LanguagesHelper.php 0000644 00000003071 15172750553 0012344 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Administrator\Helper; use Joomla\CMS\Filter\InputFilter; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Languages component helper. * * @since 1.6 */ class LanguagesHelper { /** * Filter method for language keys. * This method will be called by \JForm while filtering the form data. * * @param string $value The language key to filter. * * @return string The filtered language key. * * @since 2.5 */ public static function filterKey($value) { $filter = InputFilter::getInstance([], [], InputFilter::ONLY_BLOCK_DEFINED_TAGS, InputFilter::ONLY_BLOCK_DEFINED_ATTRIBUTES); return strtoupper($filter->clean($value, 'cmd')); } /** * Filter method for language strings. * This method will be called by \JForm while filtering the form data. * * @param string $value The language string to filter. * * @return string The filtered language string. * * @since 2.5 */ public static function filterText($value) { $filter = InputFilter::getInstance([], [], InputFilter::ONLY_BLOCK_DEFINED_TAGS, InputFilter::ONLY_BLOCK_DEFINED_ATTRIBUTES); return $filter->clean($value); } } services/provider.php 0000644 00000003334 15172750553 0010747 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface; use Joomla\CMS\Extension\ComponentInterface; use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherFactory; use Joomla\CMS\Extension\Service\Provider\MVCFactory; use Joomla\CMS\HTML\Registry; use Joomla\CMS\MVC\Factory\MVCFactoryInterface; use Joomla\Component\Languages\Administrator\Extension\LanguagesComponent; use Joomla\DI\Container; use Joomla\DI\ServiceProviderInterface; /** * The language service provider. * * @since 4.0.0 */ return new class () implements ServiceProviderInterface { /** * Registers the service provider with a DI container. * * @param Container $container The DI container. * * @return void * * @since 4.0.0 */ public function register(Container $container) { $container->registerServiceProvider(new MVCFactory('\\Joomla\\Component\\Languages')); $container->registerServiceProvider(new ComponentDispatcherFactory('\\Joomla\\Component\\Languages')); $container->set( ComponentInterface::class, function (Container $container) { $component = new LanguagesComponent($container->get(ComponentDispatcherFactoryInterface::class)); $component->setMVCFactory($container->get(MVCFactoryInterface::class)); $component->setRegistry($container->get(Registry::class)); return $component; } ); } }; index.html 0000604 00000000037 15172750553 0006547 0 ustar 00 <!DOCTYPE html><title></title> config.xml 0000644 00000000706 15172750553 0006550 0 ustar 00 <?xml version="1.0" encoding="UTF-8"?> <config> <help key="Languages:_Options"/> <fieldset name="permissions" label="JCONFIG_PERMISSIONS_LABEL" > <field name="rules" type="rules" label="JCONFIG_PERMISSIONS_LABEL" filter="rules" validate="rules" component="com_languages" section="component" /> <field type="hidden" name="site" /> <field type="hidden" name="administrator" /> </fieldset> </config> tmpl/multilangstatus/default.php 0000644 00000046324 15172750553 0013140 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\CMS\Language\Text; $notice_disabled = !$this->language_filter && ($this->homes > 1 || $this->switchers != 0); $notice_switchers = !$this->switchers && ($this->homes > 1 || $this->language_filter); // Defining arrays $content_languages = array_column($this->contentlangs, 'lang_code'); $sitelangs = array_column($this->site_langs, 'element'); $home_pages = array_column($this->homepages, 'language'); ?> <div class="mod-multilangstatus"> <?php if (!$this->language_filter && $this->switchers == 0) : ?> <?php if ($this->homes == 1) : ?> <div class="alert alert-info"> <span class="icon-info-circle" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('INFO'); ?></span> <?php echo Text::_('COM_LANGUAGES_MULTILANGSTATUS_NONE'); ?> </div> <?php else : ?> <div class="alert alert-info"> <span class="icon-info-circle" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('INFO'); ?></span> <?php echo Text::_('COM_LANGUAGES_MULTILANGSTATUS_USELESS_HOMES'); ?> </div> <?php endif; ?> <?php else : ?> <?php if (!in_array($this->default_lang, $content_languages)) : ?> <div class="alert alert-error"> <span class="icon-exclamation" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('ERROR'); ?></span> <?php echo Text::sprintf('COM_LANGUAGES_MULTILANGSTATUS_ERROR_DEFAULT_CONTENT_LANGUAGE', $this->default_lang); ?> </div> <?php else : ?> <?php foreach ($this->contentlangs as $contentlang) : ?> <?php if ($contentlang->lang_code == $this->default_lang && $contentlang->published != 1) : ?> <div class="alert alert-error"> <span class="icon-exclamation" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('ERROR'); ?></span> <?php echo Text::sprintf('COM_LANGUAGES_MULTILANGSTATUS_ERROR_DEFAULT_CONTENT_LANGUAGE', $this->default_lang); ?> </div> <?php endif; ?> <?php endforeach; ?> <?php endif; ?> <?php if ($this->defaultHome == true) : ?> <div class="alert alert-warning"> <span class="icon-exclamation-triangle" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('WARNING'); ?></span> <?php echo Text::_('COM_LANGUAGES_MULTILANGSTATUS_DEFAULT_HOME_MODULE_PUBLISHED'); ?> </div> <?php endif; ?> <?php foreach ($this->statuses as $status) : ?> <?php // Displays error when Site language and Content language are published but Home page is unpublished, trashed or missing. ?> <?php if ($status->lang_code && $status->published == 1 && $status->home_published != 1) : ?> <div class="alert alert-warning"> <span class="icon-exclamation-triangle" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('WARNING'); ?></span> <?php echo Text::sprintf('COM_LANGUAGES_MULTILANGSTATUS_HOME_UNPUBLISHED', $status->lang_code, $status->lang_code); ?> </div> <?php endif; ?> <?php // Displays error when both Content Language and Home page are unpublished. ?> <?php if ($status->lang_code && $status->published == 0 && $status->home_published != 1) : ?> <div class="alert alert-warning"> <span class="icon-exclamation-triangle" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('WARNING'); ?></span> <?php echo Text::sprintf('COM_LANGUAGES_MULTILANGSTATUS_CONTENT_LANGUAGE_HOME_UNPUBLISHED', $status->lang_code, $status->lang_code); ?> </div> <?php endif; ?> <?php endforeach; ?> <?php if ($notice_disabled) : ?> <div class="alert alert-warning"> <span class="icon-exclamation-triangle" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('WARNING'); ?></span> <?php echo Text::_('COM_LANGUAGES_MULTILANGSTATUS_LANGUAGEFILTER_DISABLED'); ?> </div> <?php endif; ?> <?php if ($notice_switchers) : ?> <div class="alert alert-warning"> <span class="icon-exclamation-triangle" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('WARNING'); ?></span> <?php echo Text::_('COM_LANGUAGES_MULTILANGSTATUS_LANGSWITCHER_UNPUBLISHED'); ?> </div> <?php endif; ?> <?php foreach ($this->contentlangs as $contentlang) : ?> <?php if (array_key_exists($contentlang->lang_code, $this->homepages) && (!array_key_exists($contentlang->lang_code, $this->site_langs) || $contentlang->published != 1)) : ?> <div class="alert alert-warning"> <span class="icon-exclamation-triangle" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('WARNING'); ?></span> <?php echo Text::sprintf('COM_LANGUAGES_MULTILANGSTATUS_ERROR_CONTENT_LANGUAGE', $contentlang->lang_code); ?> </div> <?php endif; ?> <?php if (!array_key_exists($contentlang->lang_code, $this->site_langs)) : ?> <div class="alert alert-warning"> <span class="icon-exclamation-triangle" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('WARNING'); ?></span> <?php echo Text::sprintf('COM_LANGUAGES_MULTILANGSTATUS_ERROR_LANGUAGE_TAG', $contentlang->lang_code); ?> </div> <?php endif; ?> <?php if ($contentlang->published == -2) : ?> <div class="alert alert-warning"> <span class="icon-exclamation-triangle" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('WARNING'); ?></span> <?php echo Text::sprintf('COM_LANGUAGES_MULTILANGSTATUS_CONTENT_LANGUAGE_TRASHED', $contentlang->lang_code); ?> </div> <?php endif; ?> <?php if (empty($contentlang->sef)) : ?> <div class="alert alert-error"> <span class="icon-exclamation" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('ERROR'); ?></span> <?php echo Text::sprintf('COM_LANGUAGES_MULTILANGSTATUS_CONTENT_LANGUAGE_SEF_MISSING', $contentlang->lang_code); ?> </div> <?php endif; ?> <?php endforeach; ?> <?php if ($this->listUsersError) : ?> <div class="alert alert-warning"> <span class="icon-exclamation-triangle" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('WARNING'); ?></span> <?php echo Text::_('COM_LANGUAGES_MULTILANGSTATUS_CONTACTS_ERROR_TIP'); ?> <ul> <?php foreach ($this->listUsersError as $user) : ?> <li> <?php echo Text::sprintf('COM_LANGUAGES_MULTILANGSTATUS_CONTACTS_ERROR', $user->name); ?> </li> <?php endforeach; ?> </ul> </div> <?php endif; ?> <?php // Displays error when the Content Language has been deleted ?> <?php foreach ($sitelangs as $sitelang) : ?> <?php if (!in_array($sitelang, $content_languages) && in_array($sitelang, $home_pages)) : ?> <div class="alert alert-warning"> <span class="icon-exclamation-triangle" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('WARNING'); ?></span> <?php echo Text::sprintf('COM_LANGUAGES_MULTILANGSTATUS_CONTENT_LANGUAGE_MISSING', $sitelang); ?> </div> <?php endif; ?> <?php endforeach; ?> <table class="table table-sm"> <caption class="visually-hidden"><?php echo Text::_('COM_LANGUAGES_MULTILANGSTATUS_TABLE_CAPTION'); ?></caption> <thead> <tr> <th scope="col"> <?php echo Text::_('JDETAILS'); ?> </th> <th class="text-center" scope="col"> <?php echo Text::_('JSTATUS'); ?> </th> </tr> </thead> <tbody> <tr> <th scope="row"> <?php echo Text::_('COM_LANGUAGES_MULTILANGSTATUS_LANGUAGEFILTER'); ?> </th> <td class="text-center"> <?php if ($this->language_filter) : ?> <?php echo Text::_('JENABLED'); ?> <?php else : ?> <?php echo Text::_('JDISABLED'); ?> <?php endif; ?> </td> </tr> <tr> <th scope="row"> <?php echo Text::_('COM_LANGUAGES_MULTILANGSTATUS_LANGSWITCHER_PUBLISHED'); ?> </th> <td class="text-center"> <?php if ($this->switchers != 0) : ?> <?php echo $this->switchers; ?> <?php else : ?> <?php echo Text::_('JNONE'); ?> <?php endif; ?> </td> </tr> <tr> <th scope="row"> <?php if ($this->homes > 1) : ?> <?php echo Text::_('COM_LANGUAGES_MULTILANGSTATUS_HOMES_PUBLISHED_INCLUDING_ALL'); ?> <?php else : ?> <?php echo Text::_('COM_LANGUAGES_MULTILANGSTATUS_HOMES_PUBLISHED'); ?> <?php endif; ?> </th> <td class="text-center"> <?php if ($this->homes > 1) : ?> <?php echo $this->homes; ?> <?php else : ?> <?php echo Text::_('COM_LANGUAGES_MULTILANGSTATUS_HOMES_PUBLISHED_ALL'); ?> <?php endif; ?> </td> </tr> </tbody> </table> <table class="table table-sm"> <caption class="visually-hidden"><?php echo Text::_('COM_LANGUAGES_MULTILANGSTATUS_CONTENT_TABLE_CAPTION'); ?></caption> <thead> <tr> <th scope="col"> <?php echo Text::_('JGRID_HEADING_LANGUAGE'); ?> </th> <th class="text-center" scope="col"> <?php echo Text::_('COM_LANGUAGES_MULTILANGSTATUS_SITE_LANG_PUBLISHED'); ?> </th> <th class="text-center" scope="col"> <?php echo Text::_('COM_LANGUAGES_MULTILANGSTATUS_CONTENT_LANGUAGE_PUBLISHED'); ?> </th> <th class="text-center" scope="col"> <?php echo Text::_('COM_LANGUAGES_MULTILANGSTATUS_HOMES_PUBLISHED'); ?> </th> </tr> </thead> <tbody> <?php foreach ($this->statuses as $status) : ?> <?php if ($status->element) : ?> <tr> <th scope="row"> <?php echo $status->element; ?> </th> <?php endif; ?> <?php // Published Site languages ?> <?php if ($status->element) : ?> <td class="text-center"> <span class="text-success icon-check" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('JYES'); ?></span> </td> <?php else : ?> <td class="text-center"> <?php echo Text::_('JNO'); ?> </td> <?php endif; ?> <?php // Published Content languages ?> <td class="text-center"> <?php if ($status->lang_code && $status->published == 1) : ?> <span class="text-success icon-check" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('JYES'); ?></span> <?php elseif ($status->lang_code && $status->published == 0) : ?> <span class="text-danger icon-times" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('WARNING'); ?></span> <?php elseif ($status->lang_code && $status->published == -2) : ?> <span class="icon-trash" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('WARNING'); ?></span> <?php else : ?> <span class="icon-exclamation-triangle" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('WARNING'); ?></span> <?php endif; ?> </td> <?php // Published Home pages ?> <td class="text-center"> <?php if ($status->home_published == 1) : ?> <span class="text-success icon-check" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('JYES'); ?></span> <?php elseif ($status->home_published == 0) : ?> <span class="text-danger icon-times" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('JNO'); ?></span> <?php elseif ($status->home_published == -2) : ?> <span class="icon-trash" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('WARNING'); ?></span> <?php else : ?> <span class="icon-exclamation-triangle" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('WARNING'); ?></span> <?php endif; ?> </td> </tr> <?php endforeach; ?> <?php foreach ($this->contentlangs as $contentlang) : ?> <?php if (!array_key_exists($contentlang->lang_code, $this->site_langs)) : ?> <tr> <th scope="row"> <?php echo $contentlang->lang_code; ?> </th> <td class="text-center"> <span class="icon-exclamation-triangle" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('WARNING'); ?></span> </td> <td class="text-center"> <?php if ($contentlang->published == 1) : ?> <span class="text-success icon-check" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('JYES'); ?></span> <?php elseif ($contentlang->published == 0 && array_key_exists($contentlang->lang_code, $this->homepages)) : ?> <span class="text-danger icon-times" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('JNO'); ?></span> <?php elseif ($contentlang->published == -2 && array_key_exists($contentlang->lang_code, $this->homepages)) : ?> <span class="icon-trash" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('WARNING'); ?></span> <?php endif; ?> </td> <td class="text-center"> <?php if (!array_key_exists($contentlang->lang_code, $this->homepages)) : ?> <span class="icon-exclamation-triangle" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('WARNING'); ?></span> <?php else : ?> <span class="text-success icon-check" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('JYES'); ?></span> <?php endif; ?> </td> </tr> <?php endif; ?> <?php endforeach; ?> <?php // Display error when the Content Language has been deleted ?> <?php foreach ($sitelangs as $sitelang) : ?> <?php if (!in_array($sitelang, $content_languages) && in_array($sitelang, $home_pages)) : ?> <tr> <th scope="row"> <?php echo $sitelang; ?> </th> <td class="text-center"> <span class="text-success icon-check" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('JYES'); ?></span> </td> <td class="text-center"> <span class="icon-exclamation-triangle" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('WARNING'); ?></span> </td> <td class="text-center"> <span class="text-success icon-check" aria-hidden="true"></span> <span class="visually-hidden"><?php echo Text::_('JYES'); ?></span> </td> </tr> <?php endif; ?> <?php endforeach; ?> </tbody> </table> <?php endif; ?> </div> tmpl/override/edit.php 0000644 00000010735 15172750553 0011015 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Router\Route; $expired = ($this->state->get('cache_expired') == 1 ) ? '1' : ''; /** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ $wa = $this->document->getWebAssetManager(); $wa->useScript('keepalive') ->useScript('form.validate') ->usePreset('com_languages.overrider') ->useScript('com_languages.admin-override-edit-refresh-searchstring'); ?> <form action="<?php echo Route::_('index.php?option=com_languages&id=' . $this->item->key); ?>" method="post" name="adminForm" id="override-form" aria-label="<?php echo Text::_('COM_LANGUAGES_VIEW_OVERRIDE_FORM_' . ((int) $this->item->key === 0 ? 'NEW' : 'EDIT'), true); ?>" class="main-card form-validate p-4 mt-4"> <div class="row"> <div class="col-md-6"> <fieldset id="fieldset-override" class="options-form"> <legend><?php echo empty($this->item->key) ? Text::_('COM_LANGUAGES_VIEW_OVERRIDE_EDIT_NEW_OVERRIDE_LEGEND') : Text::_('COM_LANGUAGES_VIEW_OVERRIDE_EDIT_EDIT_OVERRIDE_LEGEND'); ?></legend> <div> <?php echo $this->form->renderField('language'); ?> <?php echo $this->form->renderField('client'); ?> <?php echo $this->form->renderField('key'); ?> <?php echo $this->form->renderField('override'); ?> <?php echo $this->form->renderField('both'); ?> <?php echo $this->form->renderField('file'); ?> </div> </fieldset> </div> <div class="col-md-6"> <fieldset id="fieldset-override-search" class="options-form"> <legend><?php echo Text::_('COM_LANGUAGES_VIEW_OVERRIDE_SEARCH_LEGEND'); ?></legend> <div> <div class="alert alert-info"> <span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('INFO'); ?></span> <?php echo Text::_('COM_LANGUAGES_VIEW_OVERRIDE_SEARCH_TIP'); ?> </div> <?php echo $this->form->renderField('searchtype'); ?> <div class="control-group"> <div class="control-label"> <?php echo $this->form->getLabel('searchstring'); ?> </div> <div class="controls"> <div class="input-group"> <?php echo $this->form->getInput('searchstring'); ?> <button type="submit" class="btn btn-primary" onclick="Joomla.overrider.searchStrings();return false;" formnovalidate> <?php echo Text::_('COM_LANGUAGES_VIEW_OVERRIDE_SEARCH_BUTTON'); ?> </button> <span id="refresh-status" class="form-text"> <span class="icon-sync icon-spin" aria-hidden="true"></span> <?php echo Text::_('COM_LANGUAGES_VIEW_OVERRIDE_REFRESHING'); ?> </span> </div> </div> </div> </div> </fieldset> <fieldset id="results-container" class="adminform"> <legend><?php echo Text::_('COM_LANGUAGES_VIEW_OVERRIDE_RESULTS_LEGEND'); ?></legend> <div id="overrider-spinner" class="overrider-spinner text-center" data-search-string-expired="<?php echo $expired; ?>"><span class="icon-spinner icon-spin" aria-hidden="true"></span></div> <span id="more-results" class="mt-2"> <button type="button" id="more-results-button" class="btn btn-secondary" disabled> <span id="overrider-spinner-btn" class="overrider-spinner-btn icon-spinner icon-spin" aria-hidden="true"></span> <?php echo Text::_('COM_LANGUAGES_VIEW_OVERRIDE_MORE_RESULTS'); ?> </button> </span> </fieldset> <input type="hidden" name="task" value=""> <input type="hidden" name="id" value="<?php echo $this->item->key; ?>"> <?php echo HTMLHelper::_('form.token'); ?> </div> </div> </form> tmpl/languages/default.php 0000644 00000025121 15172750553 0011636 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2008 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Layout\LayoutHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; /** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ $wa = $this->document->getWebAssetManager(); $wa->useScript('table.columns') ->useScript('multiselect'); $user = Factory::getUser(); $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); $saveOrder = $listOrder == 'a.ordering'; if ($saveOrder && !empty($this->items)) { $saveOrderingUrl = 'index.php?option=com_languages&task=languages.saveOrderAjax&tmpl=component&' . Session::getFormToken() . '=1'; HTMLHelper::_('draggablelist.draggable'); } ?> <form action="<?php echo Route::_('index.php?option=com_languages&view=languages'); ?>" method="post" name="adminForm" id="adminForm"> <div class="row"> <div class="col-md-12"> <div id="j-main-container" class="j-main-container"> <?php echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this]); ?> <?php if (empty($this->items)) : ?> <div class="alert alert-info"> <span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('INFO'); ?></span> <?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?> </div> <?php else : ?> <table class="table" id="languageList"> <caption class="visually-hidden"> <?php echo Text::_('COM_LANGUAGES_CONTENT_TABLE_CAPTION'); ?>, <span id="orderedBy"><?php echo Text::_('JGLOBAL_SORTED_BY'); ?> </span>, <span id="filteredBy"><?php echo Text::_('JGLOBAL_FILTERED_BY'); ?></span> </caption> <thead> <tr> <td class="w-1 text-center"> <?php echo HTMLHelper::_('grid.checkall'); ?> </td> <th scope="col" class="w-1 text-center d-none d-md-table-cell"> <?php echo HTMLHelper::_('searchtools.sort', '', 'a.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-sort'); ?> </th> <th scope="col" class="w-1 text-center"> <?php echo HTMLHelper::_('searchtools.sort', 'JSTATUS', 'a.published', $listDirn, $listOrder); ?> </th> <th scope="col" class="title"> <?php echo HTMLHelper::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?> </th> <th scope="col" class="title d-none d-md-table-cell"> <?php echo HTMLHelper::_('searchtools.sort', 'COM_LANGUAGES_HEADING_TITLE_NATIVE', 'a.title_native', $listDirn, $listOrder); ?> </th> <th scope="col" class="w-10 d-none d-md-table-cell text-center"> <?php echo HTMLHelper::_('searchtools.sort', 'COM_LANGUAGES_HEADING_LANG_TAG', 'a.lang_code', $listDirn, $listOrder); ?> </th> <th scope="col" class="w-10 d-none d-md-table-cell text-center"> <?php echo HTMLHelper::_('searchtools.sort', 'COM_LANGUAGES_HEADING_LANG_CODE', 'a.sef', $listDirn, $listOrder); ?> </th> <th scope="col" class="w-10 d-none d-md-table-cell"> <?php echo HTMLHelper::_('searchtools.sort', 'COM_LANGUAGES_HEADING_LANG_IMAGE', 'a.image', $listDirn, $listOrder); ?> </th> <th scope="col" class="w-10 d-none d-md-table-cell text-center"> <?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ACCESS', 'a.access', $listDirn, $listOrder); ?> </th> <th scope="col" class="w-10 d-none d-md-table-cell text-center"> <?php echo HTMLHelper::_('searchtools.sort', 'COM_LANGUAGES_HEADING_HOMEPAGE', 'l.home', $listDirn, $listOrder); ?> </th> <th scope="col" class="w-5 d-none d-md-table-cell text-center"> <?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.lang_id', $listDirn, $listOrder); ?> </th> </tr> </thead> <tbody<?php if ($saveOrder) : ?> class="js-draggable" data-url="<?php echo $saveOrderingUrl; ?>" data-direction="<?php echo strtolower($listDirn); ?>"<?php endif; ?>> <?php foreach ($this->items as $i => $item) : $canCreate = $user->authorise('core.create', 'com_languages'); $canEdit = $user->authorise('core.edit', 'com_languages'); $canChange = $user->authorise('core.edit.state', 'com_languages'); ?> <tr class="row<?php echo $i % 2; ?>"> <td> <?php echo HTMLHelper::_('grid.id', $i, $item->lang_id, false, 'cid', 'cb', $item->title); ?> </td> <td class="text-center d-none d-md-table-cell"> <?php if ($canChange) : $disableClassName = ''; $disabledLabel = ''; if (!$saveOrder) : $disabledLabel = Text::_('JORDERINGDISABLED'); $disableClassName = 'inactive'; endif; ?> <span class="sortable-handler <?php echo $disableClassName; ?>" title="<?php echo $disabledLabel; ?>"> <span class="icon-ellipsis-v" aria-hidden="true"></span> </span> <input type="text" name="order[]" size="5" value="<?php echo $item->ordering; ?>" class="width-20 text-area-order hidden"> <?php else : ?> <span class="sortable-handler inactive"> <span class="icon-ellipsis-v" aria-hidden="true"></span> </span> <?php endif; ?> </td> <td class="text-center"> <?php echo HTMLHelper::_('jgrid.published', $item->published, $i, 'languages.', $canChange); ?> </td> <th scope="row"> <?php if ($canEdit) : ?> <a href="<?php echo Route::_('index.php?option=com_languages&task=language.edit&lang_id=' . (int) $item->lang_id); ?>" title="<?php echo Text::_('JACTION_EDIT'); ?> <?php echo $this->escape($item->title); ?>"> <?php echo $this->escape($item->title); ?></a> <?php else : ?> <?php echo $this->escape($item->title); ?> <?php endif; ?> </th> <td class="d-none d-md-table-cell"> <?php echo $this->escape($item->title_native); ?> </td> <td class="d-none d-md-table-cell text-center"> <?php echo $this->escape($item->lang_code); ?> </td> <td class="d-none d-md-table-cell text-center"> <?php echo $this->escape($item->sef); ?> </td> <td class="d-none d-md-table-cell"> <?php if ($item->image) : ?> <?php echo HTMLHelper::_('image', 'mod_languages/' . $item->image . '.gif', $item->image, ['class' => 'me-1'], true); ?><?php echo $this->escape($item->image); ?> <?php else : ?> <?php echo Text::_('JNONE'); ?> <?php endif; ?> </td> <td class="d-none d-md-table-cell text-center"> <?php echo $this->escape($item->access_level); ?> </td> <td class="d-none d-md-table-cell text-center"> <?php echo ($item->home == '1') ? Text::_('JYES') : Text::_('JNO'); ?> </td> <td class="d-none d-md-table-cell text-center"> <?php echo $this->escape($item->lang_id); ?> </td> </tr> <?php endforeach; ?> </tbody> </table> <?php // load the pagination. ?> <?php echo $this->pagination->getListFooter(); ?> <?php endif; ?> <input type="hidden" name="task" value=""> <input type="hidden" name="boxchecked" value="0"> <?php echo HTMLHelper::_('form.token'); ?> </div> </div> </div> </form> tmpl/languages/default.xml 0000644 00000000330 15172750553 0011642 0 ustar 00 <?xml version="1.0" encoding="UTF-8"?> <metadata> <layout title="COM_LANGUAGES_LANGUAGES_VIEW_DEFAULT_TITLE"> <message> <![CDATA[COM_LANGUAGES_LANGUAGES_VIEW_DEFAULT_DESC]]> </message> </layout> </metadata> tmpl/language/edit.php 0000644 00000007634 15172750553 0010765 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Router\Route; /** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ $wa = $this->document->getWebAssetManager(); $wa->useScript('keepalive') ->useScript('form.validate') ->useScript('com_languages.admin-language-edit-change-flag'); ?> <h2><?php echo $this->escape($this->form->getValue('title', null, Text::_('COM_LANGUAGES_LANGUAGE_NEW_LANGUAGE_TITLE'))); ?></h2> <form action="<?php echo Route::_('index.php?option=com_languages&view=language&layout=edit&lang_id=' . (int) $this->item->lang_id); ?>" method="post" name="adminForm" id="language-form" aria-label="<?php echo Text::_('COM_LANGUAGES_LANGUAGE_FORM_' . ((int) $this->item->lang_id === 0 ? 'NEW' : 'EDIT'), true); ?>" class="main-card form-validate"> <?php echo HTMLHelper::_('uitab.startTabSet', 'myTab', ['active' => 'details', 'recall' => true, 'breakpoint' => 768]); ?> <?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'details', Text::_('JDETAILS')); ?> <fieldset id="fieldset-details" class="options-form"> <legend><?php echo Text::_('JDETAILS'); ?></legend> <div> <?php echo $this->form->renderField('title'); ?> <?php echo $this->form->renderField('title_native'); ?> <?php echo $this->form->renderField('lang_code'); ?> <?php echo $this->form->renderField('sef'); ?> <div class="control-group"> <div class="control-label"> <?php echo $this->form->getLabel('image'); ?> </div> <div class="controls"> <?php echo $this->form->getInput('image'); ?> <span id="flag"> <?php echo HTMLHelper::_('image', 'mod_languages/' . $this->form->getValue('image') . '.gif', $this->form->getValue('image'), null, true); ?> </span> </div> </div> <?php if ($this->canDo->get('core.edit.state')) : ?> <?php echo $this->form->renderField('published'); ?> <?php endif; ?> <?php echo $this->form->renderField('access'); ?> <?php echo $this->form->renderField('description'); ?> <?php echo $this->form->renderField('lang_id'); ?> </div> </fieldset> <?php echo HTMLHelper::_('uitab.endTab'); ?> <?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'metadata', Text::_('JGLOBAL_FIELDSET_OPTIONS')); ?> <div class="row"> <div class="col-md-6 mb-3"> <fieldset id="fieldset-sitename" class="options-form"> <legend><?php echo Text::_('COM_LANGUAGES_FIELDSET_SITE_NAME_LABEL'); ?></legend> <div> <?php echo $this->form->renderFieldset('site_name'); ?> </div> </fieldset> </div> <div class="col-md-6 mb-3"> <fieldset id="fieldset-metadata" class="options-form"> <legend><?php echo Text::_('JGLOBAL_FIELDSET_METADATA_OPTIONS'); ?></legend> <div> <?php echo $this->form->renderFieldset('metadata'); ?> </div> </fieldset> </div> </div> <?php echo HTMLHelper::_('uitab.endTab'); ?> <?php echo HTMLHelper::_('uitab.endTabSet'); ?> <input type="hidden" name="task" value=""> <?php echo HTMLHelper::_('form.token'); ?> </form> tmpl/overrides/default.php 0000644 00000014664 15172750553 0011704 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\LanguageHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Layout\LayoutHelper; use Joomla\CMS\Router\Route; /** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ $wa = $this->document->getWebAssetManager(); $wa->useScript('table.columns') ->useScript('multiselect'); $client = $this->state->get('filter.client') == 'site' ? Text::_('JSITE') : Text::_('JADMINISTRATOR'); $language = $this->state->get('filter.language'); $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); $oppositeClient = $this->state->get('filter.client') == 'administrator' ? Text::_('JSITE') : Text::_('JADMINISTRATOR'); $oppositeFilename = constant('JPATH_' . strtoupper($this->state->get('filter.client') === 'site' ? 'administrator' : 'site')) . '/language/overrides/' . $this->state->get('filter.language', 'en-GB') . '.override.ini'; $oppositeStrings = LanguageHelper::parseIniFile($oppositeFilename); ?> <form action="<?php echo Route::_('index.php?option=com_languages&view=overrides'); ?>" method="post" name="adminForm" id="adminForm"> <div class="row"> <div class="col-md-12"> <div id="j-main-container" class="j-main-container"> <?php echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this, 'options' => ['selectorFieldName' => 'language_client']]); ?> <div class="clearfix"></div> <?php if (empty($this->items)) : ?> <div class="alert alert-info"> <span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('INFO'); ?></span> <?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?> </div> <?php else : ?> <table class="table" id="overrideList"> <caption class="visually-hidden"> <?php echo Text::_('COM_LANGUAGES_OVERRIDES_TABLE_CAPTION'); ?>, <span id="orderedBy"><?php echo Text::_('JGLOBAL_SORTED_BY'); ?> </span>, <span id="filteredBy"><?php echo Text::_('JGLOBAL_FILTERED_BY'); ?></span> </caption> <thead> <tr> <td class="w-1 text-center"> <?php echo HTMLHelper::_('grid.checkall'); ?> </td> <th scope="col" class="w-30"> <?php echo HTMLHelper::_('searchtools.sort', 'COM_LANGUAGES_VIEW_OVERRIDES_KEY', 'key', $listDirn, $listOrder); ?> </th> <th scope="col" class="d-none d-md-table-cell"> <?php echo HTMLHelper::_('searchtools.sort', 'COM_LANGUAGES_VIEW_OVERRIDES_TEXT', 'text', $listDirn, $listOrder); ?> </th> <th scope="col" class="d-none d-md-table-cell"> <?php echo Text::_('COM_LANGUAGES_FIELD_LANG_TAG_LABEL'); ?> </th> <th scope="col" class="d-none d-md-table-cell"> <?php echo Text::_('JCLIENT'); ?> </th> </tr> </thead> <tbody> <?php $canEdit = Factory::getUser()->authorise('core.edit', 'com_languages'); ?> <?php $i = 0; ?> <?php foreach ($this->items as $key => $text) : ?> <tr class="row<?php echo $i % 2; ?>" id="overriderrow<?php echo $i; ?>"> <td class="text-center"> <?php echo HTMLHelper::_('grid.id', $i, $key, false, 'cid', 'cb', $key); ?> </td> <th scope="row"> <?php if ($canEdit) : ?> <a id="key[<?php echo $this->escape($key); ?>]" href="<?php echo Route::_('index.php?option=com_languages&task=override.edit&id=' . $key); ?>" title="<?php echo Text::_('JACTION_EDIT'); ?> <?php echo $this->escape($key); ?>"> <?php echo $this->escape($key); ?></a> <?php else : ?> <?php echo $this->escape($key); ?> <?php endif; ?> </th> <td class="d-none d-md-table-cell"> <span id="string[<?php echo $this->escape($key); ?>]"><?php echo HTMLHelper::_('string.truncate', $this->escape($text), 200); ?></span> </td> <td class="d-none d-md-table-cell"> <?php echo $language; ?> </td> <td class="d-none d-md-table-cell"> <?php echo $client; if (isset($oppositeStrings[$key]) && $oppositeStrings[$key] === $text) : echo '/' . $oppositeClient; endif; ?> </td> </tr> <?php $i++; ?> <?php endforeach; ?> </tbody> </table> <?php // load the pagination. ?> <?php echo $this->pagination->getListFooter(); ?> <?php endif; ?> <input type="hidden" name="task" value=""> <input type="hidden" name="boxchecked" value="0"> <?php echo HTMLHelper::_('form.token'); ?> </div> </div> </div> </form> tmpl/overrides/default.xml 0000644 00000000326 15172750553 0011703 0 ustar 00 <?xml version="1.0" encoding="UTF-8"?> <metadata> <layout title="COM_LANGUAGES_OVERRIDE_VIEW_DEFAULT_TITLE"> <message> <![CDATA[COM_LANGUAGES_OVERRIDE_VIEW_DEFAULT_DESC]]> </message> </layout> </metadata> tmpl/installed/default.xml 0000644 00000000330 15172750553 0011653 0 ustar 00 <?xml version="1.0" encoding="UTF-8"?> <metadata> <layout title="COM_LANGUAGES_INSTALLED_VIEW_DEFAULT_TITLE"> <message> <![CDATA[COM_LANGUAGES_INSTALLED_VIEW_DEFAULT_DESC]]> </message> </layout> </metadata> tmpl/installed/default.php 0000644 00000020170 15172750553 0011646 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_languages * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Layout\LayoutHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\String\PunycodeHelper; use Joomla\CMS\Version; /** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ $wa = $this->document->getWebAssetManager(); $wa->useScript('table.columns'); $user = Factory::getUser(); $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); ?> <form action="<?php echo Route::_('index.php?option=com_languages&view=installed'); ?>" method="post" id="adminForm" name="adminForm"> <div class="row"> <div class="col-md-12"> <div id="j-main-container" class="j-main-container"> <?php echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this]); ?> <?php if (empty($this->rows)) : ?> <div class="alert alert-info"> <span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('INFO'); ?></span> <?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?> </div> <?php else : ?> <table class="table"> <caption class="visually-hidden"> <?php echo Text::_('COM_LANGUAGES_INSTALLED_TABLE_CAPTION'); ?>, <span id="orderedBy"><?php echo Text::_('JGLOBAL_SORTED_BY'); ?> </span>, <span id="filteredBy"><?php echo Text::_('JGLOBAL_FILTERED_BY'); ?></span> </caption> <thead> <tr> <td class="w-1">   </td> <th scope="col" class="w-15"> <?php echo HTMLHelper::_('searchtools.sort', 'JGLOBAL_TITLE', 'name', $listDirn, $listOrder); ?> </th> <th scope="col" class="w-15 d-none d-md-table-cell"> <?php echo HTMLHelper::_('searchtools.sort', 'COM_LANGUAGES_HEADING_TITLE_NATIVE', 'nativeName', $listDirn, $listOrder); ?> </th> <th scope="col" class="text-center"> <?php echo HTMLHelper::_('searchtools.sort', 'COM_LANGUAGES_HEADING_LANG_TAG', 'language', $listDirn, $listOrder); ?> </th> <th scope="col" class="w-5 text-center"> <?php echo HTMLHelper::_('searchtools.sort', 'COM_LANGUAGES_HEADING_DEFAULT', 'published', $listDirn, $listOrder); ?> </th> <th scope="col" class="w-5 d-none d-md-table-cell text-center"> <?php echo HTMLHelper::_('searchtools.sort', 'COM_LANGUAGES_HEADING_VERSION', 'version', $listDirn, $listOrder); ?> </th> <th scope="col" class="w-10 d-none d-md-table-cell text-center"> <?php echo HTMLHelper::_('searchtools.sort', 'COM_LANGUAGES_HEADING_DATE', 'creationDate', $listDirn, $listOrder); ?> </th> <th scope="col" class="w-10 d-none d-md-table-cell text-center"> <?php echo HTMLHelper::_('searchtools.sort', 'COM_LANGUAGES_HEADING_AUTHOR', 'author', $listDirn, $listOrder); ?> </th> <th scope="col" class="w-10 d-none d-md-table-cell text-center"> <?php echo HTMLHelper::_('searchtools.sort', 'COM_LANGUAGES_HEADING_AUTHOR_EMAIL', 'authorEmail', $listDirn, $listOrder); ?> </th> <th scope="col" class="w-5 d-none d-md-table-cell text-center"> <?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ID', 'extension_id', $listDirn, $listOrder); ?> </th> </tr> </thead> <tbody> <?php $version = new Version(); $currentShortVersion = preg_replace('#^([0-9\.]+)(|.*)$#', '$1', $version->getShortVersion()); foreach ($this->rows as $i => $row) : $canCreate = $user->authorise('core.create', 'com_languages'); $canEdit = $user->authorise('core.edit', 'com_languages'); $canChange = $user->authorise('core.edit.state', 'com_languages'); ?> <tr class="row<?php echo $i % 2; ?>"> <td> <?php echo HTMLHelper::_('languages.id', $i, $row->language); ?> </td> <th scope="row"> <label for="cb<?php echo $i; ?>"> <?php echo $this->escape($row->name); ?> </label> </th> <td class="d-none d-md-table-cell"> <?php echo $this->escape($row->nativeName); ?> </td> <td class="text-center"> <?php echo $this->escape($row->language); ?> </td> <td class="text-center"> <?php echo HTMLHelper::_('jgrid.isdefault', $row->published, $i, 'installed.', !$row->published && $canChange); ?> </td> <td class="d-none d-md-table-cell text-center"> <?php $minorVersion = $version::MAJOR_VERSION . '.' . $version::MINOR_VERSION; ?> <?php // Display a Note if language pack version is not equal to Joomla version ?> <?php if (strpos($row->version, $minorVersion) !== 0 || strpos($row->version, $currentShortVersion) !== 0) : ?> <span class="badge bg-warning text-dark" title="<?php echo Text::_('JGLOBAL_LANGUAGE_VERSION_NOT_PLATFORM'); ?>"><?php echo $row->version; ?></span> <?php else : ?> <span class="badge bg-success"><?php echo $row->version; ?></span> <?php endif; ?> </td> <td class="d-none d-md-table-cell text-center"> <?php echo $this->escape($row->creationDate); ?> </td> <td class="d-none d-md-table-cell text-center"> <?php echo $this->escape($row->author); ?> </td> <td class="d-none d-md-table-cell text-center"> <?php echo $this->escape(PunycodeHelper::emailToUTF8($row->authorEmail)); ?> </td> <td class="d-none d-md-table-cell text-center"> <?php echo $this->escape($row->extension_id); ?> </td> </tr> <?php endforeach; ?> </tbody> </table> <?php // load the pagination. ?> <?php echo $this->pagination->getListFooter(); ?> <?php endif; ?> <input type="hidden" name="task" value=""> <input type="hidden" name="boxchecked" value="0"> <?php echo HTMLHelper::_('form.token'); ?> </div> </div> </div> </form> forms/filter_languages.xml 0000644 00000004630 15172750553 0011744 0 ustar 00 <?xml version="1.0" encoding="UTF-8"?> <form> <fields name="filter"> <field name="search" type="text" inputmode="search" label="JSEARCH_FILTER" description="COM_LANGUAGES_SEARCH_IN_TITLE" hint="JSEARCH_FILTER" /> <field name="published" type="status" label="JSTATUS" optionsFilter="1,0,-2,*" class="js-select-submit-on-change" > <option value="">JOPTION_SELECT_PUBLISHED</option> </field> <field name="access" type="accesslevel" label="JGRID_HEADING_ACCESS" class="js-select-submit-on-change" > <option value="">JOPTION_SELECT_ACCESS</option> </field> </fields> <fields name="list"> <field name="fullordering" type="list" label="JGLOBAL_SORT_BY" class="js-select-submit-on-change" default="a.ordering ASC" validate="options" > <option value="">JGLOBAL_SORT_BY</option> <option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option> <option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option> <option value="a.published ASC">JSTATUS_ASC</option> <option value="a.published DESC">JSTATUS_DESC</option> <option value="a.title ASC">JGLOBAL_TITLE_ASC</option> <option value="a.title DESC">JGLOBAL_TITLE_DESC</option> <option value="a.title_native ASC">COM_LANGUAGES_HEADING_TITLE_NATIVE_ASC</option> <option value="a.title_native DESC">COM_LANGUAGES_HEADING_TITLE_NATIVE_DESC</option> <option value="a.lang_code ASC">COM_LANGUAGES_HEADING_LANG_TAG_ASC</option> <option value="a.lang_code DESC">COM_LANGUAGES_HEADING_LANG_TAG_DESC</option> <option value="a.sef ASC">COM_LANGUAGES_HEADING_LANG_CODE_ASC</option> <option value="a.sef DESC">COM_LANGUAGES_HEADING_LANG_CODE_DESC</option> <option value="a.image ASC">COM_LANGUAGES_HEADING_LANG_IMAGE_ASC</option> <option value="a.image DESC">COM_LANGUAGES_HEADING_LANG_IMAGE_DESC</option> <option value="a.access ASC">JGRID_HEADING_ACCESS_ASC</option> <option value="a.access DESC">JGRID_HEADING_ACCESS_DESC</option> <option value="l.home ASC">COM_LANGUAGES_HEADING_HOMEPAGE_ASC</option> <option value="l.home DESC">COM_LANGUAGES_HEADING_HOMEPAGE_DESC</option> <option value="a.lang_id ASC">JGRID_HEADING_ID_ASC</option> <option value="a.lang_id DESC">JGRID_HEADING_ID_DESC</option> </field> <field name="limit" type="limitbox" label="JGLOBAL_LIST_LIMIT" default="25" class="js-select-submit-on-change" /> </fields> </form> forms/filter_installed.xml 0000644 00000004426 15172750553 0011760 0 ustar 00 <?xml version="1.0" encoding="UTF-8"?> <form> <field name="client_id" type="list" label="JSITEADMIN" class="js-select-submit-on-change" filtermode="selector" validate="options" > <option value="0">JSITE</option> <option value="1">JADMINISTRATOR</option> </field> <fields name="filter"> <field name="search" type="text" inputmode="search" label="COM_LANGUAGES_INSTALLED_FILTER_SEARCH_LABEL" description="COM_LANGUAGES_INSTALLED_FILTER_SEARCH_DESC" hint="JSEARCH_FILTER" noresults="JGLOBAL_NO_MATCHING_RESULTS" /> </fields> <fields name="list"> <field name="fullordering" type="list" label="JGLOBAL_SORT_BY" class="js-select-submit-on-change" default="name ASC" validate="options" > <option value="">JGLOBAL_SORT_BY</option> <option value="name ASC">COM_LANGUAGES_HEADING_TITLE_ASC</option> <option value="name DESC">COM_LANGUAGES_HEADING_TITLE_DESC</option> <option value="nativeName ASC">COM_LANGUAGES_HEADING_TITLE_NATIVE_ASC</option> <option value="nativeName DESC">COM_LANGUAGES_HEADING_TITLE_NATIVE_DESC</option> <option value="language ASC">COM_LANGUAGES_HEADING_LANG_TAG_ASC</option> <option value="language DESC">COM_LANGUAGES_HEADING_LANG_TAG_DESC</option> <option value="published ASC">COM_LANGUAGES_HEADING_DEFAULT_ASC</option> <option value="published DESC">COM_LANGUAGES_HEADING_DEFAULT_DESC</option> <option value="version ASC">COM_LANGUAGES_HEADING_VERSION_ASC</option> <option value="version DESC">COM_LANGUAGES_HEADING_VERSION_DESC</option> <option value="creationDate ASC">COM_LANGUAGES_HEADING_DATE_ASC</option> <option value="creationDate DESC">COM_LANGUAGES_HEADING_DATE_DESC</option> <option value="author ASC">COM_LANGUAGES_HEADING_AUTHOR_ASC</option> <option value="author DESC">COM_LANGUAGES_HEADING_AUTHOR_DESC</option> <option value="authorEmail ASC">COM_LANGUAGES_HEADING_AUTHOR_EMAIL_ASC</option> <option value="authorEmail DESC">COM_LANGUAGES_HEADING_AUTHOR_EMAIL_DESC</option> <option value="extension_id ASC">JGRID_HEADING_ID_ASC</option> <option value="extension_id DESC">JGRID_HEADING_ID_DESC</option> </field> <field name="limit" type="limitbox" label="JGLOBAL_LIST_LIMIT" default="25" class="js-select-submit-on-change" /> </fields> </form> forms/override.xml 0000644 00000003066 15172750553 0010252 0 ustar 00 <?xml version="1.0" encoding="UTF-8"?> <form> <fieldset> <field name="key" type="text" label="COM_LANGUAGES_OVERRIDE_FIELD_KEY_LABEL" required="true" filter="\Joomla\Component\Languages\Administrator\Helper\LanguagesHelper::filterKey" /> <field name="override" type="textarea" label="COM_LANGUAGES_OVERRIDE_FIELD_OVERRIDE_LABEL" cols="50" rows="5" filter="\Joomla\Component\Languages\Administrator\Helper\LanguagesHelper::filterText" /> <field name="both" type="checkbox" label="COM_LANGUAGES_OVERRIDE_FIELD_BOTH_LABEL" value="true" filter="boolean" /> <field name="searchstring" type="text" label="COM_LANGUAGES_OVERRIDE_FIELD_SEARCHSTRING_LABEL" /> <field name="searchtype" type="list" label="COM_LANGUAGES_OVERRIDE_FIELD_SEARCHTYPE_LABEL" default="value" validate="options" > <option value="constant">COM_LANGUAGES_OVERRIDE_FIELD_SEARCHTYPE_CONSTANT</option> <option value="value">COM_LANGUAGES_OVERRIDE_FIELD_SEARCHTYPE_TEXT</option> </field> <field name="language" type="text" label="COM_LANGUAGES_OVERRIDE_FIELD_LANGUAGE_LABEL" filter="unset" readonly="true" class="readonly" /> <field name="client" type="text" label="COM_LANGUAGES_OVERRIDE_FIELD_CLIENT_LABEL" filter="unset" readonly="true" class="readonly" /> <field name="file" type="text" label="COM_LANGUAGES_OVERRIDE_FIELD_FILE_LABEL" filter="unset" readonly="true" class="readonly" /> <field name="id" type="hidden" /> </fieldset> </form> forms/language.xml 0000644 00000004016 15172750553 0010212 0 ustar 00 <?xml version="1.0" encoding="UTF-8"?> <form> <fieldset> <field name="lang_id" type="text" label="JGLOBAL_FIELD_ID_LABEL" class="readonly" default="0" readonly="true" /> <field name="lang_code" type="text" label="COM_LANGUAGES_FIELD_LANG_TAG_LABEL" description="COM_LANGUAGES_FIELD_LANG_TAG_DESC" maxlength="7" required="true" /> <field name="title" type="text" label="JGLOBAL_TITLE" maxlength="50" required="true" /> <field name="title_native" type="text" label="COM_LANGUAGES_FIELD_TITLE_NATIVE_LABEL" maxlength="50" required="true" /> <field name="sef" type="text" label="COM_LANGUAGES_FIELD_LANG_CODE_LABEL" description="COM_LANGUAGES_FIELD_LANG_CODE_DESC" maxlength="50" required="true" /> <field name="image" type="filelist" label="COM_LANGUAGES_FIELD_IMAGE_LABEL" stripext="1" directory="media/mod_languages/images/" hide_none="1" hide_default="1" fileFilter="\.gif$" validate="options" > <option value="">JNONE</option> </field> <field name="description" type="textarea" label="JGLOBAL_DESCRIPTION" cols="80" rows="5" /> <field name="published" type="list" label="JSTATUS" class="form-select-color-state" default="1" validate="options" > <option value="1">JPUBLISHED</option> <option value="0">JUNPUBLISHED</option> <option value="-2">JTRASHED</option> </field> <field name="access" type="accesslevel" label="JFIELD_ACCESS_LABEL" filter="UINT" validate="options" /> </fieldset> <fieldset name="metadata" label="JGLOBAL_FIELDSET_METADATA_OPTIONS"> <field name="metadesc" type="textarea" label="JFIELD_META_DESCRIPTION_LABEL" rows="3" cols="30" maxlength="160" charcounter="true" /> </fieldset> <fieldset name="site_name" label="COM_LANGUAGES_FIELDSET_SITE_NAME_LABEL"> <field name="sitename" type="text" label="COM_LANGUAGES_FIELD_SITE_NAME_LABEL" filter="string" /> </fieldset> </form> forms/filter_overrides.xml 0000644 00000002374 15172750553 0012003 0 ustar 00 <?xml version="1.0" encoding="UTF-8"?> <form> <field name="language_client" type="languageclient" label="COM_LANGUAGES_OVERRIDE_SELECT_LANGUAGECLIENT" class="js-select-submit-on-change" filtermode="selector" addfieldprefix="Joomla\Component\Languages\Administrator\Field" > <option value="">COM_LANGUAGES_OVERRIDE_SELECT_LANGUAGE</option> </field> <fields name="filter"> <field name="search" type="text" inputmode="search" label="JSEARCH_FILTER" description="COM_LANGUAGES_VIEW_OVERRIDES_FILTER_SEARCH_DESC" hint="JSEARCH_FILTER" /> </fields> <fields name="list"> <field name="fullordering" type="list" label="JGLOBAL_SORT_BY" class="js-select-submit-on-change" default="key ASC" validate="options" > <option value="">JGLOBAL_SORT_BY</option> <option value="key ASC">COM_LANGUAGES_VIEW_OVERRIDES_KEY_ASC</option> <option value="key DESC">COM_LANGUAGES_VIEW_OVERRIDES_KEY_DESC</option> <option value="text ASC">COM_LANGUAGES_VIEW_OVERRIDES_TEXT_ASC</option> <option value="text DESC">COM_LANGUAGES_VIEW_OVERRIDES_TEXT_DESC</option> </field> <field name="limit" type="limitbox" label="JGLOBAL_LIST_LIMIT" default="25" class="js-select-submit-on-change" /> </fields> </form> access.xml 0000644 00000000707 15172750553 0006545 0 ustar 00 <?xml version="1.0" encoding="UTF-8"?> <access component="com_languages"> <section name="component"> <action name="core.admin" title="JACTION_ADMIN" /> <action name="core.manage" title="JACTION_MANAGE" /> <action name="core.create" title="JACTION_CREATE" /> <action name="core.delete" title="JACTION_DELETE" /> <action name="core.edit" title="JACTION_EDIT" /> <action name="core.edit.state" title="JACTION_EDITSTATE" /> </section> </access> src/View/Overrides/JsonapiView.php 0000644 00000004631 15173030063 0013160 0 ustar 00 <?php /** * @package Joomla.API * @subpackage com_languages * * @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Api\View\Overrides; use Joomla\CMS\MVC\View\JsonApiView as BaseApiView; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * The overrides view * * @since 4.0.0 */ class JsonapiView extends BaseApiView { /** * The fields to render item in the documents * * @var array * @since 4.0.0 */ protected $fieldsToRenderItem = ['value']; /** * The fields to render items in the documents * * @var array * @since 4.0.0 */ protected $fieldsToRenderList = ['value']; /** * Execute and display a template script. * * @param object $item Item * * @return string * * @since 4.0.0 */ public function displayItem($item = null) { /** @var \Joomla\Component\Languages\Administrator\Model\OverrideModel $model */ $model = $this->getModel(); $id = $model->getState($model->getName() . '.id'); $item = $this->prepareItem($model->getItem($id)); return parent::displayItem($item); } /** * Execute and display a template script. * * @param array|null $items Array of items * * @return string * * @since 4.0.0 */ public function displayList(array $items = null) { /** @var \Joomla\Component\Languages\Administrator\Model\OverridesModel $model */ $model = $this->getModel(); $items = []; foreach ($model->getOverrides() as $key => $override) { $item = (object) [ 'key' => $key, 'override' => $override, ]; $items[] = $this->prepareItem($item); } return parent::displayList($items); } /** * Prepare item before render. * * @param object $item The model item * * @return object * * @since 4.0.0 */ protected function prepareItem($item) { $item->id = $item->key; $item->value = $item->override; unset($item->key); unset($item->override); return parent::prepareItem($item); } } src/View/Languages/JsonapiView.php 0000644 00000003417 15173030063 0013125 0 ustar 00 <?php /** * @package Joomla.API * @subpackage com_languages * * @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Api\View\Languages; use Joomla\CMS\MVC\View\JsonApiView as BaseApiView; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * The languages view * * @since 4.0.0 */ class JsonapiView extends BaseApiView { /** * The fields to render item in the documents * * @var array * @since 4.0.0 */ protected $fieldsToRenderItem = [ 'id', 'asset_id', 'lang_code', 'title', 'title_native', 'sef', 'image', 'description', 'metakey', 'metadesc', 'sitename', 'published', 'access', 'ordering', 'access_level', 'home', ]; /** * The fields to render items in the documents * * @var array * @since 4.0.0 */ protected $fieldsToRenderList = [ 'id', 'asset_id', 'lang_code', 'title', 'title_native', 'sef', 'image', 'description', 'metakey', 'metadesc', 'sitename', 'published', 'access', 'ordering', 'access_level', 'home', ]; /** * Prepare item before render. * * @param object $item The model item * * @return object * * @since 4.0.0 */ protected function prepareItem($item) { $item->id = $item->lang_id; unset($item->lang->id); return parent::prepareItem($item); } } src/View/Strings/JsonapiView.php 0000644 00000004646 15173030063 0012655 0 ustar 00 <?php /** * @package Joomla.API * @subpackage com_languages * * @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Languages\Api\View\Strings; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\View\GenericDataException; use Joomla\CMS\MVC\View\JsonApiView as BaseApiView; use Joomla\CMS\Serializer\JoomlaSerializer; use Tobscure\JsonApi\Collection; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * The strings view * * @since 4.0.0 */ class JsonapiView extends BaseApiView { /** * The fields to render items in the documents * * @var array * @since 4.0.0 */ protected $fieldsToRenderList = [ 'id', 'string', 'file', ]; /** * Execute and display a template script. * * @param array|null $items Array of items * * @return string * * @since 4.0.0 */ public function displayList(array $items = null) { /** @var \Joomla\Component\Languages\Administrator\Model\StringsModel $model */ $model = $this->getModel(); $result = $model->search(); if ($result instanceof \Exception) { throw $result; } $items = []; foreach ($result['results'] as $item) { $items[] = $this->prepareItem($item); } // Check for errors. if (\count($errors = $this->get('Errors'))) { throw new GenericDataException(implode("\n", $errors), 500); } if ($this->type === null) { throw new \RuntimeException(Text::_('JLIB_APPLICATION_ERROR_CONTENT_TYPE_MISSING'), 400); } $collection = (new Collection($items, new JoomlaSerializer($this->type))) ->fields([$this->type => $this->fieldsToRenderList]); // Set the data into the document and render it $this->getDocument()->setData($collection); return $this->getDocument()->render(); } /** * Prepare item before render. * * @param object $item The model item * * @return object * * @since 4.0.0 */ protected function prepareItem($item) { $item->id = $item->constant; unset($item->constant); return parent::prepareItem($item); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.23 | Generation time: 0 |
proxy
|
phpinfo
|
Settings