1 call to _advagg_admin_settings_information()
advagg_advagg_admin_form dans includes/admin.inc
Implements hook_advagg_admin_form(). @see: advagg_form_system_performance_settings_alter().

Fichier

includes/admin.inc, line 246

Code

function _advagg_admin_settings_information(&$form, &$form_state) {
    $form['hook_process_html'] = array(
        '#type' => 'fieldset',
        '#collapsible' => TRUE,
        '#collapsed' => FALSE,
        '#title' => t('$theme_registry[html][process functions]'),
        '#description' => t('Ensure that %advagg_process_html is at the bottom of the array of functions. It is vital for this function to be the last in the list as it will be altering and completely replacing the CSS and JavaScript loaded on each page request. If other functions appear after it, you may experience undesirable functionality or this module may not work at all.', array(
            '%advagg_process_html' => 'advagg_process_html',
        )),
    );
    drupal_theme_initialize();
    $theme_registry = theme_get_registry();
    if (module_exists('devel')) {
        $form['hook_process_html']['value'] = array(
            '#markup' => kprint_r($theme_registry['html']['process functions'], TRUE),
        );
    }
    else {
        $form['hook_process_html']['value'] = array(
            '#type' => 'textarea',
            '#default_value' => implode("\n", $hooks['html']['process functions']),
            '#rows' => count($theme_registry['html']['process functions']) + 1,
        );
    }
    $types = db_query("SELECT DISTINCT(filetype) FROM {advagg_files}");
    while ($type = $types->fetchField()) {
        $form[$type] = array(
            '#type' => 'fieldset',
            '#collapsible' => TRUE,
            '#collapsed' => TRUE,
            '#title' => t('@type files', array(
                '@type' => drupal_strtoupper($type),
            )),
        );
        // filename  filename_md5  checksum  filetype  counter   data
        $results = db_query("SELECT * FROM {advagg_files} WHERE filetype = :filetype", array(
            ':filetype' => $type,
        ));
        while ($row = db_fetch_array($results)) {
            $data = advagg_get_file_data($row['filename_md5']);
            if (!empty($data)) {
                list($data, $rows) = advagg_form_print_r($data);
                $form[$type][$row['filename_md5']] = array(
                    '#type' => 'textarea',
                    '#title' => check_plain($row['filename']),
                    '#default_value' => $data,
                    '#rows' => $rows - 1,
                    '#description' => t('File has changed %counter times', array(
                        '%counter' => $row['counter'],
                    )),
                );
            }
            else {
                $form[$type][$row['filename_md5']] = array(
                    '#markup' => '<div>' . format_plural($row['counter'], 'changed 1 time - %file<br />', 'changed %counter times - %file<br /></div>', array(
                        '%counter' => $row['counter'],
                        '%file' => $row['filename'],
                    )),
                );
            }
        }
    }
    // Get hooks in use.
    $hooks = array(
        'advagg_admin_form' => array(),
        'advagg_css_alter' => array(),
        'advagg_css_inline_alter' => array(),
        'advagg_css_pre_alter' => array(),
        'advagg_css_extra_alter' => array(),
        'advagg_js_alter' => array(),
        'advagg_js_inline_alter' => array(),
        'advagg_js_pre_alter' => array(),
        'advagg_js_extra_alter' => array(),
        'advagg_js_header_footer_alter' => array(),
        'advagg_filenames_alter' => array(),
        'advagg_files_table' => array(),
        'advagg_master_reset' => array(),
        'advagg_disable_processor' => array(),
        'advagg_disable_page_cache' => array(),
        'advagg_bundler_analysis_alter' => array(),
    );
    foreach ($hooks as $hook => $values) {
        $hooks[$hook] = module_implements($hook);
    }
    // Record function overrides. Not working currently.
    //   $hooks['advagg_css_render_function'] = array(variable_get('advagg_css_render_function', ADVAGG_CSS_RENDER_FUNCTION));
    //   $hooks['advagg_js_render_function'] = array(variable_get('advagg_js_render_function', ADVAGG_JS_RENDER_FUNCTION));
    //   $hooks['advagg_file_save_function'] = array(variable_get('advagg_file_save_function', ADVAGG_FILE_SAVE_FUNCTION));
    $form['hooks_implemented'] = array(
        '#type' => 'fieldset',
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#title' => t('Modules implementing advagg hooks'),
    );
    // Output hooks in form.
    foreach ($hooks as $hook => $values) {
        if (empty($values)) {
            $form['hooks_implemented'][$hook] = array(
                '#markup' => '<div><strong>' . check_plain($hook) . ':</strong><br />&nbsp;&nbsp;&nbsp;&nbsp;' . t('None') . '</div>',
            );
        }
        else {
            $form['hooks_implemented'][$hook] = array(
                '#markup' => '<div><strong>' . check_plain($hook) . ':</strong><br />&nbsp;&nbsp;&nbsp;&nbsp;' . filter_xss(implode('<br />&nbsp;&nbsp;&nbsp;&nbsp;', $values)) . '</div>',
            );
        }
    }
    // If any files are missing list them.
    // TODO: Reset missing files list.
    $results = db_query("SELECT * FROM {advagg_files} WHERE checksum = :checksum ORDER BY filetype ASC", array(
        ':checksum' => '-1',
    ));
    while ($row = $results->fetchAssoc()) {
        $form['missing'][$row['filename_md5']] = array(
            '#type' => 'markup',
            '#value' => '<div>' . check_plain($row['filename']) . '<br /></div>',
        );
    }
    if (!empty($form['missing'])) {
        $form['missing'] += array(
            '#type' => 'fieldset',
            '#collapsible' => TRUE,
            '#collapsed' => FALSE,
            '#title' => t('Missing files'),
        );
    }
    // Asynchronous raw output
    $form['async'] = array(
        '#type' => 'fieldset',
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#title' => t('Asynchronous debug info'),
    );
    list($css_path, $js_path) = advagg_get_root_files_dir();
    $filepath = $css_path . '/css_missing' . mt_rand() . REQUEST_TIME . '_0.css';
    $url = _advagg_build_url($filepath);
    $headers = array(
        'Host' => $_SERVER['HTTP_HOST'],
        'Connection' => 'close',
    );
    timer_start(__FUNCTION__ . 'local');
    $data_local = drupal_http_request($url, array(
        'headers' => $headers,
    ));
    $data_local->timer = timer_stop(__FUNCTION__ . 'local');
    // Use Krumo if Devel is installed.
    if (module_exists('devel')) {
        $form['async']['cdn'] = array(
            '#markup' => kprint_r($data_local, TRUE, t('Local Asynchronous Mode') . ' (' . check_plain($url) . ')'),
        );
    }
    else {
        list($data, $rows) = advagg_form_print_r($data_local);
        $form['async']['normal'] = array(
            '#type' => 'textarea',
            '#title' => t('Local Asynchronous Mode') . ' (' . check_plain($url) . ')',
            '#default_value' => $data,
            '#rows' => min($rows + 1, 50),
        );
    }
    if (module_exists('cdn')) {
        global $conf;
        $path_blacklist = variable_get(CDN_EXCEPTION_DRUPAL_PATH_BLACKLIST_VARIABLE, CDN_EXCEPTION_DRUPAL_PATH_BLACKLIST_DEFAULT);
        $conf[CDN_EXCEPTION_DRUPAL_PATH_BLACKLIST_VARIABLE] = '';
        $url_cdn = advagg_build_uri($filepath);
        $conf[CDN_EXCEPTION_DRUPAL_PATH_BLACKLIST_VARIABLE] = $path_blacklist;
        // Send request and also time it.
        timer_start(__FUNCTION__ . 'cdn');
        $data_cdn = drupal_http_request($url_cdn);
        $data_cdn->timer = timer_stop(__FUNCTION__ . 'cdn');
        // Use Krumo if Devel is installed.
        if (module_exists('devel')) {
            $form['async']['cdn'] = array(
                '#markup' => kprint_r($data_cdn, TRUE, t('CDN Asynchronous Mode') . ' (' . check_plain($url) . ')'),
            );
        }
        else {
            list($data, $rows) = advagg_form_print_r($data_cdn);
            $form['async']['cdn'] = array(
                '#type' => 'textarea',
                '#title' => t('CDN Asynchronous Mode') . ' (' . check_plain($url) . ')',
                '#default_value' => $data,
                '#rows' => min($rows + 1, 50),
            );
        }
    }
}