GX-Feature #46726 » StyleEdit3CustomBoxesPOC.patch
| src/StyleEdit3/classes/Repositories/ConfigReader.inc.php (revision ) | ||
|---|---|---|
| 245 | 245 |
|
| 246 | 246 |
$styleConfig->setJsonDataArray($mergedConfig); |
| 247 | 247 |
} |
| 248 |
$this->_initCustomBoxes($styleConfig); |
|
| 249 |
|
|
| 250 |
return $styleConfig; |
|
| 251 |
} |
|
| 252 |
|
|
| 253 |
/** |
|
| 254 |
* Initializes the custom boxes configuration of the active style configuration. |
|
| 255 |
*/ |
|
| 256 |
private function _initCustomBoxes(StoredConfig $styleConfig) |
|
| 257 |
{
|
|
| 258 |
$boxesConfig = $styleConfig->getJsonDataArray(); |
|
| 259 |
|
|
| 260 |
$customBoxesArray = array(); |
|
| 261 |
|
|
| 262 |
$customBoxesDirectory = $this->settings->getTemplatesDirectory() . DIRECTORY_SEPARATOR . $this->settings->getCurrentTemplate().DIRECTORY_SEPARATOR.'boxes'.DIRECTORY_SEPARATOR.'*.json'; |
|
| 263 |
|
|
| 264 |
$customBoxes = glob($customBoxesDirectory); |
|
| 265 |
|
|
| 266 |
foreach($customBoxes as $boxes) |
|
| 267 |
{
|
|
| 268 |
$customBoxesArray[] = json_decode(file_get_contents($boxes)); |
|
| 269 |
} |
|
| 270 |
|
|
| 271 |
foreach($boxesConfig['settings'] as $key => &$setting) |
|
| 272 |
{
|
|
| 273 |
if($setting['name'] === 'boxes') |
|
| 274 |
{
|
|
| 275 |
|
|
| 276 |
foreach($customBoxesArray as $boxesArray) |
|
| 277 |
{
|
|
| 278 |
foreach($boxesArray as $boxes) |
|
| 279 |
{
|
|
| 280 |
foreach($boxes as $box) |
|
| 281 |
{
|
|
| 282 |
$setting['entries'][] = (array)$box; |
|
| 283 |
} |
|
| 284 |
} |
|
| 285 |
} |
|
| 286 |
} |
|
| 287 |
continue; |
|
| 288 |
} |
|
| 289 |
|
|
| 290 |
$styleConfig->setJsonDataArray($boxesConfig); |
|
| 248 |
|
|
| 291 |
|
|
| 249 | 292 |
return $styleConfig; |
| 250 | 293 |
} |
| 251 | 294 |
} |