Even title page year (or all years) tables now also displayed from "title.php"
authorshort <>
Fri, 17 Aug 2001 20:12:40 +0000 (20:12 +0000)
committershort <>
Fri, 17 Aug 2001 20:12:40 +0000 (20:12 +0000)
Main "index.php" page now displays only the titles of the current year

common.php
index.php
obsah.php
title.php

index 1e6f22f..cd9e5e4 100644 (file)
@@ -67,8 +67,7 @@ function prepvar($name,$regex=".",$require=true)
        if (!isset($v))
                return(0);
 
-       global $$name;
-       $$name=$v;
+       $globals[$name]=$v;
        return($v);
 }
 
@@ -153,6 +152,114 @@ function price_a()
        return($r);
 }
 
+function title_name($year,$month)
+{
+            if (isset($year) && isset($month)) {
+               $month_a=month_a($year,$month);
+               return("Titulní strana èísla ".$month_a["name"]);
+               }
+       else if (isset($year))
+               return("Titulní strany roèníku $year");
+       else
+               return("Titulní strany");
+}
+
+function title_month($year,$month)
+{
+  $month_a=month_a($year,$month);
+       return(""
+                       ."<table border=\"0\" width=\"100%\">\n"
+                       ."<tr><td align=\"center\"><table border=\"1\" cellpadding=\"10\">\n"
+                       ."<tr><th align=\"center\">".title_name($year,$month)."</th></tr>\n"
+                       ."<tr><td align=\"center\"><img src=\"".$month_a["img"]."\" ".img_size($month_a["img"])
+                       ." alt=\"titulní stránka ".$month_a["name"]."\" /></td></tr>\n"
+                       ."</table></td></tr>\n"
+                       ."</table>\n"
+                       );
+}
+
+function title_icons_table_month($year,$month,$month_last)
+{
+       $month_a=month_a($year,$month,$month_last);
+       print("<a href=\"title.php?year=$year&amp;month=$month\">"
+                               ."<img src=\"".$month_a["icon"]."\" ".img_size($month_a["icon"])
+                               ." alt=\"titulní stránka ".$month_a["name"]."\" /></a><br />"
+                       ."<a href=\"obsah.php?year=$year&amp;month=$month\">obsah ".$month_a["name"]."</a>"
+                       );
+}
+
+function title_icons($year,$month)
+{
+       global $tb_obsah;
+
+       print("<h2>"
+               .(isset($year) ? "<a name=\"year_$year\">" : "")
+               .title_name(&$year,&$month)
+               .(isset($year) ? "</a>" : "")
+               ."</h2>\n");
+
+       $result=db_query("select year,month,month_last from $tb_obsah"
+                       .(isset($year) || isset($month) ? " where" : "")
+                       .(isset($year ) ? " year=$year"   : "")
+                       .(isset($year) && isset($month) ? " and" : "")
+                       .(isset($month) ?   " month=$month" : "")
+                       ." order by year,month");
+       $split=6;
+
+       // $year variable changes its meaning here!!!
+       if (isset($year))
+               $wanted_year=$year;
+       $year=0;
+
+       $fin_split="";
+       $fin_year="";
+       while ($row=mysql_fetch_array($result)) {
+               $row["month"     ]--;
+               $row["month_last"]--;
+
+               if ($row["year"]!=$year) {
+                       print($fin_split.$fin_year);
+
+                       $year=$row["year"];
+                       print(""
+                                       .(!isset($wanted_year) ? "<p><a name=\"year_$year\">&nbsp;</a></p>" : "")
+                                       ."<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>)</th></tr>\n"
+                                       );
+                       $fin_year="</table></td></tr></table>\n";
+                       $fin_split="";
+                       $month=-1;
+                       $floor=-1;
+                       }
+               while ($floor<floor($row["month"]/$split)) {
+                       print($fin_split."<tr>");
+                       $fin_split="</tr>\n";
+                       $floor++;
+                       $month=$floor*$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_icons_table_month($year,$row["month"]+1,$row["month_last"]+1);
+               print("</td>\n");
+               $month=$row["month_last"];
+               }
+       mysql_free_result($result);
+       print($fin_split.$fin_year);
+}
+
+function title($year,$month)
+{
+       if (isset($year) && isset($month))
+               return(title_month( $year, $month));
+       else
+               return(title_icons(&$year,&$month));
+}
+
 function footer()
 {
        // deadlock prevention:
@@ -163,6 +270,7 @@ function footer()
 
        global $cvs_id_html,$viewcvs,$viewcvs,$HTTP_SERVER_VARS;
        ?>
+<p>&nbsp;</p>
 <hr />
 <table border="0" width="100%">
 <tr><td align="left"><span class="cvs-id"><?php print($cvs_id_html); ?></span></td><td align="right"><a
index 1188594..1571450 100644 (file)
--- a/index.php
+++ b/index.php
 <h1 class="centered"><img src="img/eap-title.png" <?php print(img_size(522,60)); ?> alt="Energie &amp; Peníze" /></h1>
 <ul>
        <li><a href="obsah.php">Obsahy v¹ech roèníkù</a></li>
+       <li><a href="title.php">Titulní strany v¹ech roèníkù</a></li>
 <?php
 
-$result=db_query("select distinct year from $tb_obsah order by year");
-while ($row=mysql_fetch_array($result))
-       print("\t<li><a href=\"#year_".$row["year"]."\">Roèník ".$row["year"]."</a></li>\n");
-mysql_free_result($result);
+       $getdate=getdate();
+       unset($unset_month);
+       $year=$getdate["year"];
+
+       $result=db_query("select distinct year from $tb_obsah order by year");
+       while ($row=mysql_fetch_array($result))
+               print("\t<li><a href=\"title.php?year=".$row["year"]."\">Roèník ".$row["year"]."</a></li>\n");
+       mysql_free_result($result);
+
 ?>
        <li><a href="#objednavka">Objednávka</a></li>
 </ul>
 
 <p>&nbsp;</p>
-<h2>Titulní strany</h2>
 <?php
 
-function title_table_month($year,$month,$month_last)
-{
-       $month_a=month_a($year,$month,$month_last);
-       print("<a href=\"title.php?year=$year&amp;month=$month\">"
-                               ."<img src=\"".$month_a["icon"]."\" ".img_size($month_a["icon"])
-                               ." alt=\"titulní stránka ".$month_a["name"]."\" /></a><br />"
-                       ."<a href=\"obsah.php?year=$year&amp;month=$month\">obsah ".$month_a["name"]."</a>"
-                       );
-}
+       title(&$year,&$unset_month);
 
-$result=db_query("select year,month,month_last from $tb_obsah order by year,month");
-$split=6;
-$year=0;
-$fin_split="";
-$fin_year="";
-while ($row=mysql_fetch_array($result)) {
-       $row["month"     ]--;
-       $row["month_last"]--;
-
-       if ($row["year"]!=$year) {
-               print($fin_split.$fin_year);
-
-               $year=$row["year"];
-               print("<p><a name=\"year_$year\">&nbsp;</a></p>"
-                               ."<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>)</th></tr>\n"
-                               );
-               $fin_year="</table></td></tr></table>\n";
-               $fin_split="";
-               $month=-1;
-               $floor=-1;
-               }
-       while ($floor<floor($row["month"]/$split)) {
-               print($fin_split."<tr>");
-               $fin_split="</tr>\n";
-               $floor++;
-               $month=$floor*$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>\n");
-       $month=$row["month_last"];
-       }
-mysql_free_result($result);
-print($fin_split.$fin_year);
 ?>
-
 <p>&nbsp;</p>
 
 <h2><a name="objednavka">Objednávka</a></h2>
@@ -169,7 +124,7 @@ print_addr("Adresa pro zas
        <tr><td align="left"><input type="radio" name="payment" value="bill" />
                        Zaslání proforma faktury a následná platba slo¾enkou, bankovním pøevodem apod.</td></tr>
        <tr><td align="left"><input type="radio" name="payment" value="direct" />
-                       Platba <?php print(gsm_banking()); ?> èi jiný pøímý bankovní pøevod, zasíláme pouze daòový doklad</td></tr>
+                       Platba <?php print(gsm_banking()); ?> èi jiný pøímý bankovní pøevod, za¹leme pouze daòový doklad</td></tr>
 </table></td></tr>
 <tr><td align="center"><table border="0">
        <tr><td align="center" class="tab-head">Jiné sdìlení redakci</td></tr>
index aee9ede..922cd36 100644 (file)
--- a/obsah.php
+++ b/obsah.php
@@ -25,8 +25,8 @@
        print("<h1>$title_tail</h1>\n");
 
        $result=db_query("select year,month,month_last,contents from $tb_obsah"
-                       .($year  ? " where year='$year'"   : "")
-                       .($month ?   " and month='$month'" : "")
+                       .($year  ? " where year=$year"   : "")
+                       .($month ?   " and month=$month" : "")
                        ." order by year,month"
                        );
        if (!mysql_num_rows($result))
index 03a0e6b..9406eb4 100644 (file)
--- a/title.php
+++ b/title.php
@@ -2,23 +2,12 @@
 
        include("common.php");
 
-       prepvar("year" ,"[0-9]+");
-       prepvar("month","[0-9]+");
+       prepvar("year" ,"[0-9]+",false/*required*/);
+       prepvar("month","[0-9]+",false/*required*/);
 
-       $month_a=month_a($year,$month);
-       $title_tail="Titulní strana èísla ".$month_a["name"];
+       $title_tail=title_name(&$year,&$month);
        heading();
 
-?>
-<table border="0" width="100%">
-<tr><td align="center"><table border="1" cellpadding=\"10\">
-       <tr><th align="center"><?php print($title_tail); ?></th></tr>
-       <tr><td align="center"><?php
-       print("<img src=\"".$month_a["img"]."\" ".img_size($month_a["img"])
-                       ." alt=\"titulní stránka ".$month_a["name"]."\" />");
-?></td></tr>
-       </table></td></tr>
-</table>
-<?php
+       print(title($year,$month));
        footer();
 ?>