aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/index/index.php2
-rw-r--r--modules/news/functions.php19
-rw-r--r--modules/news/index.php42
-rw-r--r--modules/rudi/includes/common.class.php4
-rw-r--r--modules/rudi/views/view.roster.php2
5 files changed, 59 insertions, 10 deletions
diff --git a/modules/index/index.php b/modules/index/index.php
index 9847cb5..54c8dbd 100644
--- a/modules/index/index.php
+++ b/modules/index/index.php
@@ -8,6 +8,8 @@
*
*/
+define('INDEX_MODULE', true);
+
$result = $db->Query("SELECT `dir_name` FROM `bayonet_modules` ORDER BY `weight` ASC");
$modules = $db->Fetch($result);
foreach($modules as $module)
diff --git a/modules/news/functions.php b/modules/news/functions.php
index 22952af..f3505df 100644
--- a/modules/news/functions.php
+++ b/modules/news/functions.php
@@ -127,7 +127,7 @@ function 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){
+function getNews($id = NULL, $limit = NULL, $index = 0){
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 ".
@@ -138,11 +138,12 @@ function getNews($id = NULL){
$query = $query."WHERE n.news_id = '$id' ";
}else{
$query = $query."ORDER BY date DESC";
- if($limit !=NULL){
- $query = $query." LIMIT '$limit'";
- }
+ if($index > 0)
+ $query = $query." LIMIT $index, $limit";
+ else if($limit !=NULL)
+ $query = $query." LIMIT $limit";
}
-
+ decho($query);
$result = $db->Query($query);
$data = $db->Fetch($result);
@@ -159,6 +160,12 @@ function displayNews($data){
date_default_timezone_set("America/New_York");
+ if(empty($data)){
+ ReportError("Sorry, we found no news using these parameters.");
+ echo "<br />";
+ }
+
+
foreach($data as $news)
{
$numComments = getNumOfComments($news['news_id']);
@@ -235,7 +242,7 @@ function commentForm(){
echo "Guest";
}
?>
- <br><span><?php echo date('F jS', time()); ?></span></p>
+ <br /><span><?php echo date('F jS', time()); ?></span></p>
</div>
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="POST" id="comment_form">
<!-- <fieldset> -->
diff --git a/modules/news/index.php b/modules/news/index.php
index 6aaec2d..1dfd98a 100644
--- a/modules/news/index.php
+++ b/modules/news/index.php
@@ -27,6 +27,20 @@ include 'modules/news/functions.php';
$logged_id = 2;
+if(!defined('INDEX_MODULE')){
+ $page_num = 1;
+ $page_num = $_GET['page']; //get variable for page number
+
+ $page_num --; //so the $index can be calculated easier while keeping [1,n] page numbers
+
+ $limit = 3; //number of items per page
+ $index = $page_num * $limit;
+
+}else{
+ //only do the limit
+ $limit = 3;
+}
+
if(isset($_GET['id']))
{
$news_id = $_GET['id'];
@@ -36,9 +50,35 @@ if(isset($_GET['id']))
}
else
{
- displayNews(getNews());
+ $news = getNews(null, $limit, $index);
+ displayNews($news);
+ OpenContent();
+ if(defined('INDEX_MODULE')){
+?>
+ <div style="float:right;">
+ <a href="?load=news">Read All</a>&nbsp;
+ </div>
+
+<?php
+ }else{
+ if($page_num > 0)
+ echo "&nbsp;<a href=\"?load=news&page={$page_num}\">More Recent News</a>";
+
+ decho("count: ".count($news));
+ if(count($news) == $limit){
+?>
+ <div style="float:right;">
+ <a href="?load=news&page=<?php echo ($page_num+2); ?>">Older News</a>&nbsp;
+ </div>
+<?php
+ }
+ }
+ echo "<div class=\"clear\"></div>";
+ CloseContent();
return;
}
+
+
?> \ No newline at end of file
diff --git a/modules/rudi/includes/common.class.php b/modules/rudi/includes/common.class.php
index 2e64e48..2112853 100644
--- a/modules/rudi/includes/common.class.php
+++ b/modules/rudi/includes/common.class.php
@@ -708,10 +708,10 @@ class RUDI_Common
* @param int $unit_id
*/
public function displayUnitsRec($unit_id){
- $result = $this->db->Query("SELECT * FROM `rudi_combat_units` WHERE `detachment` = '$unit_id'");
+ $result = $this->db->Query("SELECT * FROM `rudi_combat_units` WHERE `detachment` = '$unit_id' ORDER BY `weight`");
$row = $this->db->FetchObject($result,'UnitInfo');
foreach($row as $unit){
- echo "<tr><th colspan=\"5\">{$unit->name}</th></tr>";
+ echo "<tr><th colspan=\"5\">{$unit->name} : {$unit->callsign}</th></tr>";
$this->printRoster($unit->unit_id, $unit->leader_id);
$this->displayUnitsRec($unit->unit_id);
}
diff --git a/modules/rudi/views/view.roster.php b/modules/rudi/views/view.roster.php
index 01da5ea..c0ee92d 100644
--- a/modules/rudi/views/view.roster.php
+++ b/modules/rudi/views/view.roster.php
@@ -3,7 +3,7 @@
$result = $this->db->query("SELECT * FROM `rudi_combat_units` WHERE `detachment` = 0");
$row = $this->db->fetch($result);
foreach($row as $unit){
- echo "<tr><th colspan=\"5\">{$unit['name']}</th></tr>";
+ echo "<tr><th colspan=\"5\">{$unit['name']} : {$unit['callsign']}</th></tr>";
?>
<tr>
<!-- Table header -->