home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet Web Designer 86 / PIWD86.iso / pc / contents / dreamweaver / software / dwmx2004.exe / Disk1 / data1.cab / Configuration_En / Commands / ExtractTemplateXML.js < prev    next >
Encoding:
JavaScript  |  2003-09-05  |  3.9 KB  |  133 lines

  1. //  Copyright 2001, 2002, 2003 Macromedia, Inc. All rights reserved.
  2. //This is the code for the "Editable Tag Attributes" dialog
  3. // ******************* GLOBALS **********************
  4.  
  5. var helpDoc = MM.HELP_extractTemplateXML;
  6. var curSiteRootFolder = ""; 
  7.  
  8. //******************* API **********************
  9. function commandButtons()
  10.     {
  11.       return new Array(
  12.                       MM.BTN_OK,"okClicked()",
  13.                       MM.BTN_Cancel,"window.close()",
  14.                       MM.BTN_Help,"displayHelp()");
  15.     }
  16.  
  17. function isDOMRequired() {
  18.     return false;
  19. }
  20.     
  21. function canAcceptCommand()
  22.     {            
  23.     return (dw.getDocumentDOM() != null && dw.getFocus() != 'browser' && dw.getDocumentDOM().getParseMode() == 'html');
  24.     } //canAcceptCommand
  25.     
  26. function receiveArguments()
  27.     {    
  28.     curSiteRootFolder = "";
  29.     } //receiveArguments
  30.     
  31.     
  32. //When the OK button is clicked, look for attributes we've touched and update them.     
  33. function okClicked()
  34.     {
  35.     var pathToExportTo = findObject("destinationFolder").value; 
  36.     
  37.     if (pathToExportTo == "")
  38.         {
  39.         alert(MSG_No_Dir); 
  40.         return;         
  41.         }
  42.         
  43.     //display message if the path doesn't exist. 
  44.     if (!DWfile.exists(pathToExportTo))
  45.         {
  46.         alert(MSG_Does_Not_exist); 
  47.         return;        
  48.         }
  49.         
  50.     //display message if it's the same as the site folder. 
  51.     if (pathToExportTo == curSiteRootFolder)
  52.         {
  53.         alert(MSG_sameAsRoot); 
  54.         return;         
  55.         }
  56.     
  57.     //Also display message if the new folder is inside the site root folder. 
  58.     if (pathToExportTo.indexOf(curSiteRootFolder) != -1)
  59.         {
  60.         alert(MSG_insideRoot); 
  61.         return;         
  62.         }
  63.         
  64.     var wantXMLFiles = findObject("wantXMLFiles").checked;
  65.     var changedFilesOnly = findObject("changedFilesOnly").checked;
  66.     
  67.     //Save the preferences. 
  68.     var notesFile = MMNotes.open(curSiteRootFolder, true);     
  69.     if (notesFile)
  70.         {
  71.         MMNotes.set(notesFile, "exportXMLFolder", findObject("destinationFolder").value); 
  72.         MMNotes.set(notesFile, "wantXMLFiles", wantXMLFiles ? "TRUE" : "FALSE"); 
  73.         MMNotes.set(notesFile, "changedFilesOnly", changedFilesOnly ? "TRUE" : "FALSE"); 
  74.         }
  75.     MMNotes.close(notesFile);    
  76.     
  77.         //Call the native
  78.     dw.extractTemplateXML(site.getCurrentSite(), pathToExportTo, wantXMLFiles, changedFilesOnly);
  79.     //close the window
  80.     window.close(); 
  81.     } //okClicked
  82.  
  83.     
  84. //***************** LOCAL FUNCTIONS  ******************
  85.     
  86. //Init the UI - load the layer objects, build the popups and move the values of the current attribute into the controls. 
  87. function initializeUI()
  88.     {        
  89.     //look for a prefs string for this site and pre-load it. Pre-set the checkboxes. 
  90.     curSiteRootFolder = site.getLocalRootURL(site.getCurrentSite()); 
  91.     
  92.     if (curSiteRootFolder == null || curSiteRootFolder == "")
  93.         {
  94.         alert(MSG_NoSiteSelected); 
  95.         window.close();
  96.         return;         
  97.         }
  98.     
  99.     var wantXMLFiles = true; 
  100.     var changedFilesOnly = true; 
  101.     var exportXMLFolder = ""; 
  102.         
  103.     var notesFile = MMNotes.open(curSiteRootFolder, true); 
  104.     if (notesFile)
  105.         {
  106.         var temp = MMNotes.get(notesFile, "exportXMLFolder"); 
  107.         
  108.         if (temp != null && temp != "")
  109.             exportXMLFolder = temp; 
  110.             
  111.         wantXMLFiles = (MMNotes.get(notesFile, "wantXMLFiles") != "FALSE"); 
  112.         changedFilesOnly = (MMNotes.get(notesFile, "changedFilesOnly") != "FALSE"); 
  113.         }
  114.     MMNotes.close(notesFile);    
  115.     
  116.     findObject("destinationFolder").value = exportXMLFolder; 
  117.     
  118.     var xmlBox = findObject("wantXMLFiles");
  119.     xmlBox.checked = wantXMLFiles; 
  120.     
  121.     var changedBox = findObject("changedFilesOnly");
  122.     changedBox.checked = changedFilesOnly; 
  123.     } //initializeUI
  124.  
  125. //Browse for the folder to extract to, set the text field accordingly. 
  126. function browseForFolder()
  127.     {
  128.     var newDirectory = dreamweaver.browseForFolderURL(MSG_PickFolder, findObject("destinationFolder").value);
  129.     if (newDirectory.length > 0 && newDirectory.charAt(newDirectory.length-1) != '/')
  130.         newDirectory += '/';
  131.     if (newDirectory != null && newDirectory != "") 
  132.         findObject("destinationFolder").value = newDirectory; 
  133.     } //browseForFolder