Form builder; Show info about advagg and advagg settings.

See also

system_settings_form()

Related topics

1 string reference to 'advagg_admin_info_form'
advagg_menu in ./advagg.module
Implements hook_menu().

File

./advagg.admin.inc, line 1051

Code

function advagg_admin_info_form($form, $form_state) {
    drupal_set_title(t('AdvAgg: Information'));
    advagg_display_message_if_requirements_not_met();
    // Explain what can be done on this page.
    $form['tip'] = array(
        '#markup' => '<p>' . t('This page provides debugging information. There are no configuration options here.') . '</p>',
    );
    // Get all hooks and variables.
    drupal_theme_initialize();
    $core_hooks = theme_get_registry();
    $advagg_hooks = advagg_hooks_implemented();
    list(, $js_path) = advagg_get_root_files_dir();
    // Output html process functions hooks.
    $form['theme_info'] = array(
        '#type' => 'fieldset',
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#title' => t('Hook Theme Info'),
    );
    $data = implode("\n", $core_hooks['html']['process functions']);
    $form['theme_info']['advagg_theme_info'] = array(
        '#markup' => '<pre>' . $data . '</pre>',
    );
    $form['render_info'] = array(
        '#type' => 'fieldset',
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#title' => t('Hook Render Info'),
    );
    $element_info = array();
    $element_info['scripts'] = element_info('scripts');
    $element_info['styles'] = element_info('styles');
    $output = '';
    foreach ($element_info as $type => &$values) {
        $output .= $type . ":\n";
        foreach ($values as $key => &$value) {
            if ($key === '#items' || $key === '#type') {
                continue;
            }
            if (empty($value)) {
                $output .= '  ' . $key . ' - ' . str_replace(array(
                    "\r",
                    "\n",
                ), '', (string) var_export($value, TRUE)) . "\n";
            }
            elseif (is_array($value)) {
                $output .= '  ' . $key . ' - ' . implode(', ', $value) . "\n";
            }
            else {
                $output .= '  ' . $key . ' - ' . print_r($value, TRUE) . "\n";
            }
        }
    }
    $form['render_info']['advagg_render_info'] = array(
        '#markup' => '<pre>' . $output . '</pre>',
    );
    // Get all parent css and js files.
    $types = array(
        'css',
        'js',
    );
    $css_file = '';
    foreach ($types as $type) {
        $form[$type] = array(
            '#type' => 'fieldset',
            '#collapsible' => TRUE,
            '#collapsed' => TRUE,
            '#title' => t('@type files', array(
                '@type' => drupal_strtoupper($type),
            )),
        );
        // Get filename, filename_hash, and changes.
        $results = db_select('advagg_files', 'af')->fields('af', array(
            'filename',
            'filename_hash',
            'changes',
        ))
            ->condition('filetype', $type)
            ->orderBy('filename', 'ASC')
            ->execute();
        while ($row = $results->fetchAssoc()) {
            if (empty($css_file) && $type === 'css') {
                $css_file = basename($row['filename']);
            }
            $form[$type][$row['filename_hash']] = array(
                '#markup' => '<div>' . format_plural($row['changes'], 'changed 1 time - %file<br />', 'changed %changes times - %file<br /></div>', array(
                    '%changes' => $row['changes'],
                    '%file' => $row['filename'],
                )),
            );
        }
    }
    // Display as module -> hook instead of hook -> module.
    ksort($advagg_hooks);
    $module_hooks = array();
    foreach ($advagg_hooks as $hook => $values) {
        if (!empty($values)) {
            foreach ($values as $module_name) {
                if (!isset($module_hooks[$module_name])) {
                    $module_hooks[$module_name] = array();
                }
                $module_hooks[$module_name][] = $hook;
            }
        }
        else {
            $module_hooks['not in use'][] = $hook;
        }
    }
    ksort($module_hooks);
    // Output all advagg hooks implemented.
    foreach ($module_hooks as $hook => $values) {
        if (empty($values)) {
            $form['modules_implementing_advagg'][$hook] = array(
                '#markup' => '<div><strong>' . check_plain($hook) . ':</strong> 0</div>',
            );
        }
        else {
            $form['modules_implementing_advagg'][$hook] = array(
                '#markup' => '<div><strong>' . check_plain($hook) . ':</strong> ' . count($values) . '<br />&nbsp;&nbsp;' . filter_xss(implode('<br />&nbsp;&nbsp;', $values), array(
                    'br',
                )) . '</div>',
            );
        }
    }
    $form['modules_implementing_advagg'] += array(
        '#type' => 'fieldset',
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#title' => t('Modules implementing AdvAgg CSS/JS hooks'),
    );
    // Output all advagg hooks implemented.
    foreach ($advagg_hooks as $hook => $values) {
        if (empty($values)) {
            $form['hooks_implemented'][$hook] = array(
                '#markup' => '<div><strong>' . check_plain($hook) . ':</strong> 0</div>',
            );
        }
        else {
            $form['hooks_implemented'][$hook] = array(
                '#markup' => '<div><strong>' . check_plain($hook) . ':</strong> ' . count($values) . '<br />&nbsp;&nbsp;' . filter_xss(implode('<br />&nbsp;&nbsp;', $values), array(
                    'br',
                )) . '</div>',
            );
        }
    }
    $form['hooks_implemented'] += array(
        '#type' => 'fieldset',
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#title' => t('AdvAgg CSS/JS hooks implemented by modules'),
    );
    // Output what is used inside of the advagg_get_current_hooks_hash() function.
    $form['hooks_variables_hash'] = array(
        '#type' => 'fieldset',
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#title' => t('Hooks And Variables Used In Hash'),
    );
    $form['hooks_variables_hash']['description'] = array(
        '#markup' => t('Current Value: %value. Below is the listing of variables and hooks used to generate the 3rd hash of an aggregates filename.', array(
            '%value' => advagg_get_current_hooks_hash(),
        )),
    );
    $form['hooks_variables_hash']['output'] = array(
        // @ignore production_php
'#markup' => '<pre>' . print_r(advagg_current_hooks_hash_array(), TRUE) . '</pre>',
    );
    // Get info about a file.
    $form['get_info_about_agg'] = array(
        '#type' => 'fieldset',
        '#collapsible' => TRUE,
        '#collapsed' => FALSE,
        '#title' => t('Get detailed info about an aggregate file'),
    );
    $form['get_info_about_agg']['filename'] = array(
        '#type' => 'textfield',
        '#size' => 170,
        '#maxlength' => 256,
        '#default_value' => '',
        '#title' => t('Filename'),
    );
    $form['get_info_about_agg']['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Lookup Details'),
        '#submit' => array(
            'advagg_admin_get_file_info_submit',
        ),
        '#validate' => array(
            'advagg_admin_get_file_info_validate',
        ),
        '#ajax' => array(
            'callback' => 'advagg_admin_get_file_info_callback',
            'wrapper' => 'advagg-file-info-ajax',
            'effect' => 'fade',
        ),
    );
    module_load_include('install', 'advagg', 'advagg');
    $first_file_path = advagg_s3fs_evaluate_no_rewrite_cssjs(FALSE) ? $js_path[0] : $js_path[1];
    $form['get_info_about_agg']['tip'] = array(
        '#markup' => '<p>' . t('Takes input like "@css_file" or a full aggregate name like "@advagg_js"', array(
            '@css_file' => $css_file,
            '@advagg_js' => advagg_install_get_first_advagg_file($first_file_path, 'js'),
        )) . '</p>',
    );
    $form['get_info_about_agg']['wrapper'] = array(
        '#markup' => "<div id='advagg-file-info-ajax'></div>",
    );
    return $form;
}