src/Eccube/Controller/ProductController.php line 639

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.ec-cube.co.jp/
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Eccube\Controller;
  13. use Eccube\Entity\BaseInfo;
  14. use Eccube\Entity\Category;
  15. use Eccube\Entity\Master\ProductStatus;
  16. use Eccube\Entity\Product;
  17. use Eccube\Entity\CartItem;
  18. use Eccube\Event\EccubeEvents;
  19. use Eccube\Event\EventArgs;
  20. use Eccube\Form\Type\AddCartType;
  21. use Eccube\Form\Type\SearchProductType;
  22. use Eccube\Repository\BaseInfoRepository;
  23. use Eccube\Repository\CustomerFavoriteProductRepository;
  24. use Eccube\Repository\Master\ProductListMaxRepository;
  25. use Eccube\Repository\ProductRepository;
  26. use Eccube\Service\CartService;
  27. use Eccube\Common\Constant;
  28. use Eccube\Helper\PageNameHelper;
  29. use Eccube\Service\PurchaseFlow\PurchaseContext;
  30. use Eccube\Service\PurchaseFlow\PurchaseFlow;
  31. use Knp\Bundle\PaginatorBundle\Pagination\SlidingPagination;
  32. use Knp\Component\Pager\PaginatorInterface;
  33. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  34. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  35. use Symfony\Component\HttpFoundation\Request;
  36. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  37. use Symfony\Component\Routing\Annotation\Route;
  38. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  39. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  40. use Customize\Service\BreadcrumbService;
  41. class ProductController extends AbstractController
  42. {
  43.     /**
  44.      * @var PurchaseFlow
  45.      */
  46.     protected $purchaseFlow;
  47.     /**
  48.      * @var CustomerFavoriteProductRepository
  49.      */
  50.     protected $customerFavoriteProductRepository;
  51.     /**
  52.      * @var CartService
  53.      */
  54.     protected $cartService;
  55.     /**
  56.      * @var ProductRepository
  57.      */
  58.     protected $productRepository;
  59.     /**
  60.      * @var BaseInfo
  61.      */
  62.     protected $BaseInfo;
  63.     /**
  64.      * @var AuthenticationUtils
  65.      */
  66.     protected $helper;
  67.     /**
  68.      * @var ProductListMaxRepository
  69.      */
  70.     protected $productListMaxRepository;
  71.     /**
  72.      * @var PageNameHelper
  73.      */
  74.     protected $pageNameHelper;
  75.     /**
  76.      * @var BreadcrumbService
  77.      */
  78.     protected $breadcrumbService;
  79.     private $title '';
  80.     /**
  81.      * ProductController constructor.
  82.      *
  83.      * @param PurchaseFlow $cartPurchaseFlow
  84.      * @param CustomerFavoriteProductRepository $customerFavoriteProductRepository
  85.      * @param CartService $cartService
  86.      * @param ProductRepository $productRepository
  87.      * @param BaseInfoRepository $baseInfoRepository
  88.      * @param AuthenticationUtils $helper
  89.      * @param ProductListMaxRepository $productListMaxRepository
  90.      * @param PageNameHelper $pageNameHelper
  91.      * @param BreadcrumbService $breadcrumbService
  92.      */
  93.     public function __construct(
  94.         PurchaseFlow $cartPurchaseFlow,
  95.         CustomerFavoriteProductRepository $customerFavoriteProductRepository,
  96.         CartService $cartService,
  97.         ProductRepository $productRepository,
  98.         BaseInfoRepository $baseInfoRepository,
  99.         AuthenticationUtils $helper,
  100.         ProductListMaxRepository $productListMaxRepository,
  101.         PageNameHelper $pageNameHelper,
  102.         BreadcrumbService $breadcrumbService
  103.     ) {
  104.         $this->purchaseFlow $cartPurchaseFlow;
  105.         $this->customerFavoriteProductRepository $customerFavoriteProductRepository;
  106.         $this->cartService $cartService;
  107.         $this->productRepository $productRepository;
  108.         $this->BaseInfo $baseInfoRepository->get();
  109.         $this->helper $helper;
  110.         $this->productListMaxRepository $productListMaxRepository;
  111.         $this->pageNameHelper $pageNameHelper;
  112.         $this->breadcrumbService $breadcrumbService;
  113.     }
  114.     /**
  115.      * 商品一覧画面.
  116.      *
  117.      * @Route("/products/list", name="product_list", methods={"GET"})
  118.      * @Template("Product/list.twig")
  119.      */
  120.     public function index(Request $requestPaginatorInterface $paginator)
  121.     {
  122.         // Doctrine SQLFilter
  123.         if ($this->BaseInfo->isOptionNostockHidden()) {
  124.             $this->entityManager->getFilters()->enable('option_nostock_hidden');
  125.         }
  126.         // handleRequestは空のqueryの場合は無視するため
  127.         if ($request->getMethod() === 'GET') {
  128.             $request->query->set('pageno'$request->query->get('pageno'''));
  129.         }
  130.         // searchForm
  131.         /* @var $builder \Symfony\Component\Form\FormBuilderInterface */
  132.         $builder $this->formFactory->createNamedBuilder(''SearchProductType::class);
  133.         if ($request->getMethod() === 'GET') {
  134.             $builder->setMethod('GET');
  135.         }
  136.         $event = new EventArgs(
  137.             [
  138.                 'builder' => $builder,
  139.             ],
  140.             $request
  141.         );
  142.         $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_PRODUCT_INDEX_INITIALIZE);
  143.         /* @var $searchForm \Symfony\Component\Form\FormInterface */
  144.         $searchForm $builder->getForm();
  145.         $searchForm->handleRequest($request);
  146.         // paginator
  147.         $searchData $searchForm->getData();
  148.         $qb $this->productRepository->getQueryBuilderBySearchData($searchData);
  149.         $event = new EventArgs(
  150.             [
  151.                 'searchData' => $searchData,
  152.                 'qb' => $qb,
  153.             ],
  154.             $request
  155.         );
  156.         $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_PRODUCT_INDEX_SEARCH);
  157.         $searchData $event->getArgument('searchData');
  158.         $query $qb->getQuery()
  159.             ->useResultCache(true$this->eccubeConfig['eccube_result_cache_lifetime_short']);
  160.         /** @var SlidingPagination $pagination */
  161.         $pagination $paginator->paginate(
  162.             $query,
  163.             !empty($searchData['pageno']) ? $searchData['pageno'] : 1,
  164.             !empty($searchData['disp_number']) ? $searchData['disp_number']->getId() : $this->productListMaxRepository->findOneBy([], ['sort_no' => 'ASC'])->getId()
  165.         );
  166.         $ids = [];
  167.         foreach ($pagination as $Product) {
  168.             $ids[] = $Product->getId();
  169.         }
  170.         $ProductsAndClassCategories $this->productRepository->findProductsWithSortedClassCategories($ids'p.id');
  171.         // addCart form
  172.         $forms = [];
  173.         foreach ($pagination as $Product) {
  174.             /* @var $builder \Symfony\Component\Form\FormBuilderInterface */
  175.             $builder $this->formFactory->createNamedBuilder(
  176.                 '',
  177.                 AddCartType::class,
  178.                 null,
  179.                 [
  180.                     'product' => $ProductsAndClassCategories[$Product->getId()],
  181.                     'allow_extra_fields' => true,
  182.                 ]
  183.             );
  184.             $addCartForm $builder->getForm();
  185.             $forms[$Product->getId()] = $addCartForm->createView();
  186.         }
  187.         $Category $searchForm->get('category_id')->getData();
  188.         $FreeArea '';
  189.         $ListProductAttribute null;
  190.         
  191.         // Kiểm tra nếu có sản phẩm trong pagination thì lấy FreeArea từ sản phẩm đầu tiên
  192.         if ($pagination->count() > 0) {
  193.             $firstProduct $pagination->getItems()[0] ?? null;
  194.             if ($firstProduct) {
  195.                 $FreeArea $firstProduct->getFreeArea();
  196.                 if ($FreeArea) {
  197.                     $ListProductAttribute = [];
  198.                     $lines preg_split('/\r\n|\r|\n/'$FreeArea);
  199.                     foreach ($lines as $line) {
  200.                         if (trim($line) === '') continue;
  201.                         $parts explode(':'$line2);
  202.                         if (count($parts) == 2) {
  203.                             $ListProductAttribute[] = [trim($parts[0]), trim($parts[1])];
  204.                         }
  205.                     }
  206.                     if (count($ListProductAttribute) === 0) {
  207.                         $ListProductAttribute null;
  208.                     }
  209.                 }
  210.             }
  211.         }
  212.         
  213.         $categoryId null;
  214.         $prefix null;
  215.         if ($Category !== null) {
  216.             $categoryId $Category->getId();
  217.             if ($categoryId !== null) {
  218.                 $prefix Category::getCategoryPageName($categoryId);
  219.             }
  220.         }
  221.         $pageName $this->pageNameHelper->createPageName($prefix);
  222.         
  223.         // Tạo breadcrumb
  224.         $breadcrumbs $this->breadcrumbService->getProductListBreadcrumb($Category);
  225.     
  226.         return [
  227.             'subtitle' => $this->getPageTitle($searchData),
  228.             'pageName' => $pageName,
  229.             'pagination' => $pagination,
  230.             'search_form' => $searchForm->createView(),
  231.             'forms' => $forms,
  232.             'Category' => $Category,
  233.             'ListProductAttribute' => $ListProductAttribute,
  234.             'FreeArea' => $FreeArea,
  235.             'breadcrumbs' => $breadcrumbs,
  236.         ];
  237.     }
  238.     /**
  239.      * 商品詳細画面.
  240.      *
  241.      * @Route("/products/detail/{id}", name="product_detail", methods={"GET"}, requirements={"id" = "\d+"})
  242.      * @Template("Product/detail.twig")
  243.      * @ParamConverter("Product", options={"repository_method" = "findWithSortedClassCategories"})
  244.      *
  245.      * @param Request $request
  246.      * @param Product $Product
  247.      *
  248.      * @return array
  249.      */
  250.     public function detail(Request $requestProduct $Product)
  251.     {
  252.         if (!$this->checkVisibility($Product)) {
  253.             throw new NotFoundHttpException();
  254.         }
  255.         $builder $this->formFactory->createNamedBuilder(
  256.             '',
  257.             AddCartType::class,
  258.             null,
  259.             [
  260.                 'product' => $Product,
  261.                 'id_add_product_id' => false,
  262.             ]
  263.         );
  264.         // Kiểm tra xem có form data và errors từ session không
  265.         $formData $this->session->get('product_detail_form_data');
  266.         $formErrors $this->session->get('product_detail_form_errors');
  267.         
  268.         if ($formData && $formErrors) {
  269.             // Xóa dữ liệu session sau khi sử dụng
  270.             $this->session->remove('product_detail_form_data');
  271.             $this->session->remove('product_detail_form_errors');
  272.         }
  273.         $event = new EventArgs(
  274.             [
  275.                 'builder' => $builder,
  276.                 'Product' => $Product,
  277.             ],
  278.             $request
  279.         );
  280.         $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_PRODUCT_DETAIL_INITIALIZE);
  281.         $form $builder->getForm();
  282.         
  283.         // Nếu có form data từ session, submit form với dữ liệu đó
  284.         if ($formData) {
  285.             $form->submit($formDatafalse); // false để không clear dữ liệu
  286.         }
  287.         $is_favorite false;
  288.         if ($this->isGranted('ROLE_USER')) {
  289.             $Customer $this->getUser();
  290.             $is_favorite $this->customerFavoriteProductRepository->isFavorite($Customer$Product);
  291.         }
  292.         $FreeArea $Product->getFreeArea();
  293.         $ListProductAttribute = [];
  294.         if ($FreeArea) {
  295.             $lines preg_split('/\r\n|\r|\n/'$FreeArea);
  296.             foreach ($lines as $line) {
  297.                 if (trim($line) === '') continue;
  298.                 $parts explode(':'$line2);
  299.                 if (count($parts) == 2) {
  300.                     $ListProductAttribute[] = [trim($parts[0]), trim($parts[1])];
  301.                 }
  302.             }
  303.             if (count($ListProductAttribute) === 0) {
  304.                 $ListProductAttribute null;
  305.             }
  306.         } else {
  307.             $ListProductAttribute null;
  308.         }
  309.         $showImeiForm $Product->hasUserImeiCategory();
  310.         $pageName $this->pageNameHelper->createPageName($Product->getName(), true);
  311.         
  312.         // Tạo breadcrumb
  313.         $breadcrumbs $this->breadcrumbService->getProductDetailBreadcrumb($Product);
  314.         return [
  315.             'title' => $this->title,
  316.             'subtitle' => $Product->getName(),
  317.             'pageName' => $pageName,
  318.             'form' => $form->createView(),
  319.             'Product' => $Product,
  320.             'is_favorite' => $is_favorite,
  321.             'ListProductAttribute' => $ListProductAttribute,
  322.             'FreeArea' => $FreeArea,
  323.             'showImeiForm' => $showImeiForm,
  324.             'breadcrumbs' => $breadcrumbs,
  325.         ];
  326.     }
  327.     /**
  328.      * お気に入り追加.
  329.      *
  330.      * @Route("/products/add_favorite/{id}", name="product_add_favorite", requirements={"id" = "\d+"}, methods={"GET", "POST"})
  331.      */
  332.     public function addFavorite(Request $requestProduct $Product)
  333.     {
  334.         $this->checkVisibility($Product);
  335.         $event = new EventArgs(
  336.             [
  337.                 'Product' => $Product,
  338.             ],
  339.             $request
  340.         );
  341.         $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_PRODUCT_FAVORITE_ADD_INITIALIZE);
  342.         if ($this->isGranted('ROLE_USER')) {
  343.             $Customer $this->getUser();
  344.             $this->customerFavoriteProductRepository->addFavorite($Customer$Product);
  345.             $this->session->getFlashBag()->set('product_detail.just_added_favorite'$Product->getId());
  346.             $event = new EventArgs(
  347.                 [
  348.                     'Product' => $Product,
  349.                 ],
  350.                 $request
  351.             );
  352.             $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_PRODUCT_FAVORITE_ADD_COMPLETE);
  353.             return $this->redirectToRoute('product_detail', ['id' => $Product->getId()]);
  354.         } else {
  355.             // 非会員の場合、ログイン画面を表示
  356.             //  ログイン後の画面遷移先を設定
  357.             $this->setLoginTargetPath($this->generateUrl('product_add_favorite', ['id' => $Product->getId()], UrlGeneratorInterface::ABSOLUTE_URL));
  358.             $this->session->getFlashBag()->set('eccube.add.favorite'true);
  359.             $event = new EventArgs(
  360.                 [
  361.                     'Product' => $Product,
  362.                 ],
  363.                 $request
  364.             );
  365.             $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_PRODUCT_FAVORITE_ADD_COMPLETE);
  366.             return $this->redirectToRoute('mypage_login');
  367.         }
  368.     }
  369.     /**
  370.      * カートに追加.
  371.      *
  372.      * @Route("/products/add_cart/{id}", name="product_add_cart", methods={"POST"}, requirements={"id" = "\d+"})
  373.      */
  374.     public function addCart(Request $requestProduct $Product)
  375.     {
  376.         // エラーメッセージの配列
  377.         $errorMessages = [];
  378.         if (!$this->checkVisibility($Product)) {
  379.             throw new NotFoundHttpException();
  380.         }
  381.         $builder $this->formFactory->createNamedBuilder(
  382.             '',
  383.             AddCartType::class,
  384.             null,
  385.             [
  386.                 'product' => $Product,
  387.                 'id_add_product_id' => false,
  388.             ]
  389.         );
  390.         $event = new EventArgs(
  391.             [
  392.                 'builder' => $builder,
  393.                 'Product' => $Product,
  394.             ],
  395.             $request
  396.         );
  397.         $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_PRODUCT_CART_ADD_INITIALIZE);
  398.         /* @var $form \Symfony\Component\Form\FormInterface */
  399.         $form $builder->getForm();
  400.         $form->handleRequest($request);
  401.         
  402.         if (!$form->isValid()) {
  403.             // Lưu form data và errors vào session để hiển thị lại
  404.             $this->session->set('product_detail_form_data'$request->request->all());
  405.             $this->session->set('product_detail_form_errors'$this->getFormErrors($form));
  406.             
  407.             return $this->redirectToRoute('product_detail', ['id' => $Product->getId()]);
  408.         }
  409.         $addCartData $form->getData();
  410.         // Lấy user_imei từ CartItem object
  411.         $user_imei null;
  412.         if ($Product->hasUserImeiCategory() && $addCartData instanceof CartItem) {
  413.             $user_imei $addCartData->getUserImei();
  414.         }
  415.         log_info(
  416.             'カート追加処理開始',
  417.             [
  418.                 'product_id' => $Product->getId(),
  419.                 'product_class_id' => $addCartData->getProductClass()->getId(),
  420.                 'quantity' => $addCartData->getQuantity(),
  421.                 'user_imei' => $user_imei,
  422.             ]
  423.         );
  424.         // Kiểm tra tồn kho trước khi thêm vào giỏ
  425.         $shouldAddToCart true;
  426.         $ProductClass $addCartData->getProductClass();
  427.         if ($ProductClass && !$ProductClass->isStockUnlimited()) {
  428.             $currentStock = (int) $ProductClass->getStock();
  429.             $requestedQty = (int) $addCartData->getQuantity();
  430.             $quantityInCart $this->cartService->getProductClassQuantityInCart($ProductClass);
  431.             $totalRequiredQty $quantityInCart $requestedQty;
  432.             
  433.             if ($currentStock <= 0) {
  434.                 $shouldAddToCart false;
  435.                 $errorMessages[] = trans('front.shopping.out_of_stock_zero', ['%product%' => $Product->getName()]);
  436.             } elseif ($currentStock $totalRequiredQty) {
  437.                 $shouldAddToCart false;
  438.                 $errorMessages[] = trans('front.shopping.out_of_stock', ['%product%' => $Product->getName()]);
  439.             }
  440.         }
  441.         if ($shouldAddToCart) {
  442.             // カートへ追加
  443.             $this->cartService->addProduct($addCartData->getProductClass()->getId(), $addCartData->getQuantity(), $user_imei);
  444.             // 明細の正規化
  445.             $Carts $this->cartService->getCarts();
  446.             foreach ($Carts as $Cart) {
  447.                 $result $this->purchaseFlow->validate($Cart, new PurchaseContext($Cart$this->getUser()));
  448.                 // 復旧不可のエラーが発生した場合は追加した明細を削除.
  449.                 if ($result->hasError()) {
  450.                     $this->cartService->removeProduct($addCartData->getProductClass()->getId(), $user_imei);
  451.                     foreach ($result->getErrors() as $error) {
  452.                         $errorMessages[] = $error->getMessage();
  453.                     }
  454.                 }
  455.                 foreach ($result->getWarning() as $warning) {
  456.                     $errorMessages[] = $warning->getMessage();
  457.                 }
  458.             }
  459.             $this->cartService->save();
  460.             log_info(
  461.                 'カート追加処理完了',
  462.                 [
  463.                     'product_id' => $Product->getId(),
  464.                     'product_class_id' => $addCartData->getProductClass()->getId(),
  465.                     'quantity' => $addCartData->getQuantity(),
  466.                 ]
  467.             );
  468.         }
  469.         $event = new EventArgs(
  470.             [
  471.                 'form' => $form,
  472.                 'Product' => $Product,
  473.             ],
  474.             $request
  475.         );
  476.         $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_PRODUCT_CART_ADD_COMPLETE);
  477.         if ($event->getResponse() !== null) {
  478.             return $event->getResponse();
  479.         }
  480.         if ($request->isXmlHttpRequest()) {
  481.             // ajaxでのリクエストの場合は結果をjson形式で返す。
  482.             // 初期化
  483.             $messages = [];
  484.             $errorCode null;
  485.             $stockLeft null;
  486.             if (empty($errorMessages)) {
  487.                 // エラーが発生していない場合
  488.                 $done true;
  489.                 array_push($messagestrans('front.product.add_cart_complete'));
  490.             } else {
  491.                 // エラーが発生している場合
  492.                 $done false;
  493.                 $messages $errorMessages;
  494.                 // 在庫エラー用の追加情報を付与
  495.                 // 直近追加を試みた商品規格の在庫とリクエスト数量から判定
  496.                 $ProductClass $addCartData->getProductClass();
  497.                 if ($ProductClass && !$ProductClass->isStockUnlimited()) {
  498.                     $currentStock = (int) $ProductClass->getStock();
  499.                     $requestedQty = (int) $addCartData->getQuantity();
  500.                     $quantityInCart $this->cartService->getProductClassQuantityInCart($ProductClass);
  501.                     $totalRequiredQty $quantityInCart $requestedQty;
  502.                     
  503.                     if ($currentStock <= 0) {
  504.                         $errorCode = \Customize\Constant\ErrorCodes::OUT_OF_STOCK_ZERO;
  505.                         $stockLeft 0;
  506.                     } elseif ($currentStock $totalRequiredQty) {
  507.                         $errorCode = \Customize\Constant\ErrorCodes::OUT_OF_STOCK;
  508.                         $stockLeft $currentStock;
  509.                     }
  510.                 }
  511.             }
  512.             $response = ['done' => $done'messages' => $messages];
  513.             if (!$done) {
  514.                 $response['error_code'] = $errorCode;
  515.                 if ($stockLeft !== null) {
  516.                     $response['stock_left'] = $stockLeft;
  517.                 }
  518.             }
  519.             return $this->json($response);
  520.         } else {
  521.             // ajax以外でのリクエストの場合はカート画面へリダイレクト
  522.             foreach ($errorMessages as $errorMessage) {
  523.                 $this->addRequestError($errorMessage);
  524.             }
  525.             return $this->redirectToRoute('cart');
  526.         }
  527.     }
  528.     /**
  529.      * ページタイトルの設定
  530.      *
  531.      * @param  array|null $searchData
  532.      *
  533.      * @return str
  534.      */
  535.     protected function getPageTitle($searchData)
  536.     {
  537.         if (isset($searchData['name']) && !empty($searchData['name'])) {
  538.             return trans('front.product.search_result');
  539.         } elseif (isset($searchData['category_id']) && $searchData['category_id']) {
  540.             return $searchData['category_id']->getName();
  541.         } else {
  542.             return trans('front.product.all_products');
  543.         }
  544.     }
  545.     /**
  546.      * Lấy tất cả lỗi từ form
  547.      *
  548.      * @param \Symfony\Component\Form\FormInterface $form
  549.      * @return array
  550.      */
  551.     protected function getFormErrors($form)
  552.     {
  553.         $errors = [];
  554.         foreach ($form->getErrors(true) as $error) {
  555.             $errors[] = $error->getMessage();
  556.         }
  557.         return $errors;
  558.     }
  559.     /**
  560.      * 閲覧可能な商品かどうかを判定
  561.      *
  562.      * @param Product $Product
  563.      *
  564.      * @return boolean 閲覧可能な場合はtrue
  565.      */
  566.     protected function checkVisibility(Product $Product)
  567.     {
  568.         $is_admin $this->session->has('_security_admin');
  569.         // 管理ユーザの場合はステータスやオプションにかかわらず閲覧可能.
  570.         if (!$is_admin) {
  571.             // 在庫なし商品の非表示オプションが有効な場合.
  572.             // if ($this->BaseInfo->isOptionNostockHidden()) {
  573.             //     if (!$Product->getStockFind()) {
  574.             //         return false;
  575.             //     }
  576.             // }
  577.             // 公開ステータスでない商品は表示しない.
  578.             if ($Product->getStatus()->getId() !== ProductStatus::DISPLAY_SHOW) {
  579.                 return false;
  580.             }
  581.         }
  582.         return true;
  583.     }
  584. }