本文整理汇总了PHP中Articles::finalize_publication方法的典型用法代码示例。如果您正苦于以下问题:PHP Articles::finalize_publication方法的具体用法?PHP Articles::finalize_publication怎么用?PHP Articles::finalize_publication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Articles
的用法示例。
在下文中一共展示了Articles::finalize_publication方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
if (isset($_REQUEST['first_comment']) && $_REQUEST['first_comment']) {
include_once $context['path_to_root'] . 'comments/comments.php';
$fields = array();
$fields['anchor'] = 'article:' . $_REQUEST['id'];
$fields['description'] = $_REQUEST['first_comment'];
Comments::post($fields);
}
// post an overlay, with the new article id --don't stop on error
if (is_object($overlay)) {
$overlay->remember('insert', $_REQUEST, 'article:' . $_REQUEST['id']);
}
// increment the post counter of the surfer
Users::increment_posts(Surfer::get_id());
// do whatever is necessary on page publication
if (isset($_REQUEST['publish_date']) && $_REQUEST['publish_date'] > NULL_DATE) {
Articles::finalize_publication($anchor, $_REQUEST, $overlay, isset($_REQUEST['silent']) && $_REQUEST['silent'] == 'Y', isset($_REQUEST['notify_followers']) && $_REQUEST['notify_followers'] == 'Y');
// else do whatever is necessary on page submission
} else {
Articles::finalize_submission($anchor, $_REQUEST, $overlay);
}
// get the new item
$article = Anchors::get('article:' . $_REQUEST['id'], TRUE);
// list persons that have been notified
$context['text'] .= Mailer::build_recipients('article:' . $_REQUEST['id']);
// list endpoints that have been notified
$context['text'] .= Servers::build_endpoints(i18n::s('Servers that have been notified'));
// follow-up commands
$follow_up = i18n::s('What do you want to do now?');
$menu = array();
$menu = array_merge($menu, array($article->get_url() => i18n::s('View the page')));
if (Surfer::may_upload()) {
示例2: sprintf
$_REQUEST['publish_name'] = $_REQUEST['edit_name'];
// show e-mail address of anonymous surfer
if ($_REQUEST['edit_address'] && !Surfer::is_logged()) {
$_REQUEST['description'] = '<p>' . sprintf(i18n::c('Sent by %s'), '[email=' . ($_REQUEST['edit_name'] ? $_REQUEST['edit_name'] : i18n::c('e-mail')) . ']' . $_REQUEST['edit_address'] . '[/email]') . "</p>\n" . $_REQUEST['description'];
}
// stop robots
if (Surfer::may_be_a_robot()) {
Logger::error(i18n::s('Please prove you are not a robot.'));
$with_form = TRUE;
// display the form on error
} elseif (!($_REQUEST['id'] = Articles::post($_REQUEST))) {
$with_form = TRUE;
// post-processing
} else {
// do whatever is necessary on page publication
Articles::finalize_publication($anchor, $_REQUEST);
// message to the query poster
$context['page_title'] = i18n::s('Your query has been registered');
// use the secret handle to access the query
$link = '';
$status = '';
if ($item = Articles::get($_REQUEST['id'])) {
// ensure the article has a private handle
if (!isset($item['handle']) || !$item['handle']) {
$item['handle'] = md5(mt_rand());
// save in the database
$fields = array();
$fields['id'] = $item['id'];
$fields['handle'] = $item['handle'];
$fields['silent'] = 'Y';
Articles::put_attributes($fields);
示例3: process_handx_entry
/**
* process one handx entry
*
* This function actually creates an article out an entry
*
* @param string entry content
* @param time stamp
*/
public static function process_handx_entry($text, $stamp = NULL)
{
global $context;
// parse article content
include_once $context['path_to_root'] . 'articles/article.php';
$article = new Article();
$fields = $article->parse($text);
// if no title, use the first line
if (!$fields['title']) {
list($fields['title'], $fields['description']) = preg_split("/\n/", $fields['description'], 2);
}
// if we have a time stamp, use it
if ($stamp) {
$fields['create_date'] = $stamp;
$fields['publish_date'] = $stamp;
$fields['edit_date'] = $stamp;
}
// load parameters for uploads
Safe::load('parameters/agents.include.php');
// user information
if ($context['uploads_nick_name']) {
if ($user = Users::get($context['uploads_nick_name'])) {
if (!$fields['create_name']) {
$fields['create_name'] = $user['nick_name'];
}
if (!$fields['create_id']) {
$fields['create_id'] = $user['id'];
}
if (!$fields['create_address']) {
$fields['create_address'] = $user['email'];
}
if (!$fields['publish_name']) {
$fields['publish_name'] = $user['nick_name'];
}
if (!$fields['publish_id']) {
$fields['publish_id'] = $user['id'];
}
if (!$fields['publish_address']) {
$fields['publish_address'] = $user['email'];
}
if (!$fields['edit_name']) {
$fields['edit_name'] = $user['nick_name'];
}
if (!$fields['edit_id']) {
$fields['edit_id'] = $user['id'];
}
if (!$fields['edit_address']) {
$fields['edit_address'] = $user['email'];
}
}
}
// the anchor
if (!$fields['anchor'] && $context['uploads_anchor']) {
$fields['anchor'] = $context['uploads_anchor'];
}
$anchor = Anchors::get($fields['anchor']);
// post a page
$fields['id'] = Articles::post($fields);
// increment the post counter of the surfer
Users::increment_posts($user['id']);
// do whatever is necessary on page publication
if (isset($fields['publish_date']) && $fields['publish_date'] > NULL_DATE) {
Articles::finalize_publication($anchor, $fields);
}
}
示例4: submit_page
//.........这里部分代码省略.........
$entry_fields['edit_id'] = $user['id'];
}
if (!isset($entry_fields['edit_address'])) {
$entry_fields['edit_address'] = $user['email'];
}
// we have to extend an existing article --this entity is mutable
if ($target && !strncmp($target, 'article:', 8) && ($article = Articles::get(substr($target, 8), TRUE))) {
// append the text to article description field
$fields = array();
$fields['id'] = $article['id'];
$fields['description'] = $article['description'] . $entry_fields['description'];
$fields['silent'] = TRUE;
Articles::put_attributes($fields);
return $target;
// we have to extend an existing comment --this entity is mutable
} elseif ($target && !strncmp($target, 'comment:', 8) && ($comment = Comments::get(substr($target, 8), TRUE))) {
// append the text to comment description field
$comment['description'] .= $entry_fields['description'];
Comments::post($comment);
return $target;
// we have to comment an existing page
} elseif (!strncmp($anchor, 'article:', 8)) {
// insert comment in the database
if (!($entry_fields['id'] = Comments::post($entry_fields))) {
Logger::remember('agents/messages.php: ' . Logger::error_pop());
return NULL;
}
// debug, if required to do so
if ($context['debug_messages'] == 'Y') {
Logger::remember('agents/messages.php: Messages::submit_page() as a comment', $entry_fields, 'debug');
}
// increment the post counter of the surfer
Users::increment_posts($user['id']);
// clear cache
$parent = Anchors::get($entry_fields['anchor']);
// touch the related anchor
if (is_object($parent) && isset($entry_fields['id'])) {
$parent->touch('comment:create', $entry_fields['id'], TRUE);
}
return 'comment:' . $entry_fields['id'];
// create a new page
} else {
// publish automatically, if required to do so
$section = Anchors::get($entry_fields['anchor']);
if (isset($context['users_with_auto_publish']) && $context['users_with_auto_publish'] == 'Y' || preg_match('/\\bauto_publish\\b/i', $options) || is_object($section) && $section->has_option('auto_publish')) {
$entry_fields['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S', time());
if (!isset($entry_fields['publish_name'])) {
$entry_fields['publish_name'] = $user['nick_name'];
}
if (!isset($entry_fields['publish_id'])) {
$entry_fields['publish_id'] = $user['id'];
}
if (!isset($entry_fields['publish_address'])) {
$entry_fields['publish_address'] = $user['email'];
}
}
// ensure we are using ids instead of nicknames
if (is_object($section)) {
$entry_fields['anchor'] = $section->get_reference();
}
// save in the database
if (!($entry_fields['id'] = Articles::post($entry_fields))) {
Logger::remember('agents/messages.php: ' . Logger::error_pop());
return NULL;
}
// debugging log
if (isset($context['debug_messages']) && $context['debug_messages'] == 'Y') {
$entry_fields['description'] = substr($entry_fields['description'], 0, 1024);
Logger::remember('agents/messages.php: Messages::submit_page() as an article', $entry_fields, 'debug');
}
// increment the post counter of the surfer
Users::increment_posts($user['id']);
// do whatever is necessary on page creation
if (isset($entry_fields['publish_date']) && $entry_fields['publish_date'] > NULL_DATE) {
Articles::finalize_publication($section, $entry_fields);
} else {
Articles::finalize_submission($section, $entry_fields);
}
// get the new item
$article = Anchors::get($anchor);
// if replies are allowed
if (!preg_match('/\\bno_reply\\b/i', $options)) {
// let the sender know about his post
if (isset($entry_fields['publish_date']) && $entry_fields['publish_date'] > NULL_DATE) {
$splash = i18n::s("The page received by e-mail has been successfully published. Please review it now to ensure that it reflects your mind.");
} else {
$splash = i18n::s("The page received by e-mail has been posted. Don't forget to read it online. Then click on the Publish command to make it publicly available.");
}
$message = '<p>' . $splash . '</p>' . '<p><a href="' . $context['url_to_home'] . $context['url_to_root'] . $article->get_url() . '">' . $article->get_title() . '</a></p>' . '<div>' . $article->get_teaser('basic') . '</div>' . '<p>' . i18n::c('Thank you for your contribution') . '</p>';
// enable threading
$headers = Mailer::set_thread($section);
// send a mail message
Mailer::notify(NULL, $post_sender, 'Re: ' . $post_subject, $message, $headers);
}
// reference to the new page
return 'article:' . $entry_fields['id'];
}
// job ends
return NULL;
}
示例5: Article
// convert dates from surfer time zone to UTC time zone
$_REQUEST['publish_date'] = Surfer::to_GMT($_REQUEST['publish_date']);
if (isset($_REQUEST['expiry_date']) && $_REQUEST['expiry_date'] > NULL_DATE) {
$_REQUEST['expiry_date'] = Surfer::to_GMT($_REQUEST['expiry_date']);
}
// update the database
if ($error = Articles::stamp($item['id'], $_REQUEST['publish_date'], isset($_REQUEST['expiry_date']) ? $_REQUEST['expiry_date'] : NULL_DATE)) {
Logger::error($error);
} else {
// reflect in memory what has been saved in database
$item['publish_date'] = $_REQUEST['publish_date'];
// send to watchers of this page, and to watchers upwards
$watching_context = new Article();
$watching_context->load_by_content($item, $anchor);
// do whatever is necessary on page publication
Articles::finalize_publication($watching_context, $item, $overlay, isset($_REQUEST['silent']) && $_REQUEST['silent'] == 'Y', isset($_REQUEST['notify_followers']) && $_REQUEST['notify_followers'] == 'Y');
// splash messages
$context['text'] .= '<p>' . i18n::s('The page has been successfully published.') . "</p>\n";
// list persons that have been notified
$context['text'] .= Mailer::build_recipients('article:' . $item['id']);
// clear the cache
Articles::clear($item);
// follow-up commands
$follow_up = i18n::s('Where do you want to go now?');
$menu = array();
$menu = array_merge($menu, array(Articles::get_permalink($item) => i18n::s('Back to main page')));
if (Surfer::is_associate()) {
$menu = array_merge($menu, array('articles/review.php' => i18n::s('Review queue')));
}
$follow_up .= Skin::build_list($menu, 'menu_bar');
$context['text'] .= Skin::build_block($follow_up, 'bottom');