<%

'*****************************************************************************
' Microsoft Content Management Server
'
' File: SDReportImages.INC
'
' Purpose:
'   ASP server-side include file that contains filename constants and utility
'	functions for manipulating images for the export and import reports in the
'	Site Deployment feature.
'
' GLOBAL DEPENDENCIES:
'
'*****************************************************************************


	'*************************************************************************
	' CONSTANTS
	'*************************************************************************
	
	' subdirectory that stores the images used by the reports
	const strIMG_SUBDIRECTORY = "images/"
	
	' constants that are passed to the getFolderStateImageTag function when
	' retrieving an image to represent folder state
	const strFOLDER_OPEN = "Open"
	const strFOLDER_CLOSED = "Closed"
	

	'*************************************************************************
	' Description:
	'	Utility helper function to grab the image representing an object
	'	package
	'
	' Parameters:
	'	None
	'
	' Returns:
	'	string that is a valid IMG tag pointing to the relative image filename
	'*************************************************************************
	function getObjectPackageImageTag(varObjectType)
	
		dim strImageTag
		dim nObjectType
		dim strImageFile

		' VBScript is loose-typed: 
		' just in case somebody passed in a number as a string thinking it's numeric...
		nObjectType = CInt( varObjectType )
		
		select case nObjectType
		
			case NR_OP_OBJECT_TYPE_RESOURCE_GALLERY			strImageFile = "resourcePackage.gif"
			case NR_OP_OBJECT_TYPE_TEMPLATE_GALLERY			strImageFile = "templatePackage.gif"
			case NR_OP_OBJECT_TYPE_FOLDER					strImageFile = "pagePackage.gif"
			case NR_OP_OBJECT_TYPE_CHANNEL					strImageFile = "pagePackage.gif"
			case NR_OP_OBJECT_TYPE_USER_RIGHTS_GROUP		strImageFile = "userPackage.gif"
        	case Else										strImageFile = "Package.gif"
				
		end select  ' node type
		
		' setup the start of the IMG tag
		strImageTag = "<IMG ALIGN=""middle"" STYLE=""vertical-align: middle"" SRC=""" & _
					  strIMG_SUBDIRECTORY & strImageFile & """>"
		
		getObjectPackageImageTag = strImageTag
		
	end function  'getObjectPackageImageTag
	
	
	'*************************************************************************
	' Description:
	'	Utility helper function to grab the image representing the state of
	'	a folder in the report (open or closed). If a folder is open, the 
	'	icon is a '-' sign (it can be closed), and if the folder is closed,
	'	the icon is a '+' sign (it can be opened).
	'
	' Parameters:
	'	strFolderState [in] - Text indicating the state of the folder
	'	bDisplay [in] - the display style attribute that the tag should have
	'
	' Returns:
	'	string that is a valid IMG tag pointing to the relative image filename
	'*************************************************************************
	function getFolderStateImageTag( strFolderState, bDisplay )
	
		dim strImageTag
		
		' setup the start of the IMG tag
		strImageTag = "<IMG ID=""openCloseImage"" ALIGN=""middle"" STYLE=""vertical-align: middle" 
		
		if bDisplay = false then
			strImageTag = strImageTag & "; display: none"
		end if  'if tag displayed
			
		strImageTag = strImageTag & """ SRC=""" & strIMG_SUBDIRECTORY
		
		' determine the path to the image (the specific filename according to the type
		' that was passed in
		select case strFolderState 
			
			case strFOLDER_OPEN			strImageTag = strImageTag & "OpenFolder.gif"
			case strFOLDER_CLOSED		strImageTag = strImageTag & "ClosedFolder.gif"
			case Else					strImageTag = ""
			
		end select
	
		' finish off the image tag
		if strImageTag <> "" then
			strImageTag = strImageTag & """> "
			
		end if  'if image tag NOT blank
		
		getFolderStateImageTag = strImageTag
		
	end function  'getFolderStateImageTag
	
	
	'*************************************************************************
	' Description:
	'	Utility helper function to grab the status image tag of an object
	'
	' Parameters:
	'	strStatus [in] - Status text that filename is generated based upon
	'
	' Returns:
	'	string that is a valid IMG tag pointing to the relative image filename
	'*************************************************************************
	function getStatusImageTag( strStatus )
	
		dim strImageTag
		
		' setup the start of the IMG tag
		strImageTag = "<IMG ALIGN=""middle"" STYLE=""vertical-align: middle"" SRC=""" & strIMG_SUBDIRECTORY
		
		' determine the path to the image (the specific filename according to the type
		' that was passed in
		select case strStatus 
			
			case "Approved"				strImageTag = strImageTag & "Approved.gif"
			case "Declined"				strImageTag = strImageTag & "Declined.gif"
			case "Expired"				strImageTag = strImageTag & "Expired.gif"
			case "New"					strImageTag = strImageTag & "New.gif"
		    case "Page Deleted"			strImageTag = strImageTag & "PageDeleted.gif"
		    case "Page Expired"			strImageTag = strImageTag & "PageExpired.gif"
		    case "Published"			strImageTag = strImageTag & "Published.gif"
			case "Saved"				strImageTag = strImageTag & "Saved.gif"
			case "Waiting for approval"	strImageTag = strImageTag & "WaitingApproval.gif"
			case Else					strImageTag = ""
			
		end select
		
		' finish off the image tag
		if strImageTag <> "" then
			strImageTag = strImageTag & """> "
			
		end if  'if image tag NOT blank
		
		getStatusImageTag = strImageTag
		
	end function  'getStatusImageTag
		
	
	'*************************************************************************
	' Description:
	'	Utility helper function to generate the image tag for an object 
	'	type
	'
	' Parameters:
	'	varObjectType [in] - Object type represented as either:
	'		* a numeric value stored as type Long or String
	'		* type name string
	'
	' Returns:
	'	string that is a valid IMG tag pointing to the relative image filename
	'
	' Note:
	'	The reason this function allows different types of input is that the
	'	Export report object XML encodes the ObjectType as numeric while the
	'	Import report renders ObjectType as the name string.  It is desirable
	'	that this discrepency be eliminated however it is not currently the
	'	case.
	'
	'*************************************************************************
	function getObjectTypeImageTag( varObjectType, bDeleted )
		
		dim strImageTag
		
		' setup the start of the IMG tag
		strImageTag = "<IMG ALIGN=""middle"" STYLE=""vertical-align: middle"" SRC=""" & strIMG_SUBDIRECTORY
		
		if IsNumeric( varObjectType ) then
			dim strObjType
			strObjType = MapSDTypeToString(varObjectType)
		else
			strObjType = varObjectType
		end if

		if bDeleted = 0 then
			select case strObjType
				case strOBJECT_TYPE_RESGAL			strImageTag = strImageTag & "ResourceGallery.gif"
				case strOBJECT_TYPE_RESGALITEM		strImageTag = strImageTag & "ResourceGalleryItem.gif"
				case strOBJECT_TYPE_TEMPGAL			strImageTag = strImageTag & "TemplateGallery.gif"
				case strOBJECT_TYPE_TEMPLATE		strImageTag = strImageTag & "Template.gif"
				case strOBJECT_TYPE_FOLDER			strImageTag = strImageTag & "Folder.gif"
				case strOBJECT_TYPE_PAGE			strImageTag = strImageTag & "Page.gif"
				case strOBJECT_TYPE_CHANNEL			strImageTag = strImageTag & "iconClosedChannel.gif"
				case strOBJECT_TYPE_POSTING			strImageTag = strImageTag & "Page.gif"
				case strOBJECT_TYPE_URG				strImageTag = strImageTag & "UserRightsGroup.gif"
				case strOBJECT_TYPE_USER			strImageTag = strImageTag & "User.gif"	
				case strUNKNOWN						strImageTag = strImageTag & "Unknown.gif"	
				case Else							
					call Err.Raise( nERROR_INVALID_OBJECT_TYPE_FOR_IMAGE_TAG, "getObjectTypeImageTag", strERROR_INVALID_OBJECT_TYPE_FOR_IMAGE_TAG )
				
			end select
		else
			select case strObjType
		
				case strOBJECT_TYPE_RESGAL			strImageTag = strImageTag & "resourceGalleryDeleted.gif"
				case strOBJECT_TYPE_RESGALITEM		strImageTag = strImageTag & "resourceDeleted.gif"
				case strOBJECT_TYPE_TEMPGAL			strImageTag = strImageTag & "templateGalleryDeleted.gif"
				case strOBJECT_TYPE_TEMPLATE		strImageTag = strImageTag & "templateDeleted.gif"
				case strOBJECT_TYPE_FOLDER			strImageTag = strImageTag & "channelDeleted.gif"
				case strOBJECT_TYPE_PAGE			strImageTag = strImageTag & "PageDeleted.gif"
				case strOBJECT_TYPE_CHANNEL			strImageTag = strImageTag & "channelDeleted.gif"
				case strOBJECT_TYPE_POSTING			strImageTag = strImageTag & "PageDeleted.gif"
				case strOBJECT_TYPE_URG				strImageTag = strImageTag & "UserRightsGroup.gif"
				case strOBJECT_TYPE_USER			strImageTag = strImageTag & "User.gif"	
				case strUNKNOWN						strImageTag = strImageTag & "Unknown.gif"	
				case Else							
					call Err.Raise( nERROR_INVALID_OBJECT_TYPE_FOR_IMAGE_TAG, "getObjectTypeImageTag", strERROR_INVALID_OBJECT_TYPE_FOR_IMAGE_TAG )
			end select
	
		end if
		
		if strImageTag <> "" then
			strImageTag = strImageTag & """>"
			
		end if  'if image tag NOT blank
		
		getObjectTypeImageTag = strImageTag
		
	end function  'getObjectTypeImageTag
	
%>
