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 */
12 if(isset($_REQUEST["page"]))
13 $page = intval($_REQUEST["page"]);
17 if(isset($_REQUEST["tag"]))
18 $tags = htmlentities($_REQUEST["tag"]);
22 if(isset($_REQUEST["pic"]))
23 $pic = intval(htmlentities($_REQUEST["pic"]));
28 /* The basic layout */
32 <title><?php echo htmlspecialchars($title) ?></title>
33 <script src="<?php echo $webbase?>/d3.min.js"></script>
34 <link rel="stylesheet" type="text/css" href="<?php echo $webbase?>/normalize.css" />
35 <link rel="stylesheet" type="text/css" href="<?php echo $webbase?>/style.css" />
39 <div class="debug">test</div>
40 <h1><?php echo htmlspecialchars($title) ?></h1>
43 <span class="index"></span>
44 <button class="prev" type="button" disabled="disabled" onclick="left()"> prev </button>
45 <button class="next" type="button" onclick="right()">next </button>
46 <button class="all" type="submit" onclick="document.location.href='<?php echo $webbase?>'">all</button>
49 <div class="permalink"></div>
51 <div class="tagsearch">
52 <form method="get" action="">
53 Add tag: <input list="MyTags" id="MyTagsInput" type="text" value="" />
54 <datalist id="MyTags">
57 Current tags:<span id="currenttags"></span>
60 <div class="pics"> </div>
63 This gallery belongs to <?php echo htmlspecialchars($admin) ?>.
64 <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>
68 <script type="text/javascript" >
70 var pics = d3.select(".pics").append("ul");
72 var page=<?php echo $page ?>;
73 var N=<?php echo $N ?>;
74 var T="<?php echo $tags ?>";
75 var ID=<?php echo $pic ?>;
78 /* populate data list with tags*/
79 d3.json("<?php echo $webbase?>/getjson.php?S", function(json) {
80 d3.select("#MyTags").selectAll("option").data(json[1])
81 .enter().append("option").attr("value",function(d) {return d.name});
84 /* update form to point to new link */
85 d3.select("input").on("keyup", function(d) {
86 d3.select('form').attr("action","<?php echo $webbase?>/tag/"+document.getElementById('MyTagsInput').value.replace(" ","+"));
91 var mycurrenttags = T.split(",");
93 d3.select("#currenttags").select("button").remove();
94 d3.select("#currenttags").selectAll("button")
95 .data(mycurrenttags).enter()
96 .append("button").attr("type","button").text( function(d) {return d;} );
100 d3.select("#currenttags").select("button").remove();
101 d3.select("#currenttags").append("span").text( ' none');
104 function load_content(a) {
105 // d3.select(".debug").text("T,P,N = *"+T+"* *"+a+"* *"+N+"*");
107 update_page_index(a);
110 url = "<?php echo $webbase?>/getjson.php?ID="+ID;
112 url = "<?php echo $webbase?>/getjson.php?T="+T+"&P="+a;
114 url = "<?php echo $webbase?>/getjson.php?P="+a;
117 d3.json(url, function(json) {
119 pics.selectAll("li").remove();
122 /* if ID is set, just show one pictures, else create an array of pictures */
125 pics.selectAll("li").data(picdata)
126 .enter().append("li")
128 .attr("class","large")
129 .attr("src",function(d) {
130 s= d.base_uri+'/'+d.filename;
131 s = s.replace('file:\/\/<?php echo "".str_replace("/","\/",$dbprefix); ?>','<?php echo $webbase?>/Photos-small/');
137 pics.selectAll("li").data(picdata)
138 .enter().append("li")
140 .attr("href",function(d) {
141 s = '<?php echo $webbase; ?>';
145 s = s + '/page/' + a;
146 s = s + '/pic/' + d.id;
150 .attr("src",function(d) {
152 s= d.base_uri+'/'+d.filename;
153 s = s.replace('file:\/\/<?php echo "".str_replace("/","\/",$dbprefix); ?>','<?php echo $webbase?>/Photos-tiny/');
161 /* update permalink */
163 permalink="<?php echo $webbase ?>";
165 permalink += '/tag/' + T;
167 permalink += '/page/' + a;
170 d3.select(".permalink").html("Permalink: <a href=\""+permalink+"\">"+permalink+"</a>");
174 if (page>=2) page=page-1;
183 function checkbutton()
187 { d3.select("button.prev").attr("disabled","disabled");}
189 { d3.select("button.prev").attr("disabled", null);};
192 { d3.select("button.next").attr("disabled","disabled");}
194 { d3.select("button.next").attr("disabled",null);}
197 function update_page_index(mypage)
199 /* load number of pictures */
202 url = "<?php echo $webbase?>/getjson.php?C=1&T="+T;
204 url = "<?php echo $webbase?>/getjson.php?C=1";
206 d3.json(url, function(json) {
207 /* update index, show only page +-5 pages max */
208 n = Math.floor(json[0].total/N);
217 s+=" <a href=\"<?php echo $webbase?>";
220 s+="/page/1\">1</a>...";
226 for(i=start;i<=Math.min(n+1,mypage+5);i++)
232 s+=" <a href=\"<?php echo $webbase?>";
235 s+="/page/"+i+"\">"+i+"</a>";
241 s+="... <a href=\"<?php echo $webbase?>";
244 s+="/page/"+(n+1)+"\">"+(n+1)+"</a>";
248 s+=" <a href=\"<?php echo $webbase?>";
251 s+="/page/"+(n+1)+"\">"+(n+1)+"</a>";
254 d3.select(".index").html(s);