Skip to content

Commit 1319682

Browse files
author
Viktor Tymchynskyi
committed
Merge remote-tracking branch 'magento2/develop' into MAGETWO-32931
2 parents 7d56760 + 2af1192 commit 1319682

File tree

26 files changed

+1123
-295
lines changed

26 files changed

+1123
-295
lines changed

app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php

Lines changed: 51 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -185,70 +185,94 @@ public function __construct(
185185
}
186186

187187
/**
188-
* Return one-level child directories for specified path
188+
* Create sub directories if DB storage is used
189189
*
190-
* @param string $path Parent directory path
191-
* @return \Magento\Framework\Data\Collection\Filesystem
192-
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
193-
* @SuppressWarnings(PHPMD.NPathComplexity)
190+
* @param string $path
191+
* @return void
194192
*/
195-
public function getDirsCollection($path)
193+
protected function createSubDirectories($path)
196194
{
197195
if ($this->_coreFileStorageDb->checkDbUsage()) {
198196
/** @var \Magento\MediaStorage\Model\File\Storage\Directory\Database $subDirectories */
199197
$subDirectories = $this->_directoryDatabaseFactory->create();
200-
$subDirectories->getSubdirectories($path);
201-
foreach ($subDirectories as $directory) {
198+
$directories = $subDirectories->getSubdirectories($path);
199+
foreach ($directories as $directory) {
202200
$fullPath = rtrim($path, '/') . '/' . $directory['name'];
203201
$this->_directory->create($fullPath);
204202
}
205203
}
204+
}
206205

206+
/**
207+
* Prepare and get conditions for exclude directories
208+
*
209+
* @return array
210+
*/
211+
protected function getConditionsForExcludeDirs()
212+
{
207213
$conditions = ['reg_exp' => [], 'plain' => []];
208214

209215
if ($this->_dirs['exclude']) {
210216
foreach ($this->_dirs['exclude'] as $dir) {
211-
$conditions[$dir->getAttribute('regexp') ? 'reg_exp' : 'plain'][$dir] = true;
217+
$conditions[!empty($dir['regexp']) ? 'reg_exp' : 'plain'][$dir['name']] = true;
212218
}
213219
}
214220

215221
// "include" section takes precedence and can revoke directory exclusion
216222
if ($this->_dirs['include']) {
217223
foreach ($this->_dirs['include'] as $dir) {
218-
unset($conditions['regexp'][(string)$dir], $conditions['plain'][$dir]);
224+
unset($conditions['reg_exp'][$dir['name']], $conditions['plain'][$dir['name']]);
219225
}
220226
}
221227

228+
return $conditions;
229+
}
230+
231+
/**
232+
* Remove excluded directories from collection
233+
*
234+
* @param \Magento\Framework\Data\Collection\Filesystem $collection
235+
* @param array $conditions
236+
* @return \Magento\Framework\Data\Collection\Filesystem
237+
*/
238+
protected function removeItemFromCollection($collection, $conditions)
239+
{
222240
$regExp = $conditions['reg_exp'] ? '~' . implode('|', array_keys($conditions['reg_exp'])) . '~i' : null;
223-
$collection = $this->getCollection(
224-
$path
225-
)->setCollectDirs(
226-
true
227-
)->setCollectFiles(
228-
false
229-
)->setCollectRecursively(
230-
false
231-
);
232241
$storageRootLength = strlen($this->_cmsWysiwygImages->getStorageRoot());
233242

234243
foreach ($collection as $key => $value) {
235244
$rootChildParts = explode('/', substr($value->getFilename(), $storageRootLength));
236245

237-
if (array_key_exists(
238-
$rootChildParts[0],
239-
$conditions['plain']
240-
) || $regExp && preg_match(
241-
$regExp,
242-
$value->getFilename()
243-
)
244-
) {
246+
if (array_key_exists($rootChildParts[1], $conditions['plain'])
247+
|| ($regExp && preg_match($regExp, $value->getFilename()))) {
248+
245249
$collection->removeItemByKey($key);
246250
}
247251
}
248252

249253
return $collection;
250254
}
251255

256+
/**
257+
* Return one-level child directories for specified path
258+
*
259+
* @param string $path Parent directory path
260+
* @return \Magento\Framework\Data\Collection\Filesystem
261+
*/
262+
public function getDirsCollection($path)
263+
{
264+
$this->createSubDirectories($path);
265+
266+
$collection = $this->getCollection($path)
267+
->setCollectDirs(true)
268+
->setCollectFiles(false)
269+
->setCollectRecursively(false);
270+
271+
$conditions = $this->getConditionsForExcludeDirs();
272+
273+
return $this->removeItemFromCollection($collection, $conditions);
274+
}
275+
252276
/**
253277
* Return files
254278
*

app/code/Magento/Cms/Setup/InstallData.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,12 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
111111
</span>
112112
</div>
113113
<p>
114-
This privacy policy sets out how {{config path="general/store_information/name"}} uses and protects any
115-
information that you give {{config path="general/store_information/name"}} when you use this website.
116-
{{config path="general/store_information/name"}} is committed to ensuring that your privacy is protected.
117-
Should we ask you to provide certain information by which you can be identified when using this website,
118-
then you can be assured that it will only be used in accordance with this privacy statement.
119-
{{config path="general/store_information/name"}} may change this policy from time to time by updating this page.
120-
You should check this page from time to time to ensure that you are happy with any changes.
114+
This privacy policy sets out how this website (hereafter "the Store") uses and protects any information that
115+
you give the Store while using this website. The Store is committed to ensuring that your privacy is protected.
116+
Should we ask you to provide certain information by which you can be identified when using this website, then
117+
you can be assured that it will only be used in accordance with this privacy statement. The Store may change
118+
this policy from time to time by updating this page. You should check this page from time to time to ensure
119+
that you are happy with any changes.
121120
</p>
122121
<h2>What we collect</h2>
123122
<p>We may collect the following information:</p>
@@ -191,8 +190,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
191190
</li>
192191
<li>
193192
if you have previously agreed to us using your personal information for direct marketing purposes,
194-
you may change your mind at any time by writing to or emailing us at
195-
{{config path="trans_email/ident_general/email"}}
193+
you may change your mind at any time by letting us know using our Contact Us information
196194
</li>
197195
</ul>
198196
<p>
@@ -202,8 +200,8 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
202200
</p>
203201
<p>
204202
You may request details of personal information which we hold about you under the Data Protection Act 1998.
205-
A small fee will be payable. If you would like a copy of the information held on you please write to
206-
{{config path="general/store_information/address"}}.
203+
A small fee will be payable. If you would like a copy of the information held on you please email us this
204+
request using our Contact Us information.
207205
</p>
208206
<p>
209207
If you believe that any information we are holding on you is incorrect or incomplete,

0 commit comments

Comments
 (0)