From be4f83cd2a17a0ec05f5bce50c91befaafaa6e0c Mon Sep 17 00:00:00 2001 From: jhunkeler Date: Sun, 20 Dec 2009 18:38:08 +0000 Subject: Test. git-svn-id: http://svn.3rd-infantry-division.org/testing/branches/Bayonet CMS v2@376 c5b2fb0a-d05d-0410-98c8-828840a80ff6 --- modules/news/categories/3rdIDnews.png | Bin 0 -> 50631 bytes modules/news/categories/marnemessenger.png | Bin 0 -> 20793 bytes modules/news/functions.php | 260 +++++++++++++++++++++++++++++ modules/news/images/avatar.png | Bin 0 -> 6617 bytes modules/news/images/comment_arrow.png | Bin 0 -> 264 bytes modules/news/index.php | 44 +++++ modules/news/style.css | 234 ++++++++++++++++++++++++++ 7 files changed, 538 insertions(+) create mode 100644 modules/news/categories/3rdIDnews.png create mode 100644 modules/news/categories/marnemessenger.png create mode 100644 modules/news/functions.php create mode 100644 modules/news/images/avatar.png create mode 100644 modules/news/images/comment_arrow.png create mode 100644 modules/news/index.php create mode 100644 modules/news/style.css (limited to 'modules/news') diff --git a/modules/news/categories/3rdIDnews.png b/modules/news/categories/3rdIDnews.png new file mode 100644 index 0000000..e31a7f5 Binary files /dev/null and b/modules/news/categories/3rdIDnews.png differ diff --git a/modules/news/categories/marnemessenger.png b/modules/news/categories/marnemessenger.png new file mode 100644 index 0000000..691129e Binary files /dev/null and b/modules/news/categories/marnemessenger.png differ diff --git a/modules/news/functions.php b/modules/news/functions.php new file mode 100644 index 0000000..66c8b68 --- /dev/null +++ b/modules/news/functions.php @@ -0,0 +1,260 @@ +. + */ + + /** + * getNewsComments($id) + * Function getting an array of comments for posted news + * @param id - news_id cooresponding to `bayonet_news` + * @return - associative array of comments + */ +function getNewsComments($id){ + + global $db; + $result = $db->Query("SELECT c.comment_id, c.news_id, c.author_id, c.message, c.date, u.username AS author, u.avatar as avatar ". + "FROM `bayonet_news_comments` AS c ". + "LEFT OUTER JOIN `mybb_users` AS u ON u.uid = c.author_id ". + "WHERE c.news_id = '$id' ". + "ORDER BY date ASC"); + while(($row = $db->Fetch($result)) != false) + { + $comments[] = $row; + } + + $db->Free($result); + + return $comments; +} + + /** + * displayComments($data) + * Function that takes an array of comments and displays them in html + * @param data - associative array of comments from the database + */ +function displayComments($data){ + + date_default_timezone_set("America/New_York"); + OpenTable(); + ?> + +
+ + + + + +

User Comments

