You are here

public function EditTexts::buildForm in TacJS 8.2

Same name and namespace in other branches
  1. 8.6 src/Form/Steps/EditTexts.php \Drupal\tacjs\Form\Steps\EditTexts::buildForm()
  2. 8.3 src/Form/Steps/EditTexts.php \Drupal\tacjs\Form\Steps\EditTexts::buildForm()
  3. 8.4 src/Form/Steps/EditTexts.php \Drupal\tacjs\Form\Steps\EditTexts::buildForm()
  4. 8.5 src/Form/Steps/EditTexts.php \Drupal\tacjs\Form\Steps\EditTexts::buildForm()

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

src/Form/Steps/EditTexts.php, line 26

Class

EditTexts
Class EditTexts.

Namespace

Drupal\tacjs\Form\Steps

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = \Drupal::getContainer()
    ->get('config.factory')
    ->getEditable('tacjs.settings');
  $texts = [
    [
      'id' => 'adblock',
      'msg' => 'Hello! This site is transparent and lets you chose the 3rd party services you want to allow.',
    ],
    [
      'id' => 'adblock_call',
      'msg' => 'Please disable your adblocker to start customizing.',
    ],
    [
      'id' => 'reload',
      'msg' => 'Refresh the page',
    ],
    [
      'id' => 'alertBigScroll',
      'msg' => 'By continuing to scroll,',
    ],
    [
      'id' => 'alertBigClick',
      'msg' => 'If you continue to browse this website,',
    ],
    [
      'id' => 'alertBig',
      'msg' => 'you are allowing all third-party services',
    ],
    [
      'id' => 'alertBigPrivacy',
      'msg' => 'This site uses cookies and gives you control over what you want to activate',
    ],
    [
      'id' => 'alertSmall',
      'msg' => 'Manage services',
    ],
    [
      'id' => 'personalize',
      'msg' => 'Personalize',
    ],
    [
      'id' => 'acceptAll',
      'msg' => 'OK, accept all',
    ],
    [
      'id' => 'close',
      'msg' => 'Close',
    ],
    [
      'id' => 'privacyUrl',
      'msg' => 'Privacy policy',
    ],
    [
      'id' => 'all',
      'msg' => 'Preference for all services',
    ],
    [
      'id' => 'info',
      'msg' => 'Protecting your privacy',
    ],
    [
      'id' => 'disclaimer',
      'msg' => 'By allowing these third party services, you accept their cookies and the use of tracking technologies necessary for their proper functioning.',
    ],
    [
      'id' => 'allow',
      'msg' => 'Allow',
    ],
    [
      'id' => 'deny',
      'msg' => 'Deny',
    ],
    [
      'id' => 'noCookie',
      'msg' => 'This service does not use cookie.',
    ],
    [
      'id' => 'useCookie',
      'msg' => 'This service can install',
    ],
    [
      'id' => 'useCookieCurrent',
      'msg' => 'This service has installed',
    ],
    [
      'id' => 'useNoCookie',
      'msg' => 'This service has not installed any cookie.',
    ],
    [
      'id' => 'more',
      'msg' => 'Read more',
    ],
    [
      'id' => 'source',
      'msg' => 'View the official website',
    ],
    [
      'id' => 'credit',
      'msg' => 'Cookies manager by tarteaucitron.js',
    ],
    [
      'id' => 'toggleInfoBox',
      'msg' => 'Show/hide informations about cookie storage',
    ],
    [
      'id' => 'title',
      'msg' => 'Cookies management panel',
    ],
    [
      'id' => 'cookieDetail',
      'msg' => 'Cookie detail for',
    ],
    [
      'id' => 'ourSite',
      'msg' => 'on our site',
    ],
    [
      'id' => 'newWindow',
      'msg' => '(new window)',
    ],
    [
      'id' => 'allowAll',
      'msg' => 'Allow all cookies',
    ],
    [
      'id' => 'denyAll',
      'msg' => 'Deny all cookies',
    ],
    [
      'id' => 'fallback',
      'msg' => 'is disabled.',
    ],
    [
      'id' => 'ads_title',
      'msg' => 'Advertising network',
    ],
    [
      'id' => 'ads_details',
      'msg' => 'Ad networks can generate revenue by selling advertising space on the site.',
    ],
    [
      'id' => 'analytic_title',
      'msg' => 'Audience measurement',
    ],
    [
      'id' => 'analytic_details',
      'msg' => 'The audience measurement services used to generate useful statistics attendance to improve the site.',
    ],
    [
      'id' => 'social_title',
      'msg' => 'Social networks',
    ],
    [
      'id' => 'social_details',
      'msg' => 'Social networks can improve the usability of the site and help to promote it via the shares.',
    ],
    [
      'id' => 'video_title',
      'msg' => 'Videos',
    ],
    [
      'id' => 'video_details',
      'msg' => 'Video sharing services help to add rich media on the site and increase its visibility.',
    ],
    [
      'id' => 'comment_title',
      'msg' => 'Comments',
    ],
    [
      'id' => 'comment_details',
      'msg' => 'Comments managers facilitate the filing of comments and fight against spam.',
    ],
    [
      'id' => 'support_title',
      'msg' => 'Support',
    ],
    [
      'id' => 'support_details',
      'msg' => 'Support services allow you to get in touch with the site team and help to improve it.',
    ],
    [
      'id' => 'api_title',
      'msg' => 'APIs',
    ],
    [
      'id' => 'api_details',
      'msg' => 'APIs are used to load scripts, geolocation, search engines, translations, ...',
    ],
    [
      'id' => 'other_title',
      'msg' => 'Other',
    ],
    [
      'id' => 'other_details',
      'msg' => 'Services to display web content.',
    ],
  ];
  $form['texts'] = [
    '#prefix' => '<p>' . t('Enter the text that will be presented to your website users. The same text is used in both the cookie declaration and the consent dialog.') . '<br />' . t('Translate the text on the <a href=":translate">User interface translation</a> page.', [
      ':translate' => Url::fromRoute('locale.translate_page')
        ->toString(),
    ]) . '</p>',
    '#type' => 'table',
    '#header' => [
      'original' => $this
        ->t('Original'),
      'destination' => $this
        ->t('Destination'),
    ],
    '#rows' => [],
  ];
  for ($i = 0; $i < count($texts); $i++) {
    $form['texts'][$i] = [
      'original' => [
        '#type' => 'inline_template',
        '#template' => '<strong>{{ msg }}</strong>',
        '#context' => [
          'msg' => $texts[$i]['msg'],
        ],
      ],
      'destination' => [
        '#type' => 'textarea',
        '#title' => t('Destination'),
        '#title_display' => 'invisible',
        '#default_value' => $config
          ->get('texts.' . $texts[$i]['id']),
      ],
    ];
  }
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => t('Save'),
  ];
  return $form;
}