Active Calendar is PHP Class, that generates calendars (year, month or week view) as a HTML Table (XHTML-Valid).
This snippet integrates the Active Calendar with the Etomite CMS. You must have a working Active Calendar “installation” for this snippet to work. The calendars created by this snippet:
-
can be static (without any links)
-
can optionally have navigation controls
-
can optionally have a date picker control
-
can optionally have linkable days
-
support different GMT zones for the current date calculation
-
support of custom month and day names
-
can be configured using CSS
-
do not require Javascript to be displayed or navigated (server side generation)
My tv page is using this script (and overLIB).
# Required settings ## Database settings $tblname=isset($tblname)? $tblname: "***"; // the name of your MySQL Database Table $tblDateName=isset($tblDateName)? $tblDateName: "***"; // the name of your MySQL Table Date Field (datetime NOT NULL default '0000-00-00 00:00:00') ex. "NOW()" $tblContent=isset($tblContent)? $tblContent: "***"; // the name of your MySQL Table Content Field (char(250) NOT NULL default '') ex. "Google" $tblLink=isset($tblLink)? $tblLink: "***"; // the name of your MySQL Table Link Field (char(250) NOT NULL default '') ex. "http://www.google.com/" ## Paths $path_to_ac = "activecalendar/source/activecalendar.php"; // Path to activecalendar.php $path_to_acw = "activecalendar/source/activecalendarweek.php"; // Path to activecalendarweek.php #General settings ## Show Year, Month or Week $show = isset($show)? $show: "m"; // m = Month, y=Year, w=Week ## GMT zone $gmt_zone = isset($gmt_zone)? $gmt_zone: ""; // If $gmt_zone is not set, the server local time will be used. Set like ex 9 for Osaka Japan, 2 for Athens Greece, -5 for New York USA. ## Week numbers $enableWeekNum = isset($enableWeekNum)? $enableWeekNum: "false"; // Set to true to enable $WeekNumtitle = isset($WeekNumtitle)? $WeekNumtitle: "Week"; // set the title of the generated column. $WeekNumlink = isset($WeekNumlink)? $WeekNumlink: ""; // make the generated week numbers linkable and to set the url for the links ## FirstWeekDay $FirstWeekDay = isset($FirstWeekDay)? $FirstWeekDay: "1"; // '0' -> Sunday , '1' -> Monday # Calendar Navigation variables $myurl = isset($myurl)? $myurl: $etomite->documentIdentifier; // the links url is this page $enableDatePicker = isset($enableDatePicker)? $enableDatePicker: "false"; // Set to true to enable ## Date Picker Settings $DatePickerstartYear = isset($DatePickerstartYear)? $DatePickerstartYear: "1971"; $DatePickerendYear = isset($DatePickerendYear)? $DatePickerendYear: "2037"; $DatePickerlink = isset($DatePickerlink)? $DatePickerlink: "$myurl"; // the links url is this page $DatePickerbutton = isset($DatePickerbutton)? $DatePickerbutton: ""; //Name of the button # Month Settings ## Navigation $enableMonthNav = isset($enableMonthNav)? $enableMonthNav: "true"; // Set to false to enable ### MonthNav Settings $MonthNavlink = isset($MonthNavlink)? $MonthNavlink: "$myurl"; // the links url is this page $MonthNavarrowBack = isset($MonthNavarrowBack)? $MonthNavarrowBack: ""; //set other month navigation controls, than the ones set in the configuration (an image link can be set too). $MonthNavarrowForw = isset($MonthNavarrowForw)? $MonthNavarrowForw: ""; //set other month navigation controls, than the ones set in the configuration (an image link can be set too). # Year Settings $columns = isset($columns)? $columns: "4"; //sets the number of the generated months in each row of the year calendar. $startMonth = isset($startMonth)? $startMonth: ""; //sets the starting month in the year calendar (default: January). ## Navigation $enableYearNav = isset($enableYearNav)? $enableYearNav: "true"; // Set to false to enable ### YearNav Settings $YearNavlink = isset($YearNavlink)? $YearNavlink: "$myurl"; // the links url is this page $YearNavarrowBack = isset($YearNavarrowBack)? $YearNavarrowBack: ""; //set other year navigation controls, than the ones set in the configuration (an image link can be set too). $YearNavarrowForw = isset($YearNavarrowForw)? $YearNavarrowForw: ""; //set other year navigation controls, than the ones set in the configuration (an image link can be set too). # Week Settings $numberOfWeeks = isset($numberOfWeeks)? $numberOfWeeks: "1"; // it sets the number of the generated week rows # CSS Settings $eventID = isset($eventID)? $eventID: "event"; // sets the name of the generated HTML class on the event day (css layout) # Language settings $monthNamesArray = array("January","February","March","April","May","June","July","August","September","October","November","December"); //must be an array of 12 month names starting with January. $dayNamesArray = array("Sun","Mon","Tue","Wed","Thu","Fri","Sat"); //must be an array of 7 day names starting with Sunday. ### No more editing ### /* ******************************************************************************** Connect to Database and send the query ******************************************************************************** */ $sqlID=$etomite->getIntTableRows($fields="UNIX_TIMESTAMP(".$tblDateName.") AS ".$tblDateName.", ".$tblContent.", ".$tblLink."", $from="$tblname", $where="", $sort="", $dir="ASC", $limit="", $push=false, $addPrefix=false); /* ******************************************************************************** Calendar Navigation variables ******************************************************************************** */ $yearID=isset($yearID)? $yearID: false; // GET variable for the year (set in Active Calendar Class), init false to display current year $monthID=isset($monthID)? $monthID: false; // GET variable for the month (set in Active Calendar Class), init false to display current month $dayID=isset($dayID)? $dayID: false; // GET variable for the day (set in Active Calendar Class), init false to display current day extract($_GET); /* ******************************************************************************** Create a calendar object ******************************************************************************** */ if ($show == "w") { require_once($path_to_acw); $cal=new activeCalendarWeek($yearID,$monthID,$dayID,$gmt_zone); }else{ require_once($path_to_ac); $cal=new activeCalendar($yearID,$monthID,$dayID,$gmt_zone); } if ($enableWeekNum == "true") {$cal->enableWeekNum($WeekNumtitle,$WeekNumlink);} if ($enableDatePicker == "true") {$cal->enableDatePicker($DatePickerstartYear,$DatePickerendYear,$DatePickerlink,$DatePickerbutton);} $cal->setFirstWeekDay($FirstWeekDay); $cal->setMonthNames($monthNamesArray); $cal->setDayNames($dayNamesArray); /* ******************************************************************************** Gets all dates from your database and set the calendar events ******************************************************************************** */ while ([email protected]_fetch_array($sqlID, MYSQL_BOTH)){ $mysqlDay=date("j",$data[$tblDateName]); // makes a day out of the database date $mysqlMonth=date("n",$data[$tblDateName]); // makes a month out of the database date $mysqlYear=date("Y",$data[$tblDateName]); // makes a year out of the database date $mysqlContent=$data[$tblContent]; // gets the event content $mysqlLink=$data[$tblLink]; // gets the event link $cal->setEvent($mysqlYear,$mysqlMonth,$mysqlDay,$eventID); // set the event, if you want the whole day to be an event $cal->setEventContent($mysqlYear,$mysqlMonth,$mysqlDay,$mysqlContent,$mysqlLink); // set the event content and link } if ($show == "m") { if ($enableMonthNav == "true") {$cal->enableMonthNav($MonthNavlink,$MonthNavarrowBack,$MonthNavarrowForw);} $output .= $cal->showMonth(); }elseif ($show == "y") { if ($enableYearNav == "true") {$cal->enableYearNav($YearNavlink,$YearNavarrowBack,$YearNavarrowForw);} $output .= $cal->showYear($columns,$startMonth); }elseif ($show == "w") { $output .= $cal->showWeeks($numberOfWeeks); }else{ $output .= "You should show someting, set show to m for month, y for year or w for week.";} return $output;
This entry was posted in Etomite CMS. Bookmark the permalink