Commit f1259496 authored by frjo's avatar frjo
Browse files

Remove settings to activate/deactivate Colorbox on specific pages since we now...

Remove settings to activate/deactivate Colorbox on specific pages since we now automatically activate it when the formatter is used.
parent a3b5e85f
......@@ -27,18 +27,6 @@ advanced:
mobile_device_width: '480px'
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/*
compression_type: 'minified'
insert:
image_style: ''
......
......@@ -89,12 +89,6 @@ colorbox.settings:
caption_trim_length:
type: integer
label: 'Caption max length'
visibility:
type: integer
label: 'Show Colorbox on specific pages'
pages:
type: string
label: 'Pages'
compression_type:
type: string
label: 'Colorbox compression level'
......@@ -9,9 +9,6 @@ namespace Drupal\colorbox;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Path\AliasStorageInterface;
use Drupal\Core\Path\PathMatcherInterface;
use Drupal\Core\Path\CurrentPathStack;
/**
* Implementation of ActivationCheckInterface.
......@@ -25,60 +22,17 @@ class ActivationCheck implements ActivationCheckInterface {
*/
protected $settings;
/**
* A service to match paths.
*
* @var \Drupal\Core\Path\PathMatcherInterface
*/
protected $pathMatcher;
/**
* The current path.
*
* @var \Drupal\Core\Path\CurrentPathStack
*/
protected $currentPath;
/**
* Alias storage.
*
* @var \Drupal\Core\Path\AliasStorageInterface
*/
protected $aliasStorage;
/**
* Create an instace of ActivationCheck.
*/
public function __construct(ConfigFactoryInterface $config, PathMatcherInterface $path_matcher, CurrentPathStack $current_path, AliasStorageInterface $alias_storage) {
public function __construct(ConfigFactoryInterface $config) {
$this->settings = $config->get('colorbox.settings');
$this->pathMatcher = $path_matcher;
$this->currentPath = $current_path;
$this->aliasStorage = $alias_storage;
}
/**
* {@inheritdoc}
*/
public function isActive() {
// Make it possible deactivate Colorbox with
// parameter ?colorbox=no in the url.
if (isset($_GET['colorbox']) && $_GET['colorbox'] == 'no') {
return FALSE;
}
// Convert path to lowercase. This allows comparison of the same path
// with different case. Ex: /Page, /page, /PAGE.
$pages = Unicode::strtolower($this->settings->get('advanced.pages'));
// Compare the lowercase path alias (if any) and internal path.
$path = $this->currentPath->getPath();
$path_alias = Unicode::strtolower($this->aliasStorage->lookupPathAlias($path, 'en'));
$page_match = $this->pathMatcher->matchPath($path_alias, $pages);
if ($path_alias != $path) {
$page_match = $page_match || $this->pathMatcher->matchPath($path, $pages);
}
$page_match = $this->settings->get('advanced.visibility') == 0 ? !$page_match : $page_match;
return $page_match;
}
}
......@@ -281,22 +281,6 @@ class ColorboxSettingsForm extends ConfigFormBase {
),
),
);
$form['colorbox_advanced_settings']['colorbox_visibility'] = array(
'#type' => 'radios',
'#title' => t('Show Colorbox on specific pages'),
'#options' => array(0 => t('All pages except those listed'), 1 => t('Only the listed pages')),
'#default_value' => $config->get('advanced.visibility'),
);
$form['colorbox_advanced_settings']['colorbox_pages'] = array(
'#type' => 'textarea',
'#title' => '<span class="element-invisible">' . t('Pages') . '</span>',
'#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/*',
'%front' => '<front>',
)),
);
$form['colorbox_advanced_settings']['colorbox_compression_type'] = array(
'#type' => 'radios',
'#title' => t('Choose Colorbox compression level'),
......@@ -344,8 +328,6 @@ class ColorboxSettingsForm extends ConfigFormBase {
->set('advanced.mobile_detect_width', $form_state->getValue('colorbox_mobile_device_width'))
->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', $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