public function AnonymousPublishingClAdminBlocked::buildForm in Anonymous Publishing 8
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- modules/
anonymous_publishing_cl/ src/ Form/ AnonymousPublishingClAdminBlocked.php, line 44
Class
Namespace
Drupal\anonymous_publishing_cl\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
// Build an 'Update options' form.
$form['options'] = array(
'#type' => 'details',
'#title' => $this
->t('Update options'),
'#open' => TRUE,
'#attributes' => array(
'class' => array(
'container-inline',
),
),
);
$options = array(
'block' => $this
->t("Block the email address"),
'unblock' => $this
->t("Unblock the email address"),
);
$form['options']['operation'] = array(
'#type' => 'select',
'#title' => $this
->t('Action'),
'#title_display' => 'invisible',
'#options' => $options,
'#default_value' => 'publish',
);
$form['options']['submit'] = array(
'#type' => 'submit',
'#value' => $this
->t('Update'),
);
$form['apu_info'] = [
'#markup' => t("<p>The table below shows the email address used to verify, IP-address, generated alias, blocked status for all <em>verified</em> email addresses. To block or unblock some email adresses, check each corresponding line's below and execute the desired action.</p><p>Note than an email address is not listed here until it has been verified. For yet unverified addresses, see the <em>unverified</em> tab.</p>"),
];
$header = array(
'email' => array(
'data' => $this
->t('Verification email'),
),
'ip' => array(
'data' => $this
->t('IP-address'),
),
'alias' => array(
'data' => $this
->t('Byline (if available)'),
'class' => array(
RESPONSIVE_PRIORITY_MEDIUM,
),
),
);
$options = array();
// Fetch all emails.
$rows = $this
->getAllBlockedContents();
// Build the table.
foreach ($rows as $row) {
$options[$row->auid] = array(
'email' => array(
'data' => array(
'#markup' => Html::escape($row->email),
),
),
'ip' => array(
'data' => array(
'#markup' => $row->ipaddress,
),
),
'alias' => array(
'data' => array(
'#markup' => !empty($row->alias) ? Html::escape($row->alias) : $this
->t('- none -'),
),
),
);
}
$form['items'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#empty' => $this
->t('There is no unverified content.'),
);
$form['pager'] = array(
'#type' => 'pager',
);
return $form;
}