return($row[0]);
}
-function month_a($year,$month,$month_last=0)
+function num2greg($num)
{
- global $tb_obsah;
+ $r="";
+ $vals=array(1=>"I",5=>"V",10=>"X",50=>"L",100=>"C",500=>"D",1000=>"M");
+ krsort($vals,SORT_NUMERIC);
+ foreach($vals as $val=>$sym) {
+ while ($num<0 && $num+$val<-$num) {
+ $r=substr($r,0,-1).$sym.substr($r,-1,1);
+ $num+=$val;
+ }
+ while (10*$num>=8*$val+(substr($val,0,1)=="1")) {
+ $r=$r.$sym;
+ $num-=$val;
+ }
+ }
+ return($r);
+}
+
+function month_a($year,$month,$month_last=0,$sequential=0)
+{
+ global $tb_obsah,$obsah_year_base;
- if (!$month_last)
- $month_last=db_item("select month_last from $tb_obsah where year='$year' and month='$month'");
+ if (!$month_last || !$sequential)
+ list($month_last,$sequential)=db_row("select month_last,sequential from $tb_obsah where year='$year' and month='$month'");
$month_full=sprintf("%02d".($month==$month_last ? "" : "-%02d"),$month,$month_last);
$r=array("year"=>$year,"month"=>$month,"month_last"=>$month_last,"month_full"=>$month_full,
- "name"=>"$month".($month==$month_last ? "" : "-$month_last")."/$year",
+ "name"=>"$month" .($month==$month_last ? "" : "-$month_last")."/$year",
"img" =>"img/eap-$year-${month_full}.jpeg",
"icon"=>"img/eap-$year-${month_full}s.jpeg",
);
+ $r["name_full"]=$r["name"]
+ ." ($sequential".($month==$month_last ? "" : "-".($sequential+$month_last-$month)).")"
+ ." - ".num2greg($year-$obsah_year_base+1).". roèník";
return($r);
}
{
if (isset($year) && isset($month)) {
$month_a=month_a($year,$month);
- return("Èíslo ".$month_a["name"]);
+ return("Èíslo ".$month_a["name_full"]);
}
else if (isset($year))
return("Roèník $year");
);
}
-function title_icons_table_month($year,$month,$month_last)
+function title_icons_table_month($year,$month,$month_last,$sequential)
{
- $month_a=month_a($year,$month,$month_last);
+ $month_a=month_a($year,$month,$month_last,$sequential);
print("<a href=\"title.php?year=$year&month=$month\">"
- .img($month_a["icon"],"titulní stránka ".$month_a["name"])."</a><br />"
+ .img($month_a["icon"],"titulní stránka ".$month_a["name_full"])."</a><br />"
."<a href=\"obsah.php?year=$year&month=$month\">obsah ".$month_a["name"]."</a>"
);
}
.(isset($year) ? "</a>" : "")
."</h2>\n");
- $result=db_query("select year,month,month_last from $tb_obsah"
+ $result=db_query("select year,month,month_last,sequential from $tb_obsah"
.(isset($year) || isset($month) ? " where" : "")
.(isset($year ) ? " year=$year" : "")
.(isset($year) && isset($month) ? " and" : "")
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);
+ title_icons_table_month($year,$row["month"]+1,$row["month_last"]+1,$row["sequential"]);
print("</td>\n");
$month=$row["month_last"];
}
$tb_obsah="energie_obsah";
$sep_obsah_contents=chr(1);
$page_obsah_contents=chr(3);
+ $appendix_obsah_contents=chr(4);
+ $obsah_year_base=1996;
$tb_objednavka="energie_objednavka";
?>
$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="
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=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]+)",
+ $contents=ereg_replace("$page_obsah_contents([^$sep_obsah_contents$appendix_obsah_contents]+)",
"<br /><div class=\"page\">strana ... \\1</div>",$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>\n";
print("<ul>\n$contents</ul>\n");
}
mysql_free_result($result);
."year year(4) not null,"
."month tinyint not null,"
."month_last tinyint not null,"
+ ."sequential smallint not null,"
."contents text not null"
.")");
&db_do("alter table $tb_obsah add unique (year,month)");
-use vars qw/$insert_tb_obsah $year $month $month_last $contents/;
+use vars qw/$insert_tb_obsah $year $month $month_last $sequential $contents $first/;
sub where
{
else {
tr/ \t\n/ \n/s;
s/([\001\n]) | ([\002\n])/$1$2/g;
- s/\nstrana \.\.\. ([\d ,]+\002)/\003$1/g;
- die "Page marker not found somewhere in this month".&where() if (/\001[^\003]*\002/);
+ die "Page marker not found somewhere in this month".&where() if (/^[^\004]*\001[^\003\004]*\002/);
+ die "Duplicate page markers in this month".&where() if (/strana /);
tr/\002//d;
$_=substr($_,1);
}
- $insert_tb_obsah->execute($year,$month,$month_last,$_) or die "SQL insert failure: $!";
+ $insert_tb_obsah->execute($year,$month,$month_last,$sequential,$_) or die "SQL insert failure: $!";
undef $year,$month;
undef $contents;
+ undef $first;
}
-$insert_tb_obsah=$db->prepare("insert into $tb_obsah (year,month,month_last,contents) values (?,?,?,?)")
+$insert_tb_obsah=$db->prepare("insert into $tb_obsah (year,month,month_last,sequential,contents) values (?,?,?,?,?)")
or die "Prepare fail: $!";
while (<>) {
chomp;
- if (m#^EaP (\d+)(-(\d+))?/(\d+)$#) {
+ if (m#^EaP (\d+)(-(\d+))?/(\d+) \((\d+)(-\d+)?\)$#) {
&flush_month();
$month=$1;
$month_last=($3 ? $3 : $1);
$year =$4;
+ $sequential=$5;
$contents="";
next;
}
- if (/^\.\s(.*)$/) {
- $contents.="\001$1\002";
+ if (/^Pøíloha:$/) {
+ die "Multiple \"Pøíloha\"s".&where() if ($contents=~/\004/);
+ $contents.="\004";
+ next;
+ }
+ if (/^[^[:space:]]/ || (/^\s/ && $contents=~/\004/)) {
+ $contents.="\001$_\002";
+ $first=$_;
+ next;
+ }
+ if (/^\s+strana \.\.\. ([\d ,-]+)$/) {
+ die "Page number without start".&where() if ("\002"!=substr($contents,-1,1));
+ die "Page number already specified".&where() if ($contents=~/\003[^\001\002\004]*\002$/);
+ $contents=substr($contents,0,-1)."\003$1\002";
next;
}
if (/^\s(.*)$/) {
- $contents=substr($contents,0,-1)."\n$1\002";
+ my( $s )=$1;
+ die "INTERNAL: continuation for \"Pøíloha\"".&where() if ($contents=~/\004/);
+ die "Continuation contents without start".&where() if ("\002"!=substr($contents,-1,1));
+ if ($contents=~/\003[^\001\002\004]*\002$/) {
+ die "First line not found".&where() if !defined($first);
+ $contents.="\001$first\002";
+ }
+ $contents=substr($contents,0,-1)."\n$s\002";
next;
}
die "Unexpected text".&where().": $_" if (/\S/);