Ok. Here I post the code (it is copied and edited from Joomla code,
more exactly, the function saveContent() from file \administrator
\components\com_content\controller.php)
protected function save_article(&$article) {
global $mainframe;
// Check for request forgeries
//JRequest::checkToken() or jexit( 'Invalid Token' );
// Initialize variables
$db = & JFactory::getDBO();
$user = & JFactory::getUser();
//JPluginHelper::importPlugin('content');
//require_once('helper.php');
$row = & JTable::getInstance('content');
//include('../../../../components/com_content/models/article.php');
//echo '<br />s';
//$row = new ContentModelArticle();
//foreach ($row->getProperties() as $k => $v)
//{
// echo '<br />' .$k;
//}
//echo '<br />e';
//exit;
$row->catid = 12;
$row->access = 0;
$row->created = '';
$row->created_by = null;
$row->publish_down = 'Never';
$row->publish_up = '';
$row->mask = 0;
$row->sectionid = 3;
$row->state = 1;
$row->version = 0;
// title, text
$row->title = $article->get_title();
//$row->introtext = 'aaa';//$article->get_lead();
//$row->fulltext = $article->get_content();
//$row->text = 'aaa';
$row->created_by = $row->created_by ? $row->created_by : $user->get
('id');
if ($row->created && strlen(trim( $row->created )) <= 10) {
$row->created .= ' 00:00:00';
}
$config =& JFactory::getConfig();
$tzoffset = $config->getValue('config.offset');
$date =& JFactory::getDate($row->created, $tzoffset);
$row->created = $date->toMySQL();
// Append time if not added to publish date
if (strlen(trim($row->publish_up)) <= 10) {
$row->publish_up .= ' 00:00:00';
}
$date =& JFactory::getDate($row->publish_up, $tzoffset);
$row->publish_up = $date->toMySQL();
// Handle never unpublish date
if (trim($row->publish_down) == JText::_('Never') || trim( $row-
>publish_down ) == '')
{
$row->publish_down = $nullDate;
}
else
{
if (strlen(trim( $row->publish_down )) <= 10) {
$row->publish_down .= ' 00:00:00';
}
$date =& JFactory::getDate($row->publish_down, $tzoffset);
$row->publish_down = $date->toMySQL();
}
// Prepare the content for saving to the database
ContentHelper::saveContentPrep( $row );
// Make sure the data is valid
//if (!$row->check()) {
// JError::raiseError( 500, $db->stderr() );
// return false;
//}
// Increment the content version number
$row->version++;
// Store the content to the database
if (!$row->store()) {
JError::raiseError( 500, $db->stderr() );
return false;
}
// Check the article and update item order
$row->checkin();
$row->reorder('catid = '.(int) $row->catid.' AND state >= 0');
$cache = & JFactory::getCache('com_content');
$cache->clean();