1203d724050c09c0ca4acab5095800897534579b
[www.energie.vellum.cz.git] / obsah.php
1 <?php $cvs_id='$Id$';
2
3         include("common.php");
4
5         /* assign it manually to force it to value "0" if it would be unset */
6         $year =prepvar("year" ,"[0-9]+",false/*required*/);
7         $month=prepvar("month","[0-9]+",false/*required*/);
8
9         if ($month && !$year)
10                 $month=0;
11
12              if (!$year)
13                 $title_tail="Obsahy v¹ech èísel";
14         else if (!$month)
15                 $title_tail="Obsahy èísel roku $year";
16         else {
17                 $month_a=month_a($year,$month);
18                 $title_tail="Obsah èísla ".$month_a["name_full"];
19                 }
20
21         $head_css="
22 .page { font-style: italic; }
23 ";
24
25         // Prevent indexing of pages with multiple months of the content, any
26         // websearch robot should get indexed the right one specific page anyway.
27         heading(true/*title*/,($year && $month)/*indexme*/);
28
29         print("<h1>$title_tail</h1>\n");
30
31         $result=db_query("select year,month,month_last,contents from $tb_obsah where contents is not null"
32                         .($year  ? " and year=$year"   : "")
33                         .($month ? " and month=$month" : "")
34                         ." order by year,month"
35                         );
36         if (!mysql_num_rows($result))
37                 fatal("Obsah po¾adovan".($month ? "ého èísla" : "ých èísel")." bohu¾el není ulo¾en");
38         while ($row=mysql_fetch_array($result)) {
39                 if (!$month) {
40                         $month_a=month_a($row["year"],$row["month"],$row["month_last"]);
41                         print("<h2>Èíslo ".$month_a["name_full"]."</h2>\n");
42                         }
43                 $contents=$sep_obsah_contents.$row["contents"];
44
45                 $article_result=db_query("select name,id from $tb_clanek"
46                                 ." where  year=".$row[ "year"]
47                                 .  " and month=".$row["month"]
48                                 );
49                 while ($article_row=mysql_fetch_array($article_result))
50                         $contents=ereg_replace("$sep_obsah_contents(".quotemeta($article_row["name"]).")([\n$page_obsah_contents])",
51                                         "$sep_obsah_contents"
52                                                         ."<a href=\"clanek.php?year=".$row["year"]."&amp;month=".$row["month"]."&amp;id=".$article_row["id"]."\">"
53                                                         ."\\1</a>"
54                                         ."\\2",$contents);
55                 mysql_free_result($article_result);
56
57                 $contents=ereg_replace("http://[^[:space:]$page_obsah_contents$sep_obsah_contents]+",
58                                 "<a href=\"\\0\">\\0</a>",$contents);
59                 $contents=ereg_replace("$page_obsah_contents([^$sep_obsah_contents$appendix_obsah_contents]+)",
60                                 "<br /><span class=\"page\">strana ... \\1</span>",$contents);
61                 $contents=ereg_replace("\n","<br />\n\t\t",$contents);
62                 $contents=ereg_replace("$sep_obsah_contents([^$sep_obsah_contents$appendix_obsah_contents]*)","\t<li>\\1</li>\n",$contents);
63                 if (1<count($contents_a=split("$appendix_obsah_contents",$contents,2)))
64                         $contents=$contents_a[0]."\t<li>Pøílohy:<ul>\n".ereg_replace("\t","\t\t",$contents_a[1])."\t</ul></li>\n";
65                 print("<ul>\n$contents</ul>\n");
66                 }
67         mysql_free_result($result);
68
69         footer();
70 ?>