Package org.olat.core.commons.fullWebApp

Source Code of org.olat.core.commons.fullWebApp.DefaultFooterController

/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS,
* <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) 2007 frentix GmbH, Switzerland<br>
* <p>
*/
package org.olat.core.commons.fullWebApp;

import org.olat.core.CoreSpringFactory;
import org.olat.core.Version;
import org.olat.core.defaults.dispatcher.ClassPathStaticDispatcher;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.Windows;
import org.olat.core.gui.components.Component;
import org.olat.core.gui.components.velocity.VelocityContainer;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.controller.BasicController;
import org.olat.core.helpers.Settings;
import org.olat.core.util.UserSession;
import org.olat.core.util.coordinate.CoordinatorManager;

/**
* <h3>Description:</h3>
* This is a simple controller that displays the brasato web app framework
* default footer.
* <p>
* Initial Date: 10.10.2007 <br>
*
* @author Florian Gnaegi, frentix GmbH, http://www.frentix.com
*/
public class DefaultFooterController extends BasicController {
  private VelocityContainer footerVC;

  /**
   * Constructor: usedd with AutoCreator
   */
  public DefaultFooterController(UserRequest ureq, WindowControl wControl) {
    super(ureq, wControl);

    // Initialize velocity container
    footerVC = createVelocityContainer("defaultfooter");

    String ressourceMapperUri = ClassPathStaticDispatcher.getInstance().getMapperBasePath(this.getClass());
    footerVC.contextPut("ressourceMapperUri", ressourceMapperUri);

    // Push brasato framework number to velocity
    Version version = (Version) CoreSpringFactory.getBean("org.olat.core.Version");
    footerVC.contextPut("appName", version.getApplicationName());
    String nodeInfo = (!CoordinatorManager.getCoordinator().isClusterMode()) ? "" : (", N"+CoordinatorManager.getCoordinator().getNodeId());
    footerVC.contextPut("fullVersion", version.getFullVersion() + nodeInfo);

    // Push information about AJAX mode
    boolean ajaxOn = false;
    if (ureq.getUserSession().isAuthenticated()) {
      ajaxOn = Windows.getWindows(ureq).getWindowManager()
          .isAjaxEnabled();
    } else {
      // on construction time only global and browserdependent ajax on
      // settings can be used
      // to show ajax gif :-)
      ajaxOn = Settings.isAjaxGloballyOn();
    }
    footerVC.contextPut("ajaxOn", ajaxOn ? Boolean.TRUE : Boolean.FALSE);

    // Push information about logged in users
    footerVC
        .contextPut("userSessionsCnt", UserSession.getUserSessionsCnt());

    // Push information about user
    if (ureq.getUserSession().isAuthenticated()) {
      footerVC.contextPut("loggedIn", Boolean.TRUE);
      footerVC.contextPut("username", ureq.getIdentity().getName());
    } else {
      footerVC.contextPut("loggedIn", Boolean.FALSE);
    }

    putInitialPanel(footerVC);
  }

  @Override
  protected void doDispose() {
    // nothing to dispose
  }

  @Override
  public void event(UserRequest ureq, Component source, Event event) {
    // no events to catch
  }
}
TOP

Related Classes of org.olat.core.commons.fullWebApp.DefaultFooterController

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.