<?php 
 
namespace Customize\Twig\Extension; 
 
use Customize\Entity\CacheTrait; 
use Customize\Service\GoodsPriceService; 
use Customize\Service\ReviewService; 
use Eccube\Entity\BaseInfo; 
use Eccube\Repository\BaseInfoRepository; 
use Eccube\Repository\PageRepository; 
use Lm\Engine\EC\Entity\GoodsWithRelated; 
use Lm\Entity\Goods; 
use Symfony\Component\HttpFoundation\RequestStack; 
use Symfony\Component\HttpFoundation\Request; 
use Twig\Environment as Twig; 
use Twig\Extension\AbstractExtension; 
use Twig\TwigFunction; 
use Twig\TwigFilter; 
use Symfony\Component\Security\Core\Security; 
use Eccube\Service\CartService; 
use Customize\Service\CartService as CartServiceCustomize; 
use Eccube\Common\EccubeConfig; 
use Customize\Service\CommonService; 
use Customize\Service\LmHelper; 
use Customize\Converter\DynamicConverter; 
use Customize\Service\RecentGoodsService; 
use Customize\Service\GoodsService; 
 
class CustomExtension extends AbstractExtension 
{ 
    use CacheTrait; 
    /** 
     * @var Security 
     */ 
    private $security; 
 
    /** 
     * @var CartService 
     */ 
    protected $cartService; 
 
    protected $cartServiceCustomize; 
 
    protected $commonService; 
 
    /** 
     * @var DynamicConverter 
     */ 
    protected $dynamicConverter; 
 
    const DISPLAY_ITEM_COUNT_LOW = 20; 
    const DISPLAY_ITEM_COUNT_MID = 50; 
    const DISPLAY_ITEM_COUNT_HI = 100; 
    const DISPLAY_ITEM_COUNT_DEFAULT = self::DISPLAY_ITEM_COUNT_MID; 
 
    /** 
     * @var EccubeConfig 
     */ 
    protected $eccubeConfig; 
 
    /** 
     * @var Twig 
     */ 
    protected $twig; 
 
    /** 
     * @var Request 
     */ 
    protected $request; 
 
    /** 
     * @var LmHelper 
     */ 
    protected $lmHelper; 
 
    /** 
     * @var ReviewService 
     */ 
    protected $reviewService; 
 
    /** 
     * @var GoodsPriceService 
     */ 
    private $goodsPriceService; 
 
    /** 
     * @var PageRepository 
     */ 
    private $pageRepository; 
 
    /** 
     * @var BaseInfo 
     */ 
    private $baseInfo; 
 
    protected $GoodsService; 
 
    public function __construct(Security         $security, 
                                RequestStack     $requestStack, 
                                Twig             $twig, 
                                EccubeConfig     $eccubeConfig, 
                                CartService      $cartService, 
                                CommonService    $commonService, 
                                LmHelper         $lmHelper, 
                                DynamicConverter $dynamicConverter, 
                                ReviewService    $reviewService, 
                                GoodsPriceService $goodsPriceService, 
                                PageRepository $pageRepository, 
                                BaseInfoRepository $baseInfoRepository, 
                                RecentGoodsService $RecentGoodsService, 
                                CartServiceCustomize $cartServiceCustomize, 
                                GoodsService     $goodService 
    ) 
    { 
        $this->security = $security; 
        $this->request = $requestStack->getCurrentRequest(); 
        $this->twig = $twig; 
        $this->eccubeConfig = $eccubeConfig; 
        $this->cartService = $cartService; 
        $this->commonService = $commonService; 
        $this->lmHelper = $lmHelper; 
        $this->dynamicConverter = $dynamicConverter; 
        $this->reviewService = $reviewService; 
        $this->goodsPriceService = $goodsPriceService; 
        $this->pageRepository = $pageRepository; 
        $this->baseInfo = $baseInfoRepository->get(); 
        $this->RecentGoodsService = $RecentGoodsService; 
        $this->cartServiceCustomize = $cartServiceCustomize; 
        $this->GoodsService = $goodService; 
    } 
 
    public function getFilters() 
    { 
        return [ 
            new TwigFilter('header4_css', [$this, 'renderHeader4Css']), 
            new TwigFilter('check_mcMcName', [$this, 'checkMcName']), 
            new TwigFilter('display_text', [$this, 'displayText']), 
            new TwigFilter('lm_sashikomi', [$this, 'LM_sashikomi']), 
            new TwigFilter('replace_item_image_root', [$this, 'replaceItemImageRoot']), 
            new TwigFilter('lm_sashikomi_main_category', [$this, 'LM_displaySashikomi_mainCategory']), 
            new TwigFilter('slider_filter', [$this, 'sliderFilter']), 
            new TwigFilter('display_form_text', [$this, 'display_form_text']), 
            new TwigFilter('json_decode', [$this, 'twigJsonDecode']), 
        ]; 
    } 
 
    public function getFunctions() 
    { 
        return [ 
            new TwigFunction('formatDescriptionForEstimate', [$this, 'handleFormatDescriptionForEstimate']), 
            new TwigFunction('footer_main_category', [$this, 'getFooterMainCategory']), 
            new TwigFunction('left_fbnrs', [$this, 'getLeftFbnrs']), 
            new TwigFunction('right_fbnrs', [$this, 'getRightFbnrs']), 
            new TwigFunction('toe_messages', [$this, 'getToeMessages']), 
            new TwigFunction('message_categories_count', [$this, 'getMessageCategoriesCount']), 
            new TwigFunction('lmenu_css', [$this, 'getLMenuCss']), 
            new TwigFunction('totalDailyRanking', [$this, 'getTotalDailyRanking']), 
            new TwigFunction('topics_data', [$this, 'getTopics']), 
            new TwigFunction('get_s3_lm_doc_path', [$this, 'getS3LmDocPath']), 
            new TwigFunction('months', [$this, 'getMonths']), 
            new TwigFunction('days', [$this, 'getDays']), 
            new TwigFunction('render_category_list', [$this, 'renderCategoryList']), 
            new TwigFunction('preg_match', [$this, 'pregMatch']), 
            new TwigFunction('lm_detailLink2', [$this, 'LM_detailLink2']), 
            new TwigFunction('default_sp_other_category_pulldown_map', [$this, 'getDefaultSpOtherCategoryPulldownMap']), 
            new TwigFunction('sp_header', [$this, 'renderSpHeader']), 
            new TwigFunction('makeImageURL', [$this, 'makeImageURL']), 
            new TwigFunction('sashikomi', [$this, 'sashikomi']), 
            new TwigFunction('session_data', [$this, 'getSessionData']), 
            new TwigFunction('showGoodsLabelList', [$this, 'renderGoodsLabelList']), 
            new TwigFunction('render_product_item', [$this, 'renderProductItem']), 
            new TwigFunction('lm_category_filter', [$this, 'lm_category_filter']), 
            new TwigFunction('custom_parse_url', [$this, 'custom_parse_url']), 
            new TwigFunction('echoImageURL', [$this, 'echoImageURL']), 
            new TwigFunction('echoVirtualImages', [$this, 'echoVirtualImages']), 
            new TwigFunction('get_updated_at', [$this, 'get_updated_at']), 
            new TwigFunction('LM_displaySashikomi_detailGoods', [$this, 'LM_displaySashikomi_detailGoods']), 
            new TwigFunction('LM_insertFile', [$this, 'LM_insertFile']), 
            new TwigFunction('createGetParamater', [$this, 'createGetParamater']), 
            new TwigFunction('LM_displayTogetherBuyDetail_new3', [$this, 'LM_displayTogetherBuyDetail_new3']), 
            new TwigFunction('hoge', [$this, 'hoge']), 
            new TwigFunction('display_item_pulldown', [$this, 'display_item_pulldown']), 
            new TwigFunction('display_order_pulldown', [$this, 'display_order_pulldown']), 
            new TwigFunction('sp_common_contents_map', [$this, 'getCommonContentsMap']), 
            new TwigFunction('get_calendar_info', [$this, 'getCalendarInfo']), 
            new TwigFunction('get_holiday_info', [$this, 'getHolidayInfo']), 
            new TwigFunction('you_may_also_like', [$this, 'getYouMayAlsoLike']), 
            new TwigFunction('get_koe_count', [$this, 'getKoeCount']), 
            new TwigFunction('get_category_order_type', [$this, 'getCategoryOrderType']), 
            new  TwigFunction('isShowSpHeader', [$this, 'isShowSpHeader']), 
            new  TwigFunction('showSizeTable', [$this, 'getSizeTable']), 
            new TwigFunction('get_carts_total_quantity', [$this, 'get_carts_total_quantity']), 
            new TwigFunction('getCampaignFlags', [$this, 'getCampaignFlags']), 
            new TwigFunction('getMatomeCampaignInfo', [$this, 'getMatomeCampaignInfo']), 
            new TwigFunction('getYoridoriCampaignInfo', [$this, 'getYoridoriCampaignInfo']), 
        ]; 
    } 
 
    public function handleFormatDescriptionForEstimate(string $text) { 
        if (empty($text)) { 
            return ""; 
        } 
        $result = ""; 
        $text = preg_replace('/\s+/', ' ', $text); 
        $lines = explode('・', $text); 
        $step = 1; 
        if (in_array('多色向き/写真等 ', $lines)) { 
            $step = 0; 
        } 
        for ($i = $step; $i < count($lines); $i++) { 
            $result .= '・' . $lines[$i] . "<br />"; 
        } 
        return $result; 
    } 
 
    public function renderHeader4Css($uri) 
    { 
        $uri = $_SERVER['REQUEST_URI']; 
        if (preg_match("/^\/polo\//", $uri)) echo "#header-menu-1-1 { background-position: -108px 0 !important; }"; 
        if (preg_match("/^\/shirt\//", $uri) and !preg_match("/^\/shirt\/aloha\//", $uri)) echo "#header-menu-1-2 { background-position: -108px -106px !important; }"; 
        if (preg_match("/^\/tshirt\//", $uri)) echo "#header-menu-1-3 { background-position: -108px -212px !important; }"; 
        if (preg_match("/^\/staff\//", $uri)) echo "#header-menu-1-4 { background-position: -108px -318px !important; }"; 
        if (preg_match("/^\/vest\//", $uri)) echo "#header-menu-1-5 { background-position: -108px -424px !important; }"; 
        if (preg_match("/^\/warm\//", $uri)) echo "#header-menu-1-6 { background-position: -108px -530px !important; }"; 
        if (preg_match("/^\/sweat\//", $uri)) echo "#header-menu-1-7 { background-position: -108px -636px !important; }"; 
        if (preg_match("/^\/pants\//", $uri)) echo "#header-menu-1-8 { background-position: -108px -742px !important; }"; 
        if (preg_match("/^\/food-uniform\/cook-coat\//", $uri)) echo "#header-menu-1-9 { background-position: -108px -848px !important; }"; 
        if (preg_match("/^\/apron\//", $uri)) echo "#header-menu-2-1 { background-position: -108px -27px !important; }"; 
        if (preg_match("/^\/shirt\/aloha\//", $uri)) echo "#header-menu-2-2 { background-position: -108px -133px !important; }"; 
        if (preg_match("/^\/happi\//", $uri)) echo "#header-menu-2-3 { background-position: -108px -239px !important; }"; 
        if (preg_match("/^\/cap\//", $uri)) echo "#header-menu-2-4 { background-position: -108px -345px !important; }"; 
        if (preg_match("/^\/overall\//", $uri)) echo "#header-menu-2-5 { background-position: -108px -451px !important; }"; 
        if (preg_match("/^\/anzengutsu\//", $uri)) echo "#header-menu-2-6 { background-position: -108px -557px !important; }"; 
        if (preg_match("/^\/towel\//", $uri)) echo "#header-menu-2-7 { background-position: -108px -663px !important; }"; 
        if (preg_match("/^\/scrub\//", $uri)) echo "#header-menu-2-8 { background-position: -108px -769px !important; }"; 
        if (preg_match("/^\/bag\//", $uri)) echo "#header-menu-2-9 { background-position: -108px -875px !important; }"; 
        if (preg_match("/^\/work\//", $uri)) echo "#header-menu-3-1 { background-position: -108px -54px !important; }"; 
        if (preg_match("/^\/jimufuku\//", $uri)) echo "#header-menu-3-2 { background-position: -108px -160px !important; }"; 
        if (preg_match("/^\/hakui\//", $uri) and !preg_match("/^\/hakui\/scrub\//", $uri)) echo "#header-menu-3-3 { background-position: -108px -266px !important; }"; 
        if (preg_match("/^\/food-uniform\//", $uri) and !preg_match("/^\/food-uniform\/cook-coat\//", $uri)) echo "#header-menu-3-4 { background-position: -108px -372px !important; }"; 
        if (preg_match("/^\/esthe-uniform\//", $uri) and !preg_match("/^\/towel\//", $uri)) echo "#header-menu-3-5 { background-position: -108px -478px !important; }"; 
        if (preg_match("/^\/election-item\//", $uri)) echo "#header-menu-3-6 { background-position: -108px -584px !important; }"; 
        if (preg_match("/^\/care-wear\//", $uri)) echo "#header-menu-3-7 { background-position: -108px -690px !important; }"; 
        if (preg_match("/^\/patrol\//", $uri)) echo "#header-menu-3-8 { background-position: -108px -796px !important; }"; 
        if (preg_match("/^\/food-uniform\/formal-vest\//", $uri)) echo "#header-menu-3-9 { background-position: -108px -902px !important; }"; 
        if (preg_match("/^\/guide\//", $uri) and !preg_match("/^\/guide\/print-shurui\//", $uri) and !preg_match("/^\/guide\/price-silk\//", $uri) and !preg_match("/^\/guide\/henpin\//", $uri) and !preg_match("/^\/guide\/shiharai\//", $uri)) echo "#header-menu-4-1 { background-position: -108px -81px !important; }"; 
        if (preg_match("/^\/guide\/print-shurui\//", $uri)) echo "#header-menu-4-2 { background-position: -108px -187px !important; }"; 
        if (preg_match("/^\/guide\/price-silk\//", $uri)) echo "#header-menu-4-3 { background-position: -108px -293px !important; }"; 
        if (preg_match("/^\/print\/font-menu\//", $uri)) echo "#header-menu-4-4 { background-position: -108px -399px !important; }"; 
        if (preg_match("/^\/guide\/henpin\//", $uri)) echo "#header-menu-4-5 { background-position: -108px -505px !important; }"; 
        if (preg_match("/^\/guide\/shiharai\//", $uri)) echo "#header-menu-4-6 { background-position: -108px -611px !important; }"; 
        if (preg_match("/^\/faq\//", $uri)) echo "#header-menu-4-7 { background-position: -108px -717px !important; }"; 
        if (preg_match("/^\/sample-order\//", $uri)) echo "#header-menu-4-8 { background-position: -108px -823px !important; }"; 
        if (preg_match("/^\/company\//", $uri)) echo "#header-menu-4-9 { background-position: -108px -929px !important; }"; 
 
        return ""; 
    } 
 
