diff options
Diffstat (limited to 'modules/news')
-rw-r--r-- | modules/news/categories/3rdIDnews.png | bin | 0 -> 50631 bytes | |||
-rw-r--r-- | modules/news/categories/marnemessenger.png | bin | 0 -> 20793 bytes | |||
-rw-r--r-- | modules/news/functions.php | 260 | ||||
-rw-r--r-- | modules/news/images/avatar.png | bin | 0 -> 6617 bytes | |||
-rw-r--r-- | modules/news/images/comment_arrow.png | bin | 0 -> 264 bytes | |||
-rw-r--r-- | modules/news/index.php | 44 | ||||
-rw-r--r-- | modules/news/style.css | 234 |
7 files changed, 538 insertions, 0 deletions
diff --git a/modules/news/categories/3rdIDnews.png b/modules/news/categories/3rdIDnews.png Binary files differnew file mode 100644 index 0000000..e31a7f5 --- /dev/null +++ b/modules/news/categories/3rdIDnews.png diff --git a/modules/news/categories/marnemessenger.png b/modules/news/categories/marnemessenger.png Binary files differnew file mode 100644 index 0000000..691129e --- /dev/null +++ b/modules/news/categories/marnemessenger.png 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 @@ +<?php +/** + * Bayonet Content Management System + * Copyright (C) 2008 Joseph Hunkeler & Evan O'Connell + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + /** + * 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(); + ?> + + <div id="comments"> + <table width="100%"> + <tr> + <td><h2>User Comments</h2></td> + <td style="text-align:right"><a href="#add">Add Yours</a></td> + </tr> + </table> + <ol class="comment_list parent"> + + <?php + foreach($data as $comment) + { + ?> + <li id="comment-<?php echo $comment['comment_id']; ?>"> + <div class="comment_wrap"> + + <div class="comment_author"> + <?php + if(!empty($comment['avatar'])){ + echo "<img src=\"{$comment['avatar']}\" height=\"80px\" />"; + }else{ + echo "<img src=\"modules/news/images/avatar.png\" />"; + } + ?> + <p> + <?php + if($comment['author_id']>0){ + echo "<a href=\"{$comment['author_id']}\">{$comment['author']}</a>"; + }else{ + echo "Guest"; + } + ?> + + <span><?php echo date('F jS', strtotime($comment['date'])); ?></span> + </p> + </div> + + <div class="single_comment"> + <img src="modules/news/images/comment_arrow.png" class="comment_arrow" /> + <p> <?php echo BBCode($comment['message']); ?></p> + + </div> + + </div> + </li> + + <?php + } + echo "</ol>"; + + 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(); ?> + + <div class="contentHeading"> + <table width="100%"> + <tr> + <td style="text-align:left;"><?php echo $news['title']; ?></td> + <td style="text-align:right;">Posted by: <?php echo $news['author']; ?></td> + </tr> + </table> + </div> + <div class="content"> + <img src="modules/news/categories/<?php echo $news['catimage']; ?>" alt="<?php echo $news['catname']; ?>" align="right" /> + <?php echo BBCode($news['message']); ?> + </div> + <div class="contentFooter"> + <table width="100%"> + <tr> + <td style="text-align:left;"> + View Comments: <a href="?load=news&id=<?php echo $news['news_id']; ?>"><?php echo $numComments;?> Comments</a> + </td> + <td style="text-align:right;">Posted on: <?php echo date('D M j, Y H:i a T', strtotime($news['date'])); ?></td> + </tr> + </table> + </div> + + <?php + CloseTable(); + echo "<br />"; + } +} + +/** 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}<br />Comment: {$comment}<br />"; + echo "Your comment has been processed. Please wait.<br />"; + } + + $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; + } + +?> +<a name="add"></a> +<h2>Add Your Comment</h2> + + <ol class="comment_form_wrap"> + <li> + <img src="modules/news/images/comment_arrow.png" class="textarea_arrow" /> + <div class="comment_author"> + <?php + if($avatar!=""){ + echo "<img src=\"{$avatar}\" height=\"80px\" />"; + }else{ + echo "<img src=\"modules/news/images/avatar.png\" />"; + } + ?> + <p> + <?php + if($logged_in){ + echo $username; + }else{ + echo "Guest"; + } + ?> + <br><span><?php echo date('F jS', time()); ?></span></p> + </div> + <form action="<?php $_SERVER['PHP_SELF']?>" method="POST" id="comment_form"> + <!-- <fieldset> --> + <textarea name="comment" id="comment" rows="8" cols="10" tabindex="1" class="input textarea required"></textarea> + <input type="hidden" value="<?php echo $cur_user_id; ?>" name="author" /> + <input type="submit" value="Add Comment" name="processed" /> + <!-- </fieldset> --> + </form> + </li> + </ol> + +<?php +} +?>
\ No newline at end of file diff --git a/modules/news/images/avatar.png b/modules/news/images/avatar.png Binary files differnew file mode 100644 index 0000000..825197a --- /dev/null +++ b/modules/news/images/avatar.png diff --git a/modules/news/images/comment_arrow.png b/modules/news/images/comment_arrow.png Binary files differnew file mode 100644 index 0000000..0962f4f --- /dev/null +++ b/modules/news/images/comment_arrow.png 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 @@ +<link rel="stylesheet" type="text/css" href="modules/news/style.css" media="screen"/> +<?php +/** + * Bayonet Content Management System + * Copyright (C) 2008 Joseph Hunkeler + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +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; +} |