Subversion-Projekte lars-tiefland.medien

Revision

Revision 42 | Zur aktuellen Revision | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

<?
        function generate_cd_pdf_lang($id, $spr)
        {
                $x1=60;         //Column 1
                $x2=200;        //Column 2 (normal)
                $x3=90;         //Column 2 (Title List)
                $x4=490;        //Column 3 (Title List)
                
                global $tr;
                
                $lang=$tr->getPage("common", $spr);
                $cd=new CD($id);
                $a=new Album($cd->album);
                $g=new Genre($a->genre);
                $tracks=Track::getTracks($cd->id);
                $a_id=$a->artist;
                $artist=new Artist($a_id);
                $a_name=(($a_id==1)?$lang["$artist->name"]:($artist->fname)?"$artist->fname $artist->name":"$artist->name");
                $pdf=PDF_NEW();

                if(!$pdf) return false;
                if(!PDF_begin_document($pdf, "pdf/$spr/CD_$id.pdf","")) return false;
                if(!PDF_begin_page_ext($pdf, 595, 842, "")) return false;
                
                $font = PDF_load_font($pdf, "Helvetica-Bold", "winansi", "");

                $y=770;
                PDF_setfont($pdf, $font, 25);
                PDF_set_text_pos($pdf, $x1, $y);
                PDF_show($pdf, "Details zur CD");
                $y-=30;
                PDF_set_text_pos($pdf, $x1, $y);
                PDF_show($pdf, "\"$cd->name\"");
                $y-=30;
                PDF_setfont($pdf, $font, 10);
                PDF_set_text_pos($pdf, $x1, $y);
                PDF_show($pdf, $lang["album_name"].":");
                PDF_set_text_pos($pdf, $x2, $y);
                PDF_show($pdf, $a->name);
                $y-=10;
                PDF_set_text_pos($pdf, $x1, $y);
                PDF_show($pdf, $lang["genre"].":");
                PDF_set_text_pos($pdf, $x2, $y);
                PDF_show($pdf, $g->name);
                $y-=10;
                PDF_set_text_pos($pdf, $x1, $y);
                PDF_show($pdf, $lang["year"].":");
                PDF_set_text_pos($pdf, $x2, $y);
                PDF_show($pdf, ($a->year)?$a->year:$lang["unknown"]);
                $y-=10;
                PDF_set_text_pos($pdf, $x1, $y);
                PDF_show($pdf, $lang["sampler"].":");
                PDF_set_text_pos($pdf, $x2, $y);
                PDF_show($pdf, ($a->artist==1)?$lang["yes"]:$lang["no"]);
                $y-=10;
                PDF_set_text_pos($pdf, $x1, $y);
                PDF_show($pdf, $lang["artist"].":");
                PDF_set_text_pos($pdf, $x2, $y);
                PDF_show($pdf, $a_name);
                $tmp_name="images/alben/$a->pic";
                $i=PDF_open_image_file($pdf, "jpeg", $tmp_name, "", 0);
                $y=470;
                PDF_set_text_pos($pdf, $x1, $y);
                PDF_show($pdf, $lang["picture"].":");
                PDF_fit_image($pdf, $i, $x2, $y, "");
                $y-=20;
                PDF_set_text_pos($pdf, $x1, $y);
                PDF_show($pdf, $lang["tracks"].":");
                $y-=20;
                PDF_set_text_pos($pdf, $x1, $y);
                PDF_show($pdf, "#");
                PDF_set_text_pos($pdf, $x3, $y);
                PDF_show($pdf, $lang["title"]);
                PDF_set_text_pos($pdf, $x4, $y);
                PDF_show($pdf, $lang["duration"]);
                $y-=20;

                foreach($tracks as $track)
                {
                        PDF_SET_text_pos($pdf, $x1, $y);
                        PDF_show($pdf,sprintf("%02d", $track["t_id"]));
                        PDF_set_text_pos($pdf, $x3, $y);
                        PDF_show($pdf, $track["t_name"]);
                        PDF_set_text_pos($pdf, $x4, $y);
                        PDF_show($pdf, $track["t_dur"]);
                        $y-=10;
                        if ($y < 60)
                        {
                                PDF_set_text_pos($pdf, 10, 10);
                                PDF_show($pdf, $sig);
                                PDF_set_text_pos($pdf, 510, 10);
                                PDF_show($pdf, $page);
                                $res=PDF_end_page_ext($pdf,"");
                                $y=750;
                                $page++;
                                $res=PDF_begin_page_ext($pdf,595,842,"");
                                pdf_set_text_pos($pdf,$x ,$y); 
                                $font = PDF_load_font($pdf, "Helvetica", "winansi", "");

                                PDF_setfont($pdf, $font, 10);
                        }
                }
                if(!PDF_end_page_ext($pdf,"")) return false;
                if(!PDF_end_document($pdf,"")) return false;
                return true;
        }
        
        function generate_cd_pdf($id)
        {
                global $db, $prefix;
                $sql="SELECT * FROM $prefix"."langs";
                $res=$db->query($sql);
                var_dump($res);
                while($row=$res->fetchRow())
                {
                        $spr=$row["id"];
                        generate_cd_pdf_lang($id, $spr);
                }
        }
?>