-
-
Save promo360/b59821a0ee349fa2a720235aed502dde to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once dirname(__FILE__).'/config.core.php'; | |
include_once MODX_CORE_PATH . 'model/modx/modx.class.php'; | |
$modx= new modX(); | |
$modx->initialize('mgr'); | |
$modx->setLogLevel(modX::LOG_LEVEL_INFO); | |
$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML'); | |
header("Content-type: text/plain"); | |
// Settings | |
$settings = array( | |
'cultureKey' => 'ru', | |
'fe_editor_lang' => 'ru', | |
'publish_default' => 1, // Новые ресурсы по умолчанию будут "Опубликованы" | |
// 'tvs_below_content' => 1, // TV параметры будут не в отдельной вкладке, а под контентом в админке | |
'upload_maxsize' => '10485760', | |
'cache_resource' => 0, | |
'topmenu_show_descriptions' => 0, // в админке у верхнего меню не будет описания | |
'locale' => 'ru_RU.utf-8', // Локаль, возможно надо ru_RU.utf8 | |
'manager_lang_attribute' => 'ru', | |
'manager_language' => 'ru', | |
// Лишнее в дашбоард отключаем | |
'feed_modx_news_enabled' => 0, // канал новостей | |
'feed_modx_security_enabled' => 0, // канал безопасности | |
'error_page' => 3, // ID страницы с ошибкой | |
'compress_js' => 0, | |
'compress_css' => 1, | |
//url | |
'automatic_alias' => 1, | |
'friendly_urls' => 1, | |
'friendly_urls_strict' => 1, | |
'use_alias_path' => 1, // вложенные урлы | |
'container_suffix' => '', // без слеша на конце | |
'global_duplicate_uri_check' => 1, | |
'friendly_alias_translit' => 'russian', | |
//'link_tag_scheme' => 'full', | |
'fastuploadtv.translit' => 1, | |
); | |
foreach ($settings as $k => $v) { | |
$opt = $modx->getObject('modSystemSetting', array('key' => $k)); | |
if (!empty($opt)){ | |
$opt->set('value', $v); | |
$opt->save(); | |
echo 'edited '.$k.' = '.$v."\n"; | |
} else { | |
$newOpt = $modx->newObject('modSystemSetting'); | |
$newOpt->set('key', $k); | |
$newOpt->set('value', $v); | |
$newOpt->save(); | |
echo 'added '.$k.' = '.$v."\n"; | |
} | |
} | |
// Обнуляем расширение файла у типа содержимого -> HTML | |
$ct = $modx->getObject('modContentType', array('name'=>'HTML')); | |
$ct->set('file_extensions', ''); | |
$ct->save(); | |
// Меняем название контекста с Website на Веб-сайт | |
$context = $modx->getObject('modContext', array('key' => 'web')); | |
$context->set('name', 'Веб-сайт'); | |
$context->save(); | |
// Создаем категории | |
// Путь: core/model/modx/processor/element/... (дальше выбираем элемент и любые действия | |
$response = $modx->runProcessor('element/category/create',array('category' => 'Tpl')); | |
$response = $modx->runProcessor('element/category/create',array('category' => 'Template')); | |
$response = $modx->runProcessor('element/category/create',array('category' => 'SEO')); | |
$category_tpl_id = 5; // ID категории (Tpl), может поменяться, если поменяются катеории у установленных пакетов из packages.php | |
$category_template_id = 6; | |
$category_seo_id = 7; | |
// Создаем дополнительные поля (TV) | |
// Начальный шаблон. Rank - позиция, Access - если будет false, то не будет соединения TV с шаблоном | |
$templates_json = json_encode(array(1 => array('id' => 1, 'rank' => 0, 'access' => true))); | |
$tvs = array( | |
array( | |
'name' => 'meta_title', | |
'caption' => 'Meta Title', | |
'type' => 'text', | |
'templates' => $templates_json, | |
'category' => $category_seo_id | |
), | |
array( | |
'name' => 'meta_description', | |
'caption' => 'Meta Description', | |
'type' => 'text', | |
'templates' => $templates_json, | |
'category' => $category_seo_id | |
), | |
array( | |
'name' => 'meta_keywords', | |
'caption' => 'Meta Keywords', | |
'type' => 'text', | |
'templates' => $templates_json, | |
'category' => $category_seo_id | |
), | |
array( | |
'name' => 'image', | |
'caption' => 'Изображение', | |
'type' => 'image', | |
'templates' => $templates_json, | |
'category' => $category_seo_id | |
), | |
); | |
foreach ($tvs as $attr) { | |
$response = $modx->runProcessor('element/tv/create', $attr); | |
} | |
// Создаем чанки | |
$chunks = array( | |
// Tpl <div class="row"></div> | |
array( | |
'name' => 'tpl.wrapper.row', | |
'category' => $category_tpl_id, | |
'description' => 'Универсальный чанк для обертки Grid-а от CSS Bootstrap', | |
'snippet' => '<div class="row">[[+output]]</div>', | |
), | |
// Tpl <table class="table"></div> | |
array( | |
'name' => 'tpl.example.table', | |
'category' => $category_tpl_id, | |
'description' => 'Пример чанка-обертки таблицы на CSS Bootstrap', | |
'snippet' => '<table class="table table-hover"> | |
<thead> | |
<tr> | |
<th>Столбец 1</th> | |
<th>Столбец 2</th> | |
</tr> | |
<thead> | |
<tbody> | |
[[+output]] | |
</tbody> | |
</table>', | |
), | |
// Tpl <tr></tr> | |
array( | |
'name' => 'tpl.example.tr', | |
'category' => $category_tpl_id, | |
'description' => 'Пример чанка-строки таблицы на CSS Bootstrap', | |
'snippet' => '<tr> | |
<td><a href="[[~[[+id]]]]">[[+pagetitle]]</a></td> | |
<td>...</td> | |
</tr>', | |
), | |
// Template Sidebar | |
array( | |
'name' => 'sidebar', | |
'category' => $category_template_id, | |
'description' => 'Левая колонка', | |
'snippet' => 'Сайдбар', | |
), | |
// Template Header | |
array( | |
'name' => 'header', | |
'category' => $category_template_id, | |
'description' => 'Шапка сайта и HEAD', | |
'snippet' => '<!DOCTYPE html>', | |
), | |
// Template Footer | |
array( | |
'name' => 'footer', | |
'category' => $category_template_id, | |
'description' => 'ПОдвал сайта', | |
'snippet' => '</body></html>', | |
), | |
); | |
foreach ($chunks as $attr) { | |
$modx->error->reset(); | |
$response = $modx->runProcessor('element/chunk/create', $attr); | |
} | |
// Создаем ресурсы | |
$resources = array( | |
array('pagetitle' => 'Контакты', | |
'template' => 1, | |
'published' => 1, | |
'hidemenu' => 0, | |
'alias' => 'contacts', | |
'content_type' => 1, | |
'richtext' => 1, | |
'menuindex' => 500, | |
'content' =>'<h1>Наши контакты</h1><p>Телефон: [[++tel]]</p>' | |
) | |
, array('pagetitle' => '404', | |
'template' => 1, | |
'published' => 1, | |
'hidemenu' => 1, | |
'alias' => 'error404', | |
'content_type' => 1, | |
'richtext' => 1, | |
'menuindex' => 9998, | |
'content' =>'<h1>Страница не найдена</h1><p>Страница, которую вы ищите не существует, либо еще не создана. Начните просмотр нашего сайта с <a href="[[~1]]">главной страницы</a>.</p>' | |
) | |
, array('pagetitle' => 'sitemap', | |
'template' => 0, | |
'published' => 1, | |
'hidemenu' => 1, | |
'alias' => 'sitemap', | |
'content_type' => 2, | |
'richtext' => 0, | |
'menuindex' => 9999, | |
'content' =>'[[!pdoSitemap]]' | |
) | |
, array('pagetitle' => 'robots', | |
'template' => 0, | |
'published' => 1, | |
'hidemenu' => 1, | |
'alias' => 'robots', | |
'content_type' => 3, | |
'richtext' => 0, | |
'menuindex' => 9999, | |
'content' => 'User-agent: * Disallow: /manager/ Disallow: /assets/components/ Allow: /assets/uploads/ Disallow: /core/ Disallow: /connectors/ Disallow: /index.php Disallow: /search Disallow: /profile/ Host: [[++site_url]] Sitemap: [[++site_url]]sitemap.xml' | |
) | |
); | |
$modx->error->reset(); | |
foreach ($resources as $attr) { | |
$modx->error->reset(); | |
$response = $modx->runProcessor('resource/create', $attr); | |
} | |
//$modx->cacheManager->refresh(); | |
$modx->runProcessor('system/clearcache'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment