From c604013c914025c82834e998c56aba2d405cd0ea Mon Sep 17 00:00:00 2001 From: quasi Date: Mon, 27 Jun 2011 10:27:44 +0000 Subject: [PATCH] ItemSearch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ItemSearch konfigurierbar gemacht, so daß bei Bedarf auch ContentSection-übergreifend gesucht werden kann. Dabei ist folgendes zu Beachten: 1. Die Suche aus dem ContentCenter ist immer eine Suche über alle ContentSection, da es keine aktuelle ContentSection gibt 2. Die Suche aus einer ContentSection wird durch die Einstellung des Config-Parameters com.arsdigita.cms.search.limitToContentSection beeinflußt. 3. Die Suche in einem ItemSearchWidget ist (zur Zeit) immer ContentSection-übergreifend, da es noch keinen Config-Parameter dafür gibt. git-svn-id: https://svn.libreccm.org/ccm/trunk@989 8810af33-2d31-482b-a856-94f89814c4df --- ccm-cms/src/com/arsdigita/cms/CMSConfig.java | 11 ++++++++++ .../cms/CMSConfig_parameter.properties | 5 +++++ .../arsdigita/cms/ui/ContentSectionPage.java | 2 +- .../src/com/arsdigita/cms/ui/ItemSearch.java | 21 ++++++++++++++++--- .../com/arsdigita/cms/ui/ItemSearchPopup.java | 13 ++++++------ .../arsdigita/cms/ui/ItemSearchSection.java | 14 +++++++------ .../cms/ui/ItemSearchSectionInline.java | 5 +++-- .../arsdigita/cms/ui/ItemSearchWidget.java | 7 ++++--- .../cms/ui/search/ItemQueryComponent.java | 6 +++--- .../bundles/devel/cfg/applications.cfg | 1 + environment/project.xml.quasi | 1 + 11 files changed, 62 insertions(+), 24 deletions(-) diff --git a/ccm-cms/src/com/arsdigita/cms/CMSConfig.java b/ccm-cms/src/com/arsdigita/cms/CMSConfig.java index c30385041..49d0613e8 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSConfig.java +++ b/ccm-cms/src/com/arsdigita/cms/CMSConfig.java @@ -334,6 +334,12 @@ public final class CMSConfig extends AbstractConfig { private final Parameter m_keywordWeight = new IntegerParameter("com.arsdigita.cms.search.intermedia.keyword_weight", Parameter.OPTIONAL, new Integer(1)); + /** + * Limit the item search to current content section + */ + private final Parameter m_limitToContentSection = new BooleanParameter("com.arsdigita.cms.search.limitToContentSection", + Parameter.OPTIONAL, + Boolean.TRUE); /** * Asset steps to skip, specify asset steps that are not relevant for * specific content types. @@ -506,6 +512,7 @@ public final class CMSConfig extends AbstractConfig { register(m_categoryAuthoringExtension); register(m_hideResetLifecycleLink); register(m_keywordWeight); + register(m_limitToContentSection); register(m_titleWeight); register(m_scoreTitleAndKeywords); register(m_skipAssetSteps); @@ -763,6 +770,10 @@ public final class CMSConfig extends AbstractConfig { return (Integer) get(m_keywordWeight); } + public final boolean limitToContentSection() { + return ((Boolean) get(m_limitToContentSection)).booleanValue(); + } + /** * The relative weight given to title element * within cms:item element when ranking search results diff --git a/ccm-cms/src/com/arsdigita/cms/CMSConfig_parameter.properties b/ccm-cms/src/com/arsdigita/cms/CMSConfig_parameter.properties index 915948242..99befca0c 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSConfig_parameter.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSConfig_parameter.properties @@ -128,6 +128,11 @@ com.arsdigita.cms.search.disableFileAssetExtraction.purpose=Get the search index com.arsdigita.cms.search.disableFileAssetExtraction.example=false com.arsdigita.cms.search.disableFileAssetExtraction.format=[boolean] +com.arsdigita.cms.search.limitToContentSection.title=Limit item search to the current content section +com.arsdigita.cms.search.limitToContentSection.purpose=Setting this parameter to false will allow item search to jump content sections +com.arsdigita.cms.search.limitToContentSection.example=true +com.arsdigita.cms.search.limitToContentSection.format=[boolean] + com.arsdigita.cms.delete_workflow_after_publication.title=Delete Workflow After Publication com.arsdigita.cms.delete_workflow_after_publication.purpose=Whether an item's workflow should be deleted, once the item has been (re)published com.arsdigita.cms.delete_workflow_after_publication.example=true diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ContentSectionPage.java b/ccm-cms/src/com/arsdigita/cms/ui/ContentSectionPage.java index fd3520ff0..a655b2b1a 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ContentSectionPage.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ContentSectionPage.java @@ -242,7 +242,7 @@ public class ContentSectionPage extends CMSPage implements ActionListener { if (m_searchPane == null) { m_searchPane = new LayoutPanel(); m_searchPane.setLeft(new SimpleComponent()); - m_searchPane.setBody(new ItemSearch(ContentItem.DRAFT)); + m_searchPane.setBody(new ItemSearch(ContentItem.DRAFT, CMS.getConfig().limitToContentSection())); } return m_searchPane; } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearch.java b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearch.java index c886ad56e..ec1139aee 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearch.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearch.java @@ -42,29 +42,44 @@ public class ItemSearch extends Form implements Resettable, QueryGenerator { /** * Construct a new ItemSearch component + * Default to limit the search to current content section * * @param context the context for the retrieved items. Should be * {@link ContentItem#DRAFT} or {@link ContentItem#LIVE} */ public ItemSearch(String context) { + this(context, true); + } + + /** + * Construct a new ItemSearch component + * + * @param context the context for the retrieved items. Should be + * {@link ContentItem#DRAFT} or {@link ContentItem#LIVE} + * @param limitToContentSection limit the search to the current content section + */ + public ItemSearch(String context, boolean limitToContentSection) { super("itemSearch", new SimpleContainer()); setMethod("GET"); - m_section = createSearchSection(context); + m_section = createSearchSection(context, limitToContentSection); add(m_section); } - protected ItemSearchSection createSearchSection(String context) { - return new ItemSearchSection(context); + protected ItemSearchSection createSearchSection(String context, boolean limitToContentSection) { + return new ItemSearchSection(context, limitToContentSection); } + @Override public boolean hasQuery(PageState state) { return m_section.hasQuery(state); } + @Override public QuerySpecification getQuerySpecification(PageState state) { return m_section.getQuerySpecification(state); } + @Override public void reset(PageState state) { m_section.reset(state); } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchPopup.java b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchPopup.java index 99157fa2f..b72649c3b 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchPopup.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchPopup.java @@ -54,9 +54,10 @@ public class ItemSearchPopup extends ItemSearch { * * @param context the context for the retrieved items. Should be * {@link ContentItem#DRAFT} or {@link ContentItem#LIVE} + * @param limitToContentSection limit the search to the current content section */ - public ItemSearchPopup(String context) { - super(context); + public ItemSearchPopup(String context, boolean limitToContentSection) { + super(context, limitToContentSection); } // Hide results by default @@ -68,14 +69,14 @@ public class ItemSearchPopup extends ItemSearch { } @Override - protected ItemSearchSection createSearchSection(String context) { - return new ItemSearchSectionPopup(context); + protected ItemSearchSection createSearchSection(String context, boolean limitToContentSection) { + return new ItemSearchSectionPopup(context, limitToContentSection); } private static class ItemSearchSectionPopup extends ItemSearchSection { - public ItemSearchSectionPopup(String context) { - super(context); + public ItemSearchSectionPopup(String context, boolean limitToContentSection) { + super(context, limitToContentSection); } @Override diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchSection.java b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchSection.java index 49d928d2a..3a2b4d7bf 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchSection.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchSection.java @@ -61,9 +61,10 @@ public class ItemSearchSection extends FormSection * * @param context the context for the retrieved items. Should be * {@link ContentItem#DRAFT} or {@link ContentItem#LIVE} + * @param limitToContentSection limit the search to the current content section */ - public ItemSearchSection(String context) { - this(null, context); + public ItemSearchSection(String context, boolean limitToContentSection) { + this(null, context, limitToContentSection); } /** * Construct a new ItemSearchSection component @@ -71,12 +72,13 @@ public class ItemSearchSection extends FormSection * @param context the context for the retrieved items. Should be * {@link ContentItem#DRAFT} or {@link ContentItem#LIVE} * @param name The name of the search parameter for the particular FormSection + * @param limitToContentSection limit the search to the current content section */ - public ItemSearchSection(String name, String context) { + public ItemSearchSection(String name, String context, boolean limitToContentSection) { super(new SimpleContainer()); String thisName = (name == null ? "itemSearch" : name); - m_query = createQueryGenerator(context); + m_query = createQueryGenerator(context, limitToContentSection); m_results = createResultsPane(m_query); addQueryGenerator(this); @@ -98,8 +100,8 @@ public class ItemSearchSection extends FormSection m_results.setVisible(state, false); } - protected ItemQueryComponent createQueryGenerator(String context) { - return new ItemQueryComponent(context); + protected ItemQueryComponent createQueryGenerator(String context, boolean limitToContentSection) { + return new ItemQueryComponent(context, limitToContentSection); } protected Component createResultsPane(QueryGenerator generator) { diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchSectionInline.java b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchSectionInline.java index 764a4a006..ef768a843 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchSectionInline.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchSectionInline.java @@ -55,9 +55,10 @@ public class ItemSearchSectionInline extends ItemSearchSection { * * @param context the context for the retrieved items. Should be * {@link ContentItem#DRAFT} or {@link ContentItem#LIVE} + * @param limitToContentSection limit the search to the current content section */ - public ItemSearchSectionInline(String name, String context) { - super(name, context); + public ItemSearchSectionInline(String name, String context, boolean limitToContentSection) { + super(name, context, limitToContentSection); m_name = name; m_item = new OIDParameter(name + "_itemOID"); } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchWidget.java b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchWidget.java index bdd783e6a..a2ddaeb4f 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchWidget.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchWidget.java @@ -67,6 +67,7 @@ public class ItemSearchWidget extends FormSection private String m_clearName; private ParameterModel m_model; public static final String BEBOP_ITEM_SEARCH = "bebop:itemSearch"; + public static final boolean LIMIT_TO_CONTENT_SECTION = false; private class ItemFragment extends TextField { @@ -125,8 +126,8 @@ public class ItemSearchWidget extends FormSection private ItemSearchWidget parent; - public ItemSearchFragment(String name, String context, ItemSearchWidget parent) { - super(name, context); + public ItemSearchFragment(String name, String context, ItemSearchWidget parent, boolean limitToContentSection) { + super(name, context, limitToContentSection); this.parent = parent; } @@ -234,7 +235,7 @@ public class ItemSearchWidget extends FormSection searchSection.add(m_clear); searchSection.add(m_jsLabel); add(searchSection); - m_searchComponent = new ItemSearchFragment(m_name, ContentItem.DRAFT, this); + m_searchComponent = new ItemSearchFragment(m_name, ContentItem.DRAFT, this, LIMIT_TO_CONTENT_SECTION); add(m_searchComponent); addSubmissionListener(this); addInitListener(this); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/search/ItemQueryComponent.java b/ccm-cms/src/com/arsdigita/cms/ui/search/ItemQueryComponent.java index 74dafb175..3419fbfcf 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/search/ItemQueryComponent.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/search/ItemQueryComponent.java @@ -50,7 +50,7 @@ public class ItemQueryComponent extends BaseQueryComponent { private String m_context; - public ItemQueryComponent(String context) { + public ItemQueryComponent(String context, final boolean limitToContentSection) { m_context = context; if (Search.getConfig().isIntermediaEnabled()) { @@ -69,7 +69,7 @@ public class ItemQueryComponent extends BaseQueryComponent { @Override protected Category[] getRoots(PageState state) { Category[] roots; - if (CMS.getContext().hasContentSection()) { + if (limitToContentSection == true && CMS.getContext().hasContentSection()) { ContentSection section = CMS.getContext().getContentSection(); roots = new Category[]{section.getRootCategory()}; } else { @@ -90,7 +90,7 @@ public class ItemQueryComponent extends BaseQueryComponent { @Override protected ContentSection getContentSection() { - if (CMS.getContext().hasContentSection()) { + if (limitToContentSection == true && CMS.getContext().hasContentSection()) { return CMS.getContext().getContentSection(); } else { return super.getContentSection(); diff --git a/ccm-quasi-aplaws/bundles/devel/cfg/applications.cfg b/ccm-quasi-aplaws/bundles/devel/cfg/applications.cfg index 4a3910efd..fdb35744a 100644 --- a/ccm-quasi-aplaws/bundles/devel/cfg/applications.cfg +++ b/ccm-quasi-aplaws/bundles/devel/cfg/applications.cfg @@ -23,6 +23,7 @@ ccm-cms-types-formsectionitem ccm-cms-types-glossaryitem # -- ccm-cms-types-htmlform # -- ccm-cms-types-inlinesite +ccm-cms-types-image # -- ccm-cms-types-job # -- ccm-cms-types-legalnotice ccm-cms-types-member diff --git a/environment/project.xml.quasi b/environment/project.xml.quasi index 7a0e316ce..861778a1c 100644 --- a/environment/project.xml.quasi +++ b/environment/project.xml.quasi @@ -42,6 +42,7 @@ +