コード例 #1
0
  /**
   * Builds an html-info string about the current page and its linked resources
   *
   * @return HTML-String
   */
  private String getCurrentPageInfoStringHTML() {
    // test if currentPage links to resource, which is used (linked) somewhere
    // else in the manifest
    final CPManager cpMgm = CPManager.getInstance();
    final DefaultElement ele = cpMgm.getElementByIdentifier(cp, currentPage.getIdRef());
    boolean single = false;
    if (ele instanceof CPResource) {
      final CPResource res = (CPResource) ele;
      single = cpMgm.isSingleUsedResource(res, cp);
    }

    final StringBuilder b = new StringBuilder();
    b.append("<br /><ul>");
    b.append(
        "<li><b>"
            + translate("cptreecontroller.pagetitle")
            + "</b> "
            + currentPage.getTitle()
            + "</li>");
    if (single) {
      b.append(
          "<li><b>"
              + translate("cptreecontroller.file")
              + "</b> "
              + currentPage.getFileName()
              + "</li>");
    }
    b.append("</ul>");
    return b.toString();
  }
コード例 #2
0
 /**
  * Performs the node-move-actions (invokes methods of the manager...)
  *
  * @param event
  * @return returns true, if move was successfull
  */
 private boolean movePage(final MoveTreeNodeEvent event) {
   final CPManager cpMgm = CPManager.getInstance();
   final String movedNodeId = event.getNodeId();
   cpMgm.moveElement(cp, movedNodeId, event.getNewParentNodeId(), event.getPosition());
   cpMgm.writeToFile(cp);
   selectTreeNodeById(movedNodeId);
   return true;
 }
コード例 #3
0
 /**
  * copies the page with given nodeID
  *
  * @param nodeID
  */
 private String copyPage(final CPPage page) {
   String newIdentifier = null;
   if (page != null) {
     final CPManager cpMgm = CPManager.getInstance();
     newIdentifier = cpMgm.copyElement(cp, page.getIdentifier());
     cpMgm.writeToFile(cp);
   }
   return newIdentifier;
 }
コード例 #4
0
 /**
  * deletes a page from the manifest
  *
  * @param nodeID
  */
 private void deletePage(final String identifier, final boolean deleteResource) {
   if (identifier.equals("")) {
     // no page selected
   } else {
     final CPManager cpMgm = CPManager.getInstance();
     final String path = treeModel.getPath(identifier);
     treeCtr.removePath(path);
     cpMgm.removeElement(cp, identifier, deleteResource);
     cpMgm.writeToFile(cp);
   }
 }
コード例 #5
0
  /**
   * Adds a page to the CP
   *
   * @return
   */
  protected String addPage(final CPPage page) {
    final CPManager cpMgm = CPManager.getInstance();
    String newNodeID = "";

    if (currentPage.getIdentifier().equals("")) {
      newNodeID = cpMgm.addBlankPage(cp, page.getTitle());
    } else {
      // adds new page as child of currentPage
      newNodeID = cpMgm.addBlankPage(cp, page.getTitle(), currentPage.getIdentifier());
    }
    setCurrentPage(new CPPage(newNodeID, cp));

    cpMgm.writeToFile(cp);
    // treeCtr.getInitialComponent().setDirty(true);
    return newNodeID;
  }
コード例 #6
0
 /** @param page */
 protected void updatePage(final CPPage page) {
   setCurrentPage(page);
   final CPManager cpMgm = CPManager.getInstance();
   cpMgm.updatePage(cp, page);
   cpMgm.writeToFile(cp);
   if (page.isOrgaPage()) {
     // TODO:GW Shall the repo entry title be updated when the organization
     // title changes?
     // // If the organization title changed, also update the repo entry
     // // title.
     // RepositoryManager resMgr = RepositoryManager.getInstance();
     // RepositoryEntry cpEntry =
     // resMgr.lookupRepositoryEntry(cp.getResourcable(), false);
     // cpEntry.setDisplayname(page.getTitle());
     treeCtr.setRootNodeTitle(page.getTitle());
   }
   selectTreeNodeByCPPage(page);
 }
