<?php

/**
 * TODO.
 *
 * @param 
 *   TODO
 * @return
 *   TODO.
 */
function theme_vote_type($variables) {
  $type = $variables['type'];
  $definition = vote_fetch_type_definition($type);
  
  return !empty($definition) ? $definition['title'] . ' (' . $type . ')' : '';	
}

/**
 * TODO.
 *
 * @param 
 *   TODO
 * @return
 *   TODO.
 */
function theme_vote_functions($variables) {
  $output = array();
  $functions = $variables['functions'];
  
  foreach ($functions as $function => $info) {
  	if ($info['status']) {
  	  $function = vote_fetch_function_definition($function);
  	  
  	  if (!empty($function)) {
  	  	$output[] = $function['title'];
  	  }
  	}
  }
  
  return !empty($output) ? implode(', ', $output) : t('- None -');
}

/**
 * TODO.
 *
 * @param 
 *   TODO
 * @return
 *   TODO.
 */
function theme_vote_pool($variables) {
  $output = array();
  $pool = $variables['pool'];

  return $pool->name . ' (' . $pool->pool . ')';
}

/**
 * TODO.
 *
 * @param 
 *   TODO
 * @return
 *   TODO.
 */
function theme_vote_functions_options($variables) {
  $options = array();
  $functions = $variables['functions'];
  
  foreach ($functions as $function => $info) {
    $options[$function] = $info['title'] . ' - <span class="description">' . $info['description'] . '</span>';
  }
  
  return $options;
}

/**
 * TODO.
 *
 * @param 
 *   TODO
 * @return
 *   TODO.
 */
function theme_vote_pools_options($variables) {
  $options = array();
  $pools = $variables['pools'];
  
  foreach ($pools as $pool) {
    $options[$pool->pool] = $pool->name;
  }
  
  return $options;
}

/**
 * TODO.
 *
 * @param 
 *   TODO
 * @return
 *   TODO.
 */
function theme_vote_storage_options($variables) {
  $options = array();
  $methods = $variables['methods'];
  
  foreach ($methods as $method => $info) {
    $options[$method] = $info['label'] . ' - <span class="description">' . $info['description'] . '</span>';
  }
  
  return $options;
}

/**
 * TODO.
 *
 * @param 
 *   TODO
 * @return
 *   TODO.
 */
function theme_vote_definitions_options($variables) {
  $options = array();
  $definitions = $variables['definitions'];
  
  foreach ($definitions as $definition => $info) {
    if ($variables['description']) {
      $options[$definition] = $info['title'] . ' - <span class="description">' . $info['description'] . '</span>';
    } 
    else {
      $options[$definition] = $info['title'];      
    }
  }
  
  return $options;
}

/**
 * TODO.
 *
 * @param 
 *   TODO
 * @return
 *   TODO.
 */
function theme_vote_operations_options($variables) {
  $options = array();
  $operations = $variables['operations'];
  
  foreach ($operations as $operation => $info) {
    $options[$operation] = $info['label'];
  }
  
  return $options;
}

/**
 * TODO.
 *
 * @param 
 *   TODO
 * @return
 *   TODO.
 */
function theme_vote_entities_options($variables) {
  $options = array();
  $entities = $variables['entities'];
  
  foreach ($entities as $entity => $info) {
    $options[$entity] = $info['label'];
  }
  
  return $options;
}