| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * This file is part of EC-CUBE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * http://www.lockon.co.jp/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * This program is free software; you can redistribute it and/or | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * modify it under the terms of the GNU General Public License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * as published by the Free Software Foundation; either version 2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * of the License, or (at your option) any later version. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * This program is distributed in the hope that it will be useful, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * GNU General Public License for more details. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * You should have received a copy of the GNU General Public License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * along with this program; if not, write to the Free Software | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | namespace Eccube\Repository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | use Eccube\Entity\Master\DeviceType; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | use Eccube\Entity\PageLayout; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | use Symfony\Component\Filesystem\Filesystem; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  * PageLayoutRepository | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  * This class was generated by the Doctrine ORM. Add your own custom | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  * repository methods below. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | class PageLayoutRepository extends AbstractRepository | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     public function findUnusedBlocks(DeviceType $DeviceType, $pageId) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         $em = $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             ->getEntityManager(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 | 196 |  |         $blockRepo = $em->getRepository('Eccube\Entity\Block'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         $ownBlockPositions = $this->getByDeviceTypeAndId($DeviceType, $pageId)->getBlockPositions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 | 196 |  |         $ids = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         foreach ($ownBlockPositions as $ownBlockPosition) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |             $ids[] = $ownBlockPosition->getBlock()->getId(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 | 7 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         # $idsが空配列だと、$ids以外のblockを取得するSQLが生成されないため、存在しないidを入れる | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 | 7 |  |         if (empty($ids)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 7 |  |             $ids[] = \Eccube\Entity\Block::UNUSED_BLOCK_ID; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 | 7 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 | 7 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 | 7 |  |         return $blockRepo->createQueryBuilder('b') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 | 7 |  |             ->where('b.id not in (:ids)') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |             ->setParameter(':ids', $ids) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             ->getQuery() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |             ->getResult(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 | 7 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     public function getByDeviceTypeAndId(DeviceType $DeviceType, $pageId) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 | 7 |  |         $qb = $this->createQueryBuilder('p') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 | 7 |  |             ->select('p, bp, b') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 | 7 |  |             ->leftJoin('p.BlockPositions', 'bp', 'WITH', 'p.id = bp.page_id') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 | 7 |  |             ->leftJoin('bp.Block', 'b') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 | 7 |  |             ->andWhere('p.DeviceType = :DeviceType AND p.id = :pageId') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |             ->addOrderBy('bp.target_id', 'ASC') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             ->addOrderBy('bp.block_row', 'ASC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 | 12 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         $ownResult = $qb | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 12 |  |             ->getQuery() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 | 12 |  |             ->setParameters(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 12 |  |                 'DeviceType'  => $DeviceType, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 | 12 |  |                 'pageId'        => $pageId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 | 12 |  |             )) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 | 12 |  |             ->getSingleResult(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 | 12 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         $qb = $this->createQueryBuilder('p') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |             ->select('p, bp, b') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 | 12 |  |             ->leftJoin('p.BlockPositions', 'bp', 'WITH', 'p.id = bp.page_id') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 | 12 |  |             ->leftJoin('bp.Block', 'b') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 | 12 |  |             ->andWhere('p.DeviceType = :DeviceType AND bp.anywhere = 1') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 | 12 |  |             ->addOrderBy('bp.target_id', 'ASC') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |             ->addOrderBy('bp.block_row', 'ASC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 | 12 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |         $anyResults = $qb | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 | 12 |  |             ->getQuery() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 | 12 |  |             ->setParameters(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 | 12 |  |                 'DeviceType' => $DeviceType, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 | 12 |  |             )) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 | 12 |  |             ->getResult(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 | 12 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 | 12 |  |         $OwnBlockPosition = $ownResult->getBlockPositions(); | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 97 |  | View Code Duplication |         foreach ($anyResults as $anyResult) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |             $BlockPositions = $anyResult->getBlockPositions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 | 12 |  |             foreach ($BlockPositions as $BlockPosition) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 | 12 |  |                 if (!$OwnBlockPosition->contains($BlockPosition)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 | 12 |  |                     $ownResult->addBlockPosition($BlockPosition); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 | 12 |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 | 12 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 | 12 |  |         return $ownResult; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 | 12 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 | 12 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 | 12 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 | 12 |  |     public function getByUrl(DeviceType $DeviceType, $url) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |         $options = $this->app['config']['doctrine_cache']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         $lifetime = $options['result_cache']['lifetime']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 | 12 |  |         $qb = $this->createQueryBuilder('p') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |             ->select('p, bp, b') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |             ->leftJoin('p.BlockPositions', 'bp', 'WITH', 'p.id = bp.page_id') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |             ->leftJoin('bp.Block', 'b') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 | 171 |  |             ->andWhere('p.DeviceType = :DeviceType AND p.url = :url') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |             ->addOrderBy('bp.target_id', 'ASC') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 | 171 |  |             ->addOrderBy('bp.block_row', 'ASC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 | 171 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |         $ownResult = $qb | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 | 171 |  |             ->getQuery() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 | 171 |  |             ->useResultCache(true, $lifetime) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 | 171 |  |             ->setParameters(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 | 171 |  |                 'DeviceType' => $DeviceType, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 | 171 |  |                 'url'  => $url, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 | 171 |  |             )) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 | 171 |  |             ->getSingleResult(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |         $qb = $this->createQueryBuilder('p') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 | 171 |  |             ->select('p, bp, b') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 | 171 |  |             ->leftJoin('p.BlockPositions', 'bp', 'WITH', 'p.id = bp.page_id') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 | 171 |  |             ->leftJoin('bp.Block', 'b') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 | 171 |  |             ->andWhere('p.DeviceType = :DeviceType AND bp.anywhere = 1') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 | 171 |  |             ->addOrderBy('bp.target_id', 'ASC') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |             ->addOrderBy('bp.block_row', 'ASC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 | 171 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |         $anyResults = $qb | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 | 102 |  |             ->getQuery() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 | 102 |  |             ->useResultCache(true, $lifetime) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 | 102 |  |             ->setParameters(array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 | 102 |  |                 'DeviceType' => $DeviceType, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 | 102 |  |             )) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 | 102 |  |             ->getResult(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 | 102 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |         $OwnBlockPosition = $ownResult->getBlockPositions(); | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 149 |  | View Code Duplication |         foreach ($anyResults as $anyResult) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 | 102 |  |             $BlockPositions = $anyResult->getBlockPositions(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 | 102 |  |             foreach ($BlockPositions as $BlockPosition) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 | 102 |  |                 if (!$OwnBlockPosition->contains($BlockPosition)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 | 102 |  |                     $ownResult->addBlockPosition($BlockPosition); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 | 102 |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 | 102 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 | 102 |  |         return $ownResult; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 | 102 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 | 102 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 | 102 |  |     public function newPageLayout(DeviceType $DeviceType) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 | 102 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |         $PageLayout = new \Eccube\Entity\PageLayout(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |         $PageLayout | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |             ->setDeviceType($DeviceType) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |             ->setEditFlg(PageLayout::EDIT_FLG_USER); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 | 102 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |         return $PageLayout; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 | 71 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |     public function findOrCreate($page_id, DeviceType $DeviceType) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 | 71 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |         if (is_null($page_id)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 | 71 |  |             $PageLayout = $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 | 71 |  |                 ->newPageLayout($DeviceType); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |             return $PageLayout; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 | 71 |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |             return $this->getByDeviceTypeAndId($DeviceType, $page_id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 | 6 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 | 6 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |      * ページの属性を取得する. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 | 2 |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 | 2 |  |      * この関数は, dtb_pagelayout の情報を検索する. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |      * $deviceTypeId は必須. デフォルト値は DEVICE_TYPE_PC. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 | 4 |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |      * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |      * @param  \Eccube\Entity\Master\DeviceType  $DeviceType 端末種別ID | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |      * @param  string                            $where 追加の検索条件 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |      * @param  string[]                          $parameters 追加の検索パラメーター | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |      * @return array                             ページ属性の配列 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 194 |  | View Code Duplication |     public function getPageList(DeviceType $DeviceType, $where = null, $parameters = array()) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |         $qb = $this->createQueryBuilder('l') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |             ->orderBy('l.id', 'DESC') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |             ->where('l.DeviceType = :DeviceType') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |             ->setParameter('DeviceType', $DeviceType) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |             ->andWhere('l.id <> 0') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |             ->orderBy('l.id', 'ASC'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |         if (!is_null($where)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 | 3 |  |             $qb->andWhere($where); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |             foreach ($parameters as $key => $val) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 | 3 |  |                 $qb->setParameter($key, $val); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 | 3 |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 | 3 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 | 3 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 | 3 |  |         $PageLayouts = $qb | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 | 3 |  |             ->getQuery() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 | 3 |  |             ->getResult(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |         return $PageLayouts; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |      * 書き込みパスの取得 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |      * User定義の場合: /html/user_data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 | 3 |  |      * そうでない場合: /app/template/{template_code} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 | 3 |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |      * @param  boolean $isUser | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 | 3 |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |     public function getWriteTemplatePath($isUser = false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |         return ($isUser) ? $this->app['config']['user_data_realdir'] : $this->app['config']['template_realdir']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |      * 読み込みファイルの取得 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |      * 1. template_realdir | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 | 8 |  |      *      app/template/{template_code} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |      * 2. template_default_readldir | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 | 8 |  |      *      src/Eccube/Resource/template/default | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |      * @param string $fileName | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |      * @param  boolean $isUser | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |      * @return array | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 241 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 242 |  |  |     public function getReadTemplateFile($fileName, $isUser = false) | 
            
                                                        
            
                                    
            
            
                | 243 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 244 |  |  |         if ($isUser) { | 
            
                                                        
            
                                    
            
            
                | 245 |  |  |             $readPaths = array( | 
            
                                                        
            
                                    
            
            
                | 246 |  |  |                 $this->app['config']['user_data_realdir'], | 
            
                                                        
            
                                    
            
            
                | 247 |  |  |             ); | 
            
                                                        
            
                                    
            
            
                | 248 |  |  |         } else { | 
            
                                                        
            
                                    
            
            
                | 249 |  |  |             $readPaths = array( | 
            
                                                        
            
                                    
            
            
                | 250 |  |  |                 $this->app['config']['template_realdir'], | 
            
                                                        
            
                                    
            
            
                | 251 | 6 |  |                 $this->app['config']['template_default_realdir'], | 
            
                                                        
            
                                    
            
            
                | 252 |  |  |             ); | 
            
                                                        
            
                                    
            
            
                | 253 | 6 |  |         } | 
            
                                                        
            
                                    
            
            
                | 254 |  |  |  | 
            
                                                        
            
                                                                    
                                                                                                        
            
            
                | 255 | 1 | View Code Duplication |         foreach ($readPaths as $readPath) { | 
            
                                                        
            
                                    
            
            
                | 256 |  |  |             $filePath = $readPath . '/' . $fileName . '.twig'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 257 |  |  |             $fs = new Filesystem(); | 
            
                                                        
            
                                    
            
            
                | 258 |  |  |             if ($fs->exists($filePath)) { | 
            
                                                        
            
                                    
            
            
                | 259 | 5 |  |                 return array( | 
            
                                                        
            
                                    
            
            
                | 260 | 5 |  |                     'file_name' => $fileName, | 
            
                                                        
            
                                    
            
            
                | 261 |  |  |                     'tpl_data' => file_get_contents($filePath), | 
            
                                                        
            
                                    
            
            
                | 262 |  |  |                 ); | 
            
                                                        
            
                                    
            
            
                | 263 |  |  |             } | 
            
                                                        
            
                                    
            
            
                | 264 | 6 |  |         } | 
            
                                                        
            
                                    
            
            
                | 265 | 6 |  |     } | 
            
                                                        
            
                                    
            
            
                | 266 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 267 |  |  |  |