/** * 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; }
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(); }
/** * 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; }
/** * 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; }
function authenticateItemHash($articleId, $password) { $articles = new Articles(); $article = $articles->getBlogArticle($articleId); $passwordField = $article->getFieldObject("password_field"); return md5($passwordField->getValue()) == $password; }
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(); }
/** * 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; }
public function actionIndex() { $Articles = new Articles(); $list = $Articles->getList(); echo "<pre>"; print_r($list); die; }
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'); } }
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); }
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; }
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(); }
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; }
/** * 文章详情 */ 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']; }
/** * 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; }
/** * @param null $args */ public function render($args = NULL) { parent::render($args); // TODO: Change the autogenerated stub $articles = $this->articles->where('published < NOW()')->order('created DESC')->limit(10)->fetchPairs('created'); $venues = $this->venues->fetchVisible()->order('created DESC')->limit(10)->fetchPairs('created'); $competitions = $this->competitions->order('created DESC')->limit(10)->fetchPairs('created'); $output = $articles + $venues + $competitions; krsort($output); $this->template->items = $output; $this->template->setFile(__DIR__ . "/StreamControl.basic.latte"); $this->template->render(); }
/** * 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; }
/** * @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; }
function perform() { // fetch the validated data $this->_blogName = Textfilter::filterAllHTML($this->_request->getValue("blogName")); $this->_ownerId = $this->_request->getValue("blogOwner"); $this->_blogProperties = $this->_request->getValue("properties"); // check that the user really exists $users = new Users(); $userInfo = $users->getUserInfoFromId($this->_ownerId); if (!$userInfo) { $this->_view = new AdminCreateBlogView($this->_blogInfo); $this->_form->setFieldValidationStatus("blogOwner", false); $this->setCommonData(true); return false; } // now that we have validated the data, we can proceed to create the user, making // sure that it doesn't already exists $blogs = new Blogs(); $blog = new BlogInfo($this->_blogName, $this->_ownerId, "", ""); $blog->setProperties($this->_blogProperties); $this->notifyEvent(EVENT_PRE_BLOG_ADD, array("blog" => &$blog)); $newBlogId = $blogs->addBlog($blog); if (!$newBlogId) { $this->_view = new AdminCreateBlogView($this->_blogInfo); $this->_form->setFieldValidationStatus("blogName", false); $this->setCommonData(); return false; } // add a default category and a default post $articleCategories = new ArticleCategories(); $articleCategory = new ArticleCategory("General", "", $newBlogId, true); $catId = $articleCategories->addArticleCategory($articleCategory); $config =& Config::getConfig(); $locale =& Locales::getLocale($config->getValue("default_locale")); $articleTopic = $locale->tr("register_default_article_topic"); $articleText = $locale->tr("register_default_article_text"); $article = new Article($articleTopic, $articleText, array($catId), $this->_ownerId, $newBlogId, POST_STATUS_PUBLISHED, 0, array(), "welcome"); $t = new Timestamp(); $article->setDateObject($t); $articles = new Articles(); $articles->addArticle($article); // and inform everyone that everything went ok $this->notifyEvent(EVENT_POST_BLOG_ADD, array("blog" => &$blog)); $this->_view = new AdminSiteBlogsListView($this->_blogInfo); $this->_view->setSuccessMessage($this->_locale->pr("blog_added_ok", $blog->getBlog())); $this->setCommonData(); return true; }
/** * @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; }
/** * display content below main panel * * Everything is in a separate panel * * @param array the hosting record, if any * @return some HTML to be inserted into the resulting page */ function &get_trailer_text($host = NULL) { $text = ''; // display the following only if at least one comment has been attached to this page if (is_object($this->anchor) && !Comments::count_for_anchor($this->anchor->get_reference())) { return $text; } // ask the surfer if he has not answered yet, and if the page has not been locked $ask = TRUE; if (isset($_COOKIE['rating_' . $host['id']])) { $ask = FALSE; } elseif (isset($host['locked']) && $host['locked'] == 'Y') { $ask = FALSE; } // ask the surfer if ($ask) { $text = '<p style="line-height: 2.5em;">' . i18n::s('Has this page been useful to you?') . ' ' . Skin::build_link(Articles::get_url($host['id'], 'like'), i18n::s('Yes'), 'button') . ' ' . Skin::build_link(Articles::get_url($host['id'], 'dislike'), i18n::s('No'), 'button') . '</p>'; // or report on results } elseif ($host['rating_count']) { $text = '<p>' . Skin::build_rating_img((int) round($host['rating_sum'] / $host['rating_count'])) . ' ' . sprintf(i18n::ns('%d rating', '%d ratings', $host['rating_count']), $host['rating_count']) . '</p>'; } // add a title if ($text) { $text = Skin::build_box(i18n::s('Feed-back'), $text); } // done return $text; }
protected function renderContent() { $module = strtolower(Yii::app()->controller->module->id); $controller = strtolower(Yii::app()->controller->id); $action = strtolower(Yii::app()->controller->action->id); $currentAction = strtolower(Yii::app()->controller->id . '/' . Yii::app()->controller->action->id); //import model Yii::import('application.modules.article.models.ArticleCategory'); Yii::import('application.modules.article.models.ArticleMedia'); Yii::import('application.modules.article.models.Articles'); Yii::import('application.modules.article.models.ArticleTag'); $criteria = new CDbCriteria(); if ($this->hastag != null) { $criteria->with = array('tag_ONE' => array('alias' => 'a'), 'tag_ONE.tag_TO' => array('alias' => 'b')); $criteria->condition = 't.publish = :publish AND t.published_date <= curdate() AND b.body = :body'; $criteria->params = array(':publish' => 1, ':body' => $this->hastag); } else { $criteria->condition = 'publish = :publish AND published_date <= curdate()'; $criteria->params = array(':publish' => 1); } $criteria->order = 't.published_date DESC'; if ($this->category != null) { $criteria->compare('cat_id', $this->category); } $criteria->limit = 3; $model = Articles::model()->findAll($criteria); $this->render('article_main_news_recent', array('model' => $model)); }
/** * 获取评分目标信息 * @return unknown */ public function getTarget() { if ($this->type == 1) { $target = Articles::findFirst($this->target_id); } return $target; }
/** * 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; }
public function getContent() { //статическая часть контента echo '<div class="container"> <!-- Example row of columns --> <div class="row"> <div class="col-md-9"> <div class="articles">'; //динамическая часть // $result = DB::query("SELECT id, title, description, date, img_src FROM articles ORDER BY date DESC"); // $this->getMessageQueryErr($result, __FUNCTION__); $result = Articles::getArticles(0, 5); foreach ($result as $key => $value) { printf("<article class='media'>\n <h2 class='media-heading'>%s</h2>\n <p>%s</p>\n <div class='media-body'>\n <img class='img-responsive' src='%s' >\n <p>%s </p>\n <p><a class='btn btn-default' href='?option=view&id_article=%s' role='button'>View details »</a></p>\n </div>\n </article>", $value[title], $value[date], $value[img_src], $value[description], $value[id]); } echo "</div>"; echo "<button class='btn btn-primary btn-lg next'>Показать еще</button>"; /*while ($content = $result->fetch_object()) { printf("<article class='media'> <h2 class='media-heading'>%s</h2> <p>%s</p> <div class='media-body'> <img class='img-responsive' src='%s' > <p>%s </p> <p><a class='btn btn-default' href='?option=view&id_article=%s' role='button'>View details »</a></p> </div> </article>", $content->title,$content->date, $content->img_src, $content->description, $content->id); }*/ //статическая часть echo "</div>"; }
public static function getInstance() { if (is_null(self::$_instance)) { self::$_instance = new Articles(); } return self::$_instance; }
public function indexAction($id = null) { if (empty($id)) { return AddAlertMessage('danger', 'Статьи не существует.', '/'); } $vUserID = GetUserID(); $UnknownUserGUID = GetUnknownUserGUID(); $IsNotifyRecipientActive = false; if ($vUserID != 0) { $vAddWhere = "((UserID = {$vUserID}) or (UnknownUserGUID = '{$UnknownUserGUID}'))"; $UnknownUserGUIDForViewed = ""; $IsNotifyRecipientActive = Emails_IsNotifyRecipientActive(1, $id, $_SESSION['auth']['email']); } else { $vAddWhere = "(UnknownUserGUID = '{$UnknownUserGUID}')"; $UnknownUserGUIDForViewed = $UnknownUserGUID; } // Регистрация просмотра статьи пользователем $sql = "insert into ArticleViewed(ArticleID, UnknownUserGUID, UserID, LastView) " . "values({$id}, '{$UnknownUserGUIDForViewed}', {$vUserID}, '" . GetLocalDateTimeAsSQLStr() . "') " . "on duplicate key update " . "LastView = '" . GetLocalDateTimeAsSQLStr() . "';"; $this->db->exec($sql); $article = new Articles($this->context, 'ID = "' . $id . '"'); if (!isset($article->ID) || $article->ID == null) { return AddAlertMessage('danger', 'Статьи не существует.', '/'); } if ($article->IsActive != '1' && !Tools::getValue('preview')) { return AddAlertMessage('danger', 'Статья в черновике.', '/'); } $article->PhotoL = URL . DIR_DBIMAGES . 'articles/' . $id . '/l_1.' . $article->MainImageExt; $sql = "select Name from ArticleCategories where ID = " . (int) $article->CategoryID; $category = GetMainConnection()->query($sql)->fetch(); $vArticleLike = $this->db->query("select ID from ArticleLikes where (ArticleID = {$id}) and {$vAddWhere} limit 1;")->fetch(); $vAlreadyLiked = !empty($vArticleLike['ID']); $sql = "select CommentDate, UserID, UserName, Comment " . "from ArticleComments " . "where (ArticleID = {$id}) " . "and (IsDeleted = 0) " . "order by CommentDate desc;"; $ArticleComments = $this->db->query($sql)->fetchAll(); if (!isset($article->AuthorID) || $article->AuthorID == null) { $ArticleAuthor['Name'] = ''; $ArticleAuthor['ShortDescription'] = ''; $ArticleAuthor['Photo'] = ''; } else { $sql = 'SELECT Name, ShortDescription, Photo FROM Authors WHERE ID=' . (int) $article->AuthorID; $ArticleAuthor = $this->db->query($sql)->fetch(); } $this->view->setVars(array('id' => $id, 'article' => $article, 'similar' => $article->getSimilar($id), 'discused' => $article->getMostDiscussed(), 'alreadyLiked' => $vAlreadyLiked, 'ArticleAuthor' => $ArticleAuthor, 'ArticleDocuments' => $article->getArticleDocuments($id), 'ArticleComments' => $ArticleComments, 'ArticleCategory' => $category['Name'], 'IsNotifyRecipientActive' => $IsNotifyRecipientActive)); $this->view->breadcrumbs = array(array('url' => '/category', 'title' => 'Все статьи'), array('url' => '/articles/c-' . $article->CategoryID, 'title' => $category['Name']), array('url' => '/articles/c-' . $article->CategoryID . '/a-' . $article->ID, 'title' => $article->Name)); $this->view->meta = array('meta_title' => $article->Name, 'meta_description' => $article->ShortDescription, 'meta_keywords' => $article->MetaKeywords); SetTokenForPreventDoubleSubmit(); $this->view->generate(); }
/** * list articles * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // clear flows $text .= '<br style="clear: left" />'; // process all items in the list while ($item = SQL::fetch($result)) { // get the related overlay $overlay = Overlay::load($item, 'article:' . $item['id']); // the url to view this item $url = Articles::get_permalink($item); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // the hovering title if ($item['introduction'] && $context['skins_with_details'] == 'Y') { $hover = strip_tags(Codes::beautify_introduction($item['introduction'])); } else { $hover = i18n::s('View the page'); } // title is a link to the target article $title =& Skin::build_link($url, $title, 'basic', $hover); // use the thumbnail for this article if ($icon = trim($item['thumbnail_url'])) { // fix relative path if (!preg_match('/^(\\/|http:|https:|ftp:)/', $icon)) { $icon = $context['url_to_root'] . $icon; } // use parameter of the control panel for this one $options = ''; if (isset($context['classes_for_thumbnail_images'])) { $options = 'class="' . $context['classes_for_thumbnail_images'] . '" '; } // build the complete HTML element $icon = '<img src="' . $icon . '" alt="" title="' . encode_field($hover) . '" ' . $options . ' />'; // use default icon if nothing to display } else { $icon = MAP_IMG; } // use the image as a link to the target page $icon =& Skin::build_link($url, $icon, 'basic', $hover); // add a floating box $text .= Skin::build_box($title, $icon, 'floating'); } // clear flows $text .= '<br style="clear: left" />'; // end of processing SQL::free($result); return $text; }
public function run() { $criteria = new CDbCriteria(); $criteria->limit = 4; $criteria->order = 'RAND()'; $model = Articles::model()->findAll($criteria); $this->render('popularProducts', array('model' => $model)); }
public function loadModelByAlias($alias_url) { $model = Articles::model()->findByAttributes(array('alias_url' => $alias_url)); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }