本文整理汇总了PHP中Articles::getBlogArticle方法的典型用法代码示例。如果您正苦于以下问题:PHP Articles::getBlogArticle方法的具体用法?PHP Articles::getBlogArticle怎么用?PHP Articles::getBlogArticle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Articles
的用法示例。
在下文中一共展示了Articles::getBlogArticle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticateItemHash
function authenticateItemHash($articleId, $password)
{
$articles = new Articles();
$article = $articles->getBlogArticle($articleId);
$passwordField = $article->getFieldObject("password_field");
return md5($passwordField->getValue()) == $password;
}
示例2: perform
function perform()
{
$this->_view = new BlogView($this->_blogInfo, VIEW_TRACKBACKS_TEMPLATE, SMARTY_VIEW_CACHE_CHECK, array("articleId" => $this->_articleId, "articleName" => $this->_articleName, "categoryName" => $this->_categoryName, "categoryId" => $this->_categoryId, "userId" => $this->_userId, "userName" => $this->_userName, "date" => $this->_date));
if ($this->_view->isCached()) {
return true;
}
// ---
// if we got a category name or a user name instead of a category
// id and a user id, then we have to look up first those
// and then proceed
// ---
// users...
if ($this->_userName) {
$users = new Users();
$user = $users->getUserInfoFromUsername($this->_userName);
if (!$user) {
$this->_setErrorView();
return false;
}
// if there was a user, use his/her id
$this->_userId = $user->getId();
}
// ...and categories...
if ($this->_categoryName) {
$categories = new ArticleCategories();
$category = $categories->getCategoryByName($this->_categoryName);
if (!$category) {
$this->_setErrorView();
return false;
}
// if there was a user, use his/her id
$this->_categoryId = $category->getId();
}
// fetch the article
$articles = new Articles();
if ($this->_articleId) {
$article = $articles->getBlogArticle($this->_articleId, $this->_blogInfo->getId(), false, $this->_date, $this->_categoryId, $this->_userId);
} else {
$article = $articles->getBlogArticleByTitle($this->_articleName, $this->_blogInfo->getId(), false, $this->_date, $this->_categoryId, $this->_userId);
}
// if the article id doesn't exist, cancel the whole thing...
if ($article == false) {
$this->_view = new ErrorView($this->_blogInfo);
$this->_view->setValue("message", "error_fetching_article");
$this->setCommonData();
return false;
}
$this->notifyEvent(EVENT_POST_LOADED, array("article" => &$article));
$this->notifyEvent(EVENT_TRACKBACKS_LOADED, array("article" => &$article));
// if everything's fine, we set up the article object for the view
$this->_view->setValue("post", $article);
$this->_view->setValue("trackbacks", $article->getTrackbacks());
$this->setCommonData();
// and return everything normal
return true;
}
示例3: perform
function perform()
{
// fetch the data and make some arrangements if needed
$this->_parentId = $this->_request->getValue("parentId");
$this->_articleId = $this->_request->getValue("articleId");
if ($this->_parentId < 0 || $this->_parentId == "") {
$this->_parentId = 0;
}
// check if comments are enabled
$blogSettings = $this->_blogInfo->getSettings();
if (!$blogSettings->getValue("comments_enabled")) {
$this->_view = new ErrorView($this->_blogInfo, "error_comments_not_enabled");
$this->setCommonData();
return false;
}
// fetch the article
$blogs = new Blogs();
$articles = new Articles();
$article = $articles->getBlogArticle($this->_articleId, $this->_blogInfo->getId());
// if there was a problem fetching the article, we give an error and quit
if ($article == false) {
$this->_view = new ErrorView($this->_blogInfo);
$this->_view->setValue("message", "error_fetching_article");
$this->setCommonData();
return false;
}
$this->_view = new BlogView($this->_blogInfo, "commentarticle", SMARTY_VIEW_CACHE_CHECK, array("articleId" => $this->_articleId, "parentId" => $this->_parentId));
// do nothing if the view was already cached
if ($this->_view->isCached()) {
return true;
}
// fetch the comments so far
$comments = new ArticleComments();
$postComments = $comments->getPostComments($article->getId());
if ($this->_parentId > 0) {
// get a pre-set string for the subject field, for those users interested
$comment = $comments->getPostComment($article->getId(), $this->_parentId);
// create the string
if ($comment) {
$replyString = $this->_locale->tr("reply_string") . $comment->getTopic();
$this->_view->setValue("comment", $comment);
}
}
// if everything's fine, we set up the article object for the view
$this->_view->setValue("post", $article);
$this->_view->setValue("parentId", $this->_parentId);
$this->_view->setValue("comments", $postComments);
$this->_view->setValue("postcomments", $postComments);
$this->_view->setValue("topic", $replyString);
$this->setCommonData();
// and return everything normal
return true;
}
示例4: ArticleComments
/**
* deletes comments
* @private
*/
function _deleteComments()
{
$comments = new ArticleComments();
$errorMessage = "";
$successMessage = "";
$totalOk = 0;
// if we can't even load the article, then forget it...
$articles = new Articles();
$article = $articles->getBlogArticle($this->_articleId, $this->_blogInfo->getId());
if (!$article) {
$this->_view = new AdminPostsListView($this->_blogInfo);
$this->_view->setErrorMessage($this->_locale->tr("error_fetching_post"));
$this->setCommonData();
return false;
}
// loop through the comments and remove them
foreach ($this->_commentIds as $commentId) {
// fetch the comment
$comment = $comments->getPostComment($this->_articleId, $commentId);
if (!$comment) {
$errorMessage .= $this->_locale->pr("error_deleting_comment2", $commentId);
} else {
// fire the pre-event
$this->notifyEvent(EVENT_PRE_COMMENT_DELETE, array("comment" => &$comment));
if (!$comments->deletePostComment($article->getId(), $commentId)) {
$errorMessage .= $this->_locale->pr("error_deleting_comment", $comment->getTopic()) . "<br/>";
} else {
$totalOk++;
if ($totalOk < 2) {
$successMessage .= $this->_locale->pr("comment_deleted_ok", $comment->getTopic()) . "<br/>";
} else {
$successMessage = $this->_locale->pr("comments_deleted_ok", $totalOk);
}
// fire the post-event
$this->notifyEvent(EVENT_POST_COMMENT_DELETE, array("comment" => &$comment));
}
}
}
// if everything fine, then display the same view again with the feedback
$this->_view = new AdminArticleCommentsListView($this->_blogInfo, array("article" => $article));
if ($successMessage != "") {
$this->_view->setSuccessMessage($successMessage);
// clear the cache
CacheControl::resetBlogCache($this->_blogInfo->getId());
}
if ($errorMessage != "") {
$this->_view->setErrorMessage($errorMessage);
}
$this->setCommonData();
// better to return true if everything fine
return true;
}
示例5: Articles
/**
* Carries out the specified action
*/
function _deletePosts()
{
// delete the post (it is not physically deleted but rather, we set
// the status field to 'DELETED'
$articles = new Articles();
$errorMessage = "";
$successMessage = "";
$totalOk = 0;
foreach ($this->_postIds as $postId) {
// get the post
$post = $articles->getBlogArticle($postId, $this->_blogInfo->getId());
if ($post) {
// fire the event
$this->notifyEvent(EVENT_PRE_POST_DELETE, array("article" => &$post));
//
// the next if-else branch allows a site administrator or the blog owner to remove
// anybody's articles. If not, then users can only remove their own articles
//
if ($this->_userInfo->isSiteAdmin() || $this->_blogInfo->getOwner() == $this->_userInfo->getId()) {
$result = $articles->deleteArticle($postId, $post->getUser(), $this->_blogInfo->getId(), false);
} else {
$result = $articles->deleteArticle($postId, $this->_userInfo->getId(), $this->_blogInfo->getId(), false);
}
if (!$result) {
$errorMessage .= $this->_locale->pr("error_deleting_article", $post->getTopic()) . "<br/>";
} else {
$totalOk++;
if ($totalOk < 2) {
$successMessage .= $this->_locale->pr("article_deleted_ok", $post->getTopic()) . "<br/>";
} else {
$successMessage = $this->_locale->pr("articles_deleted_ok", $totalOk);
}
// fire the post event
$this->notifyEvent(EVENT_POST_POST_DELETE, array("article" => &$post));
}
} else {
$errorMessage .= $this->_locale->pr("error_deleting_article2", $postId) . "<br/>";
}
}
// clean up the cache
CacheControl::resetBlogCache($this->_blogInfo->getId());
$this->_view = new AdminPostsListView($this->_blogInfo);
if ($errorMessage != "") {
$this->_view->setErrorMessage($errorMessage);
}
if ($successMessage != "") {
$this->_view->setSuccessMessage($successMessage);
}
$this->setCommonData();
return true;
}
示例6: Trackbacks
/**
* @private
*/
function _deleteTrackbacks()
{
$trackbacks = new Trackbacks();
$errorMessage = "";
$successMessage = "";
$totalOk = 0;
// check if we can really load the article or not...
$articles = new Articles();
$article = $articles->getBlogArticle($this->_articleId, $this->_blogInfo->getId());
if (!$article) {
$this->_view = new AdminPostsListView($this->_blogInfo);
$this->_view->setErrorMessage($this->_locale->tr("error_fetching_post"));
$this->setCommonData();
return false;
}
foreach ($this->_trackbackIds as $trackbackId) {
// fetch the trackback
$trackback = $trackbacks->getArticleTrackback($trackbackId, $this->_articleId);
if (!$trackback) {
$errorMessage .= $this->_locale->pr("error_deleting_trackback2", $trackbackId) . "<br/>";
} else {
// fire the pre-event
$this->notifyEvent(EVENT_PRE_TRACKBACK_DELETE, array("trackback" => &$trackback));
if (!$trackbacks->deletePostTrackback($trackbackId, $this->_articleId)) {
$errorMessage .= $this->_locale->pr("error_deleting_trackback", $trackback->getExcerpt()) . "<br/>";
} else {
$totalOk++;
if ($totalOk < 2) {
$successMessage .= $this->_locale->pr("trackback_deleted_ok", $trackback->getExcerpt());
} else {
$successMessage = $this->_locale->pr("trackbacks_deleted_ok", $totalOk);
}
// fire the post-event
$this->notifyEvent(EVENT_POST_TRACKBACK_DELETE, array("trackback" => &$trackback));
}
}
}
$this->_view = new AdminArticleTrackbacksListView($this->_blogInfo, array("article" => $article));
if ($successMessage != "") {
$this->_view->setSuccessMessage($successMessage);
// clear the cache
CacheControl::resetBlogCache($this->_blogInfo->getId());
}
if ($errorMessage != "") {
$this->_view->setErrorMessage($errorMessage);
}
$this->setCommonData();
// better to return true if everything fine
return true;
}
示例7: perform
/**
* Carries out the specified action
*/
function perform()
{
// get the validated parameters from the request
$articleId = $this->_request->getValue("articleId");
$articles = new Articles();
$article = $articles->getBlogArticle($articleId, $this->_blogInfo->getId());
if (!$article) {
$this->_view = new AdminPostsListView($this->_blogInfo);
$this->_view->setErrorMessage($this->_locale->tr("error_fetching_post"));
} else {
$this->_view = new AdminArticleTrackbacksListView($this->_blogInfo, array("article" => $article));
}
$this->setCommonData();
// better to return true if everything fine
return true;
}
示例8: ArticleComments
/**
* @private
* Returns true wether the comment whose status we're trying to change
* really belongs to this blog, just in case somebody's trying to mess
* around with that...
*/
function _checkComment($commentId, $articleId, $blogId)
{
$articleComments = new ArticleComments();
$articles = new Articles();
// fetch the comment
$this->_comment = $articleComments->getPostComment($articleId, $commentId);
if (!$this->_comment) {
return false;
}
// fetch the article
$this->_article = $articles->getBlogArticle($this->_comment->getArticleId(), $blogId);
if (!$this->_article) {
return false;
}
return true;
}
示例9: perform
/**
* Carries out the specified action
*/
function perform()
{
$this->_postId = $this->_request->getValue("postId");
// fetch the post itself
$posts = new Articles();
$post = $posts->getBlogArticle($this->_postId, $this->_blogInfo->getId());
if (!$post) {
$this->_view = new AdminPostsListView($this->_blogInfo);
$this->_view->setErrorMessage($this->_locale->tr("error_fetching_post"));
$this->setCommonData();
return false;
}
// generate the view
$this->_view = new AdminArticleReferrersView($this->_blogInfo, array("page" => $this->_page, "article" => $post));
$this->setCommonData();
return true;
}
示例10: perform
function perform()
{
// try to fetch the article
$articles = new Articles();
$article = $articles->getBlogArticle($this->_articleId, $this->_blogInfo->getId());
// if there was an error, show a message and quit
if (!$article) {
$this->_view = new AdminErrorView($this->_blogInfo);
$this->_view->setMessage($this->_locale->tr("error_fetching_article"));
$this->setCommonData();
return false;
}
// otherwise continue...
$this->_view = new PluginTemplatedView($this->_blogInfo, "print", "printview", false);
$this->_view->setValue("article", $article);
$this->setCommonData();
return true;
}
示例11: perform
/**
* Carries out the specified action
*/
function perform()
{
// fetch the post id that has already been validated
$this->_postId = $this->_request->getValue("postId");
// fetch the post from the database
$posts = new Articles();
$post = $posts->getBlogArticle($this->_postId, $this->_blogInfo->getId(), false);
// if the article does not exist, quit
if (!$post) {
$this->_view = new AdminPostsListView($this->_blogInfo);
$this->_view->setErrorMessage($this->_locale->tr("error_fetching_article"));
$this->setCommonData();
return false;
}
// throw the event
$this->notifyEvent(EVENT_POST_LOADED, array("article" => &$post, "from" => "editPost"));
// and create the view where we will edit the post
$this->_view = new AdminEditPostView($this->_blogInfo);
$this->_view->setArticle($post);
$this->_view->setUserInfo($this->_userInfo);
$this->setCommonData();
return true;
}
示例12: trackbackLog
}
if (!$config->getValue("trackback_server_enabled")) {
trackbackLog("Trackback server disabled by administrator");
$result = errorResponse("Trackback feature has been disabled by the administrator.");
die($result);
}
// for security, we will strip _ANY_ html tag from the tags
$tf = new TextFilter();
$blogName = $tf->filterAllHTML($params->getValue("blog_name"));
$excerpt = $tf->filterAllHTML($params->getValue("excerpt"));
$title = $tf->filterAllHTML($params->getValue("title"));
$articleId = $params->getValue("id");
$url = $tf->filterAllHTML($params->getValue("url"));
// try to see if the article is correct
$articles = new Articles();
$article = $articles->getBlogArticle($articleId);
if (!$article) {
trackbackLog("ERROR: Incorrect error identifier");
$result = errorResponse("Incorrect article identifier");
die($result);
}
// try to load the blog info too, as we are going to need it
$blogs = new Blogs();
$blogInfo = $blogs->getBlogInfo($article->getBlog());
// a bit of protection...
if (!$blogInfo) {
trackbackLog("ERROR: Article id " . $article->getId() . " points to blog " . $article->getBlog() . " that doesn't exist!");
$result = errorResponse("The blog does not exist");
die($result);
}
// if the blog is disabled, then we shoulnd't take trackbacks...
示例13: getBlogComments
/**
* returns the lastest $maxItems comments received in the blog
*
* @param blogId
* @param maxItems
* @return An array of ArticleComment objects
*/
function getBlogComments($blogId, $maxItems = 0, $articleStatus = POST_STATUS_PUBLISHED)
{
$prefix = $this->getPrefix();
$query = "SELECT c.id AS id, c.article_id AS article_id, c.topic AS topic, \n\t\t\t c.text AS text, c.date AS date, c.user_email AS user_email,\n\t\t\t\t\t\t\t c.user_url AS user_url, c.user_name AS user_name, c.parent_id AS parent_id,\n\t\t\t\t\t\t\t c.client_ip AS client_ip, c.send_notification AS send_notification,\n\t\t\t\t\t\t\t c.status AS status \n\t\t\t\t\t FROM {$prefix}articles_comments c, {$prefix}articles a\n\t\t\t WHERE a.blog_id = '" . Db::qstr($blogId) . "' AND a.id = c.article_id\n\t\t\t\t\t AND a.status = {$articleStatus} \n\t\t\t\t\t ORDER BY date DESC";
if ($maxItems > 0) {
$query .= " LIMIT 0, {$maxItems}";
}
$result = $this->Execute($query);
if (!$result) {
return false;
}
if ($result->RowCount() == 0) {
return array();
}
$comments = array();
$articles = new Articles();
while ($row = $result->FetchRow()) {
// load the article to which this comment belongs
$comment = $this->_fillCommentInformation($row);
$article = $articles->getBlogArticle($comment->getArticleId(), $blogId);
$comment->setArticle($article);
// and store everything in the array
$comments[] = $comment;
}
$result->Close();
return $comments;
}
示例14: getArticle
/**
* returns the Article object to which this one trackback points
*
* @return An Article object
*/
function getArticle()
{
// if we haven't loaded the article yet
if ($this->_article == null) {
include_once PLOG_CLASS_PATH . "class/dao/articles.class.php";
// load the article and return it
$articles = new Articles();
$this->_article = $articles->getBlogArticle($this->_articleId);
}
return $this->_article;
}
示例15: notifyUsers
/**
* Notifies all the users of new comments in a post
*
* @param postId The post we want to check if there are notifications
* @param blogId Just in case, the blog to which that post belongs.
*/
function notifyUsers($postId, $blogInfo, $message = null)
{
$blogId = $blogInfo->getId();
$artNotifs = $this->getArticleNotifications($postId, $blogId);
// default message.
// NOTE: Should this be translatable???
if ($message == null) {
$message = "There has been actitivity in the article with id " . $postId;
}
if (empty($artNotifs)) {
return;
}
$articles = new Articles();
$article = $articles->getBlogArticle($postId, $blogId);
// get the correct character set
$blogLocale =& $blogInfo->getLocale();
$charset = $blogLocale->getCharset();
$users = new Users();
foreach ($artNotifs as $notif) {
$userInfo = $users->getUserInfoFromId($notif->getUserId());
$message = $this->renderMessageTemplate($article, $blogInfo);
$this->notifyUser($notif, $userInfo, "pLog Notification", $message, $charset);
}
}