You are here

function uc_store_tokens in Ubercart 7.3

Same name and namespace in other branches
  1. 8.4 uc_store/uc_store.tokens.inc \uc_store_tokens()

Implements hook_tokens().

File

uc_store/uc_store.tokens.inc, line 72
Token hooks for the uc_store module.

Code

function uc_store_tokens($type, $tokens, $data = array(), $options = array()) {
  $replacements = array();
  if ($type == 'site') {
    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'login-link':
          $login_link = url('user', array(
            'absolute' => TRUE,
          ));
          $replacements[$original] = l($login_link, $login_link);
          break;
        case 'logo':

          // Use a logo; but only if we have one to use.
          $replacements[$original] = '';
          if ($uri = theme_get_setting('logo')) {
            $replacements[$original] = theme('image', array(
              'path' => $uri,
            ));
          }
          break;
      }
    }
  }
  if ($type == 'store') {
    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'name':
          $replacements[$original] = uc_store_name();
          break;
        case 'link':
          $replacements[$original] = l(uc_store_name(), '<front>', array(
            'absolute' => TRUE,
          ));
          break;
        case 'owner':
          $replacements[$original] = variable_get('uc_store_owner', '');
          break;
        case 'email':
          $replacements[$original] = uc_store_email();
          break;
        case 'phone':
          $replacements[$original] = variable_get('uc_store_phone', '');
          break;
        case 'fax':
          $replacements[$original] = variable_get('uc_store_fax', '');
          break;
        case 'address':
          $replacements[$original] = uc_store_address();
          break;
        case 'help-url':
          $replacements[$original] = url(variable_get('uc_store_help_page', ''), array(
            'absolute' => TRUE,
          ));
          break;
      }
    }

    // Handle chaining for tokens that have 'type' defined in hook_token_info()
    if ($link_tokens = token_find_with_prefix($tokens, 'help-url')) {
      $replacements += token_generate('url', $link_tokens, array(
        'path' => variable_get('uc_store_help_page', ''),
      ), $options);
    }
  }
  return $replacements;
}