Get detailed info about the given filename.

Parameters

string $filename: Name of file to lookup.

Return value

array Returns an array of detailed info about this file.

Related topics

2 calls to advagg_admin_get_file_info()
advagg_admin_get_file_info_callback in ./advagg.admin.inc
Display file info via ajax callback.
advagg_admin_get_file_info_submit in ./advagg.admin.inc
Display file info in a drupal message.

File

./advagg.admin.inc, line 1469

Code

function advagg_admin_get_file_info($filename) {
    module_load_include('inc', 'advagg', 'advagg.missing');
    module_load_include('inc', 'advagg', 'advagg');
    // Strip quotes and trim.
    $filename = trim(str_replace(array(
        '"',
        "'",
    ), '', $filename));
    $data = advagg_get_hashes_from_filename(basename($filename));
    $output = array();
    if (is_array($data)) {
        list($type, $aggregate_filenames_hash, $aggregate_contents_hash) = $data;
        // Get a list of files.
        $files = advagg_get_files_from_hashes($type, $aggregate_filenames_hash, $aggregate_contents_hash);
        if (empty($files)) {
            list($css_path, $js_path) = advagg_get_root_files_dir();
            // Skip if the file exists.
            if ($type === 'css') {
                $uri = $css_path[0] . '/' . $filename;
            }
            elseif ($type === 'js') {
                $uri = $js_path[0] . '/' . $filename;
            }
            if (file_exists($uri)) {
                $atime = advagg_get_atime($aggregate_filenames_hash, $aggregate_contents_hash, $uri);
                if (REQUEST_TIME - $atime > variable_get('drupal_stale_file_threshold', 2592000)) {
                    $files = t('This is an old aggregate, it should be deleted on the next cron run.');
                }
                else {
                    $files = t('This is an old aggregate, it should be deleted on the cron run after !time.', array(
                        '!time' => format_interval(variable_get('drupal_stale_file_threshold', 2592000) - (REQUEST_TIME - $atime)),
                    ));
                }
            }
            else {
                $files = t('This aggregate file no longer exists.');
            }
        }
        $data['files'] = $files;
        // Get detailed info on each file.
        $files_info_filenames = array();
        foreach ($data['files'] as $filename => &$info) {
            $files_info_filenames[] = $filename;
        }
        unset($info);
        // Get filesystem data.
        $files_info = advagg_get_info_on_files($files_info_filenames);
        foreach ($data['files'] as $filename => &$info) {
            $info += $files_info[$filename];
            if (module_exists('advagg_bundler')) {
                $bundler = advagg_bundler_analysis($filename);
                $info['group_hash'] = $bundler['group_hash'];
            }
        }
        unset($info);
        $output = $data;
    }
    else {
        $results = db_select('advagg_files', 'af')->fields('af')
            ->condition('filename', '%' . db_like($filename), 'LIKE')
            ->execute();
        while ($row = $results->fetchAssoc()) {
            $row += advagg_get_info_on_file($row['filename']);
            if (module_exists('advagg_bundler')) {
                $bundler = advagg_bundler_analysis($row['filename']);
                $row['group_hash'] = $bundler['group_hash'];
            }
            $output[] = $row;
        }
    }
    return $output;
}