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",
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

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.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

View File

@ -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;
}

View File

@ -42,29 +42,44 @@ public class ItemSearch extends Form implements Resettable, QueryGenerator {
/**
* 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
* {@link ContentItem#DRAFT} or {@link ContentItem#LIVE}
*/
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());
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);
}

View File

@ -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

View File

@ -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 <code>ItemSearchSection</code> 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) {

View File

@ -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");
}

View File

@ -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);

View File

@ -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();

View File

@ -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

View File

@ -42,6 +42,7 @@
<ccm:application name="ccm-cms-types-glossaryitem"/>
<!-- <ccm:application name="ccm-cms-types-htmlform"/> -->
<!-- <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-legalnotice"/> -->
<ccm:application name="ccm-cms-types-member"/>