    public function getFooterMainCategory() 
    { 
        // TODO: MainCategoryページのFooterで ページDescription取得 
        /** 
         * [ 
         *  [ 
         *    name: 'description', 
         *    content: 'TEST' 
         *  ] 
         *  ... 
         * ] 
         */ 
 
        $response = [ 
            [ 
                'name' => 'description', 
                'content' => 'TEST' 
            ] 
        ]; 
 
        return $response; 
    } 
 
    public function getLeftFbnrs() 
    { 
        $viewCacheKey = $this->lmHelper->getCacheKey('getLeftFbnrs', []); 
        return $this->getCacheByKey($viewCacheKey, function() { 
            $result = []; 
            $fbnrs = array_values(array_filter($this->dynamicConverter->getFbnrs(), function ($fbnr) { 
                return !empty($fbnr['fbnr_content']); 
            })); 
            $result[] = array_shift($fbnrs); 
 
            return $result; 
        }); 
    } 
  public function displayText($text) 
  { 
    return nl2br(str_replace(">",">",str_replace("<","<",stripslashes($text)))); 
  } 
 
  public function LM_sashikomi($srcHtml) 
  { 
    $CFIMG_URL = $this->eccubeConfig['CFIMG_URL'] . '/'; 
    $BACKIMG_URL = $this->eccubeConfig['BACKIMG_URL']; 
 
        $dstHtml = $srcHtml; 
        $dstHtml = str_replace('"img/','"'.$CFIMG_URL."public_img/",$dstHtml); 
        $dstHtml = str_replace('"/img/','"'.$CFIMG_URL."public_img/",$dstHtml); 
        $dstHtml = str_replace('"./img/','"'.$CFIMG_URL."public_img/",$dstHtml); 
        $dstHtml = str_replace('"../img/','"'.$CFIMG_URL."public_img/",$dstHtml); 
        $dstHtml = str_replace('http://www.l-m.co.jp/img/',$CFIMG_URL."public_img/",$dstHtml); 
        $dstHtml = str_replace('https://www.l-m.co.jp/img/',$CFIMG_URL."public_img/",$dstHtml); 
        $dstHtml = str_replace('"images/','"'.$CFIMG_URL."public_images/",$dstHtml); 
        $dstHtml = str_replace('"/images/','"'.$CFIMG_URL."public_images/",$dstHtml); 
        $dstHtml = str_replace('"./images/','"'.$CFIMG_URL."public_images/",$dstHtml); 
        $dstHtml = str_replace('"../images/','"'.$CFIMG_URL."public_images/",$dstHtml); 
        $dstHtml = str_replace('http://www.l-m.co.jp/images/',$CFIMG_URL."public_images/",$dstHtml); 
        $dstHtml = str_replace('https://www.l-m.co.jp/images/',$CFIMG_URL."public_images/",$dstHtml); 
        $dstHtml = str_replace('url(images/','url('.$CFIMG_URL.'public_images/',$dstHtml); 
        $dstHtml = str_replace('url(/images/','url('.$CFIMG_URL.'public_images/',$dstHtml); 
        $dstHtml = str_replace('url(\'images/','url(\''.$CFIMG_URL.'public_images/',$dstHtml); 
        $dstHtml = str_replace('url(\'/images/','url(\''.$CFIMG_URL.'public_images/',$dstHtml); 
        $dstHtml = str_replace('url("images/','url("'.$CFIMG_URL.'public_images/',$dstHtml); 
        $dstHtml = str_replace('url("/images/','url("'.$CFIMG_URL.'public_images/',$dstHtml); 
        $dstHtml = str_replace('"item/kihon/','"'.$BACKIMG_URL."public_item/kihon/",$dstHtml); 
        $dstHtml = str_replace('"/item/kihon/','"'.$BACKIMG_URL."public_item/kihon/",$dstHtml); 
        $dstHtml = str_replace('"./item/kihon/','"'.$BACKIMG_URL."public_item/kihon/",$dstHtml); 
        $dstHtml = str_replace('"../item/kihon/','"'.$BACKIMG_URL."public_item/kihon/",$dstHtml); 
        $dstHtml = str_replace('http://www.l-m.co.jp/item/kihon/',$BACKIMG_URL."public_item/kihon/",$dstHtml); 
        $dstHtml = str_replace('https://www.l-m.co.jp/item/kihon/',$BACKIMG_URL."public_item/kihon/",$dstHtml); 
        $dstHtml = str_replace('url(item/kihon/','url('.$BACKIMG_URL.'public_item/kihon/',$dstHtml); 
        $dstHtml = str_replace('url(/item/kihon/','url('.$BACKIMG_URL.'public_item/kihon/',$dstHtml); 
        $dstHtml = str_replace('url(\'item/kihon/','url(\''.$BACKIMG_URL.'public_item/kihon/',$dstHtml); 
        $dstHtml = str_replace('url(\'/item/kihon/','url(\''.$BACKIMG_URL.'public_item/kihon/',$dstHtml); 
        $dstHtml = str_replace('url("item/kihon/','url("'.$BACKIMG_URL.'public_item/kihon/',$dstHtml); 
    $dstHtml = str_replace('url("/item/kihon/','url("'.$BACKIMG_URL.'public_item/kihon/',$dstHtml); 
 
    return $dstHtml; 
  } 
 
  public function renderCategoryList($mcMcName, $mcName, $data, $canonicalMcData, $categoryData, $dataItem, $subCategoryList, $ctId) 
  { 
      // 配下カテゴリ 
      $canonicalMcName = $mcName; 
      if (!empty($mcMcName)) { 
          $canonicalMcName = "{$mcMcName}/{$mcName}"; 
      } else if (!empty($data['main_category_main_category_webname'])) { 
          $canonicalMcName = "{$data['main_category_main_category_webname']}/{$mcName}"; 
      } 
      if (!empty($canonicalMcData)) { 
          $data = $canonicalMcData; 
          $canonicalMcName = $data['main_category_webname']; 
          if (!empty($data['main_category_main_category_webname'])) { 
              $canonicalMcName = "{$data['main_category_main_category_webname']}/{$canonicalMcName}"; 
          } 
      } else if ($categoryData == null) { 
          $data = $data; 
      } else { 
          $data = $categoryData; 
      } 
      // 件数リスト 
      $categoryCntList = array(); 
      if (isset($dataItem)) { 
          foreach ($dataItem as $_item) { 
              $categoryCntList[$_item['category_id']] = $_item['cnt'] ?? 0; 
          } 
      } 
  } 
 
    public function getRightFbnrs() 
    { 
        $viewCacheKey = $this->lmHelper->getCacheKey('getRightFbnrs', []); 
        $fbnrs = array_values(array_filter($this->dynamicConverter->getFbnrs(), function ($fbnr) { 
            return !empty($fbnr['fbnr_content2']); 
        })); 
        $result = []; 
        $result[] = array_shift($fbnrs); 
        $pageType = $this->lmHelper->getPageType(); 
        if ($pageType['value'] === 'print-shurui') { 
            $shuruiSideMenu[]['fbnr_content2'] = ' 
            <div id="print-shurui-side-nav"> 
                <dl> 
                <dt id="nav_lad"><a href="' . $this->eccubeConfig['FRONT_PATH'] . 'guide/print-shurui/#silk_anchor">シルクプリント</a></dt> 
                <dd><a href="' . $this->eccubeConfig['FRONT_PATH'] . 'guide/print-shurui/#silk_k" class="allsale_h">価格</a></dd> 
                <dd><a href="' . $this->eccubeConfig['FRONT_PATH'] . 'guide/print-shurui/#silk_kd">├型代</a></dd> 
                <dd><a href="' . $this->eccubeConfig['FRONT_PATH'] . 'guide/print-shurui/#silk_pd">├プリント代</a></dd> 
                <dd><a href="' . $this->eccubeConfig['FRONT_PATH'] . 'guide/print-shurui/#silk_im">└色見本</a></dd> 
                <dt id="nav_lad"><a href="' . $this->eccubeConfig['FRONT_PATH'] . 'guide/print-shurui/#staff_anchor">STAFF無料型</a></dt> 
                <dt id="nav_lad"><a href="' . $this->eccubeConfig['FRONT_PATH'] . 'guide/print-shurui/#magic_anchor">マジックプリント</a></dt> 
                <dt id="nav_lad"><a href="' . $this->eccubeConfig['FRONT_PATH'] . 'guide/print-shurui/#transfer_anchor">転写</a></dt> 
                <dt id="nav_lad"><a href="' . $this->eccubeConfig['FRONT_PATH'] . 'guide/print-shurui/#embroidery_anchor">刺繍</a></dt> 
                <dd><a href="' . $this->eccubeConfig['FRONT_PATH'] . 'guide/print-shurui/#sisyu_k" class="allsale_h">価格</a></dd> 
                <dd><a href="' . $this->eccubeConfig['FRONT_PATH'] . 'guide/print-shurui/#sisyu_sya">├社名刺繍</a></dd> 
                <dd><a href="' . $this->eccubeConfig['FRONT_PATH'] . 'guide/print-shurui/#sisyu_logo">├ロゴマーク</a></dd> 
                <dd><a href="' . $this->eccubeConfig['FRONT_PATH'] . 'guide/print-shurui/#sisyu_im">└色見本</a></dd> 
                <dt id="nav_lad"><a href="' . $this->eccubeConfig['FRONT_PATH'] . 'guide/print-shurui/#threedimensional_anchor">立体刺繍</a></dt> 
                <dt id="nav_lad"><a href="' . $this->eccubeConfig['FRONT_PATH'] . 'guide/print-shurui/#rehem_anchor">ズボンの裾直し</a></dt> 
                </dl> 
            </div>'; 
 
            return $shuruiSideMenu; 
        } 
        return $result; 
    } 
 
    public function getToeMessages() 
    { 
        $messages = (array)$this->dynamicConverter->getMessageList('cm_id, title, add_datetime', 10); 
 
        $response = [ 
            'total_count' => sizeof((array)$this->dynamicConverter->getMessageList()), 
            'data' => $messages 
        ]; 
 
        return $response; 
    } 
 
    public function getMessageCategoriesCount() 
    { 
        $messages = $this->dynamicConverter->getMessageCountByCategory(); 
 
        return $messages; 
    } 
 
    public function getLMenuCss() 
    { 
        $uri = $_SERVER['REQUEST_URI']; 
        if (preg_match("/^\/work\//", $uri)) echo "#side-nav.top-use #fixed-menu-1 { background-position: -165px 0 !important; }"; 
        if (preg_match("/^\/anzengutsu\//", $uri)) echo "#side-nav.top-category #fixed-menu-2 { background-position: -165px -43px !important; }"; 
        if (preg_match("/^\/jimufuku\//", $uri)) echo "#side-nav.top-use #fixed-menu-3 { background-position: -165px -86px !important; }"; 
        if (preg_match("/^\/hakui\//", $uri) and !preg_match("/^\/hakui\/scrub\//", $uri)) echo "#side-nav.top-use #fixed-menu-4 { background-position: -165px -129px !important; }"; 
        if (preg_match("/^\/scrub\//", $uri)) echo "#side-nav.top-use #fixed-menu-5 { background-position: -165px -172px !important; }"; 
        if (preg_match("/^\/food-uniform\//", $uri) and !preg_match("/^\/food-uniform\/cook-coat\//", $uri)) echo "#side-nav.top-use #fixed-menu-6 { background-position: -165px -215px !important; }"; 
        if (preg_match("/^\/food-uniform\/cook-coat\//", $uri)) echo "#side-nav.top-use #fixed-menu-7 { background-position: -165px -258px !important; }"; 
        if (preg_match("/^\/esthe-uniform\//", $uri) and !preg_match("/^\/towel\//", $uri)) echo "#side-nav.top-use #fixed-menu-8 { background-position: -165px -301px !important; }"; 
        if (preg_match("/^\/care-wear\//", $uri)) echo "#side-nav.top-use #fixed-menu-9 { background-position: -165px -344px !important; }"; 
        if (preg_match("/^\/patrol\//", $uri)) echo "#side-nav.top-use #fixed-menu-10 { background-position: -165px -387px !important; }"; 
        if (preg_match("/^\/formal\//", $uri)) echo "#side-nav.top-use #fixed-menu-11 { background-position: -165px -430px !important; }"; 
        if (preg_match("/^\/polo\//", $uri)) echo "#side-nav.top-category #fixed-menu-1 { background-position: -165px 0 !important; }"; 
        if (preg_match("/^\/apron\//", $uri)) echo "#side-nav.top-category #fixed-menu-2 { background-position: -165px -43px !important; }"; 
        if (preg_match("/^\/shirt\//", $uri) and !preg_match("/^\/shirt\/aloha\//", $uri)) echo "#side-nav.top-category #fixed-menu-3 { background-position: -165px -86px !important; }"; 
        if (preg_match("/^\/tshirt\//", $uri)) echo "#side-nav.top-category #fixed-menu-4 { background-position: -165px -129px !important; }"; 
        if (preg_match("/^\/staff\//", $uri)) echo "#side-nav.top-category #fixed-menu-5 { background-position: -165px -172px !important; }"; 
        if (preg_match("/^\/vest\//", $uri)) echo "#side-nav.top-category #fixed-menu-6 { background-position: -165px -215px !important; }"; 
        if (preg_match("/^\/warm\//", $uri)) echo "#side-nav.top-category #fixed-menu-7 { background-position: -165px -258px !important; }"; 
        if (preg_match("/^\/sweat\//", $uri)) echo "#side-nav.top-category #fixed-menu-8 { background-position: -165px -301px !important; }"; 
        if (preg_match("/^\/pants\//", $uri)) echo "#side-nav.top-category #fixed-menu-9 { background-position: -165px -344px !important; }"; 
        if (preg_match("/^\/shirt\/aloha\//", $uri)) echo "#side-nav.top-category #fixed-menu-10 { background-position: -165px -387px !important; }"; 
        if (preg_match("/^\/happi\//", $uri)) echo "#side-nav.top-category #fixed-menu-11 { background-position: -165px -430px !important; }"; 
        if (preg_match("/^\/cap\//", $uri)) echo "#side-nav.top-category #fixed-menu-12 { background-position: -165px -473px !important; }"; 
        if (preg_match("/^\/overall\//", $uri)) echo "#side-nav.top-category #fixed-menu-13 { background-position: -165px -516px !important; }"; 
        if (preg_match("/^\/towel\//", $uri)) echo "#side-nav.top-category #fixed-menu-14 { background-position: -165px -559px !important; }"; 
        if (preg_match("/^\/bag\//", $uri)) echo "#side-nav.top-category #fixed-menu-15 { background-position: -165px -602px !important; }"; 
 
        return ""; 
    } 
 
