/**
 * Copyright (c) 2003-2004 System Integrator Corporation.
 *                 All Rights Reserved.
 */
package jp.co.sint.beans.mobile.imode;

import java.sql.Connection;

import javax.servlet.http.HttpServletRequest;

import jp.co.sint.basic.SICtgry;
import jp.co.sint.beans.front.UIMain;
import jp.co.sint.config.SIConfig;
import jp.co.sint.tools.SIUtil;
import jp.co.sint.tools.SIURLParameter;//7.1.1 ST0236 追加

import org.apache.log4j.Category;
import jp.livewell.baby.util.ZenHanConverter;

/**
 * @version $Id: UIICmdtyList.java,v 1.0 2003/12/22 Exp $
 * @author  Jinwang Chen
 * <br>Description:
 * <p>History</p>
 * <p>Author&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Reason</p>
 *  ============&nbsp;&nbsp;&nbsp;==========&nbsp;&nbsp;===========================<br>
 * Jinwang Chen   2003/12/22 15:29:47  Original
 */
public class UIICmdtyList extends UIMain{
  //ログ用のインスタンスの生成
  private static Category log=Category.getInstance(SIConfig.SILOG4J_WEBSHOP_CATEGORY_NAME);

  private String displayTitleName="検索結果";

  private boolean isSmartPhone = false;

  public void setDisplayTitleName(String lDisplayTitleName){
    if (SIUtil.isNull(lDisplayTitleName)) lDisplayTitleName="";
    this.displayTitleName=lDisplayTitleName.trim();
  }

  public String getDisplayTitleName(){
    return this.displayTitleName;
  }

  public UIICmdtyList(){
  }

  public void init(HttpServletRequest lRequest,Connection lConnection,SIURLParameter lUrlParam){//7.1.1 ST0236 修正
    super.init(lRequest,lUrlParam);//7.1.1 ST0236 修正
    ZenHanConverter lConverter = new ZenHanConverter();
    log.debug("getActionNameTxt="+getActionNameTxt());
    if (SIConfig.SIACTION_SEARCH.equals(this.getActionNameTxt())){
      setCmdtyFlagTxt(SIConfig.SICMDTY_FLAG_SRCH);
      setDisplayTitleName("検索結果");
      /* if(!SIConfig.SICATEGORY_ROOT_CODE.equals(getCtgryCodeTxt())){
        SICtgry lCtgry=new SICtgry(getCtgryCodeTxt());
        lCtgry.reset(lConnection);
        setDisplayTitleName("["+SIFlagUtil.getFlagName(SIFlagConf.SIFLAG_CATEGORY_MENU_INX,lCtgry.getAbbvCtgryName())+"]からの検索結果");
      } カテゴリからの絞り込み検索*/
    }else if (SIConfig.SICATEGORY_ROOT_CODE.equals(getCtgryCodeTxt())){//トップカテゴリ
      if (getCmdtyFlagTxt().equalsIgnoreCase(SIConfig.SICMDTY_FLAG_ADVICE)) {
        setDisplayTitleName("[おすすめ品]");
      } else if (getCmdtyFlagTxt().equalsIgnoreCase(SIConfig.SICMDTY_FLAG_DISCOUNT)) {
        setDisplayTitleName("[特価品]");
      } else if (getCmdtyFlagTxt().equalsIgnoreCase(SIConfig.SICMDTY_FLAG_NEW)) {
        setDisplayTitleName("[新着]");
      }
    }else{
      SICtgry lCtgry=new SICtgry(getCtgryCodeTxt());
      lCtgry.reset(lConnection);
      setCmdtyFlagTxt(SIConfig.SICMDTY_FLAG_SRCH);
      setDisplayTitleName("["+lConverter.convert(lCtgry.getCtgryName()).replaceAll("ー","ｰ")+"]");
    }
    //並び順文の作成
    this.makeOrderBySQL();
  }

  public void setSmartPhone(boolean isSmartPhone){
    this.isSmartPhone = isSmartPhone;
  }
  
  public String getPageSizeSel(){
    if (isSmartPhone) return "20";
    else return String.valueOf(SIConfig.SIPAGE_SIZE_MOBILE);
  }

}
