﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
	<xsl:import href="ResourcesSearchDashboard.xslt"/>
	<xsl:output method="xml" indent="yes"/>

	<xsl:template match="/">
		<xsl:variable name="AjaxRequest" select="AjaxRequest"></xsl:variable>
		<xsl:variable name="PortalItemID" select="normalize-space(AjaxRequest/Params/ItemID)"></xsl:variable>
		<xsl:variable name="SubPortalItemID" select="normalize-space(AjaxRequest/Params/SubPortalItemID)"></xsl:variable>
		<xsl:variable name="FolderItemID" select="$AjaxRequest/Params/FolderItemID"></xsl:variable>
		<xsl:variable name="FolderItem" select="$AjaxRequest/Params/FolderItem"></xsl:variable>
		<xsl:variable name="TemplateURL" select="normalize-space($AjaxRequest/TemplateURL)" />
		<xsl:variable name="HostName" select="$AjaxRequest/HostName"></xsl:variable>
		<xsl:variable name="FileCabinet" select="$AjaxRequest/FileCabinet/."></xsl:variable>
		<xsl:variable name="OnlyFileListing" select="$AjaxRequest/Params/OnlyFileListing"></xsl:variable>
		<xsl:variable name="FolderList" select="$AjaxRequest/Folders"></xsl:variable>

		<div>
			<div class="col-md-12 outr padg-left">
				<div class="col-md-4 col-sm-4 left_panel padg5" id="div_MediaList_TreeContainer">
					<!--<xsl:for-each select="$FolderList/Folder[ParentItemID = $PortalItemID]">
						<xsl:call-template name="FolderItem">
							<xsl:with-param name="FolderList" select="$FolderList"></xsl:with-param>
							<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
							<xsl:with-param name="FolderItemID" select="ItemID"></xsl:with-param>
							<xsl:with-param name="FolderItem" select="Item"></xsl:with-param>
							<xsl:with-param name="FolderRootItem" select="RootItemID"></xsl:with-param>
							<xsl:with-param name="position" select="position()"></xsl:with-param>
							<xsl:with-param name="TemplateURL" select="$TemplateURL"></xsl:with-param>
						</xsl:call-template>
					</xsl:for-each>-->
					<span class="folder glyphicon glyphicon-folder-open glypcolor1"></span>
					<a href="javascript:void(0);"
						   onClick="ClientPortal_LoadFileCabinetFiles_3_0( {$PortalItemID}, 'div_MediaList_{$PortalItemID}_FileContainer'
							   ,{$PortalItemID},{$SubPortalItemID});">
						Home
					</a>
					<a href="javascript:void(0);" onclick="loadResourcesSearchRightPanel('{$PortalItemID}')" style="float:right">
						<span class="glyphicon glyphicon-search glypcolor" ></span>
					</a>
					<ul id="tree1" class="Mrgn15">

						<xsl:call-template name="ListFolder">
							<xsl:with-param name="FolderList" select="$FolderList"></xsl:with-param>
							<xsl:with-param name="FolderItemID" select="$PortalItemID"></xsl:with-param>
							<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
							<xsl:with-param name="SubPortalItemID" select="$SubPortalItemID"></xsl:with-param>
						</xsl:call-template>
					</ul>
				</div>
				<div class="col-md-8 col-sm-8 center_panel">
					<div class="center_list" id="div_MediaList_{$PortalItemID}_FileContainer">
						<xsl:variable name="CommunityAdmin" select="count($AjaxRequest/UserRoles/Role[RoleName = 'Community Admin'])"></xsl:variable>

						<script>
							ClientPortal_LoadFileCabinetFiles_3_0('<xsl:value-of select="$PortalItemID"></xsl:value-of>', 'div_MediaList_<xsl:value-of select="$PortalItemID"></xsl:value-of>_FileContainer',<xsl:value-of select="$PortalItemID"></xsl:value-of>,<xsl:value-of select="$SubPortalItemID"></xsl:value-of>);
						</script>
						<!--<xsl:call-template name="ResourcesSearchdashboard">
							<xsl:with-param name="Resources" select="$AjaxRequest/Resources/."></xsl:with-param>
							<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
							<xsl:with-param name="Type" select="$AjaxRequest/ContentType"></xsl:with-param>
							<xsl:with-param name="Format" select="$AjaxRequest/ContentFormat"></xsl:with-param>
							<xsl:with-param name="Sync" select="$AjaxRequest/Sync/."></xsl:with-param>
							<xsl:with-param name="CommunityAdmin" select="$CommunityAdmin"></xsl:with-param>
						</xsl:call-template>-->
						<!--<ul>
							<li>
								<span class="folder glyphicon glyphicon-folder-open glypcolor1"></span>
								<span>Home</span>
							</li>
							<li>
								<hr/>
							</li>
							<xsl:for-each select="$FolderList/Folder[ParentItemID = $PortalItemID]">
								<li >
									<div class="btn-group" style="padding:0;">

									<button  type="button" class="multiselect dropdown-toggle btn padinone" data-toggle="dropdown" title="" aria-expanded="false" style="width: auto;padding:0px;">
										<span class="onMouseOver star-default glyphicon glyphicon-star star_{Priority}" id="span_Priority_{normalize-space(ItemID)}">
										</span>
									</button>


									<ul style="padding:0;width:70px;right:0!important;left:inherit;" class=" dropdown-menu Priority" id="ddl_Priority_{normalize-space(ItemID)}" previousValue="{Priority}">
										<xsl:choose>
											<xsl:when test="Priority=1">
												<li class="active" >
													<a href="javascript:void(0);" onclick="UpdateItemPriority_3_0('{normalize-space(ItemID)}','1');">
														<label class="radio" style="padding-left: 0px;">
															<span class="glyphicon glyphicon-star star_1" ></span>
														</label>
													</a>
												</li>
												<li >
													<a href="javascript:void(0);" onclick="UpdateItemPriority_3_0('{normalize-space(ItemID)}','3');">
														<label class="radio" style="padding-left: 0px;">
															<span class="glyphicon glyphicon-star star_3" ></span>
														</label>
													</a>
												</li>
											</xsl:when>
											<xsl:otherwise>
												<li >
													<a href="javascript:void(0);" onclick="UpdateItemPriority_3_0('{normalize-space(ItemID)}','1');">
														<label class="radio" style="padding-left: 0px;">
															<span class="glyphicon glyphicon-star star_1" ></span>
														</label>
													</a>
												</li>
												<li class="active" >
													<a href="javascript:void(0);" onclick="UpdateItemPriority_3_0('{normalize-space(ItemID)}','3');">
														<label class="radio" style="padding-left: 0px;">
															<span class="glyphicon glyphicon-star star_3" ></span>
														</label>
													</a>
												</li>
											</xsl:otherwise>
										</xsl:choose>
									</ul>

								</div>
									<a href="javascript:void(0);"
									   onClick="ClientPortal_LoadFileCabinetFiles_3_0( {$PortalItemID}, 'div_MediaList_{$PortalItemID}_FileContainer',{ItemID});ExpandFolder('{ItemID}');">
										<span class="folder glyphicon glyphicon-folder-open glypcolor1"></span>
										<xsl:value-of select="Item"/>
									</a>
								</li>
							</xsl:for-each>
							<li>
								<span >
									<div class="form-group">
										<input id="txt_{$PortalItemID}_FolderName" type="text" class="form-control addsbfoldr "
											   placeholder="Add sub-folder...."
											   onkeyup="ClientPortal_CreateFolder_3_0({$PortalItemID}, 'div_MediaList_{$PortalItemID}_List_Folders', event, {$PortalItemID});"/>
									</div>
								</span>
							</li>
						</ul>-->
					</div>
				</div>
			</div>
		</div>
	</xsl:template>

	<xsl:template name="ListFolder">
		<xsl:param name="FolderList" select="'N/A'"></xsl:param>
		<xsl:param name="FolderItemID" select="'N/A'"></xsl:param>
		<xsl:param name="PortalItemID" select="'N/A'"></xsl:param>
		<xsl:param name="SubPortalItemID" select="'N/A'"></xsl:param>
		<xsl:for-each select="$FolderList/Folder[ParentItemID = $FolderItemID]">
			<xsl:variable name="currentFolderItemID" select="ItemID"></xsl:variable>
			<xsl:choose>
				<xsl:when test="count($FolderList/Folder[ParentItemID = $currentFolderItemID]) &gt; 0">
					<li id="folder_{ItemID}" ondragenter="ExpandFolder('{ItemID}');dragEnter(event); " ondragleave="dragleave(event);"  ondragstart="dragStart(event)" ondrop="drop(event)" ondragover="allowDrop(event)" ondragend="this.classList.remove('selectedrow');" draggable="true" ItemID="{ItemID}">
						<a class="dotclass" href="javascript:void(0);" draggable="false" id="Tfolder_{ItemID}"
						   onClick="ClientPortal_LoadFileCabinetFiles_3_0({$PortalItemID}
						   , 'div_MediaList_{$PortalItemID}_FileContainer'
						   , {ItemID},{$SubPortalItemID});" ItemID="{ItemID}"  ondragenter="dragEnter(event);" ondragleave="dragleave(event);">
							<xsl:value-of select="Item"/>
						</a>
						<ul ondrop="drop(event)"  ondragstart="dragStart(event)" ondragover="allowDrop(event)" draggable="true" ItemID="{ItemID}">
							<xsl:call-template name="ListFolder">
								<xsl:with-param name="FolderList" select="$FolderList"></xsl:with-param>
								<xsl:with-param name="FolderItemID" select="ItemID"></xsl:with-param>
								<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
								<xsl:with-param name="SubPortalItemID" select="$SubPortalItemID"></xsl:with-param>
							</xsl:call-template>
						</ul>
					</li>
				</xsl:when>
				<xsl:otherwise>
					<li id="folder_{ItemID}" ondragenter="dragEnter(event)" ondragleave="dragleave(event);" ondragend="this.classList.remove('selectedrow');" ondragstart="dragStart(event)" ondrop="drop(event)" ondragover="allowDrop(event)" draggable="true" ItemID="{ItemID}">
						<a href="javascript:void(0);" class="dotclass" draggable="false" id="Tfolder_{ItemID}"
						   onClick="ClientPortal_LoadFileCabinetFiles_3_0({$PortalItemID}
						   , 'div_MediaList_{$PortalItemID}_FileContainer'
						   , {ItemID},{$SubPortalItemID});" ItemID="{ItemID}"  ondragenter="dragEnter(event);" ondragleave="dragleave(event);">
							<xsl:value-of select="Item"/>
						</a>
					</li>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:for-each>
	</xsl:template>

	<xsl:template name="ListFolder_backup">
		<xsl:param name="FolderList" select="'N/A'"></xsl:param>
		<xsl:param name="FolderItemID" select="'N/A'"></xsl:param>

		<xsl:for-each select="$FolderList/Folder[ParentItemID = $FolderItemID]">
			<xsl:variable name="currentFolderItemID" select="ItemID"></xsl:variable>
			<xsl:choose>
				<xsl:when test="count($FolderList/Folder[ParentItemID = $currentFolderItemID]) &gt; 0">
					<div>
						<xsl:value-of select="Item"/>
						(<xsl:value-of select="$currentFolderItemID"/>)
						(<xsl:value-of select="count($FolderList/Folder[ParentItemID = $currentFolderItemID])"/>)
					</div>
					<xsl:call-template name="ListFolder">
						<xsl:with-param name="FolderList" select="$FolderList">
						</xsl:with-param>
						<xsl:with-param name="FolderItemID" select="ItemID"></xsl:with-param>
					</xsl:call-template>
				</xsl:when>
				<xsl:otherwise>
					<div>
						<xsl:value-of select="Item"/>
						(<xsl:value-of select="$currentFolderItemID"/>)
						(<xsl:value-of select="count($FolderList/Folder[ParentItemID = $currentFolderItemID])"/>)
					</div>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:for-each>
	</xsl:template>

	<xsl:template name="FolderItem">
		<xsl:param name="position" select="'N/A'"></xsl:param>
		<xsl:param name="PortalItemID" select="'N/A'"></xsl:param>
		<xsl:param name="FolderItemID" select="'N/A'"></xsl:param>
		<xsl:param name="FolderList" select="'N/A'"></xsl:param>
		<xsl:param name="FolderItem" select="'N/A'"></xsl:param>
		<xsl:param name="FolderRootItem" select="'N/A'"></xsl:param>
		<xsl:param name="TemplateURL" select="'N/A'"></xsl:param>
		<!--<xsl:choose>
			<xsl:when test="$FolderRootItem=$FolderItemID">-->
		<ul id="tree1">
			<li>
				<a href="javascript:void(0);"
				   onClick="ClientPortal_LoadFileCabinetFiles_3_0({$PortalItemID}, 'div_MediaList_{$PortalItemID}_FileContainer', {$FolderItemID});">
					<xsl:value-of select="$FolderItem"/>
				</a>
				<!--<ul>
					<xsl:for-each select="$FolderList/Folder">
						<xsl:choose>
							<xsl:when test="$FolderRootItem=RootItemID and position()>$position">

								<xsl:variable name="innerItem" select="ItemID"></xsl:variable>
								<xsl:variable name="Innerposition" select="position()"></xsl:variable>
								<li>
									<a href="javascript:void(0);" onClick="ClientPortal_LoadFileCabinetFiles_3_0({$PortalItemID}
											   , 'div_MediaList_{$PortalItemID}_FileContainer', {ItemID});">
										<xsl:value-of select="Item"/>
									</a>
									<ul>
										<xsl:for-each select="$FolderList/Folder">
											<xsl:choose>
												<xsl:when test="$FolderRootItem=RootItemID and position()>$Innerposition and $innerItem=ParentItemID">
													<li>
														<a href="javascript:void(0);" onClick="ClientPortal_LoadFileCabinetFiles_3_0({$PortalItemID}
																   , 'div_MediaList_{$PortalItemID}_FileContainer', {ItemID});">
															<xsl:value-of select="Item"/>
														</a>
													</li>
												</xsl:when>
											</xsl:choose>
										</xsl:for-each>
									</ul>
								</li>
							</xsl:when>
						</xsl:choose>
					</xsl:for-each>
				</ul>-->
			</li>
		</ul>
		<!--</xsl:when>
			<xsl:otherwise>
			</xsl:otherwise>
		</xsl:choose>-->
	</xsl:template>


	<xsl:template name="FolderTreePanel">
		<xsl:param name="AjaxRequest" select="'N/A'"></xsl:param>
		<xsl:variable name="PortalItemID" select="normalize-space($AjaxRequest/Params/ItemID)"></xsl:variable>
		<xsl:variable name="SubPortalItemID" select="normalize-space($AjaxRequest/Params/SubPortalItemID)"></xsl:variable>
		<xsl:variable name="FolderItemID" select="$AjaxRequest/Params/FolderItemID"></xsl:variable>
		<xsl:variable name="FolderItem" select="$AjaxRequest/Params/FolderItem"></xsl:variable>
		<xsl:variable name="TemplateURL" select="normalize-space($AjaxRequest/TemplateURL)" />
		<xsl:variable name="HostName" select="$AjaxRequest/HostName"></xsl:variable>
		<xsl:variable name="FileCabinet" select="$AjaxRequest/FileCabinet/."></xsl:variable>
		<xsl:variable name="OnlyFileListing" select="$AjaxRequest/Params/OnlyFileListing"></xsl:variable>
		<xsl:variable name="FolderList" select="$AjaxRequest/Folders"></xsl:variable>
		<span class="folder glyphicon glyphicon-folder-open glypcolor1"></span>
		<a href="javascript:void(0);"
			   onClick="ClientPortal_LoadFileCabinetFiles_3_0( {$PortalItemID}, 'div_MediaList_{$PortalItemID}_FileContainer'
							   ,{$PortalItemID},{$SubPortalItemID});">
			Home
		</a>
		<a href="javascript:void(0);" onclick="loadResourcesSearchRightPanel('{$PortalItemID}')" style="float:right">
			<span class="glyphicon glyphicon-search glypcolor" ></span>
		</a>
		<ul id="tree1" class="Mrgn15">

			<xsl:call-template name="ListFolder">
				<xsl:with-param name="FolderList" select="$FolderList"></xsl:with-param>
				<xsl:with-param name="FolderItemID" select="$PortalItemID"></xsl:with-param>
				<xsl:with-param name="PortalItemID" select="$PortalItemID"></xsl:with-param>
				<xsl:with-param name="SubPortalItemID" select="$SubPortalItemID"></xsl:with-param>
			</xsl:call-template>
		</ul>
	</xsl:template>
</xsl:stylesheet>
