function boost_nodeapi in Boost 6
Same name and namespace in other branches
- 5 boost.module \boost_nodeapi()
Implementation of hook_nodeapi(). Acts on nodes defined by other modules.
File
- ./
boost.module, line 1078 - Provides static file caching for Drupal text output. Pages, Feeds, ect...
Code
function boost_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
global $_boost;
if (!variable_get('boost_enabled', CACHE_NORMAL) || !isset($node->nid)) {
return;
}
$data[] = array(
'page_callback' => 'node',
'page_id' => $node->nid,
);
boost_set_base_dir_in_array($data);
switch ($op) {
case 'insert':
boost_expire_node($node);
// Run all cached views, looking for this new node
if (BOOST_FLUSH_VIEWS_INSERT && module_exists('views')) {
$GLOBALS['_boost_nid'] = $node->nid;
$_boost['new_nodes'][$node->nid] = $node->nid;
register_shutdown_function('_boost_view_insert');
}
// Insert new node into boost_cache table
if (variable_get('boost_insert_node_on_creation', FALSE)) {
$GLOBALS['_boost_nid'] = $node->nid;
$_boost['new_nodes'][$node->nid] = $node->nid;
register_shutdown_function('_boost_cache_insert');
}
break;
case 'update':
boost_expire_node($node);
// Run all cached views, looking for this new node
if (BOOST_FLUSH_VIEWS_UPDATE && module_exists('views')) {
$GLOBALS['_boost_nid'] = $node->nid;
$_boost['new_nodes'][$node->nid] = $node->nid;
register_shutdown_function('_boost_view_insert');
}
// if node is not published, delete it.
if (!$node->status) {
boost_cache_expire_router($data, TRUE, TRUE);
}
break;
case 'delete':
boost_expire_node($node);
boost_cache_expire_router($data, TRUE, TRUE);
break;
case 'presave':
// If path changes remove old path entry from database
// Logic taken from path_redirect_node_presave()
if (!empty($node->path)) {
$node_path = 'node/' . $node->nid;
$old_alias = drupal_get_path_alias($node_path, $node->language ? $node->language : '');
if ($old_alias != $node_path && $node->path != $old_alias) {
// If the user is manually changing the path alias, nuke the old files
boost_cache_expire_router($data, TRUE, TRUE);
}
}
break;
}
}