You are here

public function GatherContentFunctions::getMediaAjaxOutput in GatherContent 7.2

Used during media import to return output array containing file details.

File

includes/functions.inc, line 118
Class containing general functions used throughout the importing. Extended by GatherContentCurl.

Class

GatherContentFunctions
@file Class containing general functions used throughout the importing. Extended by GatherContentCurl.

Code

public function getMediaAjaxOutput($post_id, $media, $cur_post, $page_total, $total) {
  $cur_num = $_POST['cur_num'];
  $cur_total = $_POST['cur_total'];
  $next_id = $post_id;
  if ($cur_num == $page_total) {
    $page_percent = 100;
    $cur_num = 1;
    unset($media[$post_id]);
    $next_id = key($media);
  }
  else {
    $page_percent = $this
      ->percent($cur_num, $page_total);
    $cur_num++;
    $media[$post_id] = $cur_post;
  }
  $media['total_files'] = $total;
  variable_set('gathercontent_media_files', $media);
  if ($cur_total == $total) {
    $next_id = $post_id;
    $page_percent = $overall_percent = '100';
  }
  else {
    $overall_percent = $this
      ->percent($cur_total, $total);
  }
  $cur_total++;
  $data = $this
    ->getPageTitleArray($next_id);
  if ($overall_percent == 100) {
    variable_set('gathercontent_media_files', array());
  }
  $out = array(
    'page_percent' => $page_percent,
    'overall_percent' => $overall_percent,
    'cur_num' => $cur_num,
    'cur_total' => $cur_total,
    'page_title' => $data['page_title'],
    'original_title' => $data['original_title'],
  );
  return $out;
}