Пример #1
0
/**
 * Collection of constants stored in DB, and referenced in data layer (only?). They cannot be
 * changed without migrating the DB data. Package visibility.
 *
 * <p>Initial Date: 23.06.2011 <br>
 *
 * @author lavinia
 */
public class Constants {

  // same as BlogFileResource.TYPE_NAME - pure coincidence ?!
  static final String BLOG_ARTEFACT_NAME = "FileResource.BLOG";
  static final String WIKI_ARTEFACT_NAME = "FileResource.WIKI";
  static final String EFFICIENCY_STATEMENT_ARTEFACT_NAME = "EfficiencyStatement";
  static final String STRUCTURE_ELEMENT_ARTEFACT_NAME = "ep-structure-element";
  static final String TEXT_ARTEFACT_NAME = "text";
  static final String FILE_ARTEFACT_NAME = "bc";
  static final String FORUM_ARTEFACT_NAME = OresHelper.calculateTypeName(Forum.class);
  static final String LIVE_BLOG_ARTEFACT_NAME = "liveblog";
}
Пример #2
0
  /**
   * @param ureq
   * @param cpRoot
   * @param showMenu
   * @param activateFirstPage
   */
  CPDisplayController(
      final UserRequest ureq,
      final WindowControl wControl,
      final VFSContainer rootContainer,
      final boolean showMenu,
      final boolean activateFirstPage,
      final String initialUri,
      final OLATResourceable ores) {
    super(ureq, wControl);
    this.rootContainer = rootContainer;

    // wrapper velocity container for page content
    this.myContent = createVelocityContainer("cpDisplay");
    // the cp component, added to the velocity

    if (!ureq.getUserSession().getRoles().isGuestOnly()) {
      final SearchServiceUIFactory searchServiceUIFactory =
          (SearchServiceUIFactory) CoreSpringFactory.getBean(SearchServiceUIFactory.class);
      searchCtrl =
          searchServiceUIFactory.createInputController(ureq, wControl, DisplayOption.BUTTON, null);
      myContent.put("search_input", searchCtrl.getInitialComponent());
    }

    // TODO:gs:a
    // may add an additional config for disabling, enabling IFrame style or not in CP mode
    // but always disable IFrame display when in screenreader mode (no matter whether style gets
    // ugly)
    if (getWindowControl().getWindowBackOffice().getWindowManager().isForScreenReader()) {
      cpComponent = new HtmlStaticPageComponent("", rootContainer);
      cpComponent.addListener(this);
      myContent.put("cpContent", cpComponent);
    } else {
      cpContentCtr =
          new IFrameDisplayController(ureq, getWindowControl(), rootContainer, null, ores);
      cpContentCtr.setAllowDownload(true);
      listenTo(cpContentCtr);
      myContent.put("cpContent", cpContentCtr.getInitialComponent());
    }

    // even if we do not show the menu, we need to build parse the manifest and
    // find the first node to display at startup
    final VFSItem mani = rootContainer.resolve("imsmanifest.xml");
    if (mani == null || !(mani instanceof VFSLeaf)) {
      throw new OLATRuntimeException(
          "error.manifest.missing",
          null,
          this.getClass().getPackage().getName(),
          "CP " + rootContainer + " has no imsmanifest",
          null);
    }
    // initialize tree model in any case
    ctm = new CPManifestTreeModel((VFSLeaf) mani);

    if (showMenu) {
      // the menu is only initialized when needed.
      cpTree = new MenuTree("cpDisplayTree");
      cpTree.setTreeModel(ctm);
      cpTree.addListener(this);
    }

    LoggingResourceable nodeInfo = null;
    if (activateFirstPage) {
      // set content to first accessible child or root node if no children
      // available
      TreeNode node = ctm.getRootNode();
      if (node == null) {
        throw new OLATRuntimeException(
            CPDisplayController.class,
            "root node of content packaging was null, file:" + rootContainer,
            null);
      }
      while (node != null && !node.isAccessible()) {
        if (node.getChildCount() > 0) {
          node = (TreeNode) node.getChildAt(0);
        } else {
          node = null;
        }
      }
      if (node != null) { // node.isAccessible
        final String nodeUri = (String) node.getUserObject();
        if (cpContentCtr != null) {
          cpContentCtr.setCurrentURI(nodeUri);
        }
        if (cpComponent != null) {
          cpComponent.setCurrentURI(nodeUri);
        }
        if (showMenu) {
          cpTree.setSelectedNodeId(node.getIdent());
        }
        // activate the selected node in the menu (skips the root node that is
        // empty anyway and saves one user click)
        selNodeId = node.getIdent();

        nodeInfo = LoggingResourceable.wrapCpNode(nodeUri);
      }
    } else if (initialUri != null) {
      // set page
      if (cpContentCtr != null) {
        cpContentCtr.setCurrentURI(initialUri);
      }
      if (cpComponent != null) {
        cpComponent.setCurrentURI(initialUri);
      }
      // update menu
      final TreeNode newNode = ctm.lookupTreeNodeByHref(initialUri);
      if (newNode != null) { // user clicked on a link which is listed in the
        // toc
        if (cpTree != null) {
          cpTree.setSelectedNodeId(newNode.getIdent());
        } else {
          selNodeId = newNode.getIdent();
        }
      }
      nodeInfo = LoggingResourceable.wrapCpNode(initialUri);
    }
    // Note: the ores has a typename of ICourse - see
    // CPCourseNode.createNodeRunConstructorResult
    // which has the following line:
    // OresHelper.createOLATResourceableInstance(ICourse.class,
    // userCourseEnv.getCourseEnvironment().getCourseResourceableId());
    // therefore we use OresHelper.calculateTypeName(ICourse.class) here
    if (ores != null
        && nodeInfo != null
        && !OresHelper.calculateTypeName(ICourse.class).equals(ores.getResourceableTypeName())) {
      addLoggingResourceable(LoggingResourceable.wrap(ores, OlatResourceableType.cp));
      ThreadLocalUserActivityLogger.log(
          LearningResourceLoggingAction.LEARNING_RESOURCE_OPEN, getClass(), nodeInfo);
    }

    putInitialPanel(myContent);
  }