<?php
if (!defined('_JEXEC')) {
define( '_JEXEC', 1 );
define('JPATH_BASE', realpath(dirname(__FILE__)));
require_once ( JPATH_BASE .'/includes/defines.php' );
require_once ( JPATH_BASE .'/includes/framework.php' );
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
}
$app = JFactory::getApplication('site');
$img_arr['image_intro'] = 'images/karta.png';
$img_arr['float_intro'] = '';
$img_arr['image_intro_alt'] = '';
$img_arr['image_intro_caption'] = '';
$img_arr['image_fulltext'] = '';
$img_arr['float_fulltext'] = '';
$img_arr['image_fulltext_alt'] = '';
$img_arr['image_fulltext_caption'] = '';
$articles_arry['catid'] = '9';
$articles_arry['created_by'] = 565;
$articles_arry['title'] = 'загалововок тестовой новости';
$articles_arry['alias'] = 'jghghghgjh';
$articles_arry['introtext'] = '';
$articles_arry['fulltext'] = 'проверка';
$articles_arry['images'] = json_encode($img_arr);
$articles_arry['state'] = 1;
$articles_arry['urls'] = '{"urla":false,"urlatext":"","targeta":"","urlb":false,"urlbtext":"","targetb":"","urlc":false,"urlctext":"","targetc":""}';
$articles_arry['attribs'] = '{"show_title":"","link_titles":"","show_tags":"","show_intro":"","info_block_position":"","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":""}';
$articles_arry['metadata'] = '{"robots":"","author":"","rights":"","xreference":""}';
$articles_arry['language'] = '*';
$articles_arry['created'] = JHTML::Date(time(), 'Y-m-d H:i:s');
$articles_arry['metakey'] = '';
createArticle($articles_arry);
function createArticle($data)
{
$basePath = 'administrator/components/com_content';
require_once $basePath.'/models/article.php';
$article_model = JModelLegacy::getInstance('Article','ContentModel');
// global $article_model;
$data['rules'] = array(
'core.edit.delete' => array(),
'core.edit.edit' => array(),
'core.edit.state' => array(),
);
if(!$article_model->save($data))
{
$err_msg = $article_model->getError();
echo JText::_($err_msg)."\n";
return false;
}
}
?>