Skip to content

Commit

Permalink
* Fixing SitesManager page
Browse files Browse the repository at this point in the history
 * Enabling debug on twig so we can use {{ dump(var) }} function
Refs #4019
  • Loading branch information
mattab committed Jun 25, 2013
1 parent 4d57c02 commit 6ac63c2
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 22 deletions.
3 changes: 2 additions & 1 deletion core/Twig.php
Expand Up @@ -40,11 +40,12 @@ public function __construct($theme = self::DEFAULT_THEME)
// Create new Twig Environment and set cache dir
$this->twig = new Twig_Environment($chainLoader,
array(
'debug' => true, // to use {{ dump(var) }} in twig templates
//'cache' => PIWIK_DOCUMENT_ROOT . '/tmp/templates_c',
)
);
$this->twig->addExtension(new Twig_Extension_Debug());
$this->twig->clearTemplateCache();

// Add default filters
$this->addFilters();
// Register namespaces
Expand Down
1 change: 1 addition & 0 deletions plugins/SitesManager/API.php
Expand Up @@ -1289,6 +1289,7 @@ private function cleanParameterUrls($urls)
if (strpos($url, 'http') !== 0) {
$url = 'http://' . $url;
}
$url = trim($url);
$url = Piwik_Common::sanitizeInputValue($url);
}
$urls = array_unique($urls);
Expand Down
6 changes: 3 additions & 3 deletions plugins/SitesManager/Controller.php
Expand Up @@ -33,9 +33,9 @@ public function index()

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);
Expand Down
6 changes: 3 additions & 3 deletions plugins/SitesManager/javascripts/SitesManager.js
Expand Up @@ -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();
Expand Down Expand Up @@ -234,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()); });
Expand All @@ -248,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);
}
Expand Down
39 changes: 24 additions & 15 deletions plugins/SitesManager/templates/index.twig
Expand Up @@ -204,27 +204,36 @@ $(document).ready(function () {
{% 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="urls" class="editableSite">
{% for url in site.alias_urls %}{{ url|replace({'http://': ''}) }}<br />{% endfor %}
<td id="siteName" class="editableSite">
{{- site.name|raw -}}
</td>
<td id="urls" class="editableSite">
{%- 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 %}
</td>
{%- 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 %}
<td id="excludedUserAgents" class="editableSite"
{% if not allowSiteSpecificUserAgentExclude %}style="display:none"{% endif %}>
{%- for ua in site.excluded_user_agents -%}
{{- ua|raw -}}<br />
{%- endfor -%}
</td>
<td id="sitesearch" class="editableSite">
{% if site.sitesearch %}
<span class='sitesearchActive'>{{ 'General_Yes'|translate }}</span>
{% else %}
<span class='sitesearchInactive'>-</span>
{% endif %}
<span class='sskp' sitesearch_keyword_parameters="{{ site.sitesearch_keyword_parameters }}""
sitesearch_category_parameters="{{ site.sitesearch_category_parameters }}"
<span class='sskp' sitesearch_keyword_parameters="{{- site.sitesearch_keyword_parameters -}}""
sitesearch_category_parameters="{{- site.sitesearch_category_parameters -}}"
id="sitesearch_parameters">
</span>
</td>
Expand Down Expand Up @@ -289,7 +298,7 @@ $(document).ready(function () {
</tr>
<tr>
<td>
<textarea cols="30" rows="3" id="globalExcludedIps">{{ globalExcludedIps }}
<textarea cols="30" rows="3" id="globalExcludedIps">{{- globalExcludedIps|raw -}}
</textarea>
</td>
<td>
Expand All @@ -307,7 +316,7 @@ $(document).ready(function () {
<tr>
<td>
<textarea cols="30" rows="3" id="globalExcludedQueryParameters">{{ globalExcludedQueryParameters }}
<textarea cols="30" rows="3" id="globalExcludedQueryParameters">{{- globalExcludedQueryParameters|raw -}}
</textarea>
</td>
<td>
Expand All @@ -326,7 +335,7 @@ $(document).ready(function () {
<tr>
<td>
<textarea cols="30" rows="3" id="globalExcludedUserAgents">{{ globalExcludedUserAgents }}</textarea>
<textarea cols="30" rows="3" id="globalExcludedUserAgents">{{- globalExcludedUserAgents|raw -}}</textarea>
</td>
<td><label for="globalExcludedUserAgents">{{ excludedUserAgentsHelp }}</label>
</td>
Expand Down Expand Up @@ -377,7 +386,7 @@ $(document).ready(function () {
<tr>
<td colspan="2">
<label>{{ searchKeywordLabel }} &nbsp;
<input type="text" size="15" id="globalSearchKeywordParameters" value="{{ globalSearchKeywordParameters }}"/>
<input type="text" size="15" id="globalSearchKeywordParameters" value="{{ globalSearchKeywordParameters|e('html_attr') }}"/>
<div style='width: 200px;float:right;'>{{ searchKeywordHelp }}</div>
</label>
Expand All @@ -396,7 +405,7 @@ $(document).ready(function () {
<tr>
<td colspan="2">
<label>{{ searchCategoryLabel }} &nbsp;
<input type="text" size="15" id="globalSearchCategoryParameters" value="{{ globalSearchCategoryParameters }}"/>
<input type="text" size="15" id="globalSearchCategoryParameters" value="{{ globalSearchCategoryParameters|e('html_attr') }}"/>
<div style='width: 200px;float:right;'>{{ searchCategoryHelp }}</div>
</label>
Expand Down

0 comments on commit 6ac63c2

Please sign in to comment.