本文整理汇总了PHP中Item::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::set方法的具体用法?PHP Item::set怎么用?PHP Item::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Item
的用法示例。
在下文中一共展示了Item::set方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
/**
* This function is called after when some file was unlinked from item
*
* @param integer Link ID
*/
function after_unlink_action($link_ID = 0)
{
if (empty($this->Item)) {
// No existing Item, Exit here
return;
}
if (!empty($link_ID)) {
// Find inline image placeholders if link ID is defined
preg_match_all('/\\[(image|file|inline):' . $link_ID . ':?[^\\]]*\\]/i', $this->Item->content, $inline_images);
if (!empty($inline_images[0])) {
// There are inline image placeholders in the post content
$this->Item->set('content', str_replace($inline_images[0], '', $this->Item->content));
$this->Item->dbupdate();
return;
}
}
// Update last touched date of the Item
$this->update_last_touched_date();
}
示例2: tool_create_sample_posts
/**
* Create sample posts and display a process of creating
*
* @param integer Blog ID
* @param integer Number of posts
*/
function tool_create_sample_posts($blog_ID, $num_posts)
{
global $Messages, $DB, $Debuglog;
$BlogCache =& get_BlogCache();
$selected_Blog = $BlogCache->get_by_ID($blog_ID, false, false);
if ($selected_Blog == NULL) {
// Incorrect blog ID, Exit here
return;
}
echo T_('Creating of the sample posts...');
evo_flush();
/**
* Disable log queries because it increases the memory and stops the process with error "Allowed memory size of X bytes exhausted..."
*/
$DB->log_queries = false;
$count = 1;
$num_posts_created = 0;
$content = T_('This is an auto generated post for testing moderation.');
for ($i = 1; $i <= $num_posts; $i++) {
// Spaces and line breaks make generated string look like real text
$length = rand(300, 500);
$word = generate_random_key($length, "\n abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
$post_content = $content . ' ' . $word;
$urltitle = strtolower(str_replace(array("\n", ' ', '-'), '', substr($word, 50, 20)));
$urltitle = trim($urltitle, '-');
$Item = new Item();
$Item->set('title', 'Generated post ' . $i);
$Item->set('content', $post_content);
$Item->set('status', 'published');
$Item->set('dateset', 1);
// Set post main cat ID, from selected blog
$Item->set('main_cat_ID', $selected_Blog->get_default_cat_ID());
// Random post url slug
$Item->set('urltitle', $urltitle);
if ($Item->dbinsert_test()) {
$num_posts_created++;
}
$count++;
if ($count % 100 == 0) {
// Display a process of creating by one dot for 100 posts
echo ' .';
//pre_dump( memory_get_usage() );
evo_flush();
}
// Clear all debug messages, To avoid an error about full memory
$Debuglog->clear('all');
}
echo ' OK.';
$Messages->add(sprintf(T_('Created %d posts.'), $num_posts_created), 'success');
if ($num_posts > $num_posts_created) {
// Some post creation failed because of concurtent modification error
// Note: This message should not appear offten, so it doesn't need translation
$Messages->add(sprintf('Creation of %d post(s) failed becuase of concurrent modification error.', $num_posts - $num_posts_created), 'note');
}
}
示例3: xmlrpcs_new_item
/**
* Create a new Item and return an XML-RPC response
*
* @param array Item properties
* @param object Blog where we are going to create a new Item
* @return xmlrpcmsg
*/
function xmlrpcs_new_item($params, &$Blog = NULL)
{
global $current_User, $Settings, $Messages, $DB, $posttypes_perms;
$params = array_merge(array('title' => '', 'content' => '', 'date' => '', 'main_cat_ID' => 0, 'extra_cat_IDs' => array(), 'cat_IDs' => array(), 'status' => 'published', 'tags' => '', 'excerpt' => '', 'item_typ_ID' => 1, 'comment_status' => 'open', 'urltitle' => '', 'featured' => 0, 'custom_fields' => array(), 'order' => '', 'parent_ID' => ''), $params);
if (empty($Blog) && !empty($params['main_cat_ID'])) {
// Get the blog by main category ID
// Check if category exists and can be used
$ChapterCache =& get_ChapterCache();
$main_Chapter =& $ChapterCache->get_by_ID($params['main_cat_ID'], false, false);
if (empty($main_Chapter)) {
// Cat does not exist:
return xmlrpcs_resperror(11);
// User error 11
}
$BlogCache =& get_BlogCache();
$Blog =& $BlogCache->get_by_ID($main_Chapter->blog_ID, false, false);
logIO('Requested Blog: ' . $Blog->ID . ' - ' . $Blog->name);
}
if (empty($Blog)) {
// Blog does not exist:
return xmlrpcs_resperror();
}
if (empty($params['main_cat_ID'])) {
if (is_array($params['cat_IDs']) && count($params['cat_IDs']) > 0) {
// Let's use first cat for MAIN and others for EXTRA
$params['main_cat_ID'] = array_shift($params['cat_IDs']);
$params['extra_cat_IDs'] = $params['cat_IDs'];
} else {
if (!($main_cat = $Blog->get_default_cat_ID())) {
// No default category found for requested blog
return xmlrpcs_resperror(12);
// User error 12
}
$params['main_cat_ID'] = $main_cat;
}
}
logIO('Main cat ID: ' . $params['main_cat_ID']);
logIO('Extra cat IDs: ' . implode(', ', $params['extra_cat_IDs']));
if (empty($params['main_cat_ID'])) {
// Main category does not exist:
return xmlrpcs_resperror(11);
// User error 11
}
// Check if category exists and can be used
if (!xmlrpcs_check_cats($params['main_cat_ID'], $Blog, $params['extra_cat_IDs'])) {
// Permission denied
return xmlrpcs_resperror(3);
// User error 3
}
/*
* CHECK PERMISSION: (we need perm on all categories, especially if they are in different blogs)
* NOTE: extra_cat_IDs array now includes main_cat_ID too, so we are actually checking ALL categories below
*/
if (!$current_User->check_perm('cats_post!' . $params['status'], 'edit', false, $params['extra_cat_IDs'])) {
// Permission denied
return xmlrpcs_resperror(3);
// User error 3
}
if (!empty($params['item_typ_ID'])) {
if (!preg_match('~^[0-9]+$~', $params['item_typ_ID'])) {
// Only accept numeric values, switch to default value
$params['item_typ_ID'] = 1;
}
foreach ($posttypes_perms as $l_permname => $l_posttypes) {
// "Reverse" the $posttypes_perms array:
foreach ($l_posttypes as $ll_posttype) {
$posttype2perm[$ll_posttype] = $l_permname;
}
}
if (isset($posttype2perm[$params['item_typ_ID']])) {
// Check permission for this post type
if (!$current_User->check_perm('cats_' . $posttype2perm[$params['item_typ_ID']], 'edit', false, $params['extra_cat_IDs'])) {
// Permission denied
return xmlrpcs_resperror(3);
// User error 3
}
}
}
logIO('Post type: ' . $params['item_typ_ID']);
logIO('Permission granted.');
// CHECK HTML SANITY:
if (($params['title'] = check_html_sanity($params['title'], 'xmlrpc_posting')) === false) {
return xmlrpcs_resperror(21, $Messages->get_string('Invalid post title, please correct these errors:', ''));
}
if (($params['content'] = check_html_sanity($params['content'], 'xmlrpc_posting')) === false) {
return xmlrpcs_resperror(22, $Messages->get_string('Invalid post contents, please correct these errors:' . "\n", '', " // \n", 'xmlrpc'));
}
if (empty($params['date'])) {
$params['date'] = date('Y-m-d H:i:s', time() + $Settings->get('time_difference'));
}
// INSERT NEW POST INTO DB:
load_class('items/model/_item.class.php', 'Item');
$edited_Item = new Item();
//.........这里部分代码省略.........
示例4: param
param('post_status', 'string', 'published');
if ($action == 'create_publish') {
// load publish status from param, because a post can be published to many status
$post_status = load_publish_status(true);
}
// Check if new category was started to create. If yes check if it is valid.
check_categories($post_category, $post_extracats);
// Check permission on statuses:
$current_User->check_perm('cats_post!' . $post_status, 'create', true, $post_extracats);
// Check permission on post type:
check_perm_posttype($post_extracats);
// CREATE NEW POST:
load_class('items/model/_item.class.php', 'Item');
$edited_Item = new Item();
// Set the params we already got:
$edited_Item->set('status', $post_status);
$edited_Item->set('main_cat_ID', $post_category);
$edited_Item->set('extra_cat_IDs', $post_extracats);
// Set object params:
$edited_Item->load_from_Request($action == 'create_edit', true);
$Plugins->trigger_event('AdminBeforeItemEditCreate', array('Item' => &$edited_Item));
if (!empty($mass_create)) {
// ------ MASS CREATE ------
$Items =& create_multiple_posts($edited_Item, param('paragraphs_linebreak', 'boolean', 0));
if (empty($Items)) {
param_error('content', T_('Content must not be empty.'));
}
}
$result = !$Messages->has_errors();
if ($result) {
// There are no validation errors
示例5: wpxml_import
/**
* Import WordPress data from XML file into b2evolution database
*/
function wpxml_import()
{
global $DB, $tableprefix;
// Load classes:
load_class('regional/model/_country.class.php', 'Country');
load_class('regional/model/_region.class.php', 'Region');
load_class('regional/model/_subregion.class.php', 'Subregion');
load_class('regional/model/_city.class.php', 'City');
// Set Blog from request blog ID
$wp_blog_ID = param('wp_blog_ID', 'integer', 0);
$BlogCache =& get_BlogCache();
$wp_Blog =& $BlogCache->get_by_ID($wp_blog_ID);
// The import type ( replace | append )
$import_type = param('import_type', 'string', 'replace');
// Get XML file from request
$xml_file = $_FILES['wp_file'];
// Parse WordPress XML file into array
$xml_data = wpxml_parser($xml_file['tmp_name']);
$DB->begin();
if ($import_type == 'replace') {
// Remove data from selected blog
// Get existing categories
$SQL = new SQL();
$SQL->SELECT('cat_ID');
$SQL->FROM('T_categories');
$SQL->WHERE('cat_blog_ID = ' . $DB->quote($wp_blog_ID));
$old_categories = $DB->get_col($SQL->get());
if (!empty($old_categories)) {
// Get existing posts
$SQL = new SQL();
$SQL->SELECT('post_ID');
$SQL->FROM('T_items__item');
$SQL->WHERE('post_main_cat_ID IN ( ' . implode(', ', $old_categories) . ' )');
$old_posts = $DB->get_col($SQL->get());
}
echo T_('Removing the comments... ');
evo_flush();
if (!empty($old_posts)) {
$SQL = new SQL();
$SQL->SELECT('comment_ID');
$SQL->FROM('T_comments');
$SQL->WHERE('comment_post_ID IN ( ' . implode(', ', $old_posts) . ' )');
$old_comments = $DB->get_col($SQL->get());
$DB->query('DELETE FROM T_comments WHERE comment_post_ID IN ( ' . implode(', ', $old_posts) . ' )');
if (!empty($old_comments)) {
$DB->query('DELETE FROM T_comments__votes WHERE cmvt_cmt_ID IN ( ' . implode(', ', $old_comments) . ' )');
}
}
echo T_('OK') . '<br />';
echo T_('Removing the posts... ');
evo_flush();
if (!empty($old_categories)) {
$DB->query('DELETE FROM T_items__item WHERE post_main_cat_ID IN ( ' . implode(', ', $old_categories) . ' )');
if (!empty($old_posts)) {
// Remove the post's data from related tables
$DB->query('DELETE FROM T_items__item_settings WHERE iset_item_ID IN ( ' . implode(', ', $old_posts) . ' )');
$DB->query('DELETE FROM T_items__prerendering WHERE itpr_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
$DB->query('DELETE FROM T_items__subscriptions WHERE isub_item_ID IN ( ' . implode(', ', $old_posts) . ' )');
$DB->query('DELETE FROM T_items__version WHERE iver_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
$DB->query('DELETE FROM T_postcats WHERE postcat_post_ID IN ( ' . implode(', ', $old_posts) . ' )');
$DB->query('DELETE FROM T_slug WHERE slug_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
}
}
echo T_('OK') . '<br />';
echo T_('Removing the categories... ');
evo_flush();
$DB->query('DELETE FROM T_categories WHERE cat_blog_ID = ' . $DB->quote($wp_blog_ID));
echo T_('OK') . '<br />';
echo T_('Removing the tags that are no longer used... ');
evo_flush();
if (!empty($old_posts)) {
// Remove the tags
// Get tags from selected blog
$SQL = new SQL();
$SQL->SELECT('itag_tag_ID');
$SQL->FROM('T_items__itemtag');
$SQL->WHERE('itag_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
$old_tags_this_blog = array_unique($DB->get_col($SQL->get()));
if (!empty($old_tags_this_blog)) {
// Get tags from other blogs
$SQL = new SQL();
$SQL->SELECT('itag_tag_ID');
$SQL->FROM('T_items__itemtag');
$SQL->WHERE('itag_itm_ID NOT IN ( ' . implode(', ', $old_posts) . ' )');
$old_tags_other_blogs = array_unique($DB->get_col($SQL->get()));
$old_tags_other_blogs_sql = !empty($old_tags_other_blogs) ? ' AND tag_ID NOT IN ( ' . implode(', ', $old_tags_other_blogs) . ' )' : '';
// Remove the tags that are no longer used
$DB->query('DELETE FROM T_items__tag
WHERE tag_ID IN ( ' . implode(', ', $old_tags_this_blog) . ' )' . $old_tags_other_blogs_sql);
}
// Remove the links of tags with posts
$DB->query('DELETE FROM T_items__itemtag WHERE itag_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
}
echo T_('OK') . '<br /><br />';
}
/* Import authors */
$authors = array();
//.........这里部分代码省略.........
示例6: init_inskin_editing
/**
* Prepare the 'In-skin editing'.
*
*/
function init_inskin_editing()
{
global $Blog, $edited_Item, $action, $form_action;
global $item_tags, $item_title, $item_content;
global $admin_url, $redirect_to, $advanced_edit_link;
if (!$Blog->get_setting('in_skin_editing')) {
// Redirect to the Back-office editing (setting is OFF)
header_redirect($admin_url . '?ctrl=items&action=new&blog=' . $Blog->ID);
}
$tab_switch_params = 'blog=' . $Blog->ID;
// Post ID, go from $_GET when we edit post from Front-office
$post_ID = param('p', 'integer', 0);
// Post ID, go from $_GET when we copy post from Front-office
$copy_post_ID = param('cp', 'integer', 0);
if ($post_ID > 0) {
// Edit post
global $post_extracats;
$action = 'edit';
$ItemCache =& get_ItemCache();
$edited_Item = $ItemCache->get_by_ID($post_ID);
check_categories_nosave($post_category, $post_extracats);
$post_extracats = postcats_get_byID($post_ID);
$redirect_to = url_add_param($admin_url, 'ctrl=items&filter=restore&blog=' . $Blog->ID . '&highlight=' . $edited_Item->ID, '&');
$tab_switch_params .= '&p=' . $edited_Item->ID;
} elseif ($copy_post_ID > 0) {
// Copy post
global $localtimenow;
$action = 'new';
$ItemCache =& get_ItemCache();
$edited_Item = $ItemCache->get_by_ID($copy_post_ID);
$edited_Item_Blog = $edited_Item->get_Blog();
$item_status = $edited_Item_Blog->get_allowed_item_status();
$edited_Item->set('status', $item_status);
$edited_Item->set('dateset', 0);
// Date not explicitly set yet
$edited_Item->set('issue_date', date('Y-m-d H:i:s', $localtimenow));
modules_call_method('constructor_item', array('Item' => &$edited_Item));
check_categories_nosave($post_category, $post_extracats);
$redirect_to = url_add_param($admin_url, 'ctrl=items&filter=restore&blog=' . $Blog->ID, '&');
} elseif (empty($action)) {
// Create new post (from Front-office)
$action = 'new';
load_class('items/model/_item.class.php', 'Item');
$edited_Item = new Item();
$def_status = get_highest_publish_status('post', $Blog->ID, false);
$edited_Item->set('status', $def_status);
check_categories_nosave($post_category, $post_extracats);
$edited_Item->set('main_cat_ID', $Blog->get_default_cat_ID());
// Set default locations from current user
$edited_Item->set_creator_location('country');
$edited_Item->set_creator_location('region');
$edited_Item->set_creator_location('subregion');
$edited_Item->set_creator_location('city');
// Set object params:
$edited_Item->load_from_Request(false, true);
$redirect_to = url_add_param($admin_url, 'ctrl=items&filter=restore&blog=' . $Blog->ID, '&');
}
// Used in the edit form:
// We never allow HTML in titles, so we always encode and decode special chars.
$item_title = htmlspecialchars_decode($edited_Item->title);
if ($Blog->get_setting('allow_html_post')) {
// HTML is allowed for this post, we have HTML in the DB and we can edit it:
$item_content = $edited_Item->content;
} else {
// HTML is disallowed for this post, content is encoded in DB and we need to decode it for editing:
$item_content = htmlspecialchars_decode($edited_Item->content);
}
// Format content for editing, if we were not already in editing...
$Plugins_admin =& get_Plugins_admin();
$edited_Item->load_Blog();
$params = array('object_type' => 'Item', 'object_Blog' => &$edited_Item->Blog);
$Plugins_admin->unfilter_contents($item_title, $item_content, $edited_Item->get_renderers_validated(), $params);
$item_tags = implode(', ', $edited_Item->get_tags());
// Get an url for a link 'Go to advanced edit screen'
$mode_editing = param('mode_editing', 'string', 'expert');
$entries = get_item_edit_modes($Blog->ID, $action, $admin_url, $tab_switch_params);
$advanced_edit_link = $entries[$mode_editing];
$form_action = get_samedomain_htsrv_url() . 'item_edit.php';
}
示例7: pbm_process_messages
/**
* Read messages from server and create posts
*
* @param resource $mbox created by pbm_connect() (by reference)
* @param integer the number of messages to process
* @return boolean true on success
*/
function pbm_process_messages(&$mbox, $limit)
{
global $Settings;
global $pbm_item_files, $pbm_messages, $pbm_items, $post_cntr, $del_cntr, $is_cron_mode;
// No execution time limit
set_max_execution_time(0);
// Are we in test mode?
$test_mode_on = $Settings->get('eblog_test_mode');
$post_cntr = 0;
$del_cntr = 0;
for ($index = 1; $index <= $limit; $index++) {
pbm_msg('<hr /><h3>Processing message #' . $index . ':</h3>');
$strbody = '';
$hasAttachment = false;
$hasRelated = false;
$pbm_item_files = array();
// reset the value for each new Item
// Save email to hard drive, otherwise attachments may take a lot of RAM
if (!($tmpMIME = tempnam(sys_get_temp_dir(), 'b2evoMail'))) {
pbm_msg(T_('Could not create temporary file.'), true);
continue;
}
imap_savebody($mbox, $tmpMIME, $index);
// Create random temp directory for message parts
$tmpDirMIME = pbm_tempdir(sys_get_temp_dir(), 'b2evo_');
$mimeParser = new mime_parser_class();
$mimeParser->mbox = 0;
// Set to 0 for parsing a single message file
$mimeParser->decode_headers = 1;
$mimeParser->ignore_syntax_errors = 1;
$mimeParser->extract_addresses = 0;
$MIMEparameters = array('File' => $tmpMIME, 'SaveBody' => $tmpDirMIME, 'SkipBody' => 1);
if (!$mimeParser->Decode($MIMEparameters, $decodedMIME)) {
pbm_msg(sprintf('MIME message decoding error: %s at position %d.', $mimeParser->error, $mimeParser->error_position), true);
rmdir_r($tmpDirMIME);
unlink($tmpMIME);
continue;
} else {
pbm_msg('MIME message decoding successful');
if (!$mimeParser->Analyze($decodedMIME[0], $parsedMIME)) {
pbm_msg(sprintf('MIME message analyse error: %s', $mimeParser->error), true);
rmdir_r($tmpDirMIME);
unlink($tmpMIME);
continue;
}
// Get message $subject and $post_date from headers (by reference)
if (!pbm_process_header($parsedMIME, $subject, $post_date)) {
// Couldn't process message headers
rmdir_r($tmpDirMIME);
unlink($tmpMIME);
continue;
}
// TODO: handle type == "message" recursively
// sam2kb> For some reason imap_qprint() demages HTML text... needs more testing
if ($parsedMIME['Type'] == 'html') {
// Mail is HTML
if ($Settings->get('eblog_html_enabled')) {
// HTML posting enabled
pbm_msg('HTML message part saved as ' . $parsedMIME['DataFile']);
$html_body = file_get_contents($parsedMIME['DataFile']);
}
foreach ($parsedMIME['Alternative'] as $alternative) {
// First try to get HTML alternative (when possible)
if ($alternative['Type'] == 'html' && $Settings->get('eblog_html_enabled')) {
// HTML text
pbm_msg('HTML alternative message part saved as ' . $alternative['DataFile']);
// sam2kb> TODO: we may need to use $html_body here instead
$strbody = file_get_contents($alternative['DataFile']);
break;
// stop after first alternative
} elseif ($alternative['Type'] == 'text') {
// Plain text
pbm_msg('Text alternative message part saved as ' . $alternative['DataFile']);
$strbody = imap_qprint(file_get_contents($alternative['DataFile']));
break;
// stop after first alternative
}
}
} elseif ($parsedMIME['Type'] == 'text') {
// Mail is plain text
pbm_msg('Plain-text message part saved as ' . $parsedMIME['DataFile']);
$strbody = imap_qprint(file_get_contents($parsedMIME['DataFile']));
}
// Check for attachments
if (!empty($parsedMIME['Attachments'])) {
$hasAttachment = true;
foreach ($parsedMIME['Attachments'] as $file) {
pbm_msg('Attachment: ' . $file['FileName'] . ' stored as ' . $file['DataFile']);
}
}
// Check for inline images
if (!empty($parsedMIME['Related'])) {
$hasRelated = true;
//.........这里部分代码省略.........
示例8: Item
*/
$AdminUI->title_titlearea = T_('Comment recycle bins');
/*
* Add sub menu entries:
* We do this here instead of _header because we need to include all filter params into regenerate_url()
*/
attach_browse_tabs(false);
$AdminUI->set_path('collections', 'comments');
$AdminUI->breadcrumbpath_add(T_('Comment recycle bins'), '?ctrl=comments&action=emptytrash');
break;
case 'elevate':
// Check that this action request is not a CSRF hacked request:
$Session->assert_received_crumb('comment');
$item_content = $edited_Comment->get_author_name() . ' ' . T_('wrote') . ': <blockquote>' . $edited_Comment->get_content() . '</blockquote>';
$new_Item = new Item();
$new_Item->set('status', 'draft');
$new_Item->set_creator_by_login($current_User->login);
$new_Item->set('main_cat_ID', $Blog->get_default_cat_ID());
$new_Item->set('title', T_('Elevated from comment'));
$new_Item->set('content', $item_content);
if (!$new_Item->dbinsert()) {
$Messages->add(T_('Unable to create the new post!'), 'error');
break;
}
// Deprecate the comment after elevating
$edited_Comment->set('status', 'deprecated');
$edited_Comment->dbupdate();
// Move all child comments to new created post
move_child_comments_to_item($edited_Comment->ID, $new_Item->ID);
header_redirect(url_add_param($admin_url, 'ctrl=items&blog=' . $blog . '&action=edit&p=' . $new_Item->ID, '&'));
break;
示例9: Item
if( $post_content != $old_content )
{
echo '<p style="color:darkblue;border:1px dashed orange;">'.htmlspecialchars($old_content).'</p>
converted img-links to: <p style="color:darkblue;border:1px dashed orange;">'.htmlspecialchars($post_content).'</p>';
}
}*/
debug_dump($post_catids, 'post_extracats');
$post_category = array_shift($post_catids);
debug_dump($post_category, 'post_category');
debug_dump($post_categories, 'post_categories');
debug_dump($post_author, 'post_author');
debug_dump(isset($item_Author->ID) ? $item_Author->ID : 'NULL (simulating)', 'item_Author->ID');
if (!$simulate) {
$edited_Item = new Item();
$edited_Item->set_creator_User($item_Author);
$edited_Item->set('title', $post_title);
$edited_Item->set('content', $post_content);
$edited_Item->set('datestart', $post_date);
$edited_Item->set('main_cat_ID', $post_category);
$edited_Item->set('extra_cat_IDs', $post_catids);
$edited_Item->set('status', $post_status);
$edited_Item->set('locale', $post_locale);
$edited_Item->set('notifications_status', 'finished');
$edited_Item->set('comment_status', $comment_status);
$edited_Item->set_renderers($post_renderers);
$edited_Item->dbinsert();
$post_ID = $edited_Item->ID;
}
$message .= '<li><span style="color:green">Imported successfully</span><ul><li>main category: <span style="color:#09c">' . get_catname($post_category) . '</span></li>';
if (count($post_catids)) {
$message .= '<li>extra categories: <span style="color:#09c">' . preg_replace('/(\\d+)/e', "get_catname('\\1')", implode(', ', $post_catids)) . '</span></li>';
示例10: switch
if (empty($item_status)) {
$Messages->add(T_('Sorry, you have no permission to post into this blog.'), 'error');
break;
}
// make sure we have loaded metas for all files in selection!
$selected_Filelist->load_meta();
// Ready to create post(s):
load_class('items/model/_item.class.php', 'Item');
switch ($action) {
case 'make_post':
// SINGLE POST:
// Stop a request from the blocked IP addresses or Domains
antispam_block_request();
// Create a post:
$edited_Item = new Item();
$edited_Item->set('status', $item_status);
$edited_Item->set('main_cat_ID', $Blog->get_default_cat_ID());
$l_File =& $selected_Filelist->get_next();
$title = $l_File->get('title');
if (empty($title)) {
$title = $l_File->get('name');
}
$edited_Item->set('title', $title);
$DB->begin('SERIALIZABLE');
// INSERT NEW POST INTO DB:
if ($edited_Item->dbinsert()) {
$order = 1;
$LinkOwner = new LinkItem($edited_Item);
do {
// LOOP through files:
// echo '<br>file meta: '.$l_File->meta;
示例11: wpxml_import
//.........这里部分代码省略.........
$SQL->FROM('T_items__item');
$SQL->WHERE('post_main_cat_ID IN ( ' . implode(', ', $old_categories) . ' )');
$old_posts = $DB->get_col($SQL->get());
}
echo T_('Removing the comments... ');
evo_flush();
if (!empty($old_posts)) {
$SQL = new SQL();
$SQL->SELECT('comment_ID');
$SQL->FROM('T_comments');
$SQL->WHERE('comment_item_ID IN ( ' . implode(', ', $old_posts) . ' )');
$old_comments = $DB->get_col($SQL->get());
$DB->query('DELETE FROM T_comments WHERE comment_item_ID IN ( ' . implode(', ', $old_posts) . ' )');
if (!empty($old_comments)) {
$DB->query('DELETE FROM T_comments__votes WHERE cmvt_cmt_ID IN ( ' . implode(', ', $old_comments) . ' )');
$DB->query('DELETE FROM T_links WHERE link_cmt_ID IN ( ' . implode(', ', $old_comments) . ' )');
}
}
echo T_('OK') . '<br />';
echo T_('Removing the posts... ');
evo_flush();
if (!empty($old_categories)) {
$DB->query('DELETE FROM T_items__item WHERE post_main_cat_ID IN ( ' . implode(', ', $old_categories) . ' )');
if (!empty($old_posts)) {
// Remove the post's data from related tables
if ($delete_files) {
// Get the file IDs that should be deleted from hard drive
$SQL = new SQL();
$SQL->SELECT('DISTINCT link_file_ID');
$SQL->FROM('T_links');
$SQL->WHERE('link_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
$deleted_file_IDs = $DB->get_col($SQL->get());
}
$DB->query('DELETE FROM T_items__item_settings WHERE iset_item_ID IN ( ' . implode(', ', $old_posts) . ' )');
$DB->query('DELETE FROM T_items__prerendering WHERE itpr_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
$DB->query('DELETE FROM T_items__subscriptions WHERE isub_item_ID IN ( ' . implode(', ', $old_posts) . ' )');
$DB->query('DELETE FROM T_items__version WHERE iver_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
$DB->query('DELETE FROM T_postcats WHERE postcat_post_ID IN ( ' . implode(', ', $old_posts) . ' )');
$DB->query('DELETE FROM T_slug WHERE slug_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
$DB->query('DELETE l, lv FROM T_links AS l
LEFT JOIN T_links__vote AS lv ON lv.lvot_link_ID = l.link_ID
WHERE l.link_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
$DB->query('DELETE FROM T_users__postreadstatus WHERE uprs_post_ID IN ( ' . implode(', ', $old_posts) . ' )');
}
}
echo T_('OK') . '<br />';
echo T_('Removing the categories... ');
evo_flush();
$DB->query('DELETE FROM T_categories WHERE cat_blog_ID = ' . $DB->quote($wp_blog_ID));
echo T_('OK') . '<br />';
echo T_('Removing the tags that are no longer used... ');
evo_flush();
if (!empty($old_posts)) {
// Remove the tags
// Get tags from selected blog
$SQL = new SQL();
$SQL->SELECT('itag_tag_ID');
$SQL->FROM('T_items__itemtag');
$SQL->WHERE('itag_itm_ID IN ( ' . implode(', ', $old_posts) . ' )');
$old_tags_this_blog = array_unique($DB->get_col($SQL->get()));
if (!empty($old_tags_this_blog)) {
// Get tags from other blogs
$SQL = new SQL();
$SQL->SELECT('itag_tag_ID');
$SQL->FROM('T_items__itemtag');
$SQL->WHERE('itag_itm_ID NOT IN ( ' . implode(', ', $old_posts) . ' )');