Subversion-Projekte lars-tiefland.niewerth

Revision

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

<?php
        function generate_pagination2($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = TRUE)
        {
                global $mode, $common;
                if (!$num_items)
                {
                        return "";
                }

                $total_pages = ceil($num_items/$per_page);

                if ( $total_pages == 1 )
                {
                        return '<table align="center" class="navig"><tr><th>'.$common["page"]." 1 ".$common["of"].' 1</th></tr></table><br><br>';
                }

                $on_page = floor($start_item / $per_page) + 1;

                $page_string = '<table align="center" class="navig"><tr><th colspan="5">'.$common["page"].' '.$on_page.' '.$common["of"].' '.$total_pages.'</th></tr><tr>';

                if ( $add_prevnext_text )
                {
                        if ( $on_page > 1 )
                        {
                                $page_string .= "<td><form name=\"nav\" action=$base_url method=\"post\"><input type=\"submit\" value=\"|<<\" title=\"${common["first_page"]}\" class=\"liteoption\"><input type=\"hidden\" name=\"start\" value=\"0\"><input type=\"hidden\" name=\"mode\" value=\"$mode\"></form></td>";
                                $prev_v=($on_page - 2 ) * $per_page;
                                $page_string .= "<td><form name=\"nav\" action=$base_url method=\"post\"><input type=\"submit\" value=\"|<\" title=\"${common["previous_page"]}\" class=\"liteoption\"><input type=\"hidden\" name=\"start\" value=\"$prev_v\"><input type=\"hidden\" name=\"mode\" value=\"$mode\"></form></td>";
                        }
                        else
                        {
                                $page_string .= "<td><form name=\"nav\" action=$base_url method=\"post\"><input type=\"submit\" value=\"|<<\" disabled class=\"liteoption\"><input type=\"hidden\" name=\"start\" value=\"0\"><input type=\"hidden\" name=\"mode\" value=\"$mode\"></form></td>";
                                $page_string .= "<td><form name=\"nav\" action=$base_url method=\"post\"><input type=\"submit\" value=\"|<\" class=\"liteoption\" disabled><input type=\"hidden\" name=\"start\" value=\"0\"></form></td>";
                        }
                }
                if($total_pages >1)
                {
                        $page_opts="";
                        for ($i=0;$i<$total_pages;$i++)
                        {
                                $selected="";
                                $j=$i+1;
                                if($j==$on_page)
                                {
                                        $selected="selected=\"selected\"";
                                }
                                $start=($i*$per_page);
                                $page_opts.="<option value=$start $selected>$j</option>";
                        }
                        $page_string.="<td width=\"100\"><form name=\"nav\" action=$base_url method=\"post\"><select name=\"start\">$page_opts</select>&nbsp;&nbsp;<input type=\"submit\" value=\"${common["go"]}\" class=\"liteoption\"><input type=\"hidden\" name=\"mode\" value=\"$mode\"></form></td>";
                }

                if ( $add_prevnext_text )
                {
                        if ( $on_page < $total_pages )
                        {
                                $next_v=($on_page * $per_page);
                                $page_string .= "<td><form name=\"nav\" action=$base_url method=\"post\"><input type=\"submit\" value=\">|\" title=\"${common["next_page"]}\" class=\"liteoption\"><input type=\"hidden\" name=\"start\" value=\"$next_v\"><input type=\"hidden\" name=\"mode\" value=\"$mode\"></form></td>";
                                $max_v=($total_pages -1)*$per_page;
                                $page_string .= "<td><form name=\"nav\" action=$base_url method=\"post\"><input type=\"submit\" value=\">>|\" title=\"${common["last_page"]}\" class=\"liteoption\"><input type=\"hidden\" name=\"start\" value=\"$max_v\"><input type=\"hidden\" name=\"mode\" value=\"$mode\"></form></td>";
                        }
                        else
                        {
                                $page_string .= "<td><form name=\"nav\" action=$base_url method=\"post\"><input type=\"submit\" value=\">|\" class=\"liteoption\" disabled><input type=\"hidden\" name=\"start\" value=\"0\"><input type=\"hidden\" name=\"mode\" value=\"$mode\"></form></td>";
                                $page_string .= "<td><form name=\"nav\" action=$base_url method=\"post\"><input type=\"submit\" value=\">>|\" disabled class=\"liteoption\" disabled><input type=\"hidden\" name=\"start\" value=\"0\"><input type=\"hidden\" name=\"mode\" value=\"$mode\"></form></td>";
                        }

                }
                $page_string.="</tr></table><br><br>";

                return $page_string;
        }
        
        function calendar($an_id, $f_id, $y=0, $m=0)
        {
                if ($y===0)
                {
                        $y=date("Y");
                }
                if ($m===0)
                {
                        $m=date("n");
                }
                global $smarty;
                require_once 'Calendar/Month/Weekdays.php';
                require_once 'Calendar/Decorator/Textual.php';
                require_once 'Calendar/Decorator/Uri.php';
                $smarty->assign("title","Termine Schritt 2 - Kalender");
                setLocale(LC_ALL,"de_DE");
                $mode=(isset($_GET["mode"]))?$_GET["mode"]:"";
                $smarty->assign("mode",$mode);
                $Month = new Calendar_Month_Weekdays($y, $m);
                $m_d=new Calendar_Decorator_Textual($Month);
                $u_d=new Calendar_Decorator_Uri($Month);
                $u_d->setFragments("jahr", "monat", "tag");
                $Month->build();

                $cal="<table>";
                $cal.="<tr><th colspan=7>
                <form action=termine.php>
                        <input type='hidden' name='mode' value='calendar'>
                        <input type='hidden' name='an_id' value='$an_id'>
                        <input type='hidden' name='f_id' value='$f_id'>
                        <input type='hidden' name='monat' value='$m'>
                        <input type='hidden' name='jahr' value='".$u_d->prevYear()."'>
                        <input class='liteoption' type='submit' value='<<'>
                </form>
                
                <form action=termine.php>
                        <input type='hidden' name='mode' value='calendar'>
                        <input type='hidden' name='an_id' value='$an_id'>
                        <input type='hidden' name='f_id' value='$f_id'>
                        <input type='hidden' name='monat' value='".$u_d->prevMonth()."'>
                        <input type='hidden' name='jahr' value='".(($m==1)?$u_d->prevYear():$y)."'>
                        <input class='liteoption' type='submit' value='<'>
                </form>
                &nbsp;&nbsp;".$m_d->thisMonthName()." ".$y."&nbsp;&nbsp;
                <form action=termine.php>
                        <input type='hidden' name='mode' value='calendar'>
                        <input type='hidden' name='an_id' value='$an_id'>
                        <input type='hidden' name='f_id' value='$f_id'>
                        <input type='hidden' name='monat' value='".$u_d->nextMonth()."'>
                        <input type='hidden' name='jahr' value='".(($m==12)?$u_d->nextYear():$y)."'>
                        <input class='liteoption' type='submit' value='>'>
                </form>
                
                <form action=termine.php>
                        <input type='hidden' name='mode' value='calendar'>
                        <input type='hidden' name='an_id' value='$an_id'>
                        <input type='hidden' name='f_id' value='$f_id'>
                        <input type='hidden' name='monat' value='$m'>
                        <input type='hidden' name='jahr' value='".$u_d->nextYear()."'>
                        <input class='liteoption' type='submit' value='>>'>
                </form>
                </th></tr>";
                $cal.="<tr><th>Mo</th><th>Di</th><th>Mi</th><th>Do</th><th>Fr</th><th>Sa</th><th>So</th></tr>";
                while ($Day = $Month->fetch()) 
                {
                        if ($Day->isFirst()) 
                        {
                                $cal.="<tr>";
                        }       

                        if ($Day->isEmpty()) 
                        {
                                $cal.="<td>&nbsp;</td>";
                        }
                        else
                        {
                                $cal.='<td>'."<a href='termine.php?mode=end&an_id=$an_id&f_id=$f_id&jahr=".$Month->thisYear()."&monat=".$Month->thisMonth()."&tag=".$Day->thisDay()."'>".$Day->thisDay()."</a></td>";
                        }

                        if ($Day->isLast()) 
                        {
                                $cal.="</tr>";
                        }
                }

                $cal.="</table>";
                $smarty->assign("cal",$cal);
                $smarty->display("calendar.tpl");
        }
?>