diff --git a/ccm-cms/src/com/arsdigita/cms/CMSConfig.java b/ccm-cms/src/com/arsdigita/cms/CMSConfig.java index 99722323b..b9e56a08e 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSConfig.java +++ b/ccm-cms/src/com/arsdigita/cms/CMSConfig.java @@ -543,6 +543,15 @@ public final class CMSConfig extends AbstractConfig { new StringParameter( "com.arsdigita.cms.item_search.default_tab", Parameter.REQUIRED, "browse"); + private final Parameter m_itemSearchFlatBrowsePaneEnable = new BooleanParameter( + "com.arsdigita.cms.item_search.flat_browse_pane.enable", + Parameter.REQUIRED, + true); + private final Parameter m_itemSearchFlatBrowsePanePageSize = new IntegerParameter( + "com.arsdigita.cms.item_search.flat_browse_pane.page_size", + Parameter.REQUIRED, + 20); + ///////////////////////////////////////////// // FolderBrowse ///////////////////////////////////////////// @@ -595,7 +604,8 @@ public final class CMSConfig extends AbstractConfig { private final Parameter m_imageBrowserThumbnailMaxHeight = new IntegerParameter( "com.arsdigita.cms.image_browser.thumbnail_max_height", Parameter.REQUIRED, - 50); + 50); + // /////////////////////////////////////////// // publishToFile package related parameter @@ -664,7 +674,7 @@ public final class CMSConfig extends AbstractConfig { register(m_hideTextAssetUploadFile); register(m_allowCategoryCreateUseContext); register(m_allowContentCreateInSectionListing); - register(m_hideLegacyPublicSiteLink); + register(m_hideLegacyPublicSiteLink); // Content Center (Workspace) config related parameters register(m_contentCenterMap); @@ -695,6 +705,9 @@ public final class CMSConfig extends AbstractConfig { // register(m_disableItemPfs); // register(m_publishToFileClass); + register(m_itemSearchFlatBrowsePaneEnable); + register(m_itemSearchFlatBrowsePanePageSize); + loadInfo(); } @@ -1142,5 +1155,13 @@ public final class CMSConfig extends AbstractConfig { public Integer getImageBrowserThumbnailMaxHeight() { return (Integer) get(m_imageBrowserThumbnailMaxHeight); } + + public Boolean getItemSearchFlatBrowsePaneEnable() { + return (Boolean) get(m_itemSearchFlatBrowsePaneEnable); + } + + public Integer getItemSearchFlatBrowsePanePageSize() { + return (Integer) get(m_itemSearchFlatBrowsePanePageSize); + } } diff --git a/ccm-cms/src/com/arsdigita/cms/CMSConfig_parameter.properties b/ccm-cms/src/com/arsdigita/cms/CMSConfig_parameter.properties index f5511cc25..0a9d1849f 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSConfig_parameter.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSConfig_parameter.properties @@ -240,10 +240,21 @@ com.arsdigita.cms.allow_content_create_in_section_listing.example=true com.arsdigita.cms.allow_content_create_in_section_listing.format=[boolean] com.arsdigita.cms.item_search.default_tab.title=Set the default table for ItemSearchWidget -com.arsdigita.cms.item_search.default_tab.purpose=Select either "browse" or "search" for default tab +com.arsdigita.cms.item_search.default_tab.purpose=Select either "browse", "flatBrowse" or "search" for default tab com.arsdigita.cms.item_search.default_tab.example=browse com.arsdigita.cms.item_search.default_tab.format=[string] +com.arsdigita.cms.item_search.flat_browse_pane.enable.title=Enables the flat browse pane of the item search widget +com.arsdigita.cms.item_search.flat_browse_pane.enable.purpose=Enables the flat browse pane of the item search widget +com.arsdigita.cms.item_search.flat_browse_pane.enable.example=true +com.arsdigita.cms.item_search.flat_browse_pane.enable.format=[boolean] + +com.arsdigita.cms.item_search.flat_browse_pane.page_size.title=Page size for the flat browse pane +com.arsdigita.cms.item_search.flat_browse_pane.page_size.purpose=Sets the page size for the flat browse pane +com.arsdigita.cms.item_search.flat_browse_pane.page_size.example=20 +com.arsdigita.cms.item_search.flat_browse_pane.page_size.format=[integer] + + com.arsdigita.cms.folder_browse_list_size.title=List size for the folder browse widget com.arsdigita.cms.folder_browse_list_size.purpose=Allows to change the number of items displayed on each page of the folder browse widget com.arsdigita.cms.folder_browse_list_size.example=20 diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchFlatBrowsePane.java b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchFlatBrowsePane.java index 08a32e031..053be45d1 100644 --- a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchFlatBrowsePane.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchFlatBrowsePane.java @@ -28,6 +28,7 @@ import com.arsdigita.bebop.table.TableColumn; import com.arsdigita.bebop.table.TableColumnModel; import com.arsdigita.bebop.table.TableModel; import com.arsdigita.bebop.table.TableModelBuilder; +import com.arsdigita.cms.CMSConfig; import com.arsdigita.cms.ContentBundle; import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentPage; @@ -59,6 +60,7 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener, private final Table resultsTable; private final Paginator paginator; private final StringParameter queryParam; + private final static CMSConfig CMS_CONFIG = CMSConfig.getInstance(); public ItemSearchFlatBrowsePane(final String name) { super(name); @@ -67,19 +69,20 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener, queryParam = new StringParameter(QUERY_PARAM); - final BoxPanel boxPanel = new BoxPanel(BoxPanel.HORIZONTAL); + final BoxPanel boxPanel = new BoxPanel(BoxPanel.HORIZONTAL); boxPanel.add(new Label(GlobalizationUtil.globalize("cms.ui.item_search.flat.filter"))); - final TextField filter = new TextField(new StringParameter(QUERY_PARAM)); + final TextField filter = new TextField(new StringParameter(QUERY_PARAM)); boxPanel.add(filter); boxPanel.add(new Submit(FILTER_SUBMIT, GlobalizationUtil.globalize("cms.ui.item_search.flat.filter.submit"))); mainPanel.add(boxPanel); resultsTable = new ResultsTable(); - paginator = new Paginator((PaginationModelBuilder) resultsTable.getModelBuilder(), 5); + paginator = new Paginator((PaginationModelBuilder) resultsTable.getModelBuilder(), + CMS_CONFIG.getItemSearchFlatBrowsePanePageSize()); mainPanel.add(paginator); - mainPanel.add(resultsTable); - + mainPanel.add(resultsTable); + add(mainPanel); addInitListener(this); @@ -100,6 +103,7 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener, if ((query == null) || query.isEmpty()) { data.setParameter(QUERY_PARAM, new ParameterData(queryParam, state.getValue(new StringParameter(ItemSearchPopup.QUERY)))); + state.setValue(queryParam, data.getParameter(QUERY_PARAM).getValue()); } } @@ -146,13 +150,13 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener, private RequestLocal collection = new RequestLocal(); public TableModel makeModel(final Table table, final PageState state) { - + if (collection.get(state) == null) { query(state); - } + } ((DataCollection) collection.get(state)).setRange(paginator.getFirst(state), paginator.getLast(state) + 1); - + return new ResultsTableModel(table, state, (DataCollection) collection.get(state)); } @@ -160,10 +164,10 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener, if (collection.get(state) == null) { query(state); } - + //((DataCollection)collection.get(state)).setRange(paginator.getFirst(state), paginator.getLast(state) + 1); - return (int) ((DataCollection)collection.get(state)).size(); + return (int) ((DataCollection) collection.get(state)).size(); } public boolean isVisible(PageState state) { @@ -182,12 +186,12 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener, final String query = (String) state.getValue(queryParam); if ((query != null) && !query.isEmpty()) { - ((DataCollection)collection.get(state)).addFilter(String.format( + ((DataCollection) collection.get(state)).addFilter(String.format( "(lower(%s) like lower('%%%s%%')) or (lower(%s) like lower('%%%s%%'))", ContentItem.NAME, query, ContentPage.TITLE, query)); } - + ((DataCollection) collection.get(state)).addOrder("title asc, name asc"); } @@ -204,17 +208,6 @@ public class ItemSearchFlatBrowsePane extends Form implements FormInitListener, this.collection = collection; - /* - * final Session session = SessionManager.getSession(); final BigDecimal typeId = (BigDecimal) - * state.getValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM)); if (typeId == null) { collection = - * session.retrieve(ContentPage.BASE_DATA_OBJECT_TYPE); } else { final ContentType type = new - * ContentType(typeId); collection = session.retrieve(type.getClassName()); } - * - * final String query = (String) state.getValue(queryParam); if ((query != null) && !query.isEmpty()) { - * collection.addFilter(String.format( "(lower(%s) like lower('%%%s%%')) or (lower(%s) like - * lower('%%%s%%'))", ContentItem.NAME, query, ContentPage.TITLE, query)); - } - */ } public int getColumnCount() { diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchPage.java b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchPage.java index c08bfcbc7..a78710178 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchPage.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchPage.java @@ -62,7 +62,7 @@ public class ItemSearchPage extends CMSPage { private static final CMSConfig s_conf = CMSConfig.getInstance(); private static final boolean LIMIT_TO_CONTENT_SECTION = false; public static final String CONTENT_SECTION = "section_id"; - private boolean showFlatBrowsePane = false; + private final boolean showFlatBrowsePane; /** * Construct a new ItemSearchPage @@ -75,6 +75,9 @@ public class ItemSearchPage extends CMSPage { addGlobalStateParam(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM)); addGlobalStateParam(new StringParameter(ItemSearchPopup.WIDGET_PARAM)); addGlobalStateParam(new StringParameter("searchWidget")); + + showFlatBrowsePane = s_conf.getItemSearchFlatBrowsePaneEnable(); + m_sectionId = new BigDecimalParameter(CONTENT_SECTION); addGlobalStateParam(m_sectionId); @@ -152,15 +155,16 @@ public class ItemSearchPage extends CMSPage { addToPane(pane, "search", getSearchPane()); // addToPane(pane, "create", getCreatePane()); - if (s_conf.getItemSearchDefaultTab().equals("browse")) { + if ("browse".equals(s_conf.getItemSearchDefaultTab())) { pane.setDefaultPane(m_browse); } - if (s_conf.getItemSearchDefaultTab().equals("search")) { + if ("search".equals(s_conf.getItemSearchDefaultTab())) { pane.setDefaultPane(m_search); } - - if (showFlatBrowsePane) { + if ("flatBrowse".equals(s_conf.getItemSearchDefaultTab()) && showFlatBrowsePane) { pane.setDefaultPane(m_flatBrowse); + } else { + pane.setDefaultPane(m_browse); } //pane.addActionListener(this);