本文整理匯總了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";
}