    public function checkMcName($mcMcName, $type) 
    { 
        $datas = [$mcMcName, $type]; 
        $viewCacheKey = $this->lmHelper->getCacheKey("checkMcName", $datas); 
        return $this->getCacheByKey($viewCacheKey, function() use ($mcMcName, $type) { 
            if ($type == 1) { 
                return ( 
                    $mcMcName != "polo" and 
                    $mcMcName != "shirt" and 
                    $mcMcName != "tshirt" and 
                    $mcMcName != "staff" and 
                    $mcMcName != "vest" and 
                    $mcMcName != "warm" and 
                    $mcMcName != "sweat" and 
                    $mcMcName != "pants" and 
                    $mcMcName != "cook-coat" and 
                    $mcMcName != "apron" and 
                    $mcMcName != "happi" and 
                    $mcMcName != "cap" and 
                    $mcMcName != "overall" and 
                    $mcMcName != "anzengutsu" and 
                    $mcMcName != "towel" and 
                    $mcMcName != "scrub" and 
                    $mcMcName != "bag" and 
 
                    $mcMcName != "work" and 
                    $mcMcName != "jimufuku" and 
                    $mcMcName != "hakui" and 
                    $mcMcName != "food-uniform" and 
                    $mcMcName != "esthe-uniform" and 
                    $mcMcName != "election-item" and 
                    $mcMcName != "care-wear" and 
                    $mcMcName != "patrol" and 
                    $mcMcName != "pachinko" and 
 
                    $mcMcName != "burtle" and 
                    $mcMcName != "tsdesign" and 
                    $mcMcName != "xebec" and 
                    $mcMcName != "aitoz" and 
                    $mcMcName != "jichodo" and 
                    $mcMcName != "jawin" and 
                    $mcMcName != "kurodaruma" and 
                    $mcMcName != "co-cos" and 
                    $mcMcName != "sowa" and 
                    $mcMcName != "joie" and 
 
 
                    $mcMcName != "bon" and 
                    $mcMcName != "boncierge" and 
                    $mcMcName != "enjoy" and 
                    $mcMcName != "selery" and 
                    $mcMcName != "mizuno" and 
                    $mcMcName != "folk" and 
                    $mcMcName != "lecoqsportif-nurse" and 
 
                    $mcMcName != "lumiere" and 
                    $mcMcName != "facemix" and 
                    $mcMcName != "arbe" and 
                    $mcMcName != "bonuni" and 
                    $mcMcName != "lecoqsportif-care" and 
                    $mcMcName != "heartgreen" and 
                    $mcMcName != "natural-smile" and 
                    $mcMcName != "pep" and 
 
                    $mcMcName != "printstar" and 
                    $mcMcName != "unitedathle" and 
                    $mcMcName != "maximum" and 
                    $mcMcName != "calala" and 
                    $mcMcName != "bspa" and 
                    $mcMcName != "counterbiz" and 
                    $mcMcName != "glimmer" and 
                    $mcMcName != "daluc" and 
                    $mcMcName != "triumph" and 
                    $mcMcName != "sunpex" and 
                    $mcMcName != "formal" and 
                    $mcMcName != "whisel" and 
 
 
                    $mcMcName != "work-ladies" and 
                    $mcMcName != "work-gekiyasu" and 
                    $mcMcName != "work-stretch" and 
                    $mcMcName != "work-seiden" and 
                    $mcMcName != "work-cotton" and 
                    $mcMcName != "work-menpoli" and 
                    $mcMcName != "work-coolbiz" and 
                    $mcMcName != "work-warmbiz" and 
                    $mcMcName != "work-bouen" and 
                    $mcMcName != "work-nannen" and 
 
 
                    $mcMcName != "office-cute" and 
                    $mcMcName != "office-adult" and 
                    $mcMcName != "office-stock" and 
                    $mcMcName != "office-gekiyasu" and 
                    $mcMcName != "office-muji" and 
                    $mcMcName != "office-check" and 
                    $mcMcName != "office-stripe" and 
                    $mcMcName != "office-border" and 
                    $mcMcName != "office-jacquard" 
                ); 
            } else if ($type == 2) { // 限定非表示したいエリアをここに入れる 2015.5.1 複数のとき、!= and 
                return ( 
                    $mcMcName != "pants" and 
                    $mcMcName != "cook-coat" and 
                    $mcMcName != "anzengutsu" and 
                    $mcMcName != "scrub" and 
                    $mcMcName != "bag" and 
                    $mcMcName != "work" and 
                    $mcMcName != "jimufuku" and 
                    $mcMcName != "hakui" and 
                    $mcMcName != "food-uniform" and 
                    $mcMcName != "esthe-uniform" and 
                    $mcMcName != "pachinko" and 
                    $mcMcName != "burtle" and 
                    $mcMcName != "tsdesign" and 
                    $mcMcName != "xebec" and 
                    $mcMcName != "aitoz" and 
                    $mcMcName != "jichodo" and 
                    $mcMcName != "jawin" and 
                    $mcMcName != "kurodaruma" and 
                    $mcMcName != "co-cos" and 
                    $mcMcName != "sowa" and 
                    $mcMcName != "joie" and 
                    $mcMcName != "bon" and 
                    $mcMcName != "boncierge" and 
                    $mcMcName != "enjoy" and 
                    $mcMcName != "selery" and 
                    $mcMcName != "mizuno" and 
                    $mcMcName != "folk" and 
                    $mcMcName != "lecoqsportif-nurse" and 
                    $mcMcName != "lumiere" and 
                    $mcMcName != "facemix" and 
                    $mcMcName != "arbe" and 
                    $mcMcName != "bonuni" and 
                    $mcMcName != "lecoqsportif-care" and 
                    $mcMcName != "heartgreen" and 
                    $mcMcName != "natural-smile" and 
                    $mcMcName != "pep" and 
                    $mcMcName != "calala" and 
                    $mcMcName != "bspa" and 
                    $mcMcName != "counterbiz" 
                ); 
            } 
 
            return false; 
        }); 
    } 
 
    public function getTotalDailyRanking() 
    { 
        $goods = (array)$this->dynamicConverter->getRankingList(); 
 
        $response = [ 
            'all' => array(), 
            'sagyoufuku' => array(), 
            'jimufuku' => array(), 
            'hakui' => array(), 
            'inshoku' => array() 
        ]; 
 
        foreach ($goods as $good) { 
            $good['image_url'] = $this->makeImageURL('goods.img', $good['goods_id']); 
            switch ($good['goods_genre_text']) { 
                case '': 
                    $good['goods_genre_text'] = '総合'; 
                    $response['all'][$good['ranking_no']] = $good; 
                    break; 
                case '作業服': 
                    $response['sagyoufuku'][$good['ranking_no']] = $good; 
                    break; 
                case '事務服': 
                    $response['jimufuku'][$good['ranking_no']] = $good; 
                    break; 
                case '白衣': 
                    $response['hakui'][$good['ranking_no']] = $good; 
                    break; 
                case '飲食': 
                    $response['inshoku'][$good['ranking_no']] = $good; 
                    break; 
            } 
        } 
        foreach ($response as $key => $dummy) { 
            ksort($response[$key]); 
        } 
        return $response; 
    } 
 
    public function getTopics() 
    { 
        $results = $this->dynamicConverter->getTopicData(); 
 
        return $results; 
 
    } 
 
    public function getS3LmDocPath() 
    { 
        $path = ''; // $this->eccubeConfig['S3_LM_DOC_PATH']; 
 
        return $path; 
    } 
 
    public function getMonths() 
    { 
        $months = array(); 
        for ($i = 1; $i <= 12; $i++) { 
            $months[] = $i; 
        } 
 
        return $months; 
    } 
 
    public function getDays() 
    { 
        $days = array(); 
        for ($i = 1; $i <= 31; $i++) { 
            $days[] = $i; 
        } 
 
        return $days; 
    } 
 
    public function replaceItemImageRoot($html) 
    { 
        $dstHtml = $html; 
        return $dstHtml; 
    } 
 
    public function LM_displaySashikomi_mainCategory($value) 
    { 
        if ($value != "") { 
            if (file_exists($filename = "files/insert/{$value}")) { 
                $file = implode("", file($filename)); 
                $file = str_replace("</BODY>", "</body>", str_replace("<BODY>", "<body>", $file)); 
                $tmp = explode("<body>", $file); 
                if (count($tmp) > 1) { 
                    $tmp = explode("</body>", $tmp[1]); 
                } else { 
                    $tmp = explode("</body>", $tmp[0]); 
                } 
                $tmp = $this->replaceItemImageRoot($tmp[0]); 
                return "<div style='line-height:12px'><br /></div>" . $tmp; 
            } 
        } 
 
        return ""; 
    } 
 
    private function addAttrRegexp($src, $attrname, array $dst) 
    { 
        $attrs = preg_replace_callback("/{$attrname}=\"([^\"]+)\"/", function ($matches) { 
            return $matches[1]; 
        }, $src); 
        $attrs = explode(' ', $attrs); 
        $attrs = $dst + $attrs; 
        $attrs = implode(' ', $attrs); 
        return $attrs; 
    } 
 
    public function sliderFilter($value) 
    { 
        // 
        if (preg_match('/class="swiper-wrapper/', $value)) { 
            return $value; 
        } 
        // bxSlider 
        $value = preg_replace_callback('/<ul([^<>]*(?:bxslider|foobar)[^<>]*)>(.*?)<\/ul>/s', function ($matches) { 
            // 
            $org = $matches[0]; 
            // 
            $classes = $this->addAttrRegexp($matches[1], 'class', [ 
                'swiper-wrapper', 
            ]); 
            // echo $classes, PHP_EOL; 
            // TODO: その他の属性の対応 
            $attrs = " class=\"{$classes}\""; 
            $li = preg_replace_callback('/<li([^<>]*)>/', function ($matches) { 
                // 
                $classes = $this->addAttrRegexp($matches[1], 'class', [ 
                    'swiper-slide', 
                ]); 
                // echo $classes, PHP_EOL; 
                // 
                return "<li class=\"{$classes}\">"; 
            }, $matches[2]); 
            // 
            $swiper = "<div class=\"swiper-container\"> 
                <ul{$attrs}>{$li}</ul> 
                <div class=\"swiper-pagination\"></div> 
                <div class=\"swiper-button-prev\"></div> 
                  <div class=\"swiper-button-next\"></div> 
                <div class=\"swiper-scrollbar\"></div> 
            </div>"; 
            // var_dump(compact('matches', 'attrs', 'li', 'swiper')); 
            // 
            return $swiper; 
        }, $value); 
        // 
        return $value; 
    } 
 
    public function pregMatch($pattern, $value, $result) 
    { 
        return preg_match($pattern, $value, $result); 
    } 
 
    public function LM_detailLink2($data, $mcName = "", $ctName = "", $useItemUrlDuplicated = true) 
    { 
        $item_id = !empty($data['goods_canonical_hinban']) ? $data['goods_canonical_hinban'] : $data['goods_id']; 
        if (!$useItemUrlDuplicated) { 
            $url = "/item/{$item_id}.html"; 
        } else if ($mcName === 'nagaileben') { 
            // ナガイレーベンの場合のみ、プレーンURLとする 
            $url = "/item/{$item_id}.html"; 
        } else if ($mcName != "" && $ctName == "") { 
            $url = "/item/{$item_id}/{$mcName}.html"; 
        } else if ($mcName != "" && $ctName != "") { 
            $url = "/item/{$item_id}/{$mcName}/{$ctName}.html"; 
        } 
        echo $url; 
    } 
 
    public function getDefaultSpOtherCategoryPulldownMap() 
    { 
        return $this->commonService->getSpOtherCategoryPulldownMap(); 
    } 
 
