diff options
83 files changed, 1755 insertions, 1194 deletions
diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 959580d6c2..4ad6b6afa5 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -1,6 +1,8 @@ +/* global phpbb */ + (function($) { // Avoid conflicts with other libraries -"use strict"; +'use strict'; /** * The following callbacks are for reording items. row_down @@ -13,11 +15,10 @@ phpbb.addAjaxCallback('row_down', function(res) { return; } - var el = $(this), - tr = el.parents('tr'), - trSwap = tr.next(); + var $firstTr = $(this).parents('tr'), + $secondTr = $firstTr.next(); - tr.insertAfter(trSwap); + $firstTr.insertAfter($secondTr); }); phpbb.addAjaxCallback('row_up', function(res) { @@ -25,11 +26,10 @@ phpbb.addAjaxCallback('row_up', function(res) { return; } - var el = $(this), - tr = el.parents('tr'), - trSwap = tr.prev(); + var $secondTr = $(this).parents('tr'), + $firstTr = $secondTr.prev(); - tr.insertBefore(trSwap); + $secondTr.insertBefore($firstTr); }); /** @@ -38,10 +38,10 @@ phpbb.addAjaxCallback('row_up', function(res) { * in the href with "deactivate", and vice versa. */ phpbb.addAjaxCallback('activate_deactivate', function(res) { - var el = $(this), - newHref = el.attr('href'); + var $this = $(this), + newHref = $this.attr('href'); - el.text(res.text); + $this.text(res.text); if (newHref.indexOf('deactivate') !== -1) { newHref = newHref.replace('deactivate', 'activate'); @@ -49,7 +49,7 @@ phpbb.addAjaxCallback('activate_deactivate', function(res) { newHref = newHref.replace('activate', 'deactivate'); } - el.attr('href', newHref); + $this.attr('href', newHref); }); /** @@ -66,11 +66,10 @@ phpbb.addAjaxCallback('row_delete', function(res) { $('[data-ajax]').each(function() { var $this = $(this), - ajax = $this.attr('data-ajax'), - fn; + ajax = $this.attr('data-ajax'); if (ajax !== 'false') { - fn = (ajax !== 'true') ? ajax : null; + var fn = (ajax !== 'true') ? ajax : null; phpbb.ajaxify({ selector: this, refresh: $this.attr('data-refresh') !== undefined, @@ -82,7 +81,7 @@ $('[data-ajax]').each(function() { /** * Automatically resize textarea */ -$(document).ready(function() { +$(function() { phpbb.resizeTextArea($('textarea:not(.no-auto-resize)'), {minHeight: 75}); }); diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 388f31698f..802b4dd7c8 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -3,7 +3,7 @@ phpbb.alertTime = 100; (function($) { // Avoid conflicts with other libraries -"use strict"; +'use strict'; // define a couple constants for keydown functions. var keymap = { @@ -12,8 +12,8 @@ var keymap = { ESC: 27 }; -var dark = $('#darkenwrapper'); -var loadingIndicator = $('#loading_indicator'); +var $dark = $('#darkenwrapper'); +var $loadingIndicator = $('#loading_indicator'); var phpbbAlertTimer = null; phpbb.isTouch = (window && typeof window.ontouchstart !== 'undefined'); @@ -24,18 +24,20 @@ phpbb.isTouch = (window && typeof window.ontouchstart !== 'undefined'); * @returns object Returns loadingIndicator. */ phpbb.loadingIndicator = function() { - if (!loadingIndicator.is(':visible')) { - loadingIndicator.fadeIn(phpbb.alertTime); + if (!$loadingIndicator.is(':visible')) { + $loadingIndicator.fadeIn(phpbb.alertTime); // Wait fifteen seconds and display an error if nothing has been returned by then. phpbb.clearLoadingTimeout(); phpbbAlertTimer = setTimeout(function() { - if (loadingIndicator.is(':visible')) { - phpbb.alert($('#phpbb_alert').attr('data-l-err'), $('#phpbb_alert').attr('data-l-timeout-processing-req')); + var $alert = $('#phpbb_alert'); + + if ($loadingIndicator.is(':visible')) { + phpbb.alert($alert.attr('data-l-err'), $alert.attr('data-l-timeout-processing-req')); } }, 15000); } - return loadingIndicator; + return $loadingIndicator; }; /** @@ -73,24 +75,24 @@ phpbb.closeDarkenWrapper = function(delay) { * @returns object Returns the div created. */ phpbb.alert = function(title, msg, fadedark) { - var div = $('#phpbb_alert'); - div.find('.alert_title').html(title); - div.find('.alert_text').html(msg); + var $alert = $('#phpbb_alert'); + $alert.find('.alert_title').html(title); + $alert.find('.alert_text').html(msg); - if (!dark.is(':visible')) { - dark.fadeIn(phpbb.alertTime); + if (!$dark.is(':visible')) { + $dark.fadeIn(phpbb.alertTime); } - div.bind('click', function(e) { + $alert.on('click', function(e) { e.stopPropagation(); }); - dark.one('click', function(e) { + $dark.one('click', function(e) { var fade; - div.find('.alert_close').unbind('click'); - fade = (typeof fadedark !== 'undefined' && !fadedark) ? div : dark; + $alert.find('.alert_close').off('click'); + fade = (typeof fadedark !== 'undefined' && !fadedark) ? $alert : $dark; fade.fadeOut(phpbb.alertTime, function() { - div.hide(); + $alert.hide(); }); e.preventDefault(); @@ -98,35 +100,35 @@ phpbb.alert = function(title, msg, fadedark) { }); $(document).keydown(function(e) { - if ((e.keyCode === keymap.ENTER || e.keyCode === keymap.ESC) && dark.is(':visible')) { - dark.trigger('click'); + if ((e.keyCode === keymap.ENTER || e.keyCode === keymap.ESC) && $dark.is(':visible')) { + $dark.trigger('click'); e.preventDefault(); e.stopPropagation(); } }); - div.find('.alert_close').one('click', function(e) { - dark.trigger('click'); + $alert.find('.alert_close').one('click', function(e) { + $dark.trigger('click'); e.preventDefault(); }); - if (loadingIndicator.is(':visible')) { - loadingIndicator.fadeOut(phpbb.alertTime, function() { - dark.append(div); - div.fadeIn(phpbb.alertTime); + if ($loadingIndicator.is(':visible')) { + $loadingIndicator.fadeOut(phpbb.alertTime, function() { + $dark.append($alert); + $alert.fadeIn(phpbb.alertTime); }); - } else if (dark.is(':visible')) { - dark.append(div); - div.fadeIn(phpbb.alertTime); + } else if ($dark.is(':visible')) { + $dark.append($alert); + $alert.fadeIn(phpbb.alertTime); } else { - dark.append(div); - div.show(); - dark.fadeIn(phpbb.alertTime); + $dark.append($alert); + $alert.show(); + $dark.fadeIn(phpbb.alertTime); } - return div; + return $alert; }; /** @@ -143,24 +145,24 @@ phpbb.alert = function(title, msg, fadedark) { * @returns object Returns the div created. */ phpbb.confirm = function(msg, callback, fadedark) { - var div = $('#phpbb_confirm'); - div.find('.alert_text').html(msg); + var $confirmDiv = $('#phpbb_confirm'); + $confirmDiv.find('.alert_text').html(msg); - if (!dark.is(':visible')) { - dark.fadeIn(phpbb.alertTime); + if (!$dark.is(':visible')) { + $dark.fadeIn(phpbb.alertTime); } - div.bind('click', function(e) { + $confirmDiv.on('click', function(e) { e.stopPropagation(); }); var clickHandler = function(e) { var res = this.name === 'confirm'; - var fade = (typeof fadedark !== 'undefined' && !fadedark && res) ? div : dark; - fade.fadeOut(phpbb.alertTime, function() { - div.hide(); + var $fade = (typeof fadedark !== 'undefined' && !fadedark && res) ? $confirmDiv : $dark; + $fade.fadeOut(phpbb.alertTime, function() { + $confirmDiv.hide(); }); - div.find('input[type="button"]').unbind('click', clickHandler); + $confirmDiv.find('input[type="button"]').off('click', clickHandler); callback(res); if (e) { @@ -168,12 +170,12 @@ phpbb.confirm = function(msg, callback, fadedark) { e.stopPropagation(); } }; - div.find('input[type="button"]').one('click', clickHandler); + $confirmDiv.find('input[type="button"]').one('click', clickHandler); - dark.one('click', function(e) { - div.find('.alert_close').unbind('click'); - dark.fadeOut(phpbb.alertTime, function() { - div.hide(); + $dark.one('click', function(e) { + $confirmDiv.find('.alert_close').off('click'); + $dark.fadeOut(phpbb.alertTime, function() { + $confirmDiv.hide(); }); callback(false); @@ -181,7 +183,7 @@ phpbb.confirm = function(msg, callback, fadedark) { e.stopPropagation(); }); - $(document).bind('keydown', function(e) { + $(document).on('keydown', function(e) { if (e.keyCode === keymap.ENTER) { $('input[name="confirm"]').trigger('click'); e.preventDefault(); @@ -193,31 +195,31 @@ phpbb.confirm = function(msg, callback, fadedark) { } }); - div.find('.alert_close').one('click', function(e) { - var fade = (typeof fadedark !== 'undefined' && fadedark) ? div : dark; - fade.fadeOut(phpbb.alertTime, function() { - div.hide(); + $confirmDiv.find('.alert_close').one('click', function(e) { + var $fade = (typeof fadedark !== 'undefined' && fadedark) ? $confirmDiv : $dark; + $fade.fadeOut(phpbb.alertTime, function() { + $confirmDiv.hide(); }); callback(false); e.preventDefault(); }); - if (loadingIndicator.is(':visible')) { - loadingIndicator.fadeOut(phpbb.alertTime, function() { - dark.append(div); - div.fadeIn(phpbb.alertTime); + if ($loadingIndicator.is(':visible')) { + $loadingIndicator.fadeOut(phpbb.alertTime, function() { + $dark.append($confirmDiv); + $confirmDiv.fadeIn(phpbb.alertTime); }); - } else if (dark.is(':visible')) { - dark.append(div); - div.fadeIn(phpbb.alertTime); + } else if ($dark.is(':visible')) { + $dark.append($confirmDiv); + $confirmDiv.fadeIn(phpbb.alertTime); } else { - dark.append(div); - div.show(); - dark.fadeIn(phpbb.alertTime); + $dark.append($confirmDiv); + $confirmDiv.show(); + $dark.fadeIn(phpbb.alertTime); } - return div; + return $confirmDiv; }; /** @@ -257,12 +259,12 @@ phpbb.parseQuerystring = function(string) { * that was returned and (if it is a form) the form action. */ phpbb.ajaxify = function(options) { - var elements = $(options.selector), + var $elements = $(options.selector), refresh = options.refresh, callback = options.callback, overlay = (typeof options.overlay !== 'undefined') ? options.overlay : true, - isForm = elements.is('form'), - isText = elements.is('input[type="text"], textarea'), + isForm = $elements.is('form'), + isText = $elements.is('input[type="text"], textarea'), eventName; if (isForm) { @@ -273,7 +275,7 @@ phpbb.ajaxify = function(options) { eventName = 'click'; } - elements.bind(eventName, function(event) { + $elements.on(eventName, function(event) { var action, method, data, submit, that = this, $this = $(this); if ($this.find('input[type="submit"][data-clicked]').attr('data-ajax') === 'false') { @@ -293,11 +295,12 @@ phpbb.ajaxify = function(options) { errorText = errorThrown; } else { - errorText = dark.attr('data-ajax-error-text-' + textStatus); - if (typeof errorText !== 'string' || !errorText.length) - errorText = dark.attr('data-ajax-error-text'); + errorText = $dark.attr('data-ajax-error-text-' + textStatus); + if (typeof errorText !== 'string' || !errorText.length) { + errorText = $dark.attr('data-ajax-error-text'); + } } - phpbb.alert(dark.attr('data-ajax-error-title'), errorText); + phpbb.alert($dark.attr('data-ajax-error-title'), errorText); } /** @@ -322,7 +325,7 @@ phpbb.ajaxify = function(options) { if (typeof res.MESSAGE_TITLE !== 'undefined') { alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); } else { - dark.fadeOut(phpbb.alertTime); + $dark.fadeOut(phpbb.alertTime); } if (typeof phpbb.ajaxCallbacks[callback] === 'function') { @@ -345,7 +348,7 @@ phpbb.ajaxify = function(options) { // Hide the alert even if we refresh the page, in case the user // presses the back button. - dark.fadeOut(phpbb.alertTime, function() { + $dark.fadeOut(phpbb.alertTime, function() { if (typeof alert !== 'undefined') { alert.hide(); } @@ -355,17 +358,19 @@ phpbb.ajaxify = function(options) { } else { // If confirmation is required, display a dialog to the user. phpbb.confirm(res.MESSAGE_BODY, function(del) { - if (del) { - phpbb.loadingIndicator(); - data = $('<form>' + res.S_HIDDEN_FIELDS + '</form>').serialize(); - $.ajax({ - url: res.S_CONFIRM_ACTION, - type: 'POST', - data: data + '&confirm=' + res.YES_VALUE + '&' + $('#phpbb_confirm form').serialize(), - success: returnHandler, - error: errorHandler - }); + if (!del) { + return; } + + phpbb.loadingIndicator(); + data = $('<form>' + res.S_HIDDEN_FIELDS + '</form>').serialize(); + $.ajax({ + url: res.S_CONFIRM_ACTION, + type: 'POST', + data: data + '&confirm=' + res.YES_VALUE + '&' + $('form', '#phpbb_confirm').serialize(), + success: returnHandler, + error: errorHandler + }); }, false); } } @@ -373,7 +378,7 @@ phpbb.ajaxify = function(options) { // If the element is a form, POST must be used and some extra data must // be taken from the form. var runFilter = (typeof options.filter === 'function'); - var data = {}; + data = {}; if (isForm) { action = $this.attr('action').replace('&', '&'); @@ -388,7 +393,7 @@ phpbb.ajaxify = function(options) { }); } } else if (isText) { - var name = ($this.attr('data-name') !== undefined) ? $this.attr('data-name') : this['name']; + var name = $this.attr('data-name') || this.name; action = $this.attr('data-url').replace('&', '&'); data[name] = this.value; method = 'POST'; @@ -399,7 +404,8 @@ phpbb.ajaxify = function(options) { } var sendRequest = function() { - if (overlay && (typeof $this.attr('data-overlay') === 'undefined' || $this.attr('data-overlay') === 'true')) { + var dataOverlay = $this.attr('data-overlay'); + if (overlay && (typeof dataOverlay === 'undefined' || dataOverlay === 'true')) { phpbb.loadingIndicator(); } @@ -411,7 +417,7 @@ phpbb.ajaxify = function(options) { error: errorHandler }); request.always(function() { - loadingIndicator.fadeOut(phpbb.alertTime); + $loadingIndicator.fadeOut(phpbb.alertTime); }); }; @@ -426,7 +432,7 @@ phpbb.ajaxify = function(options) { }); if (isForm) { - elements.find('input:submit').click(function () { + $elements.find('input:submit').click(function () { var $this = $(this); $this.siblings('[data-clicked]').removeAttr('data-clicked'); @@ -437,7 +443,13 @@ phpbb.ajaxify = function(options) { return this; }; -phpbb.search = {cache: {data: []}, tpl: [], container: []}; +phpbb.search = { + cache: { + data: [] + }, + tpl: [], + container: [] +}; /** * Get cached search data. @@ -478,7 +490,7 @@ phpbb.search.cache.set = function(id, key, value) { * @return undefined */ phpbb.search.cache.setResults = function(id, keyword, value) { - this.data[id]['results'][keyword] = value; + this.data[id].results[keyword] = value; }; /** @@ -495,16 +507,16 @@ phpbb.search.cleanKeyword = function(keyword) { * Get clean version of search keyword. If textarea supports several keywords * (one per line), it fetches the current keyword based on the caret position. * - * @param jQuery el Search input|textarea. + * @param jQuery $input Search input|textarea. * @param string keyword Input|textarea value. * @param bool multiline Whether textarea supports multiple search keywords. * * @return string Clean string. */ -phpbb.search.getKeyword = function(el, keyword, multiline) { +phpbb.search.getKeyword = function($input, keyword, multiline) { if (multiline) { - var line = phpbb.search.getKeywordLine(el); - keyword = keyword.split("\n").splice(line, 1); + var line = phpbb.search.getKeywordLine($input); + keyword = keyword.split('\n').splice(line, 1); } return phpbb.search.cleanKeyword(keyword); }; @@ -513,46 +525,48 @@ phpbb.search.getKeyword = function(el, keyword, multiline) { * Get the textarea line number on which the keyword resides - for textareas * that support multiple keywords (one per line). * - * @param jQuery el Search textarea. + * @param jQuery $textarea Search textarea. * @return int */ -phpbb.search.getKeywordLine = function (el) { - return el.val().substr(0, el.get(0).selectionStart).split("\n").length - 1; +phpbb.search.getKeywordLine = function ($textarea) { + var selectionStart = $textarea.get(0).selectionStart; + return $textarea.val().substr(0, selectionStart).split('\n').length - 1; }; /** * Set the value on the input|textarea. If textarea supports multiple * keywords, only the active keyword is replaced. * - * @param jQuery el Search input|textarea. + * @param jQuery $input Search input|textarea. * @param string value Value to set. * @param bool multiline Whether textarea supports multiple search keywords. * * @return undefined */ -phpbb.search.setValue = function(el, value, multiline) { +phpbb.search.setValue = function($input, value, multiline) { if (multiline) { - var line = phpbb.search.getKeywordLine(el), - lines = el.val().split("\n"); + var line = phpbb.search.getKeywordLine($input), + lines = $input.val().split('\n'); lines[line] = value; - value = lines.join("\n"); + value = lines.join('\n'); } - el.val(value); + $input.val(value); }; /** * Sets the onclick event to set the value on the input|textarea to the selected search result. * - * @param jQuery el Search input|textarea. + * @param jQuery $input Search input|textarea. * @param object value Result object. - * @param object container jQuery object for the search container. + * @param jQuery $row Result element. + * @param jQuery $container jQuery object for the search container. * * @return undefined */ -phpbb.search.setValueOnClick = function(el, value, row, container) { - row.click(function() { - phpbb.search.setValue(el, value.result, el.attr('data-multiline')); - container.hide(); +phpbb.search.setValueOnClick = function($input, value, $row, $container) { + $row.click(function() { + phpbb.search.setValue($input, value.result, $input.attr('data-multiline')); + $container.hide(); }); }; @@ -569,39 +583,39 @@ phpbb.search.setValueOnClick = function(el, value, row, container) { * @return bool Returns false. */ phpbb.search.filter = function(data, event, sendRequest) { - var el = $(this), - dataName = (el.attr('data-name') !== undefined) ? el.attr('data-name') : el.attr('name'), - minLength = parseInt(el.attr('data-min-length')), - searchID = el.attr('data-results'), - keyword = phpbb.search.getKeyword(el, data[dataName], el.attr('data-multiline')), + var $this = $(this), + dataName = ($this.attr('data-name') !== undefined) ? $this.attr('data-name') : $this.attr('name'), + minLength = parseInt($this.attr('data-min-length')), + searchID = $this.attr('data-results'), + keyword = phpbb.search.getKeyword($this, data[dataName], $this.attr('data-multiline')), cache = phpbb.search.cache.get(searchID), proceed = true; data[dataName] = keyword; - if (cache['timeout']) { - clearTimeout(cache['timeout']); + if (cache.timeout) { + clearTimeout(cache.timeout); } var timeout = setTimeout(function() { // Check min length and existence of cache. if (minLength > keyword.length) { proceed = false; - } else if (cache['last_search']) { + } else if (cache.lastSearch) { // Has the keyword actually changed? - if (cache['last_search'] === keyword) { + if (cache.lastSearch === keyword) { proceed = false; } else { // Do we already have results for this? - if (cache['results'][keyword]) { - var response = {keyword: keyword, results: cache['results'][keyword]}; - phpbb.search.handleResponse(response, el, true); + if (cache.results[keyword]) { + var response = {keyword: keyword, results: cache.results[keyword]}; + phpbb.search.handleResponse(response, $this, true); proceed = false; } // If the previous search didn't yield results and the string only had characters added to it, // then we won't bother sending a request. - if (keyword.indexOf(cache['last_search']) === 0 && cache['results'][cache['last_search']].length === 0) { - phpbb.search.cache.set(searchID, 'last_search', keyword); + if (keyword.indexOf(cache.lastSearch) === 0 && cache.results[cache.lastSearch].length === 0) { + phpbb.search.cache.set(searchID, 'lastSearch', keyword); phpbb.search.cache.setResults(searchID, keyword, []); proceed = false; } @@ -621,22 +635,22 @@ phpbb.search.filter = function(data, event, sendRequest) { * Handle search result response. * * @param object res Data received from server. - * @param jQuery el Search input|textarea. + * @param jQuery $input Search input|textarea. * @param bool fromCache Whether the results are from the cache. * @param function callback Optional callback to run when assigning each search result. * * @return undefined */ -phpbb.search.handleResponse = function(res, el, fromCache, callback) { +phpbb.search.handleResponse = function(res, $input, fromCache, callback) { if (typeof res !== 'object') { return; } - var searchID = el.attr('data-results'), - container = $(searchID); + var searchID = $input.attr('data-results'), + $container = $(searchID); - if (this.cache.get(searchID)['callback']) { - callback = this.cache.get(searchID)['callback']; + if (this.cache.get(searchID).callback) { + callback = this.cache.get(searchID).callback; } else if (typeof callback === 'function') { this.cache.set(searchID, 'callback', callback); } @@ -645,35 +659,35 @@ phpbb.search.handleResponse = function(res, el, fromCache, callback) { this.cache.setResults(searchID, res.keyword, res.results); } - this.cache.set(searchID, 'last_search', res.keyword); - this.showResults(res.results, el, container, callback); + this.cache.set(searchID, 'lastSearch', res.keyword); + this.showResults(res.results, $input, $container, callback); }; /** * Show search results. * * @param array results Search results. - * @param jQuery el Search input|textarea. - * @param jQuery container Search results container element. + * @param jQuery $input Search input|textarea. + * @param jQuery $container Search results container element. * @param function callback Optional callback to run when assigning each search result. * * @return undefined */ -phpbb.search.showResults = function(results, el, container, callback) { - var resultContainer = $('.search-results', container); - this.clearResults(resultContainer); +phpbb.search.showResults = function(results, $input, $container, callback) { + var $resultContainer = $('.search-results', $container); + this.clearResults($resultContainer); if (!results.length) { - container.hide(); + $container.hide(); return; } - var searchID = container.attr('id'), + var searchID = $container.attr('id'), tpl, row; if (!this.tpl[searchID]) { - tpl = $('.search-result-tpl', container); + tpl = $('.search-result-tpl', $container); this.tpl[searchID] = tpl.clone().removeClass('search-result-tpl'); tpl.remove(); } @@ -684,27 +698,27 @@ phpbb.search.showResults = function(results, el, container, callback) { row.find('.search-result').html(item.display); if (typeof callback === 'function') { - callback.call(this, el, item, row, container); + callback.call(this, $input, item, row, $container); } - row.appendTo(resultContainer).show(); + row.appendTo($resultContainer).show(); }); - container.show(); + $container.show(); }; /** * Clear search results. * - * @param jQuery container Search results container. + * @param jQuery $container Search results container. * @return undefined */ -phpbb.search.clearResults = function(container) { - container.children(':not(.search-result-tpl)').remove(); +phpbb.search.clearResults = function($container) { + $container.children(':not(.search-result-tpl)').remove(); }; -$('#phpbb').click(function(e) { - var target = $(e.target); +$('#phpbb').click(function() { + var $this = $(this); - if (!target.is('.live-search') && !target.parents().is('.live-search')) { + if (!$this.is('.live-search') && !$this.parents().is('.live-search')) { $('.live-search').hide(); } }); @@ -718,10 +732,7 @@ phpbb.history = {}; * @return bool Returns true if the method is supported. */ phpbb.history.isSupported = function(fn) { - if (typeof history === 'undefined' || typeof history[fn] === 'undefined') { - return false; - } - return true; + return !(typeof history === 'undefined' || typeof history[fn] === 'undefined'); }; /** @@ -783,36 +794,52 @@ phpbb.history.pushUrl = function(url, title, obj) { * @param bool keepSelection Shall we keep the value selected, or shall the user be forced to repick one. */ phpbb.timezoneSwitchDate = function(keepSelection) { - if ($('#timezone_copy').length === 0) { + var $timezoneCopy = $('#timezone_copy'); + var $timezone = $('#timezone'); + var $tzDate = $('#tz_date'); + var $tzSelectDateSuggest = $('#tz_select_date_suggest'); + + if ($timezoneCopy.length === 0) { // We make a backup of the original dropdown, so we can remove optgroups // instead of setting display to none, because IE and chrome will not // hide options inside of optgroups and selects via css - $('#timezone').clone().attr('id', 'timezone_copy').css('display', 'none').attr('name', 'tz_copy').insertAfter('#timezone'); + $timezone.clone() + .attr('id', 'timezone_copy') + .css('display', 'none') + .attr('name', 'tz_copy') + .insertAfter('#timezone'); } else { // Copy the content of our backup, so we can remove all unneeded options - $('#timezone').replaceWith($('#timezone_copy').clone().attr('id', 'timezone').css('display', 'block').attr('name', 'tz')); + var $replacement = $timezoneCopy.clone(); + $replacement.attr('id', 'timezone') + .css('display', 'block') + .attr('name', 'tz'); + + $timezone.replaceWith($replacement); } - if ($('#tz_date').val() !== '') { - $('#timezone > optgroup').remove(":not([label='" + $('#tz_date').val() + "'])"); + if ($tzDate.val() !== '') { + $timezone.children('optgroup').remove(':not([label="' + $('#tz_date').val() + '"])'); } - if ($('#tz_date').val() === $('#tz_select_date_suggest').attr('data-suggested-tz')) { - $('#tz_select_date_suggest').css('display', 'none'); + if ($tzDate.val() === $tzSelectDateSuggest.attr('data-suggested-tz')) { + $tzSelectDateSuggest.css('display', 'none'); } else { - $('#tz_select_date_suggest').css('display', 'inline'); + $tzSelectDateSuggest.css('display', 'inline'); } + + var $tzOptions = $timezone.children('optgroup[label="' + $tzDate.val() + '"]').children('option'); - if ($("#timezone > optgroup[label='" + $('#tz_date').val() + "'] > option").size() === 1) { + if ($tzOptions.length === 1) { // If there is only one timezone for the selected date, we just select that automatically. - $("#timezone > optgroup[label='" + $('#tz_date').val() + "'] > option:first").prop('selected', true); + $tzOptions.prop('selected', true); keepSelection = true; } if (typeof keepSelection !== 'undefined' && !keepSelection) { - var timezoneOptions = $('#timezone > optgroup option'); - if (timezoneOptions.filter(':selected').length <= 0) { - timezoneOptions.filter(':first').prop('selected', true); + var $timezoneOptions = $timezone.find('optgroup option'); + if ($timezoneOptions.filter(':selected').length <= 0) { + $timezoneOptions.filter(':first').prop('selected', true); } } }; @@ -832,7 +859,6 @@ phpbb.timezoneEnableDateSelection = function() { phpbb.timezonePreselectSelect = function(forceSelector) { // The offset returned here is in minutes and negated. - // http://www.w3schools.com/jsref/jsref_getTimezoneOffset.asp var offset = (new Date()).getTimezoneOffset(); var sign = '-'; @@ -858,9 +884,11 @@ phpbb.timezonePreselectSelect = function(forceSelector) { var prefix = 'GMT' + sign + hours + ':' + minutes; var prefixLength = prefix.length; - var selectorOptions = $('#tz_date > option'); + var selectorOptions = $('option', '#tz_date'); var i; + var $tzSelectDateSuggest = $('#tz_select_date_suggest'); + for (i = 0; i < selectorOptions.length; ++i) { var option = selectorOptions[i]; @@ -869,16 +897,18 @@ phpbb.timezonePreselectSelect = function(forceSelector) { // We do not select the option for the user, but notify him, // that we would suggest a different setting. phpbb.timezoneSwitchDate(true); - $('#tz_select_date_suggest').css('display', 'inline'); + $tzSelectDateSuggest.css('display', 'inline'); } else { option.selected = true; phpbb.timezoneSwitchDate(!forceSelector); - $('#tz_select_date_suggest').css('display', 'none'); + $tzSelectDateSuggest.css('display', 'none'); } - $('#tz_select_date_suggest').attr('title', $('#tz_select_date_suggest').attr('data-l-suggestion').replace("%s", option.innerHTML)); - $('#tz_select_date_suggest').attr('value', $('#tz_select_date_suggest').attr('data-l-suggestion').replace("%s", option.innerHTML.substring(0, 9))); - $('#tz_select_date_suggest').attr('data-suggested-tz', option.innerHTML); + var suggestion = $tzSelectDateSuggest.attr('data-l-suggestion'); + + $tzSelectDateSuggest.attr('title', suggestion.replace('%s', option.innerHTML)); + $tzSelectDateSuggest.attr('value', suggestion.replace('%s', option.innerHTML.substring(0, 9))); + $tzSelectDateSuggest.attr('data-suggested-tz', option.innerHTML); // Found the suggestion, there cannot be more, so return from here. return; @@ -916,22 +946,22 @@ phpbb.addAjaxCallback('member_search', function(res) { * current text so that the process can be repeated. */ phpbb.addAjaxCallback('alt_text', function() { - var el, + var $anchor, updateAll = $(this).data('update-all'), altText; if (updateAll !== undefined && updateAll.length) { - el = $(updateAll); + $anchor = $(updateAll); } else { - el = $(this); + $anchor = $(this); } - el.each(function() { - var el = $(this); - altText = el.attr('data-alt-text'); - el.attr('data-alt-text', el.text()); - el.attr('title', $.trim(altText)); - el.text(altText); + $anchor.each(function() { + var $this = $(this); + altText = $this.attr('data-alt-text'); + $this.attr('data-alt-text', $this.text()); + $this.attr('title', $.trim(altText)); + $this.text(altText); }); }); @@ -945,36 +975,36 @@ phpbb.addAjaxCallback('alt_text', function() { * and changes the link itself. */ phpbb.addAjaxCallback('toggle_link', function() { - var el, + var $anchor, updateAll = $(this).data('update-all') , toggleText, toggleUrl, toggleClass; if (updateAll !== undefined && updateAll.length) { - el = $(updateAll); + $anchor = $(updateAll); } else { - el = $(this); + $anchor = $(this); } - el.each(function() { - var el = $(this); + $anchor.each(function() { + var $this = $(this); // Toggle link text - toggleText = el.attr('data-toggle-text'); - el.attr('data-toggle-text', el.text()); - el.attr('title', $.trim(toggleText)); - el.text(toggleText); + toggleText = $this.attr('data-toggle-text'); + $this.attr('data-toggle-text', $this.text()); + $this.attr('title', $.trim(toggleText)); + $this.text(toggleText); // Toggle link url - toggleUrl = el.attr('data-toggle-url'); - el.attr('data-toggle-url', el.attr('href')); - el.attr('href', toggleUrl); + toggleUrl = $this.attr('data-toggle-url'); + $this.attr('data-toggle-url', $this.attr('href')); + $this.attr('href', toggleUrl); // Toggle class of link parent - toggleClass = el.attr('data-toggle-class'); - el.attr('data-toggle-class', el.parent().attr('class')); - el.parent().attr('class', toggleClass); + toggleClass = $this.attr('data-toggle-class'); + $this.attr('data-toggle-class', $this.parent().attr('class')); + $this.parent().attr('class', toggleClass); }); }); @@ -984,7 +1014,7 @@ phpbb.addAjaxCallback('toggle_link', function() { * This function automatically resizes textarea elements when user * types text. * -* @param {jQuery} items jQuery object(s) to resize +* @param {jQuery} $items jQuery object(s) to resize * @param {object} options Optional parameter that adjusts default * configuration. See configuration variable * @@ -1000,25 +1030,26 @@ phpbb.addAjaxCallback('toggle_link', function() { * this points to DOM object * item is a jQuery object, same as this */ -phpbb.resizeTextArea = function(items, options) { +phpbb.resizeTextArea = function($items, options) { // Configuration var configuration = { minWindowHeight: 500, minHeight: 200, maxHeight: 500, heightDiff: 200, - resizeCallback: function(item) { }, - resetCallback: function(item) { } + resizeCallback: function() {}, + resetCallback: function() {} }; - if (phpbb.isTouch) return; + if (phpbb.isTouch) { + return; + } if (arguments.length > 1) { configuration = $.extend(configuration, options); } - function resetAutoResize(item) - { + function resetAutoResize(item) { var $item = $(item); if ($item.hasClass('auto-resized')) { $(item).css({height: '', resize: ''}).removeClass('auto-resized'); @@ -1026,10 +1057,8 @@ phpbb.resizeTextArea = function(items, options) { } } - function autoResize(item) - { - function setHeight(height) - { + function autoResize(item) { + function setHeight(height) { height += parseInt($item.css('height')) - $item.height(); $item.css({height: height + 'px', resize: 'none'}).addClass('auto-resized'); configuration.resizeCallback.call(item, $item); @@ -1042,7 +1071,10 @@ phpbb.resizeTextArea = function(items, options) { return; } - var maxHeight = Math.min(Math.max(windowHeight - configuration.heightDiff, configuration.minHeight), configuration.maxHeight), + var maxHeight = Math.min( + Math.max(windowHeight - configuration.heightDiff, configuration.minHeight), + configuration.maxHeight + ), $item = $(item), height = parseInt($item.height()), scrollHeight = (item.scrollHeight) ? item.scrollHeight : 0; @@ -1059,14 +1091,14 @@ phpbb.resizeTextArea = function(items, options) { } } - items.bind('focus change keyup', function() { + $items.on('focus change keyup', function() { $(this).each(function() { autoResize(this); }); }).change(); $(window).resize(function() { - items.each(function() { + $items.each(function() { if ($(this).hasClass('auto-resized')) { autoResize(this); } @@ -1104,7 +1136,9 @@ phpbb.inBBCodeTag = function(textarea, startTags, endTags) { lastStart = Math.max(lastStart, index); } } - if (lastStart == -1) return false; + if (lastStart === -1) { + return false; + } if (start > 0) { for (i = 0; i < endTags.length; i++) { @@ -1114,7 +1148,7 @@ phpbb.inBBCodeTag = function(textarea, startTags, endTags) { } return (lastEnd < lastStart); -} +}; /** @@ -1158,7 +1192,7 @@ phpbb.applyCodeEditor = function(textarea) { function getLastLine(stripCodeStart) { var start = textarea.selectionStart, value = textarea.value, - index = value.lastIndexOf("\n", start - 1); + index = value.lastIndexOf('\n', start - 1); value = value.substring(index + 1, start); @@ -1201,28 +1235,27 @@ phpbb.applyCodeEditor = function(textarea) { var key = event.keyCode || event.which; // intercept tabs - if (key == keymap.TAB && + if (key === keymap.TAB && !event.ctrlKey && !event.shiftKey && !event.altKey && !event.metaKey) { if (inTag()) { - appendText("\t"); + appendText('\t'); event.preventDefault(); return; } } // intercept new line characters - if (key == keymap.ENTER) { + if (key === keymap.ENTER) { if (inTag()) { var lastLine = getLastLine(true), code = '' + /^\s*/g.exec(lastLine); if (code.length > 0) { - appendText("\n" + code); + appendText('\n' + code); event.preventDefault(); - return; } } } @@ -1247,43 +1280,41 @@ phpbb.toggleDropdown = function() { var $this = $(this), options = $this.data('dropdown-options'), parent = options.parent, - visible = parent.hasClass('dropdown-visible'); + visible = parent.hasClass('dropdown-visible'), + direction; if (!visible) { // Hide other dropdown menus $(phpbb.dropdownHandles).each(phpbb.toggleDropdown); // Figure out direction of dropdown - var direction = options.direction, - verticalDirection = options.verticalDirection, + direction = options.direction; + var verticalDirection = options.verticalDirection, offset = $this.offset(); - if (direction == 'auto') { + if (direction === 'auto') { if (($(window).width() - $this.outerWidth(true)) / 2 > offset.left) { direction = 'right'; - } - else { + } else { direction = 'left'; } } - parent.toggleClass(options.leftClass, direction == 'left').toggleClass(options.rightClass, direction == 'right'); + parent.toggleClass(options.leftClass, direction === 'left') + .toggleClass(options.rightClass, direction === 'right'); - if (verticalDirection == 'auto') { + if (verticalDirection === 'auto') { var height = $(window).height(), top = offset.top - $(window).scrollTop(); - if (top < height * 0.7) { - verticalDirection = 'down'; - } - else { - verticalDirection = 'up'; - } + verticalDirection = (top < height * 0.7) ? 'down' : 'up'; } - parent.toggleClass(options.upClass, verticalDirection == 'up').toggleClass(options.downClass, verticalDirection == 'down'); + parent.toggleClass(options.upClass, verticalDirection === 'up') + .toggleClass(options.downClass, verticalDirection === 'down'); } options.dropdown.toggle(); - parent.toggleClass(options.visibleClass, !visible).toggleClass('dropdown-visible', !visible); + parent.toggleClass(options.visibleClass, !visible) + .toggleClass('dropdown-visible', !visible); // Check dimensions when showing dropdown // !visible because variable shows state of dropdown before it was toggled @@ -1304,8 +1335,7 @@ phpbb.toggleDropdown = function() { if (offset < 2) { $this.css('left', (2 - offset) + 'px'); - } - else if ((offset + width + 2) > windowWidth) { + } else if ((offset + width + 2) > windowWidth) { $this.css('margin-left', (windowWidth - offset - width - 2) + 'px'); } @@ -1315,7 +1345,7 @@ phpbb.toggleDropdown = function() { }); var freeSpace = parent.offset().left - 4; - if (direction == 'left') { + if (direction === 'left') { options.dropdown.css('margin-left', '-' + freeSpace + 'px'); // Try to position the notification dropdown correctly in RTL-responsive mode @@ -1342,8 +1372,7 @@ phpbb.toggleDropdown = function() { var e = arguments[0]; e.preventDefault(); e.stopPropagation(); - } - catch (error) { } + } catch (error) { } } return false; }; @@ -1354,7 +1383,7 @@ phpbb.toggleDropdown = function() { phpbb.toggleSubmenu = function(e) { $(this).siblings('.dropdown-submenu').toggle(); e.preventDefault(); -} +}; /** * Register dropdown menu @@ -1364,8 +1393,7 @@ phpbb.toggleSubmenu = function(e) { * @param {jQuery} dropdown Dropdown menu. * @param {Object} options List of options. Optional. */ -phpbb.registerDropdown = function(toggle, dropdown, options) -{ +phpbb.registerDropdown = function(toggle, dropdown, options) { var ops = { parent: toggle.parent(), // Parent item to add classes to direction: 'auto', // Direction of dropdown menu. Possible values: auto, left, right @@ -1411,8 +1439,8 @@ phpbb.colorPalette = function(dir, width, height) { numberList[3] = 'BF'; numberList[4] = 'FF'; - var table_class = (dir == 'h') ? 'horizontal-palette' : 'vertical-palette'; - html += '<table class="not-responsive colour-palette ' + table_class + '" style="width: auto;">'; + var tableClass = (dir == 'h') ? 'horizontal-palette' : 'vertical-palette'; + html += '<table class="not-responsive colour-palette ' + tableClass + '" style="width: auto;">'; for (r = 0; r < 5; r++) { if (dir == 'h') { @@ -1442,7 +1470,7 @@ phpbb.colorPalette = function(dir, width, height) { } html += '</table>'; return html; -} +}; /** * Register a color palette. @@ -1492,12 +1520,14 @@ phpbb.toggleDisplay = function(id, action, type) { type = 'block'; } - var display = $('#' + id).css('display'); + var $element = $('#' + id); + + var display = $element.css('display'); if (!action) { action = (display === '' || display === type) ? -1 : 1; } - $('#' + id).css('display', ((action === 1) ? type : 'none')); -} + $element.css('display', ((action === 1) ? type : 'none')); +}; /** * Toggle additional settings based on the selected @@ -1508,9 +1538,9 @@ phpbb.toggleDisplay = function(id, action, type) { */ phpbb.toggleSelectSettings = function(el) { el.children().each(function() { - var option = $(this), - setting = $(option.data('toggle-setting')); - setting.toggle(option.is(':selected')); + var $this = $(this), + $setting = $($this.data('toggle-setting')); + $setting.toggle($this.is(':selected')); }); }; @@ -1536,49 +1566,61 @@ phpbb.getFunctionByName = function (functionName) { * Register page dropdowns. */ phpbb.registerPageDropdowns = function() { - $('body').find('.dropdown-container').each(function() { + var $body = $('body'); + + $body.find('.dropdown-container').each(function() { var $this = $(this), - trigger = $this.find('.dropdown-trigger:first'), - contents = $this.find('.dropdown'), + $trigger = $this.find('.dropdown-trigger:first'), + $contents = $this.find('.dropdown'), options = { direction: 'auto', verticalDirection: 'auto' }, data; - if (!trigger.length) { + if (!$trigger.length) { data = $this.attr('data-dropdown-trigger'); - trigger = data ? $this.children(data) : $this.children('a:first'); + $trigger = data ? $this.children(data) : $this.children('a:first'); } - if (!contents.length) { + if (!$contents.length) { data = $this.attr('data-dropdown-contents'); - contents = data ? $this.children(data) : $this.children('div:first'); + $contents = data ? $this.children(data) : $this.children('div:first'); } - if (!trigger.length || !contents.length) return; + if (!$trigger.length || !$contents.length) { + return; + } - if ($this.hasClass('dropdown-up')) options.verticalDirection = 'up'; - if ($this.hasClass('dropdown-down')) options.verticalDirection = 'down'; - if ($this.hasClass('dropdown-left')) options.direction = 'left'; - if ($this.hasClass('dropdown-right')) options.direction = 'right'; + if ($this.hasClass('dropdown-up')) { + options.verticalDirection = 'up'; + } + if ($this.hasClass('dropdown-down')) { + options.verticalDirection = 'down'; + } + if ($this.hasClass('dropdown-left')) { + options.direction = 'left'; + } + if ($this.hasClass('dropdown-right')) { + options.direction = 'right'; + } - phpbb.registerDropdown(trigger, contents, options); + phpbb.registerDropdown($trigger, $contents, options); }); // Hide active dropdowns when click event happens outside - $('body').click(function(e) { - var parents = $(e.target).parents(); - if (!parents.is(phpbb.dropdownVisibleContainers)) { + $body.click(function(e) { + var $parents = $(e.target).parents(); + if (!$parents.is(phpbb.dropdownVisibleContainers)) { $(phpbb.dropdownHandles).each(phpbb.toggleDropdown); } }); -} +}; /** * Apply code editor to all textarea elements with data-bbcode attribute */ -$(document).ready(function() { +$(function() { $('textarea[data-bbcode]').each(function() { phpbb.applyCodeEditor(this); }); @@ -1595,12 +1637,12 @@ $(document).ready(function() { // Hide settings that are not selected via select element. $('select[data-togglable-settings]').each(function() { - var select = $(this); + var $this = $(this); - select.change(function() { - phpbb.toggleSelectSettings(select); + $this.change(function() { + phpbb.toggleSelectSettings($this); }); - phpbb.toggleSelectSettings(select); + phpbb.toggleSelectSettings($this); }); }); diff --git a/phpBB/composer.json b/phpBB/composer.json index e74dd120f0..69f0de8479 100644 --- a/phpBB/composer.json +++ b/phpBB/composer.json @@ -44,6 +44,7 @@ "sami/sami": "1.*", "squizlabs/php_codesniffer": "1.*", "symfony/browser-kit": "2.3.*", + "symfony/css-selector": "2.3.*", "symfony/debug": "2.3.*", "symfony/dom-crawler": "2.3.*", "symfony/filesystem": "2.3.*", diff --git a/phpBB/composer.lock b/phpBB/composer.lock index 671daa70e1..b686bfef5c 100644 --- a/phpBB/composer.lock +++ b/phpBB/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "27d5da149e0b5d76b76f43210306b666", + "hash": "d93446768ea0665b7c55c01890153a67", "packages": [ { "name": "lusitanian/oauth", @@ -108,17 +108,17 @@ }, { "name": "symfony/config", - "version": "v2.3.16", + "version": "v2.3.19", "target-dir": "Symfony/Component/Config", "source": { "type": "git", "url": "https://github.com/symfony/Config.git", - "reference": "259722b5f2e87d3f487630abfd40f922cf2f6900" + "reference": "b34d2b32a92938476f0689486e7a11ea1aeb079e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Config/zipball/259722b5f2e87d3f487630abfd40f922cf2f6900", - "reference": "259722b5f2e87d3f487630abfd40f922cf2f6900", + "url": "https://api.github.com/repos/symfony/Config/zipball/b34d2b32a92938476f0689486e7a11ea1aeb079e", + "reference": "b34d2b32a92938476f0689486e7a11ea1aeb079e", "shasum": "" }, "require": { @@ -142,33 +142,31 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Config Component", "homepage": "http://symfony.com", - "time": "2014-04-22 08:09:28" + "time": "2014-08-02 07:53:48" }, { "name": "symfony/console", - "version": "v2.3.16", + "version": "v2.3.19", "target-dir": "Symfony/Component/Console", "source": { "type": "git", "url": "https://github.com/symfony/Console.git", - "reference": "c6c5a354a9945a5e9a9a6a495ca19558eb8639e9" + "reference": "a2723f99716c2fa6411e2eb5842edbe680e4b462" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/c6c5a354a9945a5e9a9a6a495ca19558eb8639e9", - "reference": "c6c5a354a9945a5e9a9a6a495ca19558eb8639e9", + "url": "https://api.github.com/repos/symfony/Console/zipball/a2723f99716c2fa6411e2eb5842edbe680e4b462", + "reference": "a2723f99716c2fa6411e2eb5842edbe680e4b462", "shasum": "" }, "require": { @@ -197,33 +195,31 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Console Component", "homepage": "http://symfony.com", - "time": "2014-05-14 13:35:53" + "time": "2014-08-07 15:55:24" }, { "name": "symfony/debug", - "version": "v2.3.16", + "version": "v2.3.19", "target-dir": "Symfony/Component/Debug", "source": { "type": "git", "url": "https://github.com/symfony/Debug.git", - "reference": "ca764f8af9cc4ba5d81b598c1b18b30db5508e18" + "reference": "91e3a1480c67601d2406cd938735abe0243e1c95" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Debug/zipball/ca764f8af9cc4ba5d81b598c1b18b30db5508e18", - "reference": "ca764f8af9cc4ba5d81b598c1b18b30db5508e18", + "url": "https://api.github.com/repos/symfony/Debug/zipball/91e3a1480c67601d2406cd938735abe0243e1c95", + "reference": "91e3a1480c67601d2406cd938735abe0243e1c95", "shasum": "" }, "require": { @@ -255,33 +251,31 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Debug Component", "homepage": "http://symfony.com", - "time": "2014-04-29 19:42:43" + "time": "2014-07-07 10:13:42" }, { "name": "symfony/dependency-injection", - "version": "v2.3.16", + "version": "v2.3.19", "target-dir": "Symfony/Component/DependencyInjection", "source": { "type": "git", "url": "https://github.com/symfony/DependencyInjection.git", - "reference": "5ebd813eac59b4051705a2e29e32f211a966b6ca" + "reference": "5ee5795515be251c56057d79154e561ee1efecd2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/5ebd813eac59b4051705a2e29e32f211a966b6ca", - "reference": "5ebd813eac59b4051705a2e29e32f211a966b6ca", + "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/5ee5795515be251c56057d79154e561ee1efecd2", + "reference": "5ee5795515be251c56057d79154e561ee1efecd2", "shasum": "" }, "require": { @@ -313,33 +307,31 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony DependencyInjection Component", "homepage": "http://symfony.com", - "time": "2014-05-02 22:42:57" + "time": "2014-08-27 08:32:18" }, { "name": "symfony/event-dispatcher", - "version": "v2.3.16", + "version": "v2.3.19", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "cb7cd38c081507d10997553c4c522956a4d2afab" + "reference": "2c64e46d7e22bcafcab4413ff62bc389abf87ea5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/cb7cd38c081507d10997553c4c522956a4d2afab", - "reference": "cb7cd38c081507d10997553c4c522956a4d2afab", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/2c64e46d7e22bcafcab4413ff62bc389abf87ea5", + "reference": "2c64e46d7e22bcafcab4413ff62bc389abf87ea5", "shasum": "" }, "require": { @@ -369,33 +361,31 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony EventDispatcher Component", "homepage": "http://symfony.com", - "time": "2014-04-16 10:30:19" + "time": "2014-07-25 15:00:14" }, { "name": "symfony/filesystem", - "version": "v2.3.16", + "version": "v2.3.19", "target-dir": "Symfony/Component/Filesystem", "source": { "type": "git", "url": "https://github.com/symfony/Filesystem.git", - "reference": "69e476c4db31c43ab7ab797adc5fc73d20aa5571" + "reference": "007359d2822d5eba4f04f6507bc9b46877c622b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/69e476c4db31c43ab7ab797adc5fc73d20aa5571", - "reference": "69e476c4db31c43ab7ab797adc5fc73d20aa5571", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/007359d2822d5eba4f04f6507bc9b46877c622b4", + "reference": "007359d2822d5eba4f04f6507bc9b46877c622b4", "shasum": "" }, "require": { @@ -418,33 +408,31 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Filesystem Component", "homepage": "http://symfony.com", - "time": "2014-04-16 10:30:19" + "time": "2014-08-31 03:30:23" }, { "name": "symfony/http-foundation", - "version": "v2.3.16", + "version": "v2.3.19", "target-dir": "Symfony/Component/HttpFoundation", "source": { "type": "git", "url": "https://github.com/symfony/HttpFoundation.git", - "reference": "ad7891d4dfe221c5a9edca64b71bdb500f5b026a" + "reference": "d0125fed988da9e189864c2e6de967b3ee7f1d98" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/ad7891d4dfe221c5a9edca64b71bdb500f5b026a", - "reference": "ad7891d4dfe221c5a9edca64b71bdb500f5b026a", + "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/d0125fed988da9e189864c2e6de967b3ee7f1d98", + "reference": "d0125fed988da9e189864c2e6de967b3ee7f1d98", "shasum": "" }, "require": { @@ -470,33 +458,31 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony HttpFoundation Component", "homepage": "http://symfony.com", - "time": "2014-05-22 16:20:26" + "time": "2014-09-03 07:39:11" }, { "name": "symfony/http-kernel", - "version": "v2.3.16", + "version": "v2.3.19", "target-dir": "Symfony/Component/HttpKernel", "source": { "type": "git", "url": "https://github.com/symfony/HttpKernel.git", - "reference": "d8c00747f592183692afaacf622c444c36092613" + "reference": "a24817f69012b23ce7c554af6b4c7b53235c7c55" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/d8c00747f592183692afaacf622c444c36092613", - "reference": "d8c00747f592183692afaacf622c444c36092613", + "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/a24817f69012b23ce7c554af6b4c7b53235c7c55", + "reference": "a24817f69012b23ce7c554af6b4c7b53235c7c55", "shasum": "" }, "require": { @@ -543,33 +529,31 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony HttpKernel Component", "homepage": "http://symfony.com", - "time": "2014-05-31 02:04:21" + "time": "2014-09-03 09:45:27" }, { "name": "symfony/routing", - "version": "v2.3.16", + "version": "v2.3.19", "target-dir": "Symfony/Component/Routing", "source": { "type": "git", "url": "https://github.com/symfony/Routing.git", - "reference": "6e4c9024a04340b83e456a1a24597dba066dcdc9" + "reference": "aa2beef5d5f1d84250b5ca73a4056c0504e5969e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Routing/zipball/6e4c9024a04340b83e456a1a24597dba066dcdc9", - "reference": "6e4c9024a04340b83e456a1a24597dba066dcdc9", + "url": "https://api.github.com/repos/symfony/Routing/zipball/aa2beef5d5f1d84250b5ca73a4056c0504e5969e", + "reference": "aa2beef5d5f1d84250b5ca73a4056c0504e5969e", "shasum": "" }, "require": { @@ -603,33 +587,31 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Routing Component", "homepage": "http://symfony.com", - "time": "2014-04-23 13:35:47" + "time": "2014-08-15 09:05:55" }, { "name": "symfony/yaml", - "version": "v2.3.16", + "version": "v2.3.19", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "2e257c292cfce88bf6c894a03d0fe8d782055aee" + "reference": "71ceeca3d8164f0c5313127b24ad056071ccf2c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/2e257c292cfce88bf6c894a03d0fe8d782055aee", - "reference": "2e257c292cfce88bf6c894a03d0fe8d782055aee", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/71ceeca3d8164f0c5313127b24ad056071ccf2c6", + "reference": "71ceeca3d8164f0c5313127b24ad056071ccf2c6", "shasum": "" }, "require": { @@ -652,19 +634,17 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2014-05-12 09:13:35" + "time": "2014-08-28 01:42:35" }, { "name": "twig/twig", @@ -2007,17 +1987,17 @@ }, { "name": "symfony/browser-kit", - "version": "v2.3.16", + "version": "v2.3.19", "target-dir": "Symfony/Component/BrowserKit", "source": { "type": "git", "url": "https://github.com/symfony/BrowserKit.git", - "reference": "bc6cb0fe5196ecfe183483791928ed525ac41728" + "reference": "262d698efaa788ce24ff9c987378789bf3f81ce9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/BrowserKit/zipball/bc6cb0fe5196ecfe183483791928ed525ac41728", - "reference": "bc6cb0fe5196ecfe183483791928ed525ac41728", + "url": "https://api.github.com/repos/symfony/BrowserKit/zipball/262d698efaa788ce24ff9c987378789bf3f81ce9", + "reference": "262d698efaa788ce24ff9c987378789bf3f81ce9", "shasum": "" }, "require": { @@ -2048,33 +2028,31 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony BrowserKit Component", "homepage": "http://symfony.com", - "time": "2014-04-22 14:58:51" + "time": "2014-08-05 07:20:55" }, { "name": "symfony/css-selector", - "version": "v2.3.16", + "version": "v2.3.19", "target-dir": "Symfony/Component/CssSelector", "source": { "type": "git", "url": "https://github.com/symfony/CssSelector.git", - "reference": "2ff53e8a7870b453836e879b083b971d455e174d" + "reference": "8953d325d3341c246abadb79be172de95ef80664" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/CssSelector/zipball/2ff53e8a7870b453836e879b083b971d455e174d", - "reference": "2ff53e8a7870b453836e879b083b971d455e174d", + "url": "https://api.github.com/repos/symfony/CssSelector/zipball/8953d325d3341c246abadb79be172de95ef80664", + "reference": "8953d325d3341c246abadb79be172de95ef80664", "shasum": "" }, "require": { @@ -2097,37 +2075,35 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" }, { "name": "Jean-François Simon", "email": "jeanfrancois.simon@sensiolabs.com" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony CssSelector Component", "homepage": "http://symfony.com", - "time": "2014-05-12 09:13:35" + "time": "2014-08-27 08:24:06" }, { "name": "symfony/dom-crawler", - "version": "v2.3.16", + "version": "v2.3.19", "target-dir": "Symfony/Component/DomCrawler", "source": { "type": "git", "url": "https://github.com/symfony/DomCrawler.git", - "reference": "5dd259d7842480fa7c5d4a45c4f911bd6fb60bc8" + "reference": "bad8d98561f071639fa67b20680bffcc256ce252" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/5dd259d7842480fa7c5d4a45c4f911bd6fb60bc8", - "reference": "5dd259d7842480fa7c5d4a45c4f911bd6fb60bc8", + "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/bad8d98561f071639fa67b20680bffcc256ce252", + "reference": "bad8d98561f071639fa67b20680bffcc256ce252", "shasum": "" }, "require": { @@ -2156,33 +2132,31 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony DomCrawler Component", "homepage": "http://symfony.com", - "time": "2014-05-26 22:15:18" + "time": "2014-08-21 00:21:59" }, { "name": "symfony/finder", - "version": "v2.3.16", + "version": "v2.3.19", "target-dir": "Symfony/Component/Finder", "source": { "type": "git", "url": "https://github.com/symfony/Finder.git", - "reference": "32949721cc76afd75e4ac60d14ac3cf55b10a768" + "reference": "f7a5a5a3b1fc0ec9a1a5b4429223a8726e0f4b55" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/32949721cc76afd75e4ac60d14ac3cf55b10a768", - "reference": "32949721cc76afd75e4ac60d14ac3cf55b10a768", + "url": "https://api.github.com/repos/symfony/Finder/zipball/f7a5a5a3b1fc0ec9a1a5b4429223a8726e0f4b55", + "reference": "f7a5a5a3b1fc0ec9a1a5b4429223a8726e0f4b55", "shasum": "" }, "require": { @@ -2205,33 +2179,31 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Finder Component", "homepage": "http://symfony.com", - "time": "2014-05-22 13:42:36" + "time": "2014-08-31 04:03:32" }, { "name": "symfony/process", - "version": "v2.3.16", + "version": "v2.3.19", "target-dir": "Symfony/Component/Process", "source": { "type": "git", "url": "https://github.com/symfony/Process.git", - "reference": "2cd7d075df6cb0d564c069a66408b3877c07d4e3" + "reference": "b8fc0e4b6750e4c458a38d038e6b4d538d4fe2bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/2cd7d075df6cb0d564c069a66408b3877c07d4e3", - "reference": "2cd7d075df6cb0d564c069a66408b3877c07d4e3", + "url": "https://api.github.com/repos/symfony/Process/zipball/b8fc0e4b6750e4c458a38d038e6b4d538d4fe2bb", + "reference": "b8fc0e4b6750e4c458a38d038e6b4d538d4fe2bb", "shasum": "" }, "require": { @@ -2254,19 +2226,17 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { "name": "Symfony Community", "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" } ], "description": "Symfony Process Component", "homepage": "http://symfony.com", - "time": "2014-05-17 21:49:26" + "time": "2014-08-28 09:02:24" } ], "aliases": [ diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 4f39e71c3c..e1308c71d1 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -434,6 +434,38 @@ memberlist_view_user_statistics_before * Since: 3.1.0-a1 * Purpose: Add entries before the user statistics part of any user profile +mcp_warn_post_add_warning_field_after +=== +* Locations: + + styles/prosilver/template/mcp_warn_post.html + + styles/subsilver2/template/mcp_warn_post.html +* Since: 3.1.0-RC4 +* Purpose: Add content during warning for a post - after add warning field. + +mcp_warn_post_add_warning_field_before +=== +* Locations: + + styles/prosilver/template/mcp_warn_post.html + + styles/subsilver2/template/mcp_warn_post.html +* Since: 3.1.0-RC4 +* Purpose: Add content during warning for a post - before add warning field. + +mcp_warn_user_add_warning_field_after +=== +* Locations: + + styles/prosilver/template/mcp_warn_user.html + + styles/subsilver2/template/mcp_warn_user.html +* Since: 3.1.0-RC4 +* Purpose: Add content during warning a user - after add warning field. + +mcp_warn_user_add_warning_field_before +=== +* Locations: + + styles/prosilver/template/mcp_warn_user.html + + styles/subsilver2/template/mcp_warn_user.html +* Since: 3.1.0-RC4 +* Purpose: Add content during warning a user - before add warning field. + navbar_header_logged_out_content === * Locations: @@ -732,6 +764,22 @@ posting_editor_subject_before * Since: 3.1.0-a2 * Purpose: Add field (e.g. textbox) to the posting screen before the subject +posting_pm_header_find_username_after +=== +* Locations: + + styles/prosilver/template/posting_pm_header.html + + styles/subsilver2/template/ucp_header.html +* Since: 3.1.0-RC4 +* Purpose: Add content after the find username link on composing pm + +posting_pm_header_find_username_before +=== +* Locations: + + styles/prosilver/template/posting_pm_header.html + + styles/subsilver2/template/ucp_header.html +* Since: 3.1.0-RC4 +* Purpose: Add content before the find username link on composing pm + quickreply_editor_panel_after === * Locations: @@ -1227,6 +1275,14 @@ viewtopic_body_postrow_post_before * Since: 3.1.0-a4 * Purpose: Add data before posts +viewtopic_body_postrow_post_content_footer +=== +* Locations: + + styles/prosilver/template/viewtopic_body.html + + styles/subsilver2/template/viewtopic_body.html +* Since: 3.1.0-RC4 +* Purpose: Add data at the end of the posts. + viewtopic_body_postrow_post_notices_after === * Locations: diff --git a/phpBB/download/file.php b/phpBB/download/file.php index fd94e78fee..db657e95f0 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -56,6 +56,8 @@ if (isset($_GET['avatar'])) $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx); $phpbb_class_loader_ext->register(); + phpbb_load_extensions_autoloaders($phpbb_root_path); + // Set up container $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_config_php_file, $phpbb_root_path, $phpEx); $phpbb_container = $phpbb_container_builder->get_container(); diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index fda6ef25ec..046281596c 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -112,58 +112,8 @@ class acp_profile $db->sql_query('DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " WHERE field_id = $field_id"); $db->sql_query('DELETE FROM ' . PROFILE_LANG_TABLE . " WHERE field_id = $field_id"); - switch ($db->get_sql_layer()) - { - case 'sqlite': - case 'sqlite3': - $sql = "SELECT sql - FROM sqlite_master - WHERE type = 'table' - AND name = '" . PROFILE_FIELDS_DATA_TABLE . "' - ORDER BY type DESC, name;"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // Create a temp table and populate it, destroy the existing one - $db->sql_query(preg_replace('#CREATE\s+TABLE\s+"?' . PROFILE_FIELDS_DATA_TABLE . '"?#i', 'CREATE TEMPORARY TABLE ' . PROFILE_FIELDS_DATA_TABLE . '_temp', $row['sql'])); - $db->sql_query('INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . '_temp SELECT * FROM ' . PROFILE_FIELDS_DATA_TABLE); - $db->sql_query('DROP TABLE ' . PROFILE_FIELDS_DATA_TABLE); - - preg_match('#\((.*)\)#s', $row['sql'], $matches); - - $new_table_cols = trim($matches[1]); - $old_table_cols = preg_split('/,(?=[\\sa-z])/im', $new_table_cols); - $column_list = array(); - - foreach ($old_table_cols as $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - - if ($entities[0] == 'PRIMARY') - { - continue; - } - - if ($entities[0] !== 'pf_' . $field_ident) - { - $column_list[] = $entities[0]; - } - } - - $columns = implode(',', $column_list); - - $new_table_cols = preg_replace('/' . 'pf_' . $field_ident . '[^,]+,/', '', $new_table_cols); - - // create a new table and fill it up. destroy the temp one - $db->sql_query('CREATE TABLE ' . PROFILE_FIELDS_DATA_TABLE . ' (' . $new_table_cols . ');'); - $db->sql_query('INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . PROFILE_FIELDS_DATA_TABLE . '_temp;'); - $db->sql_query('DROP TABLE ' . PROFILE_FIELDS_DATA_TABLE . '_temp'); - break; - - default: - $db->sql_query('ALTER TABLE ' . PROFILE_FIELDS_DATA_TABLE . " DROP COLUMN pf_$field_ident"); - } + $db_tools = $phpbb_container->get('dbal.tools'); + $db_tools->sql_column_remove(PROFILE_FIELDS_DATA_TABLE, 'pf_' . $field_ident); $order = 0; @@ -932,9 +882,7 @@ class acp_profile $field_ident = 'pf_' . $field_ident; $db_tools = $phpbb_container->get('dbal.tools'); - - list($sql_type, $null) = $db_tools->get_column_type($profile_field->get_database_column_type()); - $profile_sql[] = $this->add_field_ident($field_ident, $sql_type); + $db_tools->sql_column_add(PROFILE_FIELDS_DATA_TABLE, $field_ident, array($profile_field->get_database_column_type(), null)); } $sql_ary = array( @@ -1188,91 +1136,4 @@ class acp_profile } } } - - /** - * Return sql statement for adding a new field ident (profile field) to the profile fields data table - */ - function add_field_ident($field_ident, $sql_type) - { - global $db; - - switch ($db->get_sql_layer()) - { - case 'mysql': - case 'mysql4': - case 'mysqli': - $sql = 'ALTER TABLE ' . PROFILE_FIELDS_DATA_TABLE . " ADD `$field_ident` " . $sql_type; - - break; - - case 'sqlite': - case 'sqlite3': - if (version_compare($db->sql_server_info(true), '3.0') == -1) - { - $sql = "SELECT sql - FROM sqlite_master - WHERE type = 'table' - AND name = '" . PROFILE_FIELDS_DATA_TABLE . "' - ORDER BY type DESC, name;"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // Create a temp table and populate it, destroy the existing one - $db->sql_query(preg_replace('#CREATE\s+TABLE\s+"?' . PROFILE_FIELDS_DATA_TABLE . '"?#i', 'CREATE TEMPORARY TABLE ' . PROFILE_FIELDS_DATA_TABLE . '_temp', $row['sql'])); - $db->sql_query('INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . '_temp SELECT * FROM ' . PROFILE_FIELDS_DATA_TABLE); - $db->sql_query('DROP TABLE ' . PROFILE_FIELDS_DATA_TABLE); - - preg_match('#\((.*)\)#s', $row['sql'], $matches); - - $new_table_cols = trim($matches[1]); - $old_table_cols = explode(',', $new_table_cols); - $column_list = array(); - - foreach ($old_table_cols as $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - if ($entities[0] == 'PRIMARY') - { - continue; - } - $column_list[] = $entities[0]; - } - - $columns = implode(',', $column_list); - - $new_table_cols = $field_ident . ' ' . $sql_type . ',' . $new_table_cols; - - // create a new table and fill it up. destroy the temp one - $db->sql_query('CREATE TABLE ' . PROFILE_FIELDS_DATA_TABLE . ' (' . $new_table_cols . ');'); - $db->sql_query('INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . PROFILE_FIELDS_DATA_TABLE . '_temp;'); - $db->sql_query('DROP TABLE ' . PROFILE_FIELDS_DATA_TABLE . '_temp'); - } - else - { - $sql = 'ALTER TABLE ' . PROFILE_FIELDS_DATA_TABLE . " ADD $field_ident [$sql_type]"; - } - - break; - - case 'mssql': - case 'mssql_odbc': - case 'mssqlnative': - $sql = 'ALTER TABLE [' . PROFILE_FIELDS_DATA_TABLE . "] ADD [$field_ident] " . $sql_type; - - break; - - case 'postgres': - $sql = 'ALTER TABLE ' . PROFILE_FIELDS_DATA_TABLE . " ADD COLUMN \"$field_ident\" " . $sql_type; - - break; - - case 'oracle': - $sql = 'ALTER TABLE ' . PROFILE_FIELDS_DATA_TABLE . " ADD $field_ident " . $sql_type; - - break; - } - - return $sql; - } } diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 21776693b0..1de70d4210 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1636,7 +1636,7 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s if (empty($sql_sort)) { - $sql_sort = 'ORDER BY t.topic_last_post_time DESC'; + $sql_sort = 'ORDER BY t.topic_last_post_time DESC, t.topic_last_post_id DESC'; } if ($config['load_db_lastread'] && $user->data['is_registered']) @@ -2576,15 +2576,17 @@ function add_form_key($form_name) } /** -* Check the form key. Required for all altering actions not secured by confirm_box -* @param string $form_name The name of the form; has to match the name used in add_form_key, otherwise no restrictions apply -* @param int $timespan The maximum acceptable age for a submitted form in seconds. Defaults to the config setting. -* @param string $return_page The address for the return link -* @param bool $trigger If true, the function will triger an error when encountering an invalid form -*/ -function check_form_key($form_name, $timespan = false, $return_page = '', $trigger = false) + * Check the form key. Required for all altering actions not secured by confirm_box + * + * @param string $form_name The name of the form; has to match the name used + * in add_form_key, otherwise no restrictions apply + * @param int $timespan The maximum acceptable age for a submitted form + * in seconds. Defaults to the config setting. + * @return bool True, if the form key was valid, false otherwise + */ +function check_form_key($form_name, $timespan = false) { - global $config, $user; + global $config, $request, $user; if ($timespan === false) { @@ -2592,10 +2594,10 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg $timespan = ($config['form_token_lifetime'] == -1) ? -1 : max(30, $config['form_token_lifetime']); } - if (isset($_POST['creation_time']) && isset($_POST['form_token'])) + if ($request->is_set_post('creation_time') && $request->is_set_post('form_token')) { - $creation_time = abs(request_var('creation_time', 0)); - $token = request_var('form_token', ''); + $creation_time = abs($request->variable('creation_time', 0)); + $token = $request->variable('form_token', ''); $diff = time() - $creation_time; @@ -2612,11 +2614,6 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg } } - if ($trigger) - { - trigger_error($user->lang['FORM_INVALID'] . $return_page); - } - return false; } @@ -2832,8 +2829,6 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa if ($result['status'] == LOGIN_SUCCESS) { $redirect = request_var('redirect', "{$phpbb_root_path}index.$phpEx"); - $message = ($l_success) ? $l_success : $user->lang['LOGIN_REDIRECT']; - $l_redirect = ($admin) ? $user->lang['PROCEED_TO_ACP'] : (($redirect === "{$phpbb_root_path}index.$phpEx" || $redirect === "index.$phpEx") ? $user->lang['RETURN_INDEX'] : $user->lang['RETURN_PAGE']); // append/replace SID (may change during the session for AOL users) $redirect = reapply_sid($redirect); @@ -4664,7 +4659,7 @@ function phpbb_get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config /** * Get avatar * -* @param array $row Row cleaned by \phpbb\avatar\driver\driver::clean_row +* @param array $row Row cleaned by \phpbb\avatar\manager::clean_row * @param string $alt Optional language string for alt tag within image, can be a language key or text * @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP * diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 78137d075b..85d9496061 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -379,10 +379,10 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $last_catless = true; foreach ($forum_rows as $row) { - // Empty category + // Category if ($row['parent_id'] == $root_data['forum_id'] && $row['forum_type'] == FORUM_CAT) { - $template->assign_block_vars('forumrow', array( + $cat_row = array( 'S_IS_CAT' => true, 'FORUM_ID' => $row['forum_id'], 'FORUM_NAME' => $row['forum_name'], @@ -391,9 +391,33 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod 'FORUM_FOLDER_IMG_SRC' => '', 'FORUM_IMAGE' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang['FORUM_CAT'] . '" />' : '', 'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '', - 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id'])) + 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), ); + /** + * Modify the template data block of the 'category' + * + * This event is triggered once per 'category' + * + * @event core.display_forums_modify_category_template_vars + * @var array cat_row Template data of the 'category' + * @var bool catless The flag indicating whether the 'category' has a parent category + * @var bool last_catless The flag indicating whether the last forum had a parent category + * @var array root_data Array with the root forum data + * @var array row The data of the 'category' + * @since 3.1.0-RC4 + */ + $vars = array( + 'cat_row', + 'catless', + 'last_catless', + 'root_data', + 'row', + ); + extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_category_template_vars', compact($vars))); + + $template->assign_block_vars('forumrow', $cat_row); + continue; } diff --git a/phpBB/includes/functions_mcp.php b/phpBB/includes/functions_mcp.php index 7593f08f4d..811d49f1de 100644 --- a/phpBB/includes/functions_mcp.php +++ b/phpBB/includes/functions_mcp.php @@ -521,21 +521,21 @@ function phpbb_mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by $limit_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'tt' => $user->lang['TOPIC_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']); - $sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'tt' => 't.topic_time', 'r' => (($auth->acl_get('m_approve', $forum_id)) ? 't.topic_posts_approved + t.topic_posts_unapproved + t.topic_posts_softdeleted' : 't.topic_posts_approved'), 's' => 't.topic_title', 'v' => 't.topic_views'); + $sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => array('t.topic_last_post_time', 't.topic_last_post_id'), 'tt' => 't.topic_time', 'r' => (($auth->acl_get('m_approve', $forum_id)) ? 't.topic_posts_approved + t.topic_posts_unapproved + t.topic_posts_softdeleted' : 't.topic_posts_approved'), 's' => 't.topic_title', 'v' => 't.topic_views'); $limit_time_sql = ($min_time) ? "AND t.topic_last_post_time >= $min_time" : ''; break; case 'posts': $limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); - $sort_by_sql = array('a' => 'u.username_clean', 't' => 'p.post_time', 's' => 'p.post_subject'); + $sort_by_sql = array('a' => 'u.username_clean', 't' => array('p.post_time', 'p.post_id'), 's' => 'p.post_subject'); $limit_time_sql = ($min_time) ? "AND p.post_time >= $min_time" : ''; break; case 'reports': $limit_days = array(0 => $user->lang['ALL_REPORTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); $sort_by_text = array('a' => $user->lang['AUTHOR'], 'r' => $user->lang['REPORTER'], 'p' => $user->lang['POST_TIME'], 't' => $user->lang['REPORT_TIME'], 's' => $user->lang['SUBJECT']); - $sort_by_sql = array('a' => 'u.username_clean', 'r' => 'ru.username', 'p' => 'p.post_time', 't' => 'r.report_time', 's' => 'p.post_subject'); + $sort_by_sql = array('a' => 'u.username_clean', 'r' => 'ru.username', 'p' => array('p.post_time', 'p.post_id'), 't' => 'r.report_time', 's' => 'p.post_subject'); break; case 'pm_reports': @@ -558,7 +558,16 @@ function phpbb_mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by $sort_key = $default_key; } - $sort_order_sql = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); + $direction = ($sort_dir == 'd') ? 'DESC' : 'ASC'; + + if (is_array($sort_by_sql[$sort_key])) + { + $sort_order_sql = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction; + } + else + { + $sort_order_sql = $sort_by_sql[$sort_key] . ' ' . $direction; + } $s_limit_days = $s_sort_key = $s_sort_dir = $sort_url = ''; gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $sort_url); diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index acfd8d779a..768011fa5b 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1040,6 +1040,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id global $config, $phpbb_root_path, $phpEx, $phpbb_container; $phpbb_content_visibility = $phpbb_container->get('content.visibility'); + $sql_sort = ($mode == 'post_review') ? 'ASC' : 'DESC'; // Go ahead and pull all data for this topic $sql = 'SELECT p.post_id @@ -1048,8 +1049,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.') . ' ' . (($mode == 'post_review') ? " AND p.post_id > $cur_post_id" : '') . ' ' . (($mode == 'post_review_edit') ? " AND p.post_id = $cur_post_id" : '') . ' - ORDER BY p.post_time '; - $sql .= ($mode == 'post_review') ? 'ASC' : 'DESC'; + ORDER BY p.post_time ' . $sql_sort . ', p.post_id ' . $sql_sort; $result = $db->sql_query_limit($sql, $config['posts_per_page']); $post_list = array(); @@ -1342,7 +1342,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $ WHERE p.topic_id = $topic_id AND p.poster_id = u.user_id AND p.post_visibility = " . ITEM_APPROVED . ' - ORDER BY p.post_time ASC'; + ORDER BY p.post_time ASC, p.post_id ASC'; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -1354,7 +1354,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $ FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u WHERE p.topic_id = $topic_id AND p.poster_id = u.user_id - ORDER BY p.post_time ASC"; + ORDER BY p.post_time ASC, p.post_id ASC"; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -1409,7 +1409,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $ WHERE topic_id = $topic_id AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id) . ' AND post_time > ' . $data['post_time'] . ' - ORDER BY post_time ASC'; + ORDER BY post_time ASC, post_id ASC'; $result = $db->sql_query_limit($sql, 1); $next_post_id = (int) $db->sql_fetchfield('post_id'); $db->sql_freeresult($result); diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php index a0a67ccf3d..f179b2fd70 100644 --- a/phpBB/includes/functions_upload.php +++ b/phpBB/includes/functions_upload.php @@ -232,7 +232,12 @@ class filespec { if ($this->mimetype_guesser !== null) { - $this->mimetype = $this->mimetype_guesser->guess($filename); + $mimetype = $this->mimetype_guesser->guess($filename, $this->uploadname); + + if ($mimetype !== 'application/octet-stream') + { + $this->mimetype = $mimetype; + } } return $this->mimetype; diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index b4ec0092e7..ebcf7ce643 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -66,7 +66,7 @@ function mcp_front_view($id, $mode, $action) FROM ' . POSTS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)) . ' - ORDER BY post_time DESC'; + ORDER BY post_time DESC, post_id DESC'; $result = $db->sql_query_limit($sql, 5); while ($row = $db->sql_fetchrow($result)) @@ -101,7 +101,7 @@ function mcp_front_view($id, $mode, $action) WHERE ' . $db->sql_in_set('p.post_id', $post_list) . ' AND t.topic_id = p.topic_id AND p.poster_id = u.user_id - ORDER BY p.post_time DESC'; + ORDER BY p.post_time DESC, p.post_id DESC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) @@ -190,7 +190,7 @@ function mcp_front_view($id, $mode, $action) AND p.poster_id = u2.user_id AND ' . $db->sql_in_set('p.forum_id', $forum_list), - 'ORDER_BY' => 'p.post_time DESC', + 'ORDER_BY' => 'p.post_time DESC, p.post_id DESC', ); /** diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 92000c6ceb..74bf687fc8 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -161,9 +161,13 @@ class mcp_main * This event allows you to handle custom quickmod options * * @event core.modify_quickmod_actions + * @var string action Topic quick moderation action name + * @var bool quickmod Flag indicating whether MCP is in quick moderation mode * @since 3.1.0-a4 + * @change 3.1.0-RC4 Added variables: action, quickmod */ - $phpbb_dispatcher->dispatch('core.modify_quickmod_actions'); + $vars = array('action', 'quickmod'); + extract($phpbb_dispatcher->trigger_event('core.modify_quickmod_actions', compact($vars))); break; } @@ -1265,7 +1269,7 @@ function mcp_fork_topic($topic_ids) $sql = 'SELECT * FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id - ORDER BY post_time ASC"; + ORDER BY post_time ASC, post_id ASC"; $result = $db->sql_query($sql); $post_rows = array(); diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index ba118e5db8..804d48ea97 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -36,7 +36,7 @@ class mcp_reports function main($id, $mode) { global $auth, $db, $user, $template, $cache; - global $config, $phpbb_root_path, $phpEx, $action, $phpbb_container; + global $config, $phpbb_root_path, $phpEx, $action, $phpbb_container, $phpbb_dispatcher; include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); @@ -364,6 +364,27 @@ class mcp_reports AND r.pm_id = 0 $limit_time_sql ORDER BY $sort_order_sql"; + + /** + * Alter sql query to get report id of all reports for requested forum and topic or just forum + * + * @event core.mcp_reports_get_reports_query_before + * @var string sql String with the query to be executed + * @var array forum_list List of forums that contain the posts + * @var int topic_id topic_id in the page request + * @var string limit_time_sql String with the SQL code to limit the time interval of the post (Note: May be empty string) + * @var string sort_order_sql String with the ORDER BY SQL code used in this query + * @since 3.1.0-RC4 + */ + $vars = array( + 'sql', + 'forum_list', + 'topic_id', + 'limit_time_sql', + 'sort_order_sql', + ); + extract($phpbb_dispatcher->trigger_event('core.mcp_reports_get_reports_query_before', compact($vars))); + $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); $i = 0; diff --git a/phpBB/includes/ucp/ucp_attachments.php b/phpBB/includes/ucp/ucp_attachments.php index aab45339c5..42724209aa 100644 --- a/phpBB/includes/ucp/ucp_attachments.php +++ b/phpBB/includes/ucp/ucp_attachments.php @@ -182,6 +182,7 @@ class ucp_attachments $template->assign_vars(array( 'TOTAL_ATTACHMENTS' => $num_attachments, + 'NUM_ATTACHMENTS' => $user->lang('NUM_ATTACHMENTS', $num_attachments), 'L_TITLE' => $user->lang['UCP_ATTACHMENTS'], diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php index 304c04eb3d..a1624e78ec 100644 --- a/phpBB/includes/ucp/ucp_main.php +++ b/phpBB/includes/ucp/ucp_main.php @@ -81,7 +81,7 @@ class ucp_main FROM $sql_from WHERE t.topic_type = " . POST_GLOBAL . ' AND ' . $db->sql_in_set('t.forum_id', $forum_ary) . ' - ORDER BY t.topic_last_post_time DESC'; + ORDER BY t.topic_last_post_time DESC, t.topic_last_post_id DESC'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) @@ -693,7 +693,7 @@ class ucp_main AND t.topic_id = tw.topic_id AND ' . $db->sql_in_set('t.forum_id', $forbidden_forum_ary, true, true), - 'ORDER_BY' => 't.topic_last_post_time DESC' + 'ORDER_BY' => 't.topic_last_post_time DESC, t.topic_last_post_id DESC' ); $sql_array['LEFT_JOIN'] = array(); @@ -710,7 +710,7 @@ class ucp_main 'WHERE' => 'b.user_id = ' . $user->data['user_id'] . ' AND ' . $db->sql_in_set('f.forum_id', $forbidden_forum_ary, true, true), - 'ORDER_BY' => 't.topic_last_post_time DESC' + 'ORDER_BY' => 't.topic_last_post_time DESC, t.topic_last_post_id DESC' ); $sql_array['LEFT_JOIN'] = array(); diff --git a/phpBB/includes/ucp/ucp_pm_options.php b/phpBB/includes/ucp/ucp_pm_options.php index 353bfdc7ec..d1fc9d2c62 100644 --- a/phpBB/includes/ucp/ucp_pm_options.php +++ b/phpBB/includes/ucp/ucp_pm_options.php @@ -32,7 +32,11 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit // Change "full folder" setting - what to do if folder is full if (isset($_POST['fullfolder'])) { - check_form_key('ucp_pm_options', $config['form_token_lifetime'], $redirect_url); + if (!check_form_key('ucp_pm_options')) + { + trigger_error('FORM_INVALID'); + } + $full_action = request_var('full_action', 0); $set_folder_id = 0; diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index a8c8920a7d..3ff8fe9ada 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -223,11 +223,11 @@ class ucp_prefs $data = array( 'topic_sk' => request_var('topic_sk', (!empty($user->data['user_topic_sortby_type'])) ? $user->data['user_topic_sortby_type'] : 't'), 'topic_sd' => request_var('topic_sd', (!empty($user->data['user_topic_sortby_dir'])) ? $user->data['user_topic_sortby_dir'] : 'd'), - 'topic_st' => request_var('topic_st', (!empty($user->data['user_topic_show_days'])) ? $user->data['user_topic_show_days'] : 0), + 'topic_st' => request_var('topic_st', (!empty($user->data['user_topic_show_days'])) ? (int) $user->data['user_topic_show_days'] : 0), 'post_sk' => request_var('post_sk', (!empty($user->data['user_post_sortby_type'])) ? $user->data['user_post_sortby_type'] : 't'), 'post_sd' => request_var('post_sd', (!empty($user->data['user_post_sortby_dir'])) ? $user->data['user_post_sortby_dir'] : 'a'), - 'post_st' => request_var('post_st', (!empty($user->data['user_post_show_days'])) ? $user->data['user_post_show_days'] : 0), + 'post_st' => request_var('post_st', (!empty($user->data['user_post_show_days'])) ? (int) $user->data['user_post_show_days'] : 0), 'images' => request_var('images', (bool) $user->optionget('viewimg')), 'flash' => request_var('flash', (bool) $user->optionget('viewflash')), @@ -254,10 +254,22 @@ class ucp_prefs if ($submit) { $error = validate_data($data, array( - 'topic_sk' => array('string', false, 1, 1), - 'topic_sd' => array('string', false, 1, 1), - 'post_sk' => array('string', false, 1, 1), - 'post_sd' => array('string', false, 1, 1), + 'topic_sk' => array( + array('string', false, 1, 1), + array('match', false, '#(a|r|s|t|v)#'), + ), + 'topic_sd' => array( + array('string', false, 1, 1), + array('match', false, '#(a|d)#'), + ), + 'post_sk' => array( + array('string', false, 1, 1), + array('match', false, '#(a|s|t)#'), + ), + 'post_sd' => array( + array('string', false, 1, 1), + array('match', false, '#(a|d)#'), + ), )); if (!check_form_key('ucp_prefs_view')) @@ -320,7 +332,7 @@ class ucp_prefs $limit_topic_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); $sort_by_topic_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']); - $sort_by_topic_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'r' => 't.topic_posts_approved', 's' => 't.topic_title', 'v' => 't.topic_views'); + $sort_by_topic_sql = array('a' => 't.topic_first_poster_name', 't' => array('t.topic_last_post_time', 't.topic_last_post_id'), 'r' => 't.topic_posts_approved', 's' => 't.topic_title', 'v' => 't.topic_views'); // Post ordering options $limit_post_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 783faa8fad..83e1f4eaa1 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -518,6 +518,10 @@ $lang = array_merge($lang, array( 'NO_USER_SPECIFIED' => 'No username was specified.', // Nullar/Singular/Plural language entry. The key numbers define the number range in which a certain grammatical expression is valid. + 'NUM_ATTACHMENTS' => array( + 1 => '%d attachment', + 2 => '%d attachments', + ), 'NUM_POSTS_IN_QUEUE' => array( 0 => 'No posts in queue', // 0 1 => '1 post in queue', // 1 @@ -864,6 +868,10 @@ $lang = array_merge($lang, array( 'WRONG_DATA_COLOUR' => 'The colour value you entered is invalid.', 'WRONG_DATA_JABBER' => 'The name you entered is not a valid Jabber account name.', 'WRONG_DATA_LANG' => 'The language you specified is not valid.', + 'WRONG_DATA_POST_SD' => 'The post sort direction you specified is not valid.', + 'WRONG_DATA_POST_SK' => 'The post sort option you specified is not valid.', + 'WRONG_DATA_TOPIC_SD' => 'The topic sort direction you specified is not valid.', + 'WRONG_DATA_TOPIC_SK' => 'The topic sort option you specified is not valid.', 'WROTE' => 'wrote', 'YAHOO' => 'Yahoo Messenger', diff --git a/phpBB/phpbb/controller/provider.php b/phpBB/phpbb/controller/provider.php index fffd4f0428..7e26848290 100644 --- a/phpBB/phpbb/controller/provider.php +++ b/phpBB/phpbb/controller/provider.php @@ -73,7 +73,7 @@ class provider $this->routes = new RouteCollection; foreach ($this->routing_files as $file_path) { - $loader = new YamlFileLoader(new FileLocator($base_path)); + $loader = new YamlFileLoader(new FileLocator(phpbb_realpath($base_path))); $this->routes->addCollection($loader->load($file_path)); } diff --git a/phpBB/phpbb/db/migration/data/v310/notifications_use_full_name.php b/phpBB/phpbb/db/migration/data/v310/notifications_use_full_name.php index 30168f4b0b..f749b32119 100644 --- a/phpBB/phpbb/db/migration/data/v310/notifications_use_full_name.php +++ b/phpBB/phpbb/db/migration/data/v310/notifications_use_full_name.php @@ -85,6 +85,11 @@ class notifications_use_full_name extends \phpbb\db\migration\migration public function update_notifications_name() { + $sql = 'UPDATE ' . NOTIFICATION_TYPES_TABLE . ' + SET notification_type_enabled = 0 + WHERE ' . $this->db->sql_in_set('notification_type_name', $this->notification_types, true); + $this->db->sql_query($sql); + foreach ($this->notification_types as $notification_type) { $sql = 'UPDATE ' . NOTIFICATION_TYPES_TABLE . " diff --git a/phpBB/phpbb/db/migrator.php b/phpBB/phpbb/db/migrator.php index 8bc63e564a..44bea3c5d2 100644 --- a/phpBB/phpbb/db/migrator.php +++ b/phpBB/phpbb/db/migrator.php @@ -715,60 +715,6 @@ class migrator } /** - * Load migration data files from a directory - * - * @param \phpbb\finder $finder - * @param string $path Path to migration data files - * @param bool $check_fulfillable If TRUE (default), we will check - * if all of the migrations are fulfillable after loading them. - * If FALSE, we will not check. You SHOULD check at least once - * to prevent errors (if including multiple directories, check - * with the last call to prevent throwing errors unnecessarily). - * @return array Array of migration names - * @throws \phpbb\db\migration\exception - */ - public function load_migrations(\phpbb\finder $finder, $path, $check_fulfillable = true) - { - if (!is_dir($path)) - { - throw new \phpbb\db\migration\exception('DIRECTORY INVALID', $path); - } - - $migrations = array(); - - $files = $finder - ->extension_directory("/") - ->find_from_paths(array('/' => $path)); - foreach ($files as $file) - { - $migrations[$file['path'] . $file['filename']] = ''; - } - $migrations = $finder->get_classes_from_files($migrations); - - foreach ($migrations as $migration) - { - if (!in_array($migration, $this->migrations)) - { - $this->migrations[] = $migration; - } - } - - if ($check_fulfillable) - { - foreach ($this->migrations as $name) - { - $unfulfillable = $this->unfulfillable($name); - if ($unfulfillable !== false) - { - throw new \phpbb\db\migration\exception('MIGRATION_NOT_FULFILLABLE', $name, $unfulfillable); - } - } - } - - return $this->migrations; - } - - /** * Creates the migrations table if it does not exist. * @return null */ diff --git a/phpBB/phpbb/feed/forum.php b/phpBB/phpbb/feed/forum.php index 610b755af3..7a2087c1cd 100644 --- a/phpBB/phpbb/feed/forum.php +++ b/phpBB/phpbb/feed/forum.php @@ -94,7 +94,7 @@ class forum extends \phpbb\feed\post_base WHERE forum_id = ' . $this->forum_id . ' AND topic_moved_id = 0 AND ' . $this->content_visibility->get_visibility_sql('topic', $this->forum_id) . ' - ORDER BY topic_last_post_time DESC'; + ORDER BY topic_last_post_time DESC, topic_last_post_id DESC'; $result = $this->db->sql_query_limit($sql, $this->num_items); $topic_ids = array(); @@ -123,7 +123,7 @@ class forum extends \phpbb\feed\post_base AND ' . $this->content_visibility->get_visibility_sql('post', $this->forum_id, 'p.') . ' AND p.post_time >= ' . $min_post_time . ' AND p.poster_id = u.user_id', - 'ORDER_BY' => 'p.post_time DESC', + 'ORDER_BY' => 'p.post_time DESC, p.post_id DESC', ); return true; diff --git a/phpBB/phpbb/feed/news.php b/phpBB/phpbb/feed/news.php index ea5f4febf5..a02c199d85 100644 --- a/phpBB/phpbb/feed/news.php +++ b/phpBB/phpbb/feed/news.php @@ -99,7 +99,7 @@ class news extends \phpbb\feed\topic_base ), 'WHERE' => 'p.topic_id = t.topic_id AND ' . $this->db->sql_in_set('p.post_id', $post_ids), - 'ORDER_BY' => 'p.post_time DESC', + 'ORDER_BY' => 'p.post_time DESC, p.post_id DESC', ); return true; diff --git a/phpBB/phpbb/feed/overall.php b/phpBB/phpbb/feed/overall.php index f6847c041e..ab452f5386 100644 --- a/phpBB/phpbb/feed/overall.php +++ b/phpBB/phpbb/feed/overall.php @@ -34,7 +34,7 @@ class overall extends \phpbb\feed\post_base FROM ' . TOPICS_TABLE . ' WHERE topic_moved_id = 0 AND ' . $this->content_visibility->get_forums_visibility_sql('topic', $forum_ids) . ' - ORDER BY topic_last_post_time DESC'; + ORDER BY topic_last_post_time DESC, topic_last_post_id DESC'; $result = $this->db->sql_query_limit($sql, $this->num_items); $topic_ids = array(); @@ -71,7 +71,7 @@ class overall extends \phpbb\feed\post_base AND ' . $this->content_visibility->get_forums_visibility_sql('post', $forum_ids, 'p.') . ' AND p.post_time >= ' . $min_post_time . ' AND u.user_id = p.poster_id', - 'ORDER_BY' => 'p.post_time DESC', + 'ORDER_BY' => 'p.post_time DESC, p.post_id DESC', ); return true; diff --git a/phpBB/phpbb/feed/topic.php b/phpBB/phpbb/feed/topic.php index 78e0b4b8ab..66c49e55cf 100644 --- a/phpBB/phpbb/feed/topic.php +++ b/phpBB/phpbb/feed/topic.php @@ -101,7 +101,7 @@ class topic extends \phpbb\feed\post_base 'WHERE' => 'p.topic_id = ' . $this->topic_id . ' AND ' . $this->content_visibility->get_visibility_sql('post', $this->forum_id, 'p.') . ' AND p.poster_id = u.user_id', - 'ORDER_BY' => 'p.post_time DESC', + 'ORDER_BY' => 'p.post_time DESC, p.post_id DESC', ); return true; diff --git a/phpBB/phpbb/feed/topics.php b/phpBB/phpbb/feed/topics.php index 88ca7c33f3..2b9cb3501a 100644 --- a/phpBB/phpbb/feed/topics.php +++ b/phpBB/phpbb/feed/topics.php @@ -71,7 +71,7 @@ class topics extends \phpbb\feed\topic_base ), 'WHERE' => 'p.topic_id = t.topic_id AND ' . $this->db->sql_in_set('p.post_id', $post_ids), - 'ORDER_BY' => 'p.post_time DESC', + 'ORDER_BY' => 'p.post_time DESC, p.post_id DESC', ); return true; diff --git a/phpBB/phpbb/feed/topics_active.php b/phpBB/phpbb/feed/topics_active.php index cde6d36f45..6d5eddfc16 100644 --- a/phpBB/phpbb/feed/topics_active.php +++ b/phpBB/phpbb/feed/topics_active.php @@ -56,7 +56,7 @@ class topics_active extends \phpbb\feed\topic_base WHERE topic_moved_id = 0 AND ' . $this->content_visibility->get_forums_visibility_sql('topic', $in_fid_ary) . ' ' . $last_post_time_sql . ' - ORDER BY topic_last_post_time DESC'; + ORDER BY topic_last_post_time DESC, topic_last_post_id DESC'; $result = $this->db->sql_query_limit($sql, $this->num_items); $post_ids = array(); @@ -88,7 +88,7 @@ class topics_active extends \phpbb\feed\topic_base ), 'WHERE' => 'p.topic_id = t.topic_id AND ' . $this->db->sql_in_set('p.post_id', $post_ids), - 'ORDER_BY' => 'p.post_time DESC', + 'ORDER_BY' => 'p.post_time DESC, p.post_id DESC', ); return true; diff --git a/phpBB/phpbb/mimetype/guesser.php b/phpBB/phpbb/mimetype/guesser.php index 773a1f822a..8baa77089b 100644 --- a/phpBB/phpbb/mimetype/guesser.php +++ b/phpBB/phpbb/mimetype/guesser.php @@ -115,17 +115,42 @@ class guesser return false; } + $mimetype = 'application/octet-stream'; + foreach ($this->guessers as $guesser) { - $mimetype = $guesser->guess($file, $file_name); + $mimetype_guess = $guesser->guess($file, $file_name); - // Try to guess something that is not the fallback application/octet-stream - if ($mimetype !== null && $mimetype !== 'application/octet-stream') - { - return $mimetype; - } + $mimetype = $this->choose_mime_type($mimetype, $mimetype_guess); } // Return any mimetype if we got a result or the fallback value - return (!empty($mimetype)) ? $mimetype : 'application/octet-stream'; + return $mimetype; + } + + /** + * Choose the best mime type based on the current mime type and the guess + * If a guesser returns nulls or application/octet-stream, we will keep + * the current guess. Guesses with a slash inside them will be favored over + * already existing ones. However, any guess that will pass the first check + * will always overwrite the default application/octet-stream. + * + * @param string $mime_type The current mime type + * @param string $guess The current mime type guess + * + * @return string The best mime type based on current mime type and guess + */ + public function choose_mime_type($mime_type, $guess) + { + if ($guess === null || $guess == 'application/octet-stream') + { + return $mime_type; + } + + if ($mime_type == 'application/octet-stream' || strpos($guess, '/') !== false) + { + $mime_type = $guess; + } + + return $mime_type; } } diff --git a/phpBB/phpbb/path_helper.php b/phpBB/phpbb/path_helper.php index 38dbbab51e..936564d8b6 100644 --- a/phpBB/phpbb/path_helper.php +++ b/phpBB/phpbb/path_helper.php @@ -316,7 +316,7 @@ class path_helper * Glue URL parameters together * * @param array $params URL parameters in the form of array(name => value) - * @return string Returns the glued string, e.g. name1=value1&name2=value2 + * @return string Returns the glued string, e.g. name1=value1&name2&name3=value3 */ public function glue_url_params($params) { @@ -324,7 +324,15 @@ class path_helper foreach ($params as $key => $value) { - $_params[] = $key . '=' . $value; + // some parameters do not have value + if ($value !== null) + { + $_params[] = $key . '=' . $value; + } + else + { + $_params[] = $key; + } } return implode('&', $_params); } @@ -353,7 +361,17 @@ class path_helper { continue; } - list($key, $value) = explode('=', $argument, 2); + + // some parameters don't have value + if (strpos($argument, '=') !== false) + { + list($key, $value) = explode('=', $argument, 2); + } + else + { + $key = $argument; + $value = null; + } if ($key === '') { diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php index 98802d2209..4ad3214ae4 100644 --- a/phpBB/phpbb/profilefields/manager.php +++ b/phpBB/phpbb/profilefields/manager.php @@ -245,12 +245,8 @@ class manager $cp_data = $this->build_insert_sql_array($cp_data); $cp_data['user_id'] = (int) $user_id; - $this->db->sql_return_on_error(true); - $sql = 'INSERT INTO ' . $this->fields_data_table . ' ' . $this->db->sql_build_array('INSERT', $cp_data); $this->db->sql_query($sql); - - $this->db->sql_return_on_error(false); } } @@ -328,7 +324,7 @@ class manager * Event to modify profile fields data retrieved from the database * * @event core.grab_profile_fields_data - * @var array user_ids Single user id or an array of ids + * @var array user_ids Single user id or an array of ids * @var array field_data Array with profile fields data * @since 3.1.0-b3 */ @@ -377,7 +373,7 @@ class manager * Event to modify data of the generated profile fields, before the template assignment loop * * @event core.generate_profile_fields_template_data_before - * @var array profile_row Array with users profile field data + * @var array profile_row Array with users profile field data * @var array tpl_fields Array with template data fields * @var bool use_contact_fields Should we display contact fields as such? * @since 3.1.0-b3 @@ -445,7 +441,7 @@ class manager * Event to modify template data of the generated profile fields * * @event core.generate_profile_fields_template_data - * @var array profile_row Array with users profile field data + * @var array profile_row Array with users profile field data * @var array tpl_fields Array with template data fields * @var bool use_contact_fields Should we display contact fields as such? * @since 3.1.0-b3 diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php index 7d564742af..30b364821d 100644 --- a/phpBB/phpbb/session.php +++ b/phpBB/phpbb/session.php @@ -441,8 +441,8 @@ class session if (!$session_expired) { - // Only update session DB a minute or so after last update or if page changes - if ($this->time_now - $this->data['session_time'] > 60 || ($this->update_session_page && $this->data['session_page'] != $this->page['page'])) + // Only update session DB a minute or so after last update or if page changes and is not ajax request + if (($this->time_now - $this->data['session_time'] > 60 || ($this->update_session_page && $this->data['session_page'] != $this->page['page'])) && !$request->is_ajax()) { $sql_ary = array('session_time' => $this->time_now); diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 5e2057f818..a3b002f350 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -177,6 +177,10 @@ class twig extends \phpbb\template\base } $names = $this->get_user_style(); + // Add 'all' folder to $names array + // It allows extensions to load a template file from 'all' folder, + // if a style doesn't include it. + $names[] = 'all'; $paths = array(); foreach ($style_directories as $directory) diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 63efe5f8ae..13e8d02469 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -1,6 +1,8 @@ +/* global phpbb */ + (function($) { // Avoid conflicts with other libraries -"use strict"; +'use strict'; // This callback will mark all forum icons read phpbb.addAjaxCallback('mark_forums_read', function(res) { @@ -40,10 +42,10 @@ phpbb.addAjaxCallback('mark_forums_read', function(res) { /** * This callback will mark all topic icons read * -* @param update_topic_links bool Wether "Mark topics read" links should be +* @param update_topic_links bool Whether "Mark topics read" links should be * updated. Defaults to true. */ -phpbb.addAjaxCallback('mark_topics_read', function(res, update_topic_links) { +phpbb.addAjaxCallback('mark_topics_read', function(res, updateTopicLinks) { var readTitle = res.NO_UNREAD_POSTS; var unreadTitle = res.UNREAD_POSTS; var iconsArray = { @@ -53,12 +55,12 @@ phpbb.addAjaxCallback('mark_topics_read', function(res, update_topic_links) { 'topic_unread': 'topic_read' }; var iconsState = ['', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine']; - var unreadClassSelectors = ''; + var unreadClassSelectors; var classMap = {}; var classNames = []; - if (typeof update_topic_links === 'undefined') { - update_topic_links = true; + if (typeof updateTopicLinks === 'undefined') { + updateTopicLinks = true; } $.each(iconsArray, function(unreadClass, readClass) { @@ -88,7 +90,7 @@ phpbb.addAjaxCallback('mark_topics_read', function(res, update_topic_links) { $('a').has('span.icon_topic_newest').remove(); // Update mark topics read links - if (update_topic_links) { + if (updateTopicLinks) { $('[data-ajax="mark_topics_read"]').attr('href', res.U_MARK_TOPICS); } @@ -114,22 +116,22 @@ phpbb.addAjaxCallback('notification.mark_read', function(res) { /** * Mark notification popup rows as read. * - * @param {jQuery} el jQuery object(s) to mark read. + * @param {jQuery} $popup jQuery object(s) to mark read. * @param {int} unreadCount The new unread notifications count. */ -phpbb.markNotifications = function(el, unreadCount) { +phpbb.markNotifications = function($popup, unreadCount) { // Remove the unread status. - el.removeClass('bg2'); - el.find('a.mark_read').remove(); + $popup.removeClass('bg2'); + $popup.find('a.mark_read').remove(); // Update the notification link to the real URL. - el.each(function() { + $popup.each(function() { var link = $(this).find('a'); link.attr('href', link.attr('data-real-url')); }); // Update the unread count. - $('#notification_list_button strong').html(unreadCount); + $('strong', '#notification_list_button').html(unreadCount); // Remove the Mark all read link if there are no unread notifications. if (!unreadCount) { $('#mark_all_notifications').remove(); @@ -143,12 +145,12 @@ phpbb.markNotifications = function(el, unreadCount) { // This callback finds the post from the delete link, and removes it. phpbb.addAjaxCallback('post_delete', function() { - var el = $(this), + var $this = $(this), postId; - if (el.attr('data-refresh') === undefined) { - postId = el[0].href.split('&p=')[1]; - var post = el.parents('#p' + postId).css('pointer-events', 'none'); + if ($this.attr('data-refresh') === undefined) { + postId = $this[0].href.split('&p=')[1]; + var post = $this.parents('#p' + postId).css('pointer-events', 'none'); if (post.hasClass('bg1') || post.hasClass('bg2')) { var posts1 = post.nextAll('.bg1'); post.nextAll('.bg2').removeClass('bg2').addClass('bg1'); @@ -167,8 +169,7 @@ phpbb.addAjaxCallback('post_visibility', function(res) { $(this).remove(); }); - if (res.visible) - { + if (res.visible) { // Remove the "Deleted by" message from the post on restoring. remove.parents('.post').find('.post_deleted_msg').css('pointer-events', 'none').fadeOut(function() { $(this).remove(); @@ -199,18 +200,18 @@ phpbb.addAjaxCallback('vote_poll', function(res) { if (typeof res.success !== 'undefined') { var poll = $('.topic_poll'); var panel = poll.find('.panel'); - var results_visible = poll.find('dl:first-child .resultbar').is(':visible'); - var most_votes = 0; + var resultsVisible = poll.find('dl:first-child .resultbar').is(':visible'); + var mostVotes = 0; // Set min-height to prevent the page from jumping when the content changes - var update_panel_height = function (height) { + var updatePanelHeight = function (height) { var height = (typeof height === 'undefined') ? panel.find('.inner').outerHeight() : height; panel.css('min-height', height); }; - update_panel_height(); + updatePanelHeight(); // Remove the View results link - if (!results_visible) { + if (!resultsVisible) { poll.find('.poll_view_results').hide(500); } @@ -226,8 +227,8 @@ phpbb.addAjaxCallback('vote_poll', function(res) { // Get the votes count of the highest poll option poll.find('[data-poll-option-id]').each(function() { var option = $(this); - var option_id = option.attr('data-poll-option-id'); - most_votes = (res.vote_counts[option_id] >= most_votes) ? res.vote_counts[option_id] : most_votes; + var optionId = option.attr('data-poll-option-id'); + mostVotes = (res.vote_counts[optionId] >= mostVotes) ? res.vote_counts[optionId] : mostVotes; }); // Update the total votes count @@ -235,28 +236,30 @@ phpbb.addAjaxCallback('vote_poll', function(res) { // Update each option poll.find('[data-poll-option-id]').each(function() { - var option = $(this); - var option_id = option.attr('data-poll-option-id'); - var voted = (typeof res.user_votes[option_id] !== 'undefined') ? true : false; - var most_voted = (res.vote_counts[option_id] == most_votes) ? true : false; - var percent = (!res.total_votes) ? 0 : Math.round((res.vote_counts[option_id] / res.total_votes) * 100); - var percent_rel = (most_votes == 0) ? 0 : Math.round((res.vote_counts[option_id] / most_votes) * 100); + var $this = $(this); + var optionId = $this.attr('data-poll-option-id'); + var voted = (typeof res.user_votes[optionId] !== 'undefined'); + var mostVoted = (res.vote_counts[optionId] === mostVotes); + var percent = (!res.total_votes) ? 0 : Math.round((res.vote_counts[optionId] / res.total_votes) * 100); + var percentRel = (mostVotes === 0) ? 0 : Math.round((res.vote_counts[optionId] / mostVotes) * 100); - option.toggleClass('voted', voted); - option.toggleClass('most-votes', most_voted); + $this.toggleClass('voted', voted); + $this.toggleClass('most-votes', mostVoted); // Update the bars - var bar = option.find('.resultbar div'); - var bar_time_lapse = (res.can_vote) ? 500 : 1500; - var new_bar_class = (percent == 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1); + var bar = $this.find('.resultbar div'); + var barTimeLapse = (res.can_vote) ? 500 : 1500; + var newBarClass = (percent === 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1); setTimeout(function () { - bar.animate({width: percent_rel + '%'}, 500).removeClass('pollbar1 pollbar2 pollbar3 pollbar4 pollbar5').addClass(new_bar_class); - bar.html(res.vote_counts[option_id]); - - var percent_txt = (!percent) ? res.NO_VOTES : percent + '%'; - option.find('.poll_option_percent').html(percent_txt); - }, bar_time_lapse); + bar.animate({width: percentRel + '%'}, 500) + .removeClass('pollbar1 pollbar2 pollbar3 pollbar4 pollbar5') + .addClass(newBarClass) + .html(res.vote_counts[optionId]); + + var percentText = percent ? percent + '%' : res.NO_VOTES; + $this.find('.poll_option_percent').html(percentText); + }, barTimeLapse); }); if (!res.can_vote) { @@ -264,30 +267,31 @@ phpbb.addAjaxCallback('vote_poll', function(res) { } // Display "Your vote has been cast." message. Disappears after 5 seconds. - var confirmation_delay = (res.can_vote) ? 300 : 900; - poll.find('.vote-submitted').delay(confirmation_delay).slideDown(200, function() { - if (results_visible) { - update_panel_height(); + var confirmationDelay = (res.can_vote) ? 300 : 900; + poll.find('.vote-submitted').delay(confirmationDelay).slideDown(200, function() { + if (resultsVisible) { + updatePanelHeight(); } $(this).delay(5000).fadeOut(500, function() { - resize_panel(300); + resizePanel(300); }); }); // Remove the gap resulting from removing options setTimeout(function() { - resize_panel(500); + resizePanel(500); }, 1500); - var resize_panel = function (time) { - var panel_height = panel.height(); - var inner_height = panel.find('.inner').outerHeight(); + var resizePanel = function (time) { + var panelHeight = panel.height(); + var innerHeight = panel.find('.inner').outerHeight(); - if (panel_height != inner_height) { - panel.css({'min-height': '', 'height': panel_height}).animate({height: inner_height}, time, function () { - panel.css({'min-height': inner_height, 'height': ''}); - }); + if (panelHeight != innerHeight) { + panel.css({'min-height': '', 'height': panelHeight}) + .animate({height: innerHeight}, time, function () { + panel.css({'min-height': innerHeight, 'height': ''}); + }); } }; } @@ -300,20 +304,19 @@ $('.poll_view_results a').click(function(e) { // Do not follow the link e.preventDefault(); - var poll = $(this).parents('.topic_poll'); + var $poll = $(this).parents('.topic_poll'); - poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show(500); - poll.find('.poll_view_results').hide(500); + $poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show(500); + $poll.find('.poll_view_results').hide(500); }); $('[data-ajax]').each(function() { - var $this = $(this), - ajax = $this.attr('data-ajax'), - filter = $this.attr('data-filter'), - fn; + var $this = $(this); + var ajax = $this.attr('data-ajax'); + var filter = $this.attr('data-filter'); if (ajax !== 'false') { - fn = (ajax !== 'true') ? ajax : null; + var fn = (ajax !== 'true') ? ajax : null; filter = (filter !== undefined) ? phpbb.getFunctionByName(filter) : null; phpbb.ajaxify({ @@ -344,10 +347,10 @@ $('.display_post').click(function(e) { // Do not follow the link e.preventDefault(); - var post_id = $(this).attr('data-post-id'); - $('#post_content' + post_id).show(); - $('#profile' + post_id).show(); - $('#post_hidden' + post_id).hide(); + var postId = $(this).attr('data-post-id'); + $('#post_content' + postId).show(); + $('#profile' + postId).show(); + $('#post_hidden' + postId).hide(); }); $('#delete_permanent').click(function () { @@ -366,10 +369,13 @@ $('#delete_permanent').click(function () { * appropriately changed based on the status of the search panel. */ $('#member_search').click(function () { - $('#memberlist_search').slideToggle('fast'); + var $memberlistSearch = $('#memberlist_search'); + + $memberlistSearch.slideToggle('fast'); phpbb.ajaxCallbacks.alt_text.call(this); + // Focus on the username textbox if it's available and displayed - if ($('#memberlist_search').is(':visible')) { + if ($memberlistSearch.is(':visible')) { $('#username').focus(); } return false; @@ -378,7 +384,7 @@ $('#member_search').click(function () { /** * Automatically resize textarea */ -$(document).ready(function() { +$(function() { phpbb.resizeTextArea($('textarea:not(#message-box textarea, .no-auto-resize)'), {minHeight: 75, maxHeight: 250}); phpbb.resizeTextArea($('#message-box textarea')); }); diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 4929e14ef7..1280ceb8ac 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -1,3 +1,5 @@ +/* global phpbb */ + /** * phpBB3 forum functions */ @@ -6,6 +8,8 @@ * Find a member */ function find_username(url) { + 'use strict'; + popup(url, 760, 570, '_usersearch'); return false; } @@ -14,6 +18,8 @@ function find_username(url) { * Window popup */ function popup(url, width, height, name) { + 'use strict'; + if (!name) { name = '_popup'; } @@ -26,17 +32,18 @@ function popup(url, width, height, name) { * Jump to page */ function pageJump(item) { + 'use strict'; var page = item.val(), - per_page = item.attr('data-per-page'), - base_url = item.attr('data-base-url'), - start_name = item.attr('data-start-name'); + perPage = item.attr('data-per-page'), + baseUrl = item.attr('data-base-url'), + startName = item.attr('data-start-name'); if (page !== null && !isNaN(page) && page == Math.floor(page) && page > 0) { - if (base_url.indexOf('?') === -1) { - document.location.href = base_url + '?' + start_name + '=' + ((page - 1) * per_page); + if (baseUrl.indexOf('?') === -1) { + document.location.href = baseUrl + '?' + startName + '=' + ((page - 1) * perPage); } else { - document.location.href = base_url.replace(/&/g, '&') + '&' + start_name + '=' + ((page - 1) * per_page); + document.location.href = baseUrl.replace(/&/g, '&') + '&' + startName + '=' + ((page - 1) * perPage); } } } @@ -46,9 +53,11 @@ function pageJump(item) { * id = ID of parent container, name = name prefix, state = state [true/false] */ function marklist(id, name, state) { + 'use strict'; + jQuery('#' + id + ' input[type=checkbox][name]').each(function() { var $this = jQuery(this); - if ($this.attr('name').substr(0, name.length) == name) { + if ($this.attr('name').substr(0, name.length) === name) { $this.prop('checked', state); } }); @@ -59,6 +68,8 @@ function marklist(id, name, state) { * e = element */ function viewableArea(e, itself) { + 'use strict'; + if (!e) { return; } @@ -86,18 +97,20 @@ function viewableArea(e, itself) { /** * Alternate display of subPanels */ -jQuery(document).ready(function() { - jQuery('.sub-panels').each(function() { +jQuery(function($) { + 'use strict'; - var panels = [], - childNodes = jQuery('a[data-subpanel]', this).each(function() { - panels.push(this.getAttribute('data-subpanel')); + $('.sub-panels').each(function() { + + var $childNodes = $('a[data-subpanel]', this), + panels = $childNodes.map(function () { + return this.getAttribute('data-subpanel'); }), - show_panel = this.getAttribute('data-show-panel'); + showPanel = this.getAttribute('data-show-panel'); if (panels.length) { - activateSubPanel(show_panel, panels); - childNodes.click(function () { + activateSubPanel(showPanel, panels); + $childNodes.click(function () { activateSubPanel(this.getAttribute('data-subpanel'), panels); return false; }); @@ -109,60 +122,30 @@ jQuery(document).ready(function() { * Activate specific subPanel */ function activateSubPanel(p, panels) { - var i; + 'use strict'; + + var i, showPanel; if (typeof(p) === 'string') { - show_panel = p; + showPanel = p; } - $('input[name="show_panel"]').val(show_panel); + $('input[name="show_panel"]').val(showPanel); - if (typeof(panels) === 'undefined') { - panels = []; - jQuery('.sub-panels a[data-subpanel]').each(function() { - panels.push(this.getAttribute('data-subpanel')); + if (typeof panels === 'undefined') { + panels = jQuery('.sub-panels a[data-subpanel]').map(function() { + return this.getAttribute('data-subpanel'); }); } for (i = 0; i < panels.length; i++) { - jQuery('#' + panels[i]).css('display', panels[i] === show_panel ? 'block' : 'none'); - jQuery('#' + panels[i] + '-tab').toggleClass('activetab', panels[i] === show_panel); - } -} - -/** -* Call print preview -*/ -function printPage() { - if (is_ie) { - printPreview(); - } else { - window.print(); - } -} - -/** -* Show/hide groups of blocks -* c = CSS style name -* e = checkbox element -* t = toggle dispay state (used to show 'grip-show' image in the profile block when hiding the profiles) -*/ -function displayBlocks(c, e, t) { - var s = (e.checked === true) ? 1 : -1; - - if (t) { - s *= -1; - } - - var divs = document.getElementsByTagName("DIV"); - - for (var d = 0; d < divs.length; d++) { - if (divs[d].className.indexOf(c) === 0) { - divs[d].style.display = (s === 1) ? 'none' : 'block'; - } + jQuery('#' + panels[i]).css('display', panels[i] === showPanel ? 'block' : 'none'); + jQuery('#' + panels[i] + '-tab').toggleClass('activetab', panels[i] === showPanel); } } function selectCode(a) { + 'use strict'; + // Get ID of code block var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0]; var s, r; @@ -209,6 +192,8 @@ function selectCode(a) { * from the displayed rectangle area */ function play_qt_file(obj) { + 'use strict'; + var rectangle = obj.GetRectangle(); var width, height; @@ -233,30 +218,32 @@ function play_qt_file(obj) { obj.Play(); } -var in_autocomplete = false; -var last_key_entered = ''; +var inAutocomplete = false; +var lastKeyEntered = ''; /** * Check event key */ -function phpbb_check_key(event) { +function phpbbCheckKey(event) { + 'use strict'; + // Keycode is array down or up? if (event.keyCode && (event.keyCode === 40 || event.keyCode === 38)) { - in_autocomplete = true; + inAutocomplete = true; } // Make sure we are not within an "autocompletion" field - if (in_autocomplete) { + if (inAutocomplete) { // If return pressed and key changed we reset the autocompletion - if (!last_key_entered || last_key_entered === event.which) { - in_autocompletion = false; + if (!lastKeyEntered || lastKeyEntered === event.which) { + inAutocomplete = false; return true; } } // Keycode is not return, then return. ;) if (event.which !== 13) { - last_key_entered = event.which; + lastKeyEntered = event.which; return true; } @@ -266,115 +253,106 @@ function phpbb_check_key(event) { /** * Apply onkeypress event for forcing default submit button on ENTER key press */ -function apply_onkeypress_event() { - jQuery('form input[type=text], form input[type=password]').on('keypress', function (e) { - var default_button = jQuery(this).parents('form').find('input[type=submit].default-submit-action'); +jQuery(function($) { + 'use strict'; + + $('form input[type=text], form input[type=password]').on('keypress', function (e) { + var defaultButton = $(this).parents('form').find('input[type=submit].default-submit-action'); - if (!default_button || default_button.length <= 0) { + if (!defaultButton || defaultButton.length <= 0) { return true; } - if (phpbb_check_key(e)) { + if (phpbbCheckKey(e)) { return true; } if ((e.which && e.which === 13) || (e.keyCode && e.keyCode === 13)) { - default_button.click(); + defaultButton.click(); return false; } return true; }); -} - -jQuery(document).ready(apply_onkeypress_event); +}); /** * Functions for user search popup */ -function insert_user(formId, value) +function insertUser(formId, value) { - var form = jQuery(formId), - formName = form.attr('data-form-name'), - fieldName = form.attr('data-field-name'), + 'use strict'; + + var $form = jQuery(formId), + formName = $form.attr('data-form-name'), + fieldName = $form.attr('data-field-name'), item = opener.document.forms[formName][fieldName]; if (item.value.length && item.type == 'textarea') { - value = item.value + "\n" + value; + value = item.value + '\n' + value; } item.value = value; } -function insert_marked_users(formId, users) -{ - if (typeof(users.length) == "undefined") - { - if (users.checked) - { - insert_user(formId, users.value); - } - } - else if (users.length > 0) - { - for (i = 0; i < users.length; i++) - { - if (users[i].checked) - { - insert_user(formId, users[i].value); - } +function insert_marked_users(formId, users) { + 'use strict'; + + for (var i = 0; i < users.length; i++) { + if (users[i].checked) { + insertUser(formId, users[i].value); } } - self.close(); + window.close(); } -function insert_single_user(formId, user) -{ - insert_user(formId, user); - self.close(); +function insert_single_user(formId, user) { + 'use strict'; + + insertUser(formId, user); + window.close(); } /** * Parse document block */ -function parse_document(container) -{ +function parseDocument($container) { + 'use strict'; + var test = document.createElement('div'), oldBrowser = (typeof test.style.borderRadius == 'undefined'); - delete test; - /** * Reset avatar dimensions when changing URL or EMAIL */ - container.find('input[data-reset-on-edit]').bind('keyup', function() { + $container.find('input[data-reset-on-edit]').on('keyup', function() { $(this.getAttribute('data-reset-on-edit')).val(''); }); /** * Pagination */ - container.find('.pagination .page-jump-form :button').click(function() { - $input = $(this).siblings('input.inputbox'); + $container.find('.pagination .page-jump-form :button').click(function() { + var $input = $(this).siblings('input.inputbox'); pageJump($input); }); - container.find('.pagination .page-jump-form input.inputbox').on('keypress', function(event) { - if (event.which == 13 || event.keyCode == 13) { + $container.find('.pagination .page-jump-form input.inputbox').on('keypress', function(event) { + if (event.which === 13 || event.keyCode === 13) { event.preventDefault(); pageJump($(this)); } }); - container.find('.pagination .dropdown-trigger').click(function() { - $dropdown_container = $(this).parent(); + $container.find('.pagination .dropdown-trigger').click(function() { + var $dropdownContainer = $(this).parent(); // Wait a little bit to make sure the dropdown has activated setTimeout(function() { - if ($dropdown_container.hasClass('dropdown-visible')) { - $dropdown_container.find('input.inputbox').focus(); + if ($dropdownContainer.hasClass('dropdown-visible')) { + $dropdownContainer.find('input.inputbox').focus(); } - },100); + }, 100); }); /** @@ -382,27 +360,29 @@ function parse_document(container) */ if (oldBrowser) { // Fix .linklist.bulletin lists - container.find('ul.linklist.bulletin > li:first-child, ul.linklist.bulletin > li.rightside:last-child').addClass('no-bulletin'); + $container.find('ul.linklist.bulletin > li:first-child, ul.linklist.bulletin > li.rightside:last-child').addClass('no-bulletin'); } /** * Resize navigation block to keep all links on same line */ - container.find('.navlinks').each(function() { + $container.find('.navlinks').each(function() { var $this = $(this), - left = $this.children().not('.rightside'), - right = $this.children('.rightside'); + $left = $this.children().not('.rightside'), + $right = $this.children('.rightside'); - if (left.length !== 1 || !right.length) return; + if ($left.length !== 1 || !$right.length) { + return; + } function resize() { var width = 0, - diff = left.outerWidth(true) - left.width(); + diff = $left.outerWidth(true) - $left.width(); - right.each(function() { + $right.each(function() { width += $(this).outerWidth(true); }); - left.css('max-width', Math.floor($this.width() - width - diff) + 'px'); + $left.css('max-width', Math.floor($this.width() - width - diff) + 'px'); } resize(); @@ -412,11 +392,11 @@ function parse_document(container) /** * Makes breadcrumbs responsive */ - container.find('.breadcrumbs:not([data-skip-responsive])').each(function() { + $container.find('.breadcrumbs:not([data-skip-responsive])').each(function() { var $this = $(this), $body = $('body'), - links = $this.find('.crumb'), - length = links.length, + $links = $this.find('.crumb'), + length = $links.length, classes = ['wrapped-max', 'wrapped-wide', 'wrapped-medium', 'wrapped-small', 'wrapped-tiny'], classesLength = classes.length, maxHeight = 0, @@ -429,14 +409,13 @@ function parse_document(container) $link.attr('title', $link.text()); }); - // Funciton that checks breadcrumbs + // Function that checks breadcrumbs function check() { var height = $this.height(), - width = $body.width(), - link, i, j; + width = $body.width(); - maxHeight = parseInt($this.css('line-height')) | 0; - links.each(function() { + maxHeight = parseInt($this.css('line-height')); + $links.each(function() { if ($(this).height() > 0) { maxHeight = Math.max(maxHeight, $(this).outerHeight(true)); } @@ -444,7 +423,6 @@ function parse_document(container) if (height <= maxHeight) { if (!wrapped || lastWidth === false || lastWidth >= width) { - lastWidth = width; return; } } @@ -452,7 +430,6 @@ function parse_document(container) if (wrapped) { $this.removeClass('wrapped').find('.crumb.wrapped').removeClass('wrapped ' + classes.join(' ')); - wrapped = false; if ($this.height() <= maxHeight) { return; } @@ -464,9 +441,9 @@ function parse_document(container) return; } - for (i = 0; i < classesLength; i ++) { - for (j = length - 1; j >= 0; j --) { - links.eq(j).addClass('wrapped ' + classes[i]); + for (var i = 0; i < classesLength; i ++) { + for (var j = length - 1; j >= 0; j --) { + $links.eq(j).addClass('wrapped ' + classes[i]); if ($this.height() <= maxHeight) { return; } @@ -482,32 +459,29 @@ function parse_document(container) /** * Responsive link lists */ - container.find('.linklist:not(.navlinks, [data-skip-responsive]), .postbody .post-buttons:not([data-skip-responsive])').each(function() { + $container.find('.linklist:not(.navlinks, [data-skip-responsive]), .postbody .post-buttons:not([data-skip-responsive])').each(function() { var $this = $(this), $body = $('body'), filterSkip = '.breadcrumbs, [data-skip-responsive]', filterLast = '.edit-icon, .quote-icon, [data-last-responsive]', persist = $this.attr('id') == 'nav-main', - allLinks = $this.children(), - links = allLinks.not(filterSkip), + $allLinks = $this.children(), + $links = $allLinks.not(filterSkip), html = '<li class="responsive-menu" style="display:none;"><a href="javascript:void(0);" class="responsive-menu-link"> </a><div class="dropdown" style="display:none;"><div class="pointer"><div class="pointer-inner" /></div><ul class="dropdown-contents" /></div></li>', - filterLastList = links.filter(filterLast), + $filterLastList = $links.filter(filterLast), slack = 1; // Vertical slack space (in pixels). Determines how sensitive the script is in determining whether a line-break has occured. if (!persist) { - if (links.is('.rightside')) - { - links.filter('.rightside:first').before(html); + if ($links.is('.rightside')) { + $links.filter('.rightside:first').before(html); $this.children('.responsive-menu').addClass('rightside'); - } - else - { + } else { $this.append(html); } } - var item = $this.children('.responsive-menu'), - menu = item.find('.dropdown-contents'), + var $item = $this.children('.responsive-menu'), + $menu = $item.find('.dropdown-contents'), lastWidth = false, compact = false, responsive = false, @@ -521,29 +495,31 @@ function parse_document(container) // Unhide the quick-links menu if it has content if (persist) { - item.addClass('hidden'); - if (menu.find('li:not(.separator, .clone)').length || (responsive && menu.find('li.clone').length)) { - item.removeClass('hidden'); + $item.addClass('hidden'); + if ($menu.find('li:not(.separator, .clone)').length || (responsive && $menu.find('li.clone').length)) { + $item.removeClass('hidden'); } } // Reset responsive and compact layout if (responsive) { - responsive = false; $this.removeClass('responsive'); - links.css('display', ''); - if (!persist) item.css('display', 'none'); + $links.css('display', ''); + if (!persist) { + $item.css('display', 'none'); + } } if (compact) { - compact = false; $this.removeClass('compact'); } // Find tallest element var maxHeight = 0; - allLinks.each(function() { - if (!$(this).height()) return; + $allLinks.each(function() { + if (!$(this).height()) { + return; + } maxHeight = Math.max(maxHeight, $(this).outerHeight(true)); }); @@ -557,12 +533,13 @@ function parse_document(container) } // Enable compact layout, find tallest element, compare to height of whole block - compact = true; $this.addClass('compact'); var compactMaxHeight = 0; - allLinks.each(function() { - if (!$(this).height()) return; + $allLinks.each(function() { + if (!$(this).height()) { + return; + } compactMaxHeight = Math.max(compactMaxHeight, $(this).outerHeight(true)); }); @@ -571,51 +548,51 @@ function parse_document(container) } // Compact layout did not resize block enough, switch to responsive layout - compact = false; $this.removeClass('compact'); responsive = true; if (!copied) { - var clone = links.clone(true); + var clone = $links.clone(true); clone.filter('.rightside').each(function() { - if (persist) $(this).addClass('clone'); - menu.prepend(this); + if (persist) { + $(this).addClass('clone'); + } + $menu.prepend(this); }); if (persist) { - menu.prepend(clone.not('.rightside').addClass('clone')); + $menu.prepend(clone.not('.rightside').addClass('clone')); } else { - menu.prepend(clone.not('.rightside')); + $menu.prepend(clone.not('.rightside')); } - menu.find('li.leftside, li.rightside').removeClass('leftside rightside'); - menu.find('.inputbox').parents('li:first').css('white-space', 'normal'); + $menu.find('li.leftside, li.rightside').removeClass('leftside rightside'); + $menu.find('.inputbox').parents('li:first').css('white-space', 'normal'); if ($this.hasClass('post-buttons')) { - $('.button', menu).removeClass('button icon-button'); - $('.responsive-menu-link', item).addClass('button icon-button').prepend('<span></span>'); + $('.button', $menu).removeClass('button icon-button'); + $('.responsive-menu-link', $item).addClass('button icon-button').prepend('<span></span>'); } copied = true; - } - else { - menu.children().css('display', ''); + } else { + $menu.children().css('display', ''); } - item.css('display', ''); + $item.css('display', ''); $this.addClass('responsive'); // Try to not hide filtered items - if (filterLastList.length) { - links.not(filterLast).css('display', 'none'); + if ($filterLastList.length) { + $links.not(filterLast).css('display', 'none'); maxHeight = 0; - filterLastList.each(function() { + $filterLastList.each(function() { if (!$(this).height()) return; maxHeight = Math.max(maxHeight, $(this).outerHeight(true)); }); if ($this.height() <= (maxHeight + slack)) { - menu.children().filter(filterLast).css('display', 'none'); + $menu.children().filter(filterLast).css('display', 'none'); return; } } @@ -624,10 +601,12 @@ function parse_document(container) compact = true; $this.addClass('compact'); - links.css('display', 'none'); + $links.css('display', 'none'); } - if (!persist) phpbb.registerDropdown(item.find('a.responsive-menu-link'), item.find('.dropdown')); + if (!persist) { + phpbb.registerDropdown($item.find('a.responsive-menu-link'), $item.find('.dropdown')); + } check(); $(window).resize(check); @@ -643,7 +622,7 @@ function parse_document(container) /** * Adjust topiclist lists with check boxes */ - container.find('ul.topiclist dd.mark').siblings('dt').children('.list-inner').addClass('with-mark'); + $container.find('ul.topiclist dd.mark').siblings('dt').children('.list-inner').addClass('with-mark'); /** * Appends contents of all extra columns to first column in @@ -652,31 +631,30 @@ function parse_document(container) * To add that functionality to .topiclist list simply add * responsive-show-all to list of classes */ - container.find('.topiclist.responsive-show-all > li > dl').each(function() { + $container.find('.topiclist.responsive-show-all > li > dl').each(function() { var $this = $(this), - block = $this.find('dt .responsive-show:last-child'), + $block = $this.find('dt .responsive-show:last-child'), first = true; // Create block that is visible only on mobile devices - if (!block.length) { + if (!$block.length) { $this.find('dt > .list-inner').append('<div class="responsive-show" style="display:none;" />'); - block = $this.find('dt .responsive-show:last-child'); - } - else { - first = ($.trim(block.text()).length == 0); + $block = $this.find('dt .responsive-show:last-child'); + } else { + first = ($.trim($block.text()).length === 0); } // Copy contents of each column $this.find('dd').not('.mark').each(function() { var column = $(this), - children = column.children(), + $children = column.children(), html = column.html(); - if (children.length == 1 && children.text() == column.text()) { - html = children.html(); + if ($children.length == 1 && $children.text() == column.text()) { + html = $children.html(); } - block.append((first ? '' : '<br />') + html); + $block.append((first ? '' : '<br />') + html); first = false; }); @@ -689,15 +667,15 @@ function parse_document(container) * To add that functionality to .topiclist list simply add * responsive-show-columns to list of classes */ - container.find('.topiclist.responsive-show-columns').each(function() { - var list = $(this), + $container.find('.topiclist.responsive-show-columns').each(function() { + var $list = $(this), headers = [], headersLength = 0; // Find all headers, get contents - list.prev('.topiclist').find('li.header dd').not('.mark').each(function() { + $list.prev('.topiclist').find('li.header dd').not('.mark').each(function() { headers.push($(this).text()); - headersLength ++; + headersLength++; }); if (!headersLength) { @@ -705,18 +683,18 @@ function parse_document(container) } // Parse each row - list.find('dl').each(function() { + $list.find('dl').each(function() { var $this = $(this), - block = $this.find('dt .responsive-show:last-child'), + $block = $this.find('dt .responsive-show:last-child'), first = true; // Create block that is visible only on mobile devices - if (!block.length) { + if (!$block.length) { $this.find('dt > .list-inner').append('<div class="responsive-show" style="display:none;" />'); - block = $this.find('dt .responsive-show:last-child'); + $block = $this.find('dt .responsive-show:last-child'); } else { - first = ($.trim(block.text()).length == 0); + first = ($.trim($block.text()).length === 0); } // Copy contents of each column @@ -734,7 +712,7 @@ function parse_document(container) html = headers[i] + ': <strong>' + html + '</strong>'; } - block.append((first ? '' : '<br />') + html); + $block.append((first ? '' : '<br />') + html); first = false; }); @@ -744,16 +722,15 @@ function parse_document(container) /** * Responsive tables */ - container.find('table.table1').not('.not-responsive').each(function() { + $container.find('table.table1').not('.not-responsive').each(function() { var $this = $(this), - th = $this.find('thead > tr > th'), - columns = th.length, + $th = $this.find('thead > tr > th'), headers = [], totalHeaders = 0, i, headersLength; // Find each header - th.each(function(column) { + $th.each(function(column) { var cell = $(this), colspan = parseInt(cell.attr('colspan')), dfn = cell.attr('data-dfn'), @@ -761,10 +738,10 @@ function parse_document(container) colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan; - for (i=0; i<colspan; i++) { + for (i = 0; i < colspan; i++) { headers.push(text); } - totalHeaders ++; + totalHeaders++; if (dfn && !column) { $this.addClass('show-header'); @@ -802,8 +779,7 @@ function parse_document(container) if ((text.length && text !== '-') || cell.children().length) { cell.prepend('<dfn style="display: none;">' + headers[column] + '</dfn>'); - } - else { + } else { cell.addClass('empty'); } @@ -816,10 +792,9 @@ function parse_document(container) /** * Hide empty responsive tables */ - container.find('table.responsive > tbody').not('.responsive-skip-empty').each(function() { - var items = $(this).children('tr'); - if (items.length == 0) - { + $container.find('table.responsive > tbody').not('.responsive-skip-empty').each(function() { + var $items = $(this).children('tr'); + if (!$items.length) { $(this).parent('table:first').addClass('responsive-hide'); } }); @@ -827,65 +802,64 @@ function parse_document(container) /** * Responsive tabs */ - container.find('#tabs, #minitabs').not('[data-skip-responsive]').each(function() { + $container.find('#tabs, #minitabs').not('[data-skip-responsive]').each(function() { var $this = $(this), $body = $('body'), - ul = $this.children(), - tabs = ul.children().not('[data-skip-responsive]'), - links = tabs.children('a'), - item = ul.append('<li class="tab responsive-tab" style="display:none;"><a href="javascript:void(0);" class="responsive-tab-link"> </a><div class="dropdown tab-dropdown" style="display: none;"><div class="pointer"><div class="pointer-inner" /></div><ul class="dropdown-contents" /></div></li>').find('li.responsive-tab'), - menu = item.find('.dropdown-contents'), + $ul = $this.children(), + $tabs = $ul.children().not('[data-skip-responsive]'), + $links = $tabs.children('a'), + $item = $ul.append('<li class="tab responsive-tab" style="display:none;"><a href="javascript:void(0);" class="responsive-tab-link"> </a><div class="dropdown tab-dropdown" style="display: none;"><div class="pointer"><div class="pointer-inner" /></div><ul class="dropdown-contents" /></div></li>').find('li.responsive-tab'), + $menu = $item.find('.dropdown-contents'), maxHeight = 0, lastWidth = false, responsive = false; - links.each(function() { - var link = $(this); - maxHeight = Math.max(maxHeight, Math.max(link.outerHeight(true), link.parent().outerHeight(true))); - }) + $links.each(function() { + var $this = $(this); + maxHeight = Math.max(maxHeight, Math.max($this.outerHeight(true), $this.parent().outerHeight(true))); + }); function check() { var width = $body.width(), height = $this.height(); - if (arguments.length == 0 && (!responsive || width <= lastWidth) && height <= maxHeight) { + if (!arguments.length && (!responsive || width <= lastWidth) && height <= maxHeight) { return; } - tabs.show(); - item.hide(); + $tabs.show(); + $item.hide(); lastWidth = width; height = $this.height(); if (height <= maxHeight) { - responsive = false; - if (item.hasClass('dropdown-visible')) { - phpbb.toggleDropdown.call(item.find('a.responsive-tab-link').get(0)); + if ($item.hasClass('dropdown-visible')) { + phpbb.toggleDropdown.call($item.find('a.responsive-tab-link').get(0)); } return; } responsive = true; - item.show(); - menu.html(''); + $item.show(); + $menu.html(''); - var availableTabs = tabs.filter(':not(.activetab, .responsive-tab)'), - total = availableTabs.length, - i, tab; + var $availableTabs = $tabs.filter(':not(.activetab, .responsive-tab)'), + total = $availableTabs.length, + i, $tab; for (i = total - 1; i >= 0; i --) { - tab = availableTabs.eq(i); - menu.prepend(tab.clone(true).removeClass('tab')); - tab.hide(); + $tab = $availableTabs.eq(i); + $menu.prepend($tab.clone(true).removeClass('tab')); + $tab.hide(); if ($this.height() <= maxHeight) { - menu.find('a').click(function() { check(true); }); + $menu.find('a').click(function() { check(true); }); return; } } - menu.find('a').click(function() { check(true); }); + $menu.find('a').click(function() { check(true); }); } - phpbb.registerDropdown(item.find('a.responsive-tab-link'), item.find('.dropdown'), {visibleClass: 'activetab'}); + phpbb.registerDropdown($item.find('a.responsive-tab-link'), $item.find('.dropdown'), {visibleClass: 'activetab'}); check(true); $(window).resize(check); @@ -894,10 +868,9 @@ function parse_document(container) /** * Hide UCP/MCP navigation if there is only 1 item */ - container.find('#navigation').each(function() { - var items = $(this).children('ol, ul').children('li'); - if (items.length == 1) - { + $container.find('#navigation').each(function() { + var $items = $(this).children('ol, ul').children('li'); + if ($items.length === 1) { $(this).addClass('responsive-hide'); } }); @@ -905,7 +878,7 @@ function parse_document(container) /** * Replace responsive text */ - container.find('[data-responsive-text]').each(function() { + $container.find('[data-responsive-text]').each(function() { var $this = $(this), fullText = $this.text(), responsiveText = $this.attr('data-responsive-text'), @@ -913,12 +886,16 @@ function parse_document(container) function check() { if ($(window).width() > 700) { - if (!responsive) return; + if (!responsive) { + return; + } $this.text(fullText); responsive = false; return; } - if (responsive) return; + if (responsive) { + return; + } $this.text(responsiveText); responsive = true; } @@ -931,18 +908,18 @@ function parse_document(container) /** * Run onload functions */ -(function($) { - $(document).ready(function() { - // Swap .nojs and .hasjs - $('#phpbb.nojs').toggleClass('nojs hasjs'); - $('#phpbb').toggleClass('hastouch', phpbb.isTouch); - $('#phpbb.hastouch').removeClass('notouch'); - - // Focus forms - $('form[data-focus]:first').each(function() { - $('#' + this.getAttribute('data-focus')).focus(); - }); +jQuery(function($) { + 'use strict'; + + // Swap .nojs and .hasjs + $('#phpbb.nojs').toggleClass('nojs hasjs'); + $('#phpbb').toggleClass('hastouch', phpbb.isTouch); + $('#phpbb.hastouch').removeClass('notouch'); - parse_document($('body')); + // Focus forms + $('form[data-focus]:first').each(function() { + $('#' + this.getAttribute('data-focus')).focus(); }); -})(jQuery); + + parseDocument($('body')); +}); diff --git a/phpBB/styles/prosilver/template/mcp_warn_post.html b/phpBB/styles/prosilver/template/mcp_warn_post.html index 0dd2e14d92..59c7d0d495 100644 --- a/phpBB/styles/prosilver/template/mcp_warn_post.html +++ b/phpBB/styles/prosilver/template/mcp_warn_post.html @@ -44,6 +44,8 @@ </div> </div> +<!-- EVENT mcp_warn_post_add_warning_field_before --> + <div class="panel"> <div class="inner"> @@ -64,6 +66,8 @@ </div> </div> +<!-- EVENT mcp_warn_post_add_warning_field_after --> + <fieldset class="submit-buttons"> <input type="reset" value="{L_RESET}" name="reset" class="button2" /> <input type="submit" name="action[add_warning]" value="{L_SUBMIT}" class="button1" /> diff --git a/phpBB/styles/prosilver/template/mcp_warn_user.html b/phpBB/styles/prosilver/template/mcp_warn_user.html index 1541f2e5f6..1ad6df7ade 100644 --- a/phpBB/styles/prosilver/template/mcp_warn_user.html +++ b/phpBB/styles/prosilver/template/mcp_warn_user.html @@ -28,6 +28,8 @@ </div> </div> +<!-- EVENT mcp_warn_user_add_warning_field_before --> + <div class="panel"> <div class="inner"> @@ -48,6 +50,8 @@ </div> </div> +<!-- EVENT mcp_warn_user_add_warning_field_after --> + <fieldset class="submit-buttons"> <input type="reset" value="{L_RESET}" name="reset" class="button2" /> <input type="submit" name="action[add_warning]" value="{L_SUBMIT}" class="button1" /> diff --git a/phpBB/styles/prosilver/template/memberlist_im.html b/phpBB/styles/prosilver/template/memberlist_im.html index 4fb383a0ba..bc71aa0969 100644 --- a/phpBB/styles/prosilver/template/memberlist_im.html +++ b/phpBB/styles/prosilver/template/memberlist_im.html @@ -1,6 +1,6 @@ <!-- INCLUDE simple_header.html --> -<h2 class="solo">{L_SEND_IM}</h2> +<h2>{L_SEND_IM}</h2> <form method="post" action="{S_IM_ACTION}"> diff --git a/phpBB/styles/prosilver/template/memberlist_view.html b/phpBB/styles/prosilver/template/memberlist_view.html index 55fcbe23ba..eb151af8df 100644 --- a/phpBB/styles/prosilver/template/memberlist_view.html +++ b/phpBB/styles/prosilver/template/memberlist_view.html @@ -65,7 +65,7 @@ <dl class="details"> <!-- IF U_EMAIL --><dt>{L_EMAIL_ADDRESS}{L_COLON}</dt> <dd><a href="{U_EMAIL}">{L_SEND_EMAIL_USER}</a></dd><!-- ENDIF --> <!-- IF U_PM --><dt>{L_PM}{L_COLON}</dt> <dd><a href="{U_PM}">{L_SEND_PRIVATE_MESSAGE}</a></dd><!-- ENDIF --> - <!-- IF U_JABBER and S_JABBER_ENABLED --><dt>{L_JABBER}{L_COLON}</dt> <dd><a href="{U_JABBER}" onclick="popup(this.href, 550, 320); return false;">{L_SEND_JABBER_MESSAGE}</a></dd><!-- ELSEIF USER_JABBER --><dt>{L_JABBER}{L_COLON}</dt> <dd>{USER_JABBER}</dd><!-- ENDIF --> + <!-- IF U_JABBER and S_JABBER_ENABLED --><dt>{L_JABBER}{L_COLON}</dt> <dd><a href="{U_JABBER}" onclick="popup(this.href, 750, 320); return false;">{L_SEND_JABBER_MESSAGE}</a></dd><!-- ELSEIF USER_JABBER --><dt>{L_JABBER}{L_COLON}</dt> <dd>{USER_JABBER}</dd><!-- ENDIF --> <!-- BEGIN custom_fields --> <!-- IF custom_fields.S_PROFILE_CONTACT --> <dt>{custom_fields.PROFILE_FIELD_NAME}{L_COLON}</dt> diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html index 076a3160f0..7882279485 100644 --- a/phpBB/styles/prosilver/template/overall_header.html +++ b/phpBB/styles/prosilver/template/overall_header.html @@ -3,8 +3,6 @@ <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width" /> -<meta name="keywords" content="" /> -<meta name="description" content="" /> {META} <title><!-- IF UNREAD_NOTIFICATIONS_COUNT -->({UNREAD_NOTIFICATIONS_COUNT}) <!-- ENDIF --><!-- IF not S_VIEWTOPIC and not S_VIEWFORUM -->{SITENAME} - <!-- ENDIF --><!-- IF S_IN_MCP -->{L_MCP} - <!-- ELSEIF S_IN_UCP -->{L_UCP} - <!-- ENDIF -->{PAGE_TITLE}<!-- IF S_VIEWTOPIC or S_VIEWFORUM --> - {SITENAME}<!-- ENDIF --></title> @@ -43,7 +41,7 @@ <link href="{T_THEME_PATH}/plupload.css?assets_version={T_ASSETS_VERSION}" rel="stylesheet" type="text/css" media="screen, projection" /> <!-- ENDIF --> -<!--[if lte IE 8]> +<!--[if lte IE 9]> <link href="{T_THEME_PATH}/tweaks.css?assets_version={T_ASSETS_VERSION}" rel="stylesheet" type="text/css" media="screen, projection" /> <![endif]--> diff --git a/phpBB/styles/prosilver/template/pagination.html b/phpBB/styles/prosilver/template/pagination.html index cb2c09bff7..4680eaa175 100644 --- a/phpBB/styles/prosilver/template/pagination.html +++ b/phpBB/styles/prosilver/template/pagination.html @@ -7,7 +7,7 @@ <ul class="dropdown-contents"> <li>{L_JUMP_TO_PAGE}{L_COLON}</li> <li class="page-jump-form"> - <input type="number" name="page-number" maxlength="6" title="{L_JUMP_PAGE}" class="inputbox tiny" data-per-page="{PER_PAGE}" data-base-url="{BASE_URL|e('html_attr')}" data-start-name="{START_NAME}" /> + <input type="number" name="page-number" min="1" maxlength="6" title="{L_JUMP_PAGE}" class="inputbox tiny" data-per-page="{PER_PAGE}" data-base-url="{BASE_URL|e('html_attr')}" data-start-name="{START_NAME}" /> <input class="button2" value="{L_GO}" type="button" /> </li> </ul> diff --git a/phpBB/styles/prosilver/template/posting_editor.html b/phpBB/styles/prosilver/template/posting_editor.html index 25e3be3bcb..333e61008e 100644 --- a/phpBB/styles/prosilver/template/posting_editor.html +++ b/phpBB/styles/prosilver/template/posting_editor.html @@ -43,7 +43,7 @@ <!-- END smiley --> <!-- ENDIF --> <!-- IF S_SHOW_SMILEY_LINK and S_SMILIES_ALLOWED--> - <br /><a href="{U_MORE_SMILIES}" onclick="popup(this.href, 300, 350, '_phpbbsmilies'); return false;">{L_MORE_SMILIES}</a> + <br /><a href="{U_MORE_SMILIES}" onclick="popup(this.href, 750, 350, '_phpbbsmilies'); return false;">{L_MORE_SMILIES}</a> <!-- ENDIF --> <!-- IF BBCODE_STATUS --> @@ -107,7 +107,7 @@ <a href="#tabs" data-subpanel="attach-panel" role="tab" aria-controls="attach-panel"> {L_ATTACHMENTS} <strong id="file-total-progress"><strong id="file-total-progress-bar"></strong></strong> </a> - </li> + </li> <!-- ENDIF --> <!-- IF S_SHOW_POLL_BOX || S_POLL_DELETE --> <li id="poll-panel-tab" class="tab"> diff --git a/phpBB/styles/prosilver/template/posting_pm_header.html b/phpBB/styles/prosilver/template/posting_pm_header.html index dea50b5daf..032d8c6a6f 100644 --- a/phpBB/styles/prosilver/template/posting_pm_header.html +++ b/phpBB/styles/prosilver/template/posting_pm_header.html @@ -15,7 +15,9 @@ <dd class="recipients"> <input type="submit" name="add_to" value="{L_ADD}" class="button2" tabindex="1" /> <input type="submit" name="add_bcc" value="{L_ADD_BCC}" class="button2" tabindex="1" /> + <!-- EVENT posting_pm_header_find_username_before --> <span><a href="{U_FIND_USERNAME}" onclick="find_username(this.href); return false;">{L_FIND_USERNAME}</a></span> + <!-- EVENT posting_pm_header_find_username_after --> </dd> </dl> <!-- ENDIF --> diff --git a/phpBB/styles/prosilver/template/simple_header.html b/phpBB/styles/prosilver/template/simple_header.html index 0831d5f9dc..6d22a074be 100644 --- a/phpBB/styles/prosilver/template/simple_header.html +++ b/phpBB/styles/prosilver/template/simple_header.html @@ -3,8 +3,6 @@ <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width" /> -<meta name="keywords" content="" /> -<meta name="description" content="" /> {META} <title>{SITENAME} • <!-- IF S_IN_MCP -->{L_MCP} • <!-- ELSEIF S_IN_UCP -->{L_UCP} • <!-- ENDIF -->{PAGE_TITLE}</title> @@ -36,6 +34,6 @@ <!-- EVENT simple_header_body_before --> -<div id="simple-wrap"> +<div id="wrap"> <a id="top" class="anchor" accesskey="t"></a> <div id="page-body"> diff --git a/phpBB/styles/prosilver/template/timezone.js b/phpBB/styles/prosilver/template/timezone.js index e0d3da9ff7..44ec1b0979 100644 --- a/phpBB/styles/prosilver/template/timezone.js +++ b/phpBB/styles/prosilver/template/timezone.js @@ -1,6 +1,8 @@ +/* global phpbb */ + (function($) { // Avoid conflicts with other libraries -"use strict"; +'use strict'; $('#tz_date').change(function() { phpbb.timezoneSwitchDate(false); @@ -10,12 +12,9 @@ $('#tz_select_date_suggest').click(function(){ phpbb.timezonePreselectSelect(true); }); -$(document).ready( - phpbb.timezoneEnableDateSelection -); - -$(document).ready( - phpbb.timezonePreselectSelect($('#tz_select_date_suggest').attr('timezone-preselect') === 'true') -); +$(function () { + phpbb.timezoneEnableDateSelection(); + phpbb.timezonePreselectSelect($('#tz_select_date_suggest').attr('timezone-preselect') === 'true'); +}); })(jQuery); // Avoid conflicts with other libraries diff --git a/phpBB/styles/prosilver/template/ucp_attachments.html b/phpBB/styles/prosilver/template/ucp_attachments.html index ddbf892dee..1d4963273c 100644 --- a/phpBB/styles/prosilver/template/ucp_attachments.html +++ b/phpBB/styles/prosilver/template/ucp_attachments.html @@ -12,7 +12,7 @@ <!-- IF .attachrow --> <div class="action-bar top"> <div class="pagination"> - {TOTAL_ATTACHMENTS} {L_TITLE} + {NUM_ATTACHMENTS} <!-- IF .pagination --> <!-- INCLUDE pagination.html --> <!-- ELSE --> diff --git a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html index 941541c582..ddd95780d7 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html +++ b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html @@ -14,7 +14,7 @@ <!-- ENDIF --> -<div id="post-{MESSAGE_ID}" class="post pm<!-- IF S_POST_UNAPPROVED or S_POST_REPORTED --> reported<!-- ENDIF --><!-- IF S_ONLINE --> online<!-- ENDIF -->"> +<div id="post-{MESSAGE_ID}" class="post pm has-profile<!-- IF S_POST_UNAPPROVED or S_POST_REPORTED --> reported<!-- ENDIF --><!-- IF S_ONLINE --> online<!-- ENDIF -->"> <div class="inner"> <dl class="postprofile" id="profile{MESSAGE_ID}"> @@ -55,7 +55,7 @@ <!-- IF REMAINDER eq 0 --> <div> <!-- ENDIF --> - <a href="<!-- IF contact.U_CONTACT -->{contact.U_CONTACT}<!-- ELSE -->{contact.U_PROFILE_AUTHOR}<!-- ENDIF -->" title="{contact.NAME}"<!-- IF $S_LAST_CELL --> class="last-cell"<!-- ENDIF --><!-- IF contact.ID eq 'jabber' --> onclick="popup(this.href, 550, 320); return false;"<!-- ENDIF -->> + <a href="<!-- IF contact.U_CONTACT -->{contact.U_CONTACT}<!-- ELSE -->{contact.U_PROFILE_AUTHOR}<!-- ENDIF -->" title="{contact.NAME}"<!-- IF $S_LAST_CELL --> class="last-cell"<!-- ENDIF --><!-- IF contact.ID eq 'jabber' --> onclick="popup(this.href, 750, 320); return false;"<!-- ENDIF -->> <span class="contact-icon {contact.ID}-icon">{contact.NAME}</span> </a> <!-- IF REMAINDER eq 3 or contact.S_LAST_ROW --> diff --git a/phpBB/styles/prosilver/template/viewonline_whois.html b/phpBB/styles/prosilver/template/viewonline_whois.html index 031f18afdc..5d780490da 100644 --- a/phpBB/styles/prosilver/template/viewonline_whois.html +++ b/phpBB/styles/prosilver/template/viewonline_whois.html @@ -1,14 +1,10 @@ <!-- INCLUDE simple_header.html --> -<h2 class="whois-title">{L_WHOIS}</h2> +<h2>{L_WHOIS}</h2> <div class="panel"> <div class="inner"> - - <div class="postbody"><div class="content"> - <pre>{WHOIS}</pre> - </div></div> - + <pre>{WHOIS}</pre> </div> </div> <a href="#" onclick="window.close(); return false;">{L_CLOSE_WINDOW}</a> diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index ac9c9a362a..5c8879af88 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -51,7 +51,7 @@ <!-- IF .pagination or TOTAL_POSTS --> <div class="pagination"> - <!-- IF U_VIEW_UNREAD_POST and not S_IS_BOT --><a href="{U_VIEW_UNREAD_POST}" class="mark">{L_VIEW_UNREAD_POST}</a> • <!-- ENDIF -->{TOTAL_POSTS} + <!-- IF U_VIEW_UNREAD_POST and not S_IS_BOT --><a href="{U_VIEW_UNREAD_POST}" class="mark">{L_VIEW_UNREAD_POST}</a> • <!-- ENDIF -->{TOTAL_POSTS} <!-- IF .pagination --> <!-- INCLUDE pagination.html --> <!-- ELSE --> @@ -120,7 +120,7 @@ <!-- IF postrow.S_FIRST_UNREAD --> <a id="unread" class="anchor"<!-- IF S_UNREAD_VIEW --> data-url="{postrow.U_MINI_POST}"<!-- ENDIF -->></a> <!-- ENDIF --> - <div id="p{postrow.POST_ID}" class="post <!-- IF postrow.S_ROW_COUNT is odd -->bg1<!-- ELSE -->bg2<!-- ENDIF --><!-- IF postrow.S_UNREAD_POST --> unreadpost<!-- ENDIF --><!-- IF postrow.S_POST_REPORTED --> reported<!-- ENDIF --><!-- IF postrow.S_POST_DELETED --> deleted<!-- ENDIF --><!-- IF postrow.S_ONLINE and not postrow.S_POST_HIDDEN --> online<!-- ENDIF --><!-- IF postrow.POSTER_WARNINGS --> warned<!-- ENDIF -->"> + <div id="p{postrow.POST_ID}" class="post has-profile <!-- IF postrow.S_ROW_COUNT is odd -->bg1<!-- ELSE -->bg2<!-- ENDIF --><!-- IF postrow.S_UNREAD_POST --> unreadpost<!-- ENDIF --><!-- IF postrow.S_POST_REPORTED --> reported<!-- ENDIF --><!-- IF postrow.S_POST_DELETED --> deleted<!-- ENDIF --><!-- IF postrow.S_ONLINE and not postrow.S_POST_HIDDEN --> online<!-- ENDIF --><!-- IF postrow.POSTER_WARNINGS --> warned<!-- ENDIF -->"> <div class="inner"> <dl class="postprofile" id="profile{postrow.POST_ID}"<!-- IF postrow.S_POST_HIDDEN --> style="display: none;"<!-- ENDIF -->> @@ -137,7 +137,7 @@ <!-- IF postrow.RANK_TITLE or postrow.RANK_IMG --><dd class="profile-rank">{postrow.RANK_TITLE}<!-- IF postrow.RANK_TITLE and postrow.RANK_IMG --><br /><!-- ENDIF -->{postrow.RANK_IMG}</dd><!-- ENDIF --> - <!-- IF postrow.POSTER_POSTS != '' --><dd class="profile-posts"><strong>{L_POSTS}{L_COLON}</strong> {postrow.POSTER_POSTS}</dd><!-- ENDIF --> + <!-- IF postrow.POSTER_POSTS != '' --><dd class="profile-posts"><strong>{L_POSTS}{L_COLON}</strong> <!-- IF postrow.U_SEARCH !== '' --><a href="{postrow.U_SEARCH}"><!-- ENDIF -->{postrow.POSTER_POSTS}<!-- IF postrow.U_SEARCH !== '' --></a><!-- ENDIF --></dd><!-- ENDIF --> <!-- IF postrow.POSTER_JOINED --><dd class="profile-joined"><strong>{L_JOINED}{L_COLON}</strong> {postrow.POSTER_JOINED}</dd><!-- ENDIF --> <!-- IF postrow.POSTER_WARNINGS --><dd class="profile-warnings"><strong>{L_WARNINGS}{L_COLON}</strong> {postrow.POSTER_WARNINGS}</dd><!-- ENDIF --> @@ -169,7 +169,7 @@ <!-- IF REMAINDER eq 0 --> <div> <!-- ENDIF --> - <a href="<!-- IF postrow.contact.U_CONTACT -->{postrow.contact.U_CONTACT}<!-- ELSE -->{postrow.contact.U_PROFILE_AUTHOR}<!-- ENDIF -->" title="{postrow.contact.NAME}"<!-- IF $S_LAST_CELL --> class="last-cell"<!-- ENDIF --><!-- IF postrow.contact.ID eq 'jabber' --> onclick="popup(this.href, 550, 320); return false;"<!-- ENDIF -->> + <a href="<!-- IF postrow.contact.U_CONTACT -->{postrow.contact.U_CONTACT}<!-- ELSE -->{postrow.contact.U_PROFILE_AUTHOR}<!-- ENDIF -->" title="{postrow.contact.NAME}"<!-- IF $S_LAST_CELL --> class="last-cell"<!-- ENDIF --><!-- IF postrow.contact.ID eq 'jabber' --> onclick="popup(this.href, 750, 320); return false;"<!-- ENDIF -->> <span class="contact-icon {postrow.contact.ID}-icon">{postrow.contact.NAME}</span> </a> <!-- IF REMAINDER eq 3 or postrow.contact.S_LAST_ROW --> @@ -302,6 +302,8 @@ <!-- IF postrow.BUMPED_MESSAGE --><div class="notice"><br /><br />{postrow.BUMPED_MESSAGE}</div><!-- ENDIF --> <!-- EVENT viewtopic_body_postrow_post_notices_after --> <!-- IF postrow.SIGNATURE --><div id="sig{postrow.POST_ID}" class="signature">{postrow.SIGNATURE}</div><!-- ENDIF --> + + <!-- EVENT viewtopic_body_postrow_post_content_footer --> </div> </div> @@ -361,7 +363,7 @@ <!-- IF .pagination or TOTAL_POSTS --> <div class="pagination"> - {TOTAL_POSTS} + {TOTAL_POSTS} <!-- IF .pagination --> <!-- INCLUDE pagination.html --> <!-- ELSE --> diff --git a/phpBB/styles/prosilver/theme/bidi.css b/phpBB/styles/prosilver/theme/bidi.css index 0d98fe7a66..46fbbadef7 100644 --- a/phpBB/styles/prosilver/theme/bidi.css +++ b/phpBB/styles/prosilver/theme/bidi.css @@ -464,6 +464,11 @@ li.breadcrumbs span:first-child > a { float: right; } +.rtl .has-profile .postbody h3 { + margin-right: 0; + margin-left: 180px; +} + .rtl p.post-notice { padding-left: 5px; padding-right: 26px; @@ -655,6 +660,11 @@ li.breadcrumbs span:first-child > a { float: left; } +.rtl .has-profile .post-buttons { + left: 0; + right: auto; +} + .rtl .post-buttons li { float: right; } @@ -1090,4 +1100,8 @@ li.breadcrumbs span:first-child > a { margin-left: 5px; margin-right: 0; } + + .rtl .has-profile .post-buttons { + left: 20px; + } } diff --git a/phpBB/styles/prosilver/theme/buttons.css b/phpBB/styles/prosilver/theme/buttons.css index b45aae5672..a08b49a81c 100644 --- a/phpBB/styles/prosilver/theme/buttons.css +++ b/phpBB/styles/prosilver/theme/buttons.css @@ -177,6 +177,14 @@ ul.linklist.bulletin > li.small-icon:before { margin-top: 2px; } +.has-profile .post-buttons { + float: none; + position: absolute; + margin: 0; + right: 0; + top: 5px; +} + .post-buttons > li { float: left; margin-right: 3px; diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index a9d9b5b01f..a3a4157704 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -189,10 +189,6 @@ ol ol ul, ol ul ul, ul ol ul, ul ul ul { } } -#simple-wrap { - padding: 6px 0; -} - #page-body { margin: 4px 0; clear: both; @@ -303,6 +299,7 @@ ol ol ul, ol ul ul, ul ol ul, ul ul ul { background-repeat: no-repeat; background-position: 100% 0; border-radius: 7px; + position: relative; } .rowbg { diff --git a/phpBB/styles/prosilver/theme/content.css b/phpBB/styles/prosilver/theme/content.css index d00c544050..9388496c53 100644 --- a/phpBB/styles/prosilver/theme/content.css +++ b/phpBB/styles/prosilver/theme/content.css @@ -233,6 +233,7 @@ dd.option { line-height: 1.48em; width: 76%; float: left; + position: relative; } .postbody .ignore { @@ -249,7 +250,8 @@ dd.option { float: left; font-size: 1.5em; padding: 2px 0 0 0; - margin: 0 0 0.3em 0 !important; + margin-top: 0 !important; + margin-bottom: 0.3em !important; text-transform: none; border: none; font-family: "Trebuchet MS", Verdana, Helvetica, Arial, sans-serif; @@ -261,6 +263,12 @@ dd.option { vertical-align: bottom; } +.has-profile .postbody h3 { + /* If there is a post-profile, we position the post-buttons differently */ + float: none !important; + margin-right: 180px; +} + .postbody .content { font-size: 1.3em; overflow-x: auto; @@ -728,6 +736,10 @@ fieldset.polls dd div { max-width: 100%; } +.postprofile .profile-posts a { + font-weight: normal; +} + dd.profile-warnings { font-weight: bold; } diff --git a/phpBB/styles/prosilver/theme/responsive.css b/phpBB/styles/prosilver/theme/responsive.css index 3ef0044621..fc39e03da7 100644 --- a/phpBB/styles/prosilver/theme/responsive.css +++ b/phpBB/styles/prosilver/theme/responsive.css @@ -398,6 +398,10 @@ fieldset.polls dd.resultbar, fieldset.polls dd.poll_option_percent { /* Post ----------------------------------------*/ +.postbody { + position: inherit; +} + .postprofile, .postbody, .search .postbody { display: block; width: auto; @@ -412,6 +416,7 @@ fieldset.polls dd.resultbar, fieldset.polls dd.poll_option_percent { padding-bottom: 5px; margin: 0; margin-bottom: 5px; + min-height: 40px; overflow: hidden; } @@ -443,12 +448,18 @@ fieldset.polls dd.resultbar, fieldset.polls dd.poll_option_percent { max-height: 32px; } -@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi), (min-resolution: 1.5dppx) -{ - /* Scale online image for HD displays */ - .online { - background-size: 40px; - } +.has-profile .postbody h3 { + margin-left: 0 !important; + margin-right: 0 !important; +} + +.has-profile .post-buttons { + right: 20px; + top: 15px; +} + +.online { + background-size: 40px; } /* Misc stuff diff --git a/phpBB/styles/prosilver/theme/tweaks.css b/phpBB/styles/prosilver/theme/tweaks.css index 851b3a6bb6..d52ac6dee8 100644 --- a/phpBB/styles/prosilver/theme/tweaks.css +++ b/phpBB/styles/prosilver/theme/tweaks.css @@ -1,78 +1,27 @@ /* Style Sheet Tweaks -These style definitions are IE 7 and 8 specific -tweaks required due to its poor CSS support. --------------------------------------------------*/ +These style definitions are IE 8 & 9 only. +They are required due to the poor CSS support in IE browsers. +------------------------------------------------------------------------------*/ -/* Clear float fix for IE7 */ -.inner { - zoom: 1; -} +/* IE 8 Tweaks (value)\9 equates to IE <= 8 +------------------------------------------------------------------------------*/ -ul.linklist { - zoom: 1; -} +/* Clear float fix */ +.inner, ul.linklist { zoom: 1\9; } /* Align checkboxes/radio buttons nicely */ -dd label input { - vertical-align: text-bottom; - *vertical-align: middle; -} +dd label input { vertical-align: text-bottom\9; } -/* Simple fix so forum and topic lists always have a height set */ -dl.icon { - *height: 35px; -} +/* Fixes header-avatar aspect-ratio */ +.header-avatar img { height: 20px\9; } -/* Correctly clear floating for details on profile view */ -dl.details dd { - *margin-left: 30%; - *float: none; -} - -/* Headerbar height fix for IE7 */ -#site-description p { - *margin-bottom: 1.0em; -} - -/* Forum list column styles for IE7 */ -dl.icon dt, dl.icon dd { - *min-height: 32px; -} - -dd.posts, dd.topics, dd.views, dd.extra, dd.mark { - *width: 79px; -} - -dd.lastpost, dd.redirect, dd.moderation, dd.time, dd.info { - *width: 249px; -} - -dd.option { - *width: 124px; -} +/* IE8 often can't handle max-width in %, so we use px instead */ +.postprofile .avatar img { max-width: 150px\9; } -/* Notifications list for IE7 */ -.dropdown-extended { - *left: 0; -} -.dropdown-extended .header_settings { - *position: absolute; - *right: 10px; - *top: 0; -} -.icon-notification { - *z-index: 2; -} +/* IE 9 Tweaks +------------------------------------------------------------------------------*/ -/* Fixes header-avatar aspect-ratio in IE8 */ -.header-avatar img { - height: 20px; -} -/* IE8 often can't handle max-width in %, so we use px instead */ -.postprofile .avatar img { - max-width: 150px; -} diff --git a/phpBB/styles/subsilver2/template/mcp_warn_post.html b/phpBB/styles/subsilver2/template/mcp_warn_post.html index 223457d158..68715eff2d 100644 --- a/phpBB/styles/subsilver2/template/mcp_warn_post.html +++ b/phpBB/styles/subsilver2/template/mcp_warn_post.html @@ -35,6 +35,8 @@ <form method="post" name="mcp" action="{U_POST_ACTION}"> +<!-- EVENT mcp_warn_post_add_warning_field_before --> + <table width="100%" cellpadding="3" cellspacing="1" border="0" class="tablebg"> <tr> <th align="center">{L_ADD_WARNING}</th> @@ -54,6 +56,9 @@ <td class="cat" align="center"><input class="btnmain" type="submit" name="action[add_warning]" value="{L_SUBMIT}" /> <input class="btnlite" type="reset" value="{L_RESET}" /></td> </tr> </table> + +<!-- EVENT mcp_warn_post_add_warning_field_after --> + {S_FORM_TOKEN} </form> diff --git a/phpBB/styles/subsilver2/template/mcp_warn_user.html b/phpBB/styles/subsilver2/template/mcp_warn_user.html index 6b78c71557..20b57c6837 100644 --- a/phpBB/styles/subsilver2/template/mcp_warn_user.html +++ b/phpBB/styles/subsilver2/template/mcp_warn_user.html @@ -48,6 +48,8 @@ <form method="post" name="mcp" action="{U_POST_ACTION}"> +<!-- EVENT mcp_warn_user_add_warning_field_before --> + <table width="100%" cellpadding="3" cellspacing="1" border="0" class="tablebg"> <tr> <th align="center">{L_ADD_WARNING}</th> @@ -67,6 +69,9 @@ <td class="cat" align="center"><input class="btnmain" type="submit" name="action[add_warning]" value="{L_SUBMIT}" /> <input class="btnlite" type="reset" value="{L_RESET}" /></td> </tr> </table> + +<!-- EVENT mcp_warn_user_add_warning_field_after --> + {S_FORM_TOKEN} </form> diff --git a/phpBB/styles/subsilver2/template/overall_header.html b/phpBB/styles/subsilver2/template/overall_header.html index ebb7b3be4d..4741154889 100644 --- a/phpBB/styles/subsilver2/template/overall_header.html +++ b/phpBB/styles/subsilver2/template/overall_header.html @@ -2,8 +2,6 @@ <html dir="{S_CONTENT_DIRECTION}" lang="{S_USER_LANG}"> <head> <meta charset="utf-8"> -<meta name="keywords" content="" /> -<meta name="description" content="" /> {META} <title><!-- IF UNREAD_NOTIFICATIONS_COUNT -->({UNREAD_NOTIFICATIONS_COUNT}) <!-- ENDIF --><!-- IF not S_VIEWTOPIC and not S_VIEWFORUM -->{SITENAME} - <!-- ENDIF --><!-- IF S_IN_MCP -->{L_MCP} - <!-- ELSEIF S_IN_UCP -->{L_UCP} - <!-- ENDIF -->{PAGE_TITLE}<!-- IF S_VIEWTOPIC or S_VIEWFORUM --> - {SITENAME}<!-- ENDIF --></title> diff --git a/phpBB/styles/subsilver2/template/simple_header.html b/phpBB/styles/subsilver2/template/simple_header.html index 0c3dff4a05..d292c4594a 100644 --- a/phpBB/styles/subsilver2/template/simple_header.html +++ b/phpBB/styles/subsilver2/template/simple_header.html @@ -2,8 +2,6 @@ <html dir="{S_CONTENT_DIRECTION}" lang="{S_USER_LANG}"> <head> <meta charset="utf-8"> -<meta name="keywords" content="" /> -<meta name="description" content="" /> {META} <title>{SITENAME} • <!-- IF S_IN_MCP -->{L_MCP} • <!-- ELSEIF S_IN_UCP -->{L_UCP} • <!-- ENDIF -->{PAGE_TITLE}</title> diff --git a/phpBB/styles/subsilver2/template/ucp_attachments.html b/phpBB/styles/subsilver2/template/ucp_attachments.html index 0f6101aac7..c513f933c0 100644 --- a/phpBB/styles/subsilver2/template/ucp_attachments.html +++ b/phpBB/styles/subsilver2/template/ucp_attachments.html @@ -17,7 +17,7 @@ <table width="100%" cellspacing="1"> <tr> <td class="nav" valign="middle" nowrap="nowrap"> {PAGE_NUMBER}<br /></td> - <td class="gensmall" nowrap="nowrap"> [ {TOTAL_ATTACHMENTS} ] </td> + <td class="gensmall" nowrap="nowrap"> [ {NUM_ATTACHMENTS} ] </td> <td class="gensmall" width="100%" align="{S_CONTENT_FLOW_END}" nowrap="nowrap"><!-- INCLUDE pagination.html --></td> </tr> </table> diff --git a/phpBB/styles/subsilver2/template/ucp_header.html b/phpBB/styles/subsilver2/template/ucp_header.html index e3aaef6943..dff2841b54 100644 --- a/phpBB/styles/subsilver2/template/ucp_header.html +++ b/phpBB/styles/subsilver2/template/ucp_header.html @@ -25,11 +25,13 @@ <tr> <td class="row1"><b class="genmed">{L_USERNAMES}{L_COLON}</b></td> </tr> + <!-- EVENT posting_pm_header_find_username_before --> <tr> <td class="row2"><textarea name="username_list" rows="5" cols="22" tabindex="1"></textarea><br /> [ <a href="{U_FIND_USERNAME}" onclick="find_username(this.href); return false;">{L_FIND_USERNAME}</a> ] </td> </tr> + <!-- EVENT posting_pm_header_find_username_after --> <!-- ENDIF --> <!-- IF S_GROUP_OPTIONS --> <tr> diff --git a/phpBB/styles/subsilver2/template/viewtopic_body.html b/phpBB/styles/subsilver2/template/viewtopic_body.html index 0f34b50950..838f6c5f03 100644 --- a/phpBB/styles/subsilver2/template/viewtopic_body.html +++ b/phpBB/styles/subsilver2/template/viewtopic_body.html @@ -308,6 +308,8 @@ <!-- ENDIF --> <!-- EVENT viewtopic_body_postrow_post_notices_after --> + <!-- EVENT viewtopic_body_postrow_post_content_footer --> + <!-- IF not postrow.S_HAS_ATTACHMENTS --><br clear="all" /><br /><!-- ENDIF --> <table width="100%" cellspacing="0"> diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 9086feb390..d186d468df 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -251,7 +251,7 @@ $s_watching_forum = array( 'is_watching' => false, ); -if (($config['email_enable'] || $config['jab_enable']) && $config['allow_forum_notify'] && $forum_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_subscribe', $forum_id) || $user->data['user_id'] == ANONYMOUS)) +if ($config['allow_forum_notify'] && $forum_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_subscribe', $forum_id) || $user->data['user_id'] == ANONYMOUS)) { $notify_status = (isset($forum_data['notify_status'])) ? $forum_data['notify_status'] : NULL; watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0, $notify_status, $start, $forum_data['forum_name']); @@ -264,7 +264,7 @@ gen_forum_auth_level('forum', $forum_id, $forum_data['forum_status']); $limit_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']); -$sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'r' => (($auth->acl_get('m_approve', $forum_id)) ? 't.topic_posts_approved + t.topic_posts_unapproved + t.topic_posts_softdeleted' : 't.topic_posts_approved'), 's' => 't.topic_title', 'v' => 't.topic_views'); +$sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => array('t.topic_last_post_time', 't.topic_last_post_id'), 'r' => (($auth->acl_get('m_approve', $forum_id)) ? 't.topic_posts_approved + t.topic_posts_unapproved + t.topic_posts_softdeleted' : 't.topic_posts_approved'), 's' => 't.topic_title', 'v' => 't.topic_views'); $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, $default_sort_days, $default_sort_key, $default_sort_dir); @@ -392,10 +392,15 @@ $sql_array = array( * Event to modify the SQL query before the topic data is retrieved * * @event core.viewforum_get_topic_data -* @var array sql_array The SQL array to get the data of all topics +* @var array forum_data Array with forum data +* @var array sql_array The SQL array to get the data of all topics * @since 3.1.0-a1 +* @change 3.1.0-RC4 Added forum_data var */ -$vars = array('sql_array'); +$vars = array( + 'forum_data', + 'sql_array', +); extract($phpbb_dispatcher->trigger_event('core.viewforum_get_topic_data', compact($vars))); $sql_approved = ' AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.'); @@ -497,7 +502,7 @@ if ($start > $topics_count / 2) $store_reverse = true; // Select the sort order - $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC'); + $direction = (($sort_dir == 'd') ? 'ASC' : 'DESC'); $sql_limit = $pagination->reverse_limit($start, $sql_limit, $topics_count); $sql_start = $pagination->reverse_start($start, $sql_limit, $topics_count); @@ -505,10 +510,19 @@ if ($start > $topics_count / 2) else { // Select the sort order - $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); + $direction = (($sort_dir == 'd') ? 'DESC' : 'ASC'); $sql_start = $start; } +if (is_array($sort_by_sql[$sort_key])) +{ + $sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction; +} +else +{ + $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction; +} + if ($forum_data['forum_type'] == FORUM_POST || !sizeof($active_forum_ary)) { $sql_where = 't.forum_id = ' . $forum_id; diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php index a03a81a15e..9589fb54e2 100644 --- a/phpBB/viewonline.php +++ b/phpBB/viewonline.php @@ -372,7 +372,7 @@ while ($row = $db->sql_fetchrow($result)) $vars = array('on_page', 'row', 'location', 'location_url', 'forum_data'); extract($phpbb_dispatcher->trigger_event('core.viewonline_overwrite_location', compact($vars))); - $template->assign_block_vars('user_row', array( + $template_row = array( 'USERNAME' => $row['username'], 'USERNAME_COLOUR' => $row['user_colour'], 'USERNAME_FULL' => $username_full, @@ -389,7 +389,22 @@ while ($row = $db->sql_fetchrow($result)) 'S_USER_HIDDEN' => $s_user_hidden, 'S_GUEST' => ($row['user_id'] == ANONYMOUS) ? true : false, 'S_USER_TYPE' => $row['user_type'], - )); + ); + + /** + * Modify viewonline template data before it is displayed in the list + * + * @event core.viewonline_modify_user_row + * @var array on_page File name and query string + * @var array row Array with the users sql row + * @var array forum_data Array with forum data + * @var array template_row Array with template variables for the user row + * @since 3.1.0-RC4 + */ + $vars = array('on_page', 'row', 'forum_data', 'template_row'); + extract($phpbb_dispatcher->trigger_event('core.viewonline_modify_user_row', compact($vars))); + + $template->assign_block_vars('user_row', $template_row); } $db->sql_freeresult($result); unset($prev_id, $prev_ip); diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index c2faffca85..f8b4a54f05 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -94,7 +94,7 @@ if ($view && !$post_id) AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id) . " AND post_time > $topic_last_read AND forum_id = $forum_id - ORDER BY post_time ASC"; + ORDER BY post_time ASC, post_id ASC"; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -146,7 +146,7 @@ if ($view && !$post_id) AND topic_moved_id = 0 AND topic_last_post_time $sql_condition {$row['topic_last_post_time']} AND " . $phpbb_content_visibility->get_visibility_sql('topic', $row['forum_id']) . " - ORDER BY topic_last_post_time $sql_ordering"; + ORDER BY topic_last_post_time $sql_ordering, topic_last_post_id $sql_ordering"; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -388,7 +388,7 @@ if (!isset($topic_tracking_info)) $limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']); -$sort_by_sql = array('a' => array('u.username_clean', 'p.post_id'), 't' => 'p.post_time', 's' => array('p.post_subject', 'p.post_id')); +$sort_by_sql = array('a' => array('u.username_clean', 'p.post_id'), 't' => array('p.post_time', 'p.post_id'), 's' => array('p.post_subject', 'p.post_id')); $join_user_sql = array('a' => true, 't' => false, 's' => false); $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; @@ -449,7 +449,7 @@ $s_watching_topic = array( 'is_watching' => false, ); -if (($config['email_enable'] || $config['jab_enable']) && $config['allow_topic_notify']) +if ($config['allow_topic_notify']) { $notify_status = (isset($topic_data['notify_status'])) ? $topic_data['notify_status'] : null; watch_topic_forum('topic', $s_watching_topic, $user->data['user_id'], $forum_id, $topic_id, $notify_status, $start, $topic_data['topic_title']); @@ -2117,9 +2117,11 @@ $page_title = $topic_data['topic_title'] . ($start ? ' - ' . sprintf($user->lang * @var array topic_data Array with topic data * @var int forum_id Forum ID of the topic * @var int start Start offset used to calculate the page +* @var array post_list Array with post_ids we are going to display * @since 3.1.0-a1 +* @change 3.1.0-RC4 Added post_list var */ -$vars = array('page_title', 'topic_data', 'forum_id', 'start'); +$vars = array('page_title', 'topic_data', 'forum_id', 'start', 'post_list'); extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_page_title', compact($vars))); // Output the page diff --git a/tests/console/config/config_test.php b/tests/console/config/config_test.php new file mode 100644 index 0000000000..7c098af004 --- /dev/null +++ b/tests/console/config/config_test.php @@ -0,0 +1,251 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Tester\CommandTester; + +class phpbb_console_command_config_test extends phpbb_test_case +{ + protected $config; + protected $command_name; + protected $user; + + public function setUp() + { + $this->config = new \phpbb\config\config(array()); + + $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + $this->user->method('lang')->will($this->returnArgument(0)); + } + + public function test_set_dynamic() + { + $this->assertEmpty($this->config); + + $command_tester = $this->get_command_tester('set'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + 'value' => 'test_value', + '--dynamic' => true, + )); + + $this->assertSame($this->config['test_key'], 'test_value'); + } + + public function test_set_no_dynamic() + { + $this->assertEmpty($this->config); + + $command_tester = $this->get_command_tester('set'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + 'value' => 'test_value', + '--dynamic' => false, + )); + + $this->assertSame($this->config['test_key'], 'test_value'); + } + + public function test_set_atomic_dynamic() + { + $this->assertEmpty($this->config); + + $this->config->set('test_key', 'old_value', true); + $this->assertSame($this->config['test_key'], 'old_value'); + + $command_tester = $this->get_command_tester('set_atomic'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + 'old' => 'old_value', + 'new' => 'new_value', + '--dynamic' => true, + )); + + $this->assertSame($this->config['test_key'], 'new_value'); + } + + public function test_set_atomic_no_dynamic() + { + $this->assertEmpty($this->config); + + $this->config->set('test_key', 'old_value', false); + $this->assertSame($this->config['test_key'], 'old_value'); + + $command_tester = $this->get_command_tester('set_atomic'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + 'old' => 'old_value', + 'new' => 'new_value', + '--dynamic' => false, + )); + + $this->assertSame($this->config['test_key'], 'new_value'); + } + + public function test_set_atomic_error_dynamic() + { + $this->assertEmpty($this->config); + + $this->config->set('test_key', 'wrong_value', true); + $this->assertSame($this->config['test_key'], 'wrong_value'); + + $command_tester = $this->get_command_tester('set_atomic'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + 'old' => 'old_value', + 'new' => 'new_value', + '--dynamic' => true, + )); + + $this->assertSame($this->config['test_key'], 'wrong_value'); + } + + public function test_get_no_new_line() + { + $this->config->set('test_key', 'test_value', false); + $this->assertSame($this->config['test_key'], 'test_value'); + + $command_tester = $this->get_command_tester('get'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + '--no-newline' => true, + )); + + $this->assertSame($this->config['test_key'], $command_tester->getDisplay()); + } + + public function test_get_new_line() + { + $this->config->set('test_key', 'test_value', false); + $this->assertSame($this->config['test_key'], 'test_value'); + + $command_tester = $this->get_command_tester('get'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + '--no-newline' => false, + )); + + $this->assertSame($this->config['test_key'] . PHP_EOL, $command_tester->getDisplay()); + } + + public function test_get_error() + { + $this->config->set('test_key', 'test_value', false); + $this->assertSame($this->config['test_key'], 'test_value'); + + $command_tester = $this->get_command_tester('get'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'wrong_key', + '--no-newline' => false, + )); + + $this->assertContains('CLI_CONFIG_NOT_EXISTS', $command_tester->getDisplay()); + } + + public function test_increment_dynamic() + { + $this->config->set('test_key', 0, false); + $this->assertSame($this->config['test_key'], 0); + + $command_tester = $this->get_command_tester('increment'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + 'increment' => 2, + '--dynamic' => true, + )); + + $this->assertContains('CLI_CONFIG_INCREMENT_SUCCESS', $command_tester->getDisplay()); + $this->assertSame(2, $this->config['test_key']); + } + + public function test_increment_no_dynamic() + { + $this->config->set('test_key', 0, false); + $this->assertSame($this->config['test_key'], 0); + + $command_tester = $this->get_command_tester('increment'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + 'increment' => 2, + '--dynamic' => false, + )); + + $this->assertContains('CLI_CONFIG_INCREMENT_SUCCESS', $command_tester->getDisplay()); + $this->assertSame(2, $this->config['test_key']); + } + + public function test_increment_no_set() + { + $this->assertEmpty($this->config); + + $command_tester = $this->get_command_tester('increment'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + 'increment' => 2, + '--dynamic' => true, + )); + + $this->assertContains('CLI_CONFIG_INCREMENT_SUCCESS', $command_tester->getDisplay()); + $this->assertSame(2, $this->config['test_key']); + } + + public function test_delete_ok() + { + $this->config->set('test_key', 'test_value', false); + $this->assertSame($this->config['test_key'], 'test_value'); + + $command_tester = $this->get_command_tester('delete'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + )); + + $this->assertContains('CLI_CONFIG_DELETE_SUCCESS', $command_tester->getDisplay()); + $this->assertEmpty($this->config); + } + + public function test_delete_error() + { + $this->assertEmpty($this->config); + + $command_tester = $this->get_command_tester('delete'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'wrong_key', + )); + + $this->assertContains('CLI_CONFIG_NOT_EXISTS', $command_tester->getDisplay()); + $this->assertEmpty($this->config); + } + + public function get_command_tester($class_name) + { + $command_complete_name = '\phpbb\console\command\config' . '\\' . $class_name; + $application = new Application(); + $application->add(new $command_complete_name($this->user, $this->config)); + $command = $application->find('config:' . $this->command_name); + $this->command_name = $command->getName(); + return new CommandTester($command); + } +} diff --git a/tests/extension/ext/vendor4/bar/composer.json b/tests/extension/ext/vendor4/bar/composer.json new file mode 100644 index 0000000000..1a2fddc3f4 --- /dev/null +++ b/tests/extension/ext/vendor4/bar/composer.json @@ -0,0 +1,23 @@ +{ + "name": "vendor4/bar", + "type": "phpbb-extension", + "description": "An example/sample extension to be used for testing purposes in phpBB Development.", + "version": "1.0.0", + "time": "2012-02-15 01:01:01", + "license": "GPL-2.0", + "authors": [{ + "name": "John Smith", + "email": "email@phpbb.com", + "homepage": "http://phpbb.com", + "role": "N/A" + }], + "require": { + "php": ">=5.3" + }, + "extra": { + "display-name": "phpBB Bar Extension", + "soft-require": { + "phpbb/phpbb": "3.1.*@dev" + } + } +} diff --git a/tests/extension/ext/vendor4/bar/styles/all/template/foobar_body.html b/tests/extension/ext/vendor4/bar/styles/all/template/foobar_body.html new file mode 100644 index 0000000000..c8f8cf957e --- /dev/null +++ b/tests/extension/ext/vendor4/bar/styles/all/template/foobar_body.html @@ -0,0 +1 @@ +All folder diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php index 5ec8e60a68..5c7cad89f6 100644 --- a/tests/extension/manager_test.php +++ b/tests/extension/manager_test.php @@ -36,7 +36,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case public function test_all_available() { // barfoo and vendor3/bar should not listed due to missing composer.json. barfoo also has incorrect dir structure. - $this->assertEquals(array('vendor/moo', 'vendor2/bar', 'vendor2/foo', 'vendor3/foo'), array_keys($this->extension_manager->all_available())); + $this->assertEquals(array('vendor/moo', 'vendor2/bar', 'vendor2/foo', 'vendor3/foo', 'vendor4/bar'), array_keys($this->extension_manager->all_available())); } public function test_all_enabled() diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index 6490c1ead3..7be8957ec7 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -84,7 +84,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid); $this->assertCount(1, $crawler->filter('.ext_enabled')); - $this->assertCount(5, $crawler->filter('.ext_disabled')); + $this->assertCount(6, $crawler->filter('.ext_disabled')); $this->assertContains('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text()); $this->assertContainsLang('EXTENSION_DISABLE', $crawler->filter('.ext_enabled')->eq(0)->text()); diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 532a160a47..18eb9ad4c6 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -26,6 +26,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c 'foo/bar/event/', 'foo/bar/language/en/', 'foo/bar/styles/prosilver/template/', + 'foo/foo/config/', + 'foo/foo/controller/', ); static public function setUpBeforeClass() @@ -65,6 +67,18 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c } /** + * Check a controller for extension foo/bar. + */ + public function test_routing_resources() + { + $this->phpbb_extension_manager->enable('foo/foo'); + $crawler = self::request('GET', 'app.php/foo/foo', array(), false); + self::assert_response_status_code(); + $this->assertContains("foo/foo controller handle() method", $crawler->filter('body')->text()); + $this->phpbb_extension_manager->purge('foo/foo'); + } + + /** * Check the output of a controller using the template system */ public function test_controller_with_template() diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php index e87953367f..b8c48389e0 100644 --- a/tests/functional/fileupload_form_test.php +++ b/tests/functional/fileupload_form_test.php @@ -107,9 +107,9 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case $crawler = $this->upload_file('disallowed.jpg', 'image/jpeg'); - // Hitting the ATTACHED_IMAGE_NOT_IMAGE error means we passed the + // Hitting the UNABLE_GET_IMAGE_SIZE error means we passed the // DISALLOWED_CONTENT check - $this->assertContains($this->lang('ATTACHED_IMAGE_NOT_IMAGE'), $crawler->text()); + $this->assertContainsLang('UNABLE_GET_IMAGE_SIZE', $crawler->text()); } public function test_too_large() diff --git a/tests/functional/fixtures/ext/foo/foo/composer.json b/tests/functional/fixtures/ext/foo/foo/composer.json new file mode 100644 index 0000000000..d85c76a6a2 --- /dev/null +++ b/tests/functional/fixtures/ext/foo/foo/composer.json @@ -0,0 +1,24 @@ +{ + "name": "foo/foo", + "type": "phpbb-extension", + "description": "Testing extensions", + "homepage": "", + "version": "1.0.0", + "time": "2013-03-21 01:01:01", + "license": "GPL-2.0", + "authors": [{ + "name": "Tristan Darricau", + "email": "nicofuma@phpbb.com", + "homepage": "http://www.phpbb.com", + "role": "Developer" + }], + "require": { + "php": ">=5.3" + }, + "extra": { + "display-name": "phpBB 3.1 Extension Testing", + "soft-require": { + "phpbb/phpbb": "3.1.*@dev" + } + } +} diff --git a/tests/functional/fixtures/ext/foo/foo/config/resource.yml b/tests/functional/fixtures/ext/foo/foo/config/resource.yml new file mode 100644 index 0000000000..ed1d018016 --- /dev/null +++ b/tests/functional/fixtures/ext/foo/foo/config/resource.yml @@ -0,0 +1,3 @@ +foo_foo_controller: + pattern: /foo + defaults: { _controller: foo_foo.controller:handle } diff --git a/tests/functional/fixtures/ext/foo/foo/config/routing.yml b/tests/functional/fixtures/ext/foo/foo/config/routing.yml new file mode 100644 index 0000000000..c2c401687d --- /dev/null +++ b/tests/functional/fixtures/ext/foo/foo/config/routing.yml @@ -0,0 +1,3 @@ +foo_foo.general: + resource: "resource.yml" + prefix: /foo diff --git a/tests/functional/fixtures/ext/foo/foo/config/services.yml b/tests/functional/fixtures/ext/foo/foo/config/services.yml new file mode 100644 index 0000000000..b3c7719715 --- /dev/null +++ b/tests/functional/fixtures/ext/foo/foo/config/services.yml @@ -0,0 +1,3 @@ +services: + foo_foo.controller: + class: foo\foo\controller\controller diff --git a/tests/functional/fixtures/ext/foo/foo/controller/controller.php b/tests/functional/fixtures/ext/foo/foo/controller/controller.php new file mode 100644 index 0000000000..771eaeacfc --- /dev/null +++ b/tests/functional/fixtures/ext/foo/foo/controller/controller.php @@ -0,0 +1,13 @@ +<?php + +namespace foo\foo\controller; + +use Symfony\Component\HttpFoundation\Response; + +class controller +{ + public function handle() + { + return new Response('foo/foo controller handle() method', 200); + } +} diff --git a/tests/functional/fixtures/ext/foo/foo/ext.php b/tests/functional/fixtures/ext/foo/foo/ext.php new file mode 100644 index 0000000000..80acda74fe --- /dev/null +++ b/tests/functional/fixtures/ext/foo/foo/ext.php @@ -0,0 +1,8 @@ +<?php + +namespace foo\foo; + +class ext extends \phpbb\extension\base +{ + +} diff --git a/tests/functional/ucp_preferences_test.php b/tests/functional/ucp_preferences_test.php new file mode 100644 index 0000000000..7ef325dc4b --- /dev/null +++ b/tests/functional/ucp_preferences_test.php @@ -0,0 +1,85 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +/** +* @group functional +*/ +class phpbb_functional_ucp_preferences_test extends phpbb_functional_test_case +{ + public function test_submitting_preferences_view() + { + $this->add_lang('ucp'); + $this->login(); + + $crawler = self::request('GET', 'ucp.php?i=ucp_prefs&mode=view'); + $this->assertContainsLang('UCP_PREFS_VIEW', $crawler->filter('#cp-main h2')->text()); + + $form = $crawler->selectButton('Submit')->form(array( + 'topic_sk' => 'a', + 'topic_sd' => 'a', + 'topic_st' => '1', + 'post_sk' => 'a', + 'post_sd' => 'a', + 'post_st' => '1', + )); + + $crawler = self::submit($form); + $this->assertContainsLang('PREFERENCES_UPDATED', $crawler->filter('#message')->text()); + } + + public function test_submitting_invalid_preferences_view() + { + $this->add_lang('ucp'); + $this->login(); + + $crawler = self::request('GET', 'ucp.php?i=ucp_prefs&mode=view'); + $this->assertContainsLang('UCP_PREFS_VIEW', $crawler->filter('#cp-main h2')->text()); + $form = $crawler->selectButton('Submit')->form(); + + if (!method_exists($form, 'disableValidation')) + { + $this->markTestIncomplete('The crawler cannot select invalid values, until Symfony 2.4!'); + } + + $form = $form->disableValidation(); + $form['topic_sk']->select('z'); + $form['topic_sd']->select('z'); + $form['topic_st']->select('test'); + $form['post_sk']->select('z'); + $form['post_sd']->select('z'); + $form['post_st']->select('test'); + + $crawler = self::submit($form); + $this->assertContainsLang('WRONG_DATA_POST_SD', $crawler->filter('#cp-main')->text()); + $this->assertContainsLang('WRONG_DATA_POST_SK', $crawler->filter('#cp-main')->text()); + $this->assertContainsLang('WRONG_DATA_TOPIC_SD', $crawler->filter('#cp-main')->text()); + $this->assertContainsLang('WRONG_DATA_TOPIC_SK', $crawler->filter('#cp-main')->text()); + } + + public function test_read_preferences_view() + { + $this->add_lang('ucp'); + $this->login(); + + $crawler = self::request('GET', 'ucp.php?i=ucp_prefs&mode=view'); + $this->assertContainsLang('UCP_PREFS_VIEW', $crawler->filter('#cp-main h2')->text()); + $form = $crawler->selectButton('Submit')->form(); + + $this->assertEquals('a', $form->get('topic_sk')->getValue()); + $this->assertEquals('a', $form->get('topic_sd')->getValue()); + $this->assertEquals('1', $form->get('topic_st')->getValue()); + $this->assertEquals('a', $form->get('post_sk')->getValue()); + $this->assertEquals('a', $form->get('post_sd')->getValue()); + $this->assertEquals('1', $form->get('post_st')->getValue()); + } +} diff --git a/tests/mimetype/guesser_test.php b/tests/mimetype/guesser_test.php index b74a9f236e..fa53e6c8c4 100644 --- a/tests/mimetype/guesser_test.php +++ b/tests/mimetype/guesser_test.php @@ -206,4 +206,25 @@ class guesser_test extends \phpbb_test_case $this->assertInstanceOf('\phpbb\mimetype\content_guesser', $guessers[0]); $this->assertInstanceOf('\phpbb\mimetype\extension_guesser', $guessers[3]); } + + public function data_choose_mime_type() + { + return array( + array('application/octet-stream', 'application/octet-stream', null), + array('application/octet-stream', 'application/octet-stream', 'application/octet-stream'), + array('binary', 'application/octet-stream', 'binary'), + array('image/jpeg', 'application/octet-stream', 'image/jpeg'), + array('image/jpeg', 'binary', 'image/jpeg'), + array('image/jpeg', 'image/jpg', 'image/jpeg'), + array('image/jpeg', 'image/jpeg', 'binary'), + ); + } + + /** + * @dataProvider data_choose_mime_type + */ + public function test_choose_mime_type($expected, $mime_type, $guess) + { + $this->assertSame($expected, $this->guesser->choose_mime_type($mime_type, $guess)); + } } diff --git a/tests/path_helper/path_helper_test.php b/tests/path_helper/path_helper_test.php index 27e94d6a07..3832307897 100644 --- a/tests/path_helper/path_helper_test.php +++ b/tests/path_helper/path_helper_test.php @@ -205,6 +205,18 @@ class phpbb_path_helper_test extends phpbb_test_case array('test' => 'xyz', 'var' => 'value'), 'test=xyz&var=value', ), + array( + array('test' => null), + 'test', + ), + array( + array('test' => null, 'var' => null), + 'test&var', + ), + array( + array('test' => 'xyz', 'var' => null, 'bar' => 'value'), + 'test=xyz&var&bar=value', + ), ); } @@ -254,6 +266,21 @@ class phpbb_path_helper_test extends phpbb_test_case true, array('base' => 'mcp.php', 'params' => array('f' => '3')), ), + array( + 'index.php?ready', + false, + array('base' => 'index.php', 'params' => array('ready' => null)), + ), + array( + 'index.php?i=1&ready', + true, + array('base' => 'index.php', 'params' => array('i' => '1', 'ready' => null)), + ), + array( + 'index.php?ready&i=1', + false, + array('base' => 'index.php', 'params' => array('ready' => null, 'i' => '1')), + ), ); } diff --git a/tests/template/template_allfolder_test.php b/tests/template/template_allfolder_test.php new file mode 100644 index 0000000000..b4ad84e9c3 --- /dev/null +++ b/tests/template/template_allfolder_test.php @@ -0,0 +1,59 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +require_once dirname(__FILE__) . '/template_test_case.php'; + +class phpbb_template_allfolder_test extends phpbb_template_template_test_case +{ + public function test_allfolder() + { + $this->setup_engine_for_allfolder(); + + $this->run_template('foobar_body.html', array(), array(), array(), "All folder"); + } + + protected function setup_engine_for_allfolder(array $new_config = array()) + { + global $phpbb_root_path, $phpEx; + + $defaults = $this->config_defaults(); + $config = new \phpbb\config\config(array_merge($defaults, $new_config)); + $this->user = new \phpbb\user('\phpbb\datetime'); + + $path_helper = new \phpbb\path_helper( + new \phpbb\symfony_request( + new phpbb_mock_request() + ), + new \phpbb\filesystem(), + $this->getMock('\phpbb\request\request'), + $phpbb_root_path, + $phpEx + ); + + $this->extension_manager = new phpbb_mock_extension_manager( + dirname(__FILE__) . '/', + array( + 'vendor4/bar' => array( + 'ext_name' => 'vendor4/bar', + 'ext_active' => '1', + 'ext_path' => 'ext/vendor4/bar/', + ), + ) + ); + + $this->template_path = $this->test_path . '/templates'; + $this->ext_template_path = 'tests/extension/ext/vendor4/bar/styles/all/template'; + $this->template = new \phpbb\template\twig\twig($path_helper, $config, $this->user, new \phpbb\template\context(), $this->extension_manager); + $this->template->set_custom_style('all', array($this->template_path, $this->ext_template_path)); + } +} |