本文整理汇总了PHP中Articles::updateArticle方法的典型用法代码示例。如果您正苦于以下问题:PHP Articles::updateArticle方法的具体用法?PHP Articles::updateArticle怎么用?PHP Articles::updateArticle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Articles
的用法示例。
在下文中一共展示了Articles::updateArticle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Articles
/**
* @private
*
* returns the id of the post or 'false' if it couldn't be saved
*/
function _savePostData($article)
{
$status = $this->_postStatus;
$articles = new Articles();
$article->setFields($this->_getArticleCustomFields());
// notifiy about this event
$this->notifyEvent(EVENT_PRE_POST_ADD, array("article" => &$article));
// in case the post is already in the db
if ($this->_postId != "") {
$article->setId($this->_postId);
$artId = $this->_postId;
$postSavedOk = $articles->updateArticle($article);
if ($postSavedOk) {
$artId = $this->_postId;
} else {
$artId = false;
}
} else {
$artId = $articles->addArticle($article);
}
return $artId;
}
示例2: perform
function perform()
{
$status = POST_STATUS_DRAFT;
$articles = new Articles();
$postText = Textfilter::xhtmlize($this->_postText) . POST_EXTENDED_TEXT_MODIFIER . Textfilter::xhtmlize($this->_postExtendedText);
$article = new Article($this->_postTopic, $postText, $this->_postCategories, $this->_userInfo->getId(), $this->_blogInfo->getId(), $status, 0, array(), $this->_postSlug);
// set also the date before it's too late
$article->setDateObject($this->_postTimestamp);
$article->setCommentsEnabled($this->_commentsEnabled);
// prepare the custom fields
$fields = array();
if (is_array($this->_customFields)) {
foreach ($this->_customFields as $fieldId => $fieldValue) {
// 3 of those parameters are not really need when creating a new object... it's enough that
// we know the field definition id.
$customField = new CustomFieldValue($fieldId, $fieldValue, "", -1, "", $artId, $this->_blogInfo->getId(), -1);
array_push($fields, $customField);
}
$article->setFields($fields);
}
// in case the post is already in the db
if ($this->_postId != "") {
$article->setId($this->_postId);
$postSavedOk = $articles->updateArticle($article);
if ($postSavedOk) {
$artId = $this->_postId;
} else {
$artId = false;
}
} else {
$artId = $articles->addArticle($article);
}
// once we have built the object, we can add it to the database
$this->_view = new AdminXmlView($this->_blogInfo, "response");
$this->_view->setValue("method", "saveXmlDraft");
if ($artId) {
$this->_view->setValue("result", $artId);
} else {
$this->_view->setValue("result", "0");
}
return true;
}
示例3: perform
/**
* Carries out the specified action
*/
function perform()
{
// fetch the data
$this->_fetchCommonData();
$this->_postId = $this->_request->getValue("postId");
// fetch the old post
$articles = new Articles();
$post = $articles->getBlogArticle($this->_postId, $this->_blogInfo->getId());
// there must be something wrong if we can't fetch the post that we are trying to update...
if (!$post) {
$this->_view = new AdminPostsListView($this->_blogInfo);
$this->_view->setErrorMessage($this->_locale->tr("error_fetching_post"));
$this->setCommonData();
return false;
}
// if we got it, update some fields
$post->setTopic(stripslashes($this->_postTopic));
$postText = $this->_postText . POST_EXTENDED_TEXT_MODIFIER . $this->_postExtendedText;
$post->setText(stripslashes($postText));
$post->setCategoryIds($this->_postCategories);
$post->setStatus($this->_postStatus);
$post->setDateObject($this->_postTimestamp);
$post->setCommentsEnabled($this->_commentsEnabled);
$post->setPostSlug($this->_postSlug);
// prepare the custom fields
$fields = array();
if (is_array($this->_customFields)) {
foreach ($this->_customFields as $fieldId => $fieldValue) {
// 3 of those parameters are not really need when creating a new object... it's enough that
// we know the field definition id.
$customField = new CustomFieldValue($fieldId, $fieldValue, "", -1, "", $post->getId(), $this->_blogInfo->getId(), -1);
array_push($fields, $customField);
}
$post->setFields($fields);
}
// fire the pre event
$this->notifyEvent(EVENT_PRE_POST_UPDATE, array("article" => &$post));
// and finally save the post to the database
if (!$articles->updateArticle($post)) {
$this->_view = new AdminPostsListView($this->_blogInfo);
$this->_view->setErrorMessage($this->_locale->tr("error_updating_post"));
$this->setCommonData();
return false;
}
// clean up the cache
CacheControl::resetBlogCache($this->_blogInfo->getId());
// create the definitive view
$this->_view = new AdminPostsListView($this->_blogInfo);
// show a message saying that the post was updated
$message = $this->_locale->pr("post_updated_ok", $post->getTopic());
// check if there was a previous notification
$notifications = new ArticleNotifications();
$artNotification = $notifications->getUserArticleNotification($this->_postId, $this->_blogInfo->getId(), $this->_userInfo->getId());
// check if we have to add or remove a notification
if ($this->_sendNotification) {
if (!$artNotification) {
// if there wasn't one and now we want it, we have to add it
$notifications->addNotification($this->_postId, $this->_blogInfo->getId(), $this->_userInfo->getId());
$message .= " " . $this->_locale->tr("notification_added");
}
} else {
// if we don't want notifications, then we have to check if there is one since we
// should remove it
if ($artNotification) {
$notifications->deleteNotification($this->_postId, $this->_blogInfo->getId(), $this->_userInfo->getId());
$message .= " " . $this->_locale->tr("notification_removed");
}
}
// if the "send xmlrpc pings" checkbox was enabled, do something about it...
if ($post->getStatus() == POST_STATUS_PUBLISHED) {
// get the links from the text of the post
$postLinks = StringUtils::getLinks(stripslashes($post->getText()));
// get the real trackback links from trackbackUrls
$trackbackLinks = array();
foreach (explode("\r\n", $this->_trackbackUrls) as $host) {
trim($host);
if ($host != "" && $host != "\r\n" && $host != "\r" && $host != "\n") {
array_push($trackbackLinks, $host);
}
}
if ($this->_sendPings) {
$message .= "<br/><br/>" . $this->sendXmlRpcPings();
}
// and now check what to do with the trackbacks
if ($this->_sendTrackbacks) {
// if no links, there is nothing to do
if (count($postLinks) == 0 && count($trackbackLinks) == 0) {
$this->_view = new AdminPostsListView($this->_blogInfo);
$this->_view->setErrorMessage($this->_locale->tr("error_no_trackback_links_sent"));
} else {
$this->_view = new AdminTemplatedView($this->_blogInfo, "sendtrackbacks");
// get the links from the text of the post
$this->_view->setValue("post", $post);
$this->_view->setValue("postLinks", $postLinks);
$this->_view->setValue("trackbackLinks", $trackbackLinks);
}
}
//.........这里部分代码省略.........
示例4: updateArticle
/**
* funkce updatne clanek
* @param int $article_id
* @param object $data
* @return bool
*/
public function updateArticle($article_id, $data)
{
try {
return Articles::updateArticle($article_id, $data);
} catch (Exception $e) {
throw new RPCFault($e->getMessage(), $e->getCode(), $e->getCode());
}
}