diff options
author | jhunkeler <jhunkeler@c5b2fb0a-d05d-0410-98c8-828840a80ff6> | 2009-12-21 23:12:44 -0500 |
---|---|---|
committer | jhunkeler <jhunkeler@c5b2fb0a-d05d-0410-98c8-828840a80ff6> | 2009-12-21 23:12:44 -0500 |
commit | b06638761f326c7f53f157137b119008c2ff7b35 (patch) | |
tree | 89e3487179ff24cd55debdb0819ef1bee1c058f9 /admin/newsreel | |
parent | 75dddd70a7f004601e0ad4aff214d94be793cd4b (diff) | |
download | bayonetcms-b06638761f326c7f53f157137b119008c2ff7b35.tar.gz |
(OC) newsreel admin is working smoothly now
git-svn-id: http://svn.3rd-infantry-division.org/testing/branches/Bayonet CMS v2@391 c5b2fb0a-d05d-0410-98c8-828840a80ff6
Diffstat (limited to 'admin/newsreel')
-rw-r--r-- | admin/newsreel/functions.php | 51 | ||||
-rw-r--r-- | admin/newsreel/index.php | 14 |
2 files changed, 63 insertions, 2 deletions
diff --git a/admin/newsreel/functions.php b/admin/newsreel/functions.php index b3c2d5f..583e719 100644 --- a/admin/newsreel/functions.php +++ b/admin/newsreel/functions.php @@ -69,7 +69,9 @@ $(document).ready(function(){ $result = $db->Query("SELECT `title`, `slide_id`, `src` FROM `bayonet_newsreel` WHERE `visible` = 1 ORDER BY `weight` ASC");
while(($row = $db->fetch($result))!= false){
- echo "<li id=\"recordsArray_{$row['slide_id']}\">{$row['title']}<br /><img src=\"../modules/newsreel/slides/{$row['src']}\" width=\"100px\" /></li>";
+ echo "<li id=\"recordsArray_{$row['slide_id']}\">";
+ PrintSlide($row);
+ echo "<br /><a href=\"?op=newsreel&disable={$row['slide_id']}\"><input type=\"button\" value=\"Disable\" /></a></li>";
}
?>
</ul>
@@ -78,6 +80,53 @@ $(document).ready(function(){ <?php
}
+ function EnableSlide($slide_id){
+
+ global $db;
+ $lastspot = GetLastPosition();
+ if($lastspot >= 6){
+ ReportError("There are already 6 active slides. You must disable one in order to enable another.");
+ PageRedirect(3,"?op=newsreel");
+ return;
+ }
+ $weight = $lastspot+1;
+ $db->Query("UPDATE `bayonet_newsreel` SET `visible` = 1, `weight` = '$weight' WHERE `slide_id` = '$slide_id' LIMIT 1");
+ PageRedirect(0,"?op=newsreel");
+ }
+
+ function DisableSlide($slide_id){
+
+ global $db;
+ echo "Disable: ".$slide_id;
+ $db->Query("UPDATE `bayonet_newsreel` SET `visible` = 0, `weight` = 0 WHERE `slide_id` = '$slide_id' LIMIT 1");
+ PageRedirect(0,"?op=newsreel");
+ }
+
+ function ListInactive(){
+
+ global $db;
+ $result = $db->query("SELECT `slide_id`, `title`, `src` FROM `bayonet_newsreel` WHERE `visible` = 0 ORDER BY `slide_id` DESC");
+ while(($row = $db->fetch($result))!= false){
+
+ echo PrintSlide($row);
+ echo "<br /><a href=\"?op=newsreel&enable={$row['slide_id']}\"><input type=\"button\" value=\"Enable\" /></a><br /><br />";
+ }
+ }
+
+ function PrintSlide($slide){
+ echo "{$slide['title']}";
+ if(file_exists("../modules/newsreel/slides/{$slide['src']}") && $slide['src'] != ""){
+ echo "<br /><img src=\"../modules/newsreel/slides/{$slide['src']}\" width=\"100px\" />";
+ }
+ }
+
+ function GetLastPosition(){
+
+ global $db;
+ $result = $db->query("SELECT `weight` FROM `bayonet_newsreel` ORDER BY `weight` DESC LIMIT 1");
+ $row = $db->Fetch($result);
+ return $row['weight'];
+ }
?>
\ No newline at end of file diff --git a/admin/newsreel/index.php b/admin/newsreel/index.php index cd3f0e1..a12eed2 100644 --- a/admin/newsreel/index.php +++ b/admin/newsreel/index.php @@ -27,6 +27,18 @@ include $basedir.'newsreel/functions.php'; <table class="panel" width="100%">
<tr>
<td class="panel"><?php EditOrder(); ?></td>
- <td class="panel-box" width="50%"></td>
+ <td class="panel-box" width="50%">
+ <?php
+ if(isset($_GET['enable'])){
+ $slide_id = $_GET['enable'];
+ EnableSlide($slide_id);
+ }else if(isset($_GET['disable'])){
+ $slide_id = $_GET['disable'];
+ DisableSlide($slide_id);
+ }else{
+ ListInactive();
+ }
+ ?>
+ </td>
</tr>
</table>
|