|
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 Doctrine\ORM\EntityRepository; |
|
28
|
|
|
use Symfony\Component\Filesystem\Filesystem; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* BlocRepository |
|
32
|
|
|
* |
|
33
|
|
|
* This class was generated by the Doctrine ORM. Add your own custom |
|
34
|
|
|
* repository methods below. |
|
35
|
|
|
*/ |
|
36
|
|
|
class BlockRepository extends EntityRepository |
|
37
|
|
|
{ |
|
38
|
|
|
protected $app; |
|
39
|
|
|
|
|
40
|
14 |
|
public function setApplication($app) |
|
|
|
|
|
|
41
|
|
|
{ |
|
42
|
14 |
|
$this->app = $app; |
|
43
|
14 |
|
} |
|
44
|
|
|
|
|
45
|
5 |
|
public function findOrCreate($block_id, $DeviceType) |
|
|
|
|
|
|
46
|
|
|
{ |
|
47
|
|
|
|
|
48
|
5 |
|
if ($block_id == null) { |
|
49
|
1 |
|
return $this->newBlock($DeviceType); |
|
50
|
|
|
} else { |
|
51
|
5 |
|
return $this->getBlock($block_id, $DeviceType); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
1 |
|
public function newBlock($DeviceType) |
|
|
|
|
|
|
57
|
|
|
{ |
|
58
|
1 |
|
$Block = new \Eccube\Entity\Block(); |
|
59
|
|
|
$Block |
|
60
|
1 |
|
->setDeviceType($DeviceType) |
|
61
|
1 |
|
->setLogicFlg(0) |
|
62
|
1 |
|
->setDeletableFlg(1); |
|
63
|
|
|
|
|
64
|
1 |
|
return $Block; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @deprecated since 3.0.0, to be removed in 3.1 |
|
69
|
|
|
*/ |
|
70
|
|
|
private function getNewBlockId($DeviceType) |
|
71
|
|
|
{ |
|
72
|
|
|
|
|
73
|
|
|
$qb = $this->createQueryBuilder('b') |
|
74
|
|
|
->select('max(b.id) +1 as block_id') |
|
75
|
|
|
->where('b.DeviceType = :DeviceType') |
|
76
|
|
|
->setParameter('DeviceType', $DeviceType); |
|
77
|
|
|
$result = $qb->getQuery()->getSingleResult(); |
|
78
|
|
|
|
|
79
|
|
|
return $result['block_id']; |
|
80
|
|
|
|
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* ブロックの情報を取得. |
|
85
|
|
|
* |
|
86
|
|
|
* @param integer $block_id ブロックID |
|
|
|
|
|
|
87
|
|
|
* @param \Eccube\Entity\Master\DeviceType $DeviceType |
|
88
|
|
|
* @return array |
|
89
|
|
|
*/ |
|
90
|
6 |
|
public function getBlock($block_id, $DeviceType) |
|
|
|
|
|
|
91
|
|
|
{ |
|
92
|
6 |
|
$Block = $this->findOneBy(array( |
|
93
|
6 |
|
'id' => $block_id, |
|
94
|
6 |
|
'DeviceType' => $DeviceType, |
|
95
|
6 |
|
)); |
|
96
|
|
|
|
|
97
|
6 |
|
return $Block; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* ブロック一覧の取得. |
|
102
|
|
|
* |
|
103
|
|
|
* @param \Eccube\Entity\Master\DeviceType $DeviceType |
|
104
|
|
|
* @return array |
|
105
|
|
|
*/ |
|
106
|
9 |
|
public function getList($DeviceType) |
|
107
|
|
|
{ |
|
108
|
3 |
|
$qb = $this->createQueryBuilder('b') |
|
109
|
3 |
|
->orderBy('b.id', 'DESC') |
|
110
|
3 |
|
->where('b.DeviceType = :DeviceType') |
|
111
|
3 |
|
->setParameter('DeviceType', $DeviceType); |
|
112
|
|
|
|
|
113
|
|
|
$Blocks = $qb |
|
114
|
3 |
|
->getQuery() |
|
115
|
3 |
|
->getResult(); |
|
116
|
|
|
|
|
117
|
9 |
|
return $Blocks; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* ページの属性を取得する. |
|
122
|
|
|
* |
|
123
|
|
|
* この関数は, dtb_pagelayout の情報を検索する. |
|
124
|
|
|
* $deviceTypeId は必須. デフォルト値は DEVICE_TYPE_PC. |
|
125
|
|
|
* |
|
126
|
|
|
* @access public |
|
127
|
|
|
* @param DeviceType $DeviceType 端末種別ID |
|
128
|
|
|
* @param string $where 追加の検索条件 |
|
|
|
|
|
|
129
|
|
|
* @param string[] $parameters 追加の検索パラメーター |
|
|
|
|
|
|
130
|
|
|
* @return array ページ属性の配列 |
|
131
|
|
|
* @deprecated since 3.0.0, to be removed in 3.1 |
|
132
|
|
|
*/ |
|
133
|
|
View Code Duplication |
public function getPageList(DeviceType $DeviceType, $where = null, $parameters = array()) |
|
|
|
|
|
|
134
|
|
|
{ |
|
135
|
|
|
$qb = $this->createQueryBuilder('l') |
|
136
|
|
|
->orderBy('l.id', 'DESC') |
|
137
|
|
|
->where('l.DeviceType = :DeviceType') |
|
138
|
|
|
->setParameter('DeviceType', $DeviceType) |
|
139
|
|
|
->andWhere('l.id <> 0') |
|
140
|
|
|
->orderBy('l.id', 'ASC'); |
|
141
|
|
|
if (!is_null($where)) { |
|
142
|
|
|
$qb->andWhere($where); |
|
143
|
|
|
foreach ($parameters as $key => $val) { |
|
144
|
|
|
$qb->setParameter($key, $val); |
|
145
|
|
|
} |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
$PageLayouts = $qb |
|
149
|
|
|
->getQuery() |
|
150
|
|
|
->getResult(); |
|
151
|
|
|
|
|
152
|
|
|
return $PageLayouts; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* 書き込みパスの取得 |
|
157
|
|
|
* User定義の場合: /html/user_data |
|
158
|
|
|
* そうでない場合: /app/template/{template_code} |
|
159
|
|
|
* |
|
160
|
|
|
* @param boolean $isUser |
|
161
|
|
|
* @return string |
|
162
|
|
|
* |
|
163
|
|
|
* @deprecated since 3.0.0, to be removed in 3.1 |
|
164
|
|
|
*/ |
|
165
|
1 |
|
public function getWriteTemplatePath($isUser = false) |
|
|
|
|
|
|
166
|
|
|
{ |
|
167
|
1 |
|
return $this->app['config']['block_realdir']; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* 読み込みファイルの取得 |
|
172
|
|
|
* |
|
173
|
|
|
* 1. block_realdir |
|
174
|
|
|
* app/template/{template_code}/block |
|
175
|
|
|
* 2. block_default_readldir |
|
176
|
|
|
* src/Eccube/Resource/template/default/block |
|
177
|
|
|
* |
|
178
|
|
|
* @param string $fileName |
|
|
|
|
|
|
179
|
|
|
* @param boolean $isUser |
|
180
|
|
|
* |
|
181
|
|
|
* @return array |
|
182
|
|
|
*/ |
|
183
|
6 |
|
public function getReadTemplateFile($fileName, $isUser = false) |
|
|
|
|
|
|
184
|
|
|
{ |
|
185
|
|
|
$readPaths = array( |
|
186
|
6 |
|
$this->app['config']['block_realdir'], |
|
187
|
6 |
|
$this->app['config']['block_default_realdir'], |
|
188
|
6 |
|
); |
|
189
|
6 |
View Code Duplication |
foreach ($readPaths as $readPath) { |
|
|
|
|
|
|
190
|
6 |
|
$filePath = $readPath . '/' . $fileName . '.twig'; |
|
|
|
|
|
|
191
|
6 |
|
$fs = new Filesystem(); |
|
192
|
6 |
|
if ($fs->exists($filePath)) { |
|
193
|
|
|
return array( |
|
194
|
6 |
|
'file_name' => $fileName, |
|
195
|
6 |
|
'tpl_data' => file_get_contents($filePath), |
|
196
|
6 |
|
); |
|
197
|
|
|
} |
|
198
|
5 |
|
} |
|
199
|
|
|
} |
|
200
|
|
|
} |
|
201
|
|
|
|