<?php
/**
 * @file
 * Contains theme override functions and preprocess functions for the SeeD sub-theme.
 */
/*
function seed_policia_button($variables) {
  $element = $variables['element'];
  $label = $element['#value'];
  
  if($element['#type'] === 'submit') {
//    unset($element['#attributes']['name']); 
    
    if(    ISSET($element['#id']) && !ISSET($element['#attributes']['id'])   ) {
      $element['#attributes']['id'] = $element['#id'];
    }
    if(    ISSET($element['#value']) && !ISSET($element['#attributes']['value'])   ) {
      $element['#attributes']['value'] = $element['#value'];
    }
    if( !ISSET($element['#attributes']['class']) ) {
      $element['#attributes']['class'] = array('form-submit');
    }
    
    $markup = '<input type="submit" ' . drupal_attributes($element['#attributes']) . " />\n";
  } else {
    $markup = '<button' . drupal_attributes($element['#attributes']) . '>' . $label ."</button>\n";
  }
  
  return $markup; 
} */



function seed_policia_preprocess_button($variables) {
  
  if($variables['element']['#type'] === 'submit') {
    unset($variables['element']['#name']);
  }
}


/**
 * THEME_form_element_label().
 */ 
function seed_policia_form_element_label($variables) {
    //~ dsm($variables);
  $element = $variables['element'];
  // This is also used in the installer, pre-database setup.
  $t = get_t();

  // If title and required marker are both empty, output no label.
  if ((!isset($element['#title']) || $element['#title'] === '') && empty($element['#required'])) {
    return '';
  }

  // If the element is required, a required marker is appended to the label.
  $required = !empty($element['#required']) ? theme('form_required_marker', array('element' => $element)) : '';

  $title = filter_xss_admin($element['#title']);

  $attributes = array();
  // Style the label as class option to display inline with the element.
  if ($element['#title_display'] == 'after') {
    $attributes['class'] = 'option';
  }
  // Show label only to screen readers to avoid disruption in visual flows.
  elseif ($element['#title_display'] == 'invisible') {
    $attributes['class'] = 'element-invisible';
  }

  if (!empty($element['#id'])) {
    $attributes['for'] = $element['#id'];
  }
  //~ This conditional set the id input data-pick as For attribute.
  if ($element['#type'] == 'date_popup') {
    $arg0 = arg(0);
    switch ($arg0) {
      case 'noticias':
        $attributes['for'] = $element['date']['#id'];
        break;
      case 'resultados':
        if (arg(1) == 'unidad') {
          $attributes['for'] = $element['date']['#id'];
        }
        break;
    }
  }
  // The leading whitespace helps visually separate fields from inline labels.
  return ' <label' . drupal_attributes($attributes) . '>' . $t('!title !required', array('!title' => $title, '!required' => $required)) . "</label>\n";
}

/**
 * THEME_file_icon().
 */

function seed_policia_file_icon($variables) {
  $file = $variables['file'];
  $alt = $variables['alt'];
  $icon_directory = $variables['icon_directory'];

  $mime = check_plain($file->filemime);
  $icon_url = file_icon_url($file, $icon_directory);
  return '<img class="file-icon" alt="' . check_plain($alt) . '" src="' . $icon_url . '" />';
}
