You are here

function theme_itoggle in iToggle 7

Same name and namespace in other branches
  1. 7.3 itoggle.module \theme_itoggle()
  2. 7.2 itoggle.theme.inc \theme_itoggle()

Theme callback

Parameters

array $variables: An array with the folowing keys/values:

  • string $type The entity type
  • int $id The property id
  • string $property The property machine-name
  • bool $checked The property value (true/false)
  • string $scope The widget scope (views/field/inline)

See also

itoggle_theme().

2 theme calls to theme_itoggle()
itoggle_field_field_formatter_view in modules/field/itoggle_field.module
Implements hook_field_formatter_view().
itoggle_views_handler_field::render in modules/views/itoggle_views_handler.inc
Render the trigger field and its linked popup information.

File

./itoggle.module, line 282
iToggle module.

Code

function theme_itoggle($variables) {
  extract($variables);
  if ($checked === TRUE) {
    $checked = 'checked="checked"';

    // set inverse values because the token gets validated against the submitted value
    $value = 0;
  }
  else {
    $checked = '';

    // set inverse values because the token gets validated against the submitted value
    $value = 1;
  }
  $token_key = "itoggle_{$type}_{$property}_{$id}_{$value}";

  // @TODO find out whether there's a better place to do this
  // add an individual token for each combination
  drupal_add_js(array(
    'itoggle' => array(
      'tokens' => array(
        "itoggle_{$type}_{$property}_{$id}_{$value}" => drupal_get_token($token_key),
      ),
    ),
  ), 'setting');
  $element_id = "itoggle_{$type}_{$property}_{$id}";
  return <<<HTML
<div class="itoggle-wrapper itoggle-{<span class="php-variable">$type</span>} itoggle-{<span class="php-variable">$type</span>}_{<span class="php-variable">$property</span>}" data-id="{<span class="php-variable">$id</span>}" data-type="{<span class="php-variable">$type</span>}" data-scope="{<span class="php-variable">$scope</span>}" data-property="{<span class="php-variable">$property</span>}">
  <input type="checkbox" id="{<span class="php-variable">$element_id</span>}" {<span class="php-variable">$checked</span>} />
</div>
HTML;
}