'Cache Expiration', 'description' => 'Settings for expiration of cached pages.', 'page callback' => 'drupal_get_form', 'page arguments' => array('expire_admin_settings_form'), 'access arguments' => array('administer site configuration'), 'type' => MENU_NORMAL_ITEM, 'file' => 'expire.admin.inc', ); return $items; } /** * Implements hook_form_FORM_ID_alter(). */ function expire_form_node_type_form_alter(&$form, &$form_state) { module_load_include('admin.inc', 'expire'); expire_node_settings_form($form, $form_state); } /** * Implements hook_node_insert(). */ function expire_node_insert($node) { expire_execute_expiration('node', $node, EXPIRE_NODE_INSERT); } /** * Implements hook_node_update(). */ function expire_node_update($node) { expire_execute_expiration('node', $node, EXPIRE_NODE_UPDATE); } /** * Implements hook_node_delete(). */ function expire_node_delete($node) { expire_execute_expiration('node', $node, EXPIRE_NODE_DELETE); } /** * Implements hook_form_FORM_ID_alter(). */ function expire_form_taxonomy_form_vocabulary_alter(&$form, &$form_state) { module_load_include('admin.inc', 'expire'); expire_taxonomy_term_settings_form($form, $form_state); } /** * Implements hook_taxonomy_term_insert(). */ function expire_taxonomy_term_insert($taxonomy_term) { expire_execute_expiration('taxonomy_term', $taxonomy_term, EXPIRE_TAXONOMY_TERM_INSERT); } /** * Implements hook_taxonomy_term_update(). */ function expire_taxonomy_term_update($taxonomy_term) { expire_execute_expiration('taxonomy_term', $taxonomy_term, EXPIRE_TAXONOMY_TERM_UPDATE); } /** * Implements hook_taxonomy_term_delete(). */ function expire_taxonomy_term_delete($taxonomy_term) { expire_execute_expiration('taxonomy_term', $taxonomy_term, EXPIRE_TAXONOMY_TERM_DELETE); } /** * Implements hook_comment_insert(). */ function expire_comment_insert($comment) { expire_execute_expiration('comment', $comment, EXPIRE_COMMENT_INSERT); } /** * Implements hook_comment_update(). */ function expire_comment_update($comment) { expire_execute_expiration('comment', $comment, EXPIRE_COMMENT_UPDATE); } /** * Implements hook_comment_delete(). */ function expire_comment_delete($comment) { expire_execute_expiration('comment', $comment, EXPIRE_COMMENT_DELETE); } /** * Implements hook_comment_publish(). */ function expire_comment_publish($comment) { expire_execute_expiration('comment', $comment, EXPIRE_COMMENT_PUBLISH); } /** * Implements hook_comment_unpublish(). */ function expire_comment_unpublish($comment) { expire_execute_expiration('comment', $comment, EXPIRE_COMMENT_UNPUBLISH); } /** * Implements hook_user_insert(). */ function expire_user_insert($account) { expire_execute_expiration('user', $account, EXPIRE_USER_INSERT); } /** * Implements hook_user_update(). */ function expire_user_update(&$edit, $account) { expire_execute_expiration('user', $account, EXPIRE_USER_UPDATE); } /** * Implements hook_user_delete(). */ function expire_user_delete($account) { expire_execute_expiration('user', $account, EXPIRE_USER_DELETE); } /** * Implements hook_user_cancel(). */ function expire_user_cancel($account) { expire_execute_expiration('user', $account, EXPIRE_USER_CANCEL); } /** * Implements hook_votingapi_insert(). */ function expire_votingapi_insert($votes) { expire_execute_expiration('votingapi', $votes, EXPIRE_VOTINGAPI_INSERT); } /** * Implements hook_votingapi_delete(). */ function expire_votingapi_delete($votes) { expire_execute_expiration('votingapi', $votes, EXPIRE_VOTINGAPI_DELETE); } /** * Implements hook_file_update(). */ function expire_file_update($file) { expire_execute_expiration('file', $file, EXPIRE_FILE_UPDATE); } /** * Implements hook_file_delete(). */ function expire_file_delete($file) { expire_execute_expiration('file', $file, EXPIRE_FILE_DELETE); } /** * Implements hook_menu_link_delete(). */ function expire_menu_link_delete($link) { expire_execute_expiration('menu_link', $link, EXPIRE_MENU_LINK_DELETE); } /** * Implements hook_menu_link_update(). */ function expire_menu_link_update($link) { expire_execute_expiration('menu_link', $link, EXPIRE_MENU_LINK_UPDATE); } /** * Implements hook_menu_link_insert(). */ function expire_menu_link_insert($link) { expire_execute_expiration('menu_link', $link, EXPIRE_MENU_LINK_INSERT); } /** * Execute expiration method for object. */ function expire_execute_expiration($type, $object, $action) { $status = variable_get('expire_status', EXPIRE_STATUS_DISABLED); if ($status) { if ($handler = _expire_get_expiration_handler($type)) { $handler->expire($object, $action); } } return FALSE; } /** * Return class object that should handle expiration. * * @param $type * Type that expiration is called for. * Example: 'node', 'user', 'votingapi', etc. * * @return mixed */ function _expire_get_expiration_handler($type) { $cache_objects = &drupal_static('expire_cache_objects', array()); if (!isset($cache_objects[$type])) { // Make class names more readable. $bits = explode('_', $type); $class_bits = array(); foreach ($bits as $bit) { $class_bits[] = drupal_ucfirst($bit); } $class = variable_get('expire_handler_' . $type, 'Expire' . implode('', $class_bits)); if (class_exists($class)) { $cache_objects[$type] = new $class(); } else { $cache_objects[$type] = FALSE; trigger_error("Unable to find expiration handler class $class for type $type.", E_USER_ERROR); } } return $cache_objects[$type]; } /** * Loads and returns a single entity. * * @param $entity_type * The entity type to load. * * @param $entity_id * The ID of the Entity to load. * * @return mixed * The desired entity or FALSE if it couldn't be found. */ function _expire_load_single_entity($entity_type, $entity_id) { $loaded_entity = entity_load($entity_type, array($entity_id)); return reset($loaded_entity); } /** * Simple print_r to html function. * * @param $data * Array with output data. * * @return string * print_r contents in nicely formatted html. */ function expire_print_r($data) { return str_replace(' ', '    ', nl2br(htmlentities(print_r($data, TRUE)))); }