1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Larrock\Core\Helpers\Plugins; |
4
|
|
|
|
5
|
|
|
use LarrockBlocks; |
|
|
|
|
6
|
|
|
use Illuminate\Database\Eloquent\Model; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Плагин замены шорткатов плагинов на их данные внутри полей компонентов |
10
|
|
|
* Class RenderPlugins. |
11
|
|
|
*/ |
12
|
|
|
class RenderPlugins |
13
|
|
|
{ |
14
|
|
|
/** @var string html-код поля модели для замены шорткатов плагинов на их данные */ |
15
|
|
|
public $rendered_html; |
16
|
|
|
|
17
|
|
|
/** @var null|Model Модель контента */ |
18
|
|
|
protected $model; |
19
|
|
|
|
20
|
|
|
public function __construct($html, $model = null) |
21
|
|
|
{ |
22
|
|
|
$this->rendered_html = $html; |
23
|
|
|
$this->model = $model; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Вставка блоков. |
28
|
|
|
* @return $this |
29
|
|
|
* @throws \Throwable |
30
|
|
|
*/ |
31
|
|
|
public function renderBlocks() |
32
|
|
|
{ |
33
|
|
|
$re = "/{Блок\\[(?P<type>[a-zA-Z0-9-_а-яА-Я\s]+)]=(?P<name>[a-zA-Z0-9-_а-яА-Я\s]+)}/u"; |
34
|
|
|
preg_match_all($re, $this->rendered_html, $matches); |
35
|
|
|
foreach ($matches['type'] as $key => $match) { |
36
|
|
|
$name = $matches['name'][$key]; |
37
|
|
|
if ($matched_block = LarrockBlocks::getModel()->whereUrl($matches['name'][$key])->first()) { |
38
|
|
|
$this->rendered_html = preg_replace('/<p>{Блок\\['.$match.']='.$name.'}<\/p>/', |
39
|
|
|
view('larrock::front.plugins.renderBlock.'.$match, ['data' => $matched_block])->render(), $this->rendered_html); |
|
|
|
|
40
|
|
|
$this->rendered_html = preg_replace('/{Блок\\['.$match.']='.$name.'}/', |
41
|
|
|
view('larrock::front.plugins.renderBlock.'.$match, ['data' => $matched_block])->render(), $this->rendered_html); |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
return $this; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Вставка галерей изображений. |
50
|
|
|
* @return $this |
51
|
|
|
* @throws \Throwable |
52
|
|
|
*/ |
53
|
|
|
public function renderImageGallery() |
54
|
|
|
{ |
55
|
|
|
$re = "/{Фото\\[(?P<type>[a-zA-Z0-9-_а-яА-Я\s]+)]=(?P<name>[a-zA-Z0-9-_а-яА-Я\s]+)}/u"; |
56
|
|
|
preg_match_all($re, $this->rendered_html, $matches); |
57
|
|
|
if (isset($matches['type'][0])) { |
58
|
|
|
$images = $this->model->getImages; |
59
|
|
|
foreach ($matches['type'] as $key => $match) { |
60
|
|
|
$name = $matches['name'][$key]; |
61
|
|
|
//Собираем изображения под каждую найденную галерею |
62
|
|
|
$matched_images['images'] = []; |
63
|
|
|
foreach ($images as $image) { |
64
|
|
|
if ($image->getCustomProperty('gallery') === $matches['name'][$key]) { |
65
|
|
|
$matched_images['images'][] = $image; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
$this->rendered_html = preg_replace('/<p>{Фото\\['.$match.']='.$name.'}<\/p>/', |
69
|
|
|
view('larrock::front.plugins.photoGallery.'.$match, $matched_images)->render(), $this->rendered_html); |
|
|
|
|
70
|
|
|
$this->rendered_html = preg_replace('/{Фото\\['.$match.']='.$name.'}/', |
71
|
|
|
view('larrock::front.plugins.photoGallery.'.$match, $matched_images)->render(), $this->rendered_html); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
return $this; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Вставка галерей файлов. |
80
|
|
|
* @return $this |
81
|
|
|
* @throws \Throwable |
82
|
|
|
*/ |
83
|
|
|
public function renderFilesGallery() |
84
|
|
|
{ |
85
|
|
|
$re = "/{Файлы\\[(?P<type>[a-zA-Z0-9-_а-яА-Я\s]+)]=(?P<name>[a-zA-Z0-9-_а-яА-Я\s]+)}/u"; |
86
|
|
|
preg_match_all($re, $this->rendered_html, $matches); |
87
|
|
|
if (isset($matches['type'][0])) { |
88
|
|
|
$files = $this->model->getFiles; |
89
|
|
|
foreach ($matches['type'] as $key => $match) { |
90
|
|
|
$name = $matches['name'][$key]; |
91
|
|
|
//Собираем изображения под каждую найденную галерею |
92
|
|
|
$matched_files['files'] = []; |
93
|
|
|
foreach ($files as $file) { |
94
|
|
|
if ($file->getCustomProperty('gallery') === $matches['name'][$key]) { |
95
|
|
|
$matched_files['files'][] = $file; |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
$this->rendered_html = preg_replace('/<p>{Файлы\\['.$match.']='.$name.'}<\/p>/', |
99
|
|
|
view('larrock::front.plugins.fileGallery.'.$match, $matched_files)->render(), $this->rendered_html); |
|
|
|
|
100
|
|
|
$this->rendered_html = preg_replace('/{Файлы\\['.$match.']='.$name.'}/', |
101
|
|
|
view('larrock::front.plugins.fileGallery.'.$match, $matched_files)->render(), $this->rendered_html); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
return $this; |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths