コード例 #1
0
 /**
  * Recursive method to find all of the javascript strings (item info) and populate the sequencer
  *
  * @param javascriptStrings
  * @param element
  * @param menuParent
  * @param useRelativePaths
  */
 protected void createNavLinks(
     Vector javascriptStrings, Element element, String menuParent, boolean useRelativePaths) {
   String name = element.getName();
   // ORGANIZATION
   if (name.equals(CP_Core.ORGANIZATION) && _navViewer.isDocumentNamespace(element)) {
     ++_orgCount;
     String orgId = element.getAttributeValue(CP_Core.IDENTIFIER);
     menuParent = "menu";
     String title = "Organization";
     // Display Title if there is one
     Element titleElement = element.getChild(CP_Core.TITLE, element.getNamespace());
     if (titleElement != null) {
       if (!titleElement.getText().equals("")) title = titleElement.getText();
     }
     // find out if this the default organization...
     String _defaultOrganization = _defaultorg.getAttributeValue(CP_Core.IDENTIFIER);
     if (_defaultOrganization != null) {
       if (_defaultOrganization.equals(orgId)) {
         writePackageSettings(javascriptStrings, "_defaultOrg", _orgCount);
       }
     }
     writeOrganization(javascriptStrings, title, orgId);
   }
   // ITEM
   else if (name.equals(CP_Core.ITEM) && _navViewer.isDocumentNamespace(element)) {
     ++_itemCount;
     String itemId = element.getAttributeValue(CP_Core.IDENTIFIER);
     String hyperLink = "";
     String url = "";
     String scoType = "";
     // Display Title if there is one
     String title = "Item";
     Element titleElement = element.getChild(CP_Core.TITLE, element.getNamespace());
     if (titleElement != null) {
       if (!titleElement.getText().equals("")) title = titleElement.getText();
     }
     // check to see that the isvisible attribute is not set to false...
     String isVisibleAttrib = element.getAttributeValue(CP_Core.ISVISIBLE);
     if (isVisibleAttrib != null) {
       if (isVisibleAttrib.equals("false")) {
         title = "* hidden";
       }
     }
     // What does this Item reference?
     Element ref_element = _navViewer.getScormCore().getReferencedElement(element);
     String prerequisites = "";
     if (ref_element != null) {
       String ref_name = ref_element.getName();
       // A RESOURCE
       if (ref_name.equals(CP_Core.RESOURCE)) {
         scoType = _navViewer.findScoType(element);
         // Relative path for export - Note the "../" is relative to where the
         // Nav file is!
         if (useRelativePaths) {
           url = _navViewer.getScormCore().getRelativeURL(element);
           // Only if local path add relative bit
           if (isExternalURL(url) == false) {
             url = "../" + url;
           }
         }
         // Absolute Paths for Previewing in-situ
         else {
           String turl = _navViewer.getLaunch(element);
           url = turl;
         }
         if (url != null) {
           hyperLink = url;
           if (!title.equals("* hidden")) {
             prerequisites = _navViewer.getPrerequisites(element);
             if (prerequisites == null) {
               prerequisites = "";
             }
           }
         }
       }
       // A sub-MANIFEST
       else if (ref_name.equals(CP_Core.MANIFEST)) {
         hyperLink = "javascript:void(0)";
         // Get ORGANIZATIONS Element
         Element orgsElement =
             ref_element.getChild(CP_Core.ORGANIZATIONS, ref_element.getNamespace());
         // Now we have to get the default ORGANIZATION
         if (orgsElement != null)
           ref_element = _navViewer.getScormCore().getDefaultOrganization(orgsElement);
         // Get the children of the referenced <organization> element and graft
         // clones
         if (ref_element != null) {
           Iterator it = ref_element.getChildren().iterator();
           while (it.hasNext()) {
             Element ref_child = (Element) it.next();
             element.addContent((Element) ref_child.clone());
           }
         }
       }
     } else {
       hyperLink = "javascript:void(0)";
     }
     // System.out.println("adding to sequencer:"+ itemId + " " + hyperLink+ "
     // " + _itemCount+ " " + scoType+ " " +title+ " " + prerequisites);
     _sequence.addNewItem(itemId, hyperLink, _itemCount, scoType, title, prerequisites);
     writeItem(javascriptStrings, title, hyperLink, itemId, menuParent);
     menuParent = itemId;
   }
   // round we go again...
   Iterator it = element.getChildren().iterator();
   while (it.hasNext()) {
     Element child = (Element) it.next();
     createNavLinks(javascriptStrings, child, menuParent, useRelativePaths);
   }
 }