navigatie-balk-voor-een-kalender

Gesponsorde koppelingen

PHP script bestanden

  1. navigatie-balk-voor-een-kalender

« Lees de omschrijving en reacties

<!-- navigation.php -->

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
/*        Copyright Notice    

THIS NOTICE MAY NOT BE DELETED

Date Navigation Row

Author:        Tessa Bakker
E-mail:        tess A T shoekje D O T NL
Version:            1.0.2
Release:            2005/01/30
Language:            all (dutch by default)
Script:        PHP, MySQL, xHTML

        End Copyricht Notice    */

/* EXPLANATION OF SCRIPT:    This script gives 7 buttons with can be used for browsing
                            a day, month or year backwards or forwards and a button to return to the date of today.
                            All the buttons are XHTML valid and useable for CSS
                            Users can't browse before first mysql date and after today
                            To remove the previous function change de if-statements with: $mysqlFirstLocalDate or date($_LOCAL_DATE['short']);

        Posibility to use this script:
        
        < ?php require ("dutch.php"); ? >
        <table>
            <tr>... rows with dates for calendar ...</tr>
            < ?php require ("navigation.php";) ? >
        </table>
        
        Your mySQL database needs a table with a 'date' row using the type: date
        
        FOR date explainations visit:
        php date():        http://www.php.net/manual/nl/function.date.php
        php strftime:        http://www.php.net/manual/nl/function.strftime.php
        mysql DATE_FORMAT():    http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

*/

//basic settings

$actionurl = "pagina.php?date="; //link from the page that has to be loaded with the new date
$table = "dairy";

//database settings
$server = 'localhost';
$username= 'username';
$password= 'wachtwoord';
$db = 'naam database';
$connectie = mysql_connect($server,$username,$password)or die (mysql_error());
mysql_select_db($db,$connectie)or die (mysql_error());

/**        Get the date from a send link    **/
if (empty($_GET['date'])){    //if 'date' is empty; use the date of today
    $day = date("d");
    $month = date("m");
    $year = date ("Y");
}
else{
    $givenDate = ($_GET['date']);
    $splitDate = explode ('-',$givenDate);
    $day = $splitDate[$_LOCAL_DATE_PLACE['day']];
    $month = $splitDate[$_LOCAL_DATE_PLACE['month']];
    $year = $splitDate[$_LOCAL_DATE_PLACE['year']];
}


/**        Look into the MySQL database for start and end date        **/
$queryFirstDate = "SELECT DATE_FORMAT(date,'%Y%m%d') as mathdate, DATE_FORMAT(date,'".$_LOCAL_DATE_MYSQL['short']."') as localdate FROM ".$table." ORDER BY date ASC LIMIT 0,1";
$resultFirstDate = mysql_query($queryFirstDate) or die (mysql_error());
$mathdate = mysql_fetch_row($resultFirstDate);
$mysqlFirstDate = $mathdate[0];
$mysqlFirstLocalDate = $mathdate[1];

//day -1
if ($mysqlFirstDate < date("Ymd", mktime(0, 0, 0, $month, $day, $year)))
{

    if (date("Ymd", mktime(0, 0, 0, $month, $day, $year)) > date("Ymd"))
    {

        $cellPrevDay = date($_LOCAL_DATE['short']);
    }

    else
    {
        $cellPrevDay = date($_LOCAL_DATE['short'], mktime(0, 0, 0, $month, $day-1, $year));
    
        //month-1
        if ($mysqlFirstDate <= date("Ymd", mktime(0, 0, 0, $month-1, $day, $year)))
        {

            if (date("Ymd", mktime(0, 0, 0, $month, $day, $year)) > date("Ymd"))
            {

                $cellPrevMonth = date($_LOCAL_DATE['short']);
            }

            else
            {
                $cellPrevMonth = date($_LOCAL_DATE['short'], mktime(0, 0, 0, $month-1, $day, $year));
            
                //year-1
                if ($mysqlFirstDate <= date("Ymd", mktime(0, 0, 0, $month, $day, $year-1)))
                {

                    if (date("Ymd", mktime(0, 0, 0, $month, $day, $year)) > date("Ymd"))
                        $cellPrevYear = date($_LOCAL_DATE['short']);
                    else
                        $cellPrevYear = date($_LOCAL_DATE['short'], mktime(0, 0, 0, $month, $day, $year-1));
                }

                elseif (!($mysqlFirstLocalDate == $cellPrevMonth))
                {

                        $cellPrevYear = $mysqlFirstLocalDate;
                }
            }
        }

        elseif (!($mysqlFirstLocalDate == $cellPrevDay))
        {

            $cellPrevMonth = $mysqlFirstLocalDate;
        }
    }
}


