ItemSearch

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
master
quasi 2011-06-27 10:27:44 +00:00
parent a321406405
commit c604013c91
11 changed files with 62 additions and 24 deletions

View File

@ -334,6 +334,12 @@ public final class CMSConfig extends AbstractConfig {
private final Parameter m_keywordWeight = new IntegerParameter("com.arsdigita.cms.search.intermedia.keyword_weight", private final Parameter m_keywordWeight = new IntegerParameter("com.arsdigita.cms.search.intermedia.keyword_weight",
Parameter.OPTIONAL, Parameter.OPTIONAL,
new Integer(1)); 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 * Asset steps to skip, specify asset steps that are not relevant for
* specific content types. * specific content types.
@ -506,6 +512,7 @@ public final class CMSConfig extends AbstractConfig {
register(m_categoryAuthoringExtension); register(m_categoryAuthoringExtension);
register(m_hideResetLifecycleLink); register(m_hideResetLifecycleLink);
register(m_keywordWeight); register(m_keywordWeight);
register(m_limitToContentSection);
register(m_titleWeight); register(m_titleWeight);
register(m_scoreTitleAndKeywords); register(m_scoreTitleAndKeywords);
register(m_skipAssetSteps); register(m_skipAssetSteps);
@ -763,6 +770,10 @@ public final class CMSConfig extends AbstractConfig {
return (Integer) get(m_keywordWeight); return (Integer) get(m_keywordWeight);
} }
public final boolean limitToContentSection() {
return ((Boolean) get(m_limitToContentSection)).booleanValue();
}
/** /**
* The relative weight given to title element * The relative weight given to title element
* within cms:item element when ranking search results * within cms:item element when ranking search results

View File

@ -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.example=false
com.arsdigita.cms.search.disableFileAssetExtraction.format=[boolean] 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.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.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 com.arsdigita.cms.delete_workflow_after_publication.example=true

View File

@ -242,7 +242,7 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
if (m_searchPane == null) { if (m_searchPane == null) {
m_searchPane = new LayoutPanel(); m_searchPane = new LayoutPanel();
m_searchPane.setLeft(new SimpleComponent()); 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; return m_searchPane;
} }

View File

@ -42,29 +42,44 @@ public class ItemSearch extends Form implements Resettable, QueryGenerator {
/** /**
* Construct a new <code>ItemSearch</code> component * Construct a new <code>ItemSearch</code> component
* Default to limit the search to current content section
* *
* @param context the context for the retrieved items. Should be * @param context the context for the retrieved items. Should be
* {@link ContentItem#DRAFT} or {@link ContentItem#LIVE} * {@link ContentItem#DRAFT} or {@link ContentItem#LIVE}
*/ */
public ItemSearch(String context) { public ItemSearch(String context) {
this(context, true);
}
/**
* Construct a new <code>ItemSearch</code> 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()); super("itemSearch", new SimpleContainer());
setMethod("GET"); setMethod("GET");
m_section = createSearchSection(context); m_section = createSearchSection(context, limitToContentSection);
add(m_section); add(m_section);
} }
protected ItemSearchSection createSearchSection(String context) { protected ItemSearchSection createSearchSection(String context, boolean limitToContentSection) {
return new ItemSearchSection(context); return new ItemSearchSection(context, limitToContentSection);
} }
@Override
public boolean hasQuery(PageState state) { public boolean hasQuery(PageState state) {
return m_section.hasQuery(state); return m_section.hasQuery(state);
} }
@Override
public QuerySpecification getQuerySpecification(PageState state) { public QuerySpecification getQuerySpecification(PageState state) {
return m_section.getQuerySpecification(state); return m_section.getQuerySpecification(state);
} }
@Override
public void reset(PageState state) { public void reset(PageState state) {
m_section.reset(state); m_section.reset(state);
} }

View File

@ -54,9 +54,10 @@ public class ItemSearchPopup extends ItemSearch {
* *
* @param context the context for the retrieved items. Should be * @param context the context for the retrieved items. Should be
* {@link ContentItem#DRAFT} or {@link ContentItem#LIVE} * {@link ContentItem#DRAFT} or {@link ContentItem#LIVE}
* @param limitToContentSection limit the search to the current content section
*/ */
public ItemSearchPopup(String context) { public ItemSearchPopup(String context, boolean limitToContentSection) {
super(context); super(context, limitToContentSection);
} }
// Hide results by default // Hide results by default
@ -68,14 +69,14 @@ public class ItemSearchPopup extends ItemSearch {
} }
@Override @Override
protected ItemSearchSection createSearchSection(String context) { protected ItemSearchSection createSearchSection(String context, boolean limitToContentSection) {
return new ItemSearchSectionPopup(context); return new ItemSearchSectionPopup(context, limitToContentSection);
} }
private static class ItemSearchSectionPopup extends ItemSearchSection { private static class ItemSearchSectionPopup extends ItemSearchSection {
public ItemSearchSectionPopup(String context) { public ItemSearchSectionPopup(String context, boolean limitToContentSection) {
super(context); super(context, limitToContentSection);
} }
@Override @Override

View File

@ -61,9 +61,10 @@ public class ItemSearchSection extends FormSection
* *
* @param context the context for the retrieved items. Should be * @param context the context for the retrieved items. Should be
* {@link ContentItem#DRAFT} or {@link ContentItem#LIVE} * {@link ContentItem#DRAFT} or {@link ContentItem#LIVE}
* @param limitToContentSection limit the search to the current content section
*/ */
public ItemSearchSection(String context) { public ItemSearchSection(String context, boolean limitToContentSection) {
this(null, context); this(null, context, limitToContentSection);
} }
/** /**
* Construct a new <code>ItemSearchSection</code> component * Construct a new <code>ItemSearchSection</code> component
@ -71,12 +72,13 @@ public class ItemSearchSection extends FormSection
* @param context the context for the retrieved items. Should be * @param context the context for the retrieved items. Should be
* {@link ContentItem#DRAFT} or {@link ContentItem#LIVE} * {@link ContentItem#DRAFT} or {@link ContentItem#LIVE}
* @param name The name of the search parameter for the particular FormSection * @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()); super(new SimpleContainer());
String thisName = (name == null ? "itemSearch" : name); String thisName = (name == null ? "itemSearch" : name);
m_query = createQueryGenerator(context); m_query = createQueryGenerator(context, limitToContentSection);
m_results = createResultsPane(m_query); m_results = createResultsPane(m_query);
addQueryGenerator(this); addQueryGenerator(this);
@ -98,8 +100,8 @@ public class ItemSearchSection extends FormSection
m_results.setVisible(state, false); m_results.setVisible(state, false);
} }
protected ItemQueryComponent createQueryGenerator(String context) { protected ItemQueryComponent createQueryGenerator(String context, boolean limitToContentSection) {
return new ItemQueryComponent(context); return new ItemQueryComponent(context, limitToContentSection);
} }
protected Component createResultsPane(QueryGenerator generator) { protected Component createResultsPane(QueryGenerator generator) {

View File

@ -55,9 +55,10 @@ public class ItemSearchSectionInline extends ItemSearchSection {
* *
* @param context the context for the retrieved items. Should be * @param context the context for the retrieved items. Should be
* {@link ContentItem#DRAFT} or {@link ContentItem#LIVE} * {@link ContentItem#DRAFT} or {@link ContentItem#LIVE}
* @param limitToContentSection limit the search to the current content section
*/ */
public ItemSearchSectionInline(String name, String context) { public ItemSearchSectionInline(String name, String context, boolean limitToContentSection) {
super(name, context); super(name, context, limitToContentSection);
m_name = name; m_name = name;
m_item = new OIDParameter(name + "_itemOID"); m_item = new OIDParameter(name + "_itemOID");
} }

View File

@ -67,6 +67,7 @@ public class ItemSearchWidget extends FormSection
private String m_clearName; private String m_clearName;
private ParameterModel m_model; private ParameterModel m_model;
public static final String BEBOP_ITEM_SEARCH = "bebop:itemSearch"; public static final String BEBOP_ITEM_SEARCH = "bebop:itemSearch";
public static final boolean LIMIT_TO_CONTENT_SECTION = false;
private class ItemFragment extends TextField { private class ItemFragment extends TextField {
@ -125,8 +126,8 @@ public class ItemSearchWidget extends FormSection
private ItemSearchWidget parent; private ItemSearchWidget parent;
public ItemSearchFragment(String name, String context, ItemSearchWidget parent) { public ItemSearchFragment(String name, String context, ItemSearchWidget parent, boolean limitToContentSection) {
super(name, context); super(name, context, limitToContentSection);
this.parent = parent; this.parent = parent;
} }
@ -234,7 +235,7 @@ public class ItemSearchWidget extends FormSection
searchSection.add(m_clear); searchSection.add(m_clear);
searchSection.add(m_jsLabel); searchSection.add(m_jsLabel);
add(searchSection); 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); add(m_searchComponent);
addSubmissionListener(this); addSubmissionListener(this);
addInitListener(this); addInitListener(this);

View File

@ -50,7 +50,7 @@ public class ItemQueryComponent extends BaseQueryComponent {
private String m_context; private String m_context;
public ItemQueryComponent(String context) { public ItemQueryComponent(String context, final boolean limitToContentSection) {
m_context = context; m_context = context;
if (Search.getConfig().isIntermediaEnabled()) { if (Search.getConfig().isIntermediaEnabled()) {
@ -69,7 +69,7 @@ public class ItemQueryComponent extends BaseQueryComponent {
@Override @Override
protected Category[] getRoots(PageState state) { protected Category[] getRoots(PageState state) {
Category[] roots; Category[] roots;
if (CMS.getContext().hasContentSection()) { if (limitToContentSection == true && CMS.getContext().hasContentSection()) {
ContentSection section = CMS.getContext().getContentSection(); ContentSection section = CMS.getContext().getContentSection();
roots = new Category[]{section.getRootCategory()}; roots = new Category[]{section.getRootCategory()};
} else { } else {
@ -90,7 +90,7 @@ public class ItemQueryComponent extends BaseQueryComponent {
@Override @Override
protected ContentSection getContentSection() { protected ContentSection getContentSection() {
if (CMS.getContext().hasContentSection()) { if (limitToContentSection == true && CMS.getContext().hasContentSection()) {
return CMS.getContext().getContentSection(); return CMS.getContext().getContentSection();
} else { } else {
return super.getContentSection(); return super.getContentSection();

View File

@ -23,6 +23,7 @@ ccm-cms-types-formsectionitem
ccm-cms-types-glossaryitem ccm-cms-types-glossaryitem
# -- ccm-cms-types-htmlform # -- ccm-cms-types-htmlform
# -- ccm-cms-types-inlinesite # -- ccm-cms-types-inlinesite
ccm-cms-types-image
# -- ccm-cms-types-job # -- ccm-cms-types-job
# -- ccm-cms-types-legalnotice # -- ccm-cms-types-legalnotice
ccm-cms-types-member ccm-cms-types-member

View File

@ -42,6 +42,7 @@
<ccm:application name="ccm-cms-types-glossaryitem"/> <ccm:application name="ccm-cms-types-glossaryitem"/>
<!-- <ccm:application name="ccm-cms-types-htmlform"/> --> <!-- <ccm:application name="ccm-cms-types-htmlform"/> -->
<!-- <ccm:application name="ccm-cms-types-inlinesite"/> --> <!-- <ccm:application name="ccm-cms-types-inlinesite"/> -->
<ccm:application name="ccm-cms-types-image"/>
<!-- <ccm:application name="ccm-cms-types-job"/> --> <!-- <ccm:application name="ccm-cms-types-job"/> -->
<!-- <ccm:application name="ccm-cms-types-legalnotice"/> --> <!-- <ccm:application name="ccm-cms-types-legalnotice"/> -->
<ccm:application name="ccm-cms-types-member"/> <ccm:application name="ccm-cms-types-member"/>