コード例 #7
0
  protected CPTreeController(
      final UserRequest ureq, final WindowControl control, final ContentPackage cp) {
    super(ureq, control);
    contentVC = createVelocityContainer("treeView");

    this.cp = cp;

    final String rootTitle = cp.getFirstOrganizationInManifest().getTitle();
    final CPManager cpMgm = CPManager.getInstance();
    treeModel = cpMgm.getTreeDataModel(cp);
    treeCtr = new TreeController(ureq, control, rootTitle, treeModel, null);
    treeCtr.setTreeInlineEditing(true, null, null);

    // do not sort jsTree (structure is given by manifest)
    treeCtr.setTreeSorting(false, false, false);
    listenTo(treeCtr);

    setLinks();
    contentVC.put("cptreecontroller.tree", treeCtr.getInitialComponent());

    putInitialPanel(contentVC);
  }
コード例 #8
0
 /**
  * Adds a new page to the CP
  *
  * @return
  */
 protected String addNewHTMLPage() {
   final String newId =
       CPManager.getInstance()
           .addBlankPage(
               cp, translate("cptreecontroller.newpage.title"), currentPage.getIdentifier());
   final CPPage newPage = new CPPage(newId, cp);
   // Create an html file
   final VFSContainer root = cp.getRootDir();
   final VFSLeaf htmlFile = root.createChildLeaf(newId + ".html");
   newPage.setFile(htmlFile);
   updatePage(newPage);
   return newId;
 }
コード例 #9
0
  /**
   * Retrieves the parent identifier of the current page
   *
   * @return The identifier of the current page's parent
   */
  private String getParentIdentifier() {
    final DefaultElement currentElem =
        CPManager.getInstance().getElementByIdentifier(cp, currentPage.getIdentifier());

    // Get the parent node to be displayed after deletion.
    String parentIdentifier = null;
    if (currentElem instanceof CPItem) {
      final Element parent = ((CPItem) currentElem).getParentElement();
      if (parent instanceof CPItem) {
        final CPItem parentItem = (CPItem) parent;
        parentIdentifier = parentItem.getIdentifier();
      } else if (parent instanceof CPOrganization) {
        final CPOrganization parentItem = (CPOrganization) parent;
        parentIdentifier = parentItem.getIdentifier();
      }
    }
    return parentIdentifier;
  }
