You are here

function uc_store_page_alter in Ubercart 7.3

Implements hook_page_alter().

File

uc_store/uc_store.module, line 673
Contains global Ubercart functions and store administration functionality.

Code

function uc_store_page_alter(&$page) {
  $id = variable_get('uc_footer_message', 0);

  // Exit if the store footer is turned off.
  if ($id === 'none') {
    return;
  }

  // Figure out what page is being viewed.
  $path = drupal_get_normal_path($_GET['q']);
  $parts = explode('/', $path);

  // Exit if the page isn't governed by Ubercart.
  switch ($parts[0]) {
    case 'admin':

      // No footer on /admin or /admin/*.
      // But add a footer on /admin/store and /admin/store/*.
      if (!isset($parts[1]) || $parts[1] != 'store') {
        return;
      }
      break;
    case 'node':

      // No footer on /node or /node/[type]/add.
      // Only add a footer on /node/[nid] if that node is a product.
      if (count($parts) != 2 || intval($parts[1]) == 0) {
        return;
      }
      else {
        $node = node_load($parts[1]);
        if ($node == FALSE || !function_exists('uc_product_node_info') || !uc_product_is_product($node->type)) {
          return;
        }
      }
      break;
    case 'catalog':
    case 'cart':
      break;
    default:
      return;
  }
  $messages = _uc_store_footer_options();
  if ($id == 0) {

    // Pseudorandom number based on the hash of the path and the site's private
    // key, so messages are consistent between pages on the same site, but
    // different on the same pages on different sites.
    $id = hexdec(substr(md5($path . drupal_get_private_key()), 0, 2)) % count($messages) + 1;
  }
  $page['page_bottom']['ubercart_footer'] = array(
    '#theme' => 'uc_store_footer',
    '#message' => $messages[$id],
  );
}