//day +1
if (date("Ymd") >= date("Ymd", mktime( 0, 0, 0, $month, $day+1, $year)))
{

    if (date("Ymd", mktime(0, 0, 0, $month, $day, $year)) < $mysqlFirstDate)
    {

        $cellNextDay = $mysqlFirstLocalDate;
    }

    else
    {
        $cellNextDay = date($_LOCAL_DATE['short'],mktime(0, 0, 0, $month, $day+1, $year));
    
        //month +1
        if (date("Ymd") >= date("Ymd", mktime( 0, 0, 0, $month+1, $day, $year)))
        {

            if (date("Ymd", mktime(0, 0, 0, $month, $day, $year)) < $mysqlFirstDate)
            {

                $cellNextMonth = $mysqlFirstLocalDate;
            }

            else
            {
                $cellNextMonth = date($_LOCAL_DATE['short'],mktime(0, 0, 0, $month+1, $day, $year));
            
                //year +1
                if (date("Ymd") >= date("Ymd", mktime( 0, 0, 0, $month, $day, $year+1)))
                {

                    if (date("Ymd", mktime(0, 0, 0, $month, $day, $year)) < $mysqlFirstDate)
                        $cellNextYear = $mysqlFirstLocalDate;
                    else
                        $cellNextYear = date($_LOCAL_DATE['short'],mktime(0, 0, 0, $month, $day, $year+1));
                }

                elseif(date("Ymd",mktime(0, 0, 0, $month+1, $day, $year)) < date("Ymd"))
                {

                    $cellNextYear = date($_LOCAL_DATE['short']);
                }
            }
        }

        elseif(date("Ymd",mktime(0, 0, 0, $month, $day+1, $year)) < date("Ymd"))
        {

            $cellNextMonth = date($_LOCAL_DATE['short']);
        }
    }
}


/**        replace cell information with xhtml and css functions    **/
if (isset($cellPrevYear))
    $cellPrevYear = "<a class=\"apyear\" href=\"".$actionurl.$cellPrevYear."\" title=\"".$_LANGUAGE['goto']."&nbsp;".$cellPrevYear."\"><span class=\"extnav\">".$_LANGUAGE['prev(year)']."&nbsp;</span><span class=\"spyear\">".$_LANGUAGE['year']."</span></a>\n";
if (isset($cellPrevMonth))
    $cellPrevMonth = "<a class=\"apmonth\" href=\"".$actionurl.$cellPrevMonth."\" title=\"".$_LANGUAGE['goto']."&nbsp;".$cellPrevMonth."\"><span class=\"extnav\">".$_LANGUAGE['prev(month)']."&nbsp;</span><span class=\"spmonth\">".$_LANGUAGE['month']."</span></a>\n";
if (isset($cellPrevDay))
    $cellPrevDay = "<a class=\"apday\" href=\"".$actionurl.$cellPrevDay."\" title=\"".$_LANGUAGE['goto']."&nbsp;".$cellPrevDay."\"><span class=\"extnav\">".$_LANGUAGE['prev(day)']."&nbsp;</span><span class=\"spday\">".$_LANGUAGE['day']."</span></a>\n";    
