diff options
author | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2010-03-29 10:32:46 +0400 |
---|---|---|
committer | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2010-03-29 10:32:46 +0400 |
commit | f8932466b8151fb11b51193f5e6ad75eeceef2ad (patch) | |
tree | d7aa9e2bfadc19b0bcdc1b16a9ec6908ac1f93df /plugins/SitesManager/templates | |
parent | f0e9fee730b4b8c330430d2177fe6f7516fd3299 (diff) |
Refs #56
- Added timezone setting per website. Added API to fetch the list of supported timezones. UTC Manual offsets are supported even if the PHP doesn't have timezone support built in.
- Added default timezone setting that the Super user can set. It will be used to pre-select timezones when creating new websites, or setting the default timezone when adding websites via the API without specifying the timezone.
- Default timezone set to UTC to all existing websites on update. PHP Default timezone set to UTC in index.php and piwik.php.
- Removed all usage of mysql date/time functions (which are internally doing timezone conversions based on mysql timezone), now using php generated timestamps (in UTC), or dates manually converted to the website timezone.
- Altered the few Mysql fields that were defaulting to "Current timestamp", they now default to NULL.
- Deprecated the field log_visit.server_date and log_conversion.server_date as they are now not used. Must use DATE(visit_last_action_time) instead. Note that the new INDEX on (idsite, visit_last_action_time, config_md5config) will greatly benefit the Live! plugin.
- Deprecated Piwik_Date->get, must now use Piwik_Date->toString
- Deprecated the DB adapters getCurrentTimezone() feature, as we now don't rely on the DB timezone. Also removed the warning from the install screen.
Diffstat (limited to 'plugins/SitesManager/templates')
-rw-r--r-- | plugins/SitesManager/templates/SitesManager.js | 59 | ||||
-rw-r--r-- | plugins/SitesManager/templates/SitesManager.tpl | 40 |
2 files changed, 95 insertions, 4 deletions
diff --git a/plugins/SitesManager/templates/SitesManager.js b/plugins/SitesManager/templates/SitesManager.js index 1c06c8c4ac..f60b0b615a 100644 --- a/plugins/SitesManager/templates/SitesManager.js +++ b/plugins/SitesManager/templates/SitesManager.js @@ -24,13 +24,15 @@ function getAddSiteAJAX( row ) var urls = getApiFormatUrls(urls); var excludedIps = $(row).find('textarea#siteadd_excludedIps').val(); excludedIps = getApiFormatExcludedIps(excludedIps); - + var timezone = encodeURIComponent($(row).find('option:selected').val()); + var request = ''; request += '&module=API'; request += '&format=json'; request += '&method=SitesManager.addSite'; siteName = encodeURIComponent(siteName); request += '&siteName='+siteName; + request += '&timezone='+timezone; request += '&excludedIps='+excludedIps; $.each(urls, function (key,value){ request+= '&urls[]='+escape(value);} ); request += '&token_auth=' + piwik.token_auth; @@ -59,7 +61,7 @@ function getUpdateSiteAJAX( row ) urls = getApiFormatUrls(urls); var excludedIps = $(row).find('textarea#excludedIps').val(); excludedIps = getApiFormatExcludedIps(excludedIps); - + var timezone = encodeURIComponent($(row).find('option:selected').val()); var request = ''; request += '&module=API'; request += '&format=json'; @@ -67,6 +69,7 @@ function getUpdateSiteAJAX( row ) siteName = encodeURIComponent(siteName); request += '&siteName='+siteName; request += '&idSite='+idSite; + request += '&timezone='+timezone; request += '&excludedIps='+excludedIps; $.each(urls, function (key,value){ if(value.length>1) request+= '&urls[]='+value;} ); request += '&token_auth=' + piwik.token_auth; @@ -76,6 +79,20 @@ function getUpdateSiteAJAX( row ) return ajaxRequest; } +function getDefaultTimezoneAJAX() +{ + var ajaxRequest = piwikHelper.getStandardAjaxConf('ajaxLoadingDefaultTimezone', 'ajaxErrorDefaultTimezone'); + var timezone = encodeURIComponent($('#defaultTimezone option:selected').val()); + var request = ''; + request += '&module=API'; + request += '&format=json'; + request += '&method=SitesManager.setDefaultTimezone'; + request += '&defaultTimezone='+timezone; + request += '&token_auth=' + piwik.token_auth; + ajaxRequest.data = request; + return ajaxRequest; +} + function getSetGlobalExcludedIpsAJAX() { var ajaxRequest = piwikHelper.getStandardAjaxConf('ajaxLoadingExcludedIps', 'ajaxErrorExcludedIps'); @@ -104,6 +121,7 @@ $(document).ready( function() { <td><input id="siteadd_name" value="Name" size="25" /></td>\ <td><textarea cols="30" rows="3" id="siteadd_urls">http://siteUrl.com/\nhttp://siteUrl2.com/</textarea><br />'+aliasUrlsHelp+'</td>\ <td><textarea cols="30" rows="3" id="siteadd_excludedIps"></textarea><br />'+excludedIpHelp+'</td>\ + <td>'+getTimezoneSelector(defaultTimezone)+'<br />' + timezoneHelp + '</td>\ <td><img src="plugins/UsersManager/images/ok.png" class="addsite" href="#" /></td>\ <td><img src="plugins/UsersManager/images/remove.png" class="cancel" /></td>\ </tr>') @@ -159,6 +177,12 @@ $(document).ready( function() { contentAfter += '<br />'+excludedIpHelp; $(n).html(contentAfter); } + if(idName == 'timezone') + { + var contentAfter = getTimezoneSelector(contentBefore); + contentAfter += '<br />' + timezoneHelp; + $(n).html(contentAfter); + } } ); $(this) @@ -173,10 +197,39 @@ $(document).ready( function() { $('#globalExcludedIpsSubmit').click( function() { $.ajax( getSetGlobalExcludedIpsAJAX() ); }); + + $('#defaultTimezone').html( getTimezoneSelector(defaultTimezone)); + + $('#defaultTimezoneSubmit').click( function() { + $.ajax( getDefaultTimezoneAJAX() ); + }); $('td.editableSite').click( function(){ $(this).parent().find('.editSite').click(); } ); }); - + +function getTimezoneSelector(selectedTimezone) +{ + var html = '<select id="timezones">'; + if(!selectedTimezone) + { + html += '<option selected="selected" value="'+selectACity+'">'+selectACity+'</option>'; + } + for(var continent in timezones) { + html += '<optgroup label="' + continent + '">'; + for(var timezoneId in timezones[continent]) { + var selected = ''; + if(timezoneId == selectedTimezone) { + selected = ' selected="selected" '; + } + html += '<option ' + selected + ' value="'+ timezoneId + '">' + timezones[continent][timezoneId] + '</option>'; + } + html += "</optgroup>\n"; + } + html += '</select>'; + return html; +} + + function submitSiteOnEnter(e) { var key=e.keyCode || e.which; diff --git a/plugins/SitesManager/templates/SitesManager.tpl b/plugins/SitesManager/templates/SitesManager.tpl index 3331aacd63..43607ab226 100644 --- a/plugins/SitesManager/templates/SitesManager.tpl +++ b/plugins/SitesManager/templates/SitesManager.tpl @@ -9,7 +9,26 @@ {assign var=excludedIpHelp value=$excludedIpHelpPlain|inlineHelp} var excludedIpHelp = '{$excludedIpHelp|escape:javascript}'; var aliasUrlsHelp = '{'SitesManager_AliasUrlHelp'|translate|inlineHelp|escape:javascript}'; +{capture assign=defaultTimezoneHelpPlain} + {if $timezoneSupported} + {'SitesManager_ChooseCityInSameTimezoneAsYou'|translate} + {else} + {'SitesManager_AdvancedTimezoneSupportNotFound'|translate} + {/if} <br /><br />{'SitesManager_UTCTimeIs'|translate:$utcTime} +{/capture} + +{capture assign=timezoneHelpPlain} + {$defaultTimezoneHelpPlain} + <br /><br />{'SitesManager_ChangingYourTimezoneWillOnlyAffectDataForward'|translate} +{/capture} + +var timezoneHelp = '{$timezoneHelpPlain|inlineHelp|escape:javascript}'; +{assign var=defaultTimezoneHelp value=$defaultTimezoneHelpPlain|inlineHelp}; +var timezones = {$timezones}; +var defaultTimezone = '{$defaultTimezone}'; +var selectACity = '{'SitesManager_SelectCity'|translate}'; </script> + <script type="text/javascript" src="plugins/SitesManager/templates/SitesManager.js"></script> {literal} @@ -29,18 +48,22 @@ var aliasUrlsHelp = '{'SitesManager_AliasUrlHelp'|translate|inlineHelp|escape:ja #editSites { valign: top; } +option, select { + font-size:11px; +} </style> {/literal} <h2>{'SitesManager_WebsitesManagement'|translate}</h2> <p>{'SitesManager_MainDescription'|translate} {if $isSuperUser} -<br/>{'SitesManager_SuperUserCanExcludeIpsOnAllWebsites'|translate:"<a href='#globalIpExclusion'>":"</a>"}. +<br/>{'SitesManager_SuperUserCan'|translate:"<a href='#globalIpExclusion'>":"</a>":"<a href='#defaultTimezone'>":"</a>"} {/if} </p> {ajaxErrorDiv} {ajaxLoadingDiv} + {if $adminSites|@count == 0} {'SitesManager_NoWebsites'|translate} {else} @@ -51,6 +74,7 @@ var aliasUrlsHelp = '{'SitesManager_AliasUrlHelp'|translate|inlineHelp|escape:ja <th>{'SitesManager_Name'|translate}</th> <th>{'SitesManager_Urls'|translate}</th> <th>{'SitesManager_ExcludedIps'|translate}</th> + <th>{'SitesManager_Timezone'|translate}</th> <th> </th> <th> </th> <th> {'SitesManager_JsTrackingTag'|translate} </th> @@ -63,6 +87,7 @@ var aliasUrlsHelp = '{'SitesManager_AliasUrlHelp'|translate|inlineHelp|escape:ja <td id="siteName" class="editableSite">{$site.name}</td> <td id="urls" class="editableSite">{foreach from=$site.alias_urls item=url}{$url}<br />{/foreach}</td> <td id="excludedIps" class="editableSite">{foreach from=$site.excluded_ips item=ip}{$ip}<br />{/foreach}</td> + <td id="timezone" class="editableSite">{$site.timezone}</td> <td><img src='plugins/UsersManager/images/edit.png' class="editSite" id="row{$i}" href='#' title="{'General_Edit'|translate}" /></td> <td><img src='plugins/UsersManager/images/remove.png' class="deleteSite" id="row{$i}" title="{'General_Delete'|translate}" value="{'General_Delete'|translate}" /></td> <td><a href='{url action=displayJavascriptCode idsite=$site.idsite}'>{'SitesManager_ShowTrackingTag'|translate}</a></td> @@ -85,6 +110,19 @@ var aliasUrlsHelp = '{'SitesManager_AliasUrlHelp'|translate|inlineHelp|escape:ja {$excludedIpHelp} <input type="hidden" name="token_auth" value="{$token_auth}" /> <p><input type="submit" class="submit" id='globalExcludedIpsSubmit' value="{'General_Save'|translate}" /></p> + + + <a name='defaultTimezone'></a><h2>{'SitesManager_DefaultTimezone'|translate}</h2> + <p>{'SitesManager_SelectDefaultTimezone'|translate} + {ajaxErrorDiv id=ajaxErrorDefaultTimezone} + {ajaxLoadingDiv id=ajaxLoadingDefaultTimezone} + <div id='defaultTimezone'></div> + <br/> + {$defaultTimezoneHelp} + <input type="hidden" name="token_auth" value="{$token_auth}" /> + <p><input type="submit" class="submit" id='defaultTimezoneSubmit' value="{'General_Save'|translate}" /></p> + + {/if} <br /><br /><br /><br /> |