// ---------------------------------------------------------------------------- Пишем в базу
if ($count_md5 == 0) { // такой новости нет в базе
// Делаем alias
function translit($str) {
$rus = array(',', '.', '!', ':', ' ', 'А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И', 'Й', 'К', 'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'Ь', 'Э', 'Ю', 'Я', 'а', 'б', 'в', 'г', 'д', 'е', 'ё', 'ж', 'з', 'и', 'й', 'к', 'л', 'м', 'н', 'о', 'п', 'р', 'с', 'т', 'у', 'ф', 'х', 'ц', 'ч', 'ш', 'щ', 'ъ', 'ы', 'ь', 'э', 'ю', 'я');
$lat = array('', '', '', '', '-', 'A', 'B', 'V', 'G', 'D', 'E', 'E', 'Gh', 'Z', 'I', 'Y', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'F', 'H', 'C', 'Ch', 'Sh', 'Sch', 'Y', 'Y', 'Y', 'E', 'Yu', 'Ya', 'a', 'b', 'v', 'g', 'd', 'e', 'e', 'gh', 'z', 'i', 'y', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'f', 'h', 'c', 'ch', 'sh', 'sch', 'y', 'y', 'y', 'e', 'yu', 'ya');
return str_replace($rus, $lat, $str);
}
$alias = translit($meta_title);
$alias = mb_strtolower($alias);
// Узнаем автора, через категорию
$db = JFactory::getDbo();
$query = "SELECT #__categories.created_user_id
FROM #__categories
WHERE #__categories.id = $db->quote('".$cat_id."') ORDER BY #__categories.id DESC LIMIT 1";
$db->setQuery($query);
$created_user_id = $db->loadObject();
$created_by = $created_user_id->created_user_id;
$metadata = '{"robots":"","author":"","rights":"","xreference":""}';
$attribs = '{"show_title":"","link_titles":"","show_tags":"","show_intro":"","info_block_position":"","info_block_show_title":"","show_category":"","link_category":"","show_parent_category":"","link_parent_category":"","show_author":"","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":""}';
$urls = '{"urla":false,"urlatext":"","targeta":"","urlb":false,"urlbtext":"","targetb":"","urlc":false,"urlctext":"","targetc":""}';
$images = '{"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}';
$date_parset = date('Y-m-d H:i:s');
$query = "INSERT INTO `#__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`, `md5`)
VALUES (`id`, `asset_id`, '".$meta_title."', '".$alias."', '".$html_news."', `fulltext`, `state`, '".$cat_id."', '".$date_parset."', '".$created_by."',
`created_by_alias`, '".$date_parset."', `modified_by`, `checked_out`, `checked_out_time`, `publish_up`, `publish_down`, '".$images."', '".$urls."', '".$attribs."',
`version`, `ordering`, `metakey`, `metadesc`, '1', `hits`, '".$metadata."', `featured`, '*', `xreference`, '".$md5_news_url."')";
$db->setQuery($query);
$db->query();
}
// ---------------------------------------------------------------------------- Конец Пишем в базу