View source
<?php
function boost_block_view_status() {
global $user;
$block = array();
$block['subject'] = '';
if (!$user->uid) {
return $block;
}
$_boost = boost_transform_url();
unset($_boost['is_cacheable'], $_boost['is_cacheable_reason']);
$_boost = boost_is_cacheable($_boost, 'status');
if (!$_boost['is_cacheable']) {
$reason = $_boost['is_cacheable_reason'] ? $_boost['is_cacheable_reason'] : 'reason unknown';
$block['content']['is_not_cacheable'] = array(
'#markup' => '<p>' . t('This page will not be cached: %reason', array(
'%reason' => $reason,
)) . '</p>',
);
return $block;
}
$_boost['header_info'] = boost_get_header_info();
$_boost['matched_header_info'] = boost_match_header_attributes($_boost['header_info']);
$filename = isset($_boost['filename']) ? $_boost['filename'] . '.' . $_boost['matched_header_info']['extension'] : 'n/a';
if (file_exists($filename)) {
$generated = date('c', filemtime($filename));
}
else {
$generated = 'not cached yet (either no one has visited the page recently, or something is preventing the cache from being generated).';
}
$block['content'] = array(
'filename' => array(
'#markup' => '<p>' . t('File: %filename', array(
'%filename' => $filename,
)) . '</p>',
),
'generated' => array(
'#markup' => '<p>' . t('Generated: %generated', array(
'%generated' => $generated,
)) . '</p>',
),
);
if (file_exists($filename) && user_access('boost flush pages')) {
$form = drupal_get_form('boost_block_flush_form');
$block['content']['flush'] = array(
'#markup' => drupal_render($form),
);
}
return $block;
}
function boost_block_flush_form() {
$form = array();
$form['boost_cache']['clear'] = array(
'#type' => 'submit',
'#value' => t('Flush Page'),
);
return $form;
}
function boost_block_flush_form_submit() {
$_boost = boost_transform_url();
$_boost['header_info'] = boost_get_header_info();
$_boost['matched_header_info'] = boost_match_header_attributes($_boost['header_info']);
$filename = $_boost['filename'] . '.' . $_boost['matched_header_info']['extension'];
if (is_file($filename)) {
if (unlink($filename)) {
drupal_set_message(t('%filename was deleted from the Boost cache', array(
'%filename' => $filename,
)));
}
else {
drupal_set_message(t('%filename could not be deleted, check file permissions on disk to see if the web server can write/delete the file.', array(
'%filename' => $filename,
)));
}
}
else {
drupal_set_message(t('%filename was not found in the Boost cache and could not be deleted.', array(
'%filename' => $filename,
)));
}
}