本文整理汇总了PHP中Articles::getBlogArticleByTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP Articles::getBlogArticleByTitle方法的具体用法?PHP Articles::getBlogArticleByTitle怎么用?PHP Articles::getBlogArticleByTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Articles
的用法示例。
在下文中一共展示了Articles::getBlogArticleByTitle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: articleIsSecret
function articleIsSecret($articleId)
{
$articles = new Articles();
if (is_numeric($articleId)) {
$article = $articles->getBlogArticle($articleId);
} else {
$article = $articles->getBlogArticleByTitle($articleId);
}
if (!$article) {
return false;
}
if (!$article->hasField("password_protected")) {
return false;
}
$isSecretField = $article->getFieldObject("password_protected");
return $isSecretField->getValue() == "1";
}