本文整理汇总了PHP中Articles类的典型用法代码示例。如果您正苦于以下问题:PHP Articles类的具体用法?PHP Articles怎么用?PHP Articles使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Articles类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:30,代码来源:blogprofileaction.class.php
示例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();
}
开发者ID:AleksandrChukhray,项目名称:good_deals,代码行数:25,代码来源:SearchController.php
示例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;
}
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:63,代码来源:rssaction.class.php
示例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;
}
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:10,代码来源:admincleanupaction.class.php
示例5: authenticateItemHash
function authenticateItemHash($articleId, $password)
{
$articles = new Articles();
$article = $articles->getBlogArticle($articleId);
$passwordField = $article->getFieldObject("password_field");
return md5($passwordField->getValue()) == $password;
}
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:7,代码来源:secretitems.class.php
示例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();
}
开发者ID:AleksandrChukhray,项目名称:good_deals,代码行数:32,代码来源:CategoryController.php
示例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;
}
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:34,代码来源:plugintopreadposts.class.php
示例8: actionIndex
public function actionIndex()
{
$Articles = new Articles();
$list = $Articles->getList();
echo "<pre>";
print_r($list);
die;
}
开发者ID:mamtou,项目名称:wavephp,代码行数:8,代码来源:TestController.php
示例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');
}
}
开发者ID:AMCeScience,项目名称:article-miner,代码行数:58,代码来源:scopus_csv.php
示例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);
}
开发者ID:bersace,项目名称:strass,代码行数:9,代码来源:Journaux.php
示例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;
}
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:56,代码来源:viewarticletrackbacksaction.class.php
示例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();
}
开发者ID:soundake,项目名称:pd,代码行数:11,代码来源:ArticlesControl.php
示例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;
}
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:53,代码来源:commentaction.class.php
示例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'];
}
开发者ID:xpmozong,项目名称:wavephp2_demos,代码行数:15,代码来源:NewsController.php
示例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;
}
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:56,代码来源:admindeletecommentaction.class.php
示例16: _deletePosts
/**
* 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;
}
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:54,代码来源:admindeletepostaction.class.php
示例17: _deleteTrackbacks
/**
* @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;
}
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:53,代码来源:admindeletetrackbackaction.class.php
示例18: perform
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;
}
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:48,代码来源:adminaddblogaction.class.php
示例19: _checkComment
/**
* @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;
}
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:22,代码来源:adminmarkcommentaction.class.php
示例20: elseif
/**
* 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;
}
开发者ID:rair,项目名称:yacs,代码行数:36,代码来源:question.php
注:本文中的Articles类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论