You are here

function advagg_admin_rebuild_bundles in Advanced CSS/JS Aggregation 6

Same name and namespace in other branches
  1. 7 includes/admin.inc \advagg_admin_rebuild_bundles()

Rebuild bundles.

1 string reference to 'advagg_admin_rebuild_bundles'
advagg_admin_batch_rebuild in ./advagg.admin.inc
Set up batch for first and last name loading.

File

./advagg.admin.inc, line 621
Admin page callbacks for the advanced CSS/JS aggregation module.

Code

function advagg_admin_rebuild_bundles($increment, &$context) {

  // init batch.
  if (!isset($context['sandbox']['progress'])) {
    $context['sandbox']['progress'] = 0;
    $context['sandbox']['max'] = db_result(db_query("SELECT COUNT(*) FROM (SELECT bundle_md5 FROM {advagg_bundles} GROUP BY bundle_md5) as temp"));

    // Increment All Counters.
    if ($increment) {
      db_query("UPDATE {advagg_bundles} SET counter = counter + 1");
    }
  }

  // Set limit.
  $limit = 1;

  // Get list of all bundles.
  $result = db_query_range("SELECT bundle_md5 FROM {advagg_bundles} GROUP BY bundle_md5", $context['sandbox']['progress'], $limit);
  while ($bundle_md5 = db_result($result)) {
    $filenames = advagg_rebuild_bundle($bundle_md5, '', TRUE);
    $filename = array();
    foreach ($filenames as $name => $data) {
      $filename[] = $name;
    }

    // Update our progress information.
    $context['sandbox']['progress']++;
    $context['message'] = t('%md5 Created', array(
      '%md5' => $bundle_md5,
    ));
    $context['results'][] = $filename;
  }

  // Inform the batch engine that we are not finished,
  // and provide an estimation of the completion level we reached.
  if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
  }
}