コード例 #10
0
ファイル: CPCourseNode.java プロジェクト: nagyist/openolat
  /**
   * Update the module configuration to have all mandatory configuration flags set to usefull
   * default values
   *
   * @param isNewNode true: an initial configuration is set; false: upgrading from previous node
   *     configuration version, set default to maintain previous behaviour
   */
  @Override
  public void updateModuleConfigDefaults(boolean isNewNode) {
    int CURRENTVERSION = 7;
    ModuleConfiguration config = getModuleConfiguration();
    if (isNewNode) {
      // use defaults for new course building blocks
      config.setBooleanEntry(NodeEditController.CONFIG_STARTPAGE, Boolean.FALSE.booleanValue());
      config.setBooleanEntry(NodeEditController.CONFIG_COMPONENT_MENU, Boolean.TRUE.booleanValue());
      // how to render files (include jquery etc)
      DeliveryOptions nodeDeliveryOptions = DeliveryOptions.defaultWithGlossary();
      nodeDeliveryOptions.setInherit(Boolean.TRUE);
      config.set(CPEditController.CONFIG_DELIVERYOPTIONS, nodeDeliveryOptions);
      config.setConfigurationVersion(CURRENTVERSION);
    } else {
      config.remove(NodeEditController.CONFIG_INTEGRATION);
      if (config.getConfigurationVersion() < 2) {
        // update new configuration options using default values for existing
        // nodes
        config.setBooleanEntry(NodeEditController.CONFIG_STARTPAGE, Boolean.TRUE.booleanValue());
        Boolean componentMenu = config.getBooleanEntry(NodeEditController.CONFIG_COMPONENT_MENU);
        if (componentMenu == null) {
          config.setBooleanEntry(
              NodeEditController.CONFIG_COMPONENT_MENU, Boolean.TRUE.booleanValue());
        }
        config.setConfigurationVersion(2);
      }

      if (config.getConfigurationVersion() < 3) {
        config.set(
            NodeEditController.CONFIG_CONTENT_ENCODING,
            NodeEditController.CONFIG_CONTENT_ENCODING_AUTO);
        config.set(
            NodeEditController.CONFIG_JS_ENCODING, NodeEditController.CONFIG_JS_ENCODING_AUTO);
        config.setConfigurationVersion(3);
      }
      // Version 5 was ineffective since the delivery options were not set. We have to redo this and
      // save it as version 6
      if (config.getConfigurationVersion() < 7) {
        String contentEncoding = (String) config.get(NodeEditController.CONFIG_CONTENT_ENCODING);
        if (contentEncoding != null && contentEncoding.equals("auto")) {
          contentEncoding = null; // new style for auto
        }
        String jsEncoding = (String) config.get(NodeEditController.CONFIG_JS_ENCODING);
        if (jsEncoding != null && jsEncoding.equals("auto")) {
          jsEncoding = null; // new style for auto
        }

        CPPackageConfig reConfig = null;
        DeliveryOptions nodeDeliveryOptions =
            (DeliveryOptions) config.get(CPEditController.CONFIG_DELIVERYOPTIONS);
        if (nodeDeliveryOptions == null) {
          // Update missing delivery options now, inherit from repo by default
          nodeDeliveryOptions = DeliveryOptions.defaultWithGlossary();
          nodeDeliveryOptions.setInherit(Boolean.TRUE);

          RepositoryEntry re = getReferencedRepositoryEntry();
          // Check if delivery options are set for repo entry, if not create default
          if (re != null) {
            reConfig = CPManager.getInstance().getCPPackageConfig(re.getOlatResource());
            if (reConfig == null) {
              reConfig = new CPPackageConfig();
            }
            DeliveryOptions repoDeliveryOptions = reConfig.getDeliveryOptions();
            if (repoDeliveryOptions == null) {
              // migrate existing config back to repo entry using the default as a base
              repoDeliveryOptions = DeliveryOptions.defaultWithGlossary();
              reConfig.setDeliveryOptions(repoDeliveryOptions);
              repoDeliveryOptions.setContentEncoding(contentEncoding);
              repoDeliveryOptions.setJavascriptEncoding(jsEncoding);
              CPManager.getInstance().setCPPackageConfig(re.getOlatResource(), reConfig);
            } else {
              // see if we have any different settings than the repo. if so, don't use inherit mode
              if (contentEncoding != repoDeliveryOptions.getContentEncoding()
                  || jsEncoding != repoDeliveryOptions.getJavascriptEncoding()) {
                nodeDeliveryOptions.setInherit(Boolean.FALSE);
                nodeDeliveryOptions.setContentEncoding(contentEncoding);
                nodeDeliveryOptions.setJavascriptEncoding(jsEncoding);
              }
            }
          }
          // remove old config parameters
          config.remove(NodeEditController.CONFIG_CONTENT_ENCODING);
          config.remove(NodeEditController.CONFIG_JS_ENCODING);
          // replace with new delivery options
          config.set(CPEditController.CONFIG_DELIVERYOPTIONS, nodeDeliveryOptions);
        }
        config.setConfigurationVersion(7);
      }

      // else node is up-to-date - nothing to do
    }
    if (config.getConfigurationVersion() != CURRENTVERSION) {
      OLog logger = Tracing.createLoggerFor(CPCourseNode.class);
      logger.error(
          "CP course node version not updated to lastest version::"
              + CURRENTVERSION
              + ", was::"
              + config.getConfigurationVersion()
              + ". Check the code, programming error.");
    }
  }