From 6431b0a5d59bc5765ba54a062e90293d72de2737 Mon Sep 17 00:00:00 2001 From: quasi Date: Thu, 9 Aug 2012 08:46:16 +0000 Subject: [PATCH] CategoryLocalization UI Bearbeiten von Kategorien funktioniert nun. (#107) Liste der Sprachversionen ist nun nach locale sortiert git-svn-id: https://svn.libreccm.org/ccm/trunk@1809 8810af33-2d31-482b-a856-94f89814c4df --- .../com/arsdigita/cms/CMSResources.properties | 2 +- .../arsdigita/cms/CMSResources_de.properties | 32 ++++----- .../cms/ui/category/CategoryItemPane.java | 15 +++- .../arsdigita/categorization/Category.java | 15 ++-- .../CategoryLocalizationCollection.java | 7 +- .../navigation/DataCollectionDefinition.java | 7 ++ .../navigation/ui/AbstractObjectList.java | 18 +++-- .../ui/object/ComplexObjectList.java | 71 ++++++++++++++----- 8 files changed, 113 insertions(+), 54 deletions(-) diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources.properties index 3f5f44539..1c055f4dd 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources.properties @@ -105,7 +105,7 @@ cms.contenttypes.ui.event_start_time=Event Start Time: cms.contenttypes.ui.event_end_time=Event End Time: cms.contenttypes.ui.government_uid=Government UID: cms.contenttypes.ui.grade=Grade: -cms.contenttypes.ui.homepage=Homepage? +cms.contenttypes.ui.homepage=Homepage: cms.contenttypes.ui.job_description=Job Description: cms.contenttypes.ui.launch_date=Launch Date: cms.contenttypes.ui.lead=Description: diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties index 75831647c..dc4f9c751 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties @@ -70,7 +70,7 @@ cms.contenttypes.template.body_text.description=Haupttext bearbeiten cms.contenttypes.shared.assign_categories.title=Kategorien zuweisen cms.contenttypes.shared.assign_categories.description=Kategorien zuweisen cms.contenttypes.shared.attach_files.title=Dateien zuordnen -cms.contenttypes.shared.attach_files.description=Dateien anh\u00c4ngen +cms.contenttypes.shared.attach_files.description=Dateien anh\u00e4ngen cms.contenttypes.shared.basic_properties.description=Basiseigenschaften editieren cms.contenttypes.shared.basic_properties.title=Basiseigenschaften cms.contenttypes.shared.body_text.title=Haupttext @@ -105,7 +105,7 @@ cms.contenttypes.ui.event_start_time=Event Beginn um\: cms.contenttypes.ui.event_end_time=Event Ende um\: cms.contenttypes.ui.government_uid=Government UID: cms.contenttypes.ui.grade=Grad: -cms.contenttypes.ui.homepage=Homepage? +cms.contenttypes.ui.homepage=Homepage: cms.contenttypes.ui.job_description=Job Beschreibung: cms.contenttypes.ui.launch_date=Ver\u00f6ffentlichungsdatum: cms.contenttypes.ui.lead=Beschreibung (Lead Text): @@ -160,8 +160,8 @@ cms.installer.cannot_find_file=kann Datei nicht finden cms.installer.cannot_find_group_for_email=Kann email-Gruppe nicht finden cms.installer.cannot_read_line_of_data=Kann Datensatz nicht lesen cms.installer.cannot_set_template_text=Kann Template Text nicht festlegen -cms.installer.could_not_load_section=Kann die folgende ContentSection nicht laden '{0}' -cms.installer.deploy=anwenden +cms.installer.could_not_load_section=Kann die ContentSection '{0}' nicht laden +cms.installer.deploy=Anwenden cms.installer.failed_to_update_the_default_content_section=Update der Default Content Section gescheitert. cms.installer.formbuilder.form=Form cms.installer.formbuilder.form_section=Form Abschnitt @@ -187,7 +187,7 @@ cms.publishToFile.cannot_read_template_text=cannot read template text cms.publishToFile.could_not_get_object_for_oid=Could not get object for oid cms.publishToFile.error_executing=Ausf\u00fchrungsfehler bei '{0}' \: cms.publishToFile.exit_value_was=Exit Code war -cms.publishToFile.interrupted_when_doing=Unterbrochen bei Ausf\u00fchren von '{0}' +cms.publishToFile.interrupted_when_doing=Unterbrochen beim Ausf\u00fchren von '{0}' cms.publishToFile.invalid_brokenlinkaction=Ung\u00fcltige BrokenLinkAction\: cms.publishToFile.invalid_reference_target_type=Ung\u00fcltige reference target type\: cms.publishToFile.malformed_url=Falsche Struktur der URL\: @@ -232,7 +232,7 @@ cms.ui.available_categories=Verf\u00fcgbare Kategorien: cms.ui.browse=Dokumente cms.ui.browse_items_by_category=Durchsicht der Elemente nach Kategorien cms.ui.cancel=Abbruch -cms.ui.cancel_hit=Abbruch dr\u00fccken +cms.ui.cancel_hit=Abbruch gedr\u00fcckt cms.ui.cancelled=abgebrochen cms.ui.cannot_assign_groups_to_owner=cannot assign groups to owner cms.ui.categories=Kategorien @@ -241,7 +241,7 @@ cms.ui.content_center=Content center cms.ui.content_item=Dokument cms.ui.content_section=Content section cms.ui.content_section_configuration=

Content Section Configuration

-cms.ui.content_types=Dokument Typen +cms.ui.content_types=Dokumenttypen cms.ui.contents_of=Inhalt von cms.ui.create=Erstellen cms.ui.cse=Bald abgelaufen @@ -324,10 +324,10 @@ cms.ui.tasks_status_no_colon=Status cms.ui.template=Vorlage cms.ui.Templates=Vorlagen cms.ui.the_model_is_empty=Das Modell ist leer -cms.ui.there_are_no_items=Keine elemente vorhanden. +cms.ui.there_are_no_items=Keine Elemente vorhanden. cms.ui.there_was_no_one_matching_the_search_criteria=Kein Element erf\u00fcllte die Suchkriterien. cms.ui.this_should_never_happen=Dies sollte nie passieren\! -cms.ui.types=Dokument Typen +cms.ui.types=Dokumenttypen cms.ui.unknown=unbekannt cms.ui.upload_new_content=Neuen Inhalt laden cms.ui.use_custom_permissions=Benutzerspezifische Rechte @@ -352,9 +352,9 @@ cms.ui.item_search.search=Suchen # Package com.arsdigita.cms.ui.authoring # ====================================== -cms.ui.authoring.an_item_with_this_name_already_exists=Ein Item mit diesem Namen existiert +cms.ui.authoring.an_item_with_this_name_already_exists=Ein Item mit diesem Namen existiert bereits cms.ui.authoring.bad_getblob_datatype=Ung\u00fcltiger Datentyp getBlob -cms.ui.authoring.bad_getclob_datatype=Ung\u00fcltiger Datentyp getBlob +cms.ui.authoring.bad_getclob_datatype=Ung\u00fcltiger Datentyp getClob cms.ui.authoring.body=Textbereich: cms.ui.authoring.caption=Untertitel: cms.ui.authoring.content_type=Inhaltstyp: @@ -457,7 +457,7 @@ cms.ui.category.localization_edit=Bearbeiten cms.ui.category.localization_error_locale=Bitte w\u00e4hlen Sie eine Sprache aus cms.ui.category.localization_locale=Sprache cms.ui.category.localization_name=Name -cms.ui.category.localization_none=Diese Kaegorie hat keine Sprachversionen +cms.ui.category.localization_none=Diese Kategorie hat keine Sprachversionen cms.ui.category.localization_url=URL cms.ui.category.name_not_unique=Es gibt bereits eine Kategorie mit diesem Namen. cms.ui.category.no_categorized_objects=Es gibt keine kategorisierten Objekte @@ -489,8 +489,8 @@ cms.ui.cse.authorName=Verfasser cms.ui.cse.itemName=Name cms.ui.cse.view=Anzeigen cms.ui.cse.viewLink=anzeigen -cms.ui.cse.edit=Edit -cms.ui.cse.editLink=edit +cms.ui.cse.edit=Bearbeiten +cms.ui.cse.editLink=bearbeiten cms.ui.cse.endDateTime=aktiv bis @@ -498,7 +498,7 @@ cms.ui.cse.endDateTime=aktiv bis # =================================== cms.ui.folder.cancelled=Abgebrochen cms.ui.folder.cannot_find_a_root_folder=Kein Wurzelverzeichnis gefunden. -cms.ui.folder.na=K.A. +cms.ui.folder.na=k.A. cms.ui.folder.no_source_items_specified=Kein Quelldokument angegeben. cms.ui.folder.parent=\u00dcbergeordneter Ordner cms.ui.folder.rename=Ordner umbenennen @@ -507,7 +507,7 @@ cms.ui.folder.rename=Ordner umbenennen # ======================================== cms.ui.formbuilder.description=Beschreibung: cms.ui.formbuilder.name=Name: -cms.ui.formbuilder.oh_no_you_dont=Nicht, sie wollen nicht +cms.ui.formbuilder.oh_no_you_dont=Nein, das wollen sie nicht cms.ui.formbuilder.title=Titel\: diff --git a/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryItemPane.java b/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryItemPane.java index 51812b05f..f84e40c0e 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryItemPane.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryItemPane.java @@ -22,8 +22,10 @@ import com.arsdigita.bebop.ActionLink; import com.arsdigita.bebop.BaseLink; import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Form; +import com.arsdigita.bebop.FormModel; import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Link; +import com.arsdigita.bebop.Page; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.ParameterSingleSelectionModel; import com.arsdigita.bebop.SimpleContainer; @@ -82,8 +84,6 @@ class CategoryItemPane extends BaseItemPane { private final SingleSelectionModel m_model; private final CategoryRequestLocal m_category; private final SimpleContainer m_detailPane; - private final StringParameter m_catLocaleParam = new StringParameter("catLocale"); - private final ParameterSingleSelectionModel m_catLocale; public CategoryItemPane(final SingleSelectionModel model, final CategoryRequestLocal category, @@ -92,7 +92,6 @@ class CategoryItemPane extends BaseItemPane { final ActionLink deleteLink) { m_model = model; m_category = category; - m_catLocale = new ParameterSingleSelectionModel(m_catLocaleParam); // Details m_detailPane = new SimpleContainer(); @@ -338,9 +337,13 @@ class CategoryItemPane extends BaseItemPane { private CategoryLocalizationTable m_catLocalizationTable; private CategoryLocalizationEditForm m_editCategoryLocalizationForm; + private StringParameter m_catLocaleParam; + private ParameterSingleSelectionModel m_catLocale; CategoryLocalizationSection(ActionLink addLink) { setHeading(new Label(gz("cms.ui.category.localizations"))); + m_catLocaleParam = new StringParameter("catLocale"); + m_catLocale = new ParameterSingleSelectionModel(m_catLocaleParam); final ActionGroup group = new ActionGroup(); setBody(group); @@ -353,6 +356,12 @@ class CategoryItemPane extends BaseItemPane { connect(m_editCategoryLocalizationForm); connect(m_catLocalizationTable, 0, m_editCategoryLocalizationForm); } + + @Override + public void register(Page page) { + super.register(page); + page.addComponentStateParam(m_editCategoryLocalizationForm, m_catLocaleParam); + } } private class SubcategorySection extends Section { diff --git a/ccm-core/src/com/arsdigita/categorization/Category.java b/ccm-core/src/com/arsdigita/categorization/Category.java index 38e831f3c..cedbe5711 100755 --- a/ccm-core/src/com/arsdigita/categorization/Category.java +++ b/ccm-core/src/com/arsdigita/categorization/Category.java @@ -745,18 +745,19 @@ public class Category extends ACSObject { */ public boolean isEnabled(String locale) { - // If not gloebally disabled and locale is not null or empty, test for localized version - if (locale != null && - !locale.isEmpty() && - ((Boolean) get(IS_ENABLED)).booleanValue() == true && - m_categoryLocalizationCollection != null && - m_categoryLocalizationCollection.localizationExists(locale)) { + // If globally disabled, return category as disabled + if (((Boolean) get(IS_ENABLED)).booleanValue() == false) { + return false; + } + + // Test for localized version + if (locale != null && !locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection. + localizationExists(locale)) { // Return value of isEnabled from localized version, so categories could be disabled depending on locale boolean isEnabled = m_categoryLocalizationCollection.isEnabled(); m_categoryLocalizationCollection.rewind(); return isEnabled; - //return m_categoryLocalizationCollection.isEnabled(); } else { diff --git a/ccm-core/src/com/arsdigita/categorization/CategoryLocalizationCollection.java b/ccm-core/src/com/arsdigita/categorization/CategoryLocalizationCollection.java index a3f6c62ba..5c256d59c 100644 --- a/ccm-core/src/com/arsdigita/categorization/CategoryLocalizationCollection.java +++ b/ccm-core/src/com/arsdigita/categorization/CategoryLocalizationCollection.java @@ -36,11 +36,12 @@ public class CategoryLocalizationCollection extends ACSObjectCollection { private String lastFoundLocale; public CategoryLocalizationCollection(Category category) { - super(category.getLocalizations().getDataCollection()); + this(category.getLocalizations().getDataCollection()); } public CategoryLocalizationCollection(DataCollection dataCollection) { super(dataCollection); + addOrder("locale"); } /** @@ -118,9 +119,7 @@ public class CategoryLocalizationCollection extends ACSObjectCollection { */ public boolean localizationExists(String locale) { - // Really string comparison using != ?? - // && !locale.isEmpty() ? - if (!m_dataCollection.isEmpty() && locale != "") { + if (!m_dataCollection.isEmpty() && !"".equals(locale)) { // First check, if we are already at the right position. This will speed up repeated access for the same locale if (this.getPosition() > 0 && this.getCategoryLocalization(). diff --git a/ccm-navigation/src/com/arsdigita/navigation/DataCollectionDefinition.java b/ccm-navigation/src/com/arsdigita/navigation/DataCollectionDefinition.java index 2a264048c..81ad45a97 100755 --- a/ccm-navigation/src/com/arsdigita/navigation/DataCollectionDefinition.java +++ b/ccm-navigation/src/com/arsdigita/navigation/DataCollectionDefinition.java @@ -195,6 +195,13 @@ public class DataCollectionDefinition extends LockableImpl { m_properties.add(property); } + /** + * Get a collection of objects from the database defined by model or + * null if the requested object type is invalid + * + * @param model + * @return data collection or null + */ public final DataCollection getDataCollection(NavigationModel model) { Assert.isLocked(this); diff --git a/ccm-navigation/src/com/arsdigita/navigation/ui/AbstractObjectList.java b/ccm-navigation/src/com/arsdigita/navigation/ui/AbstractObjectList.java index 4ac1bf786..c4e046f22 100755 --- a/ccm-navigation/src/com/arsdigita/navigation/ui/AbstractObjectList.java +++ b/ccm-navigation/src/com/arsdigita/navigation/ui/AbstractObjectList.java @@ -21,19 +21,21 @@ import com.arsdigita.globalization.GlobalizationHelper; import com.arsdigita.kernel.Kernel; import com.arsdigita.navigation.DataCollectionDefinition; import com.arsdigita.navigation.DataCollectionRenderer; - import com.arsdigita.persistence.DataCollection; - import com.arsdigita.persistence.Filter; import com.arsdigita.persistence.FilterFactory; import com.arsdigita.util.Assert; import com.arsdigita.util.UncheckedWrapperException; - import com.arsdigita.xml.Element; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +/** + * Abstract base class for object lists + * + * @author unknown + * @author Sören Bernstein (quasimodo) + */ public abstract class AbstractObjectList extends AbstractComponent implements ObjectList { @@ -58,6 +60,14 @@ public abstract class AbstractObjectList return m_renderer; } + /** + * Get a list of objects from the database which meet a set criteria or + * null if the requested object type is invalid + * + * @param request + * @param response + * @return the object list or null + */ protected DataCollection getObjects(HttpServletRequest request, HttpServletResponse response) { diff --git a/ccm-navigation/src/com/arsdigita/navigation/ui/object/ComplexObjectList.java b/ccm-navigation/src/com/arsdigita/navigation/ui/object/ComplexObjectList.java index 3ef8d2d90..167ef686b 100755 --- a/ccm-navigation/src/com/arsdigita/navigation/ui/object/ComplexObjectList.java +++ b/ccm-navigation/src/com/arsdigita/navigation/ui/object/ComplexObjectList.java @@ -15,22 +15,22 @@ package com.arsdigita.navigation.ui.object; import com.arsdigita.navigation.Navigation; import com.arsdigita.navigation.ui.AbstractObjectList; - import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.Filter; import com.arsdigita.persistence.FilterFactory; - - import com.arsdigita.xml.Element; import java.util.HashMap; import java.util.Iterator; import java.util.Map; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * A complex object list + * + * An object list which will accept SQL filters to customize the content easily. + * + * @author Sören Bernstein */ public class ComplexObjectList extends AbstractObjectList { @@ -41,19 +41,52 @@ public class ComplexObjectList extends AbstractObjectList { protected Map m_customAttributes = new HashMap(); + // Getter / Setter + + /** + * Sets a custom name for this list. + * @param name the list name + */ public void setCustomName(String name) { m_customName = name; } + /** + * Gets the costum name for this list. + * @return the list name + */ public String getCustomName() { return m_customName; } /** - * Hinzufügen eines SQL-Filter zur Abfrage - * Verarbeitet einen boolschen Filter, der SQL-konform Formatiert ist. - * Siehe PostgreSQL-Handbuch zur where-Klausel - * @param sqlfilter + * Adds a custom attribute + * + * @param attribute + * @param value + */ + public void addCustomAttribute(final String attribute, final String value) { + m_customAttributes.put(attribute, value); + } + + /** + * Gets a custom attribute + * + * @param attribute + * @return + */ + public String getCustomAttribute(final String attribute) { + return m_customAttributes.get(attribute); + } + + + /** + * Add a SQL filter to query. + * This filter can handle wildcards which have to be set with {@link #setParameter(java.lang.String, java.lang.Object)} + * + *See PostgreSQL handbook about where clause + * + * @param sqlfilter the sql filter */ public void setSQLFilter(String sqlfilter) { @@ -61,22 +94,22 @@ public class ComplexObjectList extends AbstractObjectList { } + /** + * Set parameter for for sql filter. + * + * @param parameterName the parameter name of the + * @param value the value attached to the parameter + */ public void setParameter(String parameterName, Object value) { m_filterParameters.put(parameterName, value); } - public String getCustomAttribute(final String attribute) { - return m_customAttributes.get(attribute); - } - - public void addCustomAttribute(final String attribute, final String value) { - m_customAttributes.put(attribute, value); - } - - /* Diese Methode überschreibt die Methode aus der Eltern-Klasse, um - * die SQL-Filter berücksichtigen zu können + /** + * Get all objects for this list. + * + * Overrides the parent class to allow for sql filter */ @Override protected DataCollection getObjects(HttpServletRequest request, @@ -112,7 +145,7 @@ public class ComplexObjectList extends AbstractObjectList { return objects; } - /* Diese Methode wird vom Servlet aufgerufen */ + /* This method will be called by the servlet */ public Element generateXML(HttpServletRequest request, HttpServletResponse response) { Element content = Navigation.newElement("complexObjectList");