function advagg_admin_rebuild_bundles in Advanced CSS/JS Aggregation 7
Same name and namespace in other branches
- 6 advagg.admin.inc \advagg_admin_rebuild_bundles()
Rebuild bundles.
1 string reference to 'advagg_admin_rebuild_bundles'
- advagg_admin_batch_rebuild in includes/
admin.inc - Set up batch for first and last name loading.
File
- includes/
admin.inc, line 646 - 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_query("SELECT COUNT(*) FROM (SELECT bundle_md5 FROM {advagg_bundles} GROUP BY bundle_md5) as temp")
->fetchField();
// Increment All Counters.
if ($increment) {
// TODO Please review the conversion of this statement to the D7 database API syntax.
/* db_query("UPDATE {advagg_bundles} SET counter = counter + 1") */
db_update('advagg_bundles')
->fields(array(
'counter' => counter + 1,
))
->execute();
}
}
// Set limit.
$limit = 1;
// Get list of all bundles.
$result = db_query_range("SELECT bundle_md5 FROM {advagg_bundles} GROUP BY bundle_md5");
while ($bundle_md5 = $result
->fetchField()) {
$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'];
}
}