added Bootstrap and converted some parts the pagination to it.
[photo-tags.git] / index.php
1 <?php
2 /* parse ini -file */
3 $iniarray=parse_ini_file("config.ini");
4 $webbase=$iniarray["webbase"];
5 $dbprefix=$iniarray["dbprefix"];
6 $admin=$iniarray["admin"];
7 $title=$iniarray["title"];
8 $N=$iniarray["pics_per_page"];
9 /* end parse ini-file */
10
11 /* parse flags */
12 if(isset($_REQUEST["page"]))
13   $page = intval($_REQUEST["page"]);
14 else
15   $page = 1;
16
17 if(isset($_REQUEST["tag"]))
18   $tags = htmlentities($_REQUEST["tag"]);
19 else
20   $tags = "";
21
22 if(isset($_REQUEST["pic"]))
23   $pic = intval(htmlentities($_REQUEST["pic"]));
24 else
25   $pic = -1;
26 /* end parse flags */
27
28 /* autoversioning of js and css files */
29 function autoversion($file)
30 {
31   /* changes the file name of e.g. css/style.css to css/style.<md5>.css/js
32    * this way the browser can cache the file and will reload it if the file changed
33    * needs to have .htaccess set up correctly to link back to css/style.css */
34
35   /* only use it for file that have an absolut path */
36   if(!file_exists(dirname($_SERVER['SCRIPT_FILENAME']). '/' . $file))
37     return $file;
38
39   $md5 = md5_file(dirname($_SERVER['SCRIPT_FILENAME']). '/' . $file);
40   return preg_replace('{\\.([^./]+)$}', ".$md5.\$1", $file);
41 }
42
43 /* The basic layout */
44 ?>
45 <!DOCTYPE html>
46 <html>
47 <head>
48 <title><?php echo htmlspecialchars($title) ?></title>
49 <script src = "<?php echo $webbase.autoversion("/js/d3.min.js")?>"></script>
50 <link rel="stylesheet" type="text/css" href="<?php echo $webbase.autoversion("/css/style.css")?>" />
51 <link rel="stylesheet" type="text/css" href="<?php echo $webbase.autoversion("/css/bootstrap.min.css")?>" />
52 </head>
53
54 <body>
55
56 <div class="debug"></div>
57 <h1><?php echo htmlspecialchars($title) ?></h1>
58
59 <nav>
60
61 <div class="pagination">
62   <ul>
63   </ul>
64 </div>
65
66 </nav>
67
68
69 <div class="permalink"></div>
70
71 <div class="tagsearch">
72 <form class="form-search" method="get" action="">
73  Search for tag: <input list="MyTags" id="MyTagsInput" type="text" value="" />
74   <datalist id="MyTags">
75   </datalist>
76 </form>
77   Current tags:<span id="currenttags"></span>
78   <button class="next" type="button" onclick="tagcloud()">tag cloud</button>
79   <button class="all"  onclick="document.location.href='<?php echo $webbase?>'">all</button>
80 </div>
81
82 <div class="nextprev"> <ul></ul></div>
83
84 <div class="pics"><ul></ul> </div>
85
86 <footer>
87   This gallery belongs to <?php echo htmlspecialchars($admin) ?>.
88   <div class="copyright"> photo-tags: copyright 2011 Arun Persaud arun@nubati.net, code available at <a href="http://source.nubati.net/projects/photo-tags">source.nubati.net/projects/photo-tags</a></div>
89 </footer>
90
91
92 <script src = "<?php echo $webbase.autoversion("/js/photo-tags.js")?>"></script>
93 <script src="http://code.jquery.com/jquery-latest.js"></script>
94 <script src="js/bootstrap.min.js"></script>
95 <script type="text/javascript" >
96
97 /*hand parameters over to javascript*/
98 var page=<?php echo $page ?>;
99 var N=<?php echo $N ?>;
100 var T="<?php echo $tags ?>";
101 var ID=<?php echo $pic ?>;
102 var count=0;
103 var dbprefix="<?php echo $dbprefix ?>".replace(/\//g,"\/");
104 var webbase = "<?php echo $webbase?>";
105
106 init();
107 load_content();
108 update_page_index();
109
110 </script>
111
112 </body>
113 </html>