You are here

function theme_jquery_countdown in jQuery Countdown 6

Same name and namespace in other branches
  1. 5 jquery_countdown.module \theme_jquery_countdown()
  2. 7.2 jquery_countdown.module \theme_jquery_countdown()
  3. 7 jquery_countdown.module \theme_jquery_countdown()

Constructs a jQuery Countdown element and adds the required JavaScript.

Parameters

$content: (optional) The initial content to put in the countdown. This is what is shown when JavaScript is not available.

$options: (optional) The options to apply to the element.

$id: (optional) The name of the element.

3 theme calls to theme_jquery_countdown()
jquery_countdown_help in ./jquery_countdown.module
Implementation of hook_help().
theme_jquery_countdown_date_formatter_jquery_countdown_default in jquery_countdown_date/jquery_countdown_date.formatter.inc
@file containes the cck formatter settings
_jquery_countdown_block_block_view in jquery_countdown_block/jquery_countdown_block.module
Returns the 'view' $op info for hook_block().

File

./jquery_countdown.theme.inc, line 18
implements the theme functions to display the countdown

Code

function theme_jquery_countdown($options = array(), $content = '', $id = 'jquery-countdown') {

  // Construct the ID name and add the JavaScript.
  $id = form_clean_id($id);

  // sanitize serversync option...
  if (isset($options['serversync'])) {

    // if set to TRUE we use our default callback for serversync otherwise use the sync provided as parameter...
    if ($options['serversync'] == TRUE) {
      $options['serversync'] = JQUERY_COUNTDOWN_SERVERSYNC_CALLBACK;
    }
    elseif ($options['serversync'] == FALSE) {
      unset($options['serversync']);
    }
  }

  // if there is no layout in the options and we dont want to use the default layout use template file as layout.
  // @TODO: add a option if we want to use a default layout or the layout file...
  if (isset($options['layout'])) {
    if ($options['layout'] == TRUE) {

      // if set to true we use our default layout otherwise use user layout
      $jquery_countdown_layout_mask = theme('jquery_countdown_layout', $id);

      // not sure if necessary but secure is secure we remove all line breaks from template file...
      $options['layout'] = str_replace(array(
        "\n",
        "\r",
      ), '', $jquery_countdown_layout_mask);
    }
    elseif ($options['layout'] == FALSE) {
      unset($options['layout']);
    }
  }
  jquery_countdown_add('#' . $id, $options);

  // Construct the HTML.
  return "<div id='{$id}' class='jquery-countdown'>{$content}</div>";
}