Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

Commit

Permalink
WL-545: new tool based on web content that takes over frame set or in…
Browse files Browse the repository at this point in the history
…dded opens in a "_blank" window
  • Loading branch information
Colin Hebert committed Aug 29, 2012
1 parent 47bceba commit 8326388
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
3 changes: 2 additions & 1 deletion web-tool/tool/src/bundle/iframe.properties
Expand Up @@ -18,6 +18,7 @@ gen.save = Update Options
gen.cancel = Cancel
gen.options = Options
gen.resize = Automatically Resize
gen.redirect = Redirect instead of using a frame
gen.description = Description
gen.info.url = Site Info URL
gen.info.url.msg = If specified, this URL will be shown instead of the Site description.
Expand All @@ -40,4 +41,4 @@ gen.info.pop = Open in new window?
### (moot) gen.info.no = no

java.alert.pleentval = The height you entered was not valid.
gen.info.title.message = My Workspace Information Message
gen.info.title.message = My Workspace Information Message
43 changes: 34 additions & 9 deletions web-tool/tool/src/java/org/sakaiproject/web/tool/IFrameAction.java
Expand Up @@ -52,12 +52,14 @@
import org.sakaiproject.site.api.SitePage;
import org.sakaiproject.site.api.ToolConfiguration;
import org.sakaiproject.site.cover.SiteService;
import org.sakaiproject.thread_local.cover.ThreadLocalManager;
import org.sakaiproject.tool.api.Placement;
import org.sakaiproject.tool.api.Session;
import org.sakaiproject.tool.api.ToolSession;
import org.sakaiproject.tool.cover.SessionManager;
import org.sakaiproject.tool.cover.ToolManager;
import org.sakaiproject.util.FormattedText;
import org.sakaiproject.util.RequestFilter;
import org.sakaiproject.util.ResourceLoader;
import org.sakaiproject.util.StringUtil;
import org.sakaiproject.user.api.User;
Expand All @@ -66,6 +68,8 @@
import org.sakaiproject.event.api.EventTrackingService;
import org.sakaiproject.event.api.NotificationService;

import javax.servlet.http.HttpServletResponse;

/**
* <p>
* IFrameAction is the Sakai tool to place any web content in an IFrame on the page.
Expand Down Expand Up @@ -105,6 +109,10 @@ public class IFrameAction extends VelocityPortletPaneledAction
/** The resize state, config and context. */
protected final static String RESIZE = "resize";

/** The value in state and context for the popup parameter. If a popup is used, it should be opened from the iframe
* in order to keep the menu bar accessible */
public static final String POP_UP = "popup";

/** The custom height from user input * */
protected final static String CUSTOM_HEIGHT = "customNumberField";

Expand Down Expand Up @@ -316,6 +324,9 @@ else if ("true".equals(config.getProperty("annotatedurl")))

// set the resize
state.setAttribute(RESIZE, Boolean.valueOf(config.getProperty(RESIZE, "false")));

// Set the popup attribute
state.setAttribute(POP_UP, Boolean.valueOf(config.getProperty(POP_UP, "false")));

state.setAttribute(ANNOTATED_TEXT, config.getProperty(ANNOTATED_TEXT, ""));

Expand Down Expand Up @@ -756,10 +767,19 @@ public String buildMainPanelContext(VelocityPortlet portlet, Context context, Ru
// set our configuration into the context for the vm
String url = (String) state.getAttribute(URL);
String special = (String) state.getAttribute(SPECIAL);

/* If redirection is enabled, skip everything and just send an HTTP redirect */
if(state.getAttribute(POP_UP) != null && (Boolean) state.getAttribute(POP_UP) &&
!SiteService.allowUpdateSite(ToolManager.getCurrentPlacement().getContext())){
sendParentRedirect((HttpServletResponse) ThreadLocalManager.get(RequestFilter.CURRENT_HTTP_RESPONSE), url);
return null;
}

context.put(URL, url);
context.put(HEIGHT, state.getAttribute(HEIGHT));
context.put(RESIZE, state.getAttribute(RESIZE));

context.put(POP_UP, state.getAttribute(POP_UP));

//for annotatedurl
context.put(TARGETPAGE_URL, state.getAttribute(TARGETPAGE_URL));
context.put(TARGETPAGE_NAME, state.getAttribute(TARGETPAGE_NAME));
Expand All @@ -771,9 +791,9 @@ public String buildMainPanelContext(VelocityPortlet portlet, Context context, Ru
// setup for the options menu if needed

String hideOptions = (String) state.getAttribute(HIDE_OPTIONS);
if (hideOptions != null && "true".equalsIgnoreCase(hideOptions))


if (hideOptions != null && "true".equalsIgnoreCase(hideOptions))
{
// always hide Options menu if hide.options is specified
} else if (SiteService.allowUpdateSite(ToolManager.getCurrentPlacement().getContext()))
Expand Down Expand Up @@ -905,6 +925,10 @@ else if (SPECIAL_ANNOTATEDURL.equals(special))
context.put(RESIZE, Boolean.TRUE);
}

if(state.getAttribute(POP_UP) != null) {
context.put(POP_UP, state.getAttribute(POP_UP));
}

context.put(TITLE, state.getAttribute(TITLE));
context.put("tlang", rb);

Expand All @@ -929,8 +953,6 @@ else if (SPECIAL_ANNOTATEDURL.equals(special))
if ((page.getTools() != null) && (page.getTools().size() == 1))
{
context.put("showPopup", Boolean.TRUE);
context.put("popup", Boolean.valueOf(page.isPopUp()));

context.put("pageTitleEditable", Boolean.TRUE);
context.put("page_title", (String) state.getAttribute(STATE_PAGE_TITLE));
}
Expand Down Expand Up @@ -1036,7 +1058,10 @@ else if (SPECIAL_ANNOTATEDURL.equals(state.getAttribute(SPECIAL)))
boolean resize = data.getParameters().getBoolean(RESIZE);
state.setAttribute(RESIZE, resize);
placement.getPlacementConfig().setProperty(RESIZE, Boolean.toString(resize));


boolean popUp = data.getParameters().getBoolean(POP_UP);
state.setAttribute(POP_UP, popUp);
placement.getPlacementConfig().setProperty(POP_UP, Boolean.toString(popUp));

// title
String title = data.getParameters().getString(TITLE);
Expand Down Expand Up @@ -1087,9 +1112,9 @@ else if (newPageTitle.length() > MAX_TITLE_LENGTH)
}
page.setTitle(newPageTitle);
state.setAttribute(STATE_PAGE_TITLE, newPageTitle);

// popup
boolean popup = data.getParameters().getBoolean("popup");
boolean popup = data.getParameters().getBoolean(POP_UP);
page.setPopup(popup);
}
}
Expand Down

0 comments on commit 8326388

Please sign in to comment.