Commit f5309364 authored by Sam152's avatar Sam152 Committed by frjo
Browse files

Issue #2642150 by Sam152: Store enabled paths as a string with newlines instead of an array

parent ff222a97
......@@ -146,28 +146,3 @@ function colorbox_libraries_info() {
return $libraries;
}
/**
* Converts a text with lines (\n) into an array of lines.
*
* @param string $text
*
* @return array
* Array with as many items as non-empty lines in the text
*/
function _colorbox_string_to_array($text) {
$text = str_replace("\r\n", "\n", $text);
return array_filter(explode("\n", $text), 'trim');
}
/**
* Converts an array of lines into an text with lines (\n).
*
* @param array $array
*
* @return string
* Text with lines
*/
function _colorbox_array_to_string($array) {
return implode("\r\n", $array);
}
......@@ -28,17 +28,17 @@ advanced:
caption_trim: '0'
caption_trim_length: '75'
visibility: '0'
pages:
- '/admin*'
- '/imagebrowser*'
- '/img_assist*'
- '/imce*'
- '/node/add/*'
- '/node/*/edit'
- '/print/*'
- '/printpdf/*'
- '/system/ajax'
- '/system/ajax/*'
pages: |
/admin*
/imagebrowser*
/img_assist*
/imce*
/node/add/*
/node/*/edit
/print/*
/printpdf/*
/system/ajax
/system/ajax/*
compression_type: 'minified'
insert:
image_style: ''
......
......@@ -93,11 +93,8 @@ colorbox.settings:
type: integer
label: 'Show Colorbox on specific pages'
pages:
type: sequence
type: string
label: 'Pages'
sequence:
- type: string
label: 'Page'
compression_type:
type: string
label: 'Colorbox compression level'
......@@ -67,7 +67,7 @@ class ActivationCheck implements ActivationCheckInterface {
}
// Convert path to lowercase. This allows comparison of the same path
// with different case. Ex: /Page, /page, /PAGE.
$pages = Unicode::strtolower(_colorbox_array_to_string($this->settings->get('advanced.pages')));
$pages = Unicode::strtolower($this->settings->get('advanced.pages'));
// Compare the lowercase path alias (if any) and internal path.
$path = $this->currentPath->getPath();
......
......@@ -293,7 +293,7 @@ class ColorboxSettingsForm extends ConfigFormBase {
$form['colorbox_advanced_settings']['colorbox_pages'] = array(
'#type' => 'textarea',
'#title' => '<span class="element-invisible">' . t('Pages') . '</span>',
'#default_value' => _colorbox_array_to_string($config->get('advanced.pages')),
'#default_value' => $config->get('advanced.pages'),
'#description' => t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %user for the current user's page and %user-wildcard for every user page. %front is the front page.", array(
'%user' => '/user',
'%user-wildcard' => '/user/*',
......@@ -349,7 +349,7 @@ class ColorboxSettingsForm extends ConfigFormBase {
->set('advanced.caption_trim', $form_state->getValue('colorbox_caption_trim'))
->set('advanced.caption_trim_length', $form_state->getValue('colorbox_caption_trim_length'))
->set('advanced.visibility', $form_state->getValue('colorbox_visibility'))
->set('advanced.pages', _colorbox_string_to_array($form_state->getValue('colorbox_pages')))
->set('advanced.pages', $form_state->getValue('colorbox_pages'))
->set('advanced.compression_type', $form_state->getValue('colorbox_compression_type'));
if ($form_state->getValue('colorbox_image_style')) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment