| 1 |
<?php |
<?php |
| 2 |
// $Id: parser.inc,v 1.41.2.27 2009/10/05 01:16:20 drumm Exp $ |
// $Id: parser.inc,v 1.41.2.28 2009/10/08 06:07:46 drumm Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 681 |
$path = file_create_path('api'); |
$path = file_create_path('api'); |
| 682 |
file_check_directory($path, FILE_CREATE_DIRECTORY); |
file_check_directory($path, FILE_CREATE_DIRECTORY); |
| 683 |
$date = gmdate('U'); |
$date = gmdate('U'); |
| 684 |
foreach (api_get_branches() as $branch_name => $branch) { |
foreach (api_get_branches() as $branch) { |
| 685 |
$new_json = api_autocomplete($branch_name, FALSE); |
$new_json = api_autocomplete($branch->branch_name, FALSE); |
| 686 |
|
|
| 687 |
$old_file_path = variable_get('api_autocomplete_path_' . $branch_name, FALSE); |
$old_file_path = variable_get('api_autocomplete_path_' . $branch->branch_name, FALSE); |
| 688 |
if ($old_file_path !== FALSE) { |
if ($old_file_path !== FALSE) { |
| 689 |
if (md5($new_json) === md5(file_get_contents($old_file_path))) { |
if (md5($new_json) === md5(file_get_contents($old_file_path))) { |
| 690 |
continue; // No changes, no file write. |
continue; // No changes, no file write. |
| 693 |
job_queue_add('file_delete', t('Remove expired API JSON, %path.'), array('%path' => $old_file_path)); |
job_queue_add('file_delete', t('Remove expired API JSON, %path.'), array('%path' => $old_file_path)); |
| 694 |
} |
} |
| 695 |
|
|
| 696 |
$file_name = $path . '/api-' . $branch_name . '-' . $date . '.json'; |
$file_name = $path . '/api-' . $branch->branch_name . '-' . $date . '.json'; |
| 697 |
file_save_data($new_json, $file_name, FILE_EXISTS_REPLACE); |
file_save_data($new_json, $file_name, FILE_EXISTS_REPLACE); |
| 698 |
variable_set('api_autocomplete_path_' . $branch_name, $file_name); |
variable_set('api_autocomplete_path_' . $branch->branch_name, $file_name); |
| 699 |
} |
} |
| 700 |
} |
} |
| 701 |
|
|