Any API in Joomla 1.0.x to add some new content ? - Joomla! Forum - community, help and support
i've started write small component upload kml file server , component automatically create new content based on file.
is there api like:
create_content(section_id, category_id, published, author_id, content_text);
which job?
or need create such function myself , write necessary code update database ?
any hint on needs done?
thanks help!
is there api like:
create_content(section_id, category_id, published, author_id, content_text);
which job?
or need create such function myself , write necessary code update database ?
any hint on needs done?
thanks help!
i had @ com_content , came following function achieve want:
code: select all
function addcontent($sectionid, $categoryid, $published, $authorid, $title, $content_text)
{
global $database;
$nulldate = $database->getnulldate();
$row = new moscontent( $database );
// load row db table: initialization
$row->load( 0 );
$row->id = 0;
$row->catid = $categoryid;
$row->sectionid = $sectionid;
$row->version = 0;
$row->state = 0;
$row->ordering = 0;
$row->images = array();
$row->publish_up = date( 'y-m-d', time() );
$row->publish_down = 'never';
$row->modified_by = 0;
// start fill in content...
$row->title = $title;
$row->introtext = $content_text;
$row->fulltext = "";
$row->created = date( 'y-m-d h:i:s' );
$row->created_by = $authorid;
$row->state = 1;
// various checks , cleanup
if (strlen(trim( $row->publish_up )) <= 10) {
$row->publish_up .= ' 00:00:00';
}
$row->publish_up = mosformatdate( $row->publish_up, _current_server_time_format, -$mosconfig_offset );
if (trim( $row->publish_down ) == 'never' || trim( $row->publish_down ) == '') {
$row->publish_down = $nulldate;
} else {
if (strlen(trim( $row->publish_down )) <= 10) {
$row->publish_down .= ' 00:00:00';
}
$row->publish_down = mosformatdate( $row->publish_down, _current_server_time_format, -$mosconfig_offset );
}
// code cleaner xhtml transitional compliance
$row->introtext = str_replace( '<br>', '<br />', $row->introtext );
$row->fulltext = str_replace( '<br>', '<br />', $row->fulltext );
// remove <br /> take being automatically added empty fulltext
$length = strlen( $row->fulltext ) < 9;
$search = strstr( $row->fulltext, '<br />');
if ( $length && $search ) {
$row->fulltext = null;
}
$row->title = ampreplace( $row->title );
$row->check();
$row->version++;
$row->store();
$row->checkin();
$row->updateorder( "catid = " . (int) $row->catid );
$msg = "content created , saved !";
$link = strval( mosgetparam( $_post, 'referer', '' ) );
mosredirect( $link, $msg );
}
Comments
Post a Comment