You are here

function theme_itoggle in iToggle 7.2

Same name and namespace in other branches
  1. 7.3 itoggle.module \theme_itoggle()
  2. 7 itoggle.module \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)
  • bool $clickable Whether the widget is clickable (triggers callback)
  • int $display_type The iToggle display type (0 = on/off, 1 = yes/no, 2 = 1/0)

Return value

string The rendered html for the iToggle widget.

See also

itoggle_theme()

4 theme calls to theme_itoggle()
itoggle_field_field_formatter_view in modules/field/itoggle_field.module
Implements hook_field_formatter_view().
itoggle_field_field_widget_form in modules/field/itoggle_field.module
Implements hook_field_widget_form().
itoggle_form_node_form_alter in ./itoggle.module
Implements hook_form_BASE_FORM_ID_alter().
itoggle_views_handler_field::render in modules/views/itoggle_views_handler_field.inc
Render the trigger field and its linked popup information.

File

./itoggle.theme.inc, line 32
iToggle theme functions.

Code

function theme_itoggle($variables) {
  static $element_ids;
  extract($variables);
  $checked = $checked == TRUE ? 'checked="checked"' : '';
  switch ($display_type) {
    case 0:
      $display_type = 'onoff';
      break;
    case 1:
      $display_type = 'yesno';
      break;
    case 2:
      $display_type = '10';
      break;
  }
  $element_id = "itoggle_{$type}_{$property}_{$id}_";
  if (!isset($element_ids[$element_id])) {
    $element_ids[$element_id] = 1;
  }
  else {
    $element_ids[$element_id]++;
  }
  $element_id .= $element_ids[$element_id];
  return <<<HTML
<div class="itoggle-wrapper itoggle-display-{<span class="php-variable">$display_type</span>} 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-bundle="{<span class="php-variable">$bundle</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;
}