Skip to content

Instantly share code, notes, and snippets.

@andronex
Last active July 27, 2023 11:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save andronex/786f846700a69bc175e7b6e35f17be39 to your computer and use it in GitHub Desktop.
Save andronex/786f846700a69bc175e7b6e35f17be39 to your computer and use it in GitHub Desktop.
Региональные поддомены для MODX Revolution с перебросом ресурсов через контексты и изменением нужных полей ресурса для SEO.
<?php
/*
*плагин для переключения контекстов
*/
// Работаем только на фронте
if ($modx->event->name != 'OnHandleRequest' || $modx->context->key == 'mgr') {return;}
// Определяем запрашиваемый хост
$host = $_SERVER['HTTP_HOST'];
// Выбираем контекст с настройкой base_url
$q = $modx->newQuery('modContextSetting', array('key' => 'http_host', 'value' => $host));
$q->select('context_key');
$tstart = microtime(true);
if ($q->prepare() && $q->stmt->execute()) {
// Учитываем наш запрос в БД
$modx->queryTime += microtime(true) - $tstart;
$modx->executedQueries++;
// Получаем ключ контекста
if ($context = $q->stmt->fetch(PDO::FETCH_COLUMN)) {
// Web инициализируется в index.php - на него переключаться не нужно
if ($context != 'web') {
$modx->switchContext($context);
}
}
else{
//если контекст не найден, но запрошен всё-таки поддомен
if(substr_count($modx->getOption('http_host'), '.') > 1){
$host = explode('.', $modx->getOption('http_host'));
//если это www поддомен, то пропускаем и отдаём на рендеринг или на обработку другим плагинам
//иначе выводим ошибку, поскольку нет такого контекста и нет, соответственно, такого поддомена
if(count($host) == 3 && $host[0] == 'www'){return;}
$modx->sendError('unavailable');
}
}
}
<?php
/*
*Плагин для отображения страниц на поддоменах из основного контекста web.
*/
if($modx->context->key == 'mgr' || $modx->context->key == 'web') {return;}
if ($modx->event->name == 'OnPageNotFound') {
$alias = $modx->context->getOption('request_param_alias', 'q');
if (!isset($_REQUEST[$alias])) {return;}
$request = $_REQUEST[$alias];
$tmp = explode('/', $request); // получаем ссылку
$tmp = str_replace('.html','',(!end($tmp)) ? $tmp[count($tmp)-2] : end($tmp));
$res = '';
if(!$document = $modx->findResource($request, 'web')){
if(!$document = $modx->findResource(str_replace('/','',$tmp), 'web')){
if($res = $modx->getObject('modResource', array('alias' => $tmp, 'context_key' => 'web', 'published' => 1, 'deleted' => 0))){
$document = $res->id;
}
}
}
if($document){
//$modx->sendForward($document);
$modx->resource = ($res) ? $res : $modx->getObject('modResource', array('id' => $document, 'published' => 1, 'deleted' => 0));
//чтобы феном распарсивал обращение к TV полям ресурса
if($tvs = $modx->resource->getTemplateVars()){
foreach($tvs as $t_v){
$modx->resource->set($t_v->name, $t_v->value);
//$modx->log(1, print_r($t_v->toArray(), true));
}
}
$_REQUEST['id'] = $document;
unset($_REQUEST['q']);
//получение MIGX поля изменений для данного контекста
$tvr = $modx->getObject('modTemplateVarResource', array(
'tmplvarid' => 11,//ID TV поля MIGX таблицы с изменёнными данными для страницы на поддомене
'contentid' => $document
));
if ($tvr) {
$json = $tvr->get('value');
if(is_array(json_decode($json, true))){
$array = json_decode($json, true);
foreach($array as $v){
if($v['context'] == $modx->context->key){
//если страница снята с публикации для текущего контекста, то выводим ошибку
if(!$v['published']) {
$modx->sendErrorPage();
exit;
}
}
}
}
}
//рендеринг страницы
$modx->handleRequest();
//$modx->request->prepareResponse();
exit();
}
}
<?php
/*
* Модернизированный вариант плагина для отображения страниц на поддоменах из основного контекста web.
* Выставление нужных плейсхолдеров на всех страницах (обычно контакты: адреса, телефоны, e-mail - которые заполняются отдельными TV, а не настройками контекстов)
* Сокрытие ненужных TV у ресурсов в контекстах, отличных от web
* Выставление плейсхолдера context_key для всех страниц сайта
* Копирование заполенных seoKeywords при копировании ресурса с установленным пакетом seoPro
*/
$modx->toPlaceholder('context_key', $modx->context->key);
if($modx->event->name == 'OnResourceDuplicate'){
$modx->addPackage('Evacuators', $modx->getOption('core_path') . 'components/seopro/model/', $modx->getOption('table_prefix'));
$newResource = $modx->getOption('newResource', $scriptProperties, null, true);
$oldResource = $modx->getOption('oldResource', $scriptProperties, null, true);
$class = 'seoKeywords';
$q = $modx->newQuery($class);
$q->where(array('resource' => $oldResource->get('id')));
foreach ($modx->getIterator($class, $q) as $keywords) {
$o = $modx->newObject($class);
$o->fromArray($keywords->toArray(), '');
$o->set('resource', $newResource->get('id'));
$o->save();
}
}
if($modx->event->name == 'OnLoadWebDocument'){
$keys = ['seo-title',
'address',
'phone1',
'phone2',
'email',
'contacts_img'];
$id_contacts = 52;
$id_tv = 25;
if($res = $modx->getObject('modResource', $id_contacts)){
//получение MIGX поля изменений для данного контекста
$tvr = $modx->getObject('modTemplateVarResource', array(
'tmplvarid' => $id_tv,
'contentid' => $id_contacts
));
foreach($keys as $key){
if($key == 'seo-title'){
$ress = $res;
$res = $modx->resource;
}
else{
$res = ($ress)?:$res;
}
$is_true = false;
if ($tvr) {
$json = $tvr->get('value');
if(is_array(json_decode($json, true))){
$array = json_decode($json, true);
foreach($array as $v){
if($v['context'] == $modx->context->key){
if($v[ $key ]) {
$modx->toPlaceholder($key, $v[ $key ]);
$is_true = true;
}
}
}
}
}
if(($out = $res->getTVValue($key)) && !$is_true){
$modx->toPlaceholder($key, $out);
$is_true = true;
}
if(($out = $modx->getPlaceholder($key)) && !$is_true){
$modx->toPlaceholder($key, $out);
$is_true = true;
}
}
}
}
if ($modx->event->name == 'OnDocFormPrerender'){
$script = 'var ctx = MODx.ctx;
if(ctx != \'web\'){
var tv = Ext.get(\'tv12-tr\');
tv.hide();
var tab = tv.parent();
tab.remove();
tv = Ext.get(\'tv16-tr\');
tv.hide();
tab = tv.parent();
tab.remove();
tv = Ext.get(\'tv18-tr\');
tv.hide();
tab = tv.parent();
tab.remove();
tv = Ext.get(\'tv15-tr\');
tv.hide();
tab = tv.parent();
tab.remove();
tv = Ext.get(\'tv17-tr\');
tv.hide();
tab = tv.parent();
tab.remove();
tv = Ext.get(\'tv25-tr\');
tv.hide();
tab = tv.parent();
tab.remove();
};';
$modx->controller->addHtml('<script type="text/javascript">
Ext.onReady(function() {
' . $script . ';
});
</script>');
}
if ($modx->event->name == 'OnManagerPageInit'){
$modx->regClientStartupHTMLBlock("<script>
console.log('%c Context Switch Author: i.modx@ya.ru', 'background: #222; color: #bada55; font-size:200%');
</script>
<script src=\"//code.jquery.com/jquery-2.2.4.min.js\" integrity=\"sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=\" crossorigin=\"anonymous\"></script>
<link rel=\"stylesheet\" href=\"//cdn.rawgit.com/needim/noty/77268c46/lib/noty.css\">
<link rel=\"stylesheet\" href=\"//cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css\">
<script src=\"//cdn.rawgit.com/needim/noty/77268c46/lib/noty.min.js\"></script>");
}
if ($modx->event->name == 'OnWebPagePrerender') {
$words = array("Москве", "москва");
$words_new = array($modx->getOption('subdomain_regione'), $modx->getOption('subdomain_region'));
$output = &$modx->resource->_output;
$output = str_replace($words,$words_new,$output);
}
if($modx->context->key == 'mgr' || $modx->context->key == 'web') {return;}
if ($modx->event->name == 'OnPageNotFound') {
$alias = $modx->context->getOption('request_param_alias', 'q');
if (!isset($_REQUEST[$alias])) {return;}
$request = $_REQUEST[$alias];
$tmp = explode('/', $request); // получаем ссылку
$tmp = str_replace('.html','',(!end($tmp)) ? $tmp[count($tmp)-2] : end($tmp));
//print_r($tmp);exit;
$res = '';
if(!$document = $modx->findResource($tmp, 'web')){
if(!$document = $modx->findResource(str_replace('/','',$tmp), 'web')){
if($res = $modx->getObject('modResource', array('alias' => $tmp))){
$document = $res->id;
}
}
}
if($document){
//$modx->sendForward($document);
$modx->resource = ($res) ? $res : $modx->getObject('modResource', $document);
//$modx->resource->setTVValue('seo-title', 'ТЕСТ');
//чтобы феном распарсивал обращение к TV полям ресурса
if($tvs = $modx->resource->getTemplateVars()){
foreach($tvs as $t_v){
$modx->resource->set($t_v->name, $t_v->value);
//$modx->log(1, print_r($t_v->toArray(), true));
}
}
$_REQUEST['id'] = $id;
unset($_REQUEST['q']);
//получение MIGX поля изменений для данного контекста
$tvr = $modx->getObject('modTemplateVarResource', array(
'tmplvarid' => 25,
'contentid' => $document
));
if ($tvr) {
$json = $tvr->get('value');
if(is_array(json_decode($json, true))){
$array = json_decode($json, true);
foreach($array as $v){
if($v['context'] == $modx->context->key){
//если страница снята с публикации для текущего контекста, то выводим ошибку
if(!$v['published']) {
$modx->sendErrorPage();
exit;
}
}
}
}
}
//рендеринг страницы
$modx->handleRequest();
//$modx->request->prepareResponse();
exit();
}
}
<?php
//функ-ия коннекта к Я.Вебмастеру
function httpRequestYa($url, $data = [], $method = 'GET'){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json', 'Authorization: OAuth y0_AgAAAABpUvNMAAlNtAAAAADe8**************'));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$returned = curl_exec($ch);
curl_close ($ch);
return $returned;
}
$q = $modx->newQuery('modContext');
$q->where(['key:NOT IN' => ['moscow', 'mgr', 'orel', 'abakan']]); //условия по потребности
$q->sortby('name','ASC');
$ctxs = $modx->getIterator('modContext', $q);
foreach($ctxs as $ctx){
$settings = $ctx->getMany('ContextSettings');
foreach($settings as $set){
switch($set->key){
case 'site_url':
$url = rtrim($set->value, '/');
break;
}
}
$response = httpRequestYa('https://api.webmaster.yandex.net/v4/user/176**/hosts',
array('host_url' => $url),
'POST'
);
if($response){
$response = json_decode($response, true);
print_r($response);
if($response['host_id']){
$host_id = $response['host_id'];
$response = httpRequestYa('https://api.webmaster.yandex.net/v4/user/176**/hosts/'.$host_id.'/verification');
if($response){
$response = json_decode($response, true);
print_r($response);
if($response['verification_uin']){
$verification_uin = $response['verification_uin'];
$settings = $ctx->getMany('ContextSettings');
$newSetting = $modx->newObject('modContextSetting');
$newSetting->fromArray(array('context_key' => $ctx->get('key'), 'value' => $verification_uin));
$newSetting->set('key', 'yandex_verification');
if($newSetting){
$settings[] = $newSetting;
$ctx->addMany($settings);
$ctx->save();
$modx->cacheManager->deleteTree(MODX_CORE_PATH.'cache/context_settings/'.$ctx->get('key').'/',array(
'skipDirs' => true,
'deleteTop' => false,
'extensions' => array('.cache.php')
));
$modx->cacheManager->deleteTree(MODX_CORE_PATH.'cache/resource/'.$ctx->get('key').'/',array(
'skipDirs' => true,
'deleteTop' => false,
'extensions' => array('.cache.php')
));
httpRequestYa('https://api.webmaster.yandex.net/v4/user/176**/hosts/'.$host_id.'/verification?verification_type=META_TAG',
[],
'POST'
);
}
}
}
}
}
break; //убрать, если тест на одном поддомене успешный
}
<?php
/*
*Плагин регистрации jQuery и скрипта Noty в админке для вывода быстрых сообщений
*/
switch ($modx->event->name) {
case 'OnManagerPageInit':
$modx->regClientStartupHTMLBlock("<script>console.log('%c Context Switch Author: i.modx@ya.ru', 'background: #222; color: #bada55; font-size:200%');</script>
<script src=\"//code.jquery.com/jquery-2.2.4.min.js\" integrity=\"sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=\" crossorigin=\"anonymous\"></script>
<link rel=\"stylesheet\" href=\"//cdn.rawgit.com/needim/noty/77268c46/lib/noty.css\">
<link rel=\"stylesheet\" href=\"//cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css\">
<script src=\"//cdn.rawgit.com/needim/noty/77268c46/lib/noty.min.js\"></script>");
break;
}
<?php
/*
* программное копирование контекстов для минимизации ручной работы
* запускать в Console
*/
$new_contexts = ['Вологда', 'Череповец'];
//подключаем транслитерацию, нужен пакет yTranslit
$Transliterate = $modx->getService('transliterate', 'modTransliterate', MODX_CORE_PATH.'components/ytranslit/model/modx/ytranslit/');
//какие настройки нужно менять на новом контексте
$settings = ['http_host', 'site_start', 'site_url', 'subdomain_region', 'subdomain_regione'];
foreach($new_contexts as $new_context){
$new_context_key = str_replace(' ','-',mb_strtolower($Transliterate->translate($new_context)));
$response = $modx->runProcessor('context/duplicate',array(
'action' => 'duplicate',
'key' => 'vidnoe',//заменить на уже созданный контекст с одним ресурсом (Главная)
'newkey' => $new_context_key,
'preserve_resources' => 'on'//копируем содержащиеся ресурсы (Главная или Главная и Контакты)
));
if ($response->isError()) {
echo $response->getMessage();
}
$chunkArray = $response->getObject();
$context = $modx->getObject('modContext', array('key' => $chunkArray['key']));
$context->set('name', $new_context);
$context->save();
if($res = $modx->getObject('modResource', array('context_key' => $new_context_key))){
$res->set('pagetitle', 'Главная ' . $new_context);
$res->save();
}
foreach($settings as $setting){
if($set = $modx->getObject('modContextSetting', array('context_key' => $new_context_key, 'key' => $setting))){
switch($setting){
case 'subdomain_region':
case 'subdomain_regione':
$set->set('value', $new_context);
break;
case 'http_host':
$set->set('value', $new_context_key.'.'.MODX_HTTP_HOST);
break;
case 'site_start':
if($res->id){
$set->set('value', $res->id);
}
break;
case 'site_url':
$set->set('value', "https://{$new_context_key}.{MODX_HTTP_HOST}/");
break;
}
$set->save();
}
}
$modx->log(modX::LOG_LEVEL_ERROR, print_r($chunkArray, true));
}
<?php
/*
* программное копирование контекстов для минимизации ручной работы
* запускать в Console
*/
$new_contexts = ['himki' => ['subdomain_region' => 'Химки', 'subdomain_regione' => 'Химках', 'name' => 'Химки (himki)'],'podolsk' => ['subdomain_region' => 'Подольск', 'subdomain_regione' => 'Подольске', 'name' => 'Подольск (podolsk)'],'aprelevka' => ['subdomain_region' => 'Апрелевка', 'subdomain_regione' => 'Апрелевке', 'name' => 'Апрелевка (aprelevka)'],'balashiha' => ['subdomain_region' => 'Балашиха', 'subdomain_regione' => 'Балашихе', 'name' => 'Балашиха (balashiha)'],'bronnitsy' => ['subdomain_region' => 'Бронницы', 'subdomain_regione' => 'Бронницах', 'name' => 'Бронницы (bronnitsy)'],'vidnoe' => ['subdomain_region' => 'Видное', 'subdomain_regione' => 'Видном', 'name' => 'Видное (vidnoe)'],'volokolamsk' => ['subdomain_region' => 'Волоколамск', 'subdomain_regione' => 'Волоколамске', 'name' => 'Волоколамск (volokolamsk)'],'golitsyno' => ['subdomain_region' => 'Голицыно', 'subdomain_regione' => 'Голицыно', 'name' => 'Голицыно (golitsyno)'],'dedovsk' => ['subdomain_region' => 'Дедовск', 'subdomain_regione' => 'Дедовске', 'name' => 'Дедовск (dedovsk)'],'dzerzhinskiy' => ['subdomain_region' => 'Дзержинский', 'subdomain_regione' => 'Дзержинском', 'name' => 'Джержинский (dzerzhinskiy)'],'dmitrov' => ['subdomain_region' => 'Дмитров', 'subdomain_regione' => 'Дмитрове', 'name' => 'Дмитров (dmitrov)'],'dolgoprudnyy' => ['subdomain_region' => 'Долгопрудный', 'subdomain_regione' => 'Долгопрудном', 'name' => 'Долгопрудный (dolgoprudnyy)'],'domodedovo' => ['subdomain_region' => 'Домодедово', 'subdomain_regione' => 'Домодедово', 'name' => 'Домодедово (domodedovo)'],'dubna' => ['subdomain_region' => 'Дубна', 'subdomain_regione' => 'Дубне', 'name' => 'Дубна (dubna)'],'egorevsk' => ['subdomain_region' => 'Егорьевск', 'subdomain_regione' => 'Егорьевске', 'name' => 'Егорьевск (egorevsk)'],'zhukovskiy' => ['subdomain_region' => 'Жуковский', 'subdomain_regione' => 'Жуковском', 'name' => 'Жуковский (zhukovskiy)'],'zarajsk' => ['subdomain_region' => 'Зарайск', 'subdomain_regione' => 'Зарайске', 'name' => 'Зарайск (zarajsk)'],'zvenigorod' => ['subdomain_region' => 'Звенигород', 'subdomain_regione' => 'Звенигороде', 'name' => 'Звенигород (zvenigorod)'],'ivanteevka' => ['subdomain_region' => 'Ивантеевка', 'subdomain_regione' => 'Ивантеевке', 'name' => 'Ивантеевка (ivanteevka)'],'kashira' => ['subdomain_region' => 'Кашира', 'subdomain_regione' => 'Кашире', 'name' => 'Кашира (kashira)'],'klin' => ['subdomain_region' => 'Клин', 'subdomain_regione' => 'Клину', 'name' => 'Клин (klin)'],'kolomna' => ['subdomain_region' => 'Коломна', 'subdomain_regione' => 'Коломне', 'name' => 'Коломна (kolomna)'],'korolev' => ['subdomain_region' => 'Королев', 'subdomain_regione' => 'Королеве', 'name' => 'Королев (korolev)'],'krasnoarmeysk' => ['subdomain_region' => 'Красноармейск', 'subdomain_regione' => 'Красноармейске', 'name' => 'Красноармейск (krasnoarmeysk)'],'krasnogorsk' => ['subdomain_region' => 'Красногорск', 'subdomain_regione' => 'Красногорске', 'name' => 'Красногорск (krasnogorsk)'],'kubinka' => ['subdomain_region' => 'Кубинка', 'subdomain_regione' => 'Кубинке', 'name' => 'Кубинка (kubinka)'],'lukhovitsy' => ['subdomain_region' => 'Луховицы', 'subdomain_regione' => 'Луховицах', 'name' => 'Луховицы (lukhovitsy)'],'lytkarino' => ['subdomain_region' => 'Лыткарино', 'subdomain_regione' => 'Лыткарино', 'name' => 'Лыткарино (lytkarino)'],'lyubertsy' => ['subdomain_region' => 'Люберцы', 'subdomain_regione' => 'Люберцах', 'name' => 'Люберцы (lyubertsy)'],'mozhaysk' => ['subdomain_region' => 'Можайск', 'subdomain_regione' => 'Можайске', 'name' => 'Можайск (mozhaysk)'],'mytischi' => ['subdomain_region' => 'Мытищи', 'subdomain_regione' => 'Мытищах', 'name' => 'Мытищи (mytischi)'],'naro-fominsk' => ['subdomain_region' => 'Наро-Фоминск', 'subdomain_regione' => 'Наро-Фоминске', 'name' => 'Наро-Фоминск (naro-fominsk)'],'nahabino' => ['subdomain_region' => 'Нахабино', 'subdomain_regione' => 'Нахабино', 'name' => 'Нахабино (nahabino)'],'novaya-kupavna' => ['subdomain_region' => 'Новая Купавна', 'subdomain_regione' => 'Новой Купавне', 'name' => 'Новая Купавна (novaya-kupavna)'],'noginsk' => ['subdomain_region' => 'Ногинск', 'subdomain_regione' => 'Ногинск', 'name' => 'Ногинск (noginsk)'],'obuhovo' => ['subdomain_region' => 'Обухово', 'subdomain_regione' => 'Обухово', 'name' => 'Обухово (obuhovo)'],'odintsovo' => ['subdomain_region' => 'Одинцово', 'subdomain_regione' => 'Одинцово', 'name' => 'Одинцово (odintsovo)'],'orehovo-zuevo' => ['subdomain_region' => 'Орехово-Зуево', 'subdomain_regione' => 'Орехово-Зуево', 'name' => 'Орехово-Зуево (orehovo-zuevo)'],'pavlovskij-posad' => ['subdomain_region' => 'Павловский Посад', 'subdomain_regione' => 'Павловском Посаде', 'name' => 'Павловский Посад (pavlovskij-posad)'],'protvino' => ['subdomain_region' => 'Протвино', 'subdomain_regione' => 'Протвино', 'name' => 'Протвино (protvino)'],'pushkino' => ['subdomain_region' => 'Пушкино', 'subdomain_regione' => 'Пушкино', 'name' => 'Пушкино (pushkino)'],'ramenskoe' => ['subdomain_region' => 'Раменское', 'subdomain_regione' => 'Раменском', 'name' => 'Раменское (ramenskoe)'],'reutov' => ['subdomain_region' => 'Реутов', 'subdomain_regione' => 'Реутове', 'name' => 'Реутов (reutov)'],'sergiev-posad' => ['subdomain_region' => 'Сергиев Посад', 'subdomain_regione' => 'Сергиев Посаде', 'name' => 'Сергиев Посад (sergiev-posad)'],'serpuhov' => ['subdomain_region' => 'Серпухов', 'subdomain_regione' => 'Серпухове', 'name' => 'Серпухов (serpuhov)'],'solnechnogorsk' => ['subdomain_region' => 'Солнечногорск', 'subdomain_regione' => 'Солнечногорске', 'name' => 'Солнечногорск (solnechnogorsk)'],'staraya-kupavna' => ['subdomain_region' => 'Старая Купавна', 'subdomain_regione' => 'Старой Купавне', 'name' => 'Старая Купавна (staraya-kupavna)'],'stupino' => ['subdomain_region' => 'Ступино', 'subdomain_regione' => 'Ступино', 'name' => 'Ступино (stupino)'],'fryazino' => ['subdomain_region' => 'Фрязино', 'subdomain_regione' => 'Фрязино', 'name' => 'Фрязино (fryazino)'],'hotkovo' => ['subdomain_region' => 'Хотьково', 'subdomain_regione' => 'Хотьково', 'name' => 'Хотьково (hotkovo)'],'chernogolovka' => ['subdomain_region' => 'Черноголовка', 'subdomain_regione' => 'Черноголовке', 'name' => 'Черноголовка (chernogolovka)'],'shatura' => ['subdomain_region' => 'Шатура', 'subdomain_regione' => 'Шатуре', 'name' => 'Шатура (shatura)'],'schelkovo' => ['subdomain_region' => 'Щелково', 'subdomain_regione' => 'Щелково', 'name' => 'Щелково (schelkovo)'],'elektrostal' => ['subdomain_region' => 'Электросталь', 'subdomain_regione' => 'Электростали', 'name' => 'Электросталь (elektrostal)'],'electrougli' => ['subdomain_region' => 'Электроугли', 'subdomain_regione' => 'Электроуглях', 'name' => 'Электроугли (electrougli)'],'sankt-peterburg' => ['subdomain_region' => 'Санкт-Петербург', 'subdomain_regione' => 'Санкт-Петербурге', 'name' => 'Санкт-Петербург (sankt-peterburg)'],'novosibirsk' => ['subdomain_region' => 'Новосибирск', 'subdomain_regione' => 'Новосибирске', 'name' => 'Новосибирск (novosibirsk)'],'ekaterinburg' => ['subdomain_region' => 'Екатеринбург', 'subdomain_regione' => 'Екатеринбурге', 'name' => 'Екатеринбург (ekaterinburg)'],'nizhniy-novgorod' => ['subdomain_region' => 'Нижний Новгород', 'subdomain_regione' => 'Нижнем Новгороде', 'name' => 'Нижний Новгород (nizhniy-novgorod)'],'kazan' => ['subdomain_region' => 'Казань', 'subdomain_regione' => 'Казани', 'name' => 'Казань (kazan)'],'chelyabinsk' => ['subdomain_region' => 'Челябинск', 'subdomain_regione' => 'Челябинске', 'name' => 'Челябинск (chelyabinsk)'],'omsk' => ['subdomain_region' => 'Омск', 'subdomain_regione' => 'Омске', 'name' => 'Омск (omsk)'],'samara' => ['subdomain_region' => 'Самара', 'subdomain_regione' => 'Самаре', 'name' => 'Самара (samara)'],'rostov' => ['subdomain_region' => 'Ростов-на-Дону', 'subdomain_regione' => 'Ростове-на-Дону', 'name' => 'Ростов-на-Дону (rostov)'],'ufa' => ['subdomain_region' => 'Уфа', 'subdomain_regione' => 'Уфе', 'name' => 'Уфа (ufa)'],'krasnoyarsk' => ['subdomain_region' => 'Красноярск', 'subdomain_regione' => 'Красноярске', 'name' => 'Красноярск (krasnoyarsk)'],'perm' => ['subdomain_region' => 'Пермь', 'subdomain_regione' => 'Перми', 'name' => 'Пермь (perm)'],'voronezh' => ['subdomain_region' => 'Воронеж', 'subdomain_regione' => 'Воронеже', 'name' => 'Воронеж (voronezh)'],'volgograd' => ['subdomain_region' => 'Волгоград', 'subdomain_regione' => 'Волгограде', 'name' => 'Волгоград (volgograd)'],'krasnodar' => ['subdomain_region' => 'Краснодар', 'subdomain_regione' => 'Краснодаре', 'name' => 'Краснодар (krasnodar)'],'saratov' => ['subdomain_region' => 'Саратов', 'subdomain_regione' => 'Саратове', 'name' => 'Саратов (saratov)'],'tyumen' => ['subdomain_region' => 'Тюмень', 'subdomain_regione' => 'Тюмени', 'name' => 'Тюмень (tyumen)'],'tolyatti' => ['subdomain_region' => 'Тольятти', 'subdomain_regione' => 'Тольятти', 'name' => 'Тольятти (tolyatti)'],'izhevsk' => ['subdomain_region' => 'Ижевск', 'subdomain_regione' => 'Ижевске', 'name' => 'Ижевск (izhevsk)'],'barnaul' => ['subdomain_region' => 'Барнаул', 'subdomain_regione' => 'Барнауле', 'name' => 'Барнаул (barnaul)'],'irkutsk' => ['subdomain_region' => 'Иркутск', 'subdomain_regione' => 'Иркутске', 'name' => 'Иркутск (irkutsk)'],'ulyanovsk' => ['subdomain_region' => 'Ульяновск', 'subdomain_regione' => 'Ульяновске', 'name' => 'Ульяновск (ulyanovsk)'],'habarovsk' => ['subdomain_region' => 'Хабаровск', 'subdomain_regione' => 'Хабаровске', 'name' => 'Хабаровск (habarovsk)'],'yaroslavl' => ['subdomain_region' => 'Ярославль', 'subdomain_regione' => 'Ярославле', 'name' => 'Ярославль (yaroslavl)'],'vladivostok' => ['subdomain_region' => 'Владивосток', 'subdomain_regione' => 'Владивостоке', 'name' => 'Владивосток (vladivostok)'],'makhachkala' => ['subdomain_region' => 'Махачкала', 'subdomain_regione' => 'Махачкале', 'name' => 'Махачкала (makhachkala)'],'tomsk' => ['subdomain_region' => 'Томск', 'subdomain_regione' => 'Томске', 'name' => 'Томск (tomsk)'],'orenburg' => ['subdomain_region' => 'Оренбург', 'subdomain_regione' => 'Оренбурге', 'name' => 'Оренбург (orenburg)'],'kemerovo' => ['subdomain_region' => 'Кемерово', 'subdomain_regione' => 'Кемерово', 'name' => 'Кемерово (kemerovo)'],'novokuznetsk' => ['subdomain_region' => 'Новокузнецк', 'subdomain_regione' => 'Новокузнецке', 'name' => 'Новокузнецк (novokuznetsk)'],'ryazan' => ['subdomain_region' => 'Рязань', 'subdomain_regione' => 'Рязани', 'name' => 'Рязань (ryazan)'],'astrahan' => ['subdomain_region' => 'Астрахань', 'subdomain_regione' => 'Астрахани', 'name' => 'Астрахань (astrahan)'],'naberezhnye-chelny' => ['subdomain_region' => 'Набережные Челны', 'subdomain_regione' => 'Набережных Челнах', 'name' => 'Набережные Челны (naberezhnye-chelny)'],'penza' => ['subdomain_region' => 'Пенза', 'subdomain_regione' => 'Пензе', 'name' => 'Пенза (penza)'],'lipetsk' => ['subdomain_region' => 'Липецк', 'subdomain_regione' => 'Липецке', 'name' => 'Липецк (lipetsk)'],'kirov' => ['subdomain_region' => 'Киров', 'subdomain_regione' => 'Кирове', 'name' => 'Киров (kirov)'],'cheboksary' => ['subdomain_region' => 'Чебоксары', 'subdomain_regione' => 'Чебоксарах', 'name' => 'Чебоксары (cheboksary)'],'tula' => ['subdomain_region' => 'Тула', 'subdomain_regione' => 'Туле', 'name' => 'Тула (tula)'],'kaliningrad' => ['subdomain_region' => 'Калининград', 'subdomain_regione' => 'Калининграде', 'name' => 'Калининград (kaliningrad)'],'kursk' => ['subdomain_region' => 'Курск', 'subdomain_regione' => 'Курске', 'name' => 'Курск (kursk)'],'ulan-ude' => ['subdomain_region' => 'Улан-Удэ', 'subdomain_regione' => 'Улан-Удэ', 'name' => 'Улан-Удэ (ulan-ude)'],'stavropol' => ['subdomain_region' => 'Ставрополь', 'subdomain_regione' => 'Ставрополе', 'name' => 'Ставрополь (stavropol)'],'sevastopol' => ['subdomain_region' => 'Севастополь', 'subdomain_regione' => 'Севастополе', 'name' => 'Севастополь (sevastopol)'],'tver' => ['subdomain_region' => 'Тверь', 'subdomain_regione' => 'Твери', 'name' => 'Тверь (tver)'],'magnitogorsk' => ['subdomain_region' => 'Магнитогорск', 'subdomain_regione' => 'Магнитогорске', 'name' => 'Магнитогорск (magnitogorsk)'],'ivanovo' => ['subdomain_region' => 'Иваново', 'subdomain_regione' => 'Иваново', 'name' => 'Иваново (ivanovo)'],'bryansk' => ['subdomain_region' => 'Брянск', 'subdomain_regione' => 'Брянске', 'name' => 'Брянск (bryansk)'],'sochi' => ['subdomain_region' => 'Сочи', 'subdomain_regione' => 'Сочи', 'name' => 'Сочи (sochi)'],'belgorod' => ['subdomain_region' => 'Белгород', 'subdomain_regione' => 'Белгороде', 'name' => 'Белгород (belgorod)'],'nizhnii-tagil' => ['subdomain_region' => 'Нижний Тагил', 'subdomain_regione' => 'Нижнем Тагиле', 'name' => 'Нижний Тагил (nizhnii-tagil)'],'vladimir' => ['subdomain_region' => 'Владимир', 'subdomain_regione' => 'Владимире', 'name' => 'Владимир (vladimir)'],'arhangelsk' => ['subdomain_region' => 'Архангельск', 'subdomain_regione' => 'Архангельске', 'name' => 'Архангельск (arhangelsk)'],'surgut' => ['subdomain_region' => 'Сургут', 'subdomain_regione' => 'Сургуте', 'name' => 'Сургут (surgut)'],'chita' => ['subdomain_region' => 'Чита', 'subdomain_regione' => 'Чите', 'name' => 'Чита (chita)'],'kaluga' => ['subdomain_region' => 'Калуга', 'subdomain_regione' => 'Калуге', 'name' => 'Калуга (kaluga)'],'simferopol' => ['subdomain_region' => 'Симферополь', 'subdomain_regione' => 'Симферополе', 'name' => 'Симферополь (simferopol)'],'smolensk' => ['subdomain_region' => 'Смоленск', 'subdomain_regione' => 'Смоленске', 'name' => 'Смоленск (smolensk)'],'volzhskii' => ['subdomain_region' => 'Волжский', 'subdomain_regione' => 'Волжском', 'name' => 'Волжский (volzhskii)'],'kurgan' => ['subdomain_region' => 'Курган', 'subdomain_regione' => 'Кургане', 'name' => 'Курган (kurgan)'],'orel' => ['subdomain_region' => 'Орел', 'subdomain_regione' => 'Орле', 'name' => 'Орел (orel)'],'cherepovets' => ['subdomain_region' => 'Череповец', 'subdomain_regione' => 'Череповце', 'name' => 'Череповец (cherepovets)'],'vologda' => ['subdomain_region' => 'Вологда', 'subdomain_regione' => 'Вологде', 'name' => 'Вологда (vologda)'],'saransk' => ['subdomain_region' => 'Саранск', 'subdomain_regione' => 'Саранске', 'name' => 'Саранск (saransk)'],'vladikavkaz' => ['subdomain_region' => 'Владикавказ', 'subdomain_regione' => 'Владикавказе', 'name' => 'Владикавказ (vladikavkaz)'],'yakutsk' => ['subdomain_region' => 'Якутск', 'subdomain_regione' => 'Якутске', 'name' => 'Якутск (yakutsk)'],'murmansk' => ['subdomain_region' => 'Мурманск', 'subdomain_regione' => 'Мурманске', 'name' => 'Мурманск (murmansk)'],'tambov' => ['subdomain_region' => 'Тамбов', 'subdomain_regione' => 'Тамбове', 'name' => 'Тамбов (tambov)'],'groznyi' => ['subdomain_region' => 'Грозный', 'subdomain_regione' => 'Грозном', 'name' => 'Грозный (groznyi)'],'sterlitamak' => ['subdomain_region' => 'Стерлитамак', 'subdomain_regione' => 'Стерлитамаке', 'name' => 'Стерлитамак (sterlitamak)'],'petrozavodsk' => ['subdomain_region' => 'Петрозаводск', 'subdomain_regione' => 'Петрозаводске', 'name' => 'Петрозаводск (petrozavodsk)'],'kostroma' => ['subdomain_region' => 'Кострома', 'subdomain_regione' => 'Костроме', 'name' => 'Кострома (kostroma)'],'nizhnevartovsk' => ['subdomain_region' => 'Нижневартовск', 'subdomain_regione' => 'Нижневартовске', 'name' => 'Нижневартовск (nizhnevartovsk)'],'novorossiysk' => ['subdomain_region' => 'Новороссийск', 'subdomain_regione' => 'Новороссийске', 'name' => 'Новороссийск (novorossiysk)'],'yoshkar-ola' => ['subdomain_region' => 'Йошкар-Ола', 'subdomain_regione' => 'Йошкар-Оле', 'name' => 'Йошкар-Ола (yoshkar-ola)'],'komsomolsk-na-amure' => ['subdomain_region' => 'Комсомольск-на-Амуре', 'subdomain_regione' => 'Комсомольске-на-Амуре', 'name' => 'Комсомольск-на-Амуре (komsomolsk-na-amure)'],'taganrog' => ['subdomain_region' => 'Таганрог', 'subdomain_regione' => 'Таганроге', 'name' => 'Таганрог (taganrog)'],'syktyvkar' => ['subdomain_region' => 'Сыктывкар', 'subdomain_regione' => 'Сыктывкаре', 'name' => 'Сыктывкар (syktyvkar)'],'nalchik' => ['subdomain_region' => 'Нальчик', 'subdomain_regione' => 'Нальчике', 'name' => 'Нальчик (nalchik)'],'shahty' => ['subdomain_region' => 'Шахты', 'subdomain_regione' => 'Шахтах', 'name' => 'Шахты (shahty)'],'nizhnekamsk' => ['subdomain_region' => 'Нижнекамск', 'subdomain_regione' => 'Нижнекамске', 'name' => 'Нижнекамск (nizhnekamsk)'],'bratsk' => ['subdomain_region' => 'Братск', 'subdomain_regione' => 'Братске', 'name' => 'Братск (bratsk)'],'orsk' => ['subdomain_region' => 'Орск', 'subdomain_regione' => 'Орске', 'name' => 'Орск (orsk)'],'angarsk' => ['subdomain_region' => 'Ангарск', 'subdomain_regione' => 'Ангарске', 'name' => 'Ангарск (angarsk)'],'blagoveschensk' => ['subdomain_region' => 'Благовещенск', 'subdomain_regione' => 'Благовещенске', 'name' => 'Благовещенск (blagoveschensk)'],'engels' => ['subdomain_region' => 'Энгельс', 'subdomain_regione' => 'Энгельсе', 'name' => 'Энгельс (engels)'],'staryi-oskol' => ['subdomain_region' => 'Старый Оскол', 'subdomain_regione' => 'Старом Осколе', 'name' => 'Старый Оскол (staryi-oskol)'],'velikiy-novgorod' => ['subdomain_region' => 'Великий Новгород', 'subdomain_regione' => 'Великом Новгороде', 'name' => 'Великий Новгород (velikiy-novgorod)'],'pskov' => ['subdomain_region' => 'Псков', 'subdomain_regione' => 'Пскове', 'name' => 'Псков (pskov)'],'biysk' => ['subdomain_region' => 'Бийск', 'subdomain_regione' => 'Бийске', 'name' => 'Бийск (biysk)'],'prokopievsk' => ['subdomain_region' => 'Прокопьевск', 'subdomain_regione' => 'Прокопьевске', 'name' => 'Прокопьевск (prokopievsk)'],'yuzhno-sahalinsk' => ['subdomain_region' => 'Южно-Сахалинск', 'subdomain_regione' => 'Южно-Сахалинске', 'name' => 'Южно-Сахалинск (yuzhno-sahalinsk)'],'balakovo' => ['subdomain_region' => 'Балаково', 'subdomain_regione' => 'Балаково', 'name' => 'Балаково (balakovo)'],'rybinsk' => ['subdomain_region' => 'Рыбинск', 'subdomain_regione' => 'Рыбинске', 'name' => 'Рыбинск (rybinsk)'],'armavir' => ['subdomain_region' => 'Армавир', 'subdomain_regione' => 'Армавире', 'name' => 'Армавир (armavir)'],'severodvinsk' => ['subdomain_region' => 'Северодвинск', 'subdomain_regione' => 'Северодвинске', 'name' => 'Северодвинск (severodvinsk)'],'petropavlovsk-kamchatsky' => ['subdomain_region' => 'Петропавловск-Камчатский', 'subdomain_regione' => 'Петропавловске-Камчатском', 'name' => 'Петропавловск-Камчатский (petropavlovsk-kamchatsky)'],'abakan' => ['subdomain_region' => 'Абакан', 'subdomain_regione' => 'Абакане', 'name' => 'Абакан (abakan)'],'norilsk' => ['subdomain_region' => 'Норильск', 'subdomain_regione' => 'Норильске', 'name' => 'Норильск (norilsk)'],'syzran' => ['subdomain_region' => 'Сызрань', 'subdomain_regione' => 'Сызрани', 'name' => 'Сызрань (syzran)'],'volgodonsk' => ['subdomain_region' => 'Волгодонск', 'subdomain_regione' => 'Волгодонске', 'name' => 'Волгодонск (volgodonsk)'],'novocherkassk' => ['subdomain_region' => 'Новочеркасск', 'subdomain_regione' => 'Новочеркасске', 'name' => 'Новочеркасск (novocherkassk)'],'kamensk-uralsky' => ['subdomain_region' => 'Каменск-Уральский', 'subdomain_regione' => 'Каменске-Уральском', 'name' => 'Каменск-Уральский (kamensk-uralsky)'],'zlatoust' => ['subdomain_region' => 'Златоуст', 'subdomain_regione' => 'Златоусте', 'name' => 'Златоуст (zlatoust)'],'ussuriysk' => ['subdomain_region' => 'Уссурийск', 'subdomain_regione' => 'Уссурийске', 'name' => 'Уссурийск (ussuriysk)'],'salavat' => ['subdomain_region' => 'Салават', 'subdomain_regione' => 'Салавате', 'name' => 'Салават (salavat)'],'nahodka' => ['subdomain_region' => 'Находка', 'subdomain_regione' => 'Находке', 'name' => 'Находка (nahodka)'],'almetevsk' => ['subdomain_region' => 'Альметьевск', 'subdomain_regione' => 'Альметьевске', 'name' => 'Альметьевск (almetevsk)'],'miass' => ['subdomain_region' => 'Миасс', 'subdomain_regione' => 'Миассе', 'name' => 'Миасс (miass)'],'kerch' => ['subdomain_region' => 'Керчь', 'subdomain_regione' => 'Керчи', 'name' => 'Керчь (kerch)'],'berezniki' => ['subdomain_region' => 'Березники', 'subdomain_regione' => 'Березниках', 'name' => 'Березники (berezniki)'],'rubtsovsk' => ['subdomain_region' => 'Рубцовск', 'subdomain_regione' => 'Рубцовске', 'name' => 'Рубцовск (rubtsovsk)'],'kopeisk' => ['subdomain_region' => 'Копейск', 'subdomain_regione' => 'Копейске', 'name' => 'Копейск (kopeisk)'],'pyatigorsk' => ['subdomain_region' => 'Пятигорск', 'subdomain_regione' => 'Пятигорске', 'name' => 'Пятигорск (pyatigorsk)'],'maikop' => ['subdomain_region' => 'Майкоп', 'subdomain_regione' => 'Майкопе', 'name' => 'Майкоп (maikop)'],'kovrov' => ['subdomain_region' => 'Ковров', 'subdomain_regione' => 'Коврове', 'name' => 'Ковров (kovrov)'],'hasavurt' => ['subdomain_region' => 'Хасавюрт', 'subdomain_regione' => 'Хасавюрте', 'name' => 'Хасавюрт (hasavurt)'],'kislovodsk' => ['subdomain_region' => 'Кисловодск', 'subdomain_regione' => 'Кисловодске', 'name' => 'Кисловодск (kislovodsk)'],'novomoskovsk' => ['subdomain_region' => 'Новомосковск', 'subdomain_regione' => 'Новомосковске', 'name' => 'Новомосковск (novomoskovsk)'],'neftekamsk' => ['subdomain_region' => 'Нефтекамск', 'subdomain_regione' => 'Нефтекамске', 'name' => 'Нефтекамск (neftekamsk)'],'novocheboksarsk' => ['subdomain_region' => 'Новочебоксарск', 'subdomain_regione' => 'Новочебоксарске', 'name' => 'Новочебоксарск (novocheboksarsk)'],'nefteugansk' => ['subdomain_region' => 'Нефтеюганск', 'subdomain_regione' => 'Нефтеюганске', 'name' => 'Нефтеюганск (nefteugansk)'],'pervouralsk' => ['subdomain_region' => 'Первоуральск', 'subdomain_regione' => 'Первоуральске', 'name' => 'Первоуральск (pervouralsk)'],'derbent' => ['subdomain_region' => 'Дербент', 'subdomain_regione' => 'Дербенте', 'name' => 'Дербент (derbent)'],'cherkessk' => ['subdomain_region' => 'Черкесск', 'subdomain_regione' => 'Черкесске', 'name' => 'Черкесск (cherkessk)'],'bataisk' => ['subdomain_region' => 'Батайск', 'subdomain_regione' => 'Батайске', 'name' => 'Батайск (bataisk)'],'nevinnomyssk' => ['subdomain_region' => 'Невинномысск', 'subdomain_regione' => 'Невинномысске', 'name' => 'Невинномысск (nevinnomyssk)'],'dimitrovgrad' => ['subdomain_region' => 'Димитровград', 'subdomain_regione' => 'Димитровграде', 'name' => 'Димитровград (dimitrovgrad)'],'kyzyl' => ['subdomain_region' => 'Кызыл', 'subdomain_regione' => 'Кызыле', 'name' => 'Кызыл (kyzyl)'],'oktyabrsky' => ['subdomain_region' => 'Октябрьский', 'subdomain_regione' => 'Октябрьском', 'name' => 'Октябрьский (oktyabrsky)'],'nazran' => ['subdomain_region' => 'Назрань', 'subdomain_regione' => 'Назрани', 'name' => 'Назрань (nazran)'],'kamyshin' => ['subdomain_region' => 'Камышин', 'subdomain_regione' => 'Камышине', 'name' => 'Камышин (kamyshin)'],'novy-urengoy' => ['subdomain_region' => 'Новый Уренгой', 'subdomain_regione' => 'Новом Уренгое', 'name' => 'Новый Уренгой (novy-urengoy)'],'kaspiysk' => ['subdomain_region' => 'Каспийск', 'subdomain_regione' => 'Каспийске', 'name' => 'Каспийск (kaspiysk)'],'murom' => ['subdomain_region' => 'Муром', 'subdomain_regione' => 'Муроме', 'name' => 'Муром (murom)'],'novoshahtinsk' => ['subdomain_region' => 'Новошахтинск', 'subdomain_regione' => 'Новошахтинске', 'name' => 'Новошахтинск (novoshahtinsk)'],'seversk' => ['subdomain_region' => 'Северск', 'subdomain_regione' => 'Северске', 'name' => 'Северск (seversk)'],'noyabrsk' => ['subdomain_region' => 'Ноябрьск', 'subdomain_regione' => 'Ноябрьске', 'name' => 'Ноябрьск (noyabrsk)'],'evpatoriya' => ['subdomain_region' => 'Евпатория', 'subdomain_regione' => 'Евпатории', 'name' => 'Евпатория (evpatoriya)'],'essentuki' => ['subdomain_region' => 'Ессентуки', 'subdomain_regione' => 'Ессентуках', 'name' => 'Ессентуки (essentuki)'],'elets' => ['subdomain_region' => 'Елец', 'subdomain_regione' => 'Ельце', 'name' => 'Елец (elets)'],'achinsk' => ['subdomain_region' => 'Ачинск', 'subdomain_regione' => 'Ачинске', 'name' => 'Ачинск (achinsk)'],'artem' => ['subdomain_region' => 'Артём', 'subdomain_regione' => 'Артёме', 'name' => 'Артём (artem)'],'arzamas' => ['subdomain_region' => 'Арзамас', 'subdomain_regione' => 'Арзамасе', 'name' => 'Арзамас (arzamas)'],'elista' => ['subdomain_region' => 'Элиста', 'subdomain_regione' => 'Элисте', 'name' => 'Элиста (elista)'],'novokuibyshevsk' => ['subdomain_region' => 'Новокуйбышевск', 'subdomain_regione' => 'Новокуйбышевске', 'name' => 'Новокуйбышевск (novokuibyshevsk)'],'berdsk' => ['subdomain_region' => 'Бердск', 'subdomain_regione' => 'Бердске', 'name' => 'Бердск (berdsk)'],'crimea' => ['subdomain_region' => 'Крым', 'subdomain_regione' => 'Крыму', 'name' => 'Крым (crimea)'],'voskresensk' => ['subdomain_region' => 'Воскресенск', 'subdomain_regione' => 'Воскресенске', 'name' => 'Воскресенск (voskresensk)'],'zheleznodorojniy' => ['subdomain_region' => 'Железнодорожный', 'subdomain_regione' => 'Железнодорожном', 'name' => 'Железнодорожный (zheleznodorojniy)'],'istra' => ['subdomain_region' => 'Истра', 'subdomain_regione' => 'Истре', 'name' => 'Истра (istra)'],'klimovsk' => ['subdomain_region' => 'Климовск', 'subdomain_regione' => 'Климовске', 'name' => 'Климовск (klimovsk)'],'kotelniki' => ['subdomain_region' => 'Котельники', 'subdomain_regione' => 'Котельниках', 'name' => 'Котельники (kotelniki)'],'losino-petrovskiy' => ['subdomain_region' => 'Лосино-Петровский', 'subdomain_regione' => 'Лосине-Петровске', 'name' => 'Лосино-Петровский (losino-petrovskiy)'],'lotoshino' => ['subdomain_region' => 'Лотошино', 'subdomain_regione' => 'Лотошино', 'name' => 'Лотошино (lotoshino)'],'mihnevo' => ['subdomain_region' => 'Михнево', 'subdomain_regione' => 'Михнево', 'name' => 'Михнево (mihnevo)'],'ozery' => ['subdomain_region' => 'Озеры', 'subdomain_regione' => 'Озерах', 'name' => 'Озеры (ozery)'],'pushchino' => ['subdomain_region' => 'Пущино', 'subdomain_regione' => 'Пущино', 'name' => 'Пущино (pushchino)'],'roshal' => ['subdomain_region' => 'Рошаль', 'subdomain_regione' => 'Рошале', 'name' => 'Рошаль (roshal)'],'ruza' => ['subdomain_region' => 'Руза', 'subdomain_regione' => 'Рузе', 'name' => 'Руза (ruza)'],'sofrino' => ['subdomain_region' => 'Софрино', 'subdomain_regione' => 'Софрино', 'name' => 'Софрино (sofrino)'],'taldom' => ['subdomain_region' => 'Талдом', 'subdomain_regione' => 'Талдоме', 'name' => 'Талдом (taldom)'],'troitsk' => ['subdomain_region' => 'Троицк', 'subdomain_regione' => 'Троицке', 'name' => 'Троицк (troitsk)'],'tuchkovo' => ['subdomain_region' => 'Тучково', 'subdomain_regione' => 'Тучково', 'name' => 'Тучково (tuchkovo)'],'chehov' => ['subdomain_region' => 'Чехов', 'subdomain_regione' => 'Чехове', 'name' => 'Чехов (chehov)'],'shahovskaya' => ['subdomain_region' => 'Шаховская', 'subdomain_regione' => 'Шаховской', 'name' => 'Шаховская (shahovskaya)'],'scherbinka' => ['subdomain_region' => 'Щербинка', 'subdomain_regione' => 'Щербинке', 'name' => 'Щербинка (scherbinka)'],'elektrogorsk' => ['subdomain_region' => 'Электрогорск', 'subdomain_regione' => 'Электрогорске', 'name' => 'Электрогорск (elektrogorsk)']];
//какие настройки нужно менять на новом контексте
$settings = ['http_host', 'site_start', 'site_url', 'subdomain_region', 'subdomain_regione'];
$i = 2;
foreach($new_contexts as $key => $new_context){
$new_context_key = $key;
$response = $modx->runProcessor('context/duplicate',array(
'action' => 'duplicate',
'key' => 'lobnya',//заменить на уже созданный контекст с одним ресурсом (Главная)
'newkey' => $new_context_key,
'preserve_resources' => 'on'//копируем содержащиеся ресурсы (Главная или Главная и Контакты)
));
if ($response->isError()) {
echo $response->getMessage();
}
$chunkArray = $response->getObject();
$context = $modx->getObject('modContext', array('key' => $chunkArray['key']));
$context->set('name', $new_context['name']);
$context->set('description', 'Поддомен для региона ' . $new_context['subdomain_region']);
$context->set('rank', $i);
$context->save();
$i++;
if($res = $modx->getObject('modResource', array('context_key' => $new_context_key))){
$res->set('pagetitle', 'Главная');
$res->set('alias', $key);
$res->save();
}
foreach($settings as $setting){
if($set = $modx->getObject('modContextSetting', array('context_key' => $new_context_key, 'key' => $setting))){
switch($setting){
case 'subdomain_region':
$set->set('value', $new_context['subdomain_region']);
break;
case 'subdomain_regione':
$set->set('value', $new_context['subdomain_regione']);
break;
case 'http_host':
$set->set('value', $new_context_key.'.'.MODX_HTTP_HOST);
break;
case 'site_start':
if($res->id){
$set->set('value', $res->id);
}
break;
case 'site_url':
$set->set('value', "https://{$new_context_key}.".MODX_HTTP_HOST."/");
break;
}
$set->save();
}
}
$vars = ['type' => 'A', 'name' => $new_context_key, 'content' => '5.9.10.197', 'proxied' => true];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://api.cloudflare.com/client/v4/zones/a8bed1ab107789fc50b25cfc9da/dns_records");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($vars)); //Post Fields
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-Auth-Email: info@MAIL',
'X-Auth-Key: c3bb9e865fc6dc9eabe08795508ac8a94',
'Content-Type: application/json'
));
$server_output = curl_exec ($ch);
curl_close ($ch);
$modx->log(modX::LOG_LEVEL_ERROR, print_r($chunkArray, true));
}
<?php
// для выгрузки всех контекстов с продакшен сайта в формате для скрипта copy_context_bonus.php
// запускать в Console
$out = [];
$ctxs = $modx->getIterator('modContext', ['rank:>=' => 77, 'key:NOT IN' => ['omsk']]); //условия по потребности
foreach($ctxs as $ctx){
$settings = $ctx->getMany('ContextSettings');
$out[$ctx->key]['name'] = $ctx->name;
foreach($settings as $set){
switch($set->key){
case 'subdomain_region':
case 'subdomain_regione':
$out[$set->context_key][$set->key] = $set->value;
break;
}
}
}
print_r(json_encode($out));
<?php
/*
*сниппет для вывода полей ресурса для разных поддоменов
*&key - любое поле ресурса, которое подлежит изменению и есть в MIGX таблице
*&toPlaceholder - сохранять вывод в плейсхолдер с одноименным названием из параметра &key, например, [[+titl]]
*/
$key = ($key) ? $key : 'titl';
$toPLS = ($toPlaceholder) ? true : false;
$res = $modx->resource;
if($res){
//получение MIGX поля изменений для данного контекста
$tvr = $modx->getObject('modTemplateVarResource', array(
'tmplvarid' => 11,
'contentid' => $res->id
));
if ($tvr) {
$json = $tvr->get('value');
if(is_array(json_decode($json, true))){
$array = json_decode($json, true);
foreach($array as $v){
if($v['context'] == $modx->context->key){
if($v[ $key ]) {
if($toPLS){
$modx->toPlaceholder($key, $v[ $key ]);
return;
}
return $v[ $key ];
}
}
}
}
}
if($out = $res->getTVValue($key)){
if($toPLS){
$modx->toPlaceholder($key, $out);
return;
}
return $out;
}
if($out = $res->$key){
if($toPLS){
$modx->toPlaceholder($key, $out);
return;
}
return (is_array($out)) ? '' : $out;
}
}
https://forums.modx.com/thread/88955/display-all-tv-values-of-a-resource#dis-post-489218 - получение всех ТВ для ресурса, выставляем в плагине, чтобы Fenom распарсил на странице приджойненный TV
{
"formtabs":[
{
"MIGX_id":1,
"caption":"\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d\u043e\u0432",
"print_before_tabs":"0",
"fields":[
{
"MIGX_id":1,
"field":"context",
"caption":"\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \/ \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d",
"description":"",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"listbox",
"validation":"",
"configs":"",
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"@EVAL return $modx->runSnippet('getContext');",
"default":"",
"useDefaultIfEmpty":"0",
"pos":1
},
{
"MIGX_id":2,
"field":"titl",
"caption":"\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b",
"description":"\u0415\u0441\u043b\u0438 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 \u0442\u0435\u0433\u0435 [[*titl]] \u0438\u043b\u0438 [[*pagetitle]].",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"",
"validation":"",
"configs":"",
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"",
"default":"",
"useDefaultIfEmpty":"0",
"pos":2
},
{
"MIGX_id":3,
"field":"meta_desc",
"caption":"META \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b",
"description":"\u0415\u0441\u043b\u0438 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043e, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0434\u043b\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 \u0442\u0435\u0433\u0435 [[*meta_desc]] \u0438\u043b\u0438 [[*description]].",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"textarea",
"validation":"",
"configs":"",
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"",
"default":"",
"useDefaultIfEmpty":"0",
"pos":3
},
{
"MIGX_id":4,
"field":"meta_keywords",
"caption":"META \u043a\u043b\u044e\u0447\u0435\u0432\u0438\u043a\u0438 \u0434\u043b\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b",
"description":"\u0415\u0441\u043b\u0438 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u044b, \u0442\u043e \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 \u0442\u0435\u0433\u0435 [[*meta_keywords]].",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"textarea",
"validation":"",
"configs":"",
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"",
"default":"",
"useDefaultIfEmpty":"0",
"pos":4
},
{
"MIGX_id":5,
"field":"content",
"caption":"\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u0430",
"description":"\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442 (\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435) \u0440\u0435\u0441\u0443\u0440\u0441\u0430 \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d\u0430, \u0442\u043e \u0442\u0435\u043a\u0441\u0442 \u043c\u043e\u0436\u043d\u043e \u0432\u0432\u0435\u0441\u0442\u0438 \u0441\u044e\u0434\u0430. \u0415\u0441\u043b\u0438 \u043d\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u043f\u043e\u043b\u0435, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043e \u043f\u043e\u043b\u0435 content \u0441\u0430\u043c\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u0430.",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"richtext",
"validation":"",
"configs":"",
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"",
"default":"",
"useDefaultIfEmpty":"0",
"pos":5
},
{
"MIGX_id":6,
"field":"help",
"caption":"\u041f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f",
"description":"\u0412\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d\u043e\u0432 \u0438\u043b\u0438 \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u0441\u0430\u0439\u0442\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0442\u0435\u043b\u0435\u0444\u043e\u043d, \u0430\u0434\u0440\u0435\u0441 e-mail \u0438 \u043f\u0440\u043e\u0447\u0438\u0435, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 <a href=\"\/manager\/?id=0&a=context\/update&key=[[+context:default=`web`]]\" target=\"_blank\">\u043d\u0430\u0441\u0442\u043e\u0439\u043a\u0430\u0445 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430<\/a> \u0438\u043b\u0438 \u043b\u044e\u0431\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430.<br>\n\u041a\u043e\u0434 \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430 \u042f\u043d\u0434\u0435\u043a\u0441 \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d\u043e\u0432 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0447\u0430\u043d\u043a\u0435 <a href=\"\/manager\/?a=element\/chunk\/update&id=8\" target=\"_blank\">yandex_counter<\/a>\n<script>\n$(function() {\n\nnew Noty({\n text: '\u0412\u043d\u0438\u043c\u0430\u043d\u0438\u0435! \u0414\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d\u043e\u0432 \u043d\u0435 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f! \u0415\u0441\u043b\u0438 \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u0442\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430!',\ntheme: 'metroui',\ntype:'warning',\nkiller:true,\n animation: {\n open: 'animated bounceInRight',\n close: 'animated bounceOutRight'\n }\n}).show();\n\n});\n<\/script>",
"description_is_code":1,
"inputTV":"",
"inputTVtype":"",
"validation":"",
"configs":"",
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"",
"default":"",
"useDefaultIfEmpty":"0",
"pos":6
},
{
"MIGX_id":7,
"field":"published",
"caption":"\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d\u0435?",
"description":"\u0415\u0441\u043b\u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u043b\u0430\u0441\u044c \u043d\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u043c \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d\u0435, \u0442\u043e \u0441\u043d\u0438\u043c\u0438\u0442\u0435 \u0433\u0430\u043b\u043e\u0447\u043a\u0443.",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"checkbox",
"validation":"",
"configs":"",
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"\u0414\u0430==1",
"default":1,
"useDefaultIfEmpty":"0",
"pos":7
}
],
"pos":1
}
],
"contextmenus":"",
"actionbuttons":"",
"columnbuttons":"",
"filters":"",
"extended":{
"migx_add":"\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d\u0430",
"disable_add_item":"",
"add_items_directly":"",
"formcaption":"",
"update_win_title":"",
"win_id":"DifferentsForContext",
"maxRecords":5,
"addNewItemAt":"bottom",
"multiple_formtabs":"",
"multiple_formtabs_label":"",
"multiple_formtabs_field":"",
"multiple_formtabs_optionstext":"",
"multiple_formtabs_optionsvalue":"",
"actionbuttonsperrow":4,
"winbuttonslist":"",
"extrahandlers":"",
"filtersperrow":4,
"packageName":"",
"classname":"",
"task":"",
"getlistsort":"",
"getlistsortdir":"",
"sortconfig":"",
"gridpagesize":"",
"use_custom_prefix":"0",
"prefix":"",
"grid":"",
"gridload_mode":1,
"check_resid":1,
"check_resid_TV":"",
"join_alias":"",
"has_jointable":"yes",
"getlistwhere":"",
"joins":"",
"hooksnippets":"",
"cmpmaincaption":"",
"cmptabcaption":"",
"cmptabdescription":"",
"cmptabcontroller":"",
"winbuttons":"",
"onsubmitsuccess":"",
"submitparams":""
},
"columns":[
{
"MIGX_id":1,
"header":"\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d\u0430",
"dataIndex":"context",
"width":"",
"sortable":"false",
"show_in_grid":1,
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":""
},
{
"MIGX_id":2,
"header":"\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043d\u0430 \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d\u0435",
"dataIndex":"titl",
"width":"",
"sortable":"false",
"show_in_grid":1,
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":"this.textEditor"
},
{
"MIGX_id":3,
"header":"\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u043d\u0430 \u043f\u043e\u0434\u0434\u043e\u043c\u0435\u043d\u0435?",
"dataIndex":"published",
"width":"",
"sortable":"false",
"show_in_grid":1,
"customrenderer":"",
"renderer":"this.renderCrossTick",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":""
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment