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>
58 <button class="next" type="button" onclick="cloud()">tag cloud</button>
61 <div class="pics"> </div>
64 This gallery belongs to <?php echo htmlspecialchars($admin) ?>.
65 <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>
69 <script type="text/javascript" >
71 var pics = d3.select(".pics").append("ul");
73 var page=<?php echo $page ?>;
74 var N=<?php echo $N ?>;
75 var T="<?php echo $tags ?>";
76 var ID=<?php echo $pic ?>;
79 /* populate data list with tags*/
80 d3.json("<?php echo $webbase?>/getjson.php?S", function(json) {
81 d3.select("#MyTags").selectAll("option").data(json)
82 .enter().append("option").attr("value",function(d) {return d.name});
85 /* update form to point to new link */
86 d3.select("input").on("keyup", function(d) {
87 d3.select('form').attr("action","<?php echo $webbase?>/tag/"+document.getElementById('MyTagsInput').value.replace(" ","+"));
92 var mycurrenttags = T.split(",");
94 d3.select("#currenttags").select("button").remove();
95 d3.select("#currenttags").selectAll("button")
96 .data(mycurrenttags).enter()
97 .append("button").attr("type","button").text( function(d) {return d;} );
101 d3.select("#currenttags").select("button").remove();
102 d3.select("#currenttags").append("span").text( ' none');
105 function load_content(a) {
106 // d3.select(".debug").text("T,P,N = *"+T+"* *"+a+"* *"+N+"*");
108 update_page_index(a);
111 url = "<?php echo $webbase?>/getjson.php?ID="+ID;
113 url = "<?php echo $webbase?>/getjson.php?T="+T+"&P="+a;
115 url = "<?php echo $webbase?>/getjson.php?P="+a;
118 d3.json(url, function(json) {
120 pics.selectAll("li").remove();
123 /* if ID is set, just show one pictures, else create an array of pictures */
126 pics.selectAll("li").data(picdata)
127 .enter().append("li")
129 .attr("class","large")
130 .attr("src",function(d) {
131 s= d.base_uri+'/'+d.filename;
132 s = s.replace('file:\/\/<?php echo "".str_replace("/","\/",$dbprefix); ?>','<?php echo $webbase?>/Photos-small/');
138 pics.selectAll("li").data(picdata)
139 .enter().append("li")
141 .attr("href",function(d) {
142 s = '<?php echo $webbase; ?>';
146 s = s + '/page/' + a;
147 s = s + '/pic/' + d.id;
151 .attr("src",function(d) {
153 s= d.base_uri+'/'+d.filename;
154 s = s.replace('file:\/\/<?php echo "".str_replace("/","\/",$dbprefix); ?>','<?php echo $webbase?>/Photos-tiny/');
162 /* update permalink */
164 permalink="<?php echo $webbase ?>";
166 permalink += '/tag/' + T;
168 permalink += '/page/' + a;
171 d3.select(".permalink").html("Permalink: <a href=\""+permalink+"\">"+permalink+"</a>");
175 if (page>=2) page=page-1;
186 url = "<?php echo $webbase?>/getjson.php?CLOUD=1";
188 pics.selectAll("li").remove();
190 var svgelement=pics.append("li")
191 .append("svg").attr("width",400).attr("height",400);
194 d3.json(url, function(json) {
195 svgelement.selectAll("text").data(json).enter().append("text")
196 .style("font-size", function(d){return Math.log(d.count+1)+"em"})
197 .text(function(d) { return d.name; })
198 .on("mouseover", function(d){ d3.select(this).style("color","red")} )
199 .on("mouseout", function(d){ d3.select(this).style("color","white")} )
200 .on("click", function(d) { document.location.href='<?php echo $webbase?>/tag/'+d.name })
204 function checkbutton()
208 { d3.select("button.prev").attr("disabled","disabled");}
210 { d3.select("button.prev").attr("disabled", null);};
213 { d3.select("button.next").attr("disabled","disabled");}
215 { d3.select("button.next").attr("disabled",null);}
218 function update_page_index(mypage)
220 /* load number of pictures */
223 url = "<?php echo $webbase?>/getjson.php?C=1&T="+T;
225 url = "<?php echo $webbase?>/getjson.php?C=1";
227 d3.json(url, function(json) {
228 /* update index, show only page +-5 pages max */
229 n = Math.floor(json[0].total/N);
238 s+=" <a href=\"<?php echo $webbase?>";
241 s+="/page/1\">1</a>...";
247 for(i=start;i<=Math.min(n+1,mypage+5);i++)
253 s+=" <a href=\"<?php echo $webbase?>";
256 s+="/page/"+i+"\">"+i+"</a>";
262 s+="... <a href=\"<?php echo $webbase?>";
265 s+="/page/"+(n+1)+"\">"+(n+1)+"</a>";
269 s+=" <a href=\"<?php echo $webbase?>";
272 s+="/page/"+(n+1)+"\">"+(n+1)+"</a>";
275 d3.select(".index").html(s);