Active Calendar

Active Calendar

Active Calendar is a PHP class that generates calendars as HTML tables (XHTML-Valid). It can produce static calendars without any links or calendars with navigation controls, a date picker control, event days and content with event URLs, and linkable days (optionally URL or JavaScript). The layout can be configured using CSS, and JavaScript is not required. The supported dates (on systems using a 32-bit signed integer Unix time_t) are: 1902-2037 (Unix) and 1971-2037 (Windows), when using the default PHP native date functions, and 100-3000 and later, when using the ADOdb Date Library.

Active Calendar is an open source project, licensed under the LGPL.

Features

The calendars created by this class:

* can be static (without any links)
* can optionally have navigation controls
* can optionally have a date picker control
* can optionally have linkable days (URL or javascript)
* can optionally have 'event days' with 'event links' and own layout
* can optionally have 'event content' with 'links' and own layout
* support different GMT zones for the current date calculation
* support month and day names, depending on your language
* can be configured using CSS
* do not require Javascript to be displayed or navigated (server side generation)
* can be generated with just 2-3 lines of code

Active Calendar is based on the PHP native date functions (default) and supports optionally the [http://phplens.com/phpeverywhere/adodb_date_library ADOdb Date Library] .

Supported dates (on systems using a 32-bit signed integer Unix time_t):
*Using PHP native date functions: 1902 - 2037 (UNIX) and 1971 - 2037 (Windows)
*Using ADOdb Date Library: 100 - 3000 and later [limited by the computation time of adodb_mktime()] on both UNIX and Windows. To use the ADOdb Date Library just include it in your scripts. The Active Calendar class will use the library functions automatically.

Usage

Basic methods overview

*

$cal = new activeCalendar( [$year,$month,$day,$gmt_zone] );
Create first a new object of the class. The parameters $year, $month and $day are optional. If these parameters are not set, the current year, month and day will be passed to the program. The parameter $year should have the form "yyyy" e.g. "2005" or "1996", the parameter $month should have the form "m" e.g. "1" for January or "10" for October and the parameter $day should have the form "d" e.g. "4" for the 4th month day or "24" for the 24th month day. So for the date e.g. 7th January 2005 please set $cal = new activeCalendar("2005","1","7"). The parameter $gmt_zone is optional as well. Use this parameter to set the GMT (Greenwich Mean Time) zone for the current date calculation (e.g 9 for Osaka Japan, 2 for Athens Greece, - 5 for New York USA). If $gmt_zone is not set, the server local time will be used.
*
$cal->enableMonthNav( [$link,$arrowBack,$arrowForw] );
Call this method, if you want the generated calendar to have month navigation controls (e.g "previous month" and "next month"). The parameter $link is optional. You can use this parameter to set the URL for the calendar links (e.g "mycalendar.php" or "mycalendar.php?mode=4&item=test", if you need more complex urls). You should modify the private method mkUrl(), if you want to change the general structure of the generated links. The parameters $arrowBack and $arrowForw are optional as well: they set other month navigation controls, than the ones set in the configuration (an image link can be set too).
*
$cal->enableYearNav( [$link,$arrowBack,$arrowForw] );
Call this method, if you want the generated calendar to have year navigation controls (e.g "previous year" and "next year"). The parameter $link is optional. You can use this parameter to set the URL for the calendar links (e.g "mycalendar.php" or "mycalendar.php?mode=4&item=test", if you need more complex urls). You should modify the private method mkUrl(), if you want to change the general structure of the generated links. The parameters $arrowBack and $arrowForw are optional as well: they set other year navigation controls, than the ones set in the configuration (an image link can be set too).
*
$cal->enableDatePicker( [$startYear,$endYear,$link,$button] );
Call this method, if you want the generated month calendar to have a date picker control. The parameters $startYear and $endYear define the range of the years, that can be selected (e.g $startYear=2000, $endYear=2010). This range is limited by the private class variables $startYear and $endYear. Please modify them according to your configuration. The parameter $link is optional. You can use this parameter to set the URL for the calendar links (e.g "mycalendar.php" or "mycalendar.php?mode=4&item=test", if you need more complex urls). You should modify the private method mkUrl(), if you want to change the general structure of the generated links. The parameter $button is optional as well: it sets some other value for the date picker submit button, than the one set in the configuration.
*
$cal->enableDayLinks( [$link,$javaScript] );
Call this method, if you want the generated calendar to have linkable dates. The parameter $link is optional. You can use this parameter to set the URL for the calendar links (e.g "mycalendar.php" or "mycalendar.php?mode=4&item=test", if you need more complex urls). You should modify the private method mkUrl(), if you want to change the general structure of the generated links. The parameter $javaScript is optional as well. You can use this parameter to set a JavaScript function instead of a URL for the calendar links. So if you set $cal->enableDayLinks(false,"selectDate"), this link will be created on e.g. 27 May 2007: ..href="javascript:selectDate(2007,5,27)".. The content of the Javascript function 'selectDate' will not be created by the class. You should develop it according to your needs.
*
$cal->setMonthNames($monthNamesArray);
Call this method, if you want the class generate different names for the calendar months, than the ones set in the configuration. The parameter $monthNamesArray must be an array of 12 month names starting with January.
*
$cal->setDayNames($dayNamesArray);
Call this method, if you want the class generate different names for the calendar weekdays, than the ones set in the configuration. The parameter $dayNamesArray must be an array of 7 day names starting with Sunday.
*
$cal->setEvent($year,$month,$day, [$id,$eventUrl] );
Call this method, if you want the class to create an HTML td class=$id on the date specified by the parameters $year, $month, $day. You can configure every 'event date' in your CSS, so that it would have e.g. a different background color. The parameter $id is optional. If you do not set an $id, a default HTML class='event' will be generated. The parameter $eventUrl is optional as well: If you set an $eventUrl, an event specific link (..href='$eventUrl'..) will be generated on the 'event date', even if the method $cal->enableDayLinks($link) was not called.
*
$cal->setEventContent($year,$month,$day,$content, [$contentUrl,$id] );
Call this method, if you want the class to create a new HTML table within the date specified by the parameters $year, $month, $day. The parameter $content can be a string or an array. If $content is a string, then the new generated table will contain one row with the value of $content. If it is an array, the generated table will contain as many rows as the array length and each row will contain the value of each array item. The parameter $contentUrl is optional: If you set a $contentUrl, an event content specific link (..href='$contentUrl'..) will be generated in the 'event content' table row(s), even if the method $cal->enableDayLinks($link) was not called. The parameter $id is optional as well: if you set an $id, an HTML class='$id' will be generated for each event content (default: 'eventcontent').
*
$cal->showMonth( [$showNoMonthDays] );
This method will generate the HTML string of the month calendar. You can display the calendar by "print $cal->showMonth()". This method calls several private class functions, that create each tr tag of the generated table. So if you would like to change the table structure, you could simply modifiy the order, that these private functions are called (mkMonthHead() must remain first and mkMonthFoot() must remain last though). The parameter $showNoMonthDays is optional: if it is set true, days that do not belong to the current month will be displayed in the calendar (default: false). Please note that these days will not contain any events or event contents!.
*
$cal->showYear( [$columns] );
This method will generate the HTML string of the year calendar. You can display the calendar by "print $cal->showYear()". This method calls several private class functions, that create each tr tag of the generated table. So if you would like to change the table structure, you could simply modify the order, that these private functions are called (mkYearHead() must remain first and mkYearFoot() must remain last though). The parameter $columns is optional: it sets the number of the generated months in each row of the year calendar (default: 4).

Code examples

*Current month static calendar

showMonth(true); // previous and next month days will be generated too?>

*Current month calendar with navigation
enableMonthNav($myurl);echo $cal->showMonth();?>

*Current month calendar with date picker
enableDatePicker(2000,2010,$myurl); // year range: 2000-2010echo $cal->showMonth();?>

*Month calendar with day links
enableDayLinks($myurl);echo $cal->showMonth();?>

*Month calendar with multiple 'event days'
setEvent("2007","11","17","meeting"); //it will create a class="meeting"$cal->setEvent("2007","11","7","birthday"); //it will create a class="birthday"//The following will create a class="myevent" and an $cal->setEvent("2007","11","20","myevent","myevent.html");echo $cal->showMonth();?>

*Current year static calendar
showYear(2); // 2 months in each row?>

*Current year calendar with navigation
enableYearNav($myurl);echo $cal->showYear();?>

*Year calendar with day links
enableDayLinks($myurl);echo $cal->showYear();?>

*Year calendar with multiple 'event days'
setEvent("2007","1","24","meeting");$cal->setEvent("2007","5","12","birthday");$cal->setEvent("2007","6","24","event");$cal->setEvent("2007","6","25");echo $cal->showYear();?>

*Year calendar with multiple 'event contents'
setEventContent("2007","1","24","meeting");$cal->setEventContent("2007","5","12","birthday");$cal->setEventContent("2007","6","24","Google","http://www.google.com");$multipleLinesEvent=array("Title: News","Time: 16.00","Status: ok");$cal->setEventContent("2007","6","25",$multipleLinesEvent);echo $cal->showYear();?>

External links

* [http://freshmeat.net/redir/activecalendar/53267/url_homepage/ http://www.micronetwork.de/activecalendar/] : Project documentation, examples and source code


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • Calendar of 2003 — ▪ 2004 January So long as there is a single Brazilian brother or sister going hungry, we have ample reason to be ashamed of ourselves. Lula, in his inaugural address as president of Brazil, January 1 January 1       The Socialist Lula (Luiz… …   Universalium

  • Calendar of 1995 — ▪ 1996 January January 1       Cardoso assumes office       Having won some 54% of the ballots cast in the October 1994 election, Fernando Cardoso took the oath of office as president of Brazil. As chief executive of South America s largest… …   Universalium

  • Calendar of 1998 — ▪ 1999 January January 1       At the stroke of the new year, the Russian ruble is worth a thousand times less than before as three zeros are removed from its value; about six new rubles equal one U.S. dollar.       Foreign Minister David Levy… …   Universalium

  • Calendar of 2002 — ▪ 2003 January I will not wait on events while dangers gather. I will not stand by as peril draws closer and closer. The United States of America will not permit the world s most dangerous regimes to threaten us with the world s most destructive… …   Universalium

  • Calendar of 1994 — ▪ 1995 JANUARY JANUARY 1       Mexican peasants revolt in Chiapas. A group of uniformed Mexican peasants, calling themselves the Zapatista National Liberation Army (EZLN), caught the government completely off guard when they attacked and captured …   Universalium

  • Calendar of 1996 — ▪ 1997 JANUARY JANUARY 1       King Fahd cedes power       Still experiencing the effects of a stroke suffered in November 1995, Saudi Arabia s King Fahd, who also held the post of prime minister, ceded temporary power to Crown Prince Abdullah,… …   Universalium

  • Calendar of 2001 — ▪ 2002 January America has never been united by blood or birth or soil. We are bound by ideals that move us beyond our backgrounds, lift us above our interests and teach us what it means to be citizens. Every child must be taught these principles …   Universalium

  • Hindu calendar — The Hindu calendar used in ancient times has undergone many changes in the process of regionalization, and today there are several regional Indian calendars, as well as an Indian national calendar. Most of these calendars are inherited from a… …   Wikipedia

  • Gregorian calendar — For the calendar of religious holidays and periods, see Liturgical year. For this year s Gregorian calendar, see Common year starting on Saturday. 2011 in other calendars Gregorian calendar 2011 MMXI …   Wikipedia

  • World Calendar — The World Calendar is a proposed reform of the Gregorian calendar created by Elisabeth Achelis of Brooklyn, New York in 1930.FeaturesThe World Calendar is a 12 month, perennial calendar with equal quarters. It is perennial, or perpetual, because… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”