Commit d280ac53 authored by APolitsin's avatar APolitsin
Browse files

ok

parent 2dff109e
......@@ -43,14 +43,14 @@ class Settings extends ConfigFormBase {
'#title' => $this->t('General settings'),
'#open' => TRUE,
];
$form["general"]['indexation'] = array(
$form["general"]['no-index'] = array(
'#title' => $this->t('Индексация запрещена'),
'#description' => $this->t('Не забываем снимать при старте сайта!'),
'#type' => 'checkbox',
'#maxlength' => 20,
'#required' => FALSE,
'#size' => 15,
'#default_value' => $config->get('indexation'),
'#default_value' => $config->get('no-index'),
);
$form["general"]['fz152'] = array(
'#title' => $this->t('Галочка ФЗ-152'),
......@@ -91,7 +91,6 @@ class Settings extends ConfigFormBase {
'#type' => 'checkbox',
];
$form['menu'] = [
'#type' => 'details',
'#title' => $this->t('Menu helper'),
......@@ -125,7 +124,7 @@ class Settings extends ConfigFormBase {
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this->config('synhelper.settings');
$config
->set('indexation', $form_state->getValue('indexation'))
->set('no-index', $form_state->getValue('no-index'))
->set('fz152', $form_state->getValue('fz152'))
->set('ya-counter', $form_state->getValue('ya_counter'))
->set('ya-goals', $form_state->getValue('ya_goals'))
......
<?php
namespace Drupal\synhelper\Hook;
use Drupal\Core\Controller\ControllerBase;
/**
* AjaxContactForm.
*/
class FormNodePageFormAlter extends ControllerBase {
/**
* Hook.
*/
public static function hook(&$form, &$form_state, $form_id) {
// Создание страницы.
$form['menu']['#weight'] = -10;
$form['menu']['#group'] = FALSE;
$form['menu']['#open'] = FALSE;
$form['menu']['enabled']['#default_value'] = FALSE;
$form['menu']['link']['description']['#type'] = 'hidden';
$form['menu']['link']['weight']['#type'] = 'hidden';
$form['menu']['link']['menu_parent']['#prefix'] = '<div class="element-hidden">';
$form['menu']['link']['menu_parent']['#disabled'] = FALSE;
$form['menu']['link']['menu_parent']['#suffix'] = '</div>';
}
}
......@@ -16,7 +16,7 @@ class FormContactMessageFormAlter extends ControllerBase {
*/
public static function hook(&$form, &$form_state, $form_id) {
$config = \Drupal::config('synapse.settings');
$config = \Drupal::config('synhelper.settings');
$callback = 'Drupal\synhelper\Hook\FormContactMessageFormAlter::ajaxCallback';
// Debug contact form.
......@@ -62,7 +62,7 @@ class FormContactMessageFormAlter extends ControllerBase {
*/
public static function ajaxCallback($form, FormStateInterface &$form_state) {
$response = contact_ajax_contact_site_form_ajax_callback($form, $form_state);
$config = \Drupal::config('synapse.settings');
$config = \Drupal::config('synhelper.settings');
$counter = $config->get('ya-counter', FALSE);
$confGoals = $config->get('ya-goals');
$explodeGoals = explode("\n", $confGoals);
......
<?php
namespace Drupal\synhelper\Hook;
use Drupal\Core\Controller\ControllerBase;
/**
* PageAttachments.
*/
class PageAttachments extends ControllerBase {
/**
* Hook.
*/
public static function hook(array &$page) {
$config = \Drupal::config('synapse.settings');
if ($config->get('indexation')) {
$page['#attached']['html_head'][] = [
[
'#tag' => 'meta',
'#attributes' => [
'name' => 'robots',
'content' => 'none',
],
],
'indexation',
];
}
}
}
......@@ -3,6 +3,7 @@
namespace Drupal\synhelper\Hook;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Render\Markup;
/**
* PreprocessHtml.
......@@ -29,6 +30,24 @@ class PreprocessHtml extends ControllerBase {
];
$variables['page']['#attached']['html_head'][] = [$noindex, 'indexation'];
};
$config = \Drupal::config('synhelper.settings');
if ($config->get('no-index')) {
$variables['page']['#attached']['html_head'][] = [
[
'#tag' => 'meta',
'#attributes' => [
'name' => 'robots',
'content' => 'none',
],
],
'indexation',
];
if (substr($current_path, 0, 7) == '/admin/') {
$message = 'Внимание!! сайт не индексируется поисковиками.
Снимите галочку <a href="/admin/config/synapse/synhelper">индексация запрещена</a>!';
drupal_set_message(Markup::create($message), 'error');
}
}
}
}
......@@ -7,7 +7,6 @@
use Drupal\synhelper\Hook\ContactMessagePresave;
use Drupal\synhelper\Hook\PreprocessHtml;
use Drupal\synhelper\Hook\PageAttachments;
use Drupal\synhelper\Hook\FileValidate;
use Drupal\synhelper\Hook\FormAlter;
use Drupal\synhelper\Hook\FormContactMessageFormAlter;
......@@ -29,14 +28,6 @@ function synhelper_preprocess_html(&$variables) {
PreprocessHtml::hook($variables);
}
/**
* Implements hook_page_attachments().
*/
function synhelper_page_attachments(array &$page) {
// Add no-index meta-tag.
PageAttachments::hook($page);
}
/**
* Implements hook_file_validate().
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment