View Single Post
  #6  
Old 11-12-2010, 06:26 PM
Adan0s Adan0s is offline
 
Join Date: May 2008
Location: Germany
Posts: 45
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well I got a direct response from a vB developer with some information for creating articles via own code. Also i got a code example by an user of vbulletin-germany.org.

Code Example (provided by Andreas http://www.vbulletin-germany.org/sho...96&postcount=4, modified by me):

Code:
<?php
define('VB_AREA', 'API');
require('./includes/init.php');
require_once(DIR . '/includes/class_bootstrap_framework.php');
vB_Bootstrap_Framework::init();

function create_article($sectionid, $title, $pagetext, $userid, $categoryid = '', $datestamp = '', $description = '', $htmltitle = '')
{
    global $db;
    
    if (empty($htmltitle)) $htmltitle = $title;
    if (empty($categoryid)) $categoryid = 41;

    $nodedm = new vBCMS_DM_Article();
    $nodedm->info['skip_verify_pagetext'] = true;
    $nodedm->set('contenttypeid', vB_Types::instance()->getContentTypeID('vBCms_Article'));
    $nodedm->set('parentnode', $sectionid);
    $nodedm->set('publicpreview', 1);
    $nodedm->set('comments_enabled', 1);
    $nodedm->set('pagetext', $pagetext);
    $nodedm->set('title', $title);
    $nodedm->set('html_title', $htmltitle);
    $nodedm->set('description', $description);
    $nodedm->set('userid', $userid);
    $nodedm->set('url', vB_Friendly_Url::clean_entities($title));
    $nodeid = $nodedm->save();
    if (empty($nodeid))
    {
        return false;
    }
    else
    {
        $db->query_write("INSERT INTO ". TABLE_PREFIX . "cms_nodecategory (nodeid, categoryid) values (" . $nodeid . ", $categoryid) ");
        $db->query_write("UPDATE " . TABLE_PREFIX . "cms_node SET new = 0 WHERE nodeid = $nodeid");
        if(empty($datestamp) OR $datestamp < 946681200) // if datestamp is empty or before 01.01.2000
        {
            $datestamp = TIMENOW  - vBCms_ContentManager::getTimeOffset(vB::$vbulletin->userinfo, false); // use current datestamp
        }
        $db->query_write("UPDATE " . TABLE_PREFIX . "cms_node set setpublish = 1, publishdate = $datestamp WHERE nodeid = $nodeid");
    }
            
    return $nodeid;
}

echo create_article(113, 'Headline', 'article text', 1);
?>
And the additional information by Ed Brown:

Quote:
We don't have an API. You'll have to work directly with the database insert. You'll need to put data in the following tables:

1) cms_article- the most important fields are userid (the author), pagetext, setpublish (whether the page is published) and publishdate (unix timestamp when is was/will be published. If there are images, they are referenced as [ATTACH=CONFIG]<attachmentid>[/ATTACH]. The content needs to be rendered in BBCode if it is anything but plain text.
2) cms_node. This is a modified preorder traversal table. You can ignore the nodeleft and noderight values and when you are done run a "verify and repair node table" in the admincp, which will save a lot of trouble. The most important fields are nodeid, parentnode (the nodeid of the section into which the article will go), contenttypeid, contentid (from the article table), and url
3) cms_nodeinfo. There is one record here for every record in cms_node, with the same nodeid. The most important field here is the title.
4) (if you have attachments) filedata . There must be a record here for every image you need. One image file can be referenced by multiple articles.
5) (if you have attachments) attachment. This relates the image data to the articles, and is where the permission comes from.
I built my whole e107 importer around those two bits. If you need more help just ask.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01275 seconds
  • Memory Usage 1,781KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete