diff options
author | Thomas ZILLIOX <thomas@zilliox.me> | 2013-07-02 20:08:38 +0400 |
---|---|---|
committer | Thomas ZILLIOX <thomas@zilliox.me> | 2013-07-02 20:08:38 +0400 |
commit | 287dcbbe9eecd9d6e4c5cd89a5a2fa7fe14bb09a (patch) | |
tree | 3ca1c8b4a1fd14cca3c5f492cf6ea8391f1a1060 /plugins/SitesManager | |
parent | 3b367dd3afffa6d44fdf0069f62b00c2bb487a5a (diff) |
Merge with master
Diffstat (limited to 'plugins/SitesManager')
-rw-r--r-- | plugins/SitesManager/API.php | 3 | ||||
-rw-r--r-- | plugins/SitesManager/Controller.php | 6 | ||||
-rw-r--r-- | plugins/SitesManager/javascripts/SitesManager.js | 33 | ||||
-rw-r--r-- | plugins/SitesManager/templates/displayAlternativeTagsHelp.twig | 2 | ||||
-rw-r--r-- | plugins/SitesManager/templates/displayJavascriptCode.twig | 2 | ||||
-rw-r--r-- | plugins/SitesManager/templates/index.twig | 45 |
6 files changed, 56 insertions, 35 deletions
diff --git a/plugins/SitesManager/API.php b/plugins/SitesManager/API.php index 27d0f5e212..77fc07d507 100644 --- a/plugins/SitesManager/API.php +++ b/plugins/SitesManager/API.php @@ -1068,8 +1068,6 @@ class Piwik_SitesManager_API * Returns the list of timezones supported. * Used for addSite and updateSite * - * @TODO NOT COMPATIBLE WITH API RESPONSE AUTO BUILDER - * * @return array of timezone strings */ public function getTimezonesList() @@ -1289,6 +1287,7 @@ class Piwik_SitesManager_API if (strpos($url, 'http') !== 0) { $url = 'http://' . $url; } + $url = trim($url); $url = Piwik_Common::sanitizeInputValue($url); } $urls = array_unique($urls); diff --git a/plugins/SitesManager/Controller.php b/plugins/SitesManager/Controller.php index 235037a1b1..74eda62af7 100644 --- a/plugins/SitesManager/Controller.php +++ b/plugins/SitesManager/Controller.php @@ -33,9 +33,9 @@ class Piwik_SitesManager_Controller extends Piwik_Controller_Admin foreach ($sites as &$site) { $site['alias_urls'] = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($site['idsite']); - $site['excluded_ips'] = str_replace(',', '<br/>', $site['excluded_ips']); - $site['excluded_parameters'] = str_replace(',', '<br/>', $site['excluded_parameters']); - $site['excluded_user_agents'] = str_replace(',', '<br/>', $site['excluded_user_agents']); + $site['excluded_ips'] = explode(',', $site['excluded_ips']); + $site['excluded_parameters'] = explode(',', $site['excluded_parameters']); + $site['excluded_user_agents'] = explode(',', $site['excluded_user_agents']); } $view->adminSites = $sites; $view->adminSitesCount = count($sites); diff --git a/plugins/SitesManager/javascripts/SitesManager.js b/plugins/SitesManager/javascripts/SitesManager.js index a74ce3010e..73000c3969 100644 --- a/plugins/SitesManager/javascripts/SitesManager.js +++ b/plugins/SitesManager/javascripts/SitesManager.js @@ -5,7 +5,7 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ -// NOTE: if you cannot find the definition of a variable here, look in SitesManager.tpl +// NOTE: if you cannot find the definition of a variable here, look in index.twig function SitesManager(_timezones, _currencies, _defaultTimezone, _defaultCurrency) { var timezones = _timezones; @@ -78,6 +78,7 @@ function SitesManager(_timezones, _currencies, _defaultTimezone, _defaultCurrenc urls = urls.trim().split("\n"); var excludedIps = $(row).find('textarea#excludedIps').val(); excludedIps = piwikHelper.getApiFormatTextarea(excludedIps); + var excludedQueryParameters = $(row).find('textarea#excludedQueryParameters').val(); excludedQueryParameters = piwikHelper.getApiFormatTextarea(excludedQueryParameters); var excludedUserAgents = $(row).find('textarea#excludedUserAgents').val(); @@ -117,8 +118,8 @@ function SitesManager(_timezones, _currencies, _defaultTimezone, _defaultCurrenc } function sendGlobalSettingsAJAX() { - var timezone = $('#defaultTimezone option:selected').val(); - var currency = $('#defaultCurrency option:selected').val(); + var timezone = $('#defaultTimezone').find('option:selected').val(); + var currency = $('#defaultCurrency').find('option:selected').val(); var excludedIps = $('textarea#globalExcludedIps').val(); excludedIps = piwikHelper.getApiFormatTextarea(excludedIps); var excludedQueryParameters = $('textarea#globalExcludedQueryParameters').val(); @@ -157,6 +158,11 @@ function SitesManager(_timezones, _currencies, _defaultTimezone, _defaultCurrenc $('.addRowSite').click(function () { piwikHelper.hideAjaxError(); $('.addRowSite').toggle(); + + var excludedUserAgentCell = ''; + if ($('#exclude-user-agent-header').is(':visible')) { + excludedUserAgentCell = '<td><textarea cols="20" rows="4" id="excludedUserAgents"></textarea><br />' + excludedUserAgentsHelp + '</td>'; + } var numberOfRows = $('table#editSites')[0].rows.length; var newRowId = 'rowNew' + numberOfRows; @@ -166,9 +172,9 @@ function SitesManager(_timezones, _currencies, _defaultTimezone, _defaultCurrenc <td><input id="name" value="Name" size="15" /><br/><br/><br/>' + submitButtonHtml + '</td>\ <td><textarea cols="25" rows="3" id="urls">http://siteUrl.com/\nhttp://siteUrl2.com/</textarea><br />' + aliasUrlsHelp + keepURLFragmentSelectHTML + '</td>\ <td><textarea cols="20" rows="4" id="excludedIps"></textarea><br />' + excludedIpHelp + '</td>\ - <td><textarea cols="20" rows="4" id="excludedQueryParameters"></textarea><br />' + excludedQueryParametersHelp + '</td>\ - <td><textarea cols="20" rows="4" id="excludedUserAgents"></textarea><br />' + excludedUserAgentsHelp + '</td>\ - <td>' + getSitesearchSelector(false) + '</td>\ + <td><textarea cols="20" rows="4" id="excludedQueryParameters"></textarea><br />' + excludedQueryParametersHelp + '</td>' + + excludedUserAgentCell + + '<td>' + getSitesearchSelector(false) + '</td>\ <td>' + getTimezoneSelector(defaultTimezone) + '<br />' + timezoneHelp + '</td>\ <td>' + getCurrencySelector(defaultCurrency) + '<br />' + currencyHelp + '</td>\ <td>' + getEcommerceSelector(0) + '<br />' + ecommerceHelp + '</td>\ @@ -199,7 +205,7 @@ function SitesManager(_timezones, _currencies, _defaultTimezone, _defaultCurrenc var nameToDelete = $(this).parent().parent().find('input#siteName').val() || $(this).parent().parent().find('td#siteName').html(); var idsiteToDelete = $(this).parent().parent().find('#idSite').html(); - $('#confirm h2').text(sprintf(_pk_translate('SitesManager_DeleteConfirm_js'), '"' + nameToDelete + '" (idSite = ' + idsiteToDelete + ')')); + $('#confirm').find('h2').text(sprintf(_pk_translate('SitesManager_DeleteConfirm_js'), '"' + nameToDelete + '" (idSite = ' + idsiteToDelete + ')')); piwikHelper.modalConfirm('#confirm', {yes: function () { sendDeleteSiteAJAX(idsiteToDelete); }}); @@ -213,7 +219,7 @@ function SitesManager(_timezones, _currencies, _defaultTimezone, _defaultCurrenc var idRow = $(this).attr('id'); if (alreadyEdited[idRow] == 1) return; if (siteBeingEdited) { - $('#alert h2').text(sprintf(_pk_translate('SitesManager_OnlyOneSiteAtTime_js'), '"' + $("<div/>").html(siteBeingEditedName).text() + '"')); + $('#alert').find('h2').text(sprintf(_pk_translate('SitesManager_OnlyOneSiteAtTime_js'), '"' + $("<div/>").html(siteBeingEditedName).text() + '"')); piwikHelper.modalConfirm('#alert', {}); return; } @@ -229,7 +235,7 @@ function SitesManager(_timezones, _currencies, _defaultTimezone, _defaultCurrenc var idName = $(n).attr('id'); if (idName == 'siteName') { siteBeingEditedName = contentBefore; - var contentAfter = '<input id="' + idName + '" value="' + piwikHelper.htmlEntities(contentBefore) + '" size="15" />'; + var contentAfter = '<input id="' + idName + '" value="' + contentBefore + '" size="15" />'; var inputSave = $('<br/><input style="margin-top:50px" type="submit" class="submit" value="' + _pk_translate('General_Save_js') + '" />') .click(function () { submitUpdateSite($(this).parent()); }); @@ -243,8 +249,7 @@ function SitesManager(_timezones, _currencies, _defaultTimezone, _defaultCurrenc } else if (idName == 'urls') { var keepURLFragmentsForSite = $(this).closest('tr').attr('data-keep-url-fragments'); - - var contentAfter = '<textarea cols="25" rows="3" id="urls">' + contentBefore.replace(/<br *\/? *>/gi, "\n") + '</textarea>'; + var contentAfter = '<textarea cols="25" rows="3" id="urls">' + contentBefore.replace(/<br *\/? *> */gi, "\n") + '</textarea>'; contentAfter += '<br />' + aliasUrlsHelp + keepURLFragmentSelectHTML; $(n).html(contentAfter).find('select').val(keepURLFragmentsForSite); } @@ -329,8 +334,10 @@ function SitesManager(_timezones, _currencies, _defaultTimezone, _defaultCurrenc if (searchGlobalHasValues) { var checkedStr = checked ? ' checked ' : ''; - html += '<label><span id="sitesearchUseDefault"' + (!enabled ? ' style="display:none" ' : '') + '><input type="checkbox" ' + checkedStr + ' id="sitesearchUseDefaultCheck" onclick="return onClickSiteSearchUseDefault();"> ' + sitesearchUseDefault + ' </span>'; - html += '</label>'; + html += '<label><span id="sitesearchUseDefault"' + (!enabled ? ' style="display:none" ' : '') + '><input type="checkbox" ' + + checkedStr + ' id="sitesearchUseDefaultCheck" onclick="return onClickSiteSearchUseDefault();"> ' + + sitesearchUseDefault + ' </span>'; + + '</label>'; html += '<div ' + ((checked && enabled) ? '' : 'style="display-none"') + ' class="searchDisplayParams form-description">' + searchKeywordLabel + ' (' + strDefault + ') ' + ': ' diff --git a/plugins/SitesManager/templates/displayAlternativeTagsHelp.twig b/plugins/SitesManager/templates/displayAlternativeTagsHelp.twig index 115b9863e2..a4bb985c54 100644 --- a/plugins/SitesManager/templates/displayAlternativeTagsHelp.twig +++ b/plugins/SitesManager/templates/displayAlternativeTagsHelp.twig @@ -81,7 +81,7 @@ It is also possible to call the Piwik Tracking API using your favorite programmi <code> <?php <br/> // Example 1: Tracks a pageview for Website id = {{ idSite }}<br/> - echo '<img src="'. str_replace("&","&amp;", Piwik_getUrlTrackPageView( $idSite = {$idSite}, $customTitle = 'This title + echo '<img src="'. str_replace("&","&amp;", Piwik_getUrlTrackPageView( $idSite = {{ idSite }}, $customTitle = 'This title will appear in the report Actions > Page titles')) . '" alt="" />';<br/> // Example 2: Triggers a Goal conversion for Website id = {{ idSite }} and Goal id = 2<br/> // $customRevenue is optional and is set to the amount generated by the current transaction (in online shops for example)<br/> diff --git a/plugins/SitesManager/templates/displayJavascriptCode.twig b/plugins/SitesManager/templates/displayJavascriptCode.twig index 1d19de45f1..34ef90e10e 100644 --- a/plugins/SitesManager/templates/displayJavascriptCode.twig +++ b/plugins/SitesManager/templates/displayJavascriptCode.twig @@ -3,5 +3,7 @@ {% block content %} {{ loadJavascriptTranslations(['SitesManager']) }} +{% raw %} {% include "@SitesManager/_displayJavascriptCode.twig" %} +{% endraw %} {% endblock %}
\ No newline at end of file diff --git a/plugins/SitesManager/templates/index.twig b/plugins/SitesManager/templates/index.twig index b34312f5a5..02b9e13432 100644 --- a/plugins/SitesManager/templates/index.twig +++ b/plugins/SitesManager/templates/index.twig @@ -141,7 +141,7 @@ <th>{{ 'General_Name'|translate }}</th> <th>{{ 'SitesManager_Urls'|translate }}</th> <th>{{ 'SitesManager_ExcludedIps'|translate }}</th> - <th>{{ 'SitesManager_ExcludedParameters'|translate|replace({" ":"<br />"}) }}</th> + <th>{{ 'SitesManager_ExcludedParameters'|translate|replace({" ":"<br />"})|raw }}</th> <th id='exclude-user-agent-header' {% if not allowSiteSpecificUserAgentExclude %}style="display:none"{% endif %}>{{ 'SitesManager_ExcludedUserAgents'|translate }}</th> <th>{{ 'Actions_SubmenuSitesearch'|translate }}</th> @@ -157,19 +157,29 @@ {% for i,site in adminSites %} <tr id="row{{ site.idsite }}" data-keep-url-fragments="{{ site.keep_url_fragment }}"> <td id="idSite">{{ site.idsite }}</td> - <td id="siteName" class="editableSite">{{ site.name }}</td> + <td id="siteName" class="editableSite"> + {{- site.name|raw -}} + </td> <td id="urls" class="editableSite"> - {% for url in site.alias_urls %}{{ url|replace({'http://': ''}) }}<br/>{% endfor %} + {%- for url in site.alias_urls -%} + {{- url|trim|replace({'http://': ''})|raw -}}<br /> + {%- endfor -%} </td> <td id="excludedIps" class="editableSite"> - {% for ip in site.excluded_ips %}{{ ip }}<br/>{% endfor %} + {%- for ip in site.excluded_ips -%} + {{- ip -}}<br/> + {%- endfor -%} </td> <td id="excludedQueryParameters" class="editableSite"> - {% for parameter in site.excluded_parameters %}{{ parameter }}<br/>{% endfor %} + {%- for parameter in site.excluded_parameters -%} + {{- parameter|raw -}}<br /> + {%- endfor -%} </td> <td id="excludedUserAgents" class="editableSite" {% if not allowSiteSpecificUserAgentExclude %}style="display:none"{% endif %}> - {% for ua in site.excluded_user_agent %}{{ ua }}<br/>{% endfor %} + {%- for ua in site.excluded_user_agents -%} + {{- ua|raw -}}<br /> + {%- endfor -%} </td> <td id="sitesearch" class="editableSite"> {% if site.sitesearch %} @@ -177,9 +187,9 @@ {% else %} <span class='sitesearchInactive'>-</span> {% endif %} - <span class='sskp' sitesearch_keyword_parameters="{{ site.sitesearch_keyword_parameters }}"" - sitesearch_category_parameters="{{ site.sitesearch_category_parameters }}" - id="sitesearch_parameters"> + <span class='sskp' sitesearch_keyword_parameters="{{- site.sitesearch_keyword_parameters -}}" + sitesearch_category_parameters="{{- site.sitesearch_category_parameters -}}" + id="sitesearch_parameters"> </span> </td> <td id="timezone" class="editableSite">{{ site.timezone }}</td> @@ -220,7 +230,6 @@ </div> {% endif %} - {# Admin users use these values for Site Search column, when editing websites #} {% if not isSuperUser %} <input type="hidden" size="15" id="globalSearchKeywordParameters" @@ -245,7 +254,8 @@ </tr> <tr> <td> - <textarea cols="30" rows="3" id="globalExcludedIps">{{ globalExcludedIps }} + <textarea cols="30" rows="3" id="globalExcludedIps"> + {{- globalExcludedIps -}} </textarea> </td> <td> @@ -263,7 +273,8 @@ <tr> <td> - <textarea cols="30" rows="3" id="globalExcludedQueryParameters">{{ globalExcludedQueryParameters }} + <textarea cols="30" rows="3" id="globalExcludedQueryParameters"> + {{- globalExcludedQueryParameters -}} </textarea> </td> <td> @@ -282,7 +293,9 @@ <tr> <td> - <textarea cols="30" rows="3" id="globalExcludedUserAgents">{{ globalExcludedUserAgents }}</textarea> + <textarea cols="30" rows="3" id="globalExcludedUserAgents"> + {{- globalExcludedUserAgents -}} + </textarea> </td> <td><label for="globalExcludedUserAgents">{{ excludedUserAgentsHelp }}</label> </td> @@ -300,7 +313,7 @@ </span> </td> <td> - {{ piwik.inlineHelp('SitesManager_EnableSiteSpecificUserAgentExclude_Help'|translate('<a href="#editSites">','</a>')) }} + {{ piwik.inlineHelp('SitesManager_EnableSiteSpecificUserAgentExclude_Help'|translate('<a href="#editSites">','</a>'))|raw }} </td> </tr> @@ -334,7 +347,7 @@ <td colspan="2"> <label>{{ searchKeywordLabel }} <input type="text" size="15" id="globalSearchKeywordParameters" - value="{{ globalSearchKeywordParameters }}"/> + value="{{ globalSearchKeywordParameters|raw }}"/> <div style='width: 200px;float:right;'>{{ searchKeywordHelp }}</div> </label> @@ -355,7 +368,7 @@ <td colspan="2"> <label>{{ searchCategoryLabel }} <input type="text" size="15" id="globalSearchCategoryParameters" - value="{{ globalSearchCategoryParameters }}"/> + value="{{ globalSearchCategoryParameters|raw }}"/> <div style='width: 200px;float:right;'>{{ searchCategoryHelp }}</div> </label> |