Skip to content

Commit

Permalink
Merge pull request pencilblue#154 from careerbuilder/loadSite-defaults
Browse files Browse the repository at this point in the history
Load site defaults
  • Loading branch information
btidwell committed Jan 11, 2016
2 parents 8dc8e70 + e292918 commit 19df9b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 0 additions & 1 deletion include/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ module.exports = function LocalizationModule(pb) {
* @param {Function} cb
*/
Localization.init = function(cb) {
var supportedLocales = [];
Localization.storage = {};
Localization.keys = {};

Expand Down
13 changes: 12 additions & 1 deletion include/service/entities/site_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,15 @@ module.exports = function SiteServiceModule(pb) {
return cb(err);
}

var defaultLocale = pb.Localization.getDefaultLocale();
var defaultSupportedLocales = {};
defaultSupportedLocales[defaultLocale] = true;
//only load the sites when we are in multi-site mode
if (pb.config.multisite.enabled) {
util.forEach(results, function (site) {
site.defaultLocale = site.defaultLocale || defaultLocale;
site.supportedLocales = site.supportedLocales || defaultSupportedLocales;
site.prevHostnames = site.prevHostnames || [];
pb.RequestHandler.loadSite(site);
});
}
Expand Down Expand Up @@ -596,12 +602,17 @@ module.exports = function SiteServiceModule(pb) {
* @return {Object}
*/
SiteService.getGlobalSiteContext = function() {
var defaultLocale = pb.Localization.getDefaultLocale();
var defaultSupportedLocales = {};
defaultSupportedLocales[defaultLocale] = true;
return {
displayName: pb.config.siteName,
uid: pb.SiteService.GLOBAL_SITE,
hostname: pb.config.multisite.enabled ? url.parse(pb.config.multisite.globalRoot).host : url.parse(pb.config.siteRoot).host,
active: pb.config.multisite.enabled ? false : true,
supportedLocales: util.arrayToObj(pb.Localization.getSupported(), function(a, i) { return a[i]; }, function(a, i) { return true; })
defaultLocale: defaultLocale,
supportedLocales: defaultSupportedLocales,
prevHostnames: []
};
};

Expand Down

0 comments on commit 19df9b2

Please sign in to comment.