if (isset($cellNextYear))
    $cellNextYear = "<a class=\"anyear\" href=\"".$actionurl.$cellNextYear."\" title=\"".$_LANGUAGE['goto']."&nbsp;".$cellNextYear."\"><span class=\"extnav\">".$_LANGUAGE['next(year)']."&nbsp;</span><span class=\"snyear\">".$_LANGUAGE['year']."</span></a>\n";
if (isset($cellNextMonth))
    $cellNextMonth = "<a class=\"anmonth\" href=\"".$actionurl.$cellNextMonth."\" title=\"".$_LANGUAGE['goto']."&nbsp;".$cellNextMonth."\"><span class=\"extnav\">".$_LANGUAGE['next(month)']."&nbsp;</span><span class=\"snmonth\">".$_LANGUAGE['month']."</span></a>\n";
if (isset($cellNextDay))
    $cellNextDay = "<a class=\"anday\" href=\"".$actionurl.$cellNextDay."\" title=\"".$_LANGUAGE['goto']."&nbsp;".$cellNextDay."\"><span class=\"extnav\">".$_LANGUAGE['next(day)']."&nbsp;</span><span class=\"snday\">".$_LANGUAGE['day']."</span></a>\n";    
    
/**     create the xhtml navigation table    **/

//creating proper html with a css-style

echo "<html>\n<head>\n<title>Example</title>\n<style type=\"text/css\" media=\"all\">\n@import \"http://location/of/your/css/file.css";
\n</style>\n</head>\n<body>\n";

//table
echo "
<table>\n"; // << you can delete this is you put you navigation bar as a hole row into your calendar
echo "
<tr class=\"navigation\"><td class=\"pyear\">".$cellPrevYear."</td><td class=\"pmonth\">".$cellPrevMonth."</td><td class=\"pday\">".$cellPrevDay."</td><td class=\"goto2day\"><a class=\"agoto2day\" href=\"".$actionurl.date($_LOCAL_DATE['short'])."\" title=\"".$_LANGUAGE['goto']."&nbsp;".$_LANGUAGE['today']."\"><span class=\"sgoto2day\">".$_LANGUAGE['today']."</span></a></td><td class=\"nday\">".$cellNextDay."</td><td class=\"nmonth\">".$cellNextMonth."</td><td class=\"nyear\">".$cellNextYear."</td></tr>\n";
echo "</table>\n"; // << you can delete this is you put you navigation bar as a hole row into your calendar
echo "</body>\n</html>";
?>


<!-- dutch.php -->

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
/**        Start Date Settings        **/
setlocale (LC_ALL, 'nld_nld');         //Local settings Windows Platform
setlocale (LC_ALL, 'nl_NL');        //Local settings UNIX/Linux Platform

$_LOCAL_DATE['medium'] =             'd-m-Y';    //date()
$_LOCAL_DATE['short'] =                'd-m-Y';    //date()
$_LOCAL_DATE_MYSQL['short'] =        '%d-%m-%Y';    //DATE_FORMAT()
$_LOCAL_DATE_EREG['short'] =        '([0-9]{2})-([0-9]{2})-([0-9]{4})'; //change the number between the {}
$_LOCAL_DATE_PLACE['day'] =            '0'; //0 = first place, 2= last place
$_LOCAL_DATE_PLACE['month'] =        '1';
$_LOCAL_DATE_PLACE['year'] =        '2';
/**        End Date Settings        **/

/**        Begin Translations for the Navigation Menu    **/

$_LANGUAGE['today'] =                 'vandaag';
$_LANGUAGE['year'] =                'jaar';
$_LANGUAGE['month'] =                'maand';
$_LANGUAGE['day'] =                    'dag';
$_LANGUAGE['prev(year)'] =            'vorig';
$_LANGUAGE['prev(month)'] =            'vorige';
$_LANGUAGE['prev(day)'] =            'vorige';
$_LANGUAGE['next(year)'] =            'volgend';
$_LANGUAGE['next(month)'] =            'volgende';
$_LANGUAGE['next(day)'] =            'volgende';
$_LANGUAGE['goto'] =                'Ga naar';
/**        End Translations for the Navigation Menu    **/
?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.