Commit 176056cb authored by jchatard's avatar jchatard Committed by bgm

Issue #1612448 : do not depend on block.module variables since the block module might be disabled.

parent c97c4788
......@@ -21,12 +21,12 @@ function boost_admin_settings() {
// See http://api.drupal.org/api/function/block_admin_configure/7
$access = user_access('use PHP for settings');
$options = array(
BLOCK_VISIBILITY_NOTLISTED => t('All pages except those listed'),
BLOCK_VISIBILITY_LISTED => t('Only the listed pages'),
BOOST_VISIBILITY_NOTLISTED => t('All pages except those listed'),
BOOST_VISIBILITY_LISTED => t('Only the listed pages'),
);
$description = t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>'));
if (module_exists('php') && $access) {
$options += array(BLOCK_VISIBILITY_PHP => t('Pages on which this PHP code returns <code>TRUE</code> (experts only)'));
$options += array(BOOST_VISIBILITY_PHP => t('Pages on which this PHP code returns <code>TRUE</code> (experts only)'));
$title = t('Pages or PHP code');
$description .= ' ' . t('If the PHP option is chosen, enter PHP code between %php. Note that executing incorrect PHP code can break your Drupal site.', array('%php' => '<?php ?>'));
}
......@@ -37,7 +37,7 @@ function boost_admin_settings() {
'#type' => 'radios',
'#title' => t('Cache specific pages'),
'#options' => $options,
'#default_value' => variable_get('boost_cacheability_option', BLOCK_VISIBILITY_NOTLISTED),
'#default_value' => variable_get('boost_cacheability_option', BOOST_VISIBILITY_NOTLISTED),
);
$form['cacheability']['boost_cacheability_pages'] = array(
'#type' => 'textarea',
......
......@@ -66,6 +66,20 @@ define('BOOST_ADD_DEFAULT_CHARSET', TRUE);
*/
define('BOOST_CHARSET_TYPE', 'utf-8');
/**
* Shows this block on every page except the listed pages.
*/
define('BOOST_VISIBILITY_NOTLISTED', 0);
/**
* Shows this block on only the listed pages.
*/
define('BOOST_VISIBILITY_LISTED', 1);
/**
* Shows this block if the associated PHP code returns TRUE.
*/
define('BOOST_VISIBILITY_PHP', 2);
/**
* Implements hook_menu().
......@@ -493,13 +507,13 @@ function boost_is_cacheable($parts) {
// Match the user's cacheability settings against the path.
// See http://api.drupal.org/api/function/block_block_list_alter/7
$visibility = variable_get('boost_cacheability_option', BLOCK_VISIBILITY_NOTLISTED);
$visibility = variable_get('boost_cacheability_option', BOOST_VISIBILITY_NOTLISTED);
$pages_setting = variable_get('boost_cacheability_pages', BOOST_CACHEABILITY_PAGES);
if ($pages_setting) {
// Convert path string to lowercase. This allows comparison of the same path
// with different case. Ex: /Page, /page, /PAGE.
$pages = drupal_strtolower($pages_setting);
if ($visibility < BLOCK_VISIBILITY_PHP) {
if ($visibility < BOOST_VISIBILITY_PHP) {
// Convert the alias to lowercase.
$path = drupal_strtolower($alias);
// Compare the lowercase internal and lowercase path alias (if any).
......@@ -507,9 +521,9 @@ function boost_is_cacheable($parts) {
if ($path != $normal_path) {
$page_match = $page_match || drupal_match_path($normal_path, $pages);
}
// When 'boost_cacheability_option' has a value of 0 (BLOCK_VISIBILITY_NOTLISTED),
// When 'boost_cacheability_option' has a value of 0 (BOOST_VISIBILITY_NOTLISTED),
// Boost will cache all pages except those listed in 'boost_cacheability_pages'.
// When set to 1 (BLOCK_VISIBILITY_LISTED), Boost will only cache those
// When set to 1 (BOOST_VISIBILITY_LISTED), Boost will only cache those
// pages listed in 'boost_cacheability_pages'.
$page_match = !($visibility xor $page_match);
}
......
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