jquery_countdown.theme.inc in jQuery Countdown 6
implements the theme functions to display the countdown
File
jquery_countdown.theme.incView source
<?php
/**
* @file
* implements the theme functions to display the countdown
*/
/**
* Constructs a jQuery Countdown element and adds the required JavaScript.
*
* @param $content
* (optional) The initial content to put in the countdown. This is what is shown
* when JavaScript is not available.
* @param $options
* (optional) The options to apply to the element.
* @param $id
* (optional) The name of the element.
*/
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>";
}
/**
* implements template_preprocess
* prepare template file sugestions based upon the jquery.countdown id submitted by theme function
* @param $variables
* @return void
*/
function template_preprocess_jquery_countdown_layout(&$variables) {
// use the script id as template suggestion so we can create a element based template file override for the layout
$variables['template_files'][] = str_replace('_', '-', 'jquery-countdown-layout' . '-' . $variables['jcid']);
}
Functions
Name![]() |
Description |
---|---|
template_preprocess_jquery_countdown_layout | implements template_preprocess prepare template file sugestions based upon the jquery.countdown id submitted by theme function |
theme_jquery_countdown | Constructs a jQuery Countdown element and adds the required JavaScript. |