+EaP 4/2010 (164)
[www.energie.vellum.cz.git] / obsah.php
index aee9ede..4aa257e 100644 (file)
--- a/obsah.php
+++ b/obsah.php
                $title_tail="Obsahy èísel roku $year";
        else {
                $month_a=month_a($year,$month);
-               $title_tail="Obsah èísla ".$month_a["name"];
+               $title_tail="Obsah èísla ".$month_a["name_full"];
                }
 
        $head_css="
 .page { font-style: italic; }
 ";
-       heading();
+
+       // Prevent indexing of pages with multiple months of the content, any
+       // websearch robot should get indexed the right one specific page anyway.
+       heading(true/*title*/,($year && $month)/*indexme*/);
+
        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'" : "")
+       $result=db_query("select year,month,month_last,contents from $tb_obsah where contents is not null"
+                       .($year  ? " and year=$year"   : "")
+                       .($month ? " and month=$month" : "")
                        ." order by year,month"
                        );
        if (!mysql_num_rows($result))
        while ($row=mysql_fetch_array($result)) {
                if (!$month) {
                        $month_a=month_a($row["year"],$row["month"],$row["month_last"]);
-                       print("<h2>Èíslo ".$month_a["name"]."</h2>\n");
+                       print("<h2>Èíslo ".$month_a["name_full"]."</h2>\n");
                        }
-               $contents=htmlspecialchars($sep_obsah_contents.$row["contents"]);
+               $contents=$sep_obsah_contents.$row["contents"];
+
+               $article_result=db_query("select name,id from $tb_clanek"
+                               ." where  year=".$row[ "year"]
+                               .  " and month=".$row["month"]
+                               );
+               while ($article_row=mysql_fetch_array($article_result))
+                       $contents=ereg_replace("$sep_obsah_contents("
+                                                       .quotemeta(ereg_replace("\\|.*\$","",$article_row["name"]))
+                                                       .")([\n$page_obsah_contents])",
+                                       "$sep_obsah_contents"
+                                                       ."<a href=\"clanek.php?year=".$row["year"]."&amp;month=".$row["month"]."&amp;id=".$article_row["id"]."\">"
+                                                       ."\\1</a>"
+                                       ."\\2",$contents);
+               mysql_free_result($article_result);
+
                $contents=ereg_replace("http://[^[:space:]$page_obsah_contents$sep_obsah_contents]+",
                                "<a href=\"\\0\">\\0</a>",$contents);
-               $contents=ereg_replace("$page_obsah_contents([^$sep_obsah_contents]+)",
-                               "<br /><div class=\"page\">strana ... \\1</div>",$contents);
+               $contents=ereg_replace("$page_obsah_contents([^$sep_obsah_contents$appendix_obsah_contents]+)",
+                               "<br /><span class=\"page\">strana ... \\1</span>",$contents);
                $contents=ereg_replace("\n","<br />\n\t\t",$contents);
-               $contents=ereg_replace("$sep_obsah_contents([^$sep_obsah_contents]*)","\t<li>\\1</li>\n",$contents);
+               $contents=ereg_replace("$sep_obsah_contents([^$sep_obsah_contents$appendix_obsah_contents]*)","\t<li>\\1</li>\n",$contents);
+               if (1<count($contents_a=split("$appendix_obsah_contents",$contents,2)))
+                       $contents=$contents_a[0]."\t<li>Pøílohy:<ul>\n".ereg_replace("\t","\t\t",$contents_a[1])."\t</ul></li>\n";
                print("<ul>\n$contents</ul>\n");
                }
        mysql_free_result($result);