You are here

function list_node_image_terms in Taxonomy Image 5

1 call to list_node_image_terms()
update_term_images.php in contributed/update_term_images.php

File

contributed/update_term_images.php, line 22

Code

function list_node_image_terms() {
  global $term_dir;
  $files = file_scan_directory($term_dir, '.*_(full|summ).*');
  if (!count($files)) {
    print 'No node_images for terms; update script does not support node images.';
    return;
  }
  $header = array(
    t('Term'),
    t('Image'),
    t('Migrate'),
    t('Delete'),
  );
  foreach ($files as $image) {
    $image->tid = migrate_term_image_get_tid($image->name);
    list($image->width, $image->height) = getimagesize($image->filename);
    if ($image->height > 100) {
      $image->height = $image->height / 2;
      $image->width = $image->width / 2;
    }
    $img = "<img src='{$image->filename} ' width='{$image->width}' height='{$image->height}' />";
    $term = taxonomy_get_term($image->tid);
    $t_i_image = db_fetch_object(db_query('SELECT path FROM {term_image} WHERE tid = %d', $image->tid));
    if ($t_i_image) {
      $term->has_image = true;
    }
    unset($t_i_image);
    $item = $term->name . '($image->name)';
    $migrate = form_checkbox(NULL, "migrate][" . $image->name, 1, $term->has_image ? 0 : 1);
    $delete = form_checkbox(NULL, "delete][" . $image->name, 1, $term->has_image ? 1 : 0);
    $rows[] = array(
      'data' => $item,
      $img,
      $migrate,
      $delete,
    );
  }
  $table = theme('table', $header, $rows);
  $table .= '<em>Checked rows do not have an existing taxonomy_image entry</em><br/>';
  $form = form($table . form_submit('Migrate'));
  print $form;
}