Commit 7439a84a authored by Simonas's avatar Simonas

Data migrated

parent bd85b470
......@@ -16,10 +16,10 @@
- check if dev.biuro.lt, dev.biuro.lv, dev.biuro.ee works
### DB backup
- `C:\web\dev.biuro> docker exec -i mysql mysqldump -uroot -pIiIjnsLi2wR9i1kWVbVpUAzP --default-character-set=utf8 wordpress > docker/mariadb/db_005.sql`
- `C:\web\dev.biuro> docker exec -i mysql mysqldump -uroot -pIiIjnsLi2wR9i1kWVbVpUAzP --default-character-set=utf8 wordpress > docker/mariadb/db_002.sql`
### DB restore
- `C:\web\dev.biuro> docker exec -i mysql mysql -uroot -pIiIjnsLi2wR9i1kWVbVpUAzP --default-character-set=utf8 wordpress < docker/mariadb/db_004.sql`
- `C:\web\dev.biuro> docker exec -i mysql mysql -uroot -pIiIjnsLi2wR9i1kWVbVpUAzP --default-character-set=utf8 wordpress < docker/mariadb/db_001.sql`
## Development
- `C:\web\dev.biuro\wordpress>yarn (or npm install)`
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -741,201 +741,3 @@ function init_biuro_theme() {
// unregister_nav_menu('vilnius-menu');
}
add_action('init', 'init_biuro_theme');
function setPagesLT () {
return setPages ( 'biuro.lt', '2018/10/' );
}
function setPagesLV () {
return setPages ( 'biuro.lv', 'sites/2/2018/10/' );
}
function setPagesEE () {
return setPages ( 'biuro.ee', 'sites/3/2018/10/' );
}
function setPages ( $domain, $path ) {
global $wpdb;
$data = $wpdb->get_results("SELECT
ID as ID,
Title as post_title,
Content as post_content,
Sort as menu_order,
URLSegment as post_name,
Created as post_date,
LastEdited as post_modified,
MetaTitle as _yoast_wpseo_title,
MetaDescription as _yoast_wpseo_metadesc,
MetaKeywords as _yoast_wpseo_focuskw,
Locale as locale,
ParentID as parentID,
CASE WHEN (ParentID > 0) THEN (select URLSegment from `SiteTree_Live` WHERE ID = a.ParentID) ELSE '' END AS URLSegmentParent,
CASE WHEN (ParentID > 0) THEN CONCAT('/', (select URLSegment from `SiteTree_Live` WHERE ID = a.ParentID), '/', URLSegment, '/') ELSE CONCAT('/', URLSegment, '/') END AS URLSegmentFull,
MenuTitle as menu FROM SiteTree_Live a ORDER BY parentID");
$res = array();
$arr = array();
foreach ($data as $row) {
$res[$row->ID] = $row;
}
foreach ($res as $key => $row) {
$search = array(
'direktorija/boxru4',
'sitetree_link%20id',
'http://' . $domain . '/assets',
'http://www.' . $domain . '/assets',
'href="http://biuro.lt',
'href="http://www.biuro.lt',
'src="http://biuro.lt',
'src="http://www.biuro.lt',
'assets/New-pictures/New-pictures/_resampled',
'assets/New-pictures/New-pictures/',
'assets/New-pictures/_resampled/',
'assets/New-pictures/',
'assets/_resampled/',
'assets/Nauja-direktorija/Nauja-direktorija/',
'assets/Nauja-direktorija/',
'assets/Files/_resampled/',
'assets/Files/',
'assets/Uploads/Nauji-paveiksleliai/',
'assets/Uploads/blocks/',
'assets/Uploads/',
'assets/',
'mysite/img/',
'/New-pictures/',
'/_resampled/',
);
$replace = array(
'direktorija/boxru6',
'sitetree_link id',
'assets',
'assets',
'href="https://dev.biuro.lt',
'href="https://dev.biuro.lt',
'src="https://dev.biuro.lt',
'src="https://dev.biuro.lt',
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'/',
'/',
);
$content = str_replace($search, $replace, $row->post_content);
preg_match_all('/\[sitetree_link id=(\d+)\]/mi', $content, $matches);
if (count($matches[0]) > 0) {
foreach ($matches[0] as $in => $r) {
// $res[$row->ID] = $row;
$content = str_replace($matches[0][$in], $res[$matches[1][$in]]->URLSegmentFull, $content);
}
}
$parentID = 0;
if ($row->parentID > 0) {
$parentPage = get_page_by_path($row->URLSegmentParent);
$parentID = $parentPage->ID;
}
# code...
$postID = wp_insert_post(array(
'post_title' => $row->post_title,
'post_content' => $content,
'menu_order' => $row->menu_order,
'post_name' => $row->post_name,
'post_date' => $row->post_date,
'post_modified' => $row->post_modified,
'post_author' => 1,
'post_type' => 'page',
'post_status' => 'publish',
'post_parent' => $parentID,
));
if ($postID > 0) {
add_post_meta($postID, '_yoast_wpseo_title', $row->_yoast_wpseo_title);
add_post_meta($postID, '_yoast_wpseo_metadesc', $row->_yoast_wpseo_metadesc);
add_post_meta($postID, '_yoast_wpseo_focuskw', $row->_yoast_wpseo_focuskw);
$code = 'lt';
switch ($row->locale) {
case 'lt_LT':
$code = 'lt';
break;
case 'en_US':
$code = 'en';
break;
case 'ru_RU':
$code = 'ru';
break;
case 'de_DE':
$code = 'de';
break;
case 'lv_LV':
$code = 'lv';
break;
case 'et_EE':
$code = 'et';
break;
}
PLL()->model->post->set_language($postID, $code);
}
}
return $arr;
}
add_action( 'rest_api_init', function () {
// https://dev.biuro.lt/wp-json/biuro/v1/pagesLT
// https://dev.biuro.lv/wp-json/biuro/v1/pagesLV
// https://dev.biuro.ee/wp-json/biuro/v1/pagesEE
register_rest_route( 'biuro/v1', '/pagesLT', array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'setPagesLT',
));
register_rest_route( 'biuro/v1', '/pagesLV', array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'setPagesLV',
));
register_rest_route( 'biuro/v1', '/pagesEE', array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'setPagesEE',
));
});
\ No newline at end of file
......@@ -145,6 +145,17 @@
<div id="sidebar">
<?php
$translations = pll_the_languages(array('raw'=>1));
echo '<ul style="float: left; list-style: none; margin: 0; padding: 0;">';
foreach ($translations as $code => $lang) :
echo '<li><a href="' . $lang['url'] . '">' . $lang['name'] . '</a></li>';
endforeach;
echo '</ul>';
?>
<ul id="menu">
<li>
<a href="#">VISI</a>
......
......@@ -741,201 +741,3 @@ function init_biuro_theme() {
// unregister_nav_menu('vilnius-menu');
}
add_action('init', 'init_biuro_theme');
function setPagesLT () {
return setPages ( 'biuro.lt', '2018/10/' );
}
function setPagesLV () {
return setPages ( 'biuro.lv', 'sites/2/2018/10/' );
}
function setPagesEE () {
return setPages ( 'biuro.ee', 'sites/3/2018/10/' );
}
function setPages ( $domain, $path ) {
global $wpdb;
$data = $wpdb->get_results("SELECT
ID as ID,
Title as post_title,
Content as post_content,
Sort as menu_order,
URLSegment as post_name,
Created as post_date,
LastEdited as post_modified,
MetaTitle as _yoast_wpseo_title,
MetaDescription as _yoast_wpseo_metadesc,
MetaKeywords as _yoast_wpseo_focuskw,
Locale as locale,
ParentID as parentID,
CASE WHEN (ParentID > 0) THEN (select URLSegment from `SiteTree_Live` WHERE ID = a.ParentID) ELSE '' END AS URLSegmentParent,
CASE WHEN (ParentID > 0) THEN CONCAT('/', (select URLSegment from `SiteTree_Live` WHERE ID = a.ParentID), '/', URLSegment, '/') ELSE CONCAT('/', URLSegment, '/') END AS URLSegmentFull,
MenuTitle as menu FROM SiteTree_Live a ORDER BY parentID");
$res = array();
$arr = array();
foreach ($data as $row) {
$res[$row->ID] = $row;
}
foreach ($res as $key => $row) {
$search = array(
'direktorija/boxru4',
'sitetree_link%20id',
'http://' . $domain . '/assets',
'http://www.' . $domain . '/assets',
'href="http://biuro.lt',
'href="http://www.biuro.lt',
'src="http://biuro.lt',
'src="http://www.biuro.lt',
'assets/New-pictures/New-pictures/_resampled',
'assets/New-pictures/New-pictures/',
'assets/New-pictures/_resampled/',
'assets/New-pictures/',
'assets/_resampled/',
'assets/Nauja-direktorija/Nauja-direktorija/',
'assets/Nauja-direktorija/',
'assets/Files/_resampled/',
'assets/Files/',
'assets/Uploads/Nauji-paveiksleliai/',
'assets/Uploads/blocks/',
'assets/Uploads/',
'assets/',
'mysite/img/',
'/New-pictures/',
'/_resampled/',
);
$replace = array(
'direktorija/boxru6',
'sitetree_link id',
'assets',
'assets',
'href="https://dev.biuro.lt',
'href="https://dev.biuro.lt',
'src="https://dev.biuro.lt',
'src="https://dev.biuro.lt',
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'https://dev.' . $domain . '/wp-content/uploads/' . $path,
'/',
'/',
);
$content = str_replace($search, $replace, $row->post_content);
preg_match_all('/\[sitetree_link id=(\d+)\]/mi', $content, $matches);
if (count($matches[0]) > 0) {
foreach ($matches[0] as $in => $r) {
// $res[$row->ID] = $row;
$content = str_replace($matches[0][$in], $res[$matches[1][$in]]->URLSegmentFull, $content);
}
}
$parentID = 0;
if ($row->parentID > 0) {
$parentPage = get_page_by_path($row->URLSegmentParent);
$parentID = $parentPage->ID;
}
# code...
$postID = wp_insert_post(array(
'post_title' => $row->post_title,
'post_content' => $content,
'menu_order' => $row->menu_order,
'post_name' => $row->post_name,
'post_date' => $row->post_date,
'post_modified' => $row->post_modified,
'post_author' => 1,
'post_type' => 'page',
'post_status' => 'publish',
'post_parent' => $parentID,
));
if ($postID > 0) {
add_post_meta($postID, '_yoast_wpseo_title', $row->_yoast_wpseo_title);
add_post_meta($postID, '_yoast_wpseo_metadesc', $row->_yoast_wpseo_metadesc);
add_post_meta($postID, '_yoast_wpseo_focuskw', $row->_yoast_wpseo_focuskw);
$code = 'lt';
switch ($row->locale) {
case 'lt_LT':
$code = 'lt';
break;
case 'en_US':
$code = 'en';
break;
case 'ru_RU':
$code = 'ru';
break;
case 'de_DE':
$code = 'de';
break;
case 'lv_LV':
$code = 'lv';
break;
case 'et_EE':
$code = 'et';
break;
}
PLL()->model->post->set_language($postID, $code);
}
}
return $arr;
}
add_action( 'rest_api_init', function () {
// https://dev.biuro.lt/wp-json/biuro/v1/pagesLT
// https://dev.biuro.lv/wp-json/biuro/v1/pagesLV
// https://dev.biuro.ee/wp-json/biuro/v1/pagesEE
register_rest_route( 'biuro/v1', '/pagesLT', array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'setPagesLT',
));
register_rest_route( 'biuro/v1', '/pagesLV', array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'setPagesLV',
));
register_rest_route( 'biuro/v1', '/pagesEE', array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'setPagesEE',
));
});
\ No newline at end of file
......@@ -145,6 +145,17 @@
<div id="sidebar">
<?php
$translations = pll_the_languages(array('raw'=>1));
echo '<ul style="float: left; list-style: none; margin: 0; padding: 0;">';
foreach ($translations as $code => $lang) :
echo '<li><a href="' . $lang['url'] . '">' . $lang['name'] . '</a></li>';
endforeach;
echo '</ul>';
?>
<ul id="menu">
<li>
<a href="#">VISI</a>
......
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