config.php introduced
[www.energie.vellum.cz.git] / index.php
index 43507a5..663b19a 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1,54 +1,73 @@
 <?php $cvs_id='$Id$';
 
+       $detect_js=true;
+       $head='
+<script type="text/javascript" src="objednavka.js"></script>
+';
+       include("common.php");
+
        $head_css="
 .tab-bold  { font-weight: bold; }
 .post-type { font-family: monospace; }
 .nowrap    { white-space: nowrap; }
 .centered  { text-align: center; }
 ";
-       $head='
-<script type="text/javascript" src="objednavka.js"></script>
-';
-       $detect_js=true;
-
-       include("common.php");
+       heading();
 ?>
-<h1 class="centered"><img src="img/eap-title.png" alt="Teplo &amp; Peníze" /></h1>
+<h1 class="centered"><img src="img/eap-title.png" <?php print(img_size(522,60)); ?> alt="Teplo &amp; Peníze" /></h1>
 <p>&nbsp;</p>
 <?php
 
-function title_table_month($year,$month)
+function title_table_month($year,$month,$month_last)
 {
-       $size_width_s= 98; $size_height_s=138;
-       $size_width  =486; $size_height  =688;
-
-       $base=sprintf("img/eap-%04d-%02d",$year,$month+1);
-       $name=sprintf(        "%04d/%02d",$year,$month+1);
+       $month_full=month_full($year,$month,$month_last);
+       $base="img/eap-$year-$month_full";
+       $name=        "$year/$month_full";
        print("<a href=\"${base}.jpg\">"
-                       ."<img src=\"${base}s.jpg\" width=\"$size_width_s\" height=\"$size_height_s\""
-                       ." style=\"border:0;width:${size_width_s}px;height:${size_height_s}px\" alt=\"titulní stránka $name\" /><br />\n"
-                       ."$name"
-                       ."</a>");
+                       ."<img src=\"${base}s.jpg\" ".img_size(98,138)." alt=\"titulní stránka $name\" /></a><br />\n"
+                       ."<a href=\"obsah.php?year=$year&month=$month\">obsah $name</a>"
+                       );
 }
 
-function title_table_year($year,$month_max=11)
-{
-       $split=6;
+db_connect();
+$result=db_query("select year,month,month_last from $tb_obsah order by year,month");
+$split=6;
+$year=0;
+$month=-$split;
+$fin_split="";
+$fin_year="";
+while ($row=mysql_fetch_array($result)) {
+       $row["month"     ]--;
+       $row["month_last"]--;
 
-       print("<table border=\"0\" width=\"100%\"><tr><td align=\"center\"><table border=\"1\" cellpadding=\"5\">\n");
-       for ($month=0;$month<=$month_max;$month++) {
-               if (($month%$split)==0)
-                       print("<tr>");
-               print("<td align=\"center\">");
-               title_table_month($year,$month);
-               print("</td>");
-               if (($month%$split)==$split-1 || $month==$month_max)
-                       print("</tr>\n");
-               }
-       print("</table></td></tr></table>");
-}
+       if ($row["year"]!=$year) {
+               print($fin_split.$fin_year);
 
-title_table_year(2001,5);
+               $year=$row["year"];
+               print("<table border=\"0\" width=\"100%\"><tr><td align=\"center\"><table border=\"1\" cellpadding=\"5\">\n"
+                               ."<tr><th colspan=\"$split\">Roèník $year (<a href=\"obsah.php?year=$year\">obsahy èísel</a>)</td></tr>\n"
+                               );
+               $fin_year="</table></td></tr></table>\n";
+               $month=-$split;
+               }
+       if ($month && floor($row["month"]/$split)!=floor($month/$split)) {
+               print($fin_split."<tr>");
+               $fin_split="</tr>";
+               $month=$row["month"]-($row["month"]%$split)-1;
+               }
+       while ($month+1<$row["month"]) {
+               print("<td></td>");
+               $month++;
+               }
+       print("<td align=\"center\""
+                       .($row["month_last"]!=$row["month"] ? " colspan=\"".($row["month_last"]+1-$row["month"])."\"" : "")
+                       .">");
+       title_table_month($year,$row["month"]+1,$row["month_last"]+1);
+       print("</td>");
+       $month=$row["month_last"];
+       }
+mysql_free_result($result);
+print($fin_split.$fin_year);
 ?>
 
 <p>&nbsp;</p>