You are here

function theme_upload_element in Upload element 6

Theme function to format the edit form.

1 theme call to theme_upload_element()
theme_image_upload_element in ./upload_element.module
Theme function to format the edit form.

File

./upload_element.module, line 299
A module that provides two new elements to the FAPI for file handling.

Code

function theme_upload_element($element) {
  _form_set_class($element, array(
    'form-file',
  ));
  $preview = '';
  if ($element['#image_formatter']) {
    $preview = theme($element['#image_formatter'], $element);

    // We need to calculate the required margin for the details section.
    $width = 100;
    if ($element['#image_preview_size'] && preg_match('/^\\d+x\\d+$/', $element['#image_preview_size'])) {
      list($width, ) = explode('x', $element['#image_preview_size'], 2);
    }
    $details_styles = ' style="margin-left:' . ($width + 10) . 'px;"';
  }
  $file_details = '';
  if ($element['#file_formatter']) {
    $file_details = theme($element['#file_formatter'], $element);
  }
  $messages = '';
  if (!empty($element['#messages'])) {
    $messages = ' <div class="ahah-messages">' . $element['#messages'] . "</div>\n";
  }
  $action_field = _upload_element_action_field($element);
  $description = $element['#description'] ? '<div class="description">' . $element['#description'] . '</div>' : '';
  $value = <<<END
    {<span class="php-variable">$preview</span>}
    <div class="upload-element-detail" {<span class="php-variable">$details_styles</span>}>
      {<span class="php-variable">$messages</span>}
      {<span class="php-variable">$file_details</span>}
      {<span class="php-variable">$action_field</span>}
      {<span class="php-variable">$element</span>[<span class="php-string">'#children'</span>]}
      <br class="upload-element-clear" />
      {<span class="php-variable">$description</span>}
    </div>
    <br class="upload-element-clear" />
END;
  $ahah_wrapper_id = $element['#id'] . '-ahah-wrapper';
  unset($element['#id']);
  unset($element['#description']);
  return isset($element['#is_ahah']) ? $value : theme('form_element', $element, "<div id=\"{$ahah_wrapper_id}\" class=\"upload-element-row\">" . $value . '</div>');
}