ItemSearchWidget

Dieverse Änderungen am ItemSearchWidget

 * Übersetzung vom Browse-Pane
 * Such-Fomular erweitert, so daß die Liste der Contenttypen jetzt durch den Basis-CT eingeschränkt wird.
 * viele andere Kleinigkeiten - hauptsächlich Formatierung

git-svn-id: https://svn.libreccm.org/ccm/trunk@636 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2010-11-25 18:16:01 +00:00
parent e3d3b435ac
commit b57e0d9474
18 changed files with 754 additions and 767 deletions

View File

@ -28,7 +28,6 @@ package com.arsdigita.cms;
* // URL resource: protocol handler removal: START * // URL resource: protocol handler removal: START
* Will be removed as soon as a stable release 6.6 is created. * Will be removed as soon as a stable release 6.6 is created.
*/ */
import com.arsdigita.bebop.SimpleComponent; import com.arsdigita.bebop.SimpleComponent;
import com.arsdigita.bebop.form.DHTMLEditor; import com.arsdigita.bebop.form.DHTMLEditor;
import com.arsdigita.categorization.Category; import com.arsdigita.categorization.Category;
@ -117,318 +116,223 @@ public final class CMSConfig extends AbstractConfig {
return s_config; return s_config;
} }
/** /**
* Storage (map) for method getAssetStepsToSkip(ContentType type) to store * Storage (map) for method getAssetStepsToSkip(ContentType type) to store
* mapping of steps that are deemed irrelevant for the passid in type. * 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 * Item category add form speciofies Subclass of ItemCategoryForm
* to use for the assign categories step. * to use for the assign categories step.
* Used in c.ad.cms.ui.authoring.ItemCategoryStep * Used in c.ad.cms.ui.authoring.ItemCategoryStep
*/ */
private final Parameter private final Parameter m_categoryAuthoringAddForm = new SpecificClassParameter("com.arsdigita.cms.category_authoring_add_form",
m_categoryAuthoringAddForm = new SpecificClassParameter Parameter.REQUIRED,
("com.arsdigita.cms.category_authoring_add_form", ItemCategoryForm.class,
Parameter.REQUIRED, SimpleComponent.class);
ItemCategoryForm.class,
SimpleComponent.class);
/** /**
* Path for the default item template. Path is relative to the * Path for the default item template. Path is relative to the
* Template Root path. * Template Root path.
*/ */
private final Parameter private final Parameter m_defaultItemTemplatePath = new StringParameter("com.arsdigita.cms.default_item_template_path",
m_defaultItemTemplatePath = new StringParameter Parameter.REQUIRED, "/default/item.jsp");
("com.arsdigita.cms.default_item_template_path",
Parameter.REQUIRED, "/default/item.jsp");
/** /**
* Path for the default folder template. Path is relative to the * Path for the default folder template. Path is relative to the
* Template Root path. * Template Root path.
*/ */
private final Parameter private final Parameter m_defaultFolderTemplatePath = new StringParameter("com.arsdigita.cms.default_folder_template_path",
m_defaultFolderTemplatePath = new StringParameter Parameter.REQUIRED, "/default/folder.jsp");
("com.arsdigita.cms.default_folder_template_path",
Parameter.REQUIRED, "/default/folder.jsp");
/** /**
* Path for the default template folder. Path is relative to webapp root * Path for the default template folder. Path is relative to webapp root
*/ */
private final Parameter private final Parameter m_templateRootPath = new StringParameter("com.arsdigita.cms.template_root_path",
m_templateRootPath = new StringParameter Parameter.REQUIRED, "/packages/content-section/templates");
("com.arsdigita.cms.template_root_path", // URL resource: protocol handler removal: START
Parameter.REQUIRED, "/packages/content-section/templates"); // remove:
// try {
// m_itemAdapters = new URLParameter
// URL resource: protocol handler removal: START // ("com.arsdigita.cms.item_adapters",
// remove: // Parameter.REQUIRED,
// try { // new URL("resource:WEB-INF/resources/cms-item-adapters.xml"));
// m_itemAdapters = new URLParameter // } catch (MalformedURLException ex) {
// ("com.arsdigita.cms.item_adapters", // throw new UncheckedWrapperException("Cannot parse URL", ex);
// Parameter.REQUIRED, // }
// new URL("resource:WEB-INF/resources/cms-item-adapters.xml")); // ADD:
// } catch (MalformedURLException ex) {
// throw new UncheckedWrapperException("Cannot parse URL", ex);
// }
// ADD:
/** /**
* Item Adapters File, path to an XML resource containing adapter * Item Adapters File, path to an XML resource containing adapter
* specifications. Path is relative to webapp root. * specifications. Path is relative to webapp root.
*/ */
private final Parameter private final Parameter m_itemAdapters = new ResourceParameter("com.arsdigita.cms.item_adapters",
m_itemAdapters = new ResourceParameter Parameter.REQUIRED,
("com.arsdigita.cms.item_adapters", "/WEB-INF/resources/cms-item-adapters.xml");
Parameter.REQUIRED, // URL resource: protocol handler removal: END
"/WEB-INF/resources/cms-item-adapters.xml");
// URL resource: protocol handler removal: END
/** /**
* Use streamlined content creation: upon item creation, * Use streamlined content creation: upon item creation,
* automatically open authoring steps and forward to the next step * automatically open authoring steps and forward to the next step
*/ */
private final Parameter private final Parameter m_useStreamlinedCreation = new BooleanParameter("com.arsdigita.cms.use_streamlined_creation",
m_useStreamlinedCreation = new BooleanParameter Parameter.REQUIRED, new Boolean(true));
("com.arsdigita.cms.use_streamlined_creation",
Parameter.REQUIRED, new Boolean(true));
/** /**
* DHTML Editor Configuration for use in CMS module, lists the * DHTML Editor Configuration for use in CMS module, lists the
* config object name and Javascript source location for its definition. * config object name and Javascript source location for its definition.
*/ */
private final Parameter private final Parameter m_dhtmlEditorConfig = new DHTMLEditorConfigParameter("com.arsdigita.cms.dhtml_editor_config",
m_dhtmlEditorConfig = new DHTMLEditorConfigParameter Parameter.REQUIRED,
("com.arsdigita.cms.dhtml_editor_config", new DHTMLEditor.Config("XinhaConfig",
Parameter.REQUIRED, "/assets/xinha/CCMcmsXinhaConfig.js"));
new DHTMLEditor.Config( "XinhaConfig", // previous parameter definition:
"/assets/xinha/CCMcmsXinhaConfig.js") ); // > DHTMLEditor.Config.STANDARD); <
// previous parameter definition: // didn't work because of broken unmarshalling (cf. similiar problem
// > DHTMLEditor.Config.STANDARD); < // with ResourceParameter and patch provided by Brad). It work for
// didn't work because of broken unmarshalling (cf. similiar problem // HTMLArea, because configuration was hard coded into xsl(!).
// with ResourceParameter and patch provided by Brad). It work for // Additionally, we would like to use a specific configuration for cms
// HTMLArea, because configuration was hard coded into xsl(!). // to include cms specific functions (like access to internal .
// Additionally, we would like to use a specific configuration for cms // content items for links and internal image assets, which may not
// to include cms specific functions (like access to internal . // be accessable by other modules which use DHTMLeditor.
// content items for links and internal image assets, which may not // Would be bad style to configure a cms specific parameter in core.
// 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 * Defines which plugins to use, e.g.TableOperations,CSS
* Format: [string,string,string] * Format: [string,string,string]
*/ */
private final Parameter private final Parameter m_dhtmlEditorPlugins = new StringArrayParameter("com.arsdigita.cms.dhtml_editor_plugins",
m_dhtmlEditorPlugins = new StringArrayParameter Parameter.OPTIONAL,
("com.arsdigita.cms.dhtml_editor_plugins", null);
Parameter.OPTIONAL,
null);
/** /**
* Prevent undesirable functions from being made available, * Prevent undesirable functions from being made available,
* eg images should only be added through the cms methods. * eg images should only be added through the cms methods.
*/ */
private final Parameter private final Parameter m_dhtmlEditorHiddenButtons = new StringArrayParameter("com.arsdigita.cms.dhtml_editor_hidden_buttons",
m_dhtmlEditorHiddenButtons = new StringArrayParameter Parameter.OPTIONAL,
("com.arsdigita.cms.dhtml_editor_hidden_buttons", null);
Parameter.OPTIONAL,
null);
/** /**
* Hide section admin tabs from users without administrative rights. * Hide section admin tabs from users without administrative rights.
*/ */
private final Parameter private final Parameter m_hideAdminTabs = new BooleanParameter("com.arsdigita.cms.hide_admin_tabs",
m_hideAdminTabs = new BooleanParameter Parameter.REQUIRED, new Boolean(false));
("com.arsdigita.cms.hide_admin_tabs",
Parameter.REQUIRED, new Boolean(false));
/** /**
* Hide Folder Index Checkbox from folder view * Hide Folder Index Checkbox from folder view
*/ */
private final Parameter private final Parameter m_hideFolderIndexCheckbox = new BooleanParameter("com.arsdigita.cms.hide_folder_index_checkbox",
m_hideFolderIndexCheckbox = new BooleanParameter Parameter.REQUIRED, new Boolean(false));
("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. * Hide launch date parameter on all forms and displays where it's used.
*/ */
private final Parameter private final Parameter m_hideLaunchDate = new BooleanParameter("com.arsdigita.cms.hide_launch_date",
m_hideLaunchDate = new BooleanParameter Parameter.REQUIRED, new Boolean(true));
("com.arsdigita.cms.hide_launch_date",
Parameter.REQUIRED, new Boolean(true));
/** /**
* Require the launch date parameter to be set by the content author. * Require the launch date parameter to be set by the content author.
*/ */
private final Parameter private final Parameter m_requireLaunchDate = new BooleanParameter("com.arsdigita.cms.require_launch_date",
m_requireLaunchDate = new BooleanParameter Parameter.REQUIRED, new Boolean(false));
("com.arsdigita.cms.require_launch_date",
Parameter.REQUIRED, new Boolean(false));
/** /**
* Hide the templates tab on the item admin page. * Hide the templates tab on the item admin page.
*/ */
private final Parameter private final Parameter m_hideTemplatesTab = new BooleanParameter("com.arsdigita.cms.hide_templates_tab",
m_hideTemplatesTab = new BooleanParameter Parameter.REQUIRED, new Boolean(false));
("com.arsdigita.cms.hide_templates_tab",
Parameter.REQUIRED, new Boolean(false));
/** /**
* Hide the upload file link in the editing of a text asset. * Hide the upload file link in the editing of a text asset.
*/ */
private final Parameter private final Parameter m_hideTextAssetUploadFile = new BooleanParameter("com.arsdigita.cms.hide_text_asset_upload_file",
m_hideTextAssetUploadFile = new BooleanParameter Parameter.REQUIRED,
("com.arsdigita.cms.hide_text_asset_upload_file", new Boolean(false));
Parameter.REQUIRED,
new Boolean(false));
/** /**
* Hide timezone labels (if, for example, all users will be in the * Hide timezone labels (if, for example, all users will be in the
* same timezone and such information would be unnecessary) * same timezone and such information would be unnecessary)
*/ */
private final Parameter private final Parameter m_hideTimezone = new BooleanParameter("com.arsdigita.cms.hide_timezone",
m_hideTimezone = new BooleanParameter Parameter.REQUIRED, new Boolean(false));
("com.arsdigita.cms.hide_timezone",
Parameter.REQUIRED, new Boolean(false));
/** /**
* Hide User Defined Content Types UI * Hide User Defined Content Types UI
*/ */
private final Parameter private final Parameter m_hideUDCTUI = new BooleanParameter("com.arsdigita.cms.hide_udct_ui",
m_hideUDCTUI = new BooleanParameter Parameter.REQUIRED, new Boolean(false));
("com.arsdigita.cms.hide_udct_ui",
Parameter.REQUIRED, new Boolean(false));
/** /**
* Specifies the name of the class to use as a PublishLifecycleListener * Specifies the name of the class to use as a PublishLifecycleListener
*/ */
private final Parameter private final Parameter m_publishLifecycleListenerClass = new StringParameter("com.arsdigita.cms.publish_lifecycle_listener_class",
m_publishLifecycleListenerClass = new StringParameter Parameter.OPTIONAL, PublishLifecycleListener.class.getName());
("com.arsdigita.cms.publish_lifecycle_listener_class",
Parameter.OPTIONAL, PublishLifecycleListener.class.getName());
/** /**
* Wether the Wysiwyg editor should clear the text of MSWord tags, * Wether the Wysiwyg editor should clear the text of MSWord tags,
* everytime the user clicks on 'Save' * everytime the user clicks on 'Save'
*/ */
private final Parameter private final Parameter m_saveTextCleansWordTags = new BooleanParameter("com.arsdigita.cms.save_text_cleans_word_tags",
m_saveTextCleansWordTags = new BooleanParameter Parameter.OPTIONAL, new Boolean(false));
("com.arsdigita.cms.save_text_cleans_word_tags",
Parameter.OPTIONAL, new Boolean(false));
/** /**
* Hide Additional Resource Fields on RelatedLinkPropertyForm * Hide Additional Resource Fields on RelatedLinkPropertyForm
*/ */
private final Parameter private final Parameter m_hideAdditionalResourceFields = new BooleanParameter("com.arsdigita.cms.contentassets.ui."
m_hideAdditionalResourceFields = new BooleanParameter + "RelatedLinkPropertyForm.hideAdditionalResourceFields",
("com.arsdigita.cms.contentassets.ui."+ Parameter.REQUIRED, new Boolean(false));
"RelatedLinkPropertyForm.hideAdditionalResourceFields",
Parameter.REQUIRED, new Boolean(false));
/** /**
* Get the search indexing not to process FileAssets, * Get the search indexing not to process FileAssets,
* eg to avoid PDF slowdowns * eg to avoid PDF slowdowns
*/ */
private final Parameter private final Parameter m_disableFileAssetExtraction = new BooleanParameter("com.arsdigita.cms.search.disableFileAssetExtraction",
m_disableFileAssetExtraction = new BooleanParameter Parameter.REQUIRED, new Boolean(false));
("com.arsdigita.cms.search.disableFileAssetExtraction",
Parameter.REQUIRED, new Boolean(false));
/** /**
* Whether an item's workflow should be deleted, once the item * Whether an item's workflow should be deleted, once the item
* has been (re)published * has been (re)published
*/ */
private final Parameter private final Parameter m_deleteWorkflowAfterPublication = new BooleanParameter("com.arsdigita.cms.delete_workflow_after_publication",
m_deleteWorkflowAfterPublication = new BooleanParameter Parameter.REQUIRED, new Boolean(true));
("com.arsdigita.cms.delete_workflow_after_publication",
Parameter.REQUIRED, new Boolean(true));
/** /**
* Defines the number of days ahead that are covered in the * Defines the number of days ahead that are covered in the
* 'Soon Expired' tab * 'Soon Expired' tab
*/ */
private final Parameter private final Parameter m_soonExpiredTimespanDays = new IntegerParameter("com.arsdigita.cms.soon_expired_timespan_days",
m_soonExpiredTimespanDays = new IntegerParameter Parameter.REQUIRED, new Integer(14));
("com.arsdigita.cms.soon_expired_timespan_days",
Parameter.REQUIRED, new Integer(14));
/** /**
* Defines the number of months ahead that are covered in the * Defines the number of months ahead that are covered in the
* 'Soon Expired' tab * 'Soon Expired' tab
*/ */
private final Parameter private final Parameter m_soonExpiredTimespanMonths = new IntegerParameter("com.arsdigita.cms.soon_expired_timespan_months",
m_soonExpiredTimespanMonths = new IntegerParameter Parameter.REQUIRED, new Integer(1));
("com.arsdigita.cms.soon_expired_timespan_months",
Parameter.REQUIRED, new Integer(1));
/** /**
* Does a redirect to the unpublished item generate not found error? * Does a redirect to the unpublished item generate not found error?
*/ */
private final Parameter private final Parameter m_unpublishedNotFound = new BooleanParameter("com.arsdigita.cms.unpublished_not_found",
m_unpublishedNotFound = new BooleanParameter Parameter.REQUIRED, new Boolean(true));
("com.arsdigita.cms.unpublished_not_found",
Parameter.REQUIRED, new Boolean(true));
/** /**
* Links created through browse interfaces should only be within the * Links created through browse interfaces should only be within the
* same subsite * same subsite
*/ */
private final Parameter private final Parameter m_linksOnlyInSameSubsite = new BooleanParameter("com.arsdigita.cms.browse_links_in_same_subsite_only",
m_linksOnlyInSameSubsite = new BooleanParameter Parameter.REQUIRED, new Boolean(false));
("com.arsdigita.cms.browse_links_in_same_subsite_only",
Parameter.REQUIRED, new Boolean(false));
/** /**
* Item category step extension hook: Subclass of ItemCategoryExtension * Item category step extension hook: Subclass of ItemCategoryExtension
* which adds extension actions for the category authoring step * which adds extension actions for the category authoring step
*/ */
private final Parameter private final Parameter m_categoryAuthoringExtension = new SpecificClassParameter("com.arsdigita.cms.category_authoring_extension",
m_categoryAuthoringExtension = new SpecificClassParameter Parameter.REQUIRED,
("com.arsdigita.cms.category_authoring_extension", ItemCategoryExtension.class,
Parameter.REQUIRED, ItemCategoryExtension.class);
ItemCategoryExtension.class,
ItemCategoryExtension.class);
/** /**
* Link available to reset lifecycle on republish. If false don't display * Link available to reset lifecycle on republish. If false don't display
* the link otherwise display. * the link otherwise display.
*/ */
private final Parameter private final Parameter m_hideResetLifecycleLink = new BooleanParameter("com.arsdigita.cms.hide_reset_lifecycle_link",
m_hideResetLifecycleLink = new BooleanParameter Parameter.OPTIONAL, new Boolean(true));
("com.arsdigita.cms.hide_reset_lifecycle_link",
Parameter.OPTIONAL, new Boolean(true));
/** /**
* Whether to include INPATH operators to contains clause in intermedia search * Whether to include INPATH operators to contains clause in intermedia search
*/ */
private final Parameter private final Parameter m_scoreTitleAndKeywords = new BooleanParameter("com.arsdigita.cms.search.score_title_and_keywords",
m_scoreTitleAndKeywords = new BooleanParameter Parameter.OPTIONAL,
("com.arsdigita.cms.search.score_title_and_keywords", Boolean.FALSE);
Parameter.OPTIONAL,
Boolean.FALSE);
/** /**
* Title Weight, the relative weight given to title element within * Title Weight, the relative weight given to title element within
* cms:item when ranking search results (only used by interMedia) * cms:item when ranking search results (only used by interMedia)
*/ */
private final Parameter private final Parameter m_titleWeight = new IntegerParameter("com.arsdigita.cms.search.intermedia.title_weight",
m_titleWeight = new IntegerParameter Parameter.OPTIONAL,
("com.arsdigita.cms.search.intermedia.title_weight", new Integer(1));
Parameter.OPTIONAL,
new Integer(1));
/** /**
* Keyword Weight, the relative weight given to the dcKeywords element * Keyword Weight, the relative weight given to the dcKeywords element
* within dublinCore element within cms:item element when ranking * within dublinCore element within cms:item element when ranking
* search results (only used by interMedia) * search results (only used by interMedia)
*/ */
private final Parameter private final Parameter m_keywordWeight = new IntegerParameter("com.arsdigita.cms.search.intermedia.keyword_weight",
m_keywordWeight = new IntegerParameter Parameter.OPTIONAL,
("com.arsdigita.cms.search.intermedia.keyword_weight", new Integer(1));
Parameter.OPTIONAL,
new Integer(1));
/** /**
* Asset steps to skip, specify asset steps that are not relevant for * Asset steps to skip, specify asset steps that are not relevant for
* specific content types. * specific content types.
@ -438,101 +342,69 @@ public final class CMSConfig extends AbstractConfig {
* Second string is the name of the bebop step component * Second string is the name of the bebop step component
* eg com.arsdigita.cms.contenttypes.ui.ImageStep * eg com.arsdigita.cms.contenttypes.ui.ImageStep
*/ */
private final Parameter private final Parameter m_skipAssetSteps = new StringArrayParameter("com.arsdigita.cms.skip_asset_steps",
m_skipAssetSteps = new StringArrayParameter
("com.arsdigita.cms.skip_asset_steps",
Parameter.OPTIONAL, Parameter.OPTIONAL,
null); null);
/** /**
* Mandatory Descriptions Content types may refer to this to decide * Mandatory Descriptions Content types may refer to this to decide
* whether to validate against empty descriptions * whether to validate against empty descriptions
*/ */
private final Parameter private final Parameter m_mandatoryDescriptions = new BooleanParameter("com.arsdigita.cms.mandatory_descriptions",
m_mandatoryDescriptions = new BooleanParameter Parameter.OPTIONAL, new Boolean(false));
("com.arsdigita.cms.mandatory_descriptions",
Parameter.OPTIONAL, new Boolean(false));
/** /**
* Delete Finished Lifecycles. Decide whether lifecycles and their phases * Delete Finished Lifecycles. Decide whether lifecycles and their phases
* should be deleted from the system when finished. * should be deleted from the system when finished.
*/ */
private final Parameter private final Parameter m_deleteLifecycleWhenComplete = new BooleanParameter("com.arsdigita.cms.delete_lifecycle_when_complete",
m_deleteLifecycleWhenComplete = new BooleanParameter Parameter.OPTIONAL, new Boolean(false));
("com.arsdigita.cms.delete_lifecycle_when_complete",
Parameter.OPTIONAL, new Boolean(false));
/** /**
* Contacts for content items. Allows you to add a Contact authoring step * Contacts for content items. Allows you to add a Contact authoring step
* to all items * to all items
*/ */
private final Parameter private final Parameter m_hasContactsAuthoringStep = new BooleanParameter("com.arsdigita.cms.has_contacts_authoring_step",
m_hasContactsAuthoringStep = new BooleanParameter Parameter.REQUIRED, new Boolean(false));
("com.arsdigita.cms.has_contacts_authoring_step",
Parameter.REQUIRED, new Boolean(false));
/** /**
* Ordering for nodes in assign category tree. Decide whether entries * Ordering for nodes in assign category tree. Decide whether entries
* should be ordered alphabetically or according to sort key * should be ordered alphabetically or according to sort key
* (maintained in category admin tab in content centre) * (maintained in category admin tab in content centre)
* SortKey|Alphabetical is initialized in constructor! See below. * SortKey|Alphabetical is initialized in constructor! See below.
*/ */
private final Parameter private final Parameter m_categoryTreeOrdering = new EnumerationParameter("com.arsdigita.cms.category_tree_order",
m_categoryTreeOrdering = new EnumerationParameter Parameter.OPTIONAL, Category.SORT_KEY);
("com.arsdigita.cms.category_tree_order",
Parameter.OPTIONAL, Category.SORT_KEY );
/** /**
* Allow content creation in section listing. Allows you to turn off * Allow content creation in section listing. Allows you to turn off
* the ability to create content in the section listing * the ability to create content in the section listing
*/ */
private final Parameter private final Parameter m_allowContentCreateInSectionListing = new BooleanParameter("com.arsdigita.cms.allow_content_create_in_section_listing",
m_allowContentCreateInSectionListing = new BooleanParameter Parameter.REQUIRED,
("com.arsdigita.cms.allow_content_create_in_section_listing", new Boolean(true));
Parameter.REQUIRED,
new Boolean(true));
// /////////////////////////////////////////// // ///////////////////////////////////////////
// Notification related parameters // Notification related parameters
// /////////////////////////////////////////// // ///////////////////////////////////////////
/** /**
* Delete Sent Workflow Notifications. Decide whether successfully sent * Delete Sent Workflow Notifications. Decide whether successfully sent
* notifications and messages should be deleted from the system * notifications and messages should be deleted from the system
*/ */
private final Parameter private final Parameter m_deleteWorkflowNotificationsWhenSent = new BooleanParameter("com.arsdigita.cms.delete_workflow_notification_when_sent",
m_deleteWorkflowNotificationsWhenSent = new BooleanParameter Parameter.OPTIONAL, new Boolean(false));
("com.arsdigita.cms.delete_workflow_notification_when_sent",
Parameter.OPTIONAL, new Boolean(false));
/** /**
* Decide whether successfully sent notifications and messages * Decide whether successfully sent notifications and messages
* should be deleted from the system * should be deleted from the system
*/ */
private final Parameter private final Parameter m_deleteExpiryNotificationsWhenSent = new BooleanParameter("com.arsdigita.cms.delete_expiry_notification_when_sent",
m_deleteExpiryNotificationsWhenSent = new BooleanParameter Parameter.OPTIONAL, new Boolean(false));
("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 * Amount of time (in hours) before the expiration of a content item
* that users in the Alert Recipient role are alerted via email * that users in the Alert Recipient role are alerted via email
*/ */
private final Parameter private final Parameter m_defaultNotificationTime = new IntegerParameter("com.arsdigita.cms.default_notification_time",
m_defaultNotificationTime = new IntegerParameter Parameter.REQUIRED, new Integer(0));
("com.arsdigita.cms.default_notification_time",
Parameter.REQUIRED, new Integer(0));
/** /**
* Wether a content item's author should be notified * Wether a content item's author should be notified
* by the item's LifecycleListener; defaults to true * by the item's LifecycleListener; defaults to true
*/ */
private final Parameter private final Parameter m_notifyAuthorOnLifecycle = new BooleanParameter("com.arsdigita.cms.notify_author_on_lifecycle",
m_notifyAuthorOnLifecycle = new BooleanParameter Parameter.OPTIONAL, new Boolean(true));
("com.arsdigita.cms.notify_author_on_lifecycle",
Parameter.OPTIONAL, new Boolean(true));
// //////////////////////////////////////////////////// // ////////////////////////////////////////////////////
// Content Center (Workspace) config related parameters // 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 * XML Mapping of the content center tabs to URLs, see
* {@link ContentCenterDispatcher} * {@link ContentCenterDispatcher}
*/ */
private final StringParameter private final StringParameter m_contentCenterMap = new StringParameter(
m_contentCenterMap = new StringParameter( "com.arsdigita.cms.loader.content_center_map",
"com.arsdigita.cms.loader.content_center_map", Parameter.REQUIRED,
Parameter.REQUIRED, "/WEB-INF/resources/content-center-map.xml");
"/WEB-INF/resources/content-center-map.xml");
// /////////////////////////////////////////// // ///////////////////////////////////////////
// Content Section config related parameters // Content Section config related parameters
// /////////////////////////////////////////// // ///////////////////////////////////////////
private final Parameter private final Parameter m_defaultSection = new StringParameter("com.arsdigita.cms.default_content_section",
m_defaultSection = new StringParameter Parameter.REQUIRED, "content");
("com.arsdigita.cms.default_content_section",
Parameter.REQUIRED, "content");
// /////////////////////////////////////////// // ///////////////////////////////////////////
// Content Section creation parameters // Content Section creation parameters
// XXX these are probably temporary parameters, as the // 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 // to SectionInitializer. However, it still may be useful to
// keep these for the default values. // keep these for the default values.
// /////////////////////////////////////////// // ///////////////////////////////////////////
private final Parameter private final Parameter m_defaultItemResolverClass = new SpecificClassParameter("com.arsdigita.cms.default_item_resolver_class",
m_defaultItemResolverClass = new SpecificClassParameter Parameter.REQUIRED,
("com.arsdigita.cms.default_item_resolver_class", MultilingualItemResolver.class,
Parameter.REQUIRED, ItemResolver.class);
MultilingualItemResolver.class, private final Parameter m_defaultTemplateResolverClass = new SpecificClassParameter("com.arsdigita.cms.default_template_resolver_class",
ItemResolver.class); Parameter.REQUIRED,
DefaultTemplateResolver.class,
private final Parameter TemplateResolver.class);
m_defaultTemplateResolverClass = new SpecificClassParameter /////////////////////////////////////////////
("com.arsdigita.cms.default_template_resolver_class", // ItemSearchWidget
Parameter.REQUIRED, /////////////////////////////////////////////
DefaultTemplateResolver.class, private final Parameter m_itemSearchDefaultTab = new StringParameter("com.arsdigita.cms.item_search.default_tab",
TemplateResolver.class); Parameter.REQUIRED, "browse");
// /////////////////////////////////////////// // ///////////////////////////////////////////
// publishToFile package related parameter // publishToFile package related parameter
// /////////////////////////////////////////// // ///////////////////////////////////////////
// Moved to publishToFile.PublishToFileConfig as of version 6.0.2 // Moved to publishToFile.PublishToFileConfig as of version 6.0.2
// private final Parameter m_disableItemPfs; // private final Parameter m_disableItemPfs;
// private final Parameter m_publishToFileClass; // private final Parameter m_publishToFileClass;
/** /**
* Constructor, but do NOT instantiate this class directly. * Constructor, but do NOT instantiate this class directly.
* *
@ -593,11 +455,11 @@ public final class CMSConfig extends AbstractConfig {
**/ **/
public CMSConfig() { public CMSConfig() {
// Initialize m_categoryTreeOrdering parameter here! // Initialize m_categoryTreeOrdering parameter here!
// 2 valid values at the moment - enumeration used rather than boolean // 2 valid values at the moment - enumeration used rather than boolean
// in case other possible orders are deemed valid // in case other possible orders are deemed valid
((EnumerationParameter)m_categoryTreeOrdering).put("SortKey", Category.SORT_KEY ); ((EnumerationParameter) m_categoryTreeOrdering).put("SortKey", Category.SORT_KEY);
((EnumerationParameter)m_categoryTreeOrdering).put("Alphabetical", Category.NAME); ((EnumerationParameter) m_categoryTreeOrdering).put("Alphabetical", Category.NAME);
register(m_templateRootPath); register(m_templateRootPath);
@ -652,6 +514,8 @@ public final class CMSConfig extends AbstractConfig {
register(m_defaultItemResolverClass); register(m_defaultItemResolverClass);
register(m_defaultTemplateResolverClass); register(m_defaultTemplateResolverClass);
register(m_itemSearchDefaultTab);
// publishToFile package related parameter // publishToFile package related parameter
// Moved to publishToFile.PublishToFileConfig as of version 6.0.2 // Moved to publishToFile.PublishToFileConfig as of version 6.0.2
// register(m_disableItemPfs); // register(m_disableItemPfs);
@ -685,15 +549,15 @@ public final class CMSConfig extends AbstractConfig {
} }
public final InputStream getItemAdapters() { public final InputStream getItemAdapters() {
// URL resource: protocol handler removal: START // URL resource: protocol handler removal: START
// remove: // remove:
// try { // try {
// return ((URL)get(m_itemAdapters)).openStream(); // return ((URL)get(m_itemAdapters)).openStream();
// } catch (IOException ex) { // } catch (IOException ex) {
// throw new UncheckedWrapperException("Cannot read stream", ex); // throw new UncheckedWrapperException("Cannot read stream", ex);
// } // }
// ADD: // ADD:
return (InputStream)get(m_itemAdapters); return (InputStream) get(m_itemAdapters);
} }
public final String getDefaultContentSection() { public final String getDefaultContentSection() {
@ -705,15 +569,15 @@ public final class CMSConfig extends AbstractConfig {
} }
public final DHTMLEditor.Config getDHTMLEditorConfig() { public final DHTMLEditor.Config getDHTMLEditorConfig() {
return (DHTMLEditor.Config)get(m_dhtmlEditorConfig); return (DHTMLEditor.Config) get(m_dhtmlEditorConfig);
} }
public final String[] getDHTMLEditorPlugins() { public final String[] getDHTMLEditorPlugins() {
return (String[])get(m_dhtmlEditorPlugins); return (String[]) get(m_dhtmlEditorPlugins);
} }
public final String[] getDHTMLEditorHiddenButtons() { public final String[] getDHTMLEditorHiddenButtons() {
return (String[])get(m_dhtmlEditorHiddenButtons); return (String[]) get(m_dhtmlEditorHiddenButtons);
} }
public final boolean getHideTemplatesTab() { public final boolean getHideTemplatesTab() {
@ -749,7 +613,7 @@ public final class CMSConfig extends AbstractConfig {
} }
public final String getPublishLifecycleListenerClass() { public final String getPublishLifecycleListenerClass() {
return (String) get(m_publishLifecycleListenerClass); return (String) get(m_publishLifecycleListenerClass);
} }
public final boolean getNotifyAuthorOnLifecycle() { public final boolean getNotifyAuthorOnLifecycle() {
@ -795,7 +659,6 @@ public final class CMSConfig extends AbstractConfig {
// /////////////////////////////////////////// // ///////////////////////////////////////////
// publishToFile package related configuration // publishToFile package related configuration
// /////////////////////////////////////////// // ///////////////////////////////////////////
// Moved to publishToFile.PublishToFileConfig! Temporarily retained here // Moved to publishToFile.PublishToFileConfig! Temporarily retained here
// for backwards compatibility // for backwards compatibility
public final boolean getDisableItemPfs() { public final boolean getDisableItemPfs() {
@ -808,17 +671,15 @@ public final class CMSConfig extends AbstractConfig {
return PublishToFileConfig.getConfig().getPublishListenerClass(); return PublishToFileConfig.getConfig().getPublishListenerClass();
} }
/** /**
* Fetch the file name contaning XML Mapping of the content center tabs * Fetch the file name contaning XML Mapping of the content center tabs
* to URLs * to URLs
* @return String containig file name including path component. * @return String containig file name including path component.
*/ */
public String getContentCenterMap() { public String getContentCenterMap() {
return (String) get(m_contentCenterMap); return (String) get(m_contentCenterMap);
} }
/** /**
* Internal class representing a DHTMLEditor configuration parameter. It * Internal class representing a DHTMLEditor configuration parameter. It
* creates a new DHMTLEditor Config object (internal class in DHTMLEditor). * creates a new DHMTLEditor Config object (internal class in DHTMLEditor).
@ -833,9 +694,10 @@ public final class CMSConfig extends AbstractConfig {
* (pboy, 2010-09-02) * (pboy, 2010-09-02)
*/ */
private class DHTMLEditorConfigParameter extends StringParameter { private class DHTMLEditorConfigParameter extends StringParameter {
public DHTMLEditorConfigParameter(final String name, public DHTMLEditorConfigParameter(final String name,
final int multiplicity, final int multiplicity,
final Object defaultObj) { final Object defaultObj) {
super(name, multiplicity, defaultObj); super(name, multiplicity, defaultObj);
} }
@ -850,8 +712,6 @@ public final class CMSConfig extends AbstractConfig {
return DHTMLEditor.Config.valueOf(value); return DHTMLEditor.Config.valueOf(value);
} }
} }
protected static HashMap extraXMLGenerators = new HashMap(); protected static HashMap extraXMLGenerators = new HashMap();
/** Add one ExtraXMLGenerator to the list. */ /** Add one ExtraXMLGenerator to the list. */
@ -871,6 +731,7 @@ public final class CMSConfig extends AbstractConfig {
public static Iterator getExtraXMLGeneratorsIterator() { public static Iterator getExtraXMLGeneratorsIterator() {
return extraXMLGenerators.entrySet().iterator(); return extraXMLGenerators.entrySet().iterator();
} }
public final boolean hideResetLifecycleLink() { public final boolean hideResetLifecycleLink() {
return ((Boolean) get(m_hideResetLifecycleLink)).booleanValue(); return ((Boolean) get(m_hideResetLifecycleLink)).booleanValue();
} }
@ -891,7 +752,7 @@ public final class CMSConfig extends AbstractConfig {
* Only used by the interMedia query engine. * Only used by the interMedia query engine.
**/ **/
public Integer getTitleSearchWeight() { public Integer getTitleSearchWeight() {
return (Integer) get(m_titleWeight); return (Integer) get(m_titleWeight);
} }
/** /**
@ -902,10 +763,9 @@ public final class CMSConfig extends AbstractConfig {
* @return * @return
*/ */
public boolean scoreKeywordsAndTitle() { public boolean scoreKeywordsAndTitle() {
return ((Boolean)get(m_scoreTitleAndKeywords)).booleanValue(); return ((Boolean) get(m_scoreTitleAndKeywords)).booleanValue();
} }
/** /**
* for the given content type, returns a collection of * for the given content type, returns a collection of
* steps that are deemed irrelevant for the type. * steps that are deemed irrelevant for the type.
@ -920,38 +780,38 @@ public final class CMSConfig extends AbstractConfig {
*/ */
public Collection getAssetStepsToSkip(ContentType type) { public Collection getAssetStepsToSkip(ContentType type) {
s_log.debug("getting asset steps to skip for type " + type.getClassName()); s_log.debug("getting asset steps to skip for type " + type.getClassName());
if (s_skipAssetSteps == null) { if (s_skipAssetSteps == null) {
// populate static map once based on config parameter value // populate static map once based on config parameter value
s_log.debug("loading skipsteps"); s_log.debug("loading skipsteps");
s_skipAssetSteps = new HashMap(); s_skipAssetSteps = new HashMap();
String[] skipSteps = (String[])get(m_skipAssetSteps); String[] skipSteps = (String[]) get(m_skipAssetSteps);
if (skipSteps != null) { if (skipSteps != null) {
s_log.debug(skipSteps.length + " entries in parameter"); s_log.debug(skipSteps.length + " entries in parameter");
for (int i = 0; i < skipSteps.length; i++) { for (int i = 0; i < skipSteps.length; i++) {
String[] pair = StringUtils.split(skipSteps[i], ':'); String[] pair = StringUtils.split(skipSteps[i], ':');
// 1st string is name of content type, 2nd string is name of asset step // 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]); s_log.debug("parameter read - type = " + pair[0] + " - step = " + pair[1]);
Collection typeSteps = (Collection)s_skipAssetSteps.get(pair[0]); Collection typeSteps = (Collection) s_skipAssetSteps.get(pair[0]);
if (typeSteps == null) { if (typeSteps == null) {
typeSteps = new HashSet(); typeSteps = new HashSet();
s_skipAssetSteps.put(pair[0], typeSteps); s_skipAssetSteps.put(pair[0], typeSteps);
} }
typeSteps.add(pair[1]); typeSteps.add(pair[1]);
} }
} }
} }
Collection skipSteps = (Collection)s_skipAssetSteps.get(type.getClassName()); Collection skipSteps = (Collection) s_skipAssetSteps.get(type.getClassName());
if (skipSteps == null) { if (skipSteps == null) {
s_log.debug("no steps to skip"); s_log.debug("no steps to skip");
skipSteps = new HashSet(); skipSteps = new HashSet();
} }
return skipSteps; return skipSteps;
} }
/** /**
* May be used by any content type creation form to decide whether to validate * May be used by any content type creation form to decide whether to validate
@ -959,7 +819,7 @@ public final class CMSConfig extends AbstractConfig {
* *
*/ */
public boolean mandatoryDescriptions() { public boolean mandatoryDescriptions() {
return ((Boolean)get(m_mandatoryDescriptions)).booleanValue(); return ((Boolean) get(m_mandatoryDescriptions)).booleanValue();
} }
/** /**
@ -970,7 +830,7 @@ public final class CMSConfig extends AbstractConfig {
* eg when was this item unpublished) * eg when was this item unpublished)
*/ */
public boolean deleteFinishedLifecycles() { public boolean deleteFinishedLifecycles() {
return ((Boolean)get(m_deleteLifecycleWhenComplete)).booleanValue(); return ((Boolean) get(m_deleteLifecycleWhenComplete)).booleanValue();
} }
/** /**
@ -983,7 +843,7 @@ public final class CMSConfig extends AbstractConfig {
* *
*/ */
public boolean deleteExpiryNotifications() { public boolean deleteExpiryNotifications() {
return ((Boolean)get(m_deleteExpiryNotificationsWhenSent)).booleanValue(); return ((Boolean) get(m_deleteExpiryNotificationsWhenSent)).booleanValue();
} }
/** /**
@ -996,11 +856,11 @@ public final class CMSConfig extends AbstractConfig {
* *
*/ */
public boolean deleteWorkflowNotifications() { public boolean deleteWorkflowNotifications() {
return ((Boolean)get(m_deleteWorkflowNotificationsWhenSent)).booleanValue(); return ((Boolean) get(m_deleteWorkflowNotificationsWhenSent)).booleanValue();
} }
public String getCategoryTreeOrder () { public String getCategoryTreeOrder() {
return (String)get(m_categoryTreeOrdering); return (String) get(m_categoryTreeOrdering);
} }
/** /**
@ -1013,15 +873,19 @@ public final class CMSConfig extends AbstractConfig {
* *
* @return * @return
*/ */
public boolean getHasContactsAuthoringStep() { public boolean getHasContactsAuthoringStep() {
return ((Boolean) get(m_hasContactsAuthoringStep)).booleanValue(); return ((Boolean) get(m_hasContactsAuthoringStep)).booleanValue();
}
public final boolean getHideTextAssetUploadFile() {
return ((Boolean) get(m_hideTextAssetUploadFile)).booleanValue();
} }
public final boolean getAllowContentCreateInSectionListing() { public final boolean getHideTextAssetUploadFile() {
return ((Boolean) get(m_allowContentCreateInSectionListing)).booleanValue(); return ((Boolean) get(m_hideTextAssetUploadFile)).booleanValue();
} }
public final boolean getAllowContentCreateInSectionListing() {
return ((Boolean) get(m_allowContentCreateInSectionListing)).booleanValue();
}
public String getItemSearchDefaultTab() {
return (String) get(m_itemSearchDefaultTab);
}
} }

View File

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

View File

@ -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_to_add_new_members=Search to Add New Members
cms.ui.search_errors.empty_terms=Please enter some search terms 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_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.select_one=--select one--
cms.ui.sign_out=Sign out cms.ui.sign_out=Sign out
cms.ui.submission_cancelled=Submission Cancelled 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.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.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 # Package com.arsdigita.cms.ui.authoring
# ====================================== # ======================================

View File

@ -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_to_add_new_members=Suche um neue Mitglieder zu erg\u00e4nzen
cms.ui.search_errors.empty_terms=Bitte Suchbegriffe eingeben 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_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.select_one=--ausw\u00e4hlen--
cms.ui.sign_out=Abmelden cms.ui.sign_out=Abmelden
cms.ui.submission_cancelled=Prozess abgebrochen 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.yes=Ja
cms.ui.you_do_not_have_sufficient_privileges_to_access_this_page=Unzureichende Zugriffsrechte f\u00fcr diese Seite. 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 # Package com.arsdigita.cms.ui.authoring
# ====================================== # ======================================

View File

@ -35,11 +35,13 @@ import com.arsdigita.globalization.Locale;
import com.arsdigita.kernel.Group; import com.arsdigita.kernel.Group;
import com.arsdigita.kernel.SiteNode; import com.arsdigita.kernel.SiteNode;
import com.arsdigita.kernel.permissions.PermissionService; import com.arsdigita.kernel.permissions.PermissionService;
import com.arsdigita.persistence.CompoundFilter;
import com.arsdigita.persistence.DataAssociation; import com.arsdigita.persistence.DataAssociation;
import com.arsdigita.persistence.DataAssociationCursor; import com.arsdigita.persistence.DataAssociationCursor;
import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.DataQuery; import com.arsdigita.persistence.DataQuery;
import com.arsdigita.persistence.FilterFactory;
import com.arsdigita.persistence.OID; import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.SessionManager;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
@ -53,6 +55,7 @@ import org.apache.log4j.Logger;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.StringTokenizer;
/** /**
* <p>A content section represents a collection of content that is * <p>A content section represents a collection of content that is
@ -776,6 +779,32 @@ public class ContentSection extends Application {
return types; 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 * Get all user-defined content types registered to the content section
* that can be created. * that can be created.

View File

@ -583,6 +583,7 @@ public class ContentType extends ACSObject {
ctc.addFilter(or); ctc.addFilter(or);
return ctc; return ctc;
} }
private static List s_xsl = new ArrayList(); private static List s_xsl = new ArrayList();
/** /**

View File

@ -18,7 +18,6 @@
*/ */
package com.arsdigita.cms.ui; package com.arsdigita.cms.ui;
import com.arsdigita.bebop.Form; import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Resettable; import com.arsdigita.bebop.Resettable;
@ -34,15 +33,11 @@ import com.arsdigita.search.ui.QueryGenerator;
* @author Stanislav Freidin (sfreidin@arsdigita.com) * @author Stanislav Freidin (sfreidin@arsdigita.com)
* @version $Id: ItemSearch.java 1940 2009-05-29 07:15:05Z terry $ * @version $Id: ItemSearch.java 1940 2009-05-29 07:15:05Z terry $
*/ */
public class ItemSearch extends Form public class ItemSearch extends Form implements Resettable, QueryGenerator {
implements Resettable, QueryGenerator {
private static final org.apache.log4j.Logger s_log = private static final org.apache.log4j.Logger s_log =
org.apache.log4j.Logger.getLogger(ItemSearch.class); org.apache.log4j.Logger.getLogger(ItemSearch.class);
public static final String SINGLE_TYPE_PARAM = ItemSearchSection.SINGLE_TYPE_PARAM;
public static final String SINGLE_TYPE_PARAM
= ItemSearchSection.SINGLE_TYPE_PARAM;
private ItemSearchSection m_section; private ItemSearchSection m_section;
/** /**
@ -52,7 +47,7 @@ public class ItemSearch extends Form
* {@link ContentItem#DRAFT} or {@link ContentItem#LIVE} * {@link ContentItem#DRAFT} or {@link ContentItem#LIVE}
*/ */
public ItemSearch(String context) { public ItemSearch(String context) {
super("itemSearch",new SimpleContainer()); super("itemSearch", new SimpleContainer());
setMethod("GET"); setMethod("GET");
m_section = createSearchSection(context); m_section = createSearchSection(context);
add(m_section); add(m_section);

View File

@ -61,12 +61,11 @@ import org.apache.log4j.Logger;
* @version $Id: ItemSearchBrowsePane.java 1166 2006-06-14 11:45:15Z fabrice $ * @version $Id: ItemSearchBrowsePane.java 1166 2006-06-14 11:45:15Z fabrice $
*/ */
public class ItemSearchBrowsePane extends CMSContainer public class ItemSearchBrowsePane extends CMSContainer
implements Resettable, TreeExpansionListener, ChangeListener, implements Resettable, TreeExpansionListener, ChangeListener,
FormProcessListener, FormSubmissionListener { FormProcessListener, FormSubmissionListener {
private static final Logger s_log = private static final Logger s_log =
Logger.getLogger( ItemSearchBrowsePane.class ); Logger.getLogger(ItemSearchBrowsePane.class);
private FolderSelectionModel m_folderSel; private FolderSelectionModel m_folderSel;
private Tree m_tree; private Tree m_tree;
private ItemSearchFolderBrowser m_browser; private ItemSearchFolderBrowser m_browser;
@ -74,7 +73,7 @@ public class ItemSearchBrowsePane extends CMSContainer
public ItemSearchBrowsePane() { public ItemSearchBrowsePane() {
setClassAttr("sidebarNavPanel"); 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")); Label l = new Label(GlobalizationUtil.globalize("cms.ui.folder_browser"));
l.setClassAttr("heading"); 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 // subsites through the ItemSearchBrowsePane. A new parameter has been added to allow the
// administrator to pick between the old and new versions. // administrator to pick between the old and new versions.
boolean linksOnlyInSameSubsite = ContentSection.getConfig().getLinksOnlyInSameSubsite(); 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() { m_tree = new Tree(new FolderTreeModelBuilder() {
protected Folder getRoot( PageState ps ) {
Folder root = getRootFolder( ps );
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; return root;
} }
} ); });
m_folderSel = createFolderSelectionModel(); m_folderSel = createFolderSelectionModel();
m_folderSel.addChangeListener(this); m_folderSel.addChangeListener(this);
if(!linksOnlyInSameSubsite) { if (!linksOnlyInSameSubsite) {
// The client should be able to pick between the subsites // The client should be able to pick between the subsites
Form sectionForm = getSectionForm(); Form sectionForm = getSectionForm();
add( sectionForm ); add(sectionForm);
} }
m_tree.setSelectionModel( m_folderSel ); m_tree.setSelectionModel(m_folderSel);
m_tree.setClassAttr("navbar"); m_tree.setClassAttr("navbar");
m_tree.addTreeExpansionListener(this); m_tree.addTreeExpansionListener(this);
@ -112,64 +115,67 @@ public class ItemSearchBrowsePane extends CMSContainer
CMSContainer container = new CMSContainer(); CMSContainer container = new CMSContainer();
container.setClassAttr("main"); container.setClassAttr("main");
m_browser = new ItemSearchFolderBrowser (m_folderSel); m_browser = new ItemSearchFolderBrowser(m_folderSel);
container.add( m_browser ); container.add(m_browser);
container.add(m_browser.getPaginator()); container.add(m_browser.getPaginator());
add( container ); add(container);
} }
private Form getSectionForm() { private Form getSectionForm() {
Form sectionForm = new Form( "isfbSectionForm", Form sectionForm = new Form("isfbSectionForm",
new BoxPanel( BoxPanel.HORIZONTAL ) ); new BoxPanel(BoxPanel.HORIZONTAL));
sectionForm.setClassAttr("navbar"); sectionForm.setClassAttr("navbar");
m_section = new SingleSelect( new OIDParameter( "isfbSection" ) ); m_section = new SingleSelect(new OIDParameter("isfbSection"));
ContentSectionCollection sections = ContentSection.getAllSections(); ContentSectionCollection sections = ContentSection.getAllSections();
while( sections.next() ) { while (sections.next()) {
ContentSection section = sections.getContentSection(); ContentSection section = sections.getContentSection();
m_section.addOption( new Option( section.getOID().toString(), m_section.addOption(new Option(section.getOID().toString(),
section.getDisplayName() ) ); section.getDisplayName()));
} }
sectionForm.addInitListener( new FormInitListener() { sectionForm.addInitListener(new FormInitListener() {
public void init( FormSectionEvent ev ) {
public void init(FormSectionEvent ev) {
PageState ps = ev.getPageState(); PageState ps = ev.getPageState();
if( null == m_section.getValue( ps ) ) { if (null == m_section.getValue(ps)) {
ContentSection section = CMS.getContext().getContentSection(); ContentSection section = CMS.getContext().getContentSection();
m_section.setValue( ps, section.getOID() ); m_section.setValue(ps, section.getOID());
} }
} }
} ); });
sectionForm.add( m_section ); sectionForm.add(m_section);
sectionForm.add( new Submit( "Change Section" ) ); sectionForm.add(new Submit("Change Section"));
return sectionForm; return sectionForm;
} }
private Folder getRootFolder( PageState ps ) { private Folder getRootFolder(PageState ps) {
s_log.debug("Getting the root folder."); s_log.debug("Getting the root folder.");
if(m_section!=null) { if (m_section != null) {
// We have more than one subsite to choose between // We have more than one subsite to choose between
OID sectionOID = (OID) m_section.getValue( ps ); OID sectionOID = (OID) m_section.getValue(ps);
if( s_log.isDebugEnabled() ) { if (s_log.isDebugEnabled()) {
if( null != sectionOID ) if (null != sectionOID) {
s_log.debug( "Using section " + sectionOID.toString() ); s_log.debug("Using section " + sectionOID.toString());
else } else {
s_log.debug( "Using default section" ); s_log.debug("Using default section");
}
} }
if( null == sectionOID ) return null; if (null == sectionOID) {
return null;
}
ContentSection section = (ContentSection) ContentSection section = (ContentSection) DomainObjectFactory.newInstance(sectionOID);
DomainObjectFactory.newInstance( sectionOID );
return section.getRootFolder(); return section.getRootFolder();
} else { } else {
return null; return null;
} }
} }
public void register(Page p) { public void register(Page p) {
@ -177,13 +183,13 @@ public class ItemSearchBrowsePane extends CMSContainer
p.addComponentStateParam(this, m_folderSel.getStateParameter()); p.addComponentStateParam(this, m_folderSel.getStateParameter());
// Only add the SingleSelect item if it exists // Only add the SingleSelect item if it exists
if(m_section!=null) { if (m_section != null) {
p.addComponentStateParam(this, m_section.getParameterModel()); p.addComponentStateParam(this, m_section.getParameterModel());
} }
} }
public void reset(PageState s) { public void reset(PageState s) {
//m_browser.reset(s); //m_browser.reset(s);
} }
public ItemSearchFolderBrowser getFolderBrowser() { public ItemSearchFolderBrowser getFolderBrowser() {
@ -207,14 +213,13 @@ public class ItemSearchBrowsePane extends CMSContainer
m_folderSel.setSelectedKey(s, key); m_folderSel.setSelectedKey(s, key);
Folder current = (Folder) m_folderSel.getSelectedObject(s); Folder current = (Folder) m_folderSel.getSelectedObject(s);
Folder parent = (Folder) current.getParent(); Folder parent = (Folder) current.getParent();
if ( parent != null ) { if (parent != null) {
BigDecimal id = parent.getID(); BigDecimal id = parent.getID();
m_tree.expand(id.toString(), s); m_tree.expand(id.toString(), s);
} }
} }
// Implement TreeExpansionListener // Implement TreeExpansionListener
public void treeCollapsed(TreeExpansionEvent e) { public void treeCollapsed(TreeExpansionEvent e) {
PageState s = e.getPageState(); PageState s = e.getPageState();
m_folderSel.setSelectedKey(s, e.getNodeKey()); m_folderSel.setSelectedKey(s, e.getNodeKey());
@ -229,7 +234,7 @@ public class ItemSearchBrowsePane extends CMSContainer
Folder current = (Folder) m_folderSel.getSelectedObject(s); Folder current = (Folder) m_folderSel.getSelectedObject(s);
Folder parent = (Folder) current.getParent(); Folder parent = (Folder) current.getParent();
m_browser.getPaginator().reset(s); m_browser.getPaginator().reset(s);
if ( parent != null ) { if (parent != null) {
BigDecimal id = parent.getID(); BigDecimal id = parent.getID();
m_tree.expand(id.toString(), s); m_tree.expand(id.toString(), s);
} }
@ -238,37 +243,39 @@ public class ItemSearchBrowsePane extends CMSContainer
} }
public void process(FormSectionEvent e) { public void process(FormSectionEvent e) {
/* /*
PageState s = e.getPageState(); PageState s = e.getPageState();
if ( e.getSource() == m_browser.getManipulator().getItemView() ) { if ( e.getSource() == m_browser.getManipulator().getItemView() ) {
// Hide everything except for the flat item list // Hide everything except for the flat item list
m_tree.setVisible(s, false); m_tree.setVisible(s, false);
} else if ( e.getSource() == m_browser.getManipulator().getTargetSelector() ) { } else if ( e.getSource() == m_browser.getManipulator().getTargetSelector() ) {
m_tree.setVisible(s, true); m_tree.setVisible(s, true);
} }
*/ */
} }
public void submitted(FormSectionEvent e) { public void submitted(FormSectionEvent e) {
/* /*
PageState s = e.getPageState(); PageState s = e.getPageState();
if ( e.getSource() == m_browser.getManipulator().getTargetSelector() ) { if ( e.getSource() == m_browser.getManipulator().getTargetSelector() ) {
if ( ! m_browser.getManipulator().getTargetSelector().isVisible(s) ) { if ( ! m_browser.getManipulator().getTargetSelector().isVisible(s) ) {
m_tree.setVisible(s, true); m_tree.setVisible(s, true);
}
} }
*/ }
*/
} }
private FolderSelectionModel createFolderSelectionModel() { private FolderSelectionModel createFolderSelectionModel() {
return new FolderSelectionModel("folder") { return new FolderSelectionModel("folder") {
protected BigDecimal getRootFolderID( PageState ps ) {
Folder root = getRootFolder( ps );
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(); return root.getID();
} }
}; };
} }
} }

View File

@ -157,6 +157,7 @@ public class ItemSearchFolderBrowser extends Table {
return new Integer((int) itemColl.size()); return new Integer((int) itemColl.size());
} }
}; };
private RequestLocal m_itemColl = new RequestLocal() { private RequestLocal m_itemColl = new RequestLocal() {
@Override @Override
@ -328,9 +329,9 @@ public class ItemSearchFolderBrowser extends Table {
+ widget + ".value=\"" + fill + "\";\n"); + widget + ".value=\"" + fill + "\";\n");
// set protocol to 'other' in FCKEditor, else relative url prepended by http:// // set protocol to 'other' in FCKEditor, else relative url prepended by http://
if (Bebop.getConfig().getDHTMLEditor().equals(BebopConstants.BEBOP_FCKEDITOR)) { 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(" window.opener.document.getElementById('cmbLinkProtocol').value=\"\";\n");
buffer.append(" }\n"); buffer.append(" }\n");
} }
buffer.append(" self.close(); \n" buffer.append(" self.close(); \n"

View File

@ -23,10 +23,12 @@ import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.bebop.TabbedPane; import com.arsdigita.bebop.TabbedPane;
import com.arsdigita.bebop.parameters.BigDecimalParameter; import com.arsdigita.bebop.parameters.BigDecimalParameter;
import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.CMSConfig;
import com.arsdigita.cms.CMSExcursion; import com.arsdigita.cms.CMSExcursion;
import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.dispatcher.CMSPage; import com.arsdigita.cms.dispatcher.CMSPage;
import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.dispatcher.RequestContext; import com.arsdigita.dispatcher.RequestContext;
import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.templating.PresentationManager; import com.arsdigita.templating.PresentationManager;
@ -47,27 +49,25 @@ import javax.servlet.http.HttpServletResponse;
* @author Scott Seago (scott@arsdigita.com) * @author Scott Seago (scott@arsdigita.com)
* @version $Revision: #12 $ $DateTime: 2004/08/17 23:15:09 $ * @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 final static String XSL_CLASS = "CMS Admin";
private TabbedPane m_tabbedPane; private TabbedPane m_tabbedPane;
private ItemSearchBrowsePane m_browse; private ItemSearchBrowsePane m_browse;
private ItemSearchPopup m_search; private ItemSearchPopup m_search;
private BigDecimalParameter m_sectionId; private BigDecimalParameter m_sectionId;
private static final CMSConfig s_conf = CMSConfig.getInstance();
public static final String CONTENT_SECTION = "section_id"; public static final String CONTENT_SECTION = "section_id";
/** /**
* Construct a new ItemSearchPage * Construct a new ItemSearchPage
*/ */
public ItemSearchPage() { public ItemSearchPage() {
super("Item Search", new SimpleContainer()); super(GlobalizationUtil.globalize("cms.ui.item_search.page_title").localize().toString(), new SimpleContainer());
setClassAttr("cms-admin"); setClassAttr("cms-admin");
addGlobalStateParam addGlobalStateParam(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM));
(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM));
addGlobalStateParam(new StringParameter(ItemSearchPopup.WIDGET_PARAM)); addGlobalStateParam(new StringParameter(ItemSearchPopup.WIDGET_PARAM));
m_sectionId = new BigDecimalParameter(CONTENT_SECTION); m_sectionId = new BigDecimalParameter(CONTENT_SECTION);
@ -81,7 +81,6 @@ public class ItemSearchPage extends CMSPage {
add(m_tabbedPane); add(m_tabbedPane);
} }
/** /**
* Creates, and then caches, the Browse pane. Overriding this * Creates, and then caches, the Browse pane. Overriding this
* method to return null will prevent this tab from appearing. * method to return null will prevent this tab from appearing.
@ -107,7 +106,6 @@ public class ItemSearchPage extends CMSPage {
return m_search; return m_search;
} }
/** /**
* Created the TabbedPane to use for this page. Sets the class * Created the TabbedPane to use for this page. Sets the class
* attribute for this tabbed pane. The default implementation uses a * attribute for this tabbed pane. The default implementation uses a
@ -122,14 +120,22 @@ public class ItemSearchPage extends CMSPage {
protected TabbedPane createTabbedPane() { protected TabbedPane createTabbedPane() {
TabbedPane pane = new TabbedPane(); TabbedPane pane = new TabbedPane();
pane.setClassAttr(XSL_CLASS); pane.setClassAttr(XSL_CLASS);
addToPane(pane, "Browse", getBrowsePane());
addToPane(pane, "Search", getSearchPane()); addToPane(pane, "browse", getBrowsePane());
pane.setDefaultPane(m_browse); 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.addActionListener(this);
// pane.setTabVisible(null, pane, true);
return pane; return pane;
} }
/** /**
* Adds the specified component, with the specified tab name, to the * Adds the specified component, with the specified tab name, to the
* tabbed pane only if it is not null. * 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) { protected void addToPane(TabbedPane pane, String tabName, Component comp) {
if (comp != null) { 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 * When a new tab is selected, reset the state of the
* formerly-selected pane. * formerly-selected pane.
@ -154,42 +159,40 @@ public class ItemSearchPage extends CMSPage {
//public void actionPerformed(ActionEvent event) { //public void actionPerformed(ActionEvent event) {
//PageState state = event.getPageState(); //PageState state = event.getPageState();
//Component pane = m_tabbedPane.getCurrentPane(state); //Component pane = m_tabbedPane.getCurrentPane(state);
//if ( pane == m_browse ) { //if ( pane == m_browse ) {
// MP: reset tasks pane // MP: reset tasks pane
//} else if ( pane == m_search ) { //} else if ( pane == m_search ) {
//m_search.reset(state); //m_search.reset(state);
//} //}
//} //}
/** /**
* This strange voodoo from Dan. No idea what it does. * This strange voodoo from Dan. No idea what it does.
*/ */
@Override
public void dispatch(final HttpServletRequest request, public void dispatch(final HttpServletRequest request,
final HttpServletResponse response, final HttpServletResponse response,
RequestContext actx) RequestContext actx)
throws IOException, ServletException { throws IOException, ServletException {
new CMSExcursion() { new CMSExcursion() {
public void excurse() public void excurse()
throws IOException, ServletException { throws IOException, ServletException {
ContentSection section = null; ContentSection section = null;
Application app = Web.getContext().getApplication(); Application app = Web.getContext().getApplication();
if (app instanceof ContentSection) { if (app instanceof ContentSection) {
section = (ContentSection)app; section = (ContentSection) app;
} else { } else {
try { try {
section = new ContentSection section = new ContentSection((BigDecimal) m_sectionId.transformValue(request));
((BigDecimal) m_sectionId.transformValue(request));
} catch (DataObjectNotFoundException ex) { } catch (DataObjectNotFoundException ex) {
throw new UncheckedWrapperException(ex); throw new UncheckedWrapperException(ex);
} }
} }
setContentSection(section); setContentSection(section);
final Document doc = buildDocument(request, response); final Document doc = buildDocument(request, response);
final PresentationManager pm = final PresentationManager pm =
Templating.getPresentationManager(); Templating.getPresentationManager();
pm.servePage(doc, request, response); pm.servePage(doc, request, response);
} }

View File

@ -18,7 +18,6 @@
*/ */
package com.arsdigita.cms.ui; package com.arsdigita.cms.ui;
import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Page; import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
@ -45,10 +44,8 @@ import javax.servlet.http.HttpServletRequest;
*/ */
public class ItemSearchPopup extends ItemSearch { public class ItemSearchPopup extends ItemSearch {
private static final org.apache.log4j.Logger s_log = private static final org.apache.log4j.Logger s_log =
org.apache.log4j.Logger.getLogger(ItemSearchPopup.class); org.apache.log4j.Logger.getLogger(ItemSearchPopup.class);
public static final String WIDGET_PARAM = "widget"; public static final String WIDGET_PARAM = "widget";
public static final String URL_PARAM = "useURL"; public static final String URL_PARAM = "useURL";
@ -63,12 +60,14 @@ public class ItemSearchPopup extends ItemSearch {
} }
// Hide results by default // Hide results by default
@Override
public void register(Page p) { public void register(Page p) {
super.register(p); super.register(p);
p.addGlobalStateParam(new StringParameter(WIDGET_PARAM)); p.addGlobalStateParam(new StringParameter(WIDGET_PARAM));
p.addGlobalStateParam(new StringParameter(URL_PARAM)); p.addGlobalStateParam(new StringParameter(URL_PARAM));
} }
@Override
protected ItemSearchSection createSearchSection(String context) { protected ItemSearchSection createSearchSection(String context) {
return new ItemSearchSectionPopup(context); return new ItemSearchSectionPopup(context);
} }
@ -79,6 +78,7 @@ public class ItemSearchPopup extends ItemSearch {
super(context); super(context);
} }
@Override
protected Component createResultsPane(QueryGenerator generator) { protected Component createResultsPane(QueryGenerator generator) {
return new PopupResultsPane(generator); return new PopupResultsPane(generator);
} }
@ -93,55 +93,56 @@ public class ItemSearchPopup extends ItemSearch {
//map.setParameter("oid", oid.toString()); //map.setParameter("oid", oid.toString());
//return URL.there(request, "/redirect/", map).toString(); //return URL.there(request, "/redirect/", map).toString();
// Always link directly to the live version. // Always link directly to the live version.
return "/redirect/?oid="+oid.toString(); return "/redirect/?oid=" + oid.toString();
} }
private static class PopupResultsPane extends ResultsPane { private static class PopupResultsPane extends ResultsPane {
public PopupResultsPane(QueryGenerator generator) { public PopupResultsPane(QueryGenerator generator) {
super(generator); super(generator);
setRelativeURLs(true); setRelativeURLs(true);
} }
protected Element generateDocumentXML(PageState state, @Override
Document doc) { protected Element generateDocumentXML(PageState state, Document doc) {
Element element = super.generateDocumentXML(state, doc); Element element = super.generateDocumentXML(state, doc);
element.addAttribute("class", "jsButton"); element.addAttribute("class", "jsButton");
String widget = (String) state.getValue( String widget = (String) state.getValue(
new StringParameter(WIDGET_PARAM)); new StringParameter(WIDGET_PARAM));
boolean useURL = "true".equals( boolean useURL = "true".equals(
state.getValue(new StringParameter(URL_PARAM))); state.getValue(new StringParameter(URL_PARAM)));
String fillString = useURL ? String fillString = useURL
getItemURL(state.getRequest(), doc.getOID()) : ? getItemURL(state.getRequest(), doc.getOID())
doc.getOID().get("id").toString() + : doc.getOID().get("id").toString()
" (" + doc.getTitle() + ")"; + " (" + doc.getTitle() + ")";
Element jsLabel = Search.newElement("jsAction"); Element jsLabel = Search.newElement("jsAction");
jsLabel.addAttribute("name", "fillItem" + jsLabel.addAttribute("name", "fillItem"
doc.getOID().get("id") + "()"); + doc.getOID().get("id") + "()");
jsLabel.setText(generateJSLabel((BigDecimal)doc.getOID().get("id"), jsLabel.setText(generateJSLabel((BigDecimal) doc.getOID().get("id"),
widget, fillString)); widget, fillString));
element.addContent(jsLabel); element.addContent(jsLabel);
return element; return element;
} }
private String generateJSLabel(BigDecimal id, String widget, String fill) { private String generateJSLabel(BigDecimal id, String widget, String fill) {
return " <script language=javascript> " + return " <script language=javascript> "
" <!-- \n" + + " <!-- \n"
" function fillItem" + + " function fillItem"
id + + id
"() { \n" + + "() { \n"
" window.opener.document." + + " window.opener.document."
widget + ".value=\"" + fill + "\";\n" + + widget + ".value=\"" + fill + "\";\n"
" self.close(); \n" + + " self.close(); \n"
" return false; \n" + + " return false; \n"
" } \n" + + " } \n"
" --> \n" + + " --> \n"
" </script> "; + " </script> ";
} }
} }
} }

View File

@ -79,8 +79,8 @@ public class ItemSearchSection extends FormSection
m_query = createQueryGenerator(context); m_query = createQueryGenerator(context);
m_results = createResultsPane(m_query); m_results = createResultsPane(m_query);
addResultsPane(this);
addQueryGenerator(this); addQueryGenerator(this);
addResultsPane(this);
addFormListener(); addFormListener();
setClassAttr("itemSearch"); setClassAttr("itemSearch");

View File

@ -18,7 +18,6 @@
*/ */
package com.arsdigita.cms.ui; package com.arsdigita.cms.ui;
import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Container; import com.arsdigita.bebop.Container;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
@ -46,12 +45,9 @@ import com.arsdigita.search.ui.ResultsPane;
public class ItemSearchSectionInline extends ItemSearchSection { public class ItemSearchSectionInline extends ItemSearchSection {
private static final org.apache.log4j.Logger s_log = private static final org.apache.log4j.Logger s_log =
org.apache.log4j.Logger.getLogger(ItemSearchSectionInline.class); org.apache.log4j.Logger.getLogger(ItemSearchSectionInline.class);
private Submit m_selectItem; private Submit m_selectItem;
private String m_name; private String m_name;
private OIDParameter m_item; private OIDParameter m_item;
/** /**
@ -66,27 +62,32 @@ public class ItemSearchSectionInline extends ItemSearchSection {
m_item = new OIDParameter(name + "_itemOID"); m_item = new OIDParameter(name + "_itemOID");
} }
@Override
public void register(Page p) { public void register(Page p) {
super.register(p); super.register(p);
p.addGlobalStateParam(m_item); p.addGlobalStateParam(m_item);
} }
@Override
protected Component createResultsPane(QueryGenerator generator) { protected Component createResultsPane(QueryGenerator generator) {
return new InlineResultsPane(generator); return new InlineResultsPane(generator);
} }
@Override
protected void addResultsPane(Container container) { protected void addResultsPane(Container container) {
super.addResultsPane(container); super.addResultsPane(container);
m_selectItem = new ItemSelectSubmit( m_selectItem = new ItemSelectSubmit(
m_name + "_itemSelect", "Select Item"); m_name + "_itemSelect", "Select Item");
container.add(m_selectItem); container.add(m_selectItem);
} }
@Override
protected void addFormListener() { protected void addFormListener() {
// do nothing (ItemSearchWidget's submission listener does this. // do nothing (ItemSearchWidget's submission listener does this.
} }
@Override
public void processQuery(PageState state) { public void processQuery(PageState state) {
super.processQuery(state); super.processQuery(state);
m_selectItem.setVisible(state, hasQuery(state)); m_selectItem.setVisible(state, hasQuery(state));
@ -97,37 +98,41 @@ public class ItemSearchSectionInline extends ItemSearchSection {
} }
public ContentItem getSelectedItem(PageState state) { public ContentItem getSelectedItem(PageState state) {
OID oid = (OID)state.getValue(m_item); OID oid = (OID) state.getValue(m_item);
if (oid == null) { if (oid == null) {
return null; return null;
} }
return (ContentItem)DomainObjectFactory.newInstance(oid); return (ContentItem) DomainObjectFactory.newInstance(oid);
} }
private class ItemSelectSubmit extends Submit { private class ItemSelectSubmit extends Submit {
public ItemSelectSubmit(String name, String label) { public ItemSelectSubmit(String name, String label) {
super(name, label); super(name, label);
} }
public ItemSelectSubmit(String name, GlobalizedMessage label) { public ItemSelectSubmit(String name, GlobalizedMessage label) {
super(name, label); super(name, label);
} }
@Override
public boolean isVisible(PageState ps) { public boolean isVisible(PageState ps) {
return hasQuery(ps) && super.isVisible(ps); return hasQuery(ps) && super.isVisible(ps);
} }
} }
private class InlineResultsPane extends ResultsPane { private class InlineResultsPane extends ResultsPane {
public InlineResultsPane(QueryGenerator query) { public InlineResultsPane(QueryGenerator query) {
super(query); super(query);
setRelativeURLs(true); setRelativeURLs(true);
} }
@Override
protected Element generateDocumentXML(PageState state, protected Element generateDocumentXML(PageState state,
Document doc) { Document doc) {
Element element = super.generateDocumentXML(state, doc); Element element = super.generateDocumentXML(state, doc);
element.addAttribute("field", m_item.getName()); element.addAttribute("field", m_item.getName());

View File

@ -165,8 +165,7 @@ public class ItemSearchWidget extends FormSection
/** /**
* Construct a new ItemSearchWidget. The model must be an ItemSearchParameter * Construct a new ItemSearchWidget. The model must be an ItemSearchParameter
*/ */
public ItemSearchWidget(ParameterModel model, public ItemSearchWidget(ParameterModel model, ContentType contentType) {
ContentType contentType) {
super(new BoxPanel(BoxPanel.VERTICAL)); super(new BoxPanel(BoxPanel.VERTICAL));
if (!(model instanceof ItemSearchParameter)) { if (!(model instanceof ItemSearchParameter)) {
@ -267,8 +266,7 @@ public class ItemSearchWidget extends FormSection
: ContentType.findByAssociatedObjectType(objectType))); : ContentType.findByAssociatedObjectType(objectType)));
} }
public ItemSearchWidget(String name, public ItemSearchWidget(String name, ContentType contentType) {
ContentType contentType) {
this(new ItemSearchParameter(name, contentType), contentType); this(new ItemSearchParameter(name, contentType), contentType);
} }

View File

@ -45,7 +45,6 @@ import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* A {@link com.arsdigita.bebop.tree.TreeModelBuilder} that produces trees * A {@link com.arsdigita.bebop.tree.TreeModelBuilder} that produces trees
* containing the folder structure underneath a root folder. The root * 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 $ * @version $Id: FolderTreeModelBuilder.java 1940 2009-05-29 07:15:05Z terry $
*/ */
public class FolderTreeModelBuilder extends LockableImpl public class FolderTreeModelBuilder extends LockableImpl
implements TreeModelBuilder { implements TreeModelBuilder {
private static final Logger s_log = Logger.getLogger(FolderTreeModelBuilder.class); private static final Logger s_log = Logger.getLogger(FolderTreeModelBuilder.class);
private PrivilegeDescriptor TREE_DESCRIPTOR = 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 * Make a tree model that lists the hierarchy of folders underneath the
* folder returnedby {@link #getRoot getRoot}. * 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) { public com.arsdigita.bebop.tree.TreeModel makeModel(final Tree t, PageState s) {
return new DataQueryTreeModel(getRoot(s).getID(), return new DataQueryTreeModel(getRoot(s).getID(),
"com.arsdigita.cms.getRootFolder", "com.arsdigita.cms.getRootFolder",
"com.arsdigita.cms.getSubFolders") { "com.arsdigita.cms.getSubFolders") {
public Iterator getChildren(TreeNode node, PageState data) { @Override
String nodeKey = node.getKey().toString(); public Iterator getChildren(TreeNode node, PageState data) {
if (t.isCollapsed(nodeKey, data)) { String nodeKey = node.getKey().toString();
return Collections.EMPTY_LIST.iterator();
} // Always expand root node
Party party = Kernel.getContext().getParty(); if (nodeKey.equals(getRoot(data).getKey().toString())/* && t.isCollapsed(nodeKey, data)*/) {
OID partyOID = null; t.expand(nodeKey, data);
if (party == null) { }
partyOID = new OID(User.BASE_DATA_OBJECT_TYPE,
PermissionManager.VIRTUAL_PUBLIC_ID); if (t.isCollapsed(nodeKey, data)) {
} else { return Collections.EMPTY_LIST.iterator();
partyOID = party.getOID(); }
} Party party = Kernel.getContext().getParty();
UniversalPermissionDescriptor universalPermission = OID partyOID = null;
new UniversalPermissionDescriptor if (party == null) {
(SecurityManager.CMS_PREVIEW_ITEM_DESCRIPTOR, partyOID); partyOID = new OID(User.BASE_DATA_OBJECT_TYPE,
if (PermissionService.checkPermission PermissionManager.VIRTUAL_PUBLIC_ID);
(universalPermission)) { } else {
// the person is an admin so we just pass in the partyOID = party.getOID();
// standard, non filtered query }
return getDataQueryTreeIterator( UniversalPermissionDescriptor universalPermission =
(DataQueryTreeNode) node, new UniversalPermissionDescriptor(SecurityManager.CMS_PREVIEW_ITEM_DESCRIPTOR, partyOID);
"com.arsdigita.cms.getSubFolders"); if (PermissionService.checkPermission(universalPermission)) {
} else { // the person is an admin so we just pass in the
// now we need to set the parameters // standard, non filtered query
return new NewFolderBrowserIterator( return getDataQueryTreeIterator(
(DataQueryTreeNode) node,
"com.arsdigita.cms.getSubFolders");
} else {
// now we need to set the parameters
return new NewFolderBrowserIterator(
(DataQueryTreeNode) node, (DataQueryTreeNode) node,
partyOID); partyOID);
}
} }
}; }
};
} }
/** /**
@ -119,12 +122,11 @@ public class FolderTreeModelBuilder extends LockableImpl
* @post return != null * @post return != null
*/ */
protected Folder getRoot(PageState s) protected Folder getRoot(PageState s)
throws IllegalStateException { throws IllegalStateException {
ContentSection sec = CMS.getContext().getContentSection(); ContentSection sec = CMS.getContext().getContentSection();
return sec.getRootFolder(); return sec.getRootFolder();
} }
private class NewFolderBrowserIterator implements Iterator { private class NewFolderBrowserIterator implements Iterator {
private DataQuery m_nodes; private DataQuery m_nodes;
@ -134,56 +136,55 @@ public class FolderTreeModelBuilder extends LockableImpl
BigDecimal userID = (BigDecimal) partyOID.get("id"); BigDecimal userID = (BigDecimal) partyOID.get("id");
String sql = "" String sql = ""
+ "\n select f.folder_id as id," + "\n select f.folder_id as id,"
+ "\n f.label as name," + "\n f.label as name,"
+ "\n count(sub.item_id) as nchild" + "\n count(sub.item_id) as nchild"
+ "\n from cms_folders f," + "\n from cms_folders f,"
+ "\n cms_items i" + "\n cms_items i"
+ "\n left join" + "\n left join"
+ "\n (select i2.item_id, f2.label as name, i2.parent_id" + "\n (select i2.item_id, f2.label as name, i2.parent_id"
+ "\n from cms_folders f2," + "\n from cms_folders f2,"
+ "\n cms_items i2" + "\n cms_items i2"
+ "\n where f2.folder_id = i2.item_id) sub" + "\n where f2.folder_id = i2.item_id) sub"
+ "\n on (sub.parent_id = i.item_id" + "\n on (sub.parent_id = i.item_id"
+ "\n and" + "\n and"
+ "\n exists (select 1" + "\n exists (select 1"
+ "\n from dnm_object_1_granted_context dogc," + "\n from dnm_object_1_granted_context dogc,"
+ "\n dnm_granted_context dgc," + "\n dnm_granted_context dgc,"
+ "\n dnm_permissions dp," + "\n dnm_permissions dp,"
+ "\n dnm_group_membership dgm" + "\n dnm_group_membership dgm"
+ "\n where dogc.pd_object_id = sub.item_id" + "\n where dogc.pd_object_id = sub.item_id"
+ "\n and dogc.pd_context_id = dgc.pd_object_id" + "\n and dogc.pd_context_id = dgc.pd_object_id"
+ "\n and dgc.pd_context_id = dp.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 dp.pd_grantee_id = dgm.pd_group_id"
+ "\n and dgm.pd_member_id in (-200," + userID + ",-202)" + "\n and dgm.pd_member_id in (-200," + userID + ",-202)"
+ "\n and dp." + TREE_DESCRIPTOR.getColumnName() + " = 1" + "\n and dp." + TREE_DESCRIPTOR.getColumnName() + " = 1"
+ "\n ) )" + "\n ) )"
+ "\n where i.parent_id = " + node.getID() + "\n where i.parent_id = " + node.getID()
+ "\n and f.folder_id = i.item_id" + "\n and f.folder_id = i.item_id"
+ "\n and exists (" + "\n and exists ("
+ "\n select 1 as permission_p" + "\n select 1 as permission_p"
+ "\n from dnm_object_1_granted_context dogc," + "\n from dnm_object_1_granted_context dogc,"
+ "\n dnm_granted_context dgc," + "\n dnm_granted_context dgc,"
+ "\n dnm_permissions dp," + "\n dnm_permissions dp,"
+ "\n dnm_group_membership dgm" + "\n dnm_group_membership dgm"
+ "\n where dogc.pd_context_id = dgc.pd_object_id" + "\n where dogc.pd_context_id = dgc.pd_object_id"
+ "\n and dgc.pd_context_id = dp.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 dgm.pd_member_id in (-200," + userID + ",-202)"
+ "\n and dp.pd_grantee_id = dgm.pd_group_id" + "\n and dp.pd_grantee_id = dgm.pd_group_id"
+ "\n and dogc.pd_object_id = f.folder_id" + "\n and dogc.pd_object_id = f.folder_id"
+ "\n and dp." + TREE_DESCRIPTOR.getColumnName() + " = 1 )" + "\n and dp." + TREE_DESCRIPTOR.getColumnName() + " = 1 )"
+ "\n group by f.label, f.folder_id" + "\n group by f.label, f.folder_id"
+ "\n order by lower(f.label)" ; + "\n order by lower(f.label)";
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Custom SQL: \n" + sql); s_log.debug("Custom SQL: \n" + sql);
} }
m_nodes = new GenericDataQuery( m_nodes = new GenericDataQuery(
SessionManager.getSession(), SessionManager.getSession(),
sql, sql,
new String[] {"id", "name", "nchild"} new String[]{"id", "name", "nchild"});
);
} }
public Object next() { public Object next() {
@ -192,25 +193,24 @@ public class FolderTreeModelBuilder extends LockableImpl
// this appears to be the only portable way to dig numbers out // this appears to be the only portable way to dig numbers out
// of the result set // of the result set
id = new BigDecimal(m_nodes.get("id").toString()); id = new BigDecimal(m_nodes.get("id").toString());
} catch (NumberFormatException nfe) {} } catch (NumberFormatException nfe) {
}
String name = m_nodes.get("name").toString(); String name = m_nodes.get("name").toString();
BigDecimal count = new BigDecimal(0); BigDecimal count = new BigDecimal(0);
try { try {
count = new BigDecimal(m_nodes.get("nchild").toString()); count = new BigDecimal(m_nodes.get("nchild").toString());
} catch (NumberFormatException nfe) {} } catch (NumberFormatException nfe) {
}
return new DataQueryTreeNode(id, name, count.intValue() > 0); return new DataQueryTreeNode(id, name, count.intValue() > 0);
} }
public void remove() { public void remove() {
throw new UnsupportedOperationException throw new UnsupportedOperationException("cannot remove nodes via iterator");
("cannot remove nodes via iterator");
} }
public boolean hasNext() { public boolean hasNext() {
return m_nodes.next(); return m_nodes.next();
} }
} }
} }

View File

@ -18,7 +18,6 @@
*/ */
package com.arsdigita.cms.ui.search; package com.arsdigita.cms.ui.search;
import com.arsdigita.search.ui.FilterWidget; import com.arsdigita.search.ui.FilterWidget;
import com.arsdigita.search.Search; import com.arsdigita.search.Search;
import com.arsdigita.search.FilterSpecification; import com.arsdigita.search.FilterSpecification;
@ -28,38 +27,105 @@ import com.arsdigita.cms.ContentSection;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.parameters.ArrayParameter; import com.arsdigita.bebop.parameters.ArrayParameter;
import com.arsdigita.bebop.parameters.BigDecimalParameter;
import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.search.ContentTypeFilterType; import com.arsdigita.cms.search.ContentTypeFilterType;
import com.arsdigita.cms.search.ContentTypeFilterSpecification; 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 { 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) { public ContentTypeFilterWidget(ContentTypeCollection types) {
super(new ContentTypeFilterType(), super(new ContentTypeFilterType(), new ArrayParameter(new StringParameter(ContentTypeFilterType.KEY)));
new ArrayParameter(new StringParameter(ContentTypeFilterType.KEY))); m_types = types;
m_types = new ContentType[(int)types.size()];
int i = 0;
while (types.next()) {
m_types[i++] = types.getContentType();
}
} }
public ContentTypeFilterWidget(ContentSection section) { public ContentTypeFilterWidget(ContentSection section) {
this(section.getContentTypes()); 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() { public ContentTypeFilterWidget() {
this(ContentType.getRegisteredContentTypes()); 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) { 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) { public FilterSpecification getFilter(PageState state) {
String[] types = (String[])getValue(state); String[] types = (String[]) getValue(state);
if (types == null) { if (types == null) {
types = new String[0]; types = new String[0];
@ -68,30 +134,30 @@ public class ContentTypeFilterWidget extends FilterWidget {
return new ContentTypeFilterSpecification(types); return new ContentTypeFilterSpecification(types);
} }
public void generateBodyXML(PageState state, @Override
Element parent) { public void generateBodyXML(PageState state, Element parent) {
super.generateBodyXML(state, parent); super.generateBodyXML(state, parent);
String[] types = (String[])getValue(state); String[] types = (String[]) getValue(state);
if (types == null) { if (types == null) {
types = new String[0]; types = new String[0];
} }
ContentType[] widgetTypes = getContentTypes(state); 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"); Element type = Search.newElement("contentType");
type.addAttribute("name", widgetTypes[i].getAssociatedObjectType()); type.addAttribute("name", widgetTypes[i].getAssociatedObjectType());
type.addAttribute("title", widgetTypes[i].getLabel()); 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())) { if (types[j].equals(widgetTypes[i].getAssociatedObjectType())) {
type.addAttribute("isSelected", "1"); type.addAttribute("isSelected", "1");
break; break;
} }
} }
parent.addContent(type); parent.addContent(type);
} }
} }

View File

@ -57,79 +57,76 @@ public class ItemQueryComponent extends BaseQueryComponent {
if (Search.getConfig().isIntermediaEnabled()) { if (Search.getConfig().isIntermediaEnabled()) {
add(new LaunchDateFilterWidget(new LaunchDateFilterType(), add(new LaunchDateFilterWidget(new LaunchDateFilterType(),
LaunchDateFilterType.KEY)); LaunchDateFilterType.KEY));
} }
if (Search.getConfig().isIntermediaEnabled() || if (Search.getConfig().isIntermediaEnabled()
Search.getConfig().isLuceneEnabled()) { || Search.getConfig().isLuceneEnabled()) {
add(new PermissionFilterComponent( add(new PermissionFilterComponent(
SecurityManager.CMS_PREVIEW_ITEM)); SecurityManager.CMS_PREVIEW_ITEM));
add(new SimpleCategoryFilterWidget() { add(new SimpleCategoryFilterWidget() {
@Override
protected Category[] getRoots(PageState state) { protected Category[] getRoots(PageState state) {
Category[] roots; Category[] roots;
if (CMS.getContext().hasContentSection()) { if (CMS.getContext().hasContentSection()) {
ContentSection section = CMS.getContext().getContentSection(); ContentSection section = CMS.getContext().getContentSection();
roots = new Category[] { section.getRootCategory() }; roots = new Category[]{section.getRootCategory()};
} else { } else {
ContentSectionCollection sections = ContentSectionCollection sections =
ContentSection.getAllSections(); ContentSection.getAllSections();
List cats = new ArrayList(); List cats = new ArrayList();
while (sections.next()) { while (sections.next()) {
ContentSection section = sections.getContentSection(); ContentSection section = sections.getContentSection();
cats.add(section.getRootCategory()); cats.add(section.getRootCategory());
} }
roots = (Category[])cats.toArray(new Category[cats.size()]); roots = (Category[]) cats.toArray(new Category[cats.size()]);
} }
return roots; return roots;
} }
}); });
add(new ContentTypeFilterWidget() { add(new ContentTypeFilterWidget() {
protected ContentType[] getContentTypes(PageState state) {
// override only if there's content section context @Override
protected ContentSection getContentSection() {
if (CMS.getContext().hasContentSection()) { if (CMS.getContext().hasContentSection()) {
ContentSection section = CMS.getContext().getContentSection(); return 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;
} else { } else {
return super.getContentTypes(state); return super.getContentSection();
} }
} }
}); });
add(new VersionFilterComponent(context)); add(new VersionFilterComponent(context));
add(new ContentSectionFilterComponent()); add(new ContentSectionFilterComponent());
add(new DateRangeFilterWidget(new LastModifiedDateFilterType(), add(new DateRangeFilterWidget(new LastModifiedDateFilterType(),
LastModifiedDateFilterType.KEY)); LastModifiedDateFilterType.KEY));
add(new DateRangeFilterWidget(new CreationDateFilterType(), add(new DateRangeFilterWidget(new CreationDateFilterType(),
CreationDateFilterType.KEY)); CreationDateFilterType.KEY));
add(new PartyFilterWidget(new CreationUserFilterType(), add(new PartyFilterWidget(new CreationUserFilterType(),
CreationUserFilterType.KEY)); CreationUserFilterType.KEY));
add(new PartyFilterWidget(new LastModifiedUserFilterType(), add(new PartyFilterWidget(new LastModifiedUserFilterType(),
LastModifiedUserFilterType.KEY)); LastModifiedUserFilterType.KEY));
} }
Submit submit = new Submit(m_context + "_search", Submit submit = new Submit(m_context + "_search",
ContentSectionPage.globalize("cms.ui.search")); ContentSectionPage.globalize("cms.ui.search"));
add(submit); add(submit);
} }
private class LaunchDateFilterWidget extends DateRangeFilterWidget { private class LaunchDateFilterWidget extends DateRangeFilterWidget {
public LaunchDateFilterWidget(FilterType type, String name) { public LaunchDateFilterWidget(FilterType type, String name) {
super(type,name); super(type, name);
} }
public boolean isVisible(PageState state) { public boolean isVisible(PageState state) {
return !ContentSection.getConfig().getHideLaunchDate() && return !ContentSection.getConfig().getHideLaunchDate()
super.isVisible(state); && super.isVisible(state);
} }
} }
} }

