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"></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>
58 <button class="next" type="button" onclick="cloud()">tag cloud</button>
61 <div class="nextprev"> <ul></ul></div>
63 <div class="pics"><ul></ul> </div>
66 This gallery belongs to <?php echo htmlspecialchars($admin) ?>.
67 <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>
71 <script type="text/javascript" >
73 var pics = d3.select(".pics").select("ul");
75 var page=<?php echo $page ?>;
76 var N=<?php echo $N ?>;
77 var T="<?php echo $tags ?>";
78 var ID=<?php echo $pic ?>;
81 /* populate data list with tags*/
82 d3.json("<?php echo $webbase?>/getjson.php?S", function(json) {
83 d3.select("#MyTags").selectAll("option").data(json)
84 .enter().append("option").attr("value",function(d) {return d.name});
87 /* update form to point to new link */
88 d3.select("input").on("keyup", function(d) {
89 d3.select('form').attr("action","<?php echo $webbase?>/tag/"+document.getElementById('MyTagsInput').value.replace(" ","+"));
94 var mycurrenttags = T.split(",");
96 d3.select("#currenttags").select("button").remove();
97 d3.select("#currenttags").selectAll("button")
98 .data(mycurrenttags).enter()
99 .append("button").attr("type","button").text( function(d) {return d;} );
103 d3.select("#currenttags").select("button").remove();
104 d3.select("#currenttags").append("span").text( ' none');
107 function load_content(a) {
108 // d3.select(".debug").text("T,P,N = *"+T+"* *"+a+"* *"+N+"*");
110 update_page_index(a);
113 url = "<?php echo $webbase?>/getjson.php?ID="+ID;
115 url = "<?php echo $webbase?>/getjson.php?T="+T+"&P="+a;
117 url = "<?php echo $webbase?>/getjson.php?P="+a;
120 d3.json(url, function(json) {
122 pics.selectAll("li").remove();
125 /* if ID is set, just show one pictures, else create an array of pictures */
128 var singlepicspace=pics.selectAll("li").data(picdata).enter().append("li").append("div").attr("class","singlepic");
129 singlepicspace.append("div").attr("class","left").append("img").attr("src","<?php echo $webbase?>/left.png");
130 singlepicspace.append("img")
131 .attr("class","large")
132 .attr("src",function(d) {
133 s= d.base_uri+'/'+d.filename;
134 s = s.replace('file:\/\/<?php echo "".str_replace("/","\/",$dbprefix); ?>','<?php echo $webbase?>/Photos-small/');
137 singlepicspace.append("div").attr("class","right").append("img").attr("src","<?php echo $webbase?>/right.png");
139 /* update thumbnails */
141 url2 = "<?php echo $webbase?>/getjson.php?NP=1&T="+T+"&ID="+ID;
143 url2 = "<?php echo $webbase?>/getjson.php?NP=1&ID="+ID;
148 d3.json(url2, function(json2) {
149 var thumbs= d3.select(".nextprev").select("ul").selectAll("li").data(json2);
150 thumbs.enter().append("li")
152 .attr("href",function(d) {
153 s = '<?php echo $webbase; ?>';
156 s = s + '/pic/' + d.id;
168 .attr("src",function(d) {
169 s= d.base_uri+'/'+d.filename;
170 s = s.replace('file:\/\/<?php echo "".str_replace("/","\/",$dbprefix); ?>','<?php echo $webbase?>/Photos-tiny/');
174 thumbs.exit().remove();
178 s = '<?php echo $webbase; ?>';
181 s = s + '/pic/' + IDprev;
182 d3.select(".left").on("click", function(d) { document.location.href=s })
186 s = '<?php echo $webbase; ?>';
189 s = s + '/pic/' + IDnext;
190 d3.select(".right").on("click", function(d) { document.location.href=s })
197 d3.select(".nextprev").select("ul").selectAll("li").remove();
198 pics.selectAll("li").data(picdata)
199 .enter().append("li")
201 .attr("href",function(d) {
202 s = '<?php echo $webbase; ?>';
206 s = s + '/page/' + a;
207 s = s + '/pic/' + d.id;
211 .attr("src",function(d) {
213 s= d.base_uri+'/'+d.filename;
214 s = s.replace('file:\/\/<?php echo "".str_replace("/","\/",$dbprefix); ?>','<?php echo $webbase?>/Photos-tiny/');
225 function update_permalink() {
226 /* update permalink */
228 permalink="<?php echo $webbase ?>";
231 permalink += '/tag/' + T;
233 permalink += '/page/' + a;
235 d3.select(".permalink").html("Permalink: <a href=\""+permalink+"\">"+permalink+"</a>");
239 if (page>=2) page=page-1;
250 url = "<?php echo $webbase?>/getjson.php?CLOUD=1";
252 pics.selectAll("li").remove();
254 var svgelement=pics.append("li")
255 .append("svg").attr("width",400).attr("height",400);
258 d3.json(url, function(json) {
259 svgelement.selectAll("text").data(json).enter().append("text")
260 .style("font-size", function(d){return (Math.log(d.count+1)/2.0)+"em"})
261 .text(function(d) { return d.name+" "; })
262 .on("mouseover", function(d){ d3.select(this).style("color","red")} )
263 .on("mouseout", function(d){ d3.select(this).style("color","white")} )
264 .on("click", function(d) { document.location.href='<?php echo $webbase?>/tag/'+d.name })
268 function checkbutton()
272 { d3.select("button.prev").attr("disabled","disabled");}
274 { d3.select("button.prev").attr("disabled", null);};
277 { d3.select("button.next").attr("disabled","disabled");}
279 { d3.select("button.next").attr("disabled",null);}
282 function update_page_index(mypage)
284 /* load number of pictures */
291 url = "<?php echo $webbase?>/getjson.php?C=1&T="+T+myID;
293 url = "<?php echo $webbase?>/getjson.php?C=1"+myID;
295 d3.json(url, function(json) {
296 /* update index, show only page +-5 pages max */
297 n = Math.floor(json[0].total/N);
306 s+=" <a href=\"<?php echo $webbase?>";
309 s+="/page/1\">1</a>...";
315 for(i=start;i<=Math.min(n+1,mypage+5);i++)
321 s+=" <a href=\"<?php echo $webbase?>";
324 s+="/page/"+i+"\">"+i+"</a>";
330 s+="... <a href=\"<?php echo $webbase?>";
333 s+="/page/"+(n+1)+"\">"+(n+1)+"</a>";
337 s+=" <a href=\"<?php echo $webbase?>";
340 s+="/page/"+(n+1)+"\">"+(n+1)+"</a>";
343 d3.select(".index").html(s);