You are here

function minisite_site_save in Mini site 7

Save and extract minisite.

1 call to minisite_site_save()
minisite_field_presave in includes/minisite.field.inc
Implements hook_field_presave().

File

./minisite.module, line 80
Module file.

Code

function minisite_site_save($entity_type, $entity, $field, $instance, $langcode, &$items) {
  foreach ($items as &$item) {
    if (isset($item['fid'])) {
      $file = file_load($item['fid']);
      if (!empty($file)) {

        // Load module inc file.
        module_load_include('inc', 'minisite', 'includes/minisite.site');
        list($minisite_extract_path, $minisite_base_path, $minisite_listing) = minisite_site_asset_info($item['fid'], FALSE);

        // Extract files.
        minisite_site_extract($file, $minisite_extract_path);

        // Save specific settings in data.
        $item['site_path'] = $minisite_extract_path . '/' . $minisite_base_path;
        $minisite_field_data = array(
          'minisite_alias_status' => isset($item['alias_status']) ? $item['alias_status'] : 0,
          'minisite_extract_path' => $minisite_extract_path,
          'minisite_base_path' => $minisite_base_path,
        );
        $item['data'] = serialize($minisite_field_data);
        $minisite_info = array(
          'minisite_extract_path' => $minisite_extract_path,
          'minisite_base_path' => $minisite_base_path,
          'minisite_listing' => $minisite_listing,
        );

        // Save assets information.
        drupal_register_shutdown_function('minisite_site_save_asset', $entity_type, $entity, $field['field_name'], $langcode, $item, $minisite_info);
      }
    }
  }
}