
// Extensions to add the portlet publshing feature

	var _l = samples.dvt.Portlet.prototype.config.controlPanelItems.length;
	samples.dvt.Portlet.prototype.config.controlPanelItems[_l] = 
	{
		label:			"publishPortlet",
		titleLabel:		"publishPortletTitle",
		title:			"Publish Portlet",
		buttonTitle:		"Publish Portlet",
		descriptionLabel:	"publishPortletDesc",
		description:		"Publish this portlet for use outside of the portal desktop.",
		buttonLabel:		"publishPortletButton",
		previewHandler:		"generatePublishForm",
		actionHandler:		"publishPortlet"
	};

	samples.dvt.Portlet.prototype.publishPortlet = function(evt) {
		var button = evt.target;
		var item = button.actionItem;
		var textarea = button.textarea;
		
		var appContext = bea.wlp.disc.context.Application.getInstance();
		var portletContext = this.getPortletContext();
		
		var markup = "";

		markup += "<html>\n";
		markup += "    <head>\n";
		markup += "        <title>" + portletContext.getTitle() + "</title>\n";
		markup += "        <";
		markup += "script type='text/javascript'";
		markup += " src='/" + appContext.getWebAppName() + "/framework/scripts/bundles/disc-publishing.js'><";
		markup += "/script>\n";
		markup += "        <";
		markup += "script type='text/javascript'>\n";
		markup += "            function handleOnLoad() {\n";
		markup += "                var publishingContext = '" + window.location.pathname + "';\n";
		markup += "                var source = bea.wlp.disc.publishing.PortletSource.get(publishingContext);\n";
		markup += "                source.render({portlet: '" + portletContext.getLabel() + "', to: 'thePortlet'});\n";
		markup += "            }\n";
		markup += "        <";
		markup += "/script>\n";
		markup += "    </head>\n";
		markup += "    <body onload='handleOnLoad();'>\n";
		markup += "        <div style='border: 1px solid black;'>\n";
		markup += "            <div id='thePortlet'>Loading...</div>\n";
		markup += "        </div>\n";
		markup += "    </body>\n";
		markup += "</html>\n";
						
		if (textarea) {
			textarea.value = markup;
		}
	}
