Mercurial > hg > fapweb
annotate compos.inc.php @ 193:1e4f530c8310
Add link list of compos.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 10 Nov 2013 15:48:23 +0200 |
parents | 0980e705dea0 |
children | c30f5bcb71fd |
rev | line source |
---|---|
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
1 <? |
160 | 2 // |
3 // FAPWeb Simple Demoparty System | |
4 // Competitions page | |
5 // (C) Copyright 2012-2013 Tecnic Software productions (TNSP) | |
6 // | |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
7 echo stGetSetting("compoDescription"); |
0 | 8 |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
9 function stConvSwitchMode(&$str, &$mode, $newMode) |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
10 { |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
11 if ($newMode != $mode) |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
12 { |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
13 if ($mode != "") |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
14 $str .= "\n</".$mode.">\n"; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
15 |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
16 $mode = $newMode; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
17 |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
18 if ($mode != "") |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
19 $str .= "<".$mode.">\n"; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
20 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
21 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
22 |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
23 |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
24 function stConvertCompoDesc($desc) |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
25 { |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
26 global $stDescConversion; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
27 $str = ""; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
28 $mode = ""; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
29 |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
30 foreach (explode("\n", $desc) as $line) |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
31 { |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
32 if (preg_match("/^\s*\s*\*(.+)$/", $line, $m)) |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
33 { |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
34 stConvSwitchMode($str, $mode, "ol"); |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
35 $str .= "<li>".$m[1]."</li>\n"; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
36 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
37 else |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
38 if (preg_match("/^\s*-\s*(.+)$/", $line, $m)) |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
39 { |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
40 stConvSwitchMode($str, $mode, "ul"); |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
41 $str .= "<li>".$m[1]."</li>\n"; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
42 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
43 else |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
44 { |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
45 stConvSwitchMode($str, $mode, "p"); |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
46 $str .= $line; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
47 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
48 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
49 |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
50 stConvSwitchMode($str, $mode, ""); |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
51 |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
52 return $str; |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
53 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
54 |
193 | 55 |
56 $sql = "SELECT id,name FROM compos WHERE visible<>0 ORDER BY id ASC"; | |
57 | |
58 if (($res = stExecSQL($sql)) !== FALSE) | |
59 { | |
60 $list = array(); | |
61 foreach ($res as $item) | |
62 { | |
63 $list[] = "<a href=\"#compo".$item["id"]."\">".chentities($item["name"])."</a>"; | |
64 } | |
65 echo "<p>".join($list, " | ")."</p>"; | |
66 } | |
67 | |
68 | |
24
5bc8bd5c7ecc
Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
14
diff
changeset
|
69 $sql = "SELECT * FROM compos WHERE visible<>0 ORDER BY id ASC"; |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
70 |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
71 if (($res = stExecSQL($sql)) !== FALSE) |
0 | 72 { |
73 foreach ($res as $item) | |
74 { | |
75 echo | |
76 "<div id=\"compo".$item["id"]."\">\n". | |
77 "<h2>".chentities($item["name"])."</h2>\n". | |
78 stConvertCompoDesc($item["description"]). | |
79 "</div>\n"; | |
80 } | |
81 } | |
82 ?> |