diff --git a/ccm-cms/src/com/arsdigita/cms/CMSConfig.java b/ccm-cms/src/com/arsdigita/cms/CMSConfig.java index 82d32a683..0f9540bba 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSConfig.java +++ b/ccm-cms/src/com/arsdigita/cms/CMSConfig.java @@ -28,7 +28,6 @@ package com.arsdigita.cms; * // URL resource: protocol handler removal: START * Will be removed as soon as a stable release 6.6 is created. */ - import com.arsdigita.bebop.SimpleComponent; import com.arsdigita.bebop.form.DHTMLEditor; import com.arsdigita.categorization.Category; @@ -117,318 +116,223 @@ public final class CMSConfig extends AbstractConfig { return s_config; } - /** * Storage (map) for method getAssetStepsToSkip(ContentType type) to store * mapping of steps that are deemed irrelevant for the passid in type. */ - private static Map s_skipAssetSteps = null; - + private static Map s_skipAssetSteps = null; /** * Item category add form speciofies Subclass of ItemCategoryForm * to use for the assign categories step. * Used in c.ad.cms.ui.authoring.ItemCategoryStep */ - private final Parameter - m_categoryAuthoringAddForm = new SpecificClassParameter - ("com.arsdigita.cms.category_authoring_add_form", - Parameter.REQUIRED, - ItemCategoryForm.class, - SimpleComponent.class); - + private final Parameter m_categoryAuthoringAddForm = new SpecificClassParameter("com.arsdigita.cms.category_authoring_add_form", + Parameter.REQUIRED, + ItemCategoryForm.class, + SimpleComponent.class); /** * Path for the default item template. Path is relative to the * Template Root path. */ - private final Parameter - m_defaultItemTemplatePath = new StringParameter - ("com.arsdigita.cms.default_item_template_path", - Parameter.REQUIRED, "/default/item.jsp"); - + private final Parameter m_defaultItemTemplatePath = new StringParameter("com.arsdigita.cms.default_item_template_path", + Parameter.REQUIRED, "/default/item.jsp"); /** * Path for the default folder template. Path is relative to the * Template Root path. */ - private final Parameter - m_defaultFolderTemplatePath = new StringParameter - ("com.arsdigita.cms.default_folder_template_path", - Parameter.REQUIRED, "/default/folder.jsp"); + private final Parameter m_defaultFolderTemplatePath = new StringParameter("com.arsdigita.cms.default_folder_template_path", + Parameter.REQUIRED, "/default/folder.jsp"); /** * Path for the default template folder. Path is relative to webapp root */ - private final Parameter - m_templateRootPath = new StringParameter - ("com.arsdigita.cms.template_root_path", - Parameter.REQUIRED, "/packages/content-section/templates"); - - - // URL resource: protocol handler removal: START - // remove: - // try { - // m_itemAdapters = new URLParameter - // ("com.arsdigita.cms.item_adapters", - // Parameter.REQUIRED, - // new URL("resource:WEB-INF/resources/cms-item-adapters.xml")); - // } catch (MalformedURLException ex) { - // throw new UncheckedWrapperException("Cannot parse URL", ex); - // } - // ADD: + private final Parameter m_templateRootPath = new StringParameter("com.arsdigita.cms.template_root_path", + Parameter.REQUIRED, "/packages/content-section/templates"); + // URL resource: protocol handler removal: START + // remove: + // try { + // m_itemAdapters = new URLParameter + // ("com.arsdigita.cms.item_adapters", + // Parameter.REQUIRED, + // new URL("resource:WEB-INF/resources/cms-item-adapters.xml")); + // } catch (MalformedURLException ex) { + // throw new UncheckedWrapperException("Cannot parse URL", ex); + // } + // ADD: /** * Item Adapters File, path to an XML resource containing adapter * specifications. Path is relative to webapp root. */ - private final Parameter - m_itemAdapters = new ResourceParameter - ("com.arsdigita.cms.item_adapters", - Parameter.REQUIRED, - "/WEB-INF/resources/cms-item-adapters.xml"); - // URL resource: protocol handler removal: END - + private final Parameter m_itemAdapters = new ResourceParameter("com.arsdigita.cms.item_adapters", + Parameter.REQUIRED, + "/WEB-INF/resources/cms-item-adapters.xml"); + // URL resource: protocol handler removal: END /** * Use streamlined content creation: upon item creation, * automatically open authoring steps and forward to the next step */ - private final Parameter - m_useStreamlinedCreation = new BooleanParameter - ("com.arsdigita.cms.use_streamlined_creation", - Parameter.REQUIRED, new Boolean(true)); - + private final Parameter m_useStreamlinedCreation = new BooleanParameter("com.arsdigita.cms.use_streamlined_creation", + Parameter.REQUIRED, new Boolean(true)); /** * DHTML Editor Configuration for use in CMS module, lists the * config object name and Javascript source location for its definition. */ - private final Parameter - m_dhtmlEditorConfig = new DHTMLEditorConfigParameter - ("com.arsdigita.cms.dhtml_editor_config", - Parameter.REQUIRED, - new DHTMLEditor.Config( "XinhaConfig", - "/assets/xinha/CCMcmsXinhaConfig.js") ); - // previous parameter definition: - // > DHTMLEditor.Config.STANDARD); < - // didn't work because of broken unmarshalling (cf. similiar problem - // with ResourceParameter and patch provided by Brad). It work for - // HTMLArea, because configuration was hard coded into xsl(!). - // Additionally, we would like to use a specific configuration for cms - // to include cms specific functions (like access to internal . - // content items for links and internal image assets, which may not - // be accessable by other modules which use DHTMLeditor. - // Would be bad style to configure a cms specific parameter in core. - + private final Parameter m_dhtmlEditorConfig = new DHTMLEditorConfigParameter("com.arsdigita.cms.dhtml_editor_config", + Parameter.REQUIRED, + new DHTMLEditor.Config("XinhaConfig", + "/assets/xinha/CCMcmsXinhaConfig.js")); + // previous parameter definition: + // > DHTMLEditor.Config.STANDARD); < + // didn't work because of broken unmarshalling (cf. similiar problem + // with ResourceParameter and patch provided by Brad). It work for + // HTMLArea, because configuration was hard coded into xsl(!). + // Additionally, we would like to use a specific configuration for cms + // to include cms specific functions (like access to internal . + // content items for links and internal image assets, which may not + // be accessable by other modules which use DHTMLeditor. + // Would be bad style to configure a cms specific parameter in core. /** * Defines which plugins to use, e.g.TableOperations,CSS * Format: [string,string,string] */ - private final Parameter - m_dhtmlEditorPlugins = new StringArrayParameter - ("com.arsdigita.cms.dhtml_editor_plugins", - Parameter.OPTIONAL, - null); - + private final Parameter m_dhtmlEditorPlugins = new StringArrayParameter("com.arsdigita.cms.dhtml_editor_plugins", + Parameter.OPTIONAL, + null); /** * Prevent undesirable functions from being made available, * eg images should only be added through the cms methods. */ - private final Parameter - m_dhtmlEditorHiddenButtons = new StringArrayParameter - ("com.arsdigita.cms.dhtml_editor_hidden_buttons", - Parameter.OPTIONAL, - null); - + private final Parameter m_dhtmlEditorHiddenButtons = new StringArrayParameter("com.arsdigita.cms.dhtml_editor_hidden_buttons", + Parameter.OPTIONAL, + null); /** * Hide section admin tabs from users without administrative rights. */ - private final Parameter - m_hideAdminTabs = new BooleanParameter - ("com.arsdigita.cms.hide_admin_tabs", - Parameter.REQUIRED, new Boolean(false)); - + private final Parameter m_hideAdminTabs = new BooleanParameter("com.arsdigita.cms.hide_admin_tabs", + Parameter.REQUIRED, new Boolean(false)); /** * Hide Folder Index Checkbox from folder view */ - private final Parameter - m_hideFolderIndexCheckbox = new BooleanParameter - ("com.arsdigita.cms.hide_folder_index_checkbox", - Parameter.REQUIRED, new Boolean(false)); - + private final Parameter m_hideFolderIndexCheckbox = new BooleanParameter("com.arsdigita.cms.hide_folder_index_checkbox", + Parameter.REQUIRED, new Boolean(false)); /** * Hide launch date parameter on all forms and displays where it's used. */ - private final Parameter - m_hideLaunchDate = new BooleanParameter - ("com.arsdigita.cms.hide_launch_date", - Parameter.REQUIRED, new Boolean(true)); + private final Parameter m_hideLaunchDate = new BooleanParameter("com.arsdigita.cms.hide_launch_date", + Parameter.REQUIRED, new Boolean(true)); /** * Require the launch date parameter to be set by the content author. */ - private final Parameter - m_requireLaunchDate = new BooleanParameter - ("com.arsdigita.cms.require_launch_date", - Parameter.REQUIRED, new Boolean(false)); + private final Parameter m_requireLaunchDate = new BooleanParameter("com.arsdigita.cms.require_launch_date", + Parameter.REQUIRED, new Boolean(false)); /** * Hide the templates tab on the item admin page. */ - private final Parameter - m_hideTemplatesTab = new BooleanParameter - ("com.arsdigita.cms.hide_templates_tab", - Parameter.REQUIRED, new Boolean(false)); - + private final Parameter m_hideTemplatesTab = new BooleanParameter("com.arsdigita.cms.hide_templates_tab", + Parameter.REQUIRED, new Boolean(false)); /** * Hide the upload file link in the editing of a text asset. */ - private final Parameter - m_hideTextAssetUploadFile = new BooleanParameter - ("com.arsdigita.cms.hide_text_asset_upload_file", - Parameter.REQUIRED, - new Boolean(false)); - + private final Parameter m_hideTextAssetUploadFile = new BooleanParameter("com.arsdigita.cms.hide_text_asset_upload_file", + Parameter.REQUIRED, + new Boolean(false)); /** * Hide timezone labels (if, for example, all users will be in the * same timezone and such information would be unnecessary) */ - private final Parameter - m_hideTimezone = new BooleanParameter - ("com.arsdigita.cms.hide_timezone", - Parameter.REQUIRED, new Boolean(false)); - + private final Parameter m_hideTimezone = new BooleanParameter("com.arsdigita.cms.hide_timezone", + Parameter.REQUIRED, new Boolean(false)); /** * Hide User Defined Content Types UI */ - private final Parameter - m_hideUDCTUI = new BooleanParameter - ("com.arsdigita.cms.hide_udct_ui", - Parameter.REQUIRED, new Boolean(false)); - - + private final Parameter m_hideUDCTUI = new BooleanParameter("com.arsdigita.cms.hide_udct_ui", + Parameter.REQUIRED, new Boolean(false)); /** * Specifies the name of the class to use as a PublishLifecycleListener */ - private final Parameter - m_publishLifecycleListenerClass = new StringParameter - ("com.arsdigita.cms.publish_lifecycle_listener_class", - Parameter.OPTIONAL, PublishLifecycleListener.class.getName()); - - + private final Parameter m_publishLifecycleListenerClass = new StringParameter("com.arsdigita.cms.publish_lifecycle_listener_class", + Parameter.OPTIONAL, PublishLifecycleListener.class.getName()); /** * Wether the Wysiwyg editor should clear the text of MSWord tags, * everytime the user clicks on 'Save' */ - private final Parameter - m_saveTextCleansWordTags = new BooleanParameter - ("com.arsdigita.cms.save_text_cleans_word_tags", - Parameter.OPTIONAL, new Boolean(false)); - + private final Parameter m_saveTextCleansWordTags = new BooleanParameter("com.arsdigita.cms.save_text_cleans_word_tags", + Parameter.OPTIONAL, new Boolean(false)); /** * Hide Additional Resource Fields on RelatedLinkPropertyForm */ - private final Parameter - m_hideAdditionalResourceFields = new BooleanParameter - ("com.arsdigita.cms.contentassets.ui."+ - "RelatedLinkPropertyForm.hideAdditionalResourceFields", - Parameter.REQUIRED, new Boolean(false)); - + private final Parameter m_hideAdditionalResourceFields = new BooleanParameter("com.arsdigita.cms.contentassets.ui." + + "RelatedLinkPropertyForm.hideAdditionalResourceFields", + Parameter.REQUIRED, new Boolean(false)); /** * Get the search indexing not to process FileAssets, * eg to avoid PDF slowdowns */ - private final Parameter - m_disableFileAssetExtraction = new BooleanParameter - ("com.arsdigita.cms.search.disableFileAssetExtraction", - Parameter.REQUIRED, new Boolean(false)); - + private final Parameter m_disableFileAssetExtraction = new BooleanParameter("com.arsdigita.cms.search.disableFileAssetExtraction", + Parameter.REQUIRED, new Boolean(false)); /** * Whether an item's workflow should be deleted, once the item * has been (re)published */ - private final Parameter - m_deleteWorkflowAfterPublication = new BooleanParameter - ("com.arsdigita.cms.delete_workflow_after_publication", - Parameter.REQUIRED, new Boolean(true)); - + private final Parameter m_deleteWorkflowAfterPublication = new BooleanParameter("com.arsdigita.cms.delete_workflow_after_publication", + Parameter.REQUIRED, new Boolean(true)); /** * Defines the number of days ahead that are covered in the * 'Soon Expired' tab */ - private final Parameter - m_soonExpiredTimespanDays = new IntegerParameter - ("com.arsdigita.cms.soon_expired_timespan_days", - Parameter.REQUIRED, new Integer(14)); - + private final Parameter m_soonExpiredTimespanDays = new IntegerParameter("com.arsdigita.cms.soon_expired_timespan_days", + Parameter.REQUIRED, new Integer(14)); /** * Defines the number of months ahead that are covered in the * 'Soon Expired' tab */ - private final Parameter - m_soonExpiredTimespanMonths = new IntegerParameter - ("com.arsdigita.cms.soon_expired_timespan_months", - Parameter.REQUIRED, new Integer(1)); - + private final Parameter m_soonExpiredTimespanMonths = new IntegerParameter("com.arsdigita.cms.soon_expired_timespan_months", + Parameter.REQUIRED, new Integer(1)); /** * Does a redirect to the unpublished item generate not found error? */ - private final Parameter - m_unpublishedNotFound = new BooleanParameter - ("com.arsdigita.cms.unpublished_not_found", - Parameter.REQUIRED, new Boolean(true)); - + private final Parameter m_unpublishedNotFound = new BooleanParameter("com.arsdigita.cms.unpublished_not_found", + Parameter.REQUIRED, new Boolean(true)); /** * Links created through browse interfaces should only be within the * same subsite */ - private final Parameter - m_linksOnlyInSameSubsite = new BooleanParameter - ("com.arsdigita.cms.browse_links_in_same_subsite_only", - Parameter.REQUIRED, new Boolean(false)); - + private final Parameter m_linksOnlyInSameSubsite = new BooleanParameter("com.arsdigita.cms.browse_links_in_same_subsite_only", + Parameter.REQUIRED, new Boolean(false)); /** * Item category step extension hook: Subclass of ItemCategoryExtension * which adds extension actions for the category authoring step */ - private final Parameter - m_categoryAuthoringExtension = new SpecificClassParameter - ("com.arsdigita.cms.category_authoring_extension", - Parameter.REQUIRED, - ItemCategoryExtension.class, - ItemCategoryExtension.class); - + private final Parameter m_categoryAuthoringExtension = new SpecificClassParameter("com.arsdigita.cms.category_authoring_extension", + Parameter.REQUIRED, + ItemCategoryExtension.class, + ItemCategoryExtension.class); /** * Link available to reset lifecycle on republish. If false don't display * the link otherwise display. */ - private final Parameter - m_hideResetLifecycleLink = new BooleanParameter - ("com.arsdigita.cms.hide_reset_lifecycle_link", - Parameter.OPTIONAL, new Boolean(true)); - + private final Parameter m_hideResetLifecycleLink = new BooleanParameter("com.arsdigita.cms.hide_reset_lifecycle_link", + Parameter.OPTIONAL, new Boolean(true)); /** * Whether to include INPATH operators to contains clause in intermedia search */ - private final Parameter - m_scoreTitleAndKeywords = new BooleanParameter - ("com.arsdigita.cms.search.score_title_and_keywords", - Parameter.OPTIONAL, - Boolean.FALSE); - + private final Parameter m_scoreTitleAndKeywords = new BooleanParameter("com.arsdigita.cms.search.score_title_and_keywords", + Parameter.OPTIONAL, + Boolean.FALSE); /** * Title Weight, the relative weight given to title element within * cms:item when ranking search results (only used by interMedia) */ - private final Parameter - m_titleWeight = new IntegerParameter - ("com.arsdigita.cms.search.intermedia.title_weight", - Parameter.OPTIONAL, - new Integer(1)); - + private final Parameter m_titleWeight = new IntegerParameter("com.arsdigita.cms.search.intermedia.title_weight", + Parameter.OPTIONAL, + new Integer(1)); /** * Keyword Weight, the relative weight given to the dcKeywords element * within dublinCore element within cms:item element when ranking * search results (only used by interMedia) */ - private final Parameter - m_keywordWeight = new IntegerParameter - ("com.arsdigita.cms.search.intermedia.keyword_weight", - Parameter.OPTIONAL, - new Integer(1)); - + private final Parameter m_keywordWeight = new IntegerParameter("com.arsdigita.cms.search.intermedia.keyword_weight", + Parameter.OPTIONAL, + new Integer(1)); /** * Asset steps to skip, specify asset steps that are not relevant for * specific content types. @@ -438,101 +342,69 @@ public final class CMSConfig extends AbstractConfig { * Second string is the name of the bebop step component * eg com.arsdigita.cms.contenttypes.ui.ImageStep */ - private final Parameter - m_skipAssetSteps = new StringArrayParameter - ("com.arsdigita.cms.skip_asset_steps", + private final Parameter m_skipAssetSteps = new StringArrayParameter("com.arsdigita.cms.skip_asset_steps", Parameter.OPTIONAL, null); /** * Mandatory Descriptions Content types may refer to this to decide * whether to validate against empty descriptions */ - private final Parameter - m_mandatoryDescriptions = new BooleanParameter - ("com.arsdigita.cms.mandatory_descriptions", - Parameter.OPTIONAL, new Boolean(false)); - + private final Parameter m_mandatoryDescriptions = new BooleanParameter("com.arsdigita.cms.mandatory_descriptions", + Parameter.OPTIONAL, new Boolean(false)); /** * Delete Finished Lifecycles. Decide whether lifecycles and their phases * should be deleted from the system when finished. */ - private final Parameter - m_deleteLifecycleWhenComplete = new BooleanParameter - ("com.arsdigita.cms.delete_lifecycle_when_complete", - Parameter.OPTIONAL, new Boolean(false)); - + private final Parameter m_deleteLifecycleWhenComplete = new BooleanParameter("com.arsdigita.cms.delete_lifecycle_when_complete", + Parameter.OPTIONAL, new Boolean(false)); /** * Contacts for content items. Allows you to add a Contact authoring step * to all items */ - private final Parameter - m_hasContactsAuthoringStep = new BooleanParameter - ("com.arsdigita.cms.has_contacts_authoring_step", - Parameter.REQUIRED, new Boolean(false)); - + private final Parameter m_hasContactsAuthoringStep = new BooleanParameter("com.arsdigita.cms.has_contacts_authoring_step", + Parameter.REQUIRED, new Boolean(false)); /** * Ordering for nodes in assign category tree. Decide whether entries * should be ordered alphabetically or according to sort key * (maintained in category admin tab in content centre) * SortKey|Alphabetical is initialized in constructor! See below. */ - private final Parameter - m_categoryTreeOrdering = new EnumerationParameter - ("com.arsdigita.cms.category_tree_order", - Parameter.OPTIONAL, Category.SORT_KEY ); - - + private final Parameter m_categoryTreeOrdering = new EnumerationParameter("com.arsdigita.cms.category_tree_order", + Parameter.OPTIONAL, Category.SORT_KEY); /** * Allow content creation in section listing. Allows you to turn off * the ability to create content in the section listing */ - private final Parameter - m_allowContentCreateInSectionListing = new BooleanParameter - ("com.arsdigita.cms.allow_content_create_in_section_listing", - Parameter.REQUIRED, - new Boolean(true)); - - + private final Parameter m_allowContentCreateInSectionListing = new BooleanParameter("com.arsdigita.cms.allow_content_create_in_section_listing", + Parameter.REQUIRED, + new Boolean(true)); // /////////////////////////////////////////// // Notification related parameters // /////////////////////////////////////////// - /** * Delete Sent Workflow Notifications. Decide whether successfully sent * notifications and messages should be deleted from the system */ - private final Parameter - m_deleteWorkflowNotificationsWhenSent = new BooleanParameter - ("com.arsdigita.cms.delete_workflow_notification_when_sent", - Parameter.OPTIONAL, new Boolean(false)); - + private final Parameter m_deleteWorkflowNotificationsWhenSent = new BooleanParameter("com.arsdigita.cms.delete_workflow_notification_when_sent", + Parameter.OPTIONAL, new Boolean(false)); /** * Decide whether successfully sent notifications and messages * should be deleted from the system */ - private final Parameter - m_deleteExpiryNotificationsWhenSent = new BooleanParameter - ("com.arsdigita.cms.delete_expiry_notification_when_sent", - Parameter.OPTIONAL, new Boolean(false)); + private final Parameter m_deleteExpiryNotificationsWhenSent = new BooleanParameter("com.arsdigita.cms.delete_expiry_notification_when_sent", + Parameter.OPTIONAL, new Boolean(false)); /** * Amount of time (in hours) before the expiration of a content item * that users in the Alert Recipient role are alerted via email */ - private final Parameter - m_defaultNotificationTime = new IntegerParameter - ("com.arsdigita.cms.default_notification_time", - Parameter.REQUIRED, new Integer(0)); - + private final Parameter m_defaultNotificationTime = new IntegerParameter("com.arsdigita.cms.default_notification_time", + Parameter.REQUIRED, new Integer(0)); /** * Wether a content item's author should be notified * by the item's LifecycleListener; defaults to true */ - private final Parameter - m_notifyAuthorOnLifecycle = new BooleanParameter - ("com.arsdigita.cms.notify_author_on_lifecycle", - Parameter.OPTIONAL, new Boolean(true)); - - + private final Parameter m_notifyAuthorOnLifecycle = new BooleanParameter("com.arsdigita.cms.notify_author_on_lifecycle", + Parameter.OPTIONAL, new Boolean(true)); // //////////////////////////////////////////////////// // Content Center (Workspace) config related parameters // //////////////////////////////////////////////////// @@ -540,21 +412,15 @@ public final class CMSConfig extends AbstractConfig { * XML Mapping of the content center tabs to URLs, see * {@link ContentCenterDispatcher} */ - private final StringParameter - m_contentCenterMap = new StringParameter( - "com.arsdigita.cms.loader.content_center_map", - Parameter.REQUIRED, - "/WEB-INF/resources/content-center-map.xml"); - - + private final StringParameter m_contentCenterMap = new StringParameter( + "com.arsdigita.cms.loader.content_center_map", + Parameter.REQUIRED, + "/WEB-INF/resources/content-center-map.xml"); // /////////////////////////////////////////// // Content Section config related parameters // /////////////////////////////////////////// - private final Parameter - m_defaultSection = new StringParameter - ("com.arsdigita.cms.default_content_section", - Parameter.REQUIRED, "content"); - + private final Parameter m_defaultSection = new StringParameter("com.arsdigita.cms.default_content_section", + Parameter.REQUIRED, "content"); // /////////////////////////////////////////// // Content Section creation parameters // XXX these are probably temporary parameters, as the @@ -562,30 +428,26 @@ public final class CMSConfig extends AbstractConfig { // to SectionInitializer. However, it still may be useful to // keep these for the default values. // /////////////////////////////////////////// - private final Parameter - m_defaultItemResolverClass = new SpecificClassParameter - ("com.arsdigita.cms.default_item_resolver_class", - Parameter.REQUIRED, - MultilingualItemResolver.class, - ItemResolver.class); - - private final Parameter - m_defaultTemplateResolverClass = new SpecificClassParameter - ("com.arsdigita.cms.default_template_resolver_class", - Parameter.REQUIRED, - DefaultTemplateResolver.class, - TemplateResolver.class); - + private final Parameter m_defaultItemResolverClass = new SpecificClassParameter("com.arsdigita.cms.default_item_resolver_class", + Parameter.REQUIRED, + MultilingualItemResolver.class, + ItemResolver.class); + private final Parameter m_defaultTemplateResolverClass = new SpecificClassParameter("com.arsdigita.cms.default_template_resolver_class", + Parameter.REQUIRED, + DefaultTemplateResolver.class, + TemplateResolver.class); + ///////////////////////////////////////////// + // ItemSearchWidget + ///////////////////////////////////////////// + private final Parameter m_itemSearchDefaultTab = new StringParameter("com.arsdigita.cms.item_search.default_tab", + Parameter.REQUIRED, "browse"); // /////////////////////////////////////////// // publishToFile package related parameter // /////////////////////////////////////////// - // Moved to publishToFile.PublishToFileConfig as of version 6.0.2 // private final Parameter m_disableItemPfs; // private final Parameter m_publishToFileClass; - - /** * Constructor, but do NOT instantiate this class directly. * @@ -593,13 +455,13 @@ public final class CMSConfig extends AbstractConfig { **/ public CMSConfig() { - // Initialize m_categoryTreeOrdering parameter here! - // 2 valid values at the moment - enumeration used rather than boolean - // in case other possible orders are deemed valid - ((EnumerationParameter)m_categoryTreeOrdering).put("SortKey", Category.SORT_KEY ); - ((EnumerationParameter)m_categoryTreeOrdering).put("Alphabetical", Category.NAME); - - + // Initialize m_categoryTreeOrdering parameter here! + // 2 valid values at the moment - enumeration used rather than boolean + // in case other possible orders are deemed valid + ((EnumerationParameter) m_categoryTreeOrdering).put("SortKey", Category.SORT_KEY); + ((EnumerationParameter) m_categoryTreeOrdering).put("Alphabetical", Category.NAME); + + register(m_templateRootPath); register(m_defaultItemTemplatePath); register(m_defaultFolderTemplatePath); @@ -651,7 +513,9 @@ public final class CMSConfig extends AbstractConfig { // Content Section creation parameters register(m_defaultItemResolverClass); register(m_defaultTemplateResolverClass); - + + register(m_itemSearchDefaultTab); + // publishToFile package related parameter // Moved to publishToFile.PublishToFileConfig as of version 6.0.2 // register(m_disableItemPfs); @@ -685,15 +549,15 @@ public final class CMSConfig extends AbstractConfig { } public final InputStream getItemAdapters() { - // URL resource: protocol handler removal: START - // remove: - // try { - // return ((URL)get(m_itemAdapters)).openStream(); - // } catch (IOException ex) { - // throw new UncheckedWrapperException("Cannot read stream", ex); - // } - // ADD: - return (InputStream)get(m_itemAdapters); + // URL resource: protocol handler removal: START + // remove: + // try { + // return ((URL)get(m_itemAdapters)).openStream(); + // } catch (IOException ex) { + // throw new UncheckedWrapperException("Cannot read stream", ex); + // } + // ADD: + return (InputStream) get(m_itemAdapters); } public final String getDefaultContentSection() { @@ -705,17 +569,17 @@ public final class CMSConfig extends AbstractConfig { } public final DHTMLEditor.Config getDHTMLEditorConfig() { - return (DHTMLEditor.Config)get(m_dhtmlEditorConfig); + return (DHTMLEditor.Config) get(m_dhtmlEditorConfig); } - + public final String[] getDHTMLEditorPlugins() { - return (String[])get(m_dhtmlEditorPlugins); + return (String[]) get(m_dhtmlEditorPlugins); } public final String[] getDHTMLEditorHiddenButtons() { - return (String[])get(m_dhtmlEditorHiddenButtons); + return (String[]) get(m_dhtmlEditorHiddenButtons); } - + public final boolean getHideTemplatesTab() { return ((Boolean) get(m_hideTemplatesTab)).booleanValue(); } @@ -749,7 +613,7 @@ public final class CMSConfig extends AbstractConfig { } public final String getPublishLifecycleListenerClass() { - return (String) get(m_publishLifecycleListenerClass); + return (String) get(m_publishLifecycleListenerClass); } public final boolean getNotifyAuthorOnLifecycle() { @@ -783,19 +647,18 @@ public final class CMSConfig extends AbstractConfig { public final int getSoonExpiredDays() { return ((Integer) get(m_soonExpiredTimespanDays)).intValue(); } - + public final boolean isUnpublishedNotFound() { return ((Boolean) get(m_unpublishedNotFound)).booleanValue(); } public final Class getCategoryAuthoringExtension() { - return (Class) get(m_categoryAuthoringExtension); + return (Class) get(m_categoryAuthoringExtension); } // /////////////////////////////////////////// // publishToFile package related configuration // /////////////////////////////////////////// - // Moved to publishToFile.PublishToFileConfig! Temporarily retained here // for backwards compatibility public final boolean getDisableItemPfs() { @@ -808,17 +671,15 @@ public final class CMSConfig extends AbstractConfig { return PublishToFileConfig.getConfig().getPublishListenerClass(); } - /** * Fetch the file name contaning XML Mapping of the content center tabs * to URLs * @return String containig file name including path component. */ - public String getContentCenterMap() { + public String getContentCenterMap() { return (String) get(m_contentCenterMap); } - /** * Internal class representing a DHTMLEditor configuration parameter. It * creates a new DHMTLEditor Config object (internal class in DHTMLEditor). @@ -833,9 +694,10 @@ public final class CMSConfig extends AbstractConfig { * (pboy, 2010-09-02) */ private class DHTMLEditorConfigParameter extends StringParameter { + public DHTMLEditorConfigParameter(final String name, - final int multiplicity, - final Object defaultObj) { + final int multiplicity, + final Object defaultObj) { super(name, multiplicity, defaultObj); } @@ -850,8 +712,6 @@ public final class CMSConfig extends AbstractConfig { return DHTMLEditor.Config.valueOf(value); } } - - protected static HashMap extraXMLGenerators = new HashMap(); /** Add one ExtraXMLGenerator to the list. */ @@ -871,10 +731,11 @@ public final class CMSConfig extends AbstractConfig { public static Iterator getExtraXMLGeneratorsIterator() { return extraXMLGenerators.entrySet().iterator(); } + public final boolean hideResetLifecycleLink() { return ((Boolean) get(m_hideResetLifecycleLink)).booleanValue(); } - + /** * The relative weight given to the dcKeywords element * within dublinCore element within cms:item element @@ -891,9 +752,9 @@ public final class CMSConfig extends AbstractConfig { * Only used by the interMedia query engine. **/ public Integer getTitleSearchWeight() { - return (Integer) get(m_titleWeight); + return (Integer) get(m_titleWeight); } - + /** * Whether to include INPATH operators to contains clause in intermedia search * @@ -902,10 +763,9 @@ public final class CMSConfig extends AbstractConfig { * @return */ public boolean scoreKeywordsAndTitle() { - return ((Boolean)get(m_scoreTitleAndKeywords)).booleanValue(); + return ((Boolean) get(m_scoreTitleAndKeywords)).booleanValue(); } - - + /** * for the given content type, returns a collection of * steps that are deemed irrelevant for the type. @@ -920,38 +780,38 @@ public final class CMSConfig extends AbstractConfig { */ public Collection getAssetStepsToSkip(ContentType type) { s_log.debug("getting asset steps to skip for type " + type.getClassName()); - if (s_skipAssetSteps == null) { - // populate static map once based on config parameter value - s_log.debug("loading skipsteps"); - s_skipAssetSteps = new HashMap(); - String[] skipSteps = (String[])get(m_skipAssetSteps); - if (skipSteps != null) { - - s_log.debug(skipSteps.length + " entries in parameter"); - for (int i = 0; i < skipSteps.length; i++) { - String[] pair = StringUtils.split(skipSteps[i], ':'); - // 1st string is name of content type, 2nd string is name of asset step - s_log.debug("parameter read - type = " + pair[0] + " - step = " + pair[1]); - Collection typeSteps = (Collection)s_skipAssetSteps.get(pair[0]); - if (typeSteps == null) { - typeSteps = new HashSet(); - s_skipAssetSteps.put(pair[0], typeSteps); - - } - typeSteps.add(pair[1]); - - } - } - - } - Collection skipSteps = (Collection)s_skipAssetSteps.get(type.getClassName()); - if (skipSteps == null) { - s_log.debug("no steps to skip"); - skipSteps = new HashSet(); - } - return skipSteps; - - } + if (s_skipAssetSteps == null) { + // populate static map once based on config parameter value + s_log.debug("loading skipsteps"); + s_skipAssetSteps = new HashMap(); + String[] skipSteps = (String[]) get(m_skipAssetSteps); + if (skipSteps != null) { + + s_log.debug(skipSteps.length + " entries in parameter"); + for (int i = 0; i < skipSteps.length; i++) { + String[] pair = StringUtils.split(skipSteps[i], ':'); + // 1st string is name of content type, 2nd string is name of asset step + s_log.debug("parameter read - type = " + pair[0] + " - step = " + pair[1]); + Collection typeSteps = (Collection) s_skipAssetSteps.get(pair[0]); + if (typeSteps == null) { + typeSteps = new HashSet(); + s_skipAssetSteps.put(pair[0], typeSteps); + + } + typeSteps.add(pair[1]); + + } + } + + } + Collection skipSteps = (Collection) s_skipAssetSteps.get(type.getClassName()); + if (skipSteps == null) { + s_log.debug("no steps to skip"); + skipSteps = new HashSet(); + } + return skipSteps; + + } /** * May be used by any content type creation form to decide whether to validate @@ -959,9 +819,9 @@ public final class CMSConfig extends AbstractConfig { * */ public boolean mandatoryDescriptions() { - return ((Boolean)get(m_mandatoryDescriptions)).booleanValue(); + return ((Boolean) get(m_mandatoryDescriptions)).booleanValue(); } - + /** * Used to decide whether lifecycles (and all asociated phases) * should be deleted from the system when complete @@ -970,9 +830,9 @@ public final class CMSConfig extends AbstractConfig { * eg when was this item unpublished) */ public boolean deleteFinishedLifecycles() { - return ((Boolean)get(m_deleteLifecycleWhenComplete)).booleanValue(); + return ((Boolean) get(m_deleteLifecycleWhenComplete)).booleanValue(); } - + /** * Used to decide whether to delete old notification records * for expiry notifications. @@ -983,9 +843,9 @@ public final class CMSConfig extends AbstractConfig { * */ public boolean deleteExpiryNotifications() { - return ((Boolean)get(m_deleteExpiryNotificationsWhenSent)).booleanValue(); + return ((Boolean) get(m_deleteExpiryNotificationsWhenSent)).booleanValue(); } - + /** * Used to decide whether to delete old notification records * for workflow notifications. @@ -996,12 +856,12 @@ public final class CMSConfig extends AbstractConfig { * */ public boolean deleteWorkflowNotifications() { - return ((Boolean)get(m_deleteWorkflowNotificationsWhenSent)).booleanValue(); + return ((Boolean) get(m_deleteWorkflowNotificationsWhenSent)).booleanValue(); + } + + public String getCategoryTreeOrder() { + return (String) get(m_categoryTreeOrdering); } - - public String getCategoryTreeOrder () { - return (String)get(m_categoryTreeOrdering); - } /** * I'am not sure for what this method is. I found it here when I tried @@ -1013,15 +873,19 @@ public final class CMSConfig extends AbstractConfig { * * @return */ - public boolean getHasContactsAuthoringStep() { - return ((Boolean) get(m_hasContactsAuthoringStep)).booleanValue(); - } - - public final boolean getHideTextAssetUploadFile() { - return ((Boolean) get(m_hideTextAssetUploadFile)).booleanValue(); + public boolean getHasContactsAuthoringStep() { + return ((Boolean) get(m_hasContactsAuthoringStep)).booleanValue(); + } + + public final boolean getHideTextAssetUploadFile() { + return ((Boolean) get(m_hideTextAssetUploadFile)).booleanValue(); + } + + public final boolean getAllowContentCreateInSectionListing() { + return ((Boolean) get(m_allowContentCreateInSectionListing)).booleanValue(); + } + + public String getItemSearchDefaultTab() { + return (String) get(m_itemSearchDefaultTab); } - - public final boolean getAllowContentCreateInSectionListing() { - return ((Boolean) get(m_allowContentCreateInSectionListing)).booleanValue(); - } } diff --git a/ccm-cms/src/com/arsdigita/cms/CMSConfig_parameter.properties b/ccm-cms/src/com/arsdigita/cms/CMSConfig_parameter.properties index 513014e85..c28e274cd 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSConfig_parameter.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSConfig_parameter.properties @@ -227,3 +227,14 @@ com.arsdigita.cms.allow_content_create_in_section_listing.title=Allow content cr com.arsdigita.cms.allow_content_create_in_section_listing.purpose=Allows you to turn off the ability to create content in the section listing 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 tabe 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.example=browse +com.arsdigita.cms.item_search.default_tab.format=[string] + +com.arsdigita.cms.item_search.xx.title= +com.arsdigita.cms.item_search.xx.purpose= +com.arsdigita.cms.item_search.xx.example= +com.arsdigita.cms.item_search.xx.format=[string] + diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources.properties index 9c5525a0e..36936a40b 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources.properties @@ -315,6 +315,7 @@ cms.ui.search_prompt=Search to add new members cms.ui.search_to_add_new_members=Search to Add New Members cms.ui.search_errors.empty_terms=Please enter some search terms cms.ui.search_errors.bad_terms=Your search terms contain illegal words or characters +cms.ui.search_no_results=Sorry. Your search returned 0 results. cms.ui.select_one=--select one-- cms.ui.sign_out=Sign out cms.ui.submission_cancelled=Submission Cancelled @@ -346,6 +347,10 @@ cms.ui.workflow_profile_exists_on_selected_folder=Workflow Profile exists on sel cms.ui.yes=Yes cms.ui.you_do_not_have_sufficient_privileges_to_access_this_page=You do not have sufficient privileges to access this page. +cms.ui.item_search.page_title=Item Search +cms.ui.item_search.browse=Browse +cms.ui.item_search.search=Search + # Package com.arsdigita.cms.ui.authoring # ====================================== diff --git a/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties b/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties index 8568d6f2b..c51cc3304 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties +++ b/ccm-cms/src/com/arsdigita/cms/CMSResources_de.properties @@ -314,6 +314,7 @@ cms.ui.search_prompt=Suche um neue Mitglieder zu erg\u00e4nzen cms.ui.search_to_add_new_members=Suche um neue Mitglieder zu erg\u00e4nzen cms.ui.search_errors.empty_terms=Bitte Suchbegriffe eingeben cms.ui.search_errors.bad_terms=Your search terms contain illegal words or characters +cms.ui.search_no_results=Ihre Suche ergab leider keine Treffer. cms.ui.select_one=--ausw\u00e4hlen-- cms.ui.sign_out=Abmelden cms.ui.submission_cancelled=Prozess abgebrochen @@ -345,7 +346,9 @@ cms.ui.workflow_profile_exists_on_selected_folder=Ablaufprofil existiert f\u00fc cms.ui.yes=Ja cms.ui.you_do_not_have_sufficient_privileges_to_access_this_page=Unzureichende Zugriffsrechte f\u00fcr diese Seite. - +cms.ui.item_search.page_title=Dokumentensuche +cms.ui.item_search.browse=Bl\u00e4ttern +cms.ui.item_search.search=Suchen # Package com.arsdigita.cms.ui.authoring # ====================================== diff --git a/ccm-cms/src/com/arsdigita/cms/ContentSection.java b/ccm-cms/src/com/arsdigita/cms/ContentSection.java index e407ae795..797273071 100755 --- a/ccm-cms/src/com/arsdigita/cms/ContentSection.java +++ b/ccm-cms/src/com/arsdigita/cms/ContentSection.java @@ -35,11 +35,13 @@ import com.arsdigita.globalization.Locale; import com.arsdigita.kernel.Group; import com.arsdigita.kernel.SiteNode; import com.arsdigita.kernel.permissions.PermissionService; +import com.arsdigita.persistence.CompoundFilter; import com.arsdigita.persistence.DataAssociation; import com.arsdigita.persistence.DataAssociationCursor; import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.DataQuery; +import com.arsdigita.persistence.FilterFactory; import com.arsdigita.persistence.OID; import com.arsdigita.persistence.SessionManager; import com.arsdigita.util.Assert; @@ -53,6 +55,7 @@ import org.apache.log4j.Logger; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; +import java.util.StringTokenizer; /** *
A content section represents a collection of content that is @@ -776,6 +779,32 @@ public class ContentSection extends Application { return types; } + public ContentTypeCollection getSiblingsOfContentType(ContentType ct) { + ContentTypeCollection ctc = getContentTypes(); + + // The Filter Factory + FilterFactory ff = ctc.getFilterFactory(); + + // Create an or-filter + CompoundFilter or = ff.or(); + + // The content type must be either of the requested type + or.addFilter(ff.equals(ContentType.ID, ct.ID)); + + // Or must be a sibling of the requested type + try { + StringTokenizer strTok = new StringTokenizer(ct.getSiblings(), "/"); + while (strTok.hasMoreElements()) { + or.addFilter(ff.equals(ContentType.ID, (String) strTok.nextElement())); + } + } catch (Exception ex) { + // WTF? The selected content type does not exist in the table??? + } + + ctc.addFilter(or); + return ctc; + } + /** * Get all user-defined content types registered to the content section * that can be created. diff --git a/ccm-cms/src/com/arsdigita/cms/ContentType.java b/ccm-cms/src/com/arsdigita/cms/ContentType.java index 6cdc103eb..5d3692c54 100755 --- a/ccm-cms/src/com/arsdigita/cms/ContentType.java +++ b/ccm-cms/src/com/arsdigita/cms/ContentType.java @@ -583,6 +583,7 @@ public class ContentType extends ACSObject { ctc.addFilter(or); return ctc; } + private static List s_xsl = new ArrayList(); /** diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearch.java b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearch.java index 49daa152d..c886ad56e 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearch.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearch.java @@ -18,7 +18,6 @@ */ package com.arsdigita.cms.ui; - import com.arsdigita.bebop.Form; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.Resettable; @@ -34,15 +33,11 @@ import com.arsdigita.search.ui.QueryGenerator; * @author Stanislav Freidin (sfreidin@arsdigita.com) * @version $Id: ItemSearch.java 1940 2009-05-29 07:15:05Z terry $ */ -public class ItemSearch extends Form - implements Resettable, QueryGenerator { - - private static final org.apache.log4j.Logger s_log = - org.apache.log4j.Logger.getLogger(ItemSearch.class); - - public static final String SINGLE_TYPE_PARAM - = ItemSearchSection.SINGLE_TYPE_PARAM; +public class ItemSearch extends Form implements Resettable, QueryGenerator { + private static final org.apache.log4j.Logger s_log = + org.apache.log4j.Logger.getLogger(ItemSearch.class); + public static final String SINGLE_TYPE_PARAM = ItemSearchSection.SINGLE_TYPE_PARAM; private ItemSearchSection m_section; /** @@ -52,7 +47,7 @@ public class ItemSearch extends Form * {@link ContentItem#DRAFT} or {@link ContentItem#LIVE} */ public ItemSearch(String context) { - super("itemSearch",new SimpleContainer()); + super("itemSearch", new SimpleContainer()); setMethod("GET"); m_section = createSearchSection(context); add(m_section); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchBrowsePane.java b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchBrowsePane.java index b4b537634..57ccaa230 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchBrowsePane.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchBrowsePane.java @@ -61,12 +61,11 @@ import org.apache.log4j.Logger; * @version $Id: ItemSearchBrowsePane.java 1166 2006-06-14 11:45:15Z fabrice $ */ public class ItemSearchBrowsePane extends CMSContainer - implements Resettable, TreeExpansionListener, ChangeListener, - FormProcessListener, FormSubmissionListener { + implements Resettable, TreeExpansionListener, ChangeListener, + FormProcessListener, FormSubmissionListener { private static final Logger s_log = - Logger.getLogger( ItemSearchBrowsePane.class ); - + Logger.getLogger(ItemSearchBrowsePane.class); private FolderSelectionModel m_folderSel; private Tree m_tree; private ItemSearchFolderBrowser m_browser; @@ -74,7 +73,7 @@ public class ItemSearchBrowsePane extends CMSContainer public ItemSearchBrowsePane() { setClassAttr("sidebarNavPanel"); - setAttribute("navbar-title", "Folders"); + setAttribute("navbar-title", GlobalizationUtil.globalize("cms.ui.folder_browser").localize().toString()); Label l = new Label(GlobalizationUtil.globalize("cms.ui.folder_browser")); l.setClassAttr("heading"); @@ -84,26 +83,30 @@ public class ItemSearchBrowsePane extends CMSContainer // subsites through the ItemSearchBrowsePane. A new parameter has been added to allow the // administrator to pick between the old and new versions. boolean linksOnlyInSameSubsite = ContentSection.getConfig().getLinksOnlyInSameSubsite(); - s_log.debug("linksOnlyInSameSubsite value is "+linksOnlyInSameSubsite); + s_log.debug("linksOnlyInSameSubsite value is " + linksOnlyInSameSubsite); - m_tree = new Tree( new FolderTreeModelBuilder() { - protected Folder getRoot( PageState ps ) { - Folder root = getRootFolder( ps ); + m_tree = new Tree(new FolderTreeModelBuilder() { - if( null == root ) return super.getRoot( ps ); + @Override + protected Folder getRoot(PageState ps) { + Folder root = getRootFolder(ps); + + if (null == root) { + return super.getRoot(ps); + } return root; } - } ); - m_folderSel = createFolderSelectionModel(); + }); + m_folderSel = createFolderSelectionModel(); m_folderSel.addChangeListener(this); - if(!linksOnlyInSameSubsite) { - // The client should be able to pick between the subsites + if (!linksOnlyInSameSubsite) { + // The client should be able to pick between the subsites Form sectionForm = getSectionForm(); - add( sectionForm ); - } + add(sectionForm); + } - m_tree.setSelectionModel( m_folderSel ); + m_tree.setSelectionModel(m_folderSel); m_tree.setClassAttr("navbar"); m_tree.addTreeExpansionListener(this); @@ -112,64 +115,67 @@ public class ItemSearchBrowsePane extends CMSContainer CMSContainer container = new CMSContainer(); container.setClassAttr("main"); - m_browser = new ItemSearchFolderBrowser (m_folderSel); - container.add( m_browser ); + m_browser = new ItemSearchFolderBrowser(m_folderSel); + container.add(m_browser); container.add(m_browser.getPaginator()); - add( container ); + add(container); } private Form getSectionForm() { - Form sectionForm = new Form( "isfbSectionForm", - new BoxPanel( BoxPanel.HORIZONTAL ) ); + Form sectionForm = new Form("isfbSectionForm", + new BoxPanel(BoxPanel.HORIZONTAL)); sectionForm.setClassAttr("navbar"); - m_section = new SingleSelect( new OIDParameter( "isfbSection" ) ); + m_section = new SingleSelect(new OIDParameter("isfbSection")); ContentSectionCollection sections = ContentSection.getAllSections(); - while( sections.next() ) { + while (sections.next()) { ContentSection section = sections.getContentSection(); - m_section.addOption( new Option( section.getOID().toString(), - section.getDisplayName() ) ); + m_section.addOption(new Option(section.getOID().toString(), + section.getDisplayName())); } - sectionForm.addInitListener( new FormInitListener() { - public void init( FormSectionEvent ev ) { + sectionForm.addInitListener(new FormInitListener() { + + public void init(FormSectionEvent ev) { PageState ps = ev.getPageState(); - if( null == m_section.getValue( ps ) ) { + if (null == m_section.getValue(ps)) { ContentSection section = CMS.getContext().getContentSection(); - m_section.setValue( ps, section.getOID() ); + m_section.setValue(ps, section.getOID()); } } - } ); + }); - sectionForm.add( m_section ); - sectionForm.add( new Submit( "Change Section" ) ); + sectionForm.add(m_section); + sectionForm.add(new Submit("Change Section")); return sectionForm; } - private Folder getRootFolder( PageState ps ) { - s_log.debug("Getting the root folder."); - if(m_section!=null) { - // We have more than one subsite to choose between - OID sectionOID = (OID) m_section.getValue( ps ); - if( s_log.isDebugEnabled() ) { - if( null != sectionOID ) - s_log.debug( "Using section " + sectionOID.toString() ); - else - s_log.debug( "Using default section" ); + private Folder getRootFolder(PageState ps) { + s_log.debug("Getting the root folder."); + if (m_section != null) { + // We have more than one subsite to choose between + OID sectionOID = (OID) m_section.getValue(ps); + if (s_log.isDebugEnabled()) { + if (null != sectionOID) { + s_log.debug("Using section " + sectionOID.toString()); + } else { + s_log.debug("Using default section"); + } } - if( null == sectionOID ) return null; + if (null == sectionOID) { + return null; + } - ContentSection section = (ContentSection) - DomainObjectFactory.newInstance( sectionOID ); + ContentSection section = (ContentSection) DomainObjectFactory.newInstance(sectionOID); return section.getRootFolder(); - } else { - return null; - } + } else { + return null; + } } public void register(Page p) { @@ -177,13 +183,13 @@ public class ItemSearchBrowsePane extends CMSContainer p.addComponentStateParam(this, m_folderSel.getStateParameter()); // Only add the SingleSelect item if it exists - if(m_section!=null) { + if (m_section != null) { p.addComponentStateParam(this, m_section.getParameterModel()); - } + } } public void reset(PageState s) { - //m_browser.reset(s); + //m_browser.reset(s); } public ItemSearchFolderBrowser getFolderBrowser() { @@ -207,14 +213,13 @@ public class ItemSearchBrowsePane extends CMSContainer m_folderSel.setSelectedKey(s, key); Folder current = (Folder) m_folderSel.getSelectedObject(s); Folder parent = (Folder) current.getParent(); - if ( parent != null ) { + if (parent != null) { BigDecimal id = parent.getID(); m_tree.expand(id.toString(), s); } } // Implement TreeExpansionListener - public void treeCollapsed(TreeExpansionEvent e) { PageState s = e.getPageState(); m_folderSel.setSelectedKey(s, e.getNodeKey()); @@ -229,7 +234,7 @@ public class ItemSearchBrowsePane extends CMSContainer Folder current = (Folder) m_folderSel.getSelectedObject(s); Folder parent = (Folder) current.getParent(); m_browser.getPaginator().reset(s); - if ( parent != null ) { + if (parent != null) { BigDecimal id = parent.getID(); m_tree.expand(id.toString(), s); } @@ -238,37 +243,39 @@ public class ItemSearchBrowsePane extends CMSContainer } public void process(FormSectionEvent e) { - /* + /* PageState s = e.getPageState(); if ( e.getSource() == m_browser.getManipulator().getItemView() ) { - // Hide everything except for the flat item list - m_tree.setVisible(s, false); + // Hide everything except for the flat item list + m_tree.setVisible(s, false); } else if ( e.getSource() == m_browser.getManipulator().getTargetSelector() ) { - m_tree.setVisible(s, true); + m_tree.setVisible(s, true); } - */ + */ } public void submitted(FormSectionEvent e) { - /* + /* PageState s = e.getPageState(); if ( e.getSource() == m_browser.getManipulator().getTargetSelector() ) { - if ( ! m_browser.getManipulator().getTargetSelector().isVisible(s) ) { - m_tree.setVisible(s, true); - } + if ( ! m_browser.getManipulator().getTargetSelector().isVisible(s) ) { + m_tree.setVisible(s, true); } - */ + } + */ } private FolderSelectionModel createFolderSelectionModel() { - return new FolderSelectionModel("folder") { - protected BigDecimal getRootFolderID( PageState ps ) { - Folder root = getRootFolder( ps ); + return new FolderSelectionModel("folder") { - if( null == root ) return super.getRootFolderID( ps ); + protected BigDecimal getRootFolderID(PageState ps) { + Folder root = getRootFolder(ps); + + if (null == root) { + return super.getRootFolderID(ps); + } return root.getID(); } }; } - } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchFolderBrowser.java b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchFolderBrowser.java index b41855a1f..43311a3e2 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchFolderBrowser.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchFolderBrowser.java @@ -157,6 +157,7 @@ public class ItemSearchFolderBrowser extends Table { return new Integer((int) itemColl.size()); } }; + private RequestLocal m_itemColl = new RequestLocal() { @Override @@ -328,9 +329,9 @@ public class ItemSearchFolderBrowser extends Table { + widget + ".value=\"" + fill + "\";\n"); // set protocol to 'other' in FCKEditor, else relative url prepended by http:// if (Bebop.getConfig().getDHTMLEditor().equals(BebopConstants.BEBOP_FCKEDITOR)) { - buffer.append(" if(window.opener.document.getElementById('cmbLinkProtocol')) {\n"); + buffer.append(" if(window.opener.document.getElementById('cmbLinkProtocol')) {\n"); buffer.append(" window.opener.document.getElementById('cmbLinkProtocol').value=\"\";\n"); - buffer.append(" }\n"); + buffer.append(" }\n"); } buffer.append(" self.close(); \n" diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchPage.java b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchPage.java index b7c9c8921..576b266c6 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchPage.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchPage.java @@ -23,10 +23,12 @@ import com.arsdigita.bebop.SimpleContainer; import com.arsdigita.bebop.TabbedPane; import com.arsdigita.bebop.parameters.BigDecimalParameter; import com.arsdigita.bebop.parameters.StringParameter; +import com.arsdigita.cms.CMSConfig; import com.arsdigita.cms.CMSExcursion; import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.dispatcher.CMSPage; +import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.dispatcher.RequestContext; import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.templating.PresentationManager; @@ -47,27 +49,25 @@ import javax.servlet.http.HttpServletResponse; * @author Scott Seago (scott@arsdigita.com) * @version $Revision: #12 $ $DateTime: 2004/08/17 23:15:09 $ */ -public class ItemSearchPage extends CMSPage { +public class ItemSearchPage extends CMSPage { + private final static String XSL_CLASS = "CMS Admin"; - private TabbedPane m_tabbedPane; - private ItemSearchBrowsePane m_browse; private ItemSearchPopup m_search; private BigDecimalParameter m_sectionId; - + private static final CMSConfig s_conf = CMSConfig.getInstance(); public static final String CONTENT_SECTION = "section_id"; /** * Construct a new ItemSearchPage */ public ItemSearchPage() { - super("Item Search", new SimpleContainer()); + super(GlobalizationUtil.globalize("cms.ui.item_search.page_title").localize().toString(), new SimpleContainer()); setClassAttr("cms-admin"); - addGlobalStateParam - (new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM)); + addGlobalStateParam(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM)); addGlobalStateParam(new StringParameter(ItemSearchPopup.WIDGET_PARAM)); m_sectionId = new BigDecimalParameter(CONTENT_SECTION); @@ -81,7 +81,6 @@ public class ItemSearchPage extends CMSPage { add(m_tabbedPane); } - /** * Creates, and then caches, the Browse pane. Overriding this * method to return null will prevent this tab from appearing. @@ -107,7 +106,6 @@ public class ItemSearchPage extends CMSPage { return m_search; } - /** * Created the TabbedPane to use for this page. Sets the class * attribute for this tabbed pane. The default implementation uses a @@ -122,14 +120,22 @@ public class ItemSearchPage extends CMSPage { protected TabbedPane createTabbedPane() { TabbedPane pane = new TabbedPane(); pane.setClassAttr(XSL_CLASS); - addToPane(pane, "Browse", getBrowsePane()); - addToPane(pane, "Search", getSearchPane()); - pane.setDefaultPane(m_browse); + + addToPane(pane, "browse", getBrowsePane()); + addToPane(pane, "search", getSearchPane()); + + if(s_conf.getItemSearchDefaultTab().equals("browse")) { + pane.setDefaultPane(m_browse); + } + if(s_conf.getItemSearchDefaultTab().equals("search")) { + pane.setDefaultPane(m_search); + } + //pane.addActionListener(this); +// pane.setTabVisible(null, pane, true); return pane; } - /** * Adds the specified component, with the specified tab name, to the * tabbed pane only if it is not null. @@ -140,11 +146,10 @@ public class ItemSearchPage extends CMSPage { */ protected void addToPane(TabbedPane pane, String tabName, Component comp) { if (comp != null) { - pane.addTab(tabName, comp); + pane.addTab(GlobalizationUtil.globalize("cms.ui.item_search." + tabName).localize().toString(), comp); } } - /** * When a new tab is selected, reset the state of the * formerly-selected pane. @@ -154,42 +159,40 @@ public class ItemSearchPage extends CMSPage { //public void actionPerformed(ActionEvent event) { //PageState state = event.getPageState(); //Component pane = m_tabbedPane.getCurrentPane(state); - //if ( pane == m_browse ) { // MP: reset tasks pane //} else if ( pane == m_search ) { //m_search.reset(state); //} //} - /** * This strange voodoo from Dan. No idea what it does. */ + @Override public void dispatch(final HttpServletRequest request, - final HttpServletResponse response, - RequestContext actx) + final HttpServletResponse response, + RequestContext actx) throws IOException, ServletException { new CMSExcursion() { + public void excurse() - throws IOException, ServletException { + throws IOException, ServletException { ContentSection section = null; Application app = Web.getContext().getApplication(); if (app instanceof ContentSection) { - section = (ContentSection)app; + section = (ContentSection) app; } else { try { - section = new ContentSection - ((BigDecimal) m_sectionId.transformValue(request)); + section = new ContentSection((BigDecimal) m_sectionId.transformValue(request)); } catch (DataObjectNotFoundException ex) { throw new UncheckedWrapperException(ex); } } setContentSection(section); - final Document doc = buildDocument(request, response); final PresentationManager pm = - Templating.getPresentationManager(); + Templating.getPresentationManager(); pm.servePage(doc, request, response); } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchPopup.java b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchPopup.java index f97ce2813..99157fa2f 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchPopup.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchPopup.java @@ -18,7 +18,6 @@ */ package com.arsdigita.cms.ui; - import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Page; import com.arsdigita.bebop.PageState; @@ -45,10 +44,8 @@ import javax.servlet.http.HttpServletRequest; */ public class ItemSearchPopup extends ItemSearch { - - private static final org.apache.log4j.Logger s_log = - org.apache.log4j.Logger.getLogger(ItemSearchPopup.class); - + private static final org.apache.log4j.Logger s_log = + org.apache.log4j.Logger.getLogger(ItemSearchPopup.class); public static final String WIDGET_PARAM = "widget"; public static final String URL_PARAM = "useURL"; @@ -63,22 +60,25 @@ public class ItemSearchPopup extends ItemSearch { } // Hide results by default + @Override public void register(Page p) { super.register(p); p.addGlobalStateParam(new StringParameter(WIDGET_PARAM)); p.addGlobalStateParam(new StringParameter(URL_PARAM)); } + @Override protected ItemSearchSection createSearchSection(String context) { return new ItemSearchSectionPopup(context); } private static class ItemSearchSectionPopup extends ItemSearchSection { - + public ItemSearchSectionPopup(String context) { super(context); } - + + @Override protected Component createResultsPane(QueryGenerator generator) { return new PopupResultsPane(generator); } @@ -93,55 +93,56 @@ public class ItemSearchPopup extends ItemSearch { //map.setParameter("oid", oid.toString()); //return URL.there(request, "/redirect/", map).toString(); // Always link directly to the live version. - return "/redirect/?oid="+oid.toString(); + return "/redirect/?oid=" + oid.toString(); } private static class PopupResultsPane extends ResultsPane { + public PopupResultsPane(QueryGenerator generator) { super(generator); setRelativeURLs(true); } - protected Element generateDocumentXML(PageState state, - Document doc) { + @Override + protected Element generateDocumentXML(PageState state, Document doc) { Element element = super.generateDocumentXML(state, doc); - + element.addAttribute("class", "jsButton"); String widget = (String) state.getValue( - new StringParameter(WIDGET_PARAM)); - - boolean useURL = "true".equals( - state.getValue(new StringParameter(URL_PARAM))); + new StringParameter(WIDGET_PARAM)); + + boolean useURL = "true".equals( + state.getValue(new StringParameter(URL_PARAM))); + + String fillString = useURL + ? getItemURL(state.getRequest(), doc.getOID()) + : doc.getOID().get("id").toString() + + " (" + doc.getTitle() + ")"; - String fillString = useURL ? - getItemURL(state.getRequest(), doc.getOID()) : - doc.getOID().get("id").toString() + - " (" + doc.getTitle() + ")"; - Element jsLabel = Search.newElement("jsAction"); - jsLabel.addAttribute("name", "fillItem" + - doc.getOID().get("id") + "()"); - jsLabel.setText(generateJSLabel((BigDecimal)doc.getOID().get("id"), - widget, fillString)); + jsLabel.addAttribute("name", "fillItem" + + doc.getOID().get("id") + "()"); + jsLabel.setText(generateJSLabel((BigDecimal) doc.getOID().get("id"), + widget, fillString)); element.addContent(jsLabel); return element; } private String generateJSLabel(BigDecimal id, String widget, String fill) { - return " "; + return " "; } } } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchSection.java b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchSection.java index 6b8271554..49d928d2a 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchSection.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchSection.java @@ -79,8 +79,8 @@ public class ItemSearchSection extends FormSection m_query = createQueryGenerator(context); m_results = createResultsPane(m_query); - addResultsPane(this); addQueryGenerator(this); + addResultsPane(this); addFormListener(); setClassAttr("itemSearch"); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchSectionInline.java b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchSectionInline.java index b36ec5bc0..764a4a006 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchSectionInline.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchSectionInline.java @@ -18,7 +18,6 @@ */ package com.arsdigita.cms.ui; - import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Container; import com.arsdigita.bebop.PageState; @@ -45,13 +44,10 @@ import com.arsdigita.search.ui.ResultsPane; */ public class ItemSearchSectionInline extends ItemSearchSection { - private static final org.apache.log4j.Logger s_log = - org.apache.log4j.Logger.getLogger(ItemSearchSectionInline.class); - - + private static final org.apache.log4j.Logger s_log = + org.apache.log4j.Logger.getLogger(ItemSearchSectionInline.class); private Submit m_selectItem; private String m_name; - private OIDParameter m_item; /** @@ -66,27 +62,32 @@ public class ItemSearchSectionInline extends ItemSearchSection { m_item = new OIDParameter(name + "_itemOID"); } + @Override public void register(Page p) { super.register(p); p.addGlobalStateParam(m_item); } + @Override protected Component createResultsPane(QueryGenerator generator) { return new InlineResultsPane(generator); } + @Override protected void addResultsPane(Container container) { super.addResultsPane(container); m_selectItem = new ItemSelectSubmit( - m_name + "_itemSelect", "Select Item"); + m_name + "_itemSelect", "Select Item"); container.add(m_selectItem); } + @Override protected void addFormListener() { // do nothing (ItemSearchWidget's submission listener does this. } + @Override public void processQuery(PageState state) { super.processQuery(state); m_selectItem.setVisible(state, hasQuery(state)); @@ -97,39 +98,43 @@ public class ItemSearchSectionInline extends ItemSearchSection { } public ContentItem getSelectedItem(PageState state) { - OID oid = (OID)state.getValue(m_item); - + OID oid = (OID) state.getValue(m_item); + if (oid == null) { return null; } - - return (ContentItem)DomainObjectFactory.newInstance(oid); + + return (ContentItem) DomainObjectFactory.newInstance(oid); } - + private class ItemSelectSubmit extends Submit { + public ItemSelectSubmit(String name, String label) { super(name, label); } + public ItemSelectSubmit(String name, GlobalizedMessage label) { super(name, label); } + @Override public boolean isVisible(PageState ps) { return hasQuery(ps) && super.isVisible(ps); } - } private class InlineResultsPane extends ResultsPane { + public InlineResultsPane(QueryGenerator query) { super(query); setRelativeURLs(true); } - + + @Override protected Element generateDocumentXML(PageState state, - Document doc) { + Document doc) { Element element = super.generateDocumentXML(state, doc); - + element.addAttribute("field", m_item.getName()); element.addAttribute("class", "radioButton"); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchWidget.java b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchWidget.java index 3c182441e..4fd96a23f 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchWidget.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchWidget.java @@ -165,8 +165,7 @@ public class ItemSearchWidget extends FormSection /** * Construct a new ItemSearchWidget. The model must be an ItemSearchParameter */ - public ItemSearchWidget(ParameterModel model, - ContentType contentType) { + public ItemSearchWidget(ParameterModel model, ContentType contentType) { super(new BoxPanel(BoxPanel.VERTICAL)); if (!(model instanceof ItemSearchParameter)) { @@ -267,8 +266,7 @@ public class ItemSearchWidget extends FormSection : ContentType.findByAssociatedObjectType(objectType))); } - public ItemSearchWidget(String name, - ContentType contentType) { + public ItemSearchWidget(String name, ContentType contentType) { this(new ItemSearchParameter(name, contentType), contentType); } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/folder/FolderTreeModelBuilder.java b/ccm-cms/src/com/arsdigita/cms/ui/folder/FolderTreeModelBuilder.java index ca72143f3..ceb5f9f9f 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/folder/FolderTreeModelBuilder.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/folder/FolderTreeModelBuilder.java @@ -45,7 +45,6 @@ import java.util.Collections; import java.util.Iterator; import org.apache.log4j.Logger; - /** * A {@link com.arsdigita.bebop.tree.TreeModelBuilder} that produces trees * containing the folder structure underneath a root folder. The root @@ -56,14 +55,13 @@ import org.apache.log4j.Logger; * * @version $Id: FolderTreeModelBuilder.java 1940 2009-05-29 07:15:05Z terry $ */ - public class FolderTreeModelBuilder extends LockableImpl - implements TreeModelBuilder { + implements TreeModelBuilder { private static final Logger s_log = Logger.getLogger(FolderTreeModelBuilder.class); - private PrivilegeDescriptor TREE_DESCRIPTOR = - SecurityManager.CMS_PREVIEW_ITEM_DESCRIPTOR; + SecurityManager.CMS_PREVIEW_ITEM_DESCRIPTOR; + /** * Make a tree model that lists the hierarchy of folders underneath the * folder returnedby {@link #getRoot getRoot}. @@ -75,40 +73,45 @@ public class FolderTreeModelBuilder extends LockableImpl */ public com.arsdigita.bebop.tree.TreeModel makeModel(final Tree t, PageState s) { return new DataQueryTreeModel(getRoot(s).getID(), - "com.arsdigita.cms.getRootFolder", - "com.arsdigita.cms.getSubFolders") { + "com.arsdigita.cms.getRootFolder", + "com.arsdigita.cms.getSubFolders") { - public Iterator getChildren(TreeNode node, PageState data) { - String nodeKey = node.getKey().toString(); - if (t.isCollapsed(nodeKey, data)) { - return Collections.EMPTY_LIST.iterator(); - } - Party party = Kernel.getContext().getParty(); - OID partyOID = null; - if (party == null) { - partyOID = new OID(User.BASE_DATA_OBJECT_TYPE, - PermissionManager.VIRTUAL_PUBLIC_ID); - } else { - partyOID = party.getOID(); - } - UniversalPermissionDescriptor universalPermission = - new UniversalPermissionDescriptor - (SecurityManager.CMS_PREVIEW_ITEM_DESCRIPTOR, partyOID); - if (PermissionService.checkPermission - (universalPermission)) { - // the person is an admin so we just pass in the - // standard, non filtered query - return getDataQueryTreeIterator( - (DataQueryTreeNode) node, - "com.arsdigita.cms.getSubFolders"); - } else { - // now we need to set the parameters - return new NewFolderBrowserIterator( + @Override + public Iterator getChildren(TreeNode node, PageState data) { + String nodeKey = node.getKey().toString(); + + // Always expand root node + if (nodeKey.equals(getRoot(data).getKey().toString())/* && t.isCollapsed(nodeKey, data)*/) { + t.expand(nodeKey, data); + } + + if (t.isCollapsed(nodeKey, data)) { + return Collections.EMPTY_LIST.iterator(); + } + Party party = Kernel.getContext().getParty(); + OID partyOID = null; + if (party == null) { + partyOID = new OID(User.BASE_DATA_OBJECT_TYPE, + PermissionManager.VIRTUAL_PUBLIC_ID); + } else { + partyOID = party.getOID(); + } + UniversalPermissionDescriptor universalPermission = + new UniversalPermissionDescriptor(SecurityManager.CMS_PREVIEW_ITEM_DESCRIPTOR, partyOID); + if (PermissionService.checkPermission(universalPermission)) { + // the person is an admin so we just pass in the + // standard, non filtered query + return getDataQueryTreeIterator( + (DataQueryTreeNode) node, + "com.arsdigita.cms.getSubFolders"); + } else { + // now we need to set the parameters + return new NewFolderBrowserIterator( (DataQueryTreeNode) node, partyOID); - } } - }; + } + }; } /** @@ -119,12 +122,11 @@ public class FolderTreeModelBuilder extends LockableImpl * @post return != null */ protected Folder getRoot(PageState s) - throws IllegalStateException { + throws IllegalStateException { ContentSection sec = CMS.getContext().getContentSection(); return sec.getRootFolder(); } - private class NewFolderBrowserIterator implements Iterator { private DataQuery m_nodes; @@ -134,56 +136,55 @@ public class FolderTreeModelBuilder extends LockableImpl BigDecimal userID = (BigDecimal) partyOID.get("id"); String sql = "" -+ "\n select f.folder_id as id," -+ "\n f.label as name," -+ "\n count(sub.item_id) as nchild" -+ "\n from cms_folders f," -+ "\n cms_items i" -+ "\n left join" -+ "\n (select i2.item_id, f2.label as name, i2.parent_id" -+ "\n from cms_folders f2," -+ "\n cms_items i2" -+ "\n where f2.folder_id = i2.item_id) sub" -+ "\n on (sub.parent_id = i.item_id" -+ "\n and" -+ "\n exists (select 1" -+ "\n from dnm_object_1_granted_context dogc," -+ "\n dnm_granted_context dgc," -+ "\n dnm_permissions dp," -+ "\n dnm_group_membership dgm" -+ "\n where dogc.pd_object_id = sub.item_id" -+ "\n and dogc.pd_context_id = dgc.pd_object_id" -+ "\n and dgc.pd_context_id = dp.pd_object_id" -+ "\n and dp.pd_grantee_id = dgm.pd_group_id" -+ "\n and dgm.pd_member_id in (-200," + userID + ",-202)" -+ "\n and dp." + TREE_DESCRIPTOR.getColumnName() + " = 1" -+ "\n ) )" -+ "\n where i.parent_id = " + node.getID() -+ "\n and f.folder_id = i.item_id" -+ "\n and exists (" -+ "\n select 1 as permission_p" -+ "\n from dnm_object_1_granted_context dogc," -+ "\n dnm_granted_context dgc," -+ "\n dnm_permissions dp," -+ "\n dnm_group_membership dgm" -+ "\n where dogc.pd_context_id = dgc.pd_object_id" -+ "\n and dgc.pd_context_id = dp.pd_object_id" -+ "\n and dgm.pd_member_id in (-200," + userID + ",-202)" -+ "\n and dp.pd_grantee_id = dgm.pd_group_id" -+ "\n and dogc.pd_object_id = f.folder_id" -+ "\n and dp." + TREE_DESCRIPTOR.getColumnName() + " = 1 )" -+ "\n group by f.label, f.folder_id" -+ "\n order by lower(f.label)" ; + + "\n select f.folder_id as id," + + "\n f.label as name," + + "\n count(sub.item_id) as nchild" + + "\n from cms_folders f," + + "\n cms_items i" + + "\n left join" + + "\n (select i2.item_id, f2.label as name, i2.parent_id" + + "\n from cms_folders f2," + + "\n cms_items i2" + + "\n where f2.folder_id = i2.item_id) sub" + + "\n on (sub.parent_id = i.item_id" + + "\n and" + + "\n exists (select 1" + + "\n from dnm_object_1_granted_context dogc," + + "\n dnm_granted_context dgc," + + "\n dnm_permissions dp," + + "\n dnm_group_membership dgm" + + "\n where dogc.pd_object_id = sub.item_id" + + "\n and dogc.pd_context_id = dgc.pd_object_id" + + "\n and dgc.pd_context_id = dp.pd_object_id" + + "\n and dp.pd_grantee_id = dgm.pd_group_id" + + "\n and dgm.pd_member_id in (-200," + userID + ",-202)" + + "\n and dp." + TREE_DESCRIPTOR.getColumnName() + " = 1" + + "\n ) )" + + "\n where i.parent_id = " + node.getID() + + "\n and f.folder_id = i.item_id" + + "\n and exists (" + + "\n select 1 as permission_p" + + "\n from dnm_object_1_granted_context dogc," + + "\n dnm_granted_context dgc," + + "\n dnm_permissions dp," + + "\n dnm_group_membership dgm" + + "\n where dogc.pd_context_id = dgc.pd_object_id" + + "\n and dgc.pd_context_id = dp.pd_object_id" + + "\n and dgm.pd_member_id in (-200," + userID + ",-202)" + + "\n and dp.pd_grantee_id = dgm.pd_group_id" + + "\n and dogc.pd_object_id = f.folder_id" + + "\n and dp." + TREE_DESCRIPTOR.getColumnName() + " = 1 )" + + "\n group by f.label, f.folder_id" + + "\n order by lower(f.label)"; if (s_log.isDebugEnabled()) { s_log.debug("Custom SQL: \n" + sql); } m_nodes = new GenericDataQuery( - SessionManager.getSession(), - sql, - new String[] {"id", "name", "nchild"} - ); + SessionManager.getSession(), + sql, + new String[]{"id", "name", "nchild"}); } public Object next() { @@ -192,25 +193,24 @@ public class FolderTreeModelBuilder extends LockableImpl // this appears to be the only portable way to dig numbers out // of the result set id = new BigDecimal(m_nodes.get("id").toString()); - } catch (NumberFormatException nfe) {} + } catch (NumberFormatException nfe) { + } String name = m_nodes.get("name").toString(); BigDecimal count = new BigDecimal(0); try { count = new BigDecimal(m_nodes.get("nchild").toString()); - } catch (NumberFormatException nfe) {} + } catch (NumberFormatException nfe) { + } return new DataQueryTreeNode(id, name, count.intValue() > 0); } public void remove() { - throw new UnsupportedOperationException - ("cannot remove nodes via iterator"); + throw new UnsupportedOperationException("cannot remove nodes via iterator"); } public boolean hasNext() { return m_nodes.next(); } - } - } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/search/ContentTypeFilterWidget.java b/ccm-cms/src/com/arsdigita/cms/ui/search/ContentTypeFilterWidget.java index e86877432..f2642eca2 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/search/ContentTypeFilterWidget.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/search/ContentTypeFilterWidget.java @@ -18,7 +18,6 @@ */ package com.arsdigita.cms.ui.search; - import com.arsdigita.search.ui.FilterWidget; import com.arsdigita.search.Search; import com.arsdigita.search.FilterSpecification; @@ -28,38 +27,105 @@ import com.arsdigita.cms.ContentSection; import com.arsdigita.xml.Element; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.parameters.ArrayParameter; +import com.arsdigita.bebop.parameters.BigDecimalParameter; import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.cms.search.ContentTypeFilterType; import com.arsdigita.cms.search.ContentTypeFilterSpecification; +import com.arsdigita.cms.ui.ItemSearch; +import com.arsdigita.domain.DataObjectNotFoundException; +import java.math.BigDecimal; public class ContentTypeFilterWidget extends FilterWidget { - private ContentType[] m_types; + private ContentType m_parentType = null; + private ContentSection m_section = null; + private ContentTypeCollection m_types = null; public ContentTypeFilterWidget(ContentTypeCollection types) { - super(new ContentTypeFilterType(), - new ArrayParameter(new StringParameter(ContentTypeFilterType.KEY))); - - m_types = new ContentType[(int)types.size()]; - int i = 0; - while (types.next()) { - m_types[i++] = types.getContentType(); - } + super(new ContentTypeFilterType(), new ArrayParameter(new StringParameter(ContentTypeFilterType.KEY))); + m_types = types; } + public ContentTypeFilterWidget(ContentSection section) { this(section.getContentTypes()); } + public ContentTypeFilterWidget(ContentSection section, ContentType parentType) { + this(section.getSiblingsOfContentType(parentType)); + m_section = section; + m_parentType = parentType; + } + + public ContentTypeFilterWidget(ContentType parentType) { + this(ContentType.getSiblingsOf(parentType)); + m_parentType = parentType; + } + public ContentTypeFilterWidget() { this(ContentType.getRegisteredContentTypes()); } + protected ContentSection getContentSection() { + return m_section; + } + + private ContentType getParentType(PageState state) { + + ContentType ct = m_parentType; + + BigDecimal singleTypeID = + (BigDecimal) state.getValue(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM)); + + if (singleTypeID != null) { + try { + ct = new ContentType(singleTypeID); + } catch (DataObjectNotFoundException ex) { + ct = null; + } + } + + return ct; + } + protected ContentType[] getContentTypes(PageState state) { - return m_types; + + ContentType parentType = getParentType(state); + ContentTypeCollection typesCollection = m_types; + + // If the section and parent type both equals the preset from initializer + // there is no need to get a new ContentTypeCollection + if (getContentSection() != m_section && parentType != m_parentType) { + + if (getContentSection() != null) { + ContentSection section = getContentSection(); + + if (parentType == null) { + typesCollection = section.getContentTypes(); + } else { + typesCollection = section.getSiblingsOfContentType(parentType); + } + + } else { + + if (parentType == null) { + typesCollection = ContentType.getRegisteredContentTypes(); + } else { + typesCollection = ContentType.getSiblingsOf(parentType); + } + } + } + + ContentType[] typesArray = new ContentType[(int) typesCollection.size()]; + + for (int i = 0; typesCollection.next();) { + typesArray[i++] = typesCollection.getContentType(); + } + + return typesArray; } public FilterSpecification getFilter(PageState state) { - String[] types = (String[])getValue(state); + String[] types = (String[]) getValue(state); if (types == null) { types = new String[0]; @@ -68,30 +134,30 @@ public class ContentTypeFilterWidget extends FilterWidget { return new ContentTypeFilterSpecification(types); } - public void generateBodyXML(PageState state, - Element parent) { + @Override + public void generateBodyXML(PageState state, Element parent) { super.generateBodyXML(state, parent); - String[] types = (String[])getValue(state); + String[] types = (String[]) getValue(state); if (types == null) { types = new String[0]; } ContentType[] widgetTypes = getContentTypes(state); - for (int i = 0 ; i < widgetTypes.length ; i++) { + for (int i = 0; i < widgetTypes.length; i++) { Element type = Search.newElement("contentType"); type.addAttribute("name", widgetTypes[i].getAssociatedObjectType()); type.addAttribute("title", widgetTypes[i].getLabel()); - for (int j = 0 ; j < types.length ; j++) { + + for (int j = 0; j < types.length; j++) { if (types[j].equals(widgetTypes[i].getAssociatedObjectType())) { type.addAttribute("isSelected", "1"); + break; } } - - parent.addContent(type); } } 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 46f36303c..eb885e3c5 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/search/ItemQueryComponent.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/search/ItemQueryComponent.java @@ -57,79 +57,76 @@ public class ItemQueryComponent extends BaseQueryComponent { if (Search.getConfig().isIntermediaEnabled()) { add(new LaunchDateFilterWidget(new LaunchDateFilterType(), - LaunchDateFilterType.KEY)); + LaunchDateFilterType.KEY)); } - if (Search.getConfig().isIntermediaEnabled() || - Search.getConfig().isLuceneEnabled()) { + if (Search.getConfig().isIntermediaEnabled() + || Search.getConfig().isLuceneEnabled()) { add(new PermissionFilterComponent( SecurityManager.CMS_PREVIEW_ITEM)); add(new SimpleCategoryFilterWidget() { + + @Override protected Category[] getRoots(PageState state) { Category[] roots; if (CMS.getContext().hasContentSection()) { ContentSection section = CMS.getContext().getContentSection(); - roots = new Category[] { section.getRootCategory() }; + roots = new Category[]{section.getRootCategory()}; } else { ContentSectionCollection sections = - ContentSection.getAllSections(); + ContentSection.getAllSections(); List cats = new ArrayList(); while (sections.next()) { ContentSection section = sections.getContentSection(); cats.add(section.getRootCategory()); } - roots = (Category[])cats.toArray(new Category[cats.size()]); + roots = (Category[]) cats.toArray(new Category[cats.size()]); } return roots; } - }); + }); add(new ContentTypeFilterWidget() { - protected ContentType[] getContentTypes(PageState state) { - // override only if there's content section context + + @Override + protected ContentSection getContentSection() { if (CMS.getContext().hasContentSection()) { - ContentSection section = CMS.getContext().getContentSection(); - ContentTypeCollection typesCollection = section.getContentTypes(); - ContentType[] typesArray = new ContentType[(int)typesCollection.size()]; - int i = 0; - while (typesCollection.next()) { - typesArray[i++] = typesCollection.getContentType(); - } - return typesArray; + return CMS.getContext().getContentSection(); } else { - return super.getContentTypes(state); + return super.getContentSection(); } } - }); + }); add(new VersionFilterComponent(context)); add(new ContentSectionFilterComponent()); add(new DateRangeFilterWidget(new LastModifiedDateFilterType(), - LastModifiedDateFilterType.KEY)); + LastModifiedDateFilterType.KEY)); add(new DateRangeFilterWidget(new CreationDateFilterType(), - CreationDateFilterType.KEY)); + CreationDateFilterType.KEY)); add(new PartyFilterWidget(new CreationUserFilterType(), - CreationUserFilterType.KEY)); + CreationUserFilterType.KEY)); add(new PartyFilterWidget(new LastModifiedUserFilterType(), - LastModifiedUserFilterType.KEY)); + LastModifiedUserFilterType.KEY)); } Submit submit = new Submit(m_context + "_search", - ContentSectionPage.globalize("cms.ui.search")); + ContentSectionPage.globalize("cms.ui.search")); add(submit); } private class LaunchDateFilterWidget extends DateRangeFilterWidget { + public LaunchDateFilterWidget(FilterType type, String name) { - super(type,name); + super(type, name); } + public boolean isVisible(PageState state) { - return !ContentSection.getConfig().getHideLaunchDate() && - super.isVisible(state); + return !ContentSection.getConfig().getHideLaunchDate() + && super.isVisible(state); } - } } diff --git a/ccm-core/src/com/arsdigita/search/ui/ResultsPane.java b/ccm-core/src/com/arsdigita/search/ui/ResultsPane.java index 367facb7a..f656aa007 100755 --- a/ccm-core/src/com/arsdigita/search/ui/ResultsPane.java +++ b/ccm-core/src/com/arsdigita/search/ui/ResultsPane.java @@ -18,7 +18,6 @@ */ package com.arsdigita.search.ui; - import com.arsdigita.bebop.SimpleComponent; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.parameters.IntegerParameter; @@ -41,15 +40,11 @@ import java.util.Iterator; import org.apache.log4j.Logger; - public class ResultsPane extends SimpleComponent { - + private static final Logger s_log = Logger.getLogger(ResultsPane.class); - public static final int PAGE_SIZE = 10; - private int m_pageSize = PAGE_SIZE; - private String m_engine; private QueryGenerator m_query; private IntegerParameter m_pageNumber; @@ -68,15 +63,14 @@ public class ResultsPane extends SimpleComponent { } public ResultsPane(QueryGenerator query, - String engine) { + String engine) { m_query = query; m_engine = engine; m_pageNumber = new IntegerParameter("page"); m_relative = false; } - public void generateXML(PageState state, - Element parent) { + public void generateXML(PageState state, Element parent) { if (!m_query.hasQuery(state)) { if (s_log.isDebugEnabled()) { s_log.debug("No query available, skipping XMl generation"); @@ -87,86 +81,96 @@ public class ResultsPane extends SimpleComponent { QuerySpecification spec = m_query.getQuerySpecification(state); ResultSet resultSet = null; try { - resultSet = m_engine == null ? - Search.process(spec) : - Search.process(spec, - Search.DEFAULT_RESULT_CACHE, - m_engine); - + resultSet = m_engine == null + ? Search.process(spec) + : Search.process(spec, Search.DEFAULT_RESULT_CACHE, m_engine); + if (s_log.isDebugEnabled()) { - s_log.debug("Got result set " + resultSet.getClass() + - " count: " + resultSet.getCount()); + s_log.debug("Got result set " + resultSet.getClass() + + " count: " + resultSet.getCount()); } - - Integer page = (Integer) m_pageNumber.transformValue(state.getRequest()); - int pageNumber = (page == null ? 1 : page.intValue()); - long objectCount = resultSet.getCount(); - int pageCount = (int)Math.ceil((double)objectCount / (double)m_pageSize); - - if (pageNumber < 1) { - pageNumber = 1; + + if (resultSet.getCount() > 0) { + + Integer page = (Integer) m_pageNumber.transformValue(state.getRequest()); + int pageNumber = (page == null ? 1 : page.intValue()); + long objectCount = resultSet.getCount(); + int pageCount = (int) Math.ceil((double) objectCount / (double) m_pageSize); + + if (pageNumber < 1) { + pageNumber = 1; + } + + if (pageNumber > pageCount) { + pageNumber = (pageCount == 0 ? 1 : pageCount); + } + + long begin = ((pageNumber - 1) * m_pageSize); + int count = (int) Math.min(m_pageSize, (objectCount - begin)); + long end = begin + count; + + Iterator results = resultSet.getDocuments(begin, count); + + Element content = Search.newElement("results"); + exportAttributes(content); + + if (s_log.isDebugEnabled()) { + s_log.debug("Paginator stats\n page number:" + pageNumber + + "\n page count: " + pageCount + "\n page size: " + + m_pageSize + "\n start " + begin + "\n end: " + + end + "\n count: " + objectCount); + } + + content.addContent(generatePaginatorXML(state, + m_pageNumber.getName(), + pageNumber, pageCount, + m_pageSize, begin, end, + objectCount)); + content.addContent(generateDocumentsXML(state, results)); + + parent.addContent(content); + } else { + // No search result, so we don't need a paginator, but we want + // to inform the user, that there are no results for this search + Element content = Search.newElement("results"); + Element info = content.newChildElement("info"); +// info.setText(GlobalizationUtil.globalize("cms.ui.search_no_results").localize().toString()); + info.setText("Sorry. Your search returned 0 results."); + parent.addContent(content); } - - if (pageNumber > pageCount) { - pageNumber = (pageCount == 0 ? 1 : pageCount); - } - - long begin = ((pageNumber-1) * m_pageSize); - int count = (int)Math.min(m_pageSize, (objectCount - begin)); - long end = begin + count; - - Iterator results = resultSet.getDocuments(begin, count); - - Element content = Search.newElement("results"); - exportAttributes(content); - - if (s_log.isDebugEnabled()) { - s_log.debug("Paginator stats\n page number:" + pageNumber + - "\n page count: "+ pageCount + "\n page size: " + - m_pageSize + "\n start " + begin + "\n end: " + - end + "\n count: "+ objectCount); - } - - content.addContent(generatePaginatorXML(state, - m_pageNumber.getName(), - pageNumber, pageCount, - m_pageSize, begin, end, - objectCount)); - content.addContent(generateDocumentsXML(state, results)); - - parent.addContent(content); + } finally { - if(resultSet != null) { - try { - resultSet.close(); - } catch (Exception e) { - /* - * If there is a problem closing the result set this probably means - * it has been closed elsewhere and is probably not fatal. We write - * a line to the error log but otherwise ignore the exception allowing - * the code to continue normally. Any issues willemerge in the log. - */ - s_log.error("Error closing resultset: "+e.getMessage()); - } + if (resultSet != null) { + try { + resultSet.close(); + } catch (Exception e) { + /* + * If there is a problem closing the result set this probably means + * it has been closed elsewhere and is probably not fatal. We write + * a line to the error log but otherwise ignore the exception allowing + * the code to continue normally. Any issues willemerge in the log. + */ + s_log.error("Error closing resultset: " + e.getMessage()); + } } } } protected Element generatePaginatorXML(PageState state, - String pageParam, - int pageNumber, - int pageCount, - int pageSize, - long begin, - long end, - long objectCount) { + String pageParam, + int pageNumber, + int pageCount, + int pageSize, + long begin, + long end, + long objectCount) { Element paginator = Search.newElement("paginator"); URL url = Web.getContext().getRequestURL(); - + ParameterMap map = new ParameterMap(); Iterator current = url.getParameterMap().keySet().iterator(); while (current.hasNext()) { - String key = (String)current.next(); + String key = (String) current.next(); if (key.equals(pageParam)) { continue; } @@ -174,43 +178,42 @@ public class ResultsPane extends SimpleComponent { } paginator.addAttribute("pageParam", m_pageNumber.getName()); - paginator.addAttribute("baseURL", URL.there(url.getPathInfo(), map) - .toString()); + paginator.addAttribute("baseURL", URL.there(url.getPathInfo(), map).toString()); paginator.addAttribute("pageNumber", XML.format(new Integer(pageNumber))); paginator.addAttribute("pageCount", XML.format(new Integer(pageCount))); paginator.addAttribute("pageSize", XML.format(new Integer(pageSize))); - paginator.addAttribute("objectBegin", XML.format(new Long(begin+1))); + paginator.addAttribute("objectBegin", XML.format(new Long(begin + 1))); paginator.addAttribute("objectEnd", XML.format(new Long(end))); paginator.addAttribute("objectCount", XML.format(new Long(objectCount))); return paginator; } protected Element generateDocumentsXML(PageState state, - Iterator results) { + Iterator results) { Element documents = Search.newElement("documents"); - + if (s_log.isDebugEnabled()) { s_log.debug("Outputting documents"); } while (results.hasNext()) { - Document doc = (Document)results.next(); + Document doc = (Document) results.next(); if (s_log.isDebugEnabled()) { s_log.debug("One doc " + doc.getOID() + " " + doc.getTitle()); } documents.addContent(generateDocumentXML(state, doc)); } - + return documents; } - + protected Element generateDocumentXML(PageState state, - Document doc) { + Document doc) { Element entry = Search.newElement("object"); - + String summary = doc.getSummary(); java.net.URL url = doc.getURL(); - + entry.addAttribute("oid", XML.format(doc.getOID())); entry.addAttribute("url", XML.format(m_relative ? url.getPath() + "?" + url.getQuery() : url.toString())); entry.addAttribute("score", XML.format(doc.getScore())); @@ -218,35 +221,33 @@ public class ResultsPane extends SimpleComponent { if (summary != null) { entry.addAttribute("summary", XML.format(summary)); } - + entry.addAttribute("locale", XML.format(doc.getLocale())); - + Date creationDate = doc.getCreationDate(); if (creationDate != null) { entry.addAttribute("creationDate", XML.format(creationDate.toString())); } Party creationParty = doc.getCreationParty(); if (creationParty != null) { - entry.addAttribute("creationParty", - XML.format(creationParty.getDisplayName())); + entry.addAttribute("creationParty", + XML.format(creationParty.getDisplayName())); } - + Date lastModifiedDate = doc.getLastModifiedDate(); if (lastModifiedDate != null) { - entry.addAttribute("lastModifiedDate", - XML.format(lastModifiedDate)); + entry.addAttribute("lastModifiedDate", + XML.format(lastModifiedDate)); } Party lastModifiedParty = doc.getLastModifiedParty(); if (lastModifiedParty != null) { - entry.addAttribute("lastModifiedParty", - XML.format(lastModifiedParty.getDisplayName())); + entry.addAttribute("lastModifiedParty", + XML.format(lastModifiedParty.getDisplayName())); } - s_log.debug("about to add the contentSectionName from search index Doc to search result xml"); - entry.addAttribute("contentSectionName", XML.format(doc.getContentSection())); - + s_log.debug("about to add the contentSectionName from search index Doc to search result xml"); + entry.addAttribute("contentSectionName", XML.format(doc.getContentSection())); + return entry; } - - }