View File

@ -18,7 +18,6 @@
*/ */
package com.arsdigita.search.ui; package com.arsdigita.search.ui;
import com.arsdigita.bebop.SimpleComponent; import com.arsdigita.bebop.SimpleComponent;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.parameters.IntegerParameter; import com.arsdigita.bebop.parameters.IntegerParameter;
@ -41,15 +40,11 @@ import java.util.Iterator;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
public class ResultsPane extends SimpleComponent { public class ResultsPane extends SimpleComponent {
private static final Logger s_log = Logger.getLogger(ResultsPane.class); private static final Logger s_log = Logger.getLogger(ResultsPane.class);
public static final int PAGE_SIZE = 10; public static final int PAGE_SIZE = 10;
private int m_pageSize = PAGE_SIZE; private int m_pageSize = PAGE_SIZE;
private String m_engine; private String m_engine;
private QueryGenerator m_query; private QueryGenerator m_query;
private IntegerParameter m_pageNumber; private IntegerParameter m_pageNumber;
@ -68,15 +63,14 @@ public class ResultsPane extends SimpleComponent {
} }
public ResultsPane(QueryGenerator query, public ResultsPane(QueryGenerator query,
String engine) { String engine) {
m_query = query; m_query = query;
m_engine = engine; m_engine = engine;
m_pageNumber = new IntegerParameter("page"); m_pageNumber = new IntegerParameter("page");
m_relative = false; m_relative = false;
} }
public void generateXML(PageState state, public void generateXML(PageState state, Element parent) {
Element parent) {
if (!m_query.hasQuery(state)) { if (!m_query.hasQuery(state)) {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("No query available, skipping XMl generation"); s_log.debug("No query available, skipping XMl generation");
@ -87,86 +81,96 @@ public class ResultsPane extends SimpleComponent {
QuerySpecification spec = m_query.getQuerySpecification(state); QuerySpecification spec = m_query.getQuerySpecification(state);
ResultSet resultSet = null; ResultSet resultSet = null;
try { try {
resultSet = m_engine == null ? resultSet = m_engine == null
Search.process(spec) : ? Search.process(spec)
Search.process(spec, : Search.process(spec, Search.DEFAULT_RESULT_CACHE, m_engine);
Search.DEFAULT_RESULT_CACHE,
m_engine);
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Got result set " + resultSet.getClass() + s_log.debug("Got result set " + resultSet.getClass()
" count: " + resultSet.getCount()); + " count: " + resultSet.getCount());
} }
Integer page = (Integer) m_pageNumber.transformValue(state.getRequest()); if (resultSet.getCount() > 0) {
int pageNumber = (page == null ? 1 : page.intValue());
long objectCount = resultSet.getCount();
int pageCount = (int)Math.ceil((double)objectCount / (double)m_pageSize);
if (pageNumber < 1) { Integer page = (Integer) m_pageNumber.transformValue(state.getRequest());
pageNumber = 1; 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 { } finally {
if(resultSet != null) { if (resultSet != null) {
try { try {
resultSet.close(); resultSet.close();
} catch (Exception e) { } catch (Exception e) {
/* /*
* If there is a problem closing the result set this probably means * If there is a problem closing the result set this probably means
* it has been closed elsewhere and is probably not fatal. We write * it has been closed elsewhere and is probably not fatal. We write
* a line to the error log but otherwise ignore the exception allowing * a line to the error log but otherwise ignore the exception allowing
* the code to continue normally. Any issues willemerge in the log. * the code to continue normally. Any issues willemerge in the log.
*/ */
s_log.error("Error closing resultset: "+e.getMessage()); s_log.error("Error closing resultset: " + e.getMessage());
} }
} }
} }
} }
protected Element generatePaginatorXML(PageState state, protected Element generatePaginatorXML(PageState state,
String pageParam, String pageParam,
int pageNumber, int pageNumber,
int pageCount, int pageCount,
int pageSize, int pageSize,
long begin, long begin,
long end, long end,
long objectCount) { long objectCount) {
Element paginator = Search.newElement("paginator"); Element paginator = Search.newElement("paginator");
URL url = Web.getContext().getRequestURL(); URL url = Web.getContext().getRequestURL();
ParameterMap map = new ParameterMap(); ParameterMap map = new ParameterMap();
Iterator current = url.getParameterMap().keySet().iterator(); Iterator current = url.getParameterMap().keySet().iterator();
while (current.hasNext()) { while (current.hasNext()) {
String key = (String)current.next(); String key = (String) current.next();
if (key.equals(pageParam)) { if (key.equals(pageParam)) {
continue; continue;
} }
@ -174,26 +178,25 @@ public class ResultsPane extends SimpleComponent {
} }
paginator.addAttribute("pageParam", m_pageNumber.getName()); paginator.addAttribute("pageParam", m_pageNumber.getName());
paginator.addAttribute("baseURL", URL.there(url.getPathInfo(), map) paginator.addAttribute("baseURL", URL.there(url.getPathInfo(), map).toString());
.toString());
paginator.addAttribute("pageNumber", XML.format(new Integer(pageNumber))); paginator.addAttribute("pageNumber", XML.format(new Integer(pageNumber)));
paginator.addAttribute("pageCount", XML.format(new Integer(pageCount))); paginator.addAttribute("pageCount", XML.format(new Integer(pageCount)));
paginator.addAttribute("pageSize", XML.format(new Integer(pageSize))); 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("objectEnd", XML.format(new Long(end)));
paginator.addAttribute("objectCount", XML.format(new Long(objectCount))); paginator.addAttribute("objectCount", XML.format(new Long(objectCount)));
return paginator; return paginator;
} }
protected Element generateDocumentsXML(PageState state, protected Element generateDocumentsXML(PageState state,
Iterator results) { Iterator results) {
Element documents = Search.newElement("documents"); Element documents = Search.newElement("documents");
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Outputting documents"); s_log.debug("Outputting documents");
} }
while (results.hasNext()) { while (results.hasNext()) {
Document doc = (Document)results.next(); Document doc = (Document) results.next();
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("One doc " + doc.getOID() + " " + doc.getTitle()); s_log.debug("One doc " + doc.getOID() + " " + doc.getTitle());
} }
@ -204,7 +207,7 @@ public class ResultsPane extends SimpleComponent {
} }
protected Element generateDocumentXML(PageState state, protected Element generateDocumentXML(PageState state,
Document doc) { Document doc) {
Element entry = Search.newElement("object"); Element entry = Search.newElement("object");
String summary = doc.getSummary(); String summary = doc.getSummary();
@ -228,25 +231,23 @@ public class ResultsPane extends SimpleComponent {
Party creationParty = doc.getCreationParty(); Party creationParty = doc.getCreationParty();
if (creationParty != null) { if (creationParty != null) {
entry.addAttribute("creationParty", entry.addAttribute("creationParty",
XML.format(creationParty.getDisplayName())); XML.format(creationParty.getDisplayName()));
} }
Date lastModifiedDate = doc.getLastModifiedDate(); Date lastModifiedDate = doc.getLastModifiedDate();
if (lastModifiedDate != null) { if (lastModifiedDate != null) {
entry.addAttribute("lastModifiedDate", entry.addAttribute("lastModifiedDate",
XML.format(lastModifiedDate)); XML.format(lastModifiedDate));
} }
Party lastModifiedParty = doc.getLastModifiedParty(); Party lastModifiedParty = doc.getLastModifiedParty();
if (lastModifiedParty != null) { if (lastModifiedParty != null) {
entry.addAttribute("lastModifiedParty", entry.addAttribute("lastModifiedParty",
XML.format(lastModifiedParty.getDisplayName())); XML.format(lastModifiedParty.getDisplayName()));
} }
s_log.debug("about to add the contentSectionName from search index Doc to search result xml"); s_log.debug("about to add the contentSectionName from search index Doc to search result xml");
entry.addAttribute("contentSectionName", XML.format(doc.getContentSection())); entry.addAttribute("contentSectionName", XML.format(doc.getContentSection()));
return entry; return entry;
} }
} }