<?xml version="1.0" encoding="UTF-8" ?>

<Module>
	<ModulePrefs author="eXoPlatform"
		title="My documents"
		directory_title="My documents"
		title_url="http://www.exoplatform.org"
		description="My documents"
		thumbnail="/eXoResources/skin/sharedImages/Icon80x80/DefaultPortlet.png"
		height="227">
	</ModulePrefs>
	<Content type="html">
	<![CDATA[
	
		<script type="text/javascript" src="/eXoDMSGadgets/javascript/script.js"></script>
		
		<style type="text/css">
			body{
				font: 11px Tahoma,Verdana,Arial,Helvetica,sans-serif;
				height:100%;
				margin:0 auto;
				padding:0;
			}
			
			a {
				text-decoration: none;
			}		
			
			.GadgetBgTitleLeft{
				background:transparent url("/eXoDMSGadgets/skin/images/ImageGadGets.gif") no-repeat left -70px;
				padding-left: 4px;
			}
			
			.GadgetBgTitleCenter{
				background:transparent url("/eXoDMSGadgets/skin/images/ImageGadGets.gif") repeat-x left -92px;
				height: 22px;
			}
			
			.GadgetBgTitleRight{
				background:transparent url("/eXoDMSGadgets/skin/images/ImageGadGets.gif") no-repeat right -70px;
				padding-right:3px;
			}
			
			.TxtTitleGadget {
				font-weight: bold;
				float: left;
				line-height: 22px;
				color: #5b5b5b;
				padding-left: 8px;
			}
			
			.GadgetBgTitleCenter .IconEditGadGet{
				background:transparent url("/eXoDMSGadgets/skin/images/ImageGadGets.gif") no-repeat center -180px;
				display: block;
				height: 13px;
				width: 13px;
				padding: 6px 2px 0px 2px;
			}
			
			.GadgetBgTitleCenter .IconMinimize{
				background:transparent url("/eXoDMSGadgets/skin/images/ImageGadGets.gif") no-repeat center -202px;
				display: block;
				height: 13px;
				width: 13px;
				padding: 6px 2px 0px 2px;
			}
			
			.GadgetBgTitleCenter .IconClose{
				background:transparent url("/eXoDMSGadgets/skin/images/ImageGadGets.gif") no-repeat center -224px;
				display: block;
				height: 13px;
				width: 13px;
				padding: 6px 2px 0px 2px;
			}
			
			/**************************** Content Gadgets *********************************/
			
			.ContentGadGet{
			}
			
			.ContentGadGet .BgLeftTitleContent{
				background:transparent url("/eXoDMSGadgets/skin/images/ImageGadGets.gif") no-repeat left top;	
				padding-left: 6px;
			}
			
			.ContentGadGet .BgCentertTitleContent{
				background:transparent url("/eXoDMSGadgets/skin/images/ImageGadGets.gif") repeat-x left -35px;	
				height: 35px;
				line-height: 35px;
			}
			
			.ContentGadGet .BgRightTitleContent{
				background: url("/eXoDMSGadgets/skin/images/ImageGadGets.gif") no-repeat right top;	
				padding-right: 8px;
			}
			.ContentGadGet .IconArrow{
				background: url("/eXoDMSGadgets/skin/images/ImageGadGets.gif") no-repeat right -246px;
				float: right;
				height: 35px;
				width: 16px;
			}
			.ContentGadGet .TextTitle{
				color: #fff;
				font-weight: bold;
			}
			
			.ContentGadGet .BgLeftFooterContent{
				background: url("/eXoDMSGadgets/skin/images/ImageGadGets.gif") no-repeat left -114px;	
				padding-left: 9px;
			}
			
			.ContentGadGet .BgCenterFooterContent{
				background: url("/eXoDMSGadgets/skin/images/ImageGadGets.gif") repeat-x center -130px;
				height: 8px;
			}
			
			.ContentGadGet .BgRightFooterContent{
				background: url("/eXoDMSGadgets/skin/images/ImageGadGets.gif") no-repeat right -122px;	
				padding-right: 8px;
			}
			
			.ContentGadGet .BgCenterContent{
				background: url("/eXoDMSGadgets/skin/images/BgBottomConten.gif") repeat-x left bottom;
			}
			.ContentGadGet .BgLeftContent{
				border-left: solid 1px #9c9c9c;
			}
			
			.ContentGadGet .BgRightContent{
				background: url("/eXoDMSGadgets/skin/images/GagetBorRight.gif") repeat-y right top;
				padding-right: 3px;
			}
			
			.ContentGadGet .BgRightContent .IconDriver {
				background: url("/eXoDMSGadgets/skin/images/ImageGadGets.gif") no-repeat left -281px;
			
			}
			
			.ContentGadGet .BgRightContent .IconPdf {
				background: url("/eXoDMSGadgets/skin/images/ImageGadGets.gif") no-repeat left -352px;
			}
			
			.ContentGadGet .BgRightContent .IconDoc {
				background: url("/eXoDMSGadgets/skin/images/ImageGadGets.gif") no-repeat left -396px;
			}
			
			.ContentGadGet .BgRightContent .IconJpg {
				background: url("/eXoDMSGadgets/skin/images/ImageGadGets.gif") no-repeat left -440px;
			}
			
			.ContentGadGet .BgRightContent .IconNote {
				background:transparent url("/eXoDMSGadgets/skin/images/ImageGadGets.gif") no-repeat left -308px;
			}
			
			.ContentGadGet .BgRightContent .BgTitle{
				background: #dfeefa;
				width: auto;
				line-height: 16px;
				font-weight: bold;
				color: #468bcc;
			}
			
			.ContentGadGet .BgRightContent .ItemIcon {
				border-bottom:1px solid #CCCCCC;
				line-height: 16px;
				margin: 0px 5px 0px 11px;
				padding: 0px 0 0px 22px;
				width: auto;
			}
			
			.ContentGadGet .BgRightContent .NotAvailableItemIcon {
				margin: 0px 5px 0px 11px;
				padding:5px;
				text-align: center;
				font-style: italic;
				color: #EF5604;
				width: auto;
				font-weight:normal;
				height:30px;
			}
			
			
			.ContentGadGet .BgRightContent .TextDateTime{
				color: #83add4;
				float: left;
				padding-left: 26px;
			}
			
			.ContentGadGet .BgRightContent  .DateTime{
				color: #83add4;
				font-weight: nomarl;
			}
			
			.ContentGadGet .BgRightContent a{
				color: #000;
				display: block;
			}
			
			.ContentGadGet .BgRightContent a:hover{
				color: orange;
			}
	  </style>
  <script type="text/javascript">
			function PublishedDocument() {}
			var prefixUrl = location.protocol + '//' + location.hostname;
			if (location.port) {
				prefixUrl += ':' + location.port;
			}

			var siteUrl = prefixUrl + '/ecmdemo/rest-ecmdemo/publication/presentation/repository/collaboration/state?showItems=5';
			var accessUrl = prefixUrl + '/ecmdemo/private/classic/siteExplorer/repository/';
			
			/**
				* Time to refresh data in client and gadget server
				*/
			var refreshInterval = 60000;
			
			PublishedDocument.prototype.makeRequest = function(url, callback) {
				var params = {};
				params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.GET;
				params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.JSON;
				var ts = new Date().getTime();
			  var sep = "?";
			  if (refreshInterval && refreshInterval > 0) {
			    ts = Math.floor(ts / refreshInterval);
			  }
			  if (url.indexOf("?") > -1) {
			    sep = "&";
			  }
			 url = [ url, sep, "nocache=", ts ].join("");
				gadgets.io.makeRequest(url, callback, params);
			}
			
			PublishedDocument.prototype.init = function() {
				publishedDocument.makeRequest(siteUrl,publishedDocument.displayValue)
			}
			
			PublishedDocument.prototype.displayValue = function(resp) {
				var data = resp.data.publishedListNode;
				var publishedDocList = _gel("PublishedDocumentList");
				if (publishedDocList) {
					 while (publishedDocList.hasChildNodes()) {
					  	publishedDocList.removeChild(publishedDocList.lastChild);
					  }
				}
				var displayTime = new DisplayTime();
				for (var i = 0; i < data.length; i++) {
					var doc = data[i];
					var AppClass = document.createElement('div');
					var showHTML = "<a target='_top' ";
					if (accessUrl.length > 0 && doc.driveName.length > 0 && doc.path.length > 0) {
						showHTML += "href='";	
						showHTML += accessUrl;
						showHTML += doc.driveName;
						showHTML += doc.path;
						showHTML += "'";
					}
					showHTML += ">";
					showHTML += doc.name;
					showHTML += "</a>";
					showHTML += "<span class='DateTime'>";
					showHTML += displayTime.timeToPrettyString(doc.datePublished);
					showHTML += "</span>";
					AppClass.innerHTML = showHTML;
					AppClass.className = 'ItemIcon';
					publishedDocList.appendChild(AppClass);
				}

				var title = _gel("BgTitle");
				if (data && (data.length > 0) && title) {
					publishedDocList.parentNode.removeChild(title);
				}
				gadgets.window.adjustHeight();
			}
			
			/**
		 	*  Set refresh automatically in refreshInterval seconds
		 	*/
			PublishedDocument.prototype.autoRefresh = function() {
				window.setInterval("publishedDocument.init();", refreshInterval);
			}
			
			var publishedDocument = new PublishedDocument();
	  gadgets.util.registerOnLoadHandler(publishedDocument.init);
	  gadgets.util.registerOnLoadHandler(publishedDocument.autoRefresh);
	  
		</script>

		<body>
				
			<div class="ContentGadGet">
				<div class="BgLeftTitleContent">
					<div class="BgRightTitleContent">
						<div class="BgCentertTitleContent">
							<div class="IconArrow"><span></span></div>
							<div class="TextTitle">Recently Published Documents</div>
							<div class="ClearRight"><span></span></div>
						</div>
					</div>
				</div>
				<div class="BgRightContent">
					<div class="BgLeftContent">
						<div class="BgCenterContent">
						<div id="BgTitle" class="BgTitle">
							<div class="NotAvailableItemIcon">
									Not available document!
							</div>
						</div>
						<div id="PublishedDocumentList" class="PublishedDocumentList">
						</div>
					</div>
					</div>
				</div>
				<div class="BgLeftFooterContent">
					<div class="BgRightFooterContent">
						<div class="BgCenterFooterContent"><span></span></div>
					</div>
				</div>
			</div>
		</body>
	]]>
	</Content>
</Module>
