function amp_admin_form in Accelerated Mobile Pages (AMP) 7
Form constructor for the AMP administration form.
See also
1 string reference to 'amp_admin_form'
- amp_menu in ./
amp.module - Implements hook_menu().
File
- ./
amp.admin.inc, line 15 - Administrative page callbacks for the AMP module.
Code
function amp_admin_form($form, &$form_state) {
$form = array();
if (!module_exists('token')) {
// Provide message in case somebody has upgraded AMP module but has not
// installed Token.
drupal_set_message(t('The AMP module requires the <a href="@module">Token</a> module as a dependency. Please download and install Token to prevent errors with AMP.', array(
'@module' => 'https://www.drupal.org/project/token',
)), 'warning');
}
if (!module_exists('ctools')) {
// Provide message in case somebody has upgraded AMP module but has not
// installed ctools.
drupal_set_message(t('The AMP module requires the <a href="@module">ctools</a> module as a dependency. Please download and install ctools to prevent errors with AMP.', array(
'@module' => 'https://www.drupal.org/project/ctools',
)), 'warning');
}
if (module_exists('field_ui')) {
$form['amp_content_amp_status'] = array(
'#title' => t('AMP Status by Content Type'),
'#theme' => 'item_list',
'#items' => amp_get_formatted_status_list(),
);
}
else {
$form['amp_content_amp_status'] = array(
'#type' => 'item',
'#title' => t('AMP Status by Content Type'),
'#markup' => t('(In order to enable and disable AMP content types in the UI, the Field UI module must be enabled.)'),
);
}
// AMP theme settings.
$form['amp_theme'] = array(
'#type' => 'select',
'#options' => _amp_get_theme_options(),
'#title' => t('AMP theme'),
'#description' => t('Choose a theme to use for AMP pages.'),
'#default_value' => variable_get('amp_theme', 'ampsubtheme_example'),
);
if (!module_exists('amp_adsense')) {
$form['amp_google_adsense_id'] = array(
'#type' => 'textfield',
'#title' => t('Google AdSense Publisher ID'),
'#default_value' => variable_get('amp_google_adsense_id'),
'#maxlength' => 25,
'#size' => 20,
'#description' => t('This is the Google AdSense Publisher ID for the site owner. Get this in your Google Adsense account. It should be similar to pub-9999999999999'),
);
}
if (!module_exists('amp_dfp')) {
$form['amp_google_doubleclick_id'] = array(
'#type' => 'textfield',
'#title' => t('Google DoubleClick for Publishers Network ID'),
'#default_value' => variable_get('amp_google_doubleclick_id', '/'),
'#maxlength' => 25,
'#size' => 20,
'#description' => t('The Network ID to use on all tags. This value should begin with a /.'),
);
}
$form['pixel_group'] = array(
'#type' => 'fieldset',
'#title' => t('amp-pixel'),
);
$form['pixel_group']['amp_pixel'] = array(
'#type' => 'checkbox',
'#title' => t('Enable amp-pixel'),
'#default_value' => variable_get('amp_pixel'),
'#description' => t('The amp-pixel element is meant to be used as a typical tracking pixel -- to count page views. Find more information in the <a href="https://www.ampproject.org/docs/reference/amp-pixel.html">amp-pixel documentation</a>.'),
);
$form['pixel_group']['amp_pixel_domain_name'] = array(
'#type' => 'textfield',
'#title' => t('amp-pixel domain name'),
'#default_value' => variable_get('amp_pixel_domain_name'),
'#description' => t('The domain name where the tracking pixel will be loaded: do not include http or https.'),
'#states' => array(
'visible' => array(
':input[name="amp_pixel"]' => array(
'checked' => TRUE,
),
),
),
);
$form['pixel_group']['amp_pixel_query_string'] = array(
'#type' => 'textfield',
'#title' => t('amp-pixel query path'),
'#default_value' => variable_get('amp_pixel_query_string'),
'#description' => t('The path at the domain where the GET request will be received, e.g. "pixel" in example.com/pixel?RANDOM.'),
'#states' => array(
'visible' => array(
':input[name="amp_pixel"]' => array(
'checked' => TRUE,
),
),
),
);
$form['pixel_group']['amp_pixel_random_number'] = array(
'#type' => 'checkbox',
'#title' => t('Random number'),
'#default_value' => variable_get('amp_pixel_random_number'),
'#description' => t('Use the special string RANDOM to add a random number to the URL if required. Find more information in the <a href="https://github.com/ampproject/amphtml/blob/master/spec/amp-var-substitutions.md#random">amp-pixel documentation</a>.'),
'#states' => array(
'visible' => array(
':input[name="amp_pixel"]' => array(
'checked' => TRUE,
),
),
),
);
$form['amp_library_group'] = array(
'#type' => 'fieldset',
'#title' => t('AMP Library Configuration <a href="https://github.com/Lullabot/amp-library">(GitHub Home and Documentation)</a>'),
);
$form['amp_library_group']['amp_test_page'] = array(
'#type' => 'item',
'#markup' => t('<a href="@url">Test that AMP is configured properly</a>', array(
'@url' => '/admin/config/amp/library/test',
)),
);
$form['amp_library_group']['amp_library_warnings_display'] = array(
'#type' => 'checkbox',
'#title' => t('<em>Debugging</em>: Show AMP Library warnings in <em>all</em> AMP text formatters for <em>all</em> users'),
'#default_value' => variable_get('amp_library_warnings_display', false),
'#description' => t('<ul><li>If you only want to see amp formatter specific warning for one node add ' . 'query "warnfix" at end of a node url. e.g. <strong>node/12345?amp&warnfix</strong></li>' . '<li>If the Debugging checkbox value is changed upon save, the Drupal cache will be cleared</li>'),
);
$form['amp_library_group']['amp_library_process_full_html'] = array(
'#type' => 'checkbox',
'#title' => t('<strong><em>Power User:</em> Run the whole HTML page through the AMP library</strong>'),
'#default_value' => variable_get('amp_library_process_full_html', false),
'#description' => t('The AMP PHP library will fix many AMP HTML standard non-compliance issues by ' . 'removing illegal or disallowed attributes, tags and property value pairs. This is useful for processing the output of modules that ' . 'generate AMP unfriendly HTML. Please test when enabling on your site as some modules may depend on ' . 'the HTML removed by the library and thus break in possibly subtle ways.'),
);
$form['amp_library_group']['amp_library_process_statistics'] = array(
'#type' => 'checkbox',
'#title' => t('<em>Statistics:</em> Add an <a href="https://www.drupal.org/files/issues/time_taken.png">HTML comment</a> at the end of Drupal page output indicating various performance statistics like time taken, number of tags processed etc.'),
'#default_value' => variable_get('amp_library_process_statistics', false),
'#states' => array(
'visible' => array(
':input[name="amp_library_process_full_html"]' => array(
'checked' => TRUE,
),
),
),
);
$form['amp_library_group']['amp_library_process_full_html_warnings'] = array(
'#type' => 'checkbox',
'#title' => t('<em>Debugging:</em> Add a notice in the Drupal log for each processed AMP page showing the AMP warnings (and fixes) generated'),
'#default_value' => variable_get('amp_library_process_full_html_warnings', false),
'#description' => t('A Drupal log entry will be generated for <em>each</em> non-anonymous AMP request. ' . 'However <em>anonymous</em> page requests will be cached by Drupal and will not repeatedly call the AMP library.'),
'#states' => array(
'visible' => array(
':input[name="amp_library_process_full_html"]' => array(
'checked' => TRUE,
),
),
),
);
$form['#submit'] = array(
'amp_admin_form_submit',
);
return system_settings_form($form);
}