root/dev/mods/forum_post/settings.php @ 204

Revision 204, 4.9 KB (checked in by knifee, 15 years ago)

forum summery mod. adds admin option to view a e-o forum ready summery to campaign/contract page and related kills page.

Admin options allow colours/styles to be added to the summery, isk totals per class to be turned on/off and the ship class to placed at the start or end of each line.

Line 
1<?
2require_once( "common/includes/class.page.php" );
3require_once( "common/admin/admin_menu.php" );
4require_once("common/includes/class.ship.php");
5
6$colours =array("red" ,
7"blue" ,
8"pink" ,
9"brown" ,
10"black" ,
11"orange" ,
12"violet" ,
13"yellow" ,
14"green" ,
15"gold" ,
16"white" ,
17"purple" ,
18"limegreen" ,
19"maroon" ,
20"navy" ,
21"teal" ,
22"beige" );
23
24$styles = array("strikethrough"=>"s","underline"=>"u","bold"=>"b","italic"=>"i");
25if(isset($_POST['Reset']))
26{
27$config->setConfig('forum_post_colours',"");
28$config->setConfig('forum_post_styles',"");
29$confirm = "<strong>Settings Reset</strong><br/>";
30}
31
32
33if(isset($_POST['submit'])) //workings
34{
35        $sql = "select scl_id, scl_class
36                        from kb3_ship_classes
37                   where scl_class not in ( 'Drone', 'Unknown' )
38                  order by scl_class";
39
40        $qry = new DBQuery();
41        $qry->execute($sql) or die($qry->getErrorMsg());
42       
43        $forum_post_colours = array();
44        $forum_post_styles = array();
45        while ($row = $qry->getRow())
46        {
47                $value = str_replace(" ","",$row['scl_class']);
48                //echo $_POST[$value.'_colour']."<br>";
49                if($_POST[$value.'_colour'] != "None")
50                {
51                        $forum_post_colours[$value] = $_POST[$value.'_colour'];
52                }       
53                if($_POST[$value.'_style'] != "None")
54                {
55                        $forum_post_styles[$value] = $_POST[$value.'_style'];
56                }       
57       
58        }
59$config->setConfig('forum_post_colours',serialize($forum_post_colours) );
60$config->setConfig('forum_post_styles',serialize($forum_post_styles));
61$config->setConfig('forum_post_isk',$_POST['isk']);
62$config->setConfig('forum_post_order',$_POST['order']);
63
64$confirm = "<strong>Settings Saved</strong><br/>";
65} // end workings
66
67
68$page = new Page( "Settings - Forum Post" );
69$html .= $confirm;
70
71$set_colours = unserialize($config->getConfig('forum_post_colours'));   //load colour settings
72if(!is_array($set_colours)) { $set_colours = array(); }                                 // if the settings have been reset create an empty array so as not to brake the code later on
73$set_styles = unserialize($config->getConfig('forum_post_styles'));             //load style settings
74if(!is_array($set_styles)) { $set_styles = array(); }                                   // if the settings have been reset create an empty array so as not to brake the code later on
75$set_isk = $config->getConfig('forum_post_isk',$_POST['isk']);                  // load isk setting
76
77//print_r($set_styles);
78
79        $sql = "select scl_id, scl_class
80                        from kb3_ship_classes
81                   where scl_class not in ( 'Drone', 'Unknown' )
82                  order by scl_class";
83
84        $qry = new DBQuery();
85        $qry->execute($sql) or die($qry->getErrorMsg());
86       
87        $html .='<form action="" method="post"><table name="settings"><tr><td>Ship Class</td><td>Colour</td><td>Style</td></tr>';
88       
89        while ($row = $qry->getRow())
90        {
91        $html .="<tr>";
92        $html .= '<td>'.$row['scl_class'].'</td><td>';
93       
94        $class = str_replace(" ","",$row['scl_class']);
95        $html.='<select name="'.$class.'_colour">';
96       
97        if(array_key_exists($class,$set_colours)) //check to see if it is set.
98        {
99                $html .= '<option value="None">None</option>';
100        }        //colour has been set previously
101        else
102        {
103        $html .= '<option value="None" selected="selected">None</option>';
104        }
105        foreach($colours as $select)
106                {
107                        $html .='<option value="'.$select.'"';
108                                                        if($select == $set_colours[$class]) { $html .= ' selected="selected"'; } //select this option
109
110                        $html .='>'.$select.'</option>';
111                }
112        $html .="</select></td><td>";
113       
114       
115        $html.='<select name="'.str_replace(" ","",$row['scl_class']).'_style">';
116       
117        if(array_key_exists($class,$set_styles)) //check to see if it is set.
118        {
119                $html .= '<option value="None">None</option>';
120        }        //colour has been set previously
121        else
122        {
123        $html .= '<option value="None" selected="selected">None</option>';
124        }
125
126                foreach($styles as $select => $v)
127                {
128                        $html .='<option value="'.$v.'"';
129                                                        if($v == $set_styles[$class]) { $html .= ' selected="selected"'; } //select this option
130
131                        $html .='>'.$select.'</option>';
132                }
133       
134        $html .="</select></td></tr>";
135        }
136       
137        $html .='
138        <tr>
139        <hr/>
140    <td colspan="3"><hr/><input name="isk" type="checkbox" value="yes" ';
141        if($set_isk == "yes") { $html .= "checked"; }
142        $html .='> Include individual Isk Values?<br/><br/>
143       
144        Place ship class at start or end of each line?<br/>';
145        if($config->getConfig('forum_post_order') != "last"){
146       
147        $html .= '<input name="order" type="radio" value="first" checked="checked"/>Start<br/>
148        <input name="order" type="radio" value="last" />End<hr/>';
149        }
150        else
151        {
152        $html .= '<input name="order" type="radio" value="first" />Start<br/>
153        <input name="order" type="radio" value="last" checked="checked" />End<hr/>';
154        }
155        $html .= '</td></tr>';
156       
157        $html .='
158        <tr>
159    <td colspan="3"><input type="submit" value="submit" name="submit"> <input type="submit" value="Reset" name="Reset"></td>
160        </tr>
161  </table></form>';
162                                                     
163$page->setContent( $html );
164$page->addContext( $menubox->generate() );
165$page->generate();
166?>
Note: See TracBrowser for help on using the browser.