<% set defau to \\newserver\pos\portal\news\ if not used('Tree') use tree in 0 endif
%> <html> <head> <SCRIPT LANGUAGE="JavaScript"> <!--
function OpenURL(winName, newURL) { window.name = "Email" win = window.open("", winName,"height=120,width=300,status=yes,toolbar=no,menubar=no,location=no"); win.location.href = newURL; //win.moveTo(screen.availWidth/2-(300/2),screen.availHeight/2-(120/2)); // document.Email.Receipient.value = newURL; }
function submitconfirm() { document.confirm.submit(); }
// --> </SCRIPT> <head> <style type="text/css"> <!-- <%=FILETOSTR('\\toyzportal\programs\wt\Portal.css')%> --> </style> </head> </head> <% cBranch = request.item("Branch") cAction = request.item('Action') cNodeId = request.item('NodeID') if not empty(cAction) do case case cAction ='Remove' %> <form name='confirm' method='post' action="tree.fwx?action=Delete&NodeID=<%=alltrim(cNodeId)%>&Branch=<%=alltrim(cBranch)%>"> <br>Are you sure you want to delete<br> <input type="submit" name="Confirm" value="Cancel" class="nicebutton"> <input type="submit" name="Confirm" value="Delete" class="nicebutton"> </form> <% case cAction = 'Delete' and Request.Form("Confirm") = "Delete" Sele Tree Set order to Node_ID if seek(cNodeId) Delete endif endcase endif cPath = getPath(cBranch) nLevel = 0 %> <a href="tree.fwx">Collapse</a><br><br> <Table border='0'> <% DisplayTree(cBranch) %> </table> </html>
<% function displayTree(cBranch)
SELECT * from tree WHERE parent_id = '0' order by Rank INTO CURSOR topLevel SELECT topLevel if not empty(cBranch) RootParent = GetRootParent(cBranch) && Manually branching @ 6 endif
SCAN xKey = Node_ID xText = alltrim(NodeDesc) xParent = Parent_ID xLinktype = Linktype xNodeAction = [<a href="tree.fwx?Branch=]+alltrim(xKey)+[">] do case case upper(xLinktype) = 'FOLDER' imgIcon = "/images/folder_ico.gif" Case upper(xLinktype) = 'FILE' imgIcon = "/images/attach.gif" xNodeAction = [<a href="Downloadfile.fwx?cfile=]+alltrim(NodeAction)+[">] otherwise imgIcon = "/images/link_ico.gif" xNodeAction = [<a target="_blank" href="]+alltrim(NodeAction)+[">] endcase
%> <tr> <td><a href="tree.fwx?Action=Remove&NodeID=<%=alltrim(xKey)%>&Branch=<%=alltrim(cBranch)%>"><img src="/images/deletemail.gif" border='0'></td> <td><img src="/images/edit.ico"></td> <td> <% if not empty(cBranch) && we need to branch out if xKey = RootParent do case case xLinktype = 'FOLDER' imgIcon = "/images/OpenFolder.gif" endcase endif endif %> <img src="<%=imgIcon%>"><%=xNodeAction%><%=xText%></a> </td> </tr> <% if not empty(cBranch) && we need to branch out if xKey = RootParent DisplayChildren(xKey,nLevel) endif endif ENDSCAN endfunc
FUNCTION GetRootParent(cKey) LOCAL cSel cSel = SELECT() SELECT Tree SET ORDER TO Node_ID SEEK cKey IF EOF() SELECT(cSel) RETURN '0' ENDIF xParent = Parent_ID IF xParent <> '0' GetRootParent(xParent) && keep going till we get to the root ELSE xParent = Node_ID && Reached 0 which is top level ENDIF SELECT(cSel) RETURN (xParent)
Function DisplayChildren(uid,nLevel) local xKey,xText,xParent,cCursor nlevel = nlevel + 1 cCursor = sys(2015) SELECT Node_ID, NodeDesc, Parent_ID,Linktype,NodeAction FROM Tree; WHERE Parent_ID = uid ORDER BY RANK Into Cursor &cCursor Sele &cCursor Scan xKey = Node_ID xText = alltrim(NodeDesc) xParent = Parent_ID xLinktype = Linktype xNodeAction = [<a href="tree.fwx?Branch=]+alltrim(xKey)+[">] do case case upper(xLinktype) = 'FOLDER' imgIcon = "/images/folder_ico.gif" Case upper(xLinktype) = 'FILE' imgIcon = "/images/attach.gif" xNodeAction = [<a href="Downloadfile.fwx?cfile=]+alltrim(NodeAction)+[">] otherwise imgIcon = "/images/link_ico.gif" xNodeAction = [<a target="_blank" href="]+alltrim(NodeAction)+[">] endcase %> <tr> <table border='0'> <tr> <% if Inlist(alltrim(xKey),&cPath) do case case upper(xLinktype) = 'FOLDER' imgIcon = "/images/OpenFolder.gif" Case upper(xLinktype) = 'FILE' imgIcon = "/images/attach.gif" otherwise imgIcon = "/images/link_ico.gif" endcase endif %> <%Indent(nLevel)%> <td><a href="tree.fwx?Action=Remove&NodeID=<%=alltrim(xKey)%>&Branch=<%=alltrim(cBranch)%>"><img src="/images/deletemail.gif" border='0'></a></td> <td><img src="/images/edit.ico"></td> <td><img src="<%=imgIcon%>"><%=xNodeAction%><%=xText%></a></td> </tr> </table> </tr> <% onlevel = nLevel if Inlist(alltrim(xKey),&cPath) nlevel = nLevel + 1 DisplayChildren(xKey,nLevel) nLevel = nlevel -1 endif endscan if used(cCursor) use in (cCursor) endif return ENDFUNC
FUNCTION GetParent(cChild) SELECT Tree SET ORDER TO Node_ID SEEK cChild IF NOT EOF() RETURN Parent_ID ELSE RETURN "" ENDIF ************** FUNCTION GetPath(cChild) oParent = GetParent(cChild) cPathStr = [']+alltrim(cChild)+[']+','+[']+alltrim(oParent)+[']+',' DO WHILE NOT EMPTY(oParent) oParent = GetParent(oParent) cPathStr = cPathStr+[']+alltrim(oParent)+[']+',' ENDDO return substr(cPathStr,1,len(cPathStr)-4) ENDFUNC ***** function Indent(nLevel)
for x = 1 to nLevel %> <td width='5'></td> <% endfor ********** |