Hinweistext für die Suche eingefügt
git-svn-id: https://svn.libreccm.org/ccm/trunk@2435 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
d3805612d3
commit
35647b1d2b
|
|
@ -83,7 +83,7 @@ public class ImageStepEdit extends SimpleContainer
|
||||||
m_attachListener = new ImageComponentAttachListener(m_imageComponent,
|
m_attachListener = new ImageComponentAttachListener(m_imageComponent,
|
||||||
m_imageStep);
|
m_imageStep);
|
||||||
|
|
||||||
/* Include CMS ImageLibrary to display existing images too select from*/
|
/* Include CMS ImageLibrary to display existing images too select from */
|
||||||
ImageLibraryComponent library = new ImageLibraryComponent();
|
ImageLibraryComponent library = new ImageLibraryComponent();
|
||||||
library.getForm().addInitListener(m_attachListener);
|
library.getForm().addInitListener(m_attachListener);
|
||||||
library.getForm().addProcessListener(m_attachListener);
|
library.getForm().addProcessListener(m_attachListener);
|
||||||
|
|
@ -95,7 +95,7 @@ public class ImageStepEdit extends SimpleContainer
|
||||||
selectors.put(ImageComponent.LIBRARY, library);
|
selectors.put(ImageComponent.LIBRARY, library);
|
||||||
add(library);
|
add(library);
|
||||||
|
|
||||||
/* Include CMS Image Upload component to enable uploading new img */
|
/* Include CMS Image Upload component to enable uploading new img */
|
||||||
ImageUploadComponent upload = new ImageUploadComponent();
|
ImageUploadComponent upload = new ImageUploadComponent();
|
||||||
upload.getForm().addInitListener(m_attachListener);
|
upload.getForm().addInitListener(m_attachListener);
|
||||||
upload.getForm().addProcessListener(m_attachListener);
|
upload.getForm().addProcessListener(m_attachListener);
|
||||||
|
|
|
||||||
|
|
@ -64,72 +64,56 @@ import org.apache.log4j.Logger;
|
||||||
*/
|
*/
|
||||||
public class ContentSectionPage extends CMSPage implements ActionListener {
|
public class ContentSectionPage extends CMSPage implements ActionListener {
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger
|
private static final Logger s_log = Logger.getLogger(ContentSectionPage.class);
|
||||||
(ContentSectionPage.class);
|
|
||||||
|
|
||||||
public static final String RESOURCE_BUNDLE =
|
public static final String RESOURCE_BUNDLE =
|
||||||
"com.arsdigita.cms.CMSResources";
|
"com.arsdigita.cms.CMSResources";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL parameter that can be passed in in order to set the
|
* The URL parameter that can be passed in in order to set the current
|
||||||
* current folder. This is used in getting back to the correct
|
* folder. This is used in getting back to the correct level of folder
|
||||||
* level of folder expansion from content item page.
|
* expansion from content item page.
|
||||||
*/
|
*/
|
||||||
public static final String SET_FOLDER = "set_folder";
|
public static final String SET_FOLDER = "set_folder";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL parameter that can be passed in in order to set the
|
* The URL parameter that can be passed in in order to set the current
|
||||||
* current template (for setting the content type)
|
* template (for setting the content type)
|
||||||
*/
|
*/
|
||||||
public static final String SET_TEMPLATE = "set_template";
|
public static final String SET_TEMPLATE = "set_template";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL parameter that can be passed in in order to set the
|
* The URL parameter that can be passed in in order to set the current tab.
|
||||||
* current tab. This is a KLUDGE right now because the
|
* This is a KLUDGE right now because the TabbedDialog's current tab is
|
||||||
* TabbedDialog's current tab is selected with a local state
|
* selected with a local state parameter.
|
||||||
* parameter.
|
|
||||||
*/
|
*/
|
||||||
public static final String SET_TAB = "set_tab";
|
public static final String SET_TAB = "set_tab";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index of the search tab
|
* Index of the search tab
|
||||||
*/
|
*/
|
||||||
public static final int SEARCH_TAB = 0;
|
public static final int SEARCH_TAB = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index of the browse tab
|
* Index of the browse tab
|
||||||
*/
|
*/
|
||||||
public static final int BROWSE_TAB = 1;
|
public static final int BROWSE_TAB = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index of the roles tab
|
* Index of the roles tab
|
||||||
*/
|
*/
|
||||||
public static final int ROLES_TAB = 2;
|
public static final int ROLES_TAB = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index of the workflows tab
|
* Index of the workflows tab
|
||||||
*/
|
*/
|
||||||
public static final int WORKFLOW_TAB = 3;
|
public static final int WORKFLOW_TAB = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index of the lifecycles tab
|
* Index of the lifecycles tab
|
||||||
*/
|
*/
|
||||||
public static final int LIFECYCLES_TAB = 4;
|
public static final int LIFECYCLES_TAB = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index of the categories tab
|
* Index of the categories tab
|
||||||
*/
|
*/
|
||||||
public static final int CATEGORIES_TAB = 5;
|
public static final int CATEGORIES_TAB = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index of the content types tab
|
* Index of the content types tab
|
||||||
*/
|
*/
|
||||||
public static final int CONTENTTYPES_TAB = 6;
|
public static final int CONTENTTYPES_TAB = 6;
|
||||||
|
|
||||||
public static final int USER_ADMIN_TAB = 7;
|
public static final int USER_ADMIN_TAB = 7;
|
||||||
|
|
||||||
private TabbedPane m_tabbedPane;
|
private TabbedPane m_tabbedPane;
|
||||||
|
|
||||||
private FolderAdminPane m_folderPane;
|
private FolderAdminPane m_folderPane;
|
||||||
private BrowsePane m_browsePane;
|
private BrowsePane m_browsePane;
|
||||||
private ItemSearch m_searchPane;
|
private ItemSearch m_searchPane;
|
||||||
|
|
@ -144,6 +128,8 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
|
||||||
private ReportPane m_reportPane;
|
private ReportPane m_reportPane;
|
||||||
|
|
||||||
private static class TitlePrinter implements PrintListener {
|
private static class TitlePrinter implements PrintListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
public void prepare(PrintEvent e) {
|
public void prepare(PrintEvent e) {
|
||||||
final Label l = (Label) e.getTarget();
|
final Label l = (Label) e.getTarget();
|
||||||
|
|
||||||
|
|
@ -183,40 +169,39 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
|
||||||
add(m_tabbedPane);
|
add(m_tabbedPane);
|
||||||
|
|
||||||
addActionListener(new ActionListener() {
|
addActionListener(new ActionListener() {
|
||||||
public final void actionPerformed(ActionEvent e) {
|
@Override
|
||||||
final PageState state = e.getPageState();
|
public final void actionPerformed(ActionEvent e) {
|
||||||
|
final PageState state = e.getPageState();
|
||||||
|
|
||||||
final String tab = state.getRequest().getParameter
|
final String tab = state.getRequest().getParameter(SET_TAB);
|
||||||
(SET_TAB);
|
|
||||||
|
|
||||||
if (tab != null) {
|
if (tab != null) {
|
||||||
m_tabbedPane.setSelectedIndex
|
m_tabbedPane.setSelectedIndex(state, Integer.valueOf(tab).intValue());
|
||||||
(state, Integer.valueOf(tab).intValue());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SecurityManager sm = CMS.getContext().getSecurityManager();
|
SecurityManager sm = CMS.getContext().getSecurityManager();
|
||||||
User user = Web.getContext().getUser();
|
User user = Web.getContext().getUser();
|
||||||
m_tabbedPane.setTabVisible(state, m_userAdminPane, sm.canAccess(user,SecurityConstants.STAFF_ADMIN));
|
m_tabbedPane.setTabVisible(state, m_userAdminPane, sm.canAccess(user, SecurityConstants.STAFF_ADMIN));
|
||||||
|
|
||||||
if ( ContentSection.getConfig().getHideAdminTabs() ) {
|
if (ContentSection.getConfig().getHideAdminTabs()) {
|
||||||
m_tabbedPane.setTabVisible(state, m_workflowPane, sm.canAccess(user,SecurityConstants.WORKFLOW_ADMIN));
|
m_tabbedPane.setTabVisible(state, m_workflowPane, sm.canAccess(user, SecurityConstants.WORKFLOW_ADMIN));
|
||||||
m_tabbedPane.setTabVisible(state, m_categoryPane, sm.canAccess(user,SecurityConstants.CATEGORY_ADMIN));
|
m_tabbedPane.setTabVisible(state, m_categoryPane, sm.canAccess(user, SecurityConstants.CATEGORY_ADMIN));
|
||||||
m_tabbedPane.setTabVisible(state, m_lifecyclePane, sm.canAccess(user,SecurityConstants.LIFECYCLE_ADMIN));
|
m_tabbedPane.setTabVisible(state, m_lifecyclePane, sm.canAccess(user, SecurityConstants.LIFECYCLE_ADMIN));
|
||||||
m_tabbedPane.setTabVisible(state, m_typePane, sm.canAccess(user,SecurityConstants.CONTENT_TYPE_ADMIN));
|
m_tabbedPane.setTabVisible(state, m_typePane, sm.canAccess(user, SecurityConstants.CONTENT_TYPE_ADMIN));
|
||||||
m_tabbedPane.setTabVisible(state, m_rolePane, sm.canAccess(user,SecurityConstants.STAFF_ADMIN));
|
m_tabbedPane.setTabVisible(state, m_rolePane, sm.canAccess(user, SecurityConstants.STAFF_ADMIN));
|
||||||
// csePane: should check permission
|
// csePane: should check permission
|
||||||
m_tabbedPane.setTabVisible(state, m_csePane, true);
|
m_tabbedPane.setTabVisible(state, m_csePane, true);
|
||||||
// TODO Check for reportPane as well
|
// TODO Check for reportPane as well
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
add(new DebugPanel());
|
add(new DebugPanel());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates, and then caches, the browse pane. Overriding this
|
* Creates, and then caches, the browse pane. Overriding this method to
|
||||||
* method to return null will prevent this tab from appearing.
|
* return null will prevent this tab from appearing.
|
||||||
*/
|
*/
|
||||||
protected FolderAdminPane getFolderAdminPane() {
|
protected FolderAdminPane getFolderAdminPane() {
|
||||||
if (m_folderPane == null) {
|
if (m_folderPane == null) {
|
||||||
|
|
@ -226,8 +211,8 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates, and then caches, the browse pane. Overriding this
|
* Creates, and then caches, the browse pane. Overriding this method to
|
||||||
* method to return null will prevent this tab from appearing.
|
* return null will prevent this tab from appearing.
|
||||||
*/
|
*/
|
||||||
protected BrowsePane getBrowsePane() {
|
protected BrowsePane getBrowsePane() {
|
||||||
if (m_browsePane == null) {
|
if (m_browsePane == null) {
|
||||||
|
|
@ -237,8 +222,8 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates, and then caches, the search pane. Overriding this
|
* Creates, and then caches, the search pane. Overriding this method to
|
||||||
* method to return null will prevent this tab from appearing.
|
* return null will prevent this tab from appearing.
|
||||||
*/
|
*/
|
||||||
protected ItemSearch getSearchPane() {
|
protected ItemSearch getSearchPane() {
|
||||||
if (m_searchPane == null) {
|
if (m_searchPane == null) {
|
||||||
|
|
@ -248,7 +233,7 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ImagesPane getImagesPane() {
|
protected ImagesPane getImagesPane() {
|
||||||
if(m_imagesPane == null) {
|
if (m_imagesPane == null) {
|
||||||
m_imagesPane = new ImagesPane();
|
m_imagesPane = new ImagesPane();
|
||||||
}
|
}
|
||||||
return m_imagesPane;
|
return m_imagesPane;
|
||||||
|
|
@ -262,9 +247,8 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates, and then caches, the workflow administration
|
* Creates, and then caches, the workflow administration pane. Overriding
|
||||||
* pane. Overriding this method to return null will prevent this
|
* this method to return null will prevent this tab from appearing.
|
||||||
* tab from appearing.
|
|
||||||
*/
|
*/
|
||||||
protected WorkflowAdminPane getWorkflowAdminPane() {
|
protected WorkflowAdminPane getWorkflowAdminPane() {
|
||||||
if (m_workflowPane == null) {
|
if (m_workflowPane == null) {
|
||||||
|
|
@ -274,9 +258,8 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates, and then caches, the lifecycle administration
|
* Creates, and then caches, the lifecycle administration pane. Overriding
|
||||||
* pane. Overriding this method to return null will prevent this tab
|
* this method to return null will prevent this tab from appearing.
|
||||||
* from appearing.
|
|
||||||
*/
|
*/
|
||||||
protected LifecycleAdminPane getLifecycleAdminPane() {
|
protected LifecycleAdminPane getLifecycleAdminPane() {
|
||||||
if (m_lifecyclePane == null) {
|
if (m_lifecyclePane == null) {
|
||||||
|
|
@ -286,9 +269,8 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates, and then caches, the category administration
|
* Creates, and then caches, the category administration pane. Overriding
|
||||||
* pane. Overriding this method to return null will prevent this tab
|
* this method to return null will prevent this tab from appearing.
|
||||||
* from appearing.
|
|
||||||
*/
|
*/
|
||||||
protected CategoryAdminPane getCategoryAdminPane() {
|
protected CategoryAdminPane getCategoryAdminPane() {
|
||||||
if (m_categoryPane == null) {
|
if (m_categoryPane == null) {
|
||||||
|
|
@ -298,9 +280,9 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates, and then caches, the content type administration
|
* Creates, and then caches, the content type administration pane.
|
||||||
* pane. Overriding this method to return null will prevent this
|
* Overriding this method to return null will prevent this tab from
|
||||||
* tab from appearing.
|
* appearing.
|
||||||
*/
|
*/
|
||||||
protected ContentTypeAdminPane getContentTypeAdminPane() {
|
protected ContentTypeAdminPane getContentTypeAdminPane() {
|
||||||
if (m_typePane == null) {
|
if (m_typePane == null) {
|
||||||
|
|
@ -329,14 +311,14 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
|
||||||
|
|
||||||
protected ReportPane getReportPane() {
|
protected ReportPane getReportPane() {
|
||||||
if (m_reportPane == null) {
|
if (m_reportPane == null) {
|
||||||
m_reportPane = new ReportPane();
|
m_reportPane = new ReportPane();
|
||||||
}
|
}
|
||||||
return m_reportPane;
|
return m_reportPane;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the specified component, with the specified tab name, to
|
* Adds the specified component, with the specified tab name, to the tabbed
|
||||||
* the tabbed pane only if it is not null.
|
* pane only if it is not null.
|
||||||
*
|
*
|
||||||
* @param pane The pane to which to add the tab
|
* @param pane The pane to which to add the tab
|
||||||
* @param tabName The name of the tab if it's added
|
* @param tabName The name of the tab if it's added
|
||||||
|
|
@ -344,28 +326,27 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
|
||||||
*/
|
*/
|
||||||
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( new Label(tabName), comp);
|
pane.addTab(new Label(tabName), comp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tab(final TabbedPane pane,
|
private void tab(final TabbedPane pane,
|
||||||
final String key,
|
final String key,
|
||||||
final Component tab) {
|
final Component tab) {
|
||||||
if (tab != null) {
|
if (tab != null) {
|
||||||
pane.addTab(new Label(gz(key)), tab);
|
pane.addTab(new Label(gz(key)), tab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Created the TabbedPane to use for this page. Adds the tabs
|
* <p>Created the TabbedPane to use for this page. Adds the tabs to the
|
||||||
* to the pane. The default implementation uses a {@link
|
* pane. The default implementation uses a {@link
|
||||||
* com.arsdigita.bebop.TabbedPane}. This implementation also adds
|
* com.arsdigita.bebop.TabbedPane}. This implementation also adds browse,
|
||||||
* browse, search, staff admin, viewers admin, workflow admin,
|
* search, staff admin, viewers admin, workflow admin, category admin, and
|
||||||
* category admin, and content type panes.</p>
|
* content type panes.</p>
|
||||||
*
|
*
|
||||||
* <p>Developers can override this method to add only the tabs
|
* <p>Developers can override this method to add only the tabs they want, or
|
||||||
* they want, or to add additional tabs after the default CMS tabs
|
* to add additional tabs after the default CMS tabs are added.</p>
|
||||||
* are added.</p>
|
|
||||||
*/
|
*/
|
||||||
protected TabbedPane createTabbedPane() {
|
protected TabbedPane createTabbedPane() {
|
||||||
final TabbedPane pane = new TabbedPane();
|
final TabbedPane pane = new TabbedPane();
|
||||||
|
|
@ -392,6 +373,7 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
|
||||||
* @param request The HTTP request
|
* @param request The HTTP request
|
||||||
* @return The current content section
|
* @return The current content section
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ContentSection getContentSection(HttpServletRequest request) {
|
public ContentSection getContentSection(HttpServletRequest request) {
|
||||||
// Resets all content sections associations.
|
// Resets all content sections associations.
|
||||||
ContentSection section = super.getContentSection(request);
|
ContentSection section = super.getContentSection(request);
|
||||||
|
|
@ -400,11 +382,12 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When a new tab is selected, reset the state of the
|
* When a new tab is selected, reset the state of the formerly-selected
|
||||||
* formerly-selected pane.
|
* pane.
|
||||||
*
|
*
|
||||||
* @param event The event fired by selecting a tab
|
* @param event The event fired by selecting a tab
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
|
|
@ -443,12 +426,10 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
|
||||||
*/
|
*/
|
||||||
public static String getSectionURL(ContentItem item, int tab) {
|
public static String getSectionURL(ContentItem item, int tab) {
|
||||||
// Get the content section associated with the content item.
|
// Get the content section associated with the content item.
|
||||||
ContentSection section = null;
|
ContentSection section = ContentSection.getContentSection(item);
|
||||||
|
|
||||||
section = ContentSection.getContentSection(item);
|
String url = section.getURL() + PageLocations.SECTION_PAGE
|
||||||
|
+ "?" + SET_TAB + "=" + tab;
|
||||||
String url = section.getURL() + PageLocations.SECTION_PAGE +
|
|
||||||
"?" + SET_TAB + "=" + tab;
|
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,12 +65,14 @@ public class ImageLibraryComponent extends SimpleContainer
|
||||||
m_chooser = new ImageChooser(ContentItem.DRAFT, m_mode);
|
m_chooser = new ImageChooser(ContentItem.DRAFT, m_mode);
|
||||||
m_chooser.addImageActionListener(new ImageBrowser.LinkActionListener() {
|
m_chooser.addImageActionListener(new ImageBrowser.LinkActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
public void deleteClicked(final PageState state, final BigDecimal imageID) {
|
public void deleteClicked(final PageState state, final BigDecimal imageID) {
|
||||||
ImagesPane.S_LOG.debug("Clicked delete");
|
ImagesPane.S_LOG.debug("Clicked delete");
|
||||||
final ReusableImageAsset image = new ReusableImageAsset(imageID);
|
final ReusableImageAsset image = new ReusableImageAsset(imageID);
|
||||||
image.delete();
|
image.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void linkClicked(final PageState state, final BigDecimal imageID) {
|
public void linkClicked(final PageState state, final BigDecimal imageID) {
|
||||||
ImagesPane.S_LOG.debug("Clicked select");
|
ImagesPane.S_LOG.debug("Clicked select");
|
||||||
try {
|
try {
|
||||||
|
|
@ -137,6 +139,7 @@ public class ImageLibraryComponent extends SimpleContainer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ReusableImageAsset getImage(final FormSectionEvent event) {
|
public ReusableImageAsset getImage(final FormSectionEvent event) {
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
return (ReusableImageAsset) m_imageModel.getSelectedItem(state);
|
return (ReusableImageAsset) m_imageModel.getSelectedItem(state);
|
||||||
|
|
@ -148,30 +151,36 @@ public class ImageLibraryComponent extends SimpleContainer
|
||||||
page.addComponentStateParam(this, m_imageID);
|
page.addComponentStateParam(this, m_imageID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getCaption(final FormSectionEvent event) {
|
public String getCaption(final FormSectionEvent event) {
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
return (String) m_caption.getValue(state);
|
return (String) m_caption.getValue(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getDescription(final FormSectionEvent event) {
|
public String getDescription(final FormSectionEvent event) {
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
return (String) m_description.getValue(state);
|
return (String) m_description.getValue(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getTitle(final FormSectionEvent event) {
|
public String getTitle(final FormSectionEvent event) {
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
return (String) m_title.getValue(state);
|
return (String) m_title.getValue(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getUseContext(final FormSectionEvent event) {
|
public String getUseContext(final FormSectionEvent event) {
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
return (String) m_useContext.getValue(state);
|
return (String) m_useContext.getValue(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Form getForm() {
|
public Form getForm() {
|
||||||
return m_form;
|
return m_form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public SaveCancelSection getSaveCancelSection() {
|
public SaveCancelSection getSaveCancelSection() {
|
||||||
return m_saveCancel;
|
return m_saveCancel;
|
||||||
}
|
}
|
||||||
|
|
@ -195,6 +204,7 @@ public class ImageLibraryComponent extends SimpleContainer
|
||||||
/**
|
/**
|
||||||
* Reset this component.
|
* Reset this component.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void reset(final PageState state) {
|
public void reset(final PageState state) {
|
||||||
// clear selection
|
// clear selection
|
||||||
m_imageModel.clearSelection(state);
|
m_imageModel.clearSelection(state);
|
||||||
|
|
|
||||||
|
|
@ -44,260 +44,265 @@ 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;
|
||||||
private boolean m_relative;
|
private boolean m_relative;
|
||||||
|
|
||||||
public ResultsPane(QueryGenerator query) {
|
public ResultsPane(QueryGenerator query) {
|
||||||
this(query, null);
|
this(query, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether the links to the search results will be
|
* Determines whether the links to the search results will be relative or
|
||||||
* relative or absolute. The default is absolute.
|
* absolute. The default is absolute.
|
||||||
*/
|
*/
|
||||||
public void setRelativeURLs(boolean relative) {
|
public void setRelativeURLs(boolean relative) {
|
||||||
m_relative = relative;
|
m_relative = relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateXML(PageState state, Element parent) {
|
public void generateXML(PageState state, 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");
|
||||||
}
|
}
|
||||||
return;
|
Element content = Search.newElement("results");
|
||||||
}
|
Element info = content.newChildElement("info");
|
||||||
|
// info.setText(GlobalizationUtil.globalize("cms.ui.search_help").localize().toString());
|
||||||
|
info.setText("To search for content items, please enter at least 3 letters into the search field. You can narrow the result by using additional parameters.");
|
||||||
|
parent.addContent(content);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
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.DEFAULT_RESULT_CACHE,
|
: Search.process(spec, Search.DEFAULT_RESULT_CACHE,
|
||||||
m_engine);
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resultSet.getCount() > 0) {
|
if (resultSet.getCount() > 0) {
|
||||||
|
|
||||||
Integer page = (Integer) m_pageNumber.transformValue(state.
|
Integer page = (Integer) m_pageNumber.transformValue(state.
|
||||||
getRequest());
|
getRequest());
|
||||||
int pageNumber = (page == null ? 1 : page.intValue());
|
int pageNumber = (page == null ? 1 : page.intValue());
|
||||||
long objectCount = resultSet.getCount();
|
long objectCount = resultSet.getCount();
|
||||||
int pageCount = (int) Math.ceil((double) objectCount
|
int pageCount = (int) Math.ceil((double) objectCount
|
||||||
/ (double) m_pageSize);
|
/ (double) m_pageSize);
|
||||||
|
|
||||||
if (pageNumber < 1) {
|
if (pageNumber < 1) {
|
||||||
pageNumber = 1;
|
pageNumber = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pageNumber > pageCount) {
|
if (pageNumber > pageCount) {
|
||||||
pageNumber = (pageCount == 0 ? 1 : pageCount);
|
pageNumber = (pageCount == 0 ? 1 : pageCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
long begin = ((pageNumber - 1) * m_pageSize);
|
long begin = ((pageNumber - 1) * m_pageSize);
|
||||||
int count = (int) Math.min(m_pageSize, (objectCount - begin));
|
int count = (int) Math.min(m_pageSize, (objectCount - begin));
|
||||||
long end = begin + count;
|
long end = begin + count;
|
||||||
|
|
||||||
Iterator results = resultSet.getDocuments(begin, count);
|
Iterator results = resultSet.getDocuments(begin, count);
|
||||||
|
|
||||||
Element content = Search.newElement("results");
|
Element content = Search.newElement("results");
|
||||||
exportAttributes(content);
|
exportAttributes(content);
|
||||||
|
|
||||||
if (s_log.isDebugEnabled()) {
|
if (s_log.isDebugEnabled()) {
|
||||||
s_log.debug("Paginator stats\n page number:" + pageNumber
|
s_log.debug("Paginator stats\n page number:" + pageNumber
|
||||||
+ "\n page count: " + pageCount
|
+ "\n page count: " + pageCount
|
||||||
+ "\n page size: "
|
+ "\n page size: "
|
||||||
+ m_pageSize + "\n start " + begin + "\n end: "
|
+ m_pageSize + "\n start " + begin + "\n end: "
|
||||||
+ end + "\n count: " + objectCount);
|
+ end + "\n count: " + objectCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
content.addContent(generatePaginatorXML(state,
|
content.addContent(generatePaginatorXML(state,
|
||||||
m_pageNumber.getName(),
|
m_pageNumber.getName(),
|
||||||
pageNumber, pageCount,
|
pageNumber, pageCount,
|
||||||
m_pageSize, begin, end,
|
m_pageSize, begin, end,
|
||||||
objectCount));
|
objectCount));
|
||||||
content.addContent(generateDocumentsXML(state, results));
|
content.addContent(generateDocumentsXML(state, results));
|
||||||
|
|
||||||
parent.addContent(content);
|
parent.addContent(content);
|
||||||
} else {
|
} else {
|
||||||
// No search result, so we don't need a paginator, but we want
|
// 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
|
// to inform the user, that there are no results for this search
|
||||||
Element content = Search.newElement("results");
|
Element content = Search.newElement("results");
|
||||||
Element info = content.newChildElement("info");
|
Element info = content.newChildElement("info");
|
||||||
// info.setText(GlobalizationUtil.globalize("cms.ui.search_no_results").localize().toString());
|
// info.setText(GlobalizationUtil.globalize("cms.ui.search_no_results").localize().toString());
|
||||||
info.setText("Sorry. Your search returned 0 results.");
|
info.setText("Sorry. Your search returned 0 results.");
|
||||||
parent.addContent(content);
|
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;
|
||||||
}
|
}
|
||||||
//map.setParameterValues(key, url.getParameterValues(key));
|
//map.setParameterValues(key, url.getParameterValues(key));
|
||||||
map.setParameterValues(key,
|
map.setParameterValues(key,
|
||||||
decodeParameters(url.getParameterValues(key),
|
decodeParameters(url.getParameterValues(key),
|
||||||
state));
|
state));
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] decodeParameters(final String[] parameters,
|
private String[] decodeParameters(final String[] parameters,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
final String[] decoded = new String[parameters.length];
|
final String[] decoded = new String[parameters.length];
|
||||||
|
|
||||||
for (int i = 0; i < parameters.length; i++) {
|
for (int i = 0; i < parameters.length; i++) {
|
||||||
decoded[i] = decodeParameter(parameters[i], state);
|
decoded[i] = decodeParameter(parameters[i], state);
|
||||||
}
|
}
|
||||||
|
|
||||||
return decoded;
|
return decoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String decodeParameter(final String parameter,
|
private String decodeParameter(final String parameter,
|
||||||
final PageState state) {
|
final PageState state) {
|
||||||
String re = state.getRequest().getParameter(Globalization.ENCODING_PARAM_NAME);
|
String re = state.getRequest().getParameter(Globalization.ENCODING_PARAM_NAME);
|
||||||
|
|
||||||
if ((re == null) || (re.isEmpty())) {
|
if ((re == null) || (re.isEmpty())) {
|
||||||
re = Globalization.getDefaultCharset();
|
re = Globalization.getDefaultCharset();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((parameter == null) || (parameter.isEmpty())) {
|
if ((parameter == null) || (parameter.isEmpty())) {
|
||||||
return parameter;
|
return parameter;
|
||||||
} else if(Globalization.getDefaultCharset(state.getRequest()).equals(re)) {
|
} else if (Globalization.getDefaultCharset(state.getRequest()).equals(re)) {
|
||||||
return parameter;
|
return parameter;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
return new String(parameter.getBytes(Globalization.getDefaultCharset(
|
return new String(parameter.getBytes(Globalization.getDefaultCharset(
|
||||||
state.getRequest())), re);
|
state.getRequest())), re);
|
||||||
} catch(UnsupportedEncodingException ex) {
|
} catch (UnsupportedEncodingException ex) {
|
||||||
s_log.warn("Unsupported encoding.", ex);
|
s_log.warn("Unsupported encoding.", ex);
|
||||||
return parameter;
|
return parameter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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());
|
||||||
}
|
}
|
||||||
documents.addContent(generateDocumentXML(state, doc));
|
documents.addContent(generateDocumentXML(state, doc));
|
||||||
}
|
}
|
||||||
|
|
||||||
return documents;
|
return documents;
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
java.net.URL url = doc.getURL();
|
java.net.URL url = doc.getURL();
|
||||||
|
|
||||||
entry.addAttribute("oid", XML.format(doc.getOID()));
|
entry.addAttribute("oid", XML.format(doc.getOID()));
|
||||||
entry.addAttribute("url", XML.format(m_relative ? url.getPath() + "?"
|
entry.addAttribute("url", XML.format(m_relative ? url.getPath() + "?"
|
||||||
+ url.getQuery()
|
+ url.getQuery()
|
||||||
: url.toString()));
|
: url.toString()));
|
||||||
entry.addAttribute("score", XML.format(doc.getScore()));
|
entry.addAttribute("score", XML.format(doc.getScore()));
|
||||||
entry.addAttribute("title", XML.format(doc.getTitle()));
|
entry.addAttribute("title", XML.format(doc.getTitle()));
|
||||||
if (summary != null) {
|
if (summary != null) {
|
||||||
entry.addAttribute("summary", XML.format(summary));
|
entry.addAttribute("summary", XML.format(summary));
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.addAttribute("locale", XML.format(doc.getLocale()));
|
entry.addAttribute("locale", XML.format(doc.getLocale()));
|
||||||
|
|
||||||
Date creationDate = doc.getCreationDate();
|
Date creationDate = doc.getCreationDate();
|
||||||
if (creationDate != null) {
|
if (creationDate != null) {
|
||||||
entry.addAttribute("creationDate", XML.format(
|
entry.addAttribute("creationDate", XML.format(
|
||||||
creationDate.toString()));
|
creationDate.toString()));
|
||||||
}
|
}
|
||||||
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(
|
s_log.debug(
|
||||||
"about to add the contentSectionName from search index Doc to search result xml");
|
"about to add the contentSectionName from search index Doc to search result xml");
|
||||||
entry.addAttribute("contentSectionName", XML.format(doc.
|
entry.addAttribute("contentSectionName", XML.format(doc.
|
||||||
getContentSection()));
|
getContentSection()));
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue