Subversion-Projekte lars-tiefland.content-management

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
    // week starts on Monday
4
    define( 'DATE_CALC_BEGIN_WEEKDAY', 1 );
5
 
6
    setlocale( LC_TIME, "de_DE" );
7
 
8
    require_once  "Date/Calc.php";
9
    require_once  "Weban_Smarty.class.php";
10
 
11
    if ( empty($_GET['date']) || !preg_match('!^\d{4}\-\d{1,2}\-\d{1,2}$!',
12
        $_GET['date']) )
13
    {
14
        $date = Date_Calc::dateNow( "%Y-%m-%d" );
15
    }
16
    else
17
    {
18
        $date = $_GET['date'];
19
    }
20
 
21
    $month = substr( $date, 5, 2 );
22
    $year = substr( $date, 0, 4 );
23
 
24
    $cal_array = Date_Calc::getCalendarMonth( $month, $year,
25
        "%Y-%m-%d" );
26
 
27
    $GLOBALS["ui"] = new Smarty;
28
    $GLOBALS["ui"]->compile_dir = $_SERVER["DOCUMENT_ROOT"] . "/templates_c/";
29
    $GLOBALS["ui"]->compile_id = "settings";
30
    $GLOBALS["ui"]->use_sub_dirs = true;
31
    $GLOBALS["ui"]->assign( 'cal_array', $cal_array );
32
    $GLOBALS["ui"]->assign( 'curr_date', $date );
33
    $GLOBALS["ui"]->assign( 'type', $_REQUEST['type'] );
34
    $theme = ( isset($_REQUEST['theme']) && is_dir($GLOBALS["ui"]->
35
        template_dir . '/' . $_REQUEST['theme']) ) ? $_REQUEST['theme'] :
36
        'default';
37
 
38
    $GLOBALS["ui"]->assign( 'theme', $theme );
39
    $month_names = get_month_names( '%b' );
40
    // fix array index numbers
41
    array_unshift( $month_names, 'foo' );
42
    array_shift( $month_names );
43
    $GLOBALS["ui"]->assign( 'month_names', $month_names );
44
    $GLOBALS["ui"]->assign( 'month_vals', array('01', '02', '03', '04', '05',
45
        '06', '07', '08', '09', '10', '11', '12') );
46
 
47
    $GLOBALS["ui"]->assign( 'last_month', Date_Calc::beginOfPrevMonth(1, $month,
48
        $year, "%Y-%m-%d") );
49
    $GLOBALS["ui"]->assign( 'next_month', Date_Calc::beginOfNextMonth(1, $month,
50
        $year, "%Y-%m-%d") );
51
    $GLOBALS["ui"]->assign( 'last_year', Date_Calc::dateFormat(1, $month, $year -
52
        1, "%Y-%m-%d") );
53
    $GLOBALS["ui"]->assign( 'next_year', Date_Calc::dateFormat(1, $month, $year +
54
        1, "%Y-%m-%d") );
55
 
56
    $GLOBALS["ui"]->register_modifier( 'safe_date_format',
57
        'datepick_date_format' );
58
 
59
    $GLOBALS["ui"]->display( "$theme/index.tpl" );
60
 
61
    function get_month_names( $format = '%B' )
62
    {
63
        for ( $i = 1; $i < 13; $i++ )
64
        {
65
            $months[$i - 1] = strftime( $format, mktime(0, 0, 0, $i, 1,
66
                2001) );
67
        }
68
        return ( $months );
69
    }
70
 
71
    function datepick_date_format( $date, $format )
72
    {
73
        $date_array = explode( '-', $date );
74
        return Date_Calc::dateFormat( $date_array[2], $date_array[1],
75
            $date_array[0], $format );
76
    }
77
 
78
?>