root/dev/common/admin/admin_navmanager.php @ 237

Revision 237, 9.6 KB (checked in by ralle030583, 15 years ago)

some stuff for top navigation

Line 
1<?php
2@set_time_limit(0);
3@ini_set('display_errors',1);
4require_once('common/includes/class.parser.php');
5require_once('common/includes/class.kill.php');
6require_once('common/admin/admin_menu.php');
7
8$page = new Page();
9$page->setAdmin();
10$page->setTitle('Administration - Navigation - Top Navigation');
11
12if ($_GET['incPrio'])
13{
14    increasePriority($_GET['incPrio']);
15}
16elseif ($_GET['decPrio'])
17{
18    decreasePriority($_GET['decPrio']);
19}
20elseif ($_POST['new'])
21{
22    newPage($_POST['name'], $_POST['url'], $_POST['target']);
23}
24elseif ($_POST['name'])
25{
26    renamePage($_POST['id'], $_POST['name']);
27}
28elseif ($_POST['target'])
29{
30    changeTarget($_POST['id'], $_POST['target']);
31}
32elseif ($_POST['newUrl'])
33{
34    changeUrl($_POST['id'], $_POST['newUrl']);
35}
36elseif ($_POST['delete'])
37{
38    delPage($_POST['id']);
39}
40elseif ($_POST['syncStat'])
41{
42    repairStatLink();
43}
44elseif ($_POST['hide'])
45{
46        chgHideStatus($_POST['hide'],1);
47}
48elseif ($_POST['show'])
49{
50        chgHideStatus($_POST['show'],0);
51}
52
53$html .= "<div class=block-header2>Navigation for intern pages</div>";
54$qry = new DBQuery();
55$query = "select * from kb3_navigation WHERE intern = 1 AND KBSITE = '".KB_SITE."' AND descr <> 'About';";
56$result = $qry->execute($query);
57
58if ($result)
59{
60    $html .= "<table class=kb-table>";
61    $html .= "<tr><td width=100><u><b>Page</b></u></td><th colspan=2><u>Actions</u></th><th>Hidden</th></tr>";
62    $odd = false;
63    while ($row = $qry->getRow())
64    {
65        $html .= "<tr class=$class><td>".$row['descr']."</td><form action ='?a=admin_navmanager' method='POST'><td><input name='name' type='text' value='".$row['descr']."'></td><td><input type='hidden' name='id' value='".$row['ID']."'><input type='submit' value='rename'></td></form>";
66        if ($row['hidden']==0){
67                $html .= "<form action ='?a=admin_navmanager' method='POST'><td><input type='hidden' name='hide' value='".$row['ID']."'><input type='submit' value='hide'></td></form>";
68        }else{
69            $html .= "<form action ='?a=admin_navmanager' method='POST'><td><input type='hidden' name='show' value='".$row['ID']."'><input type='submit' value='show'></td></form>";
70        }
71        $html .= "</tr>";
72        if (!$odd)
73        {
74            $odd = true;
75            $class = 'kb-table-row-odd';
76        }
77        else
78        {
79            $odd = false;
80            $class = 'kb-table-row-even';
81        }
82    }
83    $html .= "<tr class=$class>";
84    if (!$odd)
85    {
86        $odd = true;
87        $class = 'kb-table-row-odd';
88    }
89    else
90    {
91        $odd = false;
92        $class = 'kb-table-row-even';
93    }
94    $html .= "<tr class=$class><form action ='?a=admin_navmanager' method='POST'><td  colspan=3>Statlink must have the name \"Stats\"<br> during repair</td><td><input type='hidden' name='syncStat' value='1'><center><input type='submit' value='Repair Stats'></center></td></form></tr>";
95    $html .= "</table>";
96}
97$html .= "<div class=block-header2>Navigation for extern pages</div>";
98$qry = new DBQuery();
99$query = "select * from kb3_navigation WHERE intern = 0 AND KBSITE = '".KB_SITE."';";
100$result = $qry->execute($query);
101
102if ($result)
103{
104    $html .= "<table class=kb-table>";
105    $html .= "<tr><td width=100><u><b>Page</b></u></td><th colspan=2>Rename</th><th colspan=2>URL</th><th colspan=2>Target</th></tr>";
106    $odd = false;
107    while ($row = $qry->getRow())
108    {
109        $html .= "<tr class=$class><td>".$row['descr']."</td>";
110        $html .= "<form action ='?a=admin_navmanager' method='POST'><td><input name='name' type='text' value='".$row['descr']."'></td><td><input type='hidden' name='id' value='".$row['ID']."'><input type='submit' value='rename'></td></form>";
111        $html .= "<form action ='?a=admin_navmanager' method='POST'><td><input name='newUrl' type='text' value='".$row['url']."'></td><td><input type='hidden' name='id' value='".$row['ID']."'><input type='submit' value='change'></td></form>";
112        $html .= "<form action ='?a=admin_navmanager' method='POST'><td><select name='target'>";
113        $html .= "<option value='_self' ";
114        if ($row['target'] == '_self')
115        {
116            $html .= "selected";
117        }
118        $html .= ">_self</option>";
119        $html .= "<option value='_blank' ";
120        if ($row['target'] == '_blank')
121        {
122            $html .= "selected";
123        }
124        $html .= ">_blank</option></select>";
125        $html .= "</td><td><input type='hidden' name='id' value='".$row['ID']."'><input type='submit' value='change'></td></form>";
126        $html .= "<form action ='?a=admin_navmanager' method='POST'><td><input name='delete' type='hidden' value='1'><input type='hidden' name='id' value='".$row['ID']."'><input type='submit' value='delete'></td></form>";
127        $html .= "</tr>";
128        if (!$odd)
129        {
130            $odd = true;
131            $class = 'kb-table-row-odd';
132        }
133        else
134        {
135            $odd = false;
136            $class = 'kb-table-row-even';
137        }
138    }
139    $html .= "<tr class=$class><td colspan=10><b><u>New Page:</b></u></td></tr>";
140    if (!$odd)
141    {
142        $odd = true;
143        $class = 'kb-table-row-odd';
144    }
145    else
146    {
147        $odd = false;
148        $class = 'kb-table-row-even';
149    }
150    $html .= "<tr class=$class><td>Description:</td>";
151    $html .= "<form action ='?a=admin_navmanager' method='POST'><td><input name='name' type='text'></td>";
152    $html .= "<td>URL:</td><td><input name='url' type='text' value='http://'></td><td>Target:</td>";
153    $html .= "<td><select name='target'><option value='_self'>_self</option><option value='_blank'>_blank</option></select>";
154    $html .= "</td><td><input type='hidden' name='new' value='1'><input type='submit' value='add'></td></form>";
155    $html .= "</tr>";
156    $html .= "</table>";
157}
158
159$html .= "<div class=block-header2>Order of the pages in Top Navigation Bar</div>";
160$qry = new DBQuery();
161$query = "select * from kb3_navigation WHERE nav_type = 'top' AND KBSITE = '".KB_SITE."' ORDER BY posnr ;";
162$result = $qry->execute($query);
163
164if ($result)
165{
166    $html .= "<table class=kb-table>";
167    $html .= "<tr><th><u>Nr</u></th><td><u><b>Page</b></u></td><th colspan=2><u>Actions</u></th></tr>";
168    $odd = false;
169    while ($row = $qry->getRow())
170    {
171        if (!$odd)
172        {
173            $odd = true;
174            $class = 'kb-table-row-odd';
175        }
176        else
177        {
178            $odd = false;
179            $class = 'kb-table-row-even';
180        }
181        $html .= "<tr class=$class><td align=right>".$row['posnr']."</td><td>".$row['descr']."</td>";
182        $html .= "<td><a href='?a=admin_navmanager&decPrio=".$row['ID']."'><b> move up </b></a></td>";
183        $html .= "<td><a href='?a=admin_navmanager&incPrio=".$row['ID']."'><b> down </b></a></td>";
184        $html .= "<tr>" ;
185    }
186    $html .= "</table>";
187}
188$page->addContext($menubox->generate());
189$page->setContent($html);
190$page->generate();
191
192function increasePriority($id)
193{
194    $qry = new DBQuery();
195    $query = "SELECT posnr FROM kb3_navigation WHERE ID = $id AND KBSITE = '".KB_SITE."'";
196    $qry->execute($query);
197    $row = $qry->getRow();
198    $next = $row['posnr'] + 1;
199
200    $qry = new DBQuery();
201    $query = "UPDATE kb3_navigation SET posnr = (posnr-1) WHERE nav_type = 'top' AND posnr = $next AND KBSITE = '".KB_SITE."'";
202    $qry->execute($query);
203
204    $qry = new DBQuery();
205    $query = "UPDATE kb3_navigation SET posnr = (posnr+1) WHERE ID = $id";
206    $qry->execute($query);
207}
208function decreasePriority($id)
209{
210    $qry = new DBQuery();
211    $query = "SELECT posnr FROM kb3_navigation WHERE ID = $id AND KBSITE = '".KB_SITE."'";
212    $qry->execute($query);
213    $row = $qry->getRow();
214    $prev = $row['posnr']-1;
215
216    $qry = new DBQuery();
217    $query = "UPDATE kb3_navigation SET posnr = (posnr+1) WHERE nav_type = 'top' AND posnr = $prev AND KBSITE = '".KB_SITE."'";
218    $qry->execute($query);
219
220    $qry = new DBQuery();
221    $query = "UPDATE kb3_navigation SET posnr = (posnr-1) WHERE ID = $id";
222    $qry->execute($query);
223}
224
225function renamePage($id, $name)
226{
227    $qry = new DBQuery();
228    $query = "UPDATE kb3_navigation SET descr ='$name' WHERE ID=$id";
229    $qry->execute($query);
230}
231
232function changeUrl($id, $url)
233{
234    $qry = new DBQuery();
235    $query = "UPDATE kb3_navigation SET url ='$url' WHERE ID=$id";
236    $qry->execute($query);
237}
238function changeTarget($id, $target)
239{
240    $qry = new DBQuery();
241    $query = "UPDATE kb3_navigation SET target ='$target' WHERE ID=$id";
242    $qry->execute($query);
243}
244function newPage($descr, $url, $target)
245{
246    $qry = new DBQuery();
247    $query = "SELECT max(posnr) as nr FROM kb3_navigation WHERE nav_type='top' AND KBSITE = '".KB_SITE."'";
248    $qry->execute($query);
249    $row = $qry->getRow();
250    $posnr = $row['nr'] + 1;
251    $query = "INSERT INTO kb3_navigation SET descr='$descr', intern=0, nav_type='top',url='$url', target ='$target', posnr=$posnr, page='ALL_PAGES', KBSITE = '".KB_SITE."'";
252    $qry->execute($query);
253}
254function delPage($id)
255{
256    $qry = new DBQuery();
257    $query = "DELETE FROM kb3_navigation WHERE ID=$id";
258    $qry->execute($query);
259}
260function chgHideStatus($id,$status)
261{
262    $qry = new DBQuery();
263    $query = "UPDATE kb3_navigation SET hidden ='$status' WHERE ID=$id";
264    $qry->execute($query);
265}
266function repairStatLink()
267{
268    if (CORP_ID)
269    {
270        $statlink = '?a=corp_detail&crp_id='.CORP_ID;
271    }elseif (ALLIANCE_ID)
272    {
273        $statlink = '?a=alliance_detail&all_id='.ALLIANCE_ID;
274    }
275    $qry = new DBQuery();
276    $query = "UPDATE kb3_navigation SET url ='$statlink' WHERE descr='Stats' AND KBSITE = '".KB_SITE."'";
277    $qry->execute($query);
278}
279?>
Note: See TracBrowser for help on using the browser.