Einführung einer statischen Konstante für die sprachunabhängige "Sprache" und eines Konfigurationsparameter.

git-svn-id: https://svn.libreccm.org/ccm/trunk@1174 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2011-10-18 05:51:06 +00:00
parent 7345401d96
commit 4a32d33f55
5 changed files with 46 additions and 25 deletions

View File

@ -20,7 +20,9 @@ package com.arsdigita.cms.util;
import com.arsdigita.cms.ContentBundle; import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ContentPage; import com.arsdigita.cms.ContentPage;
import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.util.Pair; import com.arsdigita.util.Pair;
@ -36,6 +38,7 @@ import java.util.StringTokenizer;
* Utility methods for dealing with the multilingual items. * Utility methods for dealing with the multilingual items.
* *
* @author Shashin Shinde (sshinde@redhat.com) * @author Shashin Shinde (sshinde@redhat.com)
* @author Sören Bernstein
*/ */
public class LanguageUtil { public class LanguageUtil {
@ -63,7 +66,11 @@ public class LanguageUtil {
* at the server startup * at the server startup
*/ */
public static void setSupportedLanguages(String languages) { public static void setSupportedLanguages(String languages) {
s_languages = languages + ",--"; if(Kernel.getConfig().languageIndependentItems()) {
s_languages = languages + "," + GlobalizationHelper.LANG_INDEPENDENT;
} else {
s_languages = languages;
}
} }
/** Get the comma separated list of all supported languages */ /** Get the comma separated list of all supported languages */

View File

@ -20,6 +20,7 @@ import javax.servlet.http.HttpSession;
*/ */
public class GlobalizationHelper { public class GlobalizationHelper {
public static final String LANG_INDEPENDENT = "--";
private static final String LANG_PARAM = "lang"; private static final String LANG_PARAM = "lang";
// Don't instantiate // Don't instantiate

View File

@ -79,6 +79,8 @@ public final class KernelConfig extends AbstractConfig {
private final Parameter m_supportedLanguages = new StringParameter private final Parameter m_supportedLanguages = new StringParameter
("waf.kernel.supported_languages", Parameter.REQUIRED, ("waf.kernel.supported_languages", Parameter.REQUIRED,
"en,de,fr,nl,it,pt,es"); "en,de,fr,nl,it,pt,es");
private final Parameter m_languageIndependentItems = new BooleanParameter
("waf.kernel.language_independent_items", Parameter.REQUIRED, Boolean.FALSE);
public KernelConfig() { public KernelConfig() {
@ -101,6 +103,7 @@ public final class KernelConfig extends AbstractConfig {
register(m_remember); register(m_remember);
register(m_secureLogin); register(m_secureLogin);
register(m_supportedLanguages); register(m_supportedLanguages);
register(m_languageIndependentItems);
loadInfo(); loadInfo();
} }
@ -183,4 +186,8 @@ public final class KernelConfig extends AbstractConfig {
return ((String) get(m_supportedLanguages)).contains(lang); return ((String) get(m_supportedLanguages)).contains(lang);
} }
public final boolean languageIndependentItems() {
return ((Boolean) get(m_languageIndependentItems)).booleanValue();
}
} }

View File

@ -26,3 +26,7 @@ waf.kernel.supported_languages.title=Set the supported languages for categorizat
waf.kernel.supported_languages.purpose=Set the supported languages for categorization. First entry is the default language waf.kernel.supported_languages.purpose=Set the supported languages for categorization. First entry is the default language
waf.kernel.supported_languages.example=en,de,fr,nl,it,pt,es waf.kernel.supported_languages.example=en,de,fr,nl,it,pt,es
waf.kernel.supported_languages.format=[string] waf.kernel.supported_languages.format=[string]
waf.kernel.language_independent_items.title=Allow language independent content items
waf.kernel.language_independent_items.purpose=Allow language independent content items
waf.kernel.language_independent_items.example=false
waf.kernel.language_independent_items.format=true|false

View File

@ -15,10 +15,10 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
package com.arsdigita.london.navigation.ui; package com.arsdigita.london.navigation.ui;
import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.london.navigation.DataCollectionDefinition; import com.arsdigita.london.navigation.DataCollectionDefinition;
import com.arsdigita.london.navigation.DataCollectionRenderer; import com.arsdigita.london.navigation.DataCollectionRenderer;
@ -89,8 +89,7 @@ public abstract class AbstractObjectList
} }
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
throw new UncheckedWrapperException( throw new UncheckedWrapperException(
"cannot parse page number " + pageNumber, ex "cannot parse page number " + pageNumber, ex);
);
} }
DataCollection objects = getObjects(request, response); DataCollection objects = getObjects(request, response);
@ -98,12 +97,15 @@ public abstract class AbstractObjectList
// Quasimodo: Begin // Quasimodo: Begin
// Limit list to objects in the negotiated language and language invariant items // Limit list to objects in the negotiated language and language invariant items
if (objects != null && objects.size() > 0) { if (objects != null && objects.size() > 0) {
if (Kernel.getConfig().languageIndependentItems()) {
FilterFactory ff = objects.getFilterFactory(); FilterFactory ff = objects.getFilterFactory();
Filter filter = ff.or(). Filter filter = ff.or().
addFilter(ff.equals("language", com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale().getLanguage())). addFilter(ff.equals("language", com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale().getLanguage())).
addFilter(ff.equals("language", "--")); addFilter(ff.equals("language", GlobalizationHelper.LANG_INDEPENDENT));
objects.addFilter(filter); objects.addFilter(filter);
// objects.addEqualsFilter("language", com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale().getLanguage()); } else {
objects.addEqualsFilter("language", com.arsdigita.globalization.GlobalizationHelper.getNegotiatedLocale().getLanguage());
}
} }
// Quasimodo: End // Quasimodo: End