    public function renderSpHeader($main_h1, $category_h1, $h1_comment, $data, $custom_menu, $recentviews, $custom_frequently_searched_word, $other_category_path_map = []) 
    { 
        $html = ''; 
            $cartCount = $this->get_carts_total_quantity(); 
            if (!strstr($_SERVER["REQUEST_URI"], "/estimate")) { 
                $html = '<nav id="ut-sp-global-navi">'; 
 
                // キャッシュが無効(通常通り出力) 
                $temp = $this->sp_h1($main_h1, $category_h1, $h1_comment, $data); 
                $html = "{$html}{$temp}"; 
 
                $html = $html . '<ul> 
          <li class="navi-home"><a href="/" data-ajax="false"><i class="material-icons">home</i><span>ホーム</span></a></li> 
          <li class="navi-tel"><a href="tel:0120115116" class="cv-tel" data-ajax="false"><i class="material-icons">phone</i><span>電話</span></a></li> 
          <li class="navi-cart"><a href="/cart/" data-ajax="false"><i class="material-icons">shopping_cart</i><span>カート<div class="cart-item-badge' . (isset($_SESSION['cart']['type']) && $_SESSION['cart']['type'] == "sample" ? ' sample' : '') . '"><b>' . $cartCount . '</b></div></span></a></li> 
          <li class="navi-search"><a href="#" data-ajax="false" data-slide-panel="search"><i class="material-icons">search</i><span>検索</span></a></li> 
          <li class="navi-menu"><a href="#" data-ajax="false" data-slide-panel="menu"><i class="material-icons">menu</i><span>メニュー</span></a></li> 
        </ul>'; 
 
                $html = "{$html}</nav>"; 
                $temp = $this->slide_panel_menu($custom_menu, $recentviews, $other_category_path_map); 
                $html = "{$html}{$temp}"; 
                 $temp = $this->slide_panel_search($data, $custom_frequently_searched_word, $custom_menu, $other_category_path_map, $recentviews); 
                $html = "{$html}{$temp}"; 
            } 
        $allowedNewCss = ['/mypage/history/', '/mypage/mhistory/', '/mypage/chistory/', '/mypage/contact/', '/mypage/update/']; 
        $currentURI = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); 
        if (!in_array($currentURI, $allowedNewCss)) { 
            $html = $html . '<div id="logo"> 
                                <a href="/" data-ajax="false"><img src="https://img0.land-mark.biz/ut_img/public_images/header/site_logo_mini.jpg" alt="ユニフォームタウン" /></a> 
                            </div>'; 
        } else { 
            $html = $html . '<div id="logo"> 
                            <a href="/" data-ajax="false"><img src="/stylesheets/images/icons-svg/union.svg" alt="ユニフォームタウン" /></a> 
                        </div> 
                        <div id="working-time-wrapper"> 
                            <img class="working-hour" src="/stylesheets/images/icons-svg/working_hour.svg" /> 
                            <img src="/stylesheets/images/icons-svg/day_off.svg" /> 
                        </div> 
                        '; 
        } 
        echo $html; 
    } 
 
    private function sp_h1($main_h1, $category_h1, $h1_comment, $data) 
    { 
        if (isset($main_h1) && $main_h1 != "") { 
            return "<h1>" . $main_h1 . "</h1>"; 
        } elseif (isset($category_h1) && $category_h1 != "") { 
            return "<h1>" . $category_h1 . "</h1>"; 
        } elseif (isset($h1_comment) && $h1_comment = trim($h1_comment)) { 
            return "<h1>" . $h1_comment . "</h1>"; 
        } elseif (isset($data['goods_h1']) && $data['goods_h1'] != "") { 
            // if (isset($data['goods'])) return str_replace('品番', '', $data['kataban'] ?? '') . " {$data['goods']['goods_maker_name_text']} {$data['goods']['goods_name']}"; 
            // return "<h1>" . ($data['main_h1_tag'] ?? '') . "</h1>"; 
            return "<h1>" . ($data['goods_h1'] ?? '') . "</h1>"; 
        } else if ($h1 = $this->getTitleStr($_SERVER["REQUEST_URI"])) { 
            return "<h1>{$h1}</h1>"; 
        } 
 
        return ""; 
    } 
 
    private function getTitleStr($urlStr) 
    { 
        // 2014.06.24 update : main-category, itemコントローラは個別layout内で解決する。 
//        $obj = new BaseLibraryModel(); 
//        $db = $obj->dbConnection(); 
        if (strpos($urlStr, '?')) { 
            $urlStr = substr($urlStr, 0, strpos($urlStr, '?')); 
        } 
        if (substr($urlStr, 0, 1) == "/") { 
            $urlStr = substr($urlStr, 1); 
        } 
        $h1_comment = ""; 
        $tmpArray = array(); 
        $tmpArrays = preg_split("(\/)", $urlStr); 
//        if ($tmpArrays[2] != "") { 
//            include FRONT_PATH . "an_ct/" . $tmpArray[1] . "/" . $tmpArray[2] . ".inc"; 
//            $h1_comment = $this->displayText($data['category_data']['category_h1_tag'] != "" ? $data['category_data']['category_h1_tag'] : ""); 
//        } elseif ($tmpArrays[1] != "") { 
//            include FRONT_PATH . "an_mc/" . $tmpArray[1] . ".inc"; 
//            $h1_comment = $this->displayText($data['main_h1_tag'] != "" ? $data['main_h1_tag'] : ""); 
//        } 
 
        if (substr($urlStr, 0, 1) == "/") { 
//            $urlStr = substr($urlStr, 1, mb_strlen($urlStr)); 
        } 
        if (trim($h1_comment) == "") { 
            $tmpArray['index'] = "ユニフォームのプリント専門店 UniformTownへようこそ"; 
            $tmpArray['sitemap'] = "サイトマップ"; 
            $tmpArray['sitemap/detail'] = "商品カテゴリ別サイトマップ"; 
            $tmpArray['guide'] = "ユニフォームタウンを初めてご利用になられる方へ"; 
            $tmpArray['print'] = "ユニフォームタウンの加工サービスについて"; 
            $tmpArray['sample-order'] = "ユニフォームタウンのカタログ請求ページです。"; 
            $tmpArray['mail'] = "メール問い合わせ"; 
            $tmpArray['estimate'] = "ユニフォームタウンの見積りシミュレーション"; 
            $tmpArray['login'] = "ユニフォームタウンのログインページ"; 
            $tmpArray['login/sendinfo'] = "パスワードを忘れた方はこのページでお手続きをお願いします。"; 
            $tmpArray['regi/thanks'] = "ユニフォームタウンの会員登録完了"; 
            $tmpArray['regi'] = "ユニフォームタウンの会員登録"; 
            $tmpArray['mypage/mhistory'] = "ユニフォームタウンでご購入いただいた履歴です"; 
            $tmpArray['mypage/chistory'] = "ユニフォームタウンでサンプルのご請求頂いた履歴です"; 
            $tmpArray['mypage/history'] = "ユニフォームタウンで購入いただいた履歴です"; 
            $tmpArray['mypage/designlist'] = "デザインシミュレーションしていただいた履歴です"; 
            $tmpArray['mypage/contact'] = "デザインデータの送付、領収書の発行などができます"; 
            $tmpArray['mypage/update'] = "ユニフォームタウンの登録情報を更新できるページです"; 
            $tmpArray['mypage/mylist'] = "いらっしゃいませ。ここは、お客様専用のマイページです。"; 
            $tmpArray['mypage/yoyaku'] = "いらっしゃいませ。ここは、お客様専用のマイページです。"; 
            $tmpArray['mypage'] = "いらっしゃいませ。ここは、お客様専用のマイページです。"; 
            $tmpArray['samplecart'] = "ユニフォームタウンのサンプル商品ショッピングカートページです。"; 
            $tmpArray['samplecheck'] = "ユニフォームタウンでのサンプル申込み内容をご確認ください。"; 
            $tmpArray['item/by-product'] = "ユニフォームタウン - すべての商品"; 
            $tmpArray['company/'] = "ユニフォームタウンの会社案内のページです。"; 
            $tmpArray['company/showroom'] = "ショールームのご案内"; 
            $tmpArray['company/use'] = "ユニフォームタウンをご利用するにあたっての環境について"; 
            $tmpArray['company/agree/'] = "利用規約|ユニフォームの通販・プリント専門店 UniformTown"; 
            $tmpArray['company/privacy'] = "ユニフォームタウンでの個人情報の保護方針と取扱いについて"; 
            $tmpArray['company/law'] = "ユニフォームタウンの特定商取引法に基づく通販の表記ページです。"; 
            $tmpArray['company/access'] = "ユニフォームタウンのショップ・アクセスへのページです。"; 
            $tmpArray['company/china-factory'] = "ランドマークの中国工場"; 
            $tmpArray['mail/backnumber'] = "バックナンバー"; 
            $tmpArray['company/link'] = "ユニフォームタウンの相互リンク"; 
            $tmpArray['company/link-detail'] = "相互リンク"; 
            $tmpArray['company/link-form'] = "相互リンクお申し込みフォーム"; 
            $tmpArray['company/idea'] = "ご意見・ご要望をお聞かせください"; 
            $tmpArray['company/recruit'] = "ユニフォームタウンの求人情報のページです。"; 
            $tmpArray['company/dictionary'] = "ユニフォームタウンの用語集のページです。"; 
            $strArray = $tmpArray; 
            foreach ($tmpArray as $key => $value) { 
                $tmpAry = preg_split("(\/)", $key); 
                if ($urlStr == $key) { 
                    $h1_comment = $strArray[$key]; 
                } elseif (strstr($urlStr, "print") and $tmpAry[0] == "print") { 
                    $h1_comment = $strArray[$key]; 
                } elseif (strstr($urlStr, "guide") and $tmpAry[0] == "guide") { 
                    $h1_comment = $strArray[$key]; 
                } elseif (strstr($urlStr, "sample-order") and $tmpAry[0] == "sample-order") { 
                    $h1_comment = $strArray[$key]; 
                } elseif ($urlStr == $tmpAry[0] and $h1_comment == "") { 
                    $h1_comment = $strArray[$key]; 
                } 
            } 
//            $obj->closeConnection($db); 
        } 
        if (trim($h1_comment) == "") { 
            if (in_array($urlStr, ['shopping', 'shopping/confirm', 'shopping/checkout', 'shopping/complete', 'shopping/error'])) { 
                $route = str_replace('/', '_', $urlStr); 
                $page = $this->pageRepository->getPageByRoute($route); 
                $h1_comment = "{$this->baseInfo->getShopName()}の{$page->getName()}"; 
            } else { 
                $h1_comment = "ユニフォームのプリント専門店 UniformTownへようこそ"; 
            } 
        } 
        return $h1_comment; 
    } 
 
    public function get_carts_total_quantity() 
    { 
        if ($this->cartService->getCartType() == CartServiceCustomize::CartTypeCatalog) { 
            $catalogOrderList = $this->commonService->GetLmOrderOption(CommonService::Lm_Option_Catalog); 
            $totalQuantity = is_array($catalogOrderList) ? count($catalogOrderList) : 0; 
        } else { 
            $Carts = $this->cartService->getCarts(); 
            $totalQuantity = array_reduce($Carts, function ($total, $Cart) { 
                $total += $Cart->getTotalQuantity(); 
 
                return $total; 
            }, 0); 
        } 
 
        return $totalQuantity; 
    } 
 
    function build_custom_menu($menu_list, $is_top = false) 
    { 
        if (empty($menu_list)) return ''; 
 
        foreach ($menu_list as $menu) { 
            echo '<li class="menu-item ' . (($is_top && !empty($menu->children)) ? ' category-menu ' : '') . ((!empty($menu->children)) ? ' has-child ' : '') . '">'; 
            if (empty($menu->children) && !empty($menu->url)) { 
                echo '<a href="' . htmlentities($menu->url) . '"><span>' . htmlentities($menu->label) . '</span></a>'; 
            } else { 
                echo '<a><span>' . htmlentities($menu->label) . '</span></a>'; 
            } 
 
            if (!empty($menu->children)) { 
                echo '<ul class="category-list">'; 
                echo $this->build_custom_menu($menu->children); 
                echo '</ul>'; 
            } 
            echo '</li>'; 
        } 
    } 
    private function slide_panel_menu($custom_menu, $recentviews, $other_category_path_map = []) 
    { 
        if (empty($recentviews)) { 
            $cookies = $this->RecentGoodsService->getRecentView(); 
            $recentviews = !empty($cookies) ? $this->RecentGoodsService->LM_getRecentViews2($cookies) : array(); 
        } 
        // 
        if (empty($other_category_path_map)) { 
            $other_category_path_map = $this->getDefaultSpOtherCategoryPulldownMap(); 
        } 
        $CFIMG_DOMAIN = "img0.land-mark.biz"; 
 
        $user = $this->security->getUser(); 
        echo '<style> 
        #recentviews .recentviews-item * { 
            max-width: none; 
        } 
        </style>'; 
        echo '<div class="slide-panel-wrapper" data-slide-type="menu" style="display: none;"> 
    <div id="slide-panel-menu" class="slide-panel"> 
                <ul> 
                    <li class="customer-info"> 
                        <span class="youkoso">ようこそ</span><span class="customer_user_name">' . (isset($user) ? $user->getFullName() : 'ゲスト') . '</span><span class="san">さん</span> 
          </li>'; 
        if (empty($custom_menu)) { 
            echo '<li class="menu-item menu-item-label"> 
              <span>カテゴリーから探す</span> 
            </li>'; 
            foreach ($other_category_path_map as $type => $type_data) { 
                echo '<li class="menu-item category-menu has-child">'; 
                echo '<a><span>' . $this->displayText($type_data['group_label']) . '</span></a>'; 
                if (!empty($type_data['map'])) { 
                    echo '<ul class="category-list">'; 
                    foreach ($type_data['map'] as $path => $label) { 
                        echo '<li class="menu-item"><a href="' . LmHelper::display_form_text($path) . '"><span>' . $this->displayText($label) . '</span></a></li>'; 
                    } 
                    echo '</ul>'; 
                } 
                echo '</li>'; 
            } 
        } else { 
            echo '<li class="menu-item menu-item-label"> 
        <span>カテゴリーから探す</span> 
      </li>'; 
            echo $this->build_custom_menu($custom_menu, true); 
        } 
        if (isset($user)) { 
            echo '<li class="menu-item"><a href="/mypage/"><span>マイページ</span></a></li> 
                    <li class="menu-item"><a href="/logout/"><span>ログアウト</span></a></li>'; 
        } else { 
            echo '<li class="menu-item"><a href="/mypage/login/"><span>ログイン</span></a></li> 
                    <li class="menu-item"><a href="/regi/"><span>新規会員登録</span></a></li>'; 
        } 
        $cartCount = $this->get_carts_total_quantity(); 
        echo '<li class="menu-item"><a href="/cart/" data-ajax="false"><span>カートの商品(<b>' . number_format($cartCount) . '</b>点)を見る</span></a></li> 
                    <li class="menu-item recentviews-menu has-child opened"> 
                        <a><span>閲覧履歴</span></a> 
                        <div class="recentviews ajax" style="margin-top:10px;">'; 
 
        echo '<div id="recentviews" style="overflow: hidden; margin: 0;"> 
 
    <div style="margin-left: 0;display:flex;overflow-x:scroll;-webkit-overflow-scrolling: touch;">'; 
        foreach ($recentviews as $item) { 
            echo '<div class="recentviews-item" style="width: 105px; float: left;margin: 0 6px;margin-bottom: 15px;"> 
          <div> 
            <a href="/item/' . $this->displayText($item['item_id']) . '.html"><img class="recommend-images" style="height: auto; display: inline-block; border: 1px solid rgb(204, 204, 204); padding: 0; width: 105px;" src="' . $this->makeImageURL("goods.img", $item['id']) . '" border="0" name="" alt="' . $this->displayText($item['goods_name']) . '"></a> 
          </div> 
          <div style="margin-top: 5px; font-size: 11px;line-height:1.3em;"> 
            <a href="/item/' . $this->displayText($item['item_id']) . '.html">' . $this->displayText($item['goods_name']) . '</a> 
          </div> 
          <div style="font-size: 11px; color: #666;"> 
          <span class="recent_item_price">' . number_format($item['min_gp_price']) . '円(税込)</span> ~ ' . 
          ((isset($item['review']) && $item['review'] > 0) ? ('<div class="recommend-average">' . $item['average_img'] . '<span class="recommend-average-bracket">(</span><span class="recommend-average-point">' . number_format($item['review']) . '</span><span class="recommend-average-bracket">)</span></div>') : '') . '</div></div>'; 
        } 
        echo '</div></div>'; 
 
        echo '</div> 
                    </li> 
                    <li class="menu-item"><a href="/mail/"><span>メール問合せ</span></a></li> 
                    <li class="menu-item"><a href="/cart/add_catalog"><span>カタログ請求する</span></a></li> 
                    <li class="menu-item menu-item-label"><span>ご案内</span></li> 
                    <li class="menu-item"><a href="/sp/pages/guide/"><span>初めての方へ</span></a></li> 
                    <li class="menu-item"><a href="/sp/pages/order/"><span>ご注文方法</span></a></li> 
                    <li class="menu-item"><a href="/guide/print-shurui/"><span>プリント・刺繍について</span></a></li> 
                    <li class="menu-item"><a href="/sp/pages/pay/"><span>お支払い方法</span></a></li> 
                    <li class="menu-item"><a href="/sp/pages/souryou/"><span>送料</span></a></li> 
                    <li class="menu-item"><a href="/sp/pages/nouki/" data-ajax="false"><span>納期</span></a></li> 
                    <li class="menu-item"><a href="/sp/pages/sample/" data-ajax="false"><span>貸出サンプル</span></a></li> 
                    <li class="menu-item"><a href="/sp/pages/oguchi/" data-ajax="false"><span>大口割引</span></a></li> 
                    <li class="menu-item"><a href="/sp/pages/henpin/" data-ajax="false"><span>返品・交換</span></a></li> 
                    <li class="menu-item"><a href="/sp/pages/faq/" data-ajax="false"><span>よくあるご質問</span></a></li> 
                    <li class="menu-item"><a href="/sp/pages/company_profile/" data-ajax="false"><span>会社概要</span></a></li> 
                    <li class="menu-item"><a href="/sp/pages/syozaiti/" data-ajax="false"><span>会社所在地</span></a></li> 
                    <li class="menu-item menu-footer-tel"> 
                        <a href="tel:0120115116"> 
                            <div class="tel-number"><img class="tel-icon" src="https://img0.land-mark.biz/ut_img/public_images/sp/icon_tel.svg" alt="電話"><span>0120-115-116</span></div> 
                            <div class="bussines-hour">(平日 9:00〜18:00)</div> 
                        </a> 
          </li> 
          <li class="menu-footer"> 
                        <ul class="menu-footer-sns"> 
                            <li class="tw"><a href="https://twitter.com/uniformtown" target="_blank" style="background-image: url(https://' . $CFIMG_DOMAIN . '/ut_img/public_images/sp/icon_tw.svg);"></a></li> 
                            <li class="instagram"><a href="https://www.instagram.com/uniformtown/" target="_blank" style="background-image: url(https://' . $CFIMG_DOMAIN . '/ut_img/public_images/sp/icon_instagram.svg);"></a></li> 
                            <li class="fb"><a href="https://www.facebook.com/uniformtown91/" target="_blank" style="background-image: url(https://' . $CFIMG_DOMAIN . '/ut_img/public_images/sp/icon_fb.svg);"></a></li> 
                            <li class="youtube"><a href="https://www.youtube.com/channel/UCkSwlrLc4G-y_35KddreLxQ" target="_blank" style="background-image: url(https://' . $CFIMG_DOMAIN . '/ut_img/public_images/sp/icon_youtube.svg);"></a></li> 
                        </ul> 
                        <button type="button">✕ メニューを閉じる</button> 
                    </li> 
                </ul> 
            </div> 
        </div>'; 
    } 
 
    private function slide_panel_search($data, $custom_frequently_searched_word, $custom_menu, $other_category_path_map, $recentviews) 
    { 
 
        $CFIMG_DOMAIN = "img0.land-mark.biz"; 
 
        echo '<style> 
        .searchpop_result { 
            overflow: hidden; 
            width: 100%; 
            text-align: left; 
        } 
 
        .searchpop_result_thumb { 
            float: left; 
            width: 90px; 
            height: 83px; 
            padding-top: 7px; 
        } 
 
        .searchpop_result_description p { 
            line-height: 1.5; 
        } 
 
        .searchpop_result_description_goodsName { 
            font-weight: bold; 
            font-size: 14px; 
            padding-top: 1px; 
            margin-bottom: 3px !important; 
            height: 18px; 
            overflow: hidden; 
        } 
 
        .searchpop_result_description_goodsDetail { 
            overflow: hidden; 
            height: 1.5rem; 
        } 
    </style>'; 
 
        echo '<div class="slide-panel-wrapper" data-slide-type="search" style="display: none;"> 
      <div id="slide-panel-search" class="slide-panel"> 
        <ul> 
          <li class="search-header"> 
            <span>詳細検索</span> 
          </li> 
          <li id="search-area" class="menu-item"> 
            <div id="search-area-search"> 
              <form method="get" action="/item/searchlist" method="get" accept-charset="UTF-8" id="search_form"> 
                <input type="hidden" name="hantei" value="検索" /> 
                <div> 
                  <div id="search-word-input-wrapper"> 
                    <div id="search-word-input-area"> 
                      <input class="searchpop" id="search_string" name="searchtext" type="text" placeholder="商品名・品番で検索" value="" autocomplete="off"> 
                    </div> 
                    <div><button id="search-button-on-slide-menu"><i class="material-icons">search</i></button></div> 
                  </div> 
                </div> 
              </form> 
            </div>'; 
            //$this->displayText($data['searchtext']); 
            if (!empty($custom_frequently_searched_word)) { 
            echo '<div id="search-area-frequently-searched-words"> 
              <span>▼よく検索されているワード</span> 
              <ul class="word-list">'; 
            foreach ($custom_frequently_searched_word as $search_word) { 
                echo '<li><a href="' . $this->displayText($search_word->url) . '">' . $this->displayText($search_word->label) . '</a></li>'; 
            } 
            echo '</ul></div>'; 
        } 
        echo '</li>'; 
 
        if (empty($custom_menu)) { 
            echo '<li class="menu-item menu-item-label"> 
              <span>カテゴリーから探す</span> 
            </li>'; 
            foreach ($other_category_path_map as $type => $type_data) { 
                echo '<li class="menu-item category-menu has-child">'; 
                echo '<a><span>' . $this->displayText($type_data['group_label']) . '</span></a>'; 
                if (!empty($type_data['map'])) { 
                    echo '<ul class="category-list">'; 
                    foreach ($type_data['map'] as $path => $label) { 
                        echo '<li class="menu-item"><a href="' . LmHelper::display_form_text($path) . '"><span>' . $this->displayText($label) . '</span></a></li>'; 
                    } 
                    echo '</ul>'; 
                } 
                echo '</li>'; 
            } 
        } else { 
            echo '<li class="menu-item menu-item-label"> 
        <span>カテゴリーから探す</span> 
      </li>'; 
            echo $this->build_custom_menu($custom_menu, true); 
        } 
 
        echo '<li class="menu-footer"> 
            <ul class="menu-footer-sns"> 
              <li class="tw"><a href="https://twitter.com/uniformtown" target="_blank" style="background-image: url(https://' . $CFIMG_DOMAIN . '/ut_img/public_images/sp/icon_tw.svg);"></a></li> 
              <li class="instagram"><a href="https://www.instagram.com/uniformtown/" target="_blank" style="background-image: url(https://' . $CFIMG_DOMAIN . '/ut_img/public_images/sp/icon_instagram.svg);"></a></li> 
              <li class="fb"><a href="https://www.facebook.com/uniformtown91/" target="_blank" style="background-image: url(https://' . $CFIMG_DOMAIN . '/ut_img/public_images/sp/icon_fb.svg);"></a></li> 
              <li class="youtube"><a href="https://www.youtube.com/channel/UCkSwlrLc4G-y_35KddreLxQ" target="_blank" style="background-image: url(https://' . $CFIMG_DOMAIN . '/ut_img/public_images/sp/icon_youtube.svg);"></a></li> 
            </ul> 
            <button type="button">✕ メニューを閉じる</button> 
          </li> 
        </ul> 
      </div> 
    </div>'; 
    } 
 
    function makeImageURL($folder, $id) 
    { 
        $filename = substr($id, -1, 1) . "/" . $id . "/main.jpg"; 
 
        $CFIMG_DOMAIN = $this->eccubeConfig['CFIMG_DOMAIN']; 
        $t = $filename; 
 
        $url = "https://" . $CFIMG_DOMAIN . "/"; 
        $ret = $url . $folder . "/" . $filename; 
 
        return $ret; 
    } 
 
    function display_form_text($text) 
    { 
        // //return stripslashes( htmlspecialchars($text,ENT_QUOTES) ); 20100609 
        //return htmlspecialchars($text, ENT_QUOTES, 'UTF-8'); 
        return LmHelper::display_form_text($text); 
    } 
 
    function sashikomi($srcHtml, $vw = 805) 
    { 
        $dstHtml = $srcHtml; 
        // 画像の処理 
        $dstHtml = $this->LM_sashikomi($dstHtml); 
        /* 
        $dstHtml = preg_replace('@(<img[^>]+?src="('.CFIMG_URL.'public_images)/([^\'">\s]+)\.([^\.\'">\s]+)"[\s\S]*?>)@', '<picture><source media="(max-width: 320px)" type="image/webp" srcset="$2_320/$3.webp"><source media="(max-width: 640px)" type="image/webp" srcset="$2_640/$3.webp"><source media="(max-width: 320px)" srcset="$2_320/$3.$4"><source media="(max-width: 640px)" srcset="$2_640/$3.$4"><source type="image/webp" srcset="$2/$3.webp">$1</picture>', $dstHtml); 
        */ 
        // スタイルタグの削除 
        $dstHtml = preg_replace_callback('/<style[\s\S]+?\/style>/', function ($matches) { 
            if (preg_match('/<style[^>]+responsive/', $matches[0])) { 
                return $matches[0]; 
            } else { 
                return ''; 
            } 
        }, $dstHtml); 
        // 特定のインラインスタイルを削除 
        // $dstHtml = preg_replace('/\s*(?:(?:margin|padding)(?:-(?:top|left|bottom|right))?|font-size)\s*:[^;]+;/', '', $dstHtml); 
        // $dstHtml = preg_replace('/(style="[^">]*)(?:width)\s*:[^;]+;/', '$1', $dstHtml); 
        // $dstHtml = preg_replace('/(style="[^">]*)(?:height)\s*:[^;]+;/', '$1', $dstHtml); 
        // インラインスタイルでのpx指定は calc() に置換し、デバイスの画面幅を基準に計算させる 
        $dstHtml = preg_replace_callback('/\s*(?:(?:margin|padding)(?:-(?:top|left|bottom|right))?|font-size|top|left|bottom|right)\s*:[^;]+;/', function ($matches) use ($vw) { 
            $dst = $src = $matches[0]; 
            $dst = preg_replace('/-[0-9.]+px/', "0", $dst); 
            $dst = preg_replace('/([0-9.]+)px/', "calc($1 * (100vw / {$vw}))", $dst); 
            return $dst; 
        }, $dstHtml); 
        $dstHtml = preg_replace_callback('/(style="[^">]*)(?:width|height)\s*:[^;]+;/', function ($matches) use ($vw) { 
            return preg_replace('/(width|height)[:\s]+([0-9.-]+)px/', "$1: calc($2 * (100vw / {$vw}))", $matches[0]); 
        }, $dstHtml); 
        // 特定の属性を削除 
        $dstHtml = preg_replace('/ width="?[^"\s>]+"?/', '', $dstHtml); 
        $dstHtml = preg_replace('/ height="?[^"\s>]+"?/', '', $dstHtml); 
        // インライン要素間の余白を詰める 
        $dstHtml = preg_replace('/(\/a>)[\s]+?(<a)/', '$1$2', $dstHtml); 
        // 試しに<br>をSPでも出力してみる 
        // // <br>はSPでは不要 
        // if (!preg_match('@^/sp/owabi/@', $_SERVER['REQUEST_URI'])) // SPのお詫びページのみ<br>を削除せず 
        // $dstHtml = preg_replace('/((?:\s*<br(?:[\s\/]*?)>)+)/', '', $dstHtml); 
        //縮小画像取得エラー時のjsイベント処理 
        $dstHtml = preg_replace('/(\<img)[\s]+/', '$1 onerror="replaceImg(this)"', $dstHtml); 
        // 
        $dstHtml = $this->goodsPriceService->embedGoodsPrice($dstHtml); 
 
        echo $dstHtml; 
    } 
 
    public function display_item_pulldown() 
    { 
        $base_link = preg_replace('!/*(?:\?.+)?$!', '', $_SERVER['REQUEST_URI']); 
 
        $display_item_count_list = $this->commonService->GetYaml('DisplayItem.yaml'); 
 
        /** 
         * 表示件数プルダウン 
         */ 
        $order_type_param = isset($_GET['type']) ? 'type=' . (int)$_GET['type'] . '&' : ''; 
        $display_count_pulldown = array( 
            (object)array('count' => $display_item_count_list['DISPLAY_ITEM_COUNT']['LOW'], 'label' => $display_item_count_list['DISPLAY_ITEM_COUNT']['LOW'] . '件', 'link' => $base_link . "/?{$order_type_param}disp=" . $display_item_count_list['DISPLAY_ITEM_COUNT']['LOW'], 'selected' => false), 
            (object)array('count' => $display_item_count_list['DISPLAY_ITEM_COUNT']['MEDIUM'], 'label' => $display_item_count_list['DISPLAY_ITEM_COUNT']['MEDIUM'] . '件', 'link' => $base_link . "/?{$order_type_param}disp=" . self::DISPLAY_ITEM_COUNT_MID, 'selected' => false), 
            (object)array('count' => $display_item_count_list['DISPLAY_ITEM_COUNT']['HIGH'], 'label' => $display_item_count_list['DISPLAY_ITEM_COUNT']['HIGH'] . '件', 'link' => $base_link . "/?{$order_type_param}disp=" . $display_item_count_list['DISPLAY_ITEM_COUNT']['HIGH'], 'selected' => false), 
        ); 
 
        // 表示件数プルダウン選択処理 
        if (isset($_SESSION['display_max'])) { 
            switch ((int)$_SESSION['display_max']) { 
                case $display_item_count_list['DISPLAY_ITEM_COUNT']['LOW']: 
                    $display_count_pulldown[0]->selected = true; 
                    break; 
                case $display_item_count_list['DISPLAY_ITEM_COUNT']['MEDIUM']: 
                    $display_count_pulldown[1]->selected = true; 
                    break; 
                case $display_item_count_list['DISPLAY_ITEM_COUNT']['HIGH']: 
                    $display_count_pulldown[2]->selected = true; 
                    break; 
                default: 
                    $display_count_pulldown[1]->selected = true; 
                    break; 
            } 
        } else { 
            if (isset($_GET['disp'])) { 
                switch ((int)$_GET['disp']) { 
                    case $display_item_count_list['DISPLAY_ITEM_COUNT']['LOW']: 
                        $display_count_pulldown[0]->selected = true; 
                        break; 
                    case $display_item_count_list['DISPLAY_ITEM_COUNT']['MEDIUM']: 
                        $display_count_pulldown[1]->selected = true; 
                        break; 
                    case $display_item_count_list['DISPLAY_ITEM_COUNT']['HIGH']: 
                        $display_count_pulldown[2]->selected = true; 
                        break; 
                    default: 
                        $display_count_pulldown[1]->selected = true; 
                        break; 
                } 
            } else { 
                foreach ($display_count_pulldown as $option) { 
                    if ($option->count === $display_item_count_list['DISPLAY_ITEM_COUNT_DEFAULT']) $option->selected = true; 
                } 
            } 
        } 
 
        return $display_count_pulldown; 
    } 
 
    /** 
     * Decode JSON string in Twig templates. 
     * Returns associative array on success, otherwise empty array. 
     * 
     * @param mixed $value 
     * @return array 
     */ 
    public function twigJsonDecode($value) 
    { 
        if (is_array($value)) { 
            return $value; 
        } 
        if (!is_string($value) || $value === '') { 
            return []; 
        } 
        $decoded = json_decode($value, true); 
        return (json_last_error() === JSON_ERROR_NONE && is_array($decoded)) ? $decoded : []; 
    } 
 
    public function display_order_pulldown($useRecommendedItemOrder) 
    { 
        $base_link = preg_replace('!/*(?:\?.+)?$!', '', $_SERVER['REQUEST_URI']); 
 
        $display_order_list = $this->commonService->GetYaml('DisplayOrder.yaml')['DISPLAY_ORDER_ITEM']; 
 
        /** 
         * 表示順プルダウン 
         */ 
        $display_count_param = isset($_GET['disp']) ? '&disp=' . (int)$_GET['disp'] : ''; 
        $display_order_pulldown = array( 
            (object)array('label' => $display_order_list[0], 'link' => $base_link . '/?type=6' . $display_count_param, 'selected' => false), 
            (object)array('label' => $display_order_list[1], 'link' => $base_link . '/?type=0' . $display_count_param, 'selected' => false), 
            (object)array('label' => $display_order_list[2], 'link' => $base_link . '/?type=5' . $display_count_param, 'selected' => false), 
            (object)array('label' => $display_order_list[3], 'link' => $base_link . '/?type=1' . $display_count_param, 'selected' => false), 
            (object)array('label' => $display_order_list[4], 'link' => $base_link . '/?type=3' . $display_count_param, 'selected' => false), 
        ); 
 
        // 表示順プルダウン選択処理 
        //$order_param = ''; 
        if (isset($_SESSION['order_type'])) { 
            switch ((int)$_SESSION['order_type']) { 
                case 0: 
                    $display_order_pulldown[1]->selected = true; 
                    break; 
                case 1: 
                    $display_order_pulldown[3]->selected = true; 
                    break; 
                case 3: 
                    $display_order_pulldown[4]->selected = true; 
                    break; 
                case 5: 
                    $display_order_pulldown[2]->selected = true; 
                    break; 
                case 6: 
                    $display_order_pulldown[0]->selected = true; 
                    break; 
                default: 
                    break; 
            } 
        } else { 
            if (isset($_GET['type'])) { 
                switch ((int)$_GET['type']) { 
                    case 0: 
                        $display_order_pulldown[1]->selected = true; 
                        break; 
                    case 1: 
                        $display_order_pulldown[3]->selected = true; 
                        break; 
                    case 3: 
                        $display_order_pulldown[4]->selected = true; 
                        break; 
                    case 5: 
                        $display_order_pulldown[2]->selected = true; 
                        break; 
                    case 6: 
                        $display_order_pulldown[0]->selected = true; 
                        break; 
                    default: 
                        break; 
                } 
            } 
        } 
 
        // おすすめ順が無効なときはプルダウンから外す 
        if (!$useRecommendedItemOrder) array_shift($display_order_pulldown); 
 
        return $display_order_pulldown; 
    } 
 
    public function getSessionData() 
    { 
        return $_SESSION; 
    } 
 
    /** 
     * @param GoodsWithRelated $goods 
     * @return string 
     */ 
    public function renderGoodsLabelList(GoodsWithRelated $goods) 
    { 
        // 
        $labelList = $goods->getLabelList(); 
        // 
        return $this->twig->render('Item/Parts/goods_label_list.twig', [ 
            'labelList' => $labelList, 
        ]); 
    } 
 
    public function renderProductItem($item_data, $useCache, $average, $col_count, $vendingStatusMap = []) 
    { 
        // TODO: CFIMG_URL, BACKIMG_URLの変更 
        $CFIMG_URL = 'https://img0.land-mark.biz/ut_img/'; 
 
        $CATEGORY_LIST_ICON_ID_NO_SHOW = 0;        // アイコンなし 
        $CATEGORY_LIST_ICON_ID_SS = 1;        // 春夏 
        $CATEGORY_LIST_ICON_ID_AW = 2;        // 秋冬 
        $CATEGORY_LIST_ICON_ID_ALL = 3;        // 通年 
        $CATEGORY_LIST_ICON_ID_BOUKAN = 4;        // 防寒 
 
        // ジェンダーマップ 
        $GENDER_ICON_MAP = array( 
            1 => array('label' => '男性用', 'class' => 'goods-icon-male'), 
            2 => array('label' => '女性用', 'class' => 'goods-icon-female'), 
            3 => array('label' => '男女兼用', 'class' => 'goods-icon-unisex'), 
            4 => array('label' => '子供用', 'class' => 'goods-icon-kids') 
        ); 
 
        // アイコンマップ 
        $CATEGORY_LIST_ICON_MAP = array( 
            $CATEGORY_LIST_ICON_ID_SS => array('label' => '春夏', 'class' => 'goods-icon-ss'), 
            $CATEGORY_LIST_ICON_ID_AW => array('label' => '秋冬', 'class' => 'goods-icon-aw'), 
            $CATEGORY_LIST_ICON_ID_ALL => array('label' => '通年', 'class' => 'goods-icon-all'), 
            $CATEGORY_LIST_ICON_ID_BOUKAN => array('label' => '防寒', 'class' => 'goods-icon-boukan') 
        ); 
 
        $color_tip_max = 30; 
        $color_tip_break_at = $color_tip_max / 2; 
 
        // アイコン 
        if ( 
            (int)$item_data['goods_target_gender'] !== 0 || 
            // (int)$item_data['color_count'] !== 0 || 
            (int)$item_data['goods_category_list_icon_id'] !== $CATEGORY_LIST_ICON_ID_NO_SHOW 
        ) { 
            echo '<div class="goods-icon-wrapper"><ul>'; 
 
            if (isset($GENDER_ICON_MAP[$item_data['goods_target_gender']])) { 
                echo '<li class="' . $GENDER_ICON_MAP[$item_data['goods_target_gender']]['class'] . '">' . $GENDER_ICON_MAP[$item_data['goods_target_gender']]['label'] . '</li>'; 
            } 
           if ((int)$item_data['color_count'] !== 0) { 
               echo '<li class="goods-icon goods-icon-color">' . $item_data['color_count'] . '色</li>'; 
           } 
            if (isset($CATEGORY_LIST_ICON_MAP[$item_data['goods_category_list_icon_id']])) { 
                echo '<li class="' . $CATEGORY_LIST_ICON_MAP[$item_data['goods_category_list_icon_id']]['class'] . '">' . $CATEGORY_LIST_ICON_MAP[$item_data['goods_category_list_icon_id']]['label'] . '</li>'; 
            } 
            echo '</ul></div>'; 
        } 
 
        // // カラーチップ 
        echo '<div class="item-color-tip"><ul>'; 
        foreach ($item_data['color_list'] as $color_idx => $rgb) { 
            if ($color_idx === $color_tip_max) break; 
            if ($color_idx !== 0 && ($color_idx) % $color_tip_break_at === 0) { 
                echo '</ul><ul>'; 
            } 
            echo '<li style="background-color: ' . $rgb . ';"></li>'; 
        } 
        echo '</ul></div>'; 
 
        $goods_name_with_vending_status = $this->getGoodsNameWithVendingStatusTo($item_data, $vendingStatusMap); 
        echo '<div class="gcont2"><div class="gname cat-list"><h3>'; 
        echo $this->displayText(!empty($goods_name_with_vending_status) ? $goods_name_with_vending_status : $item_data['goods_name']); 
        echo '<span> </span></h3></div>'; 
 
        echo '<div class="item-info"> 
                    <table> 
                        <tr class="item-info-kataban"> 
                            <th><span>商品番号:</span></th><td><span>' . $this->displayText($item_data['kataban']) . '</span></td> 
                        </tr>'; 
//var_dump($item_data); 
//        if (!$useCache) { 
        if ($item_data['teika']) { 
            echo '<tr class="item-info-list-price"> 
                            <th><span>定価:</span></th>'; 
            echo '<td><span>' . number_format($item_data['teika']) . '</span><span>円 (税込)</span></td>'; 
            echo '</tr>'; 
        } else  { 
            echo '<tr class="item-info-list-price"> 
                            <th></th>'; 
            echo '<td></td>'; 
            echo '</tr>'; 
        } 
            echo '            <tr class="item-info-price"> 
                            <th><span>売価:</span></th> 
                            <td><span style="font-size:24px;">' . number_format($item_data['price']*1.10) . '</span><span>円(税込)</span></td></tr>'; 
/*        } else { 
            echo '<tr class="item-info-list-price"> 
                            <th><span>定価:</span></th> 
                            <td><span class="gprice_teika fbt-lazy"></span></td> 
                        </tr> 
                        <tr class="item-info-price"> 
                            <th><span>売価:</span></th> 
                            <td><span class="gprice fbt-lazy price"></span><span class="yen_txt">円 (税込)</span></td> 
                        </tr>'; 
        }*/ 
        echo '</table></div>'; 
 
        echo '<div class="gtest">'; 
        if (!empty($item_data['average'])) { 
            $average_for_image = (int)($item_data['average'] * 2) / 2; 
            echo '<div class="item-review-star"> 
        <img alt="お客様からの口コミレビュー評価の星の数' . $average_for_image . '" src="' . $CFIMG_URL . 'public_images/review/star_m' . ($average_for_image * 10) . '.gif"><span class="item-review-star-average"></span><span class="item-review-star-review-count">(' . $item_data['review_count'] . '<span class="item-review-star-review-count-unit"></span>)</span> 
      </div>'; 
        } 
 
        if ($item_data['goods_caption'] != "") { 
            echo '<p class="item-caption">' . mb_eregi_replace(" ", "", $item_data['goods_caption']) . '<span> </span></p>'; 
        } 
        echo '</div><!-- /.gtest -->'; 
 
        echo '</div>'; 
    } 
 
    public function getGoodsNameWithVendingStatusTo($goods_data, $vendingStatusMap) 
    { 
        if (!isset($goods_data['goods_id']) || !isset($goods_data['goods_name'])) return null; 
 
        $VENDING_STATUS_MAP = $vendingStatusMap; 
 
        $GOODS_VENDING_STATUS_IS_VENDING = 1;    // 販売中 
        $GOODS_VENDING_STATUS_IS_SOLD_OUT = 2;    // 完売 
        $GOODS_VENDING_STATUS_IS_DISCONTINUED = 3;    // 廃番 
        $GOODS_VENDING_STATUS_EXCLUDE_MANUFACTURER_STOCK = 4; // メーカー在庫連携除外(バートルのみ対応) 
        $GOODS_VENDING_STATUS_LABEL_MAP = [ 
            $GOODS_VENDING_STATUS_IS_VENDING => '販売継続中', 
            $GOODS_VENDING_STATUS_IS_SOLD_OUT => '完売', 
            $GOODS_VENDING_STATUS_IS_DISCONTINUED => '廃番', 
            $GOODS_VENDING_STATUS_EXCLUDE_MANUFACTURER_STOCK => 'メーカー在庫連携除外(バートルのみ対応)' 
        ]; 
 
        // キャッシュがなければ生成 
        if (empty($VENDING_STATUS_MAP)) { 
            // 
            $rows = $this->getGoodsVendingStatusListCache(); 
 
            // 
            foreach ($rows as $row) { 
                $VENDING_STATUS_MAP[(int)$row['goods_id']] = (int)$row['goods_vending_status']; 
            } 
        } 
 
        $vending_status = $VENDING_STATUS_MAP[(int)$goods_data['goods_id']] ?? null; 
        $prefix = ''; 
 
        if (empty($vending_status)) { 
            $createNewFlg = true; 
            $this->GoodsService->getGoodsVendingStatusMap($createNewFlg); 
        } 
 
        switch ($vending_status) { 
            case $GOODS_VENDING_STATUS_IS_SOLD_OUT: 
                $prefix = '[' . $GOODS_VENDING_STATUS_LABEL_MAP[$GOODS_VENDING_STATUS_IS_SOLD_OUT] . '] '; 
                break; 
 
            case $GOODS_VENDING_STATUS_IS_DISCONTINUED: 
                $prefix = '[' . $GOODS_VENDING_STATUS_LABEL_MAP[$GOODS_VENDING_STATUS_IS_DISCONTINUED] . '] '; 
                break; 
        } 
 
        $goods_data['goods_name'] = $prefix . $goods_data['goods_name']; 
        if (isset($goods_data['goods_new_name'])) $goods_data['goods_new_name'] = $prefix . $goods_data['goods_new_name']; 
 
        return $goods_data['goods_name']; 
    } 
 
    public function getGoodsVendingStatusListCache() 
    { 
        if (file_exists($filename = 'files/goods/goods_vending_status_list.json')) { 
            $json = file_get_contents($filename); 
            $goodsVendingStatusList = json_decode($json); 
        } else { 
            $goodsVendingStatusList = $this->dynamicConverter->getGoodsVendingStatusList(); 
        } 
        return $goodsVendingStatusList; 
    } 
 
    function lm_category_filter($mcName, $categoryData, $data, $items, $subCategoryList, $canonicalSubCategoryList, $leftmenuForCategoryData, $canonicalMcName, $ctName) 
    { 
        $BACK_URL = $this->eccubeConfig['BACK_URL']; 
 
//        if ($categoryData == null) { 
//            $data = $data; 
//        } else { 
//            // TODO: とりあえずコメントアウト 
//             $data = $categoryData['main_category']; 
//            return null; 
//        } 
 
        // SEO用のキーワード設定 
//        if (in_array($data['main_category_name'], array("作業服・作業着", "作業服バートル", "医療白衣", "エプロン", "防寒服", "スタッフジャンパー", "メディカルウェア", "エステユニフォーム"))) { 
//            $seoKeyword = ""; 
//        } else { 
//            $seoKeyword = $data['main_category_name'] . " "; 
//        } 
        for ($i = 1; $i <= count($items); $i++) { 
            $anImgUrl = $this->displayText(str_replace(array('backoffice/', 'main_bsum'), array($BACK_URL, 'main_45x45'), $items[$i - 1]['image'])); 
            $goodsImgUrl = $this->displayText(str_replace(array('backoffice/', 'main_bsum'), array($BACK_URL, 'main_45x45'), $items[$i - 1]['goods_image'])); 
            if ($items[$i - 1]['category_id'] != "coordinate" and $items[$i - 1]['category_id'] != "allitem") { 
                if (isset($leftmenuForCategoryData[$items[$i - 1]['category_id']])) { 
                    echo "<li class=\"sepa\">{$leftmenuForCategoryData[$items[$i - 1]['category_id']]['category_name']}</li><br>"; 
                } 
                if (!empty($subCategoryList[$items[$i - 1]['category_id']])) { 
                    if ($ctName === $subCategoryList[$items[$i - 1]['category_id']]['category_webname']) { 
                        echo '<li style="height: 50x !important; padding: 5px; overflow: hidden;float:none;display:inline-block;vertical-align:top;">'; 
                        echo '<h3><img alt="カテゴリ" style="float: left; margin-right: 5px; vertical-align: middle;" width="32" height="32" onerror="this.src=\'' . $goodsImgUrl . '\'"  src="' . $anImgUrl . '" /><div style="width: 70%; float: left;">' . $this->displayText(str_replace(" ", "", $items[$i - 1]['category_name'])) . $this->displayText("(" . $items[$i - 1]['cnt'] . ")") . '</div></h3></a>'; 
                        echo "</li>"; 
                    } else { 
                        if (!empty($subCategoryList[$items[$i - 1]['category_id']]['category_webname'])) { 
 
                            echo '<li style="height: 50x !important; padding: 5px; overflow: hidden;float:none;display:inline-block;vertical-align:top;"><a href="/' . $canonicalMcName . "/" . $subCategoryList[$items[$i - 1]['category_id']]['category_webname'] . '/">'; 
                            echo '<h3><img alt="カテゴリ" style="float: left; margin-right: 5px; vertical-align: middle;" width="32" height="32" onerror="this.src=\'' . $goodsImgUrl . '\'"  src="' . $anImgUrl . '" /><div style="width: 70%; float: left;">' . $this->displayText(str_replace(" ", "", $items[$i - 1]['category_name'])) . $this->displayText("(" . $items[$i - 1]['cnt'] . ")") . '</div></h3></a>'; 
                            echo "</a></li>"; 
 
                        } elseif (!empty($canonicalSubCategoryList[$items[$i - 1]['category_id']]['category_webname'])) { 
 
                            echo '<li style="height: 50x !important; padding: 5px; overflow: hidden;float:none;display:inline-block;vertical-align:top;"><a href="/' . $canonicalMcName . "/" . $canonicalSubCategoryList[$items[$i - 1]['category_id']]['category_webname'] . '/">'; 
                            echo '<h3><img alt="カテゴリ" style="float: left; margin-right: 5px; vertical-align: middle;" width="32" height="32" onerror="this.src=\'' . $goodsImgUrl . '\'"  src="' . $anImgUrl . '" /><div style="width: 70%; float: left;">' . $this->displayText(str_replace(" ", "", $items[$i - 1]['category_name'])) . $this->displayText("(" . $items[$i - 1]['cnt'] . ")") . '</div></h3></a>'; 
                            echo "</a></li>"; 
 
                        } 
 
                    } 
                } 
            } 
        } 
    } 
 
    public function custom_parse_url($value) 
    { 
        return parse_url($value, PHP_URL_QUERY); 
    } 
 
    public function echoImageURL($imgUrl) 
    { 
        $IMG_HOST_NAME = $this->eccubeConfig['IMG_HOST_NAME']; 
        $CFIMG_DOMAIN = $this->eccubeConfig['CFIMG_DOMAIN']; 
        $CFIMG_URL = $this->eccubeConfig['CFIMG_URL']; 
 
        $imgUrl = "{$CFIMG_URL}/{$imgUrl}"; 
 
        //ドメインが「www.l-m.co.jp」 or 「images.l-m.co.jp」の場合 
        if (strpos($imgUrl, "images.l-m.co.jp") !== false or strpos($imgUrl, $IMG_HOST_NAME) !== false) { 
 
            //ドメインが「www.l-m.co.jp」の場合 
            if (strpos($imgUrl, $IMG_HOST_NAME) !== false) { 
 
                //httpsの時、httpへ変換 
                if (!((isset($_SERVER['HTTPS']) and $_SERVER['HTTPS'] == "on") or $_SERVER['HTTP_X_FORWARDED_PROTO'] == "https")) { 
                    $newImgUrl = str_replace("https://", "http://", $imgUrl); 
                } else { 
 
                    //httpの時、「images.l-m.co.jp」へ変換 
                    $newImgUrl = str_replace($IMG_HOST_NAME, "images.l-m.co.jp", $imgUrl); 
                } 
 
                //ドメインが「images.l-m.co.jp」の場合 
            } elseif (strpos($imgUrl, "images.l-m.co.jp") !== false) { 
 
                //httpsの時、httpへ変換 
                if (!((isset($_SERVER['HTTPS']) and $_SERVER['HTTPS'] == "on") or $_SERVER['HTTP_X_FORWARDED_PROTO'] == "https")) { 
                    $newImgUrl = str_replace("https://", "http://", $imgUrl); 
                } else { 
                    $newImgUrl = $imgUrl; 
                } 
            } 
            return $imgUrl; 
        } else { 
            $newImgUrl = $imgUrl; 
 
            //相対パスの場合 
            if (strstr($imgUrl, "images") !== false and strstr($imgUrl, "public") === false) { 
                $strurl = strstr($imgUrl, "images"); 
                $imgUrl = "https://" . $CFIMG_DOMAIN . "/ut_img/" . str_replace("images", "public_images", $strurl); 
            } 
 
            return $imgUrl; 
        } 
    } 
    public function echoVirtualImages($imgUrl) 
    { 
        $IMG_HOST_NAME = $this->eccubeConfig['IMG_HOST_NAME']; 
        $CFIMG_DOMAIN = $this->eccubeConfig['CFIMG_DOMAIN']; 
        $CFIMG_URL = $this->eccubeConfig['CFIMG_URL']; 
 
        $imgUrl = "{$CFIMG_URL}/{$imgUrl}"; 
 
        if (strstr($imgUrl, "images") !== false and strstr($imgUrl, "virtual_images") === false) { 
            $strurl = strstr($imgUrl, "images"); 
            $imgUrl = "https://" . $CFIMG_DOMAIN . "/ut_img/" . str_replace("images", "virtual_images", $strurl); 
        } 
 
        return $imgUrl; 
    } 
 
    public function get_updated_at() 
    { 
        $week_day_list = array('日', '月', '火', '水', '木', '金', '土'); 
        return sprintf('%s (%s)%d時%d分', date('Y年n月j日'), $week_day_list[date('w')], date('H'), date('i')); 
    } 
 
    public function LM_displaySashikomi_detailGoods($data, $noEcho = false) 
    { 
        if ($data['goods_top_sashikomi'] != "") { 
            $sashikomi_top = $this->replaceItemImageRoot($data['goods_top_sashikomi']); 
            if ($noEcho) return $sashikomi_top; 
            echo $sashikomi_top; 
        } elseif ($data['goods_top_html'] != "") { 
            if (file_exists("files/insert/" . $data['goods_top_html'])) { 
                $file = implode("", file("files/insert/" . $data['goods_top_html'])); 
                $file = str_replace("</BODY>", "</body>", str_replace("<BODY>", "<body>", $file)); 
                $tmp = explode("<body>", $file); 
                if (count($tmp) > 1) { 
                    $tmp = explode("</body>", $tmp[1]); 
                } else { 
                    $tmp = explode("</body>", $tmp[0]); 
                } 
                $tmp = $tmp[0]; 
                $tmp = $this->replaceItemImageRoot($tmp); 
                if ($noEcho) return "<div style='line-height:5px'></div>" . $tmp; 
                echo "<div style='line-height:5px'></div>" . $tmp; 
            } 
        } 
 
        echo ""; 
    } 
 
    function LM_insertFile($data) 
    { 
        if ($data['goods_bottom_sashikomi'] != "") { 
            echo $this->replaceItemImageRoot($data['goods_bottom_sashikomi']); 
        } elseif ($data['goods_html'] != "") { 
            if (file_exists("files/insert/" . $data['goods_html'])) { 
                $file = implode("", file("files/insert/" . $data['goods_html'])); 
                $file = str_replace("</BODY>", "</body>", str_replace("<BODY>", "<body>", $file)); 
                $tmp = explode("<body>", $file); 
                if (count($tmp) > 1) { 
                    $tmp = explode("</body>", $tmp[1]); 
                } else { 
                    $tmp = explode("</body>", $tmp[0]); 
                } 
                $tmp = $tmp[0]; 
                $tmp = $this->replaceItemImageRoot($tmp); 
                echo $tmp; 
            } 
        } 
    } 
 
    public function createGetParamater($moji = "?", $expect = "", $and = "&", $equal = "=") 
    { 
        $getVar = $_GET; 
 
        $form = ""; 
        $array = explode(",", $expect); 
        while (!is_null($key = key($getVar))) { 
            if (!in_array($key, $array)) { 
                if ($form != "") { 
                    //$form .= $and . $key . $equal . urlencode( LmHelper::display_form_text($getVar[$key]) ); 20110104 /の変換処理修正 
                    $form .= $and . $key . $equal . str_replace("%2F", "%252F", urlencode(LmHelper::display_form_text($getVar[$key]))); 
                    urlencode($getVar[$key]); 
                } else { 
                    //$form = $moji . $key . $equal . urlencode( LmHelper::display_form_text($getVar[$key]) ); 20110104 /の変換処理修正 
                    $form = $moji . $key . $equal . str_replace("%2F", "%252F", urlencode(LmHelper::display_form_text($getVar[$key]))); 
                } 
            } 
            next($getVar); 
        } 
        return $form; 
    } 
 
    public function LM_displayTogetherBuyDetail_new3($id, $is_secret = true, $count = false) 
    { 
        $rs = $this->dynamicConverter->getGoodsLinkSelect($id, $is_secret, $count); 
        $result = array(); 
        if (isset($rs)) { 
            foreach ($rs as $row) { 
                $goodsId = $row['goods_id']; 
                $result[$goodsId] = $row; 
                $average = $this->dynamicConverter->getReviewAverage($goodsId); 
                $average = (!empty($average[$row['goods_id']])) ? $average[$row['goods_id']] : 0; 
                $image_name = (int)($average * 2) / 2 * 10; 
                $result[$goodsId]['average'] = $average; 
                $result[$goodsId]['average_img'] = "<img class=\"history-average-img\" alt=\"お客様からの口コミレビュー評価の星の数{$average}\" src=\"/images/review/star_m{$image_name}.gif\">"; 
                //$tempRow = $this->dynamicConverter->getReview($id, $is_secret); 
                //$result[$goodsId]['review_count'] = count($tempRow); 
                $result[$goodsId]['img'] = $this->makeImageURL("goods.img", $goodsId); 
            } 
        } 
 
        return $result; 
    } 
 
    /** 
     * Use this instead of `include 'Common/hoge.twig'`. 
     * 
     * @param string $hoge 
     * @param string|null $piyo 
     * @return string 
     * @throws \Twig\Error\LoaderError 
     * @throws \Twig\Error\RuntimeError 
     * @throws \Twig\Error\SyntaxError 
     */ 
    function hoge(string $hoge, string $piyo = null) 
    { 
        // 
        $route = $this->request->get('_route'); 
        $url = $this->request->getPathInfo(); 
        // 
        $context = compact('hoge', 'piyo', 'route', 'url'); 
        // 
        return $this->twig->render('Common/hoge.twig', $context); 
    } 
 
    public function getCommonContentsMap() 
    { 
        $common_contents_map = $this->dynamicConverter->getCommonContentsMap($this->eccubeConfig['CommonContents']['SITE_TYPE_UT'], $this->eccubeConfig['CommonContents']['DEVICE_TYPE_SP'], $this->eccubeConfig['CommonContents']['IS_NOT_SUPER_CATEGORY_ID']); 
 
        $common_header_contents_all = ''; 
        $common_header_contents = ''; 
        $uri = $_SERVER['REQUEST_URI']; 
        $webname = trim($uri, '/'); 
 
        if (isset($common_contents_map[$this->eccubeConfig['CommonContents']['PAGE_TYPE_ALL']][$this->eccubeConfig['CommonContents']['POSITION_HEADER']])) { 
            $common_header_contents_all = $common_contents_map[$this->eccubeConfig['CommonContents']['PAGE_TYPE_ALL']][$this->eccubeConfig['CommonContents']['POSITION_HEADER']]; 
        } 
 
        if ($uri == '/' && isset($common_contents_map[$this->eccubeConfig['CommonContents']['PAGE_TYPE_TOP']][$this->eccubeConfig['CommonContents']['POSITION_HEADER']])) { 
            $common_header_contents = $common_contents_map[$this->eccubeConfig['CommonContents']['PAGE_TYPE_TOP']][$this->eccubeConfig['CommonContents']['POSITION_HEADER']]; 
        } 
        else if (isset($common_contents_map[$this->eccubeConfig['CommonContents']['PAGE_TYPE_SUPER_CATEGORY']][$this->eccubeConfig['CommonContents']['POSITION_HEADER']][$webname])) { 
            $common_header_contents = $common_contents_map[$this->eccubeConfig['CommonContents']['PAGE_TYPE_SUPER_CATEGORY']][$this->eccubeConfig['CommonContents']['POSITION_HEADER']][$webname]; 
        } 
 
        return [ 
            'common_header_contents_all' => $common_header_contents_all, 
            'common_header_contents' => $common_header_contents 
        ]; 
    } 
 
    public function getCalendarInfo() 
    { 
        $week_array = explode(",", "7,1,2,3,4,5,6"); 
        //現在月を判別 
        $now_array = explode("-", date("Y-m-d")); 
        //翌月を表示する 
        $now_array = array_merge($now_array, explode("-", date("Y-m-d", mktime(0, 0, 0, intval($now_array[1]) + 1, 1, intval($now_array[0]))))); 
        //当日日付 
        $today = date("Ymd"); 
        $meyasun_date = 0;    //お届け日の目安フラグ 
 
        $add = 1; 
        if (date("Hi") >= "1200") { 
            $add = 2; 
        } 
        $prefecture = 0; 
        $options = ""; 
 
        //加工 
        $url = "https://www.l-m.co.jp/index/check-holiday?date=" . date("Y-m-d") . "&add=" . $add . "&kakou=1&area=0"; 
        $output = file_get_contents($url); 
        $obj = json_decode($output, true); 
        $date = $obj['result']; 
        $kakou_date = substr($date, 0, 4) . "-" . ltrim(substr($date, 4, 2), 0) . "-" . ltrim(substr($date, 6, 2), 0); 
 
        //無地 
        $url = "https://www.l-m.co.jp/index/check-holiday?date=" . date("Y-m-d") . "&add=" . $add . "&kakou=0&area=0"; 
        $output = file_get_contents($url); 
        $obj = json_decode($output, true); 
        $date = $obj['result']; 
        $muji_date = substr($date, 0, 4) . "-" . ltrim(substr($date, 4, 2), 0) . "-" . ltrim(substr($date, 6, 2), 0); 
 
        return [ 
            'week_array' => $week_array, 
            'now_array' => $now_array, 
            'kakou_date' => $kakou_date, 
            'muji_date' => $muji_date, 
            'today' => $today 
        ]; 
    } 
 
    public function getHolidayInfo($year, $month, $day, $week, $count) 
    { 
        return $this->dynamicConverter->getHolidayInfo(intval($year), intval($month), intval($day), intval($week), intval($count)); 
    } 
 
    /** 
     * カート内の商品のIDを取得する 
     * TODO: 現状、最初の1件のみを取得。 
     * 
     * @return int|void 
     */ 
    protected function getGoodsIdFromCart() 
    { 
        // 
        foreach ($this->cartService->getCarts() as $cart) { 
            foreach ($cart->getCartItems() as $item) { 
                return $item->getProductClass()->getProduct()->getId(); 
            } 
        } 
    } 
 
    public function getYouMayAlsoLike($goodsId = null, $count = false) 
    { 
        // 
        if (($goodsId !== null) || ($goodsId = $this->getGoodsIdFromCart())) { 
            // 
            $displayTogether = $this->reviewService->LM_displayTogetherBuyDetail_new3($goodsId, $count); 
            if (empty($displayTogether)) { 
                return null; 
            } 
            // 
            $context = compact('displayTogether'); 
            // 
            return $this->twig->render('Review/recentview.twig', $context); 
        } 
        // 
        return null; 
    } 
 
    /** 
     * Get count of koe for template 
     * 
     * @return $koe_count 
     */ 
    public function getKoeCount() 
    { 
        $viewCacheKey = $this->lmHelper->getCacheKey('getKoeCount', []); 
        return $this->getCacheByKey($viewCacheKey, function() { 
            $koe_count = $this->dynamicConverter->LM_get_koe_count(); 
            return $koe_count; 
        }); 
    } 
 
    /** 
     * カテゴリページの表示順(order_type)を返す。 
     * 
     * @return int $order_type 表示順 
     */ 
    public function getCategoryOrderType(){ 
        if( !is_null($this->request->get('type')) ){ 
            return (int)$this->request->get('type'); 
        } 
        else { 
            $session = $this->request->getSession(); 
            if( $session->has('order_type') ){ 
                return (int)$session->get('order_type'); 
            } 
        } 
 
        return null; 
    } 
 
    /** 
     * @return bool 
     */ 
    public function isShowSpHeader() 
    { 
        // 
        $_route = $this->request->get('_route'); 
        $cartCount = $this->get_carts_total_quantity(); 
        // 
        if ($_route === 'cart') { 
            // カート(STEP 1) 
            if ($cartCount == 0) { 
                // カート内の商品が1点も無い時だけ表示 
                return true; 
            } else { 
                // 
                return true; 
            } 
        } else if (preg_match('@(?:shopping|estimate)@', $_route)) { 
            // ショッピング(STEP 2-5)、見積シミュは非表示 
            return true; 
        } else { 
            // それ以外はOK 
            return true; 
        } 
    } 
 
    /** 
     * @param Goods $goods 
     * @return string 
     * @throws \Twig\Error\LoaderError 
     * @throws \Twig\Error\RuntimeError 
     * @throws \Twig\Error\SyntaxError 
     */ 
    public function getSizeTable(Goods $goods) 
    { 
        // 
        list($SizeList,$SizePosition) = $this->dynamicConverter->LM_displaySizeMatrix_cross2($goods->getGoodsId()); 
        // 
        return $this->twig->render('Common/SizeTable.twig', compact('goods', 'SizeList', 'SizePosition')); 
    } 
 
    /** 
     * Get campaign flags for a product 
     *  
     * @param int $productId 
     * @return array 
     */ 
    public function getCampaignFlags($productId) 
    { 
        try { 
            $sqlService = new \Lm\Service\Db\SqlService(); 
            $goodsData = $sqlService 
                ->Table('goods_table') 
                ->Where('goods_id = :goods_id') 
                ->Param(':goods_id', $productId) 
                ->Find(); 
             
            if ($goodsData) { 
                return [ 
                    'yoridori' => (int)($goodsData['campaign_yoridori'] ?? 0), 
                    'matome' => (int)($goodsData['campaign_matome'] ?? 0) 
                ]; 
            } 
        } catch (\Throwable $e) { 
            // Skip error 
        } 
         
        return [ 
            'yoridori' => 0, 
            'matome' => 0 
        ]; 
    } 
 
    /** 
     * Get active Matome campaign info for a product (percent and min count) 
     * Only returns data if the product has campaign_matome=1 and there is at least one active Matome campaign. 
     * 
     * @param int $productId 
     * @return array|null [ 'percent' => int, 'min' => int, 'name' => string ] or null if none 
     */ 
    public function getMatomeCampaignInfo($productId) 
    { 
        try { 
            $sqlService = new \Lm\Service\Db\SqlService(); 
            $goods = $sqlService 
                ->Table('goods_table') 
                ->Where('goods_id = :gid') 
                ->Param(':gid', (int)$productId) 
                ->Find(); 
            if (empty($goods) || (int)($goods['campaign_matome'] ?? 0) !== 1) { 
                return null; 
            } 
 
            $now = (new \DateTime())->format('Y-m-d H:i:s'); 
            $campaigns = $sqlService 
                ->Table('campaign_table') 
                ->Where('campaign_ddate IS NULL') 
                ->Where('campaign_type = 2') 
                ->Where('campaign_start <= :now') 
                ->Where('campaign_end >= :now') 
                ->Param(':now', $now) 
                ->FindAll(); 
            if (empty($campaigns)) { 
                return null; 
            } 
            // Pick the campaign with the highest percent 
            $best = null; 
            foreach ($campaigns as $c) { 
                $percent = (float)($c['discount_percent'] ?? 0); 
                $min = (int)($c['min_product_count'] ?? 0); 
                if ($percent <= 0) { continue; } 
                if ($best === null || $percent > $best['percent']) { 
                    $best = [ 
                        'percent' => (int)round($percent), 
                        'min' => $min, 
                        'name' => (string)($c['campaign_name'] ?? ''), 
                    ]; 
                } 
            } 
            return $best; 
        } catch (\Throwable $e) { 
            return null; 
        } 
    } 
 
    /** 
     * Get active Yoridori campaign info for a product 
     * Only returns data if the product has campaign_yoridori=1 and there is at least one active Yoridori campaign. 
     * 
     * @param int $productId 
     * @return array|null [ 'percent' => int, 'name' => string ] or null if none 
     */ 
    public function getYoridoriCampaignInfo($productId) 
    { 
        try { 
            $sqlService = new \Lm\Service\Db\SqlService(); 
            $goods = $sqlService 
                ->Table('goods_table') 
                ->Where('goods_id = :gid') 
                ->Param(':gid', (int)$productId) 
                ->Find(); 
            if (empty($goods) || (int)($goods['campaign_yoridori'] ?? 0) !== 1) { 
                return null; 
            } 
 
            $now = (new \DateTime())->format('Y-m-d H:i:s'); 
            $campaigns = $sqlService 
                ->Table('campaign_table') 
                ->Where('campaign_ddate IS NULL') 
                ->Where('campaign_type = 1') 
                ->Where('campaign_start <= :now') 
                ->Where('campaign_end >= :now') 
                ->Param(':now', $now) 
                ->FindAll(); 
            if (empty($campaigns)) { 
                return null; 
            } 
            // Pick the campaign with the highest percent 
            $best = null; 
            foreach ($campaigns as $c) { 
                $percent = (float)($c['discount_percent'] ?? 0); 
                $min = (int)($c['min_product_count'] ?? 0); 
                if ($percent <= 0) { continue; } 
                if ($best === null || $percent > $best['percent']) { 
                    $best = [ 
                        'percent' => (int)round($percent), 
                        'min' => $min, 
                        'name' => (string)($c['campaign_name'] ?? ''), 
                    ]; 
                } 
            } 
            return $best; 
        } catch (\Throwable $e) { 
            return null; 
        } 
    } 
 
}