本文整理汇总了PHP中Articles类的典型用法代码示例。如果您正苦于以下问题:PHP Articles类的具体用法?PHP Articles怎么用?PHP Articles使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Articles类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: perform
/**
* Loads the blog info and show it
*/
function perform()
{
$this->_blogId = $this->_request->getValue("blogId");
$this->_view = new SummaryCachedView("blogprofile", array("summary" => "BlogProfile", "blogId" => $this->_blogId, "locale" => $this->_locale->getLocaleCode()));
if ($this->_view->isCached()) {
// nothing to do, the view is cached
return true;
}
// load some information about the user
$blogs = new Blogs();
$blogInfo = $blogs->getBlogInfo($this->_blogId, true);
// if there was no blog or the status was incorrect, let's not show it!
if (!$blogInfo || $blogInfo->getStatus() != BLOG_STATUS_ACTIVE) {
$this->_view = new SummaryView("error");
$this->_view->setValue("message", $this->_locale->tr("error_incorrect_blog_id"));
return false;
}
// fetch the blog latest posts
$posts = array();
$articles = new Articles();
$t = new Timestamp();
$posts = $articles->getBlogArticles($blogInfo->getId(), -1, SUMMARY_DEFAULT_RECENT_BLOG_POSTS, 0, POST_STATUS_PUBLISHED, 0, $t->getTimestamp());
$this->_view->setValue("blog", $blogInfo);
$this->_view->setValue("blogposts", $posts);
$this->setCommonData();
return true;
}
示例2: indexAction
function indexAction()
{
$p = Tools::getValue('page', 1);
$q = Tools::getValue('q', '');
$AuthorID = Tools::getValue('author', null);
$articles = new Articles($this->context);
if ($AuthorID != null) {
$sql = "SELECT ID, Name FROM Authors WHERE ID = {$AuthorID};";
$author = GetMainConnection()->query($sql)->fetch();
if (empty($author['ID'])) {
return AddAlertMessage('danger', 'Такого автора не существует.', '/');
}
$AuthorName = $author['Name'];
$total = ceil($articles->getArticles($p, 'AuthorID = ' . $AuthorID, true) / ARTICLES_PER_PAGE);
$articles = $total > 0 ? $articles->getArticles($p, 'AuthorID = ' . $AuthorID) : null;
} else {
$AuthorName = '';
$AddWhere = empty($q) ? '' : '(Name LIKE "%' . $q . '%" OR Description LIKE "%' . $q . '%")';
$total = ceil($articles->getArticles($p, $AddWhere, true) / ARTICLES_PER_PAGE);
$articles = $total > 0 ? $articles->getArticles($p, $AddWhere) : null;
}
$this->view->setVars(array('q' => $q, 'AuthorName' => $AuthorName, 'articles' => $articles, 'pagination' => array('total_pages' => $total, 'current' => $p)));
$this->view->breadcrumbs = array(array('url' => '/search', 'title' => 'Поиск'));
$this->view->generate();
}
示例3: perform
/**
* Performs the action.
*/
function perform()
{
// fetch the articles for the given blog
$articles = new Articles();
$blogSettings = $this->_blogInfo->getSettings();
$localeCode = $blogSettings->getValue("locale");
// fetch the default profile as chosen by the administrator
$defaultProfile = $this->_config->getValue("default_rss_profile");
if ($defaultProfile == "" || $defaultProfile == null) {
$defaultProfile = DEFAULT_PROFILE;
}
// fetch the profile
// if the profile specified by the user is not valid, then we will
// use the default profile as configured
$profile = $this->_request->getValue("profile");
if ($profile == "") {
$profile = $defaultProfile;
}
// fetch the category, or set it to '0' otherwise, which will mean
// fetch all the most recent posts from any category
$categoryId = $this->_request->getValue("categoryId");
if (!is_numeric($categoryId)) {
$categoryId = 0;
}
// check if the template is available
$this->_view = new RssView($this->_blogInfo, $profile, array("profile" => $profile, "categoryId" => $categoryId));
// do nothing if the view was already cached
if ($this->_view->isCached()) {
return true;
}
// create an instance of a locale object
$locale = Locales::getLocale($localeCode);
// fetch the posts, though we are going to fetch the same amount in both branches
$amount = $blogSettings->getValue("recent_posts_max", 15);
$t = new Timestamp();
if ($blogSettings->getValue('show_future_posts_in_calendar')) {
$blogArticles = $articles->getBlogArticles($this->_blogInfo->getId(), -1, $amount, $categoryId, POST_STATUS_PUBLISHED, 0);
} else {
$today = $t->getTimestamp();
$blogArticles = $articles->getBlogArticles($this->_blogInfo->getId(), -1, $amount, $categoryId, POST_STATUS_PUBLISHED, 0, $today);
}
$pm =& PluginManager::getPluginManager();
$pm->setBlogInfo($this->_blogInfo);
$pm->setUserInfo($this->_userInfo);
$result = $pm->notifyEvent(EVENT_POSTS_LOADED, array('articles' => &$blogArticles));
$articles = array();
foreach ($blogArticles as $article) {
$postText = $article->getIntroText();
$postExtendedText = $article->getExtendedText();
$pm->notifyEvent(EVENT_TEXT_FILTER, array("text" => &$postText));
$pm->notifyEvent(EVENT_TEXT_FILTER, array("text" => &$postExtendedText));
$article->setIntroText($postText);
$article->setExtendedText($postExtendedText);
array_push($articles, $article);
}
$this->_view->setValue("locale", $locale);
$this->_view->setValue("posts", $articles);
$this->setCommonData();
return true;
}
示例4: cleanupPosts
/**
* cleans up posts. Returns true if successful or false otherwise
*/
function cleanupPosts()
{
$articles = new Articles();
$articles->purgePosts();
$this->_message = $this->_locale->tr("posts_purged_ok");
return true;
}
示例5: authenticateItemHash
function authenticateItemHash($articleId, $password)
{
$articles = new Articles();
$article = $articles->getBlogArticle($articleId);
$passwordField = $article->getFieldObject("password_field");
return md5($passwordField->getValue()) == $password;
}
示例6: indexAction
function indexAction($id = null)
{
$p = Tools::getValue('page', 1);
if (!empty($id)) {
$sql = "select ID, Name, MetaKeywords, MetaRobots, Description from ArticleCategories where (ID = {$id}) and (IsDeleted = 0);";
$category = GetMainConnection()->query($sql)->fetch();
if (empty($category['ID'])) {
return AddAlertMessage('danger', 'Категории статей не существует.', '/');
}
$CategoryName = $category['Name'];
$sql = "SELECT count(*) as RecordCount " . "FROM Articles a " . "WHERE a.CategoryID = {$id} " . "AND a.isActive = 1 " . "AND a.IsDeleted = 0";
$rec = GetMainConnection()->query($sql)->fetch();
$total = ceil($rec['RecordCount'] / ARTICLES_PER_PAGE);
$sql = "SELECT a.ID, a.CategoryID, a.Name, a.ShortDescription, a.count_likes, a.CountComments, MainImageExt " . "FROM Articles a " . "WHERE a.CategoryID = {$id} " . "AND a.isActive = 1 " . "AND a.IsDeleted = 0 " . "ORDER BY a.CreateDate DESC, a.ID DESC " . "LIMIT " . ($p > 0 ? $p - 1 : 0) * ARTICLES_PER_PAGE . ", " . ARTICLES_PER_PAGE;
$articles = GetMainConnection()->query($sql)->fetchAll();
} else {
$category = null;
$CategoryName = 'Все статьи';
$article = new Articles($this->context);
$total = ceil($article->getArticles($p, null, true) / ARTICLES_PER_PAGE);
$articles = $article->getArticles($p);
}
$this->view->setVars(array('CategoryName' => $CategoryName, 'articles' => $articles, 'pagination' => array('total_pages' => $total, 'current' => $p)));
$this->view->breadcrumbs = array(array('url' => '/category', 'title' => 'Все статьи'));
if (isset($category)) {
$this->view->breadcrumbs[] = array('url' => '/articles/c-' . $id, 'title' => $CategoryName);
$this->view->meta = array('meta_title' => $CategoryName, 'meta_description' => $category['Description'], 'meta_keywords' => $category['MetaKeywords']);
} else {
$this->view->meta = array('meta_title' => $CategoryName, 'meta_description' => $CategoryName, 'meta_keywords' => $CategoryName);
}
$this->view->generate();
}
示例7: getTopReadPosts
/**
* Returns the top read posts object of current blog
*/
function getTopReadPosts($maxPosts = 0, $based = 'BLOG')
{
$articles = new Articles();
$blogId = $this->blogInfo->getId();
if ($based == 'BLOG') {
$query = "SELECT * FROM " . $this->prefix . "articles";
$query .= " WHERE blog_id = " . $blogId . " AND status = 1";
$query .= " ORDER BY num_reads DESC";
} elseif ($based == 'SITE') {
$query = "SELECT * FROM " . $this->prefix . "articles";
$query .= " WHERE status = 1";
$query .= " ORDER BY num_reads DESC";
} else {
return false;
}
if ($maxPosts > 0) {
$query .= " LIMIT " . $maxPosts;
} else {
$query .= " LIMIT " . $this->maxPosts;
}
$result = $articles->_db->Execute($query);
if (!$result) {
return false;
}
$topreadposts = array();
while ($row = $result->FetchRow()) {
$article = $articles->_fillArticleInformation($row);
array_push($topreadposts, $article);
}
return $topreadposts;
}
示例8: actionIndex
public function actionIndex()
{
$Articles = new Articles();
$list = $Articles->getList();
echo "<pre>";
print_r($list);
die;
}
示例9: parse
function parse($config, $db)
{
$folder = $config["dir"] . $config["scopus_dir"];
if ($config["test"] === true) {
$folder = $config["test_dir"] . $config["scopus_dir"];
}
// Hard set PHP config, used for CSV file line endings
ini_set("auto_detect_line_endings", true);
$scanned_directory = array_diff(scandir($folder), array('..', '.'));
if (!isset($scanned_directory)) {
echo "Warning: no files found in: " . $folder . '<br/>';
return;
}
$articles = array();
foreach ($scanned_directory as $file) {
// Open the file
if (($handle = @fopen($folder . "/" . $file, "r")) === false) {
echo "Warning: file not found at: " . $folder . "/" . $file;
return;
}
while ($line = fgets($handle)) {
// Split csv
$line = str_getcsv($line);
// Check if this is the first line
if ($line[1] === 'Title') {
continue;
}
// Title
$title = $line[1];
// Abstract
$abstract = $line[15];
// Journal-Title
$journal_title = $line[3];
// Journal-ISO
$journal_iso = "";
// ISSN
$issn = "";
// DOI
$doi = "";
$pattern = '/[0-9\\.]+\\/.*/';
preg_match($pattern, $line[11], $match);
if (count($match) > 0) {
$doi = $match[0];
}
// Publication date
$day = "";
$month = "";
$year = $line[2];
array_push($articles, array("title" => $title, "abstract" => $abstract, "doi" => $doi, "journal_title" => $journal_title, "journal_iso" => $journal_iso, "journal_issn" => $issn, "day" => $day, "month" => $month, "year" => $year));
}
fclose($handle);
}
require_once "models/articles.php";
$article_model = new Articles();
foreach ($articles as $article) {
$article_model->insert($db, $article, 'scopus');
}
}
示例10: findArticles
function findArticles($select = null)
{
$t = new Articles();
if (is_string($select)) {
$select = $t->select()->where($select);
}
$select->setIntegrityCheck(false)->from('article')->where('article.journal = ?', $this->id);
return $t->fetchAll($select);
}
示例11: 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;
}
示例12: render
public function render($args = NULL)
{
parent::render($args);
$this->template->articles = $this->articles->order('created DESC')->limit($this->count);
$f = $this->template->getFile();
if (!isset($f)) {
$this->template->setFile(__DIR__ . "/Articles.latte");
}
$this->template->headline = $this->headline;
$this->template->render();
}
示例13: 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;
}
示例14: actionArticle
/**
* 文章详情
*/
public function actionArticle($aid)
{
$aid = (int) $aid;
$Articles = new Articles();
$Category = new Category();
$where = array('a.aid' => $aid);
$this->data = $Articles->select('c.*,a.*')->from('articles a')->join('articles_content c', 'a.aid=c.aid')->where($where)->getOne();
$this->data['content'] = stripslashes($this->data['content']);
$this->title = $this->data['title'];
$this->category = $Category->getOne('*', array('cid' => $this->data['cid']));
$this->cid = $this->data['cid'];
}
示例15: _deleteComments
/**
* 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;
}