Конвертер с wordpress на joomla
[28.09.2015]
Будем конверировать информацию с БД wordress http://fashionschool.com.ua/ в БД joomla 3.5 http://demo.os.zp.ua/
смотрим какие посты есть
SELECT post_status, COUNT( post_status ) AS count_post_status FROM wp_posts GROUP BY post_status
Результат:
SELECT post_type, COUNT( post_type ) AS count_post_type FROM wp_posts GROUP BY post_type
Теперь ищем все посты:
SELECT * FROM `wp_posts` WHERE `post_type` LIKE 'post'
Конвертор положим сюда:
/www/demo.os.zp.ua/sql_utility/select_title.php
Его основная цель: для каждого поста в формате вордпреса сформировать соответствующую запись дампа БД в формате джумлы 3.5:
$alias = $row->post_name; $alias = str_replace("_","-",$alias); if (stripos($alias,"%") !== false || strlen($alias) == 0) $alias = str2url($row->post_title); $introtext = strip_tags($row->post_content); $pos = stripos($introtext," ", 200); if (strlen($introtext) > 200 && pos >= 200) $introtext = substr($introtext, 0, $pos); $sql = "INSERT INTO `mcyqt_content` (`id`, `asset_id`, `title`, `alias`, `introtext`, `fulltext`, `state`, `catid`, `created`, `created_by`, `created_by_alias`, `modified`, `modified_by`, `checked_out`, `checked_out_time`, `publish_up`, `publish_down`, `images`, `urls`, `attribs`, `version`, `ordering`, `metakey`, `metadesc`, `access`, `hits`, `metadata`, `featured`, `language`, `xreference`) VALUES (".$num.", ".$num.", '".str_replace("'","''",$row->post_title)."', '".$alias."', '".str_replace("'","''",$introtext)."', '".str_replace("'","''",$row->post_content)."', 1, 2, '".$row->post_date."', 302, '', '0000-00-00 00:00:00', 302, 0, '0000-00-00 00:00:00', '".$row->post_date."', '0000-00-00 00:00:00', '{".'"'."image_intro".'"'.":".'"'."".'"'.",".'"'."float_intro".'"'.":".'"'."".'"'.",".'"'."image_intro_alt".'"'.":".'"'."".'"'.",".'"'."image_intro_caption".'"'.":".'"'."".'"'.",".'"'."image_fulltext".'"'.":".'"'."".'"'.",".'"'."float_fulltext".'"'.":".'"'."".'"'.",".'"'."image_fulltext_alt".'"'.":".'"'."".'"'.",".'"'."image_fulltext_caption".'"'.":".'"'."".'"'."}', '{".'"'."urla".'"'.":false,".'"'."urlatext".'"'.":".'"'."".'"'.",".'"'."targeta".'"'.":".'"'."".'"'.",".'"'."urlb".'"'.":false,".'"'."urlbtext".'"'.":".'"'."".'"'.",".'"'."targetb".'"'.":".'"'."".'"'.",".'"'."urlc".'"'.":false,".'"'."urlctext".'"'.":".'"'."".'"'.",".'"'."targetc".'"'.":".'"'."".'"'."}', '{".'"'."show_title".'"'.":".'"'."".'"'.",".'"'."link_titles".'"'.":".'"'."".'"'.",".'"'."show_tags".'"'.":".'"'."".'"'.",".'"'."show_intro".'"'.":".'"'."".'"'.",".'"'."info_block_position".'"'.":".'"'."".'"'.",".'"'."show_category".'"'.":".'"'."".'"'.",".'"'."link_category".'"'.":".'"'."".'"'.",".'"'."show_parent_category".'"'.":".'"'."".'"'.",".'"'."link_parent_category".'"'.":".'"'."".'"'.",".'"'."show_author".'"'.":".'"'."0".'"'.",".'"'."link_author".'"'.":".'"'."".'"'.",".'"'."show_create_date".'"'.":".'"'."".'"'.",".'"'."show_modify_date".'"'.":".'"'."".'"'.",".'"'."show_publish_date".'"'.":".'"'."".'"'.",".'"'."show_item_navigation".'"'.":".'"'."".'"'.",".'"'."show_icons".'"'.":".'"'."".'"'.",".'"'."show_print_icon".'"'.":".'"'."".'"'.",".'"'."show_email_icon".'"'.":".'"'."".'"'.",".'"'."show_vote".'"'.":".'"'."".'"'.",".'"'."show_hits".'"'.":".'"'."".'"'.",".'"'."show_noauth".'"'.":".'"'."".'"'.",".'"'."urls_position".'"'.":".'"'."".'"'.",".'"'."alternative_readmore".'"'.":".'"'."".'"'.",".'"'."article_layout".'"'.":".'"'."".'"'.",".'"'."show_publishing_options".'"'.":".'"'."".'"'.",".'"'."show_article_options".'"'.":".'"'."".'"'.",".'"'."show_urls_images_backend".'"'.":".'"'."".'"'.",".'"'."show_urls_images_frontend".'"'.":".'"'."".'"'."}', 1, ".$num.", '', '', 1, 0, '{".'"'."robots".'"'.":".'"'."".'"'.",".'"'."author".'"'.":".'"'."".'"'.",".'"'."rights".'"'.":".'"'."".'"'.",".'"'."xreference".'"'.":".'"'."".'"'."}', 0, '*', '');"; echo $num.". ".$row->post_name." ".$alias." ".$introtext."
"; $num++; file_put_contents("wp_post.sql",$sql."\r\n",FILE_APPEND | LOCK_EX);
Единственный его недостаток пока состоит в том, что в joomla 3.5 появилась таблица безопасности, которую придется сформировать вручную открывая поочередно каждый item в админке сайта. Пример можно увидеть здесь:
- Для комментирования войдите или зарегистрируйтесь