Add Yours
+
    + + +
  1. +
    + +
    + "; + }else{ + echo ""; + } + ?> +

    + 0){ + echo "{$comment['author']}"; + }else{ + echo "Guest"; + } + ?> + + +

    +
    + +
    + +

    + +
    + +
    +
  2. + + "; + + commentForm(); + + CloseTable(); +} + + /** + * getNumOfComments($id) + * Function that gets the number of comments a news post has + * @param id - news_id cooresponding to `bayonet_news` + */ +function getNumOfComments($id){ + + global $db; + $result = $db->Query("SELECT `comment_id` FROM `bayonet_news_comments` WHERE `news_id` = '$id'"); + + return $db->Rows($result);; +} + + /** + * getNumOfComments($id) + * Function that gets the desired news from the database and returns it as an array + * @param id - (optional) news_id cooresponding to `bayonet_news` + */ +function getNews($id = NULL){ + + global $db; + $query = "SELECT n.news_id, n.title, n.message, n.date, n.category_id, u.username AS author, c.name AS catname, c.image AS catimage ". + "FROM `bayonet_news` AS n ". + "INNER JOIN `bayonet_news_categories` AS c ON c.category_id = n.category_id ". + "LEFT OUTER JOIN `mybb_users` AS u ON u.uid = n.author_id "; + if(isset($id)){ + $query = $query."WHERE n.news_id = '$id' "; + }else{ + $query = $query."ORDER BY date DESC"; + if($limit !=NULL){ + $query = $query." LIMIT '$limit'"; + } + } + + $result = $db->Query($query); + while(($row = $db->Fetch($result)) != false) + { + $data[] = $row; + } + + $db->Free($result); + + return $data; +} + + /** + * displayNews($data) + * Function that takes an array of news and displays it as html + * @param data - associative array of news from the database + */ +function displayNews($data){ + + date_default_timezone_set("America/New_York"); + foreach($data as $news) + { + $numComments = getNumOfComments($news['news_id']); + + OpenTable(); ?> + +
    + + + + + +
    Posted by:
    +
    +
    + <?php echo $news['catname']; ?> + +
    + + + "; + } +} + +/** This was coded on Coda with a MacBook Pro **/ +function commentForm(){ + + global $db; + + if(isset($_POST['processed'])) + { + $comment = stripslashes($_POST['comment']); + $author_id = stripslashes($_POST['author']); + + echo "Author: {$author_id}
    Comment: {$comment}
    "; + echo "Your comment has been processed. Please wait.
    "; + } + + $cur_user_id = 0; //testing variable, until i get the login system working for this + + $logged_in = false; + $result = $db->Query("SELECT `username`, `avatar` FROM `mybb_users` WHERE `uid` = '$cur_user_id' LIMIT 1"); + while(($row = $db->Fetch($result)) != false) + { + $username = $row['username']; + $avatar = $row['avatar']; + $logged_in = true; + } + +?> + +

    Add Your Comment

    + +
      +
    1. + +
      + "; + }else{ + echo ""; + } + ?> +

      + +

      +
      +
      + + + + + +
      +
    2. +
    + + \ No newline at end of file diff --git a/modules/news/images/avatar.png b/modules/news/images/avatar.png new file mode 100644 index 0000000..825197a Binary files /dev/null and b/modules/news/images/avatar.png differ diff --git a/modules/news/images/comment_arrow.png b/modules/news/images/comment_arrow.png new file mode 100644 index 0000000..0962f4f Binary files /dev/null and b/modules/news/images/comment_arrow.png differ diff --git a/modules/news/index.php b/modules/news/index.php new file mode 100644 index 0000000..6aaec2d --- /dev/null +++ b/modules/news/index.php @@ -0,0 +1,44 @@ + +. + */ + +if(!defined("MODULE_FILE")) +{ + die('Access Denied.'); +} + +include 'modules/news/functions.php'; + +$logged_id = 2; + +if(isset($_GET['id'])) +{ + $news_id = $_GET['id']; + displayNews(getNews($news_id)); + displayComments(getNewsComments($news_id)); + return; +} +else +{ + displayNews(getNews()); + return; +} + + +?> \ No newline at end of file diff --git a/modules/news/style.css b/modules/news/style.css new file mode 100644 index 0000000..fe98982 --- /dev/null +++ b/modules/news/style.css @@ -0,0 +1,234 @@ + /********************************* + ** Comment Styles ** + *********************************/ + + div.comment_author a, div.comment_author a:visited { + font-size: 10px; + font-family: verdana; + color:#3666ba; + } + + div.comment_author a:hover, div.comment_author a:visited:hover { + font-size: 10px; + font-family: verdana; + color:#42423d; + } + +/* Comments */ +#comments { + background: #ededed; + padding: 25px 25px; + padding-top:0px; + border: 1px solid #dcdddd; + color: #42423d; +} +#comments a { + text-decoration: none; +} +#comments_wrap h3 { + font-size: 22px; + font-weight: normal; + margin: 0px; + padding-bottom: 20px; + margin-top: 10px; +} +#comments_wrap h3 a, #comments_wrap h3 a:hover { + color: #242323; + text-decoration: none; +} +#comments_wrap .get_avatar { + color: #a7a7a7; + font-size: 10px; + letter-spacing: -1px; + padding-top: 10px; +} +#comments ol.parent { + padding-bottom: 25px +} +#comments ol { + margin: 0px; + padding: 0px; + padding-left: 120px; +} +#comments ol li { + list-style: none; + padding: 0px; + margin: 10px 0px; + padding-top: 1px; +} +#comments span.comment-reply { + position: absolute; + bottom: 10px; + left: 20px; + font-size: 10px; + text-transform: uppercase; +} +#comments .comment_wrap { + position: relative; + background: #fff; + border: 1px solid #dcdddd; +} +#comments .single_comment { + padding: 20px; + padding-bottom: 60px; + color: #42423d; +} +#comments .comment_arrow { + position: absolute; + top: 20px; + left: -32px; +} +#comments .comment_author { + position: absolute; + left: -120px; + width: 100px; + color: #8d8d8d; + font-size: 10px; + line-height: 14px; +} +#comments .comment_author span { + display: block; +} +#comments .children { + padding-left: 0px; + border-left: 1px solid #ced0d0; +} +#comments .children li { + padding-left: 25px; + background: url(images/comment_li_bg.gif) no-repeat 0px 25px; +} +#comments .children .comment_wrap { + background: #f8f8f8; + border: 1px solid #d3d5d5; +} +#comments .children .comment_arrow { + display: none; +} +#comments .children .comment_author { + position: absolute; + left: auto; + right: 20px; + bottom: 10px; + width: 200px; + height: 40px; +} +#comments .children .comment_author p { + position: absolute; + right: 50px; + bottom: -20px; + text-align: right; +} +#comments .children .comment_author span { + display: block; +} +#comments .children .comment_author img { + width: 40px; + height: 40px; + float: right; +} +/* Comments Form */ +#respond { + position: relative; +} +#comments .comment_form_wrap { + position: relative; + padding-left: 120px; +} +#comments .parent .comment_form_wrap { + position: relative; + padding-left: 0px; +} +#comments .textarea_arrow { + position: absolute; + top: 25px; + left: 89px; +} +#comments .children .textarea_arrow, +#comments .parent .textarea_arrow { + display: none; +} +#comments .comment_form_wrap .comment_author { + position: absolute; + left: 0px; +} +#comments .children .comment_form_wrap { + position: relative; + padding-left: 0px; +} +#comments .children .comment_form_wrap .comment_author, +#comments .parent .comment_form_wrap .comment_author, +#comments .children .form_header, +#comments .parent .form_header { + display: none; +} +#comments .input { + width: 456px; + padding: 4px 5px; + background: #fff; + border: 1px solid #ced0d0; + color: #5f6565; + font-family: Tahoma, Arial, Helvetica, sans-serif; + display: block; + margin-bottom: 10px; +} +#comments .children .input { + width: 431px; +} +#comments .textarea { + padding-top: 20px; + padding-left: 20px; + width: 448px; + max-width: 468px; + height: 135px; + font-size: 12px; + color: #5f6565; + font-family: Tahoma, Arial, Helvetica, sans-serif; +} +#comments .children .textarea { + width: 423px; +} +#comments #submit_comment { + width: 12.0em; + height: 3.0em; + float: right; + margin-right: 7px; + margin-top: 10px; +} +#wpUserLinks_form #submit_comment { + width: 12.0em; + height: 3.0em; + margin-top: 10px; +} +#comments .inputerror { + border-color: #555; +} +#cancel-comment-reply { + float: left; + width: 120px; + height: 30px; + margin-top: 8px; +} +#cancel-comment-reply-link { + background: #fdfdfd url(images/button_bg.png) repeat-x 0 100%; + border: 1px solid #bbbbbb; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 9px; + text-transform: uppercase; + height: 22px; + width: 70px; + text-align: center; + padding-bottom: 2px; + letter-spacing: -0.05em; + cursor: pointer; + display: block; + line-height: 22px; +} +*+html #cancel-comment-reply-link { + height: 22px; + padding-bottom: 0px; +} +#cancel-comment-reply-link:hover { + color: #232323; + background: #eeeeee url(images/button_bg_hover.png) repeat-x 0 100%; + text-decoration: none; +} -- cgit