/*
 * $Id: HelpViewAction.java,v 1.11 2006/10/04 03:15:20 marbobo Exp $
 *
 * Copyright (c) Siemens AG 2008 
 *           (c) Universität Paderborn 2008 
 * Licensed under EUPL 1.1. 
 *
 * $Log: HelpViewAction.java,v $
 * Revision 1.11  2006/10/04 03:15:20  marbobo
 * + Vollständige Unterstützung für Templates implementiert
 * + Alles von Virtoweb auf ProCoBa umgestellt
 *
 * Revision 1.10  2006/05/12 22:14:51  marbobo
 * + Administrationssicht implementiert
 *
 * Revision 1.9  2005/10/04 15:15:17  marbobo
 * + Unterstützung für klassische und alternative Sicht implementiert
 *
 * Revision 1.8  2004/11/02 21:42:31  marbobo
 * + Einige Funktionen für Gast-Benutzer gesperrt
 * + WebShare.LOGIN_PAGE mit WebShare.getLoginPage() ersetzt
 *
 * Revision 1.7  2004/07/20 08:26:39  jonyp
 * added copyright info + cvs log
 *
 */
package vkc.help.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import vkc.db.serializer.VKCTabViewSerializer;
import vkc.help.form.HelpViewForm;
import vkc.view.TabId;
import vkc.view.bean.TabInfo;

/**
 * Action-Klasse zur Weiterleitung zur Hilfeseiten
 *
 * @author marbobo
 * @version $Revision: 1.11 $
 */
public final class HelpViewAction extends Action {
	/**
	 * Weiterleitung zur Hilfeseiten. 
	 */
	public ActionForward execute(ActionMapping mapping,
 								 ActionForm f,
								 HttpServletRequest request, 
								 HttpServletResponse response)
	throws Exception {
		HelpViewForm form = (HelpViewForm)f;
		TabInfo tab = VKCTabViewSerializer.getTabInfo(new Integer(TabId.HELP_TAB));
		
		if (HelpViewForm.VKC_VIEW.equals(form.getViewId())) {
			if (TabInfo.VIEWTYPEID_CLASSIC.equals(tab.getViewTypeId())) {
				return new ActionForward("/templates/${template.name}/help/" + form.getUser().getLanguage().getShortName() + "/help.jsp", true);
			} else if (TabInfo.VIEWTYPEID_ALTERNATE.equals(tab.getViewTypeId())) {
				return new ActionForward("/templates/${template.name}/help/" + form.getUser().getLanguage().getShortName() + "/help-alternate.jsp", true);
			} else {
				return new ActionForward("/templates/${template.name}/help/" + form.getUser().getLanguage().getShortName() + "/help.jsp", true);
			}
		} else if (HelpViewForm.PROCOBA_VIEW.equals(form.getViewId())) {
			return new ActionForward("/templates/${template.name}/help/" + form.getUser().getLanguage().getShortName() + "/help-views.jsp", true);
		} else if (HelpViewForm.ADMIN_VIEW.equals(form.getViewId())) {
			return new ActionForward("/templates/${template.name}/help/" + form.getUser().getLanguage().getShortName() + "/help-admin.jsp", true);
		} else {
			if (TabInfo.VIEWTYPEID_CLASSIC.equals(tab.getViewTypeId())) {
				return new ActionForward("/templates/${template.name}/help/" + form.getUser().getLanguage().getShortName() + "/help.jsp", true);
			} else if (TabInfo.VIEWTYPEID_ALTERNATE.equals(tab.getViewTypeId())) {
				return new ActionForward("/templates/${template.name}/help/" + form.getUser().getLanguage().getShortName() + "/help-alternate.jsp", true);
			} else {
				return new ActionForward("/templates/${template.name}/help/" + form.getUser().getLanguage().getShortName() + "/help.jsp", true);
			}
		}
	}
}