summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Calendar.php477
-rw-r--r--add_calendar.php123
-rw-r--r--admin/admin_calendar_inc.php55
-rw-r--r--admin/index.php4
-rw-r--r--admin/schema_inc.php107
-rw-r--r--bit_setup_inc.php9
-rw-r--r--calendar_lib.php328
-rw-r--r--icons/calendar.gifbin0 -> 122 bytes
-rw-r--r--icons/calendar2.gifbin0 -> 127 bytes
-rw-r--r--icons/calendar3.gifbin0 -> 355 bytes
-rw-r--r--icons/calendar4.gifbin0 -> 235 bytes
-rw-r--r--icons/day.gifbin0 -> 310 bytes
-rw-r--r--icons/month.gifbin0 -> 299 bytes
-rw-r--r--icons/pkg_calendar.pngbin0 -> 2786 bytes
-rw-r--r--icons/week.gifbin0 -> 315 bytes
-rw-r--r--icons/year.gifbin0 -> 313 bytes
-rw-r--r--index.php529
-rw-r--r--modules/index.php6
-rw-r--r--modules/mod_calendar.tpl137
-rw-r--r--templates/add_calendars.tpl109
-rw-r--r--templates/admin_calendar.tpl40
-rw-r--r--templates/calendar.tpl458
-rw-r--r--templates/calendar_box.tpl13
-rw-r--r--templates/index.php6
-rw-r--r--templates/menu_calendar.tpl10
-rw-r--r--templates/menu_calendar_admin.tpl6
26 files changed, 2417 insertions, 0 deletions
diff --git a/Calendar.php b/Calendar.php
new file mode 100644
index 0000000..d4497e5
--- /dev/null
+++ b/Calendar.php
@@ -0,0 +1,477 @@
+<?php
+// class_calendar.php EXTENDS: None Abstract: No.
+//
+// The calendar class provides basic functions to build calendars,
+// like validating dates, getting day of week etc...
+//
+// Constructor:
+//
+// new calendar('lan') : Language for the calendar valid options: (ar,br,en)
+// Tiki: doesn't use the language translation, the translation is done at the calling level
+//
+// Methods:
+//
+// validDate($day,$month,$year) : Returns true if date is valid.
+// validTime($hour,$minute,$second) : Returns true if time is valid.
+// isLeap($year) : true/false
+// nameOfMonth($monthnum,[$lan]) : Name of the month, language is optional.
+// daysInMonth($monthnum,$year) : Number of days in month for the given year.
+// dayOfWeek($day,$month,$year) : Day of week in 1-7 format.
+// dayOfWeekStr($day,$month,$year,[$lan]) : String representing of day of week, language optional.
+// getDisplayMatrix($day,$month,$year) : Builds a 425 (7x6) matrix where
+// representing the calendar, the actual day appears as +NN
+// buildMonthBox($name,$m) : Builds an HTML select box for months,the second argument indicates selected month
+// buildYearBox($name,$ny) : Builds a select box for years
+// buildDayOfWeekBox($name,$mul=false,$d=1): Builds a select box for days of the week, multiple selection may be allowed
+// buildDayBox($name,$d,$m,$y) : Bulds a select box for days
+// buildHourBox($name,$h) : Builds a select box for hours
+// buildMinBox($name,$h) : Builds a select box for minutes
+// buildIntBox($name,$min,$max,$inter,$def=0) : Generic Select box indicating minimum, maximum, interval and default values
+// buildIntBoxMul($name,$min,$max,$inter,$def=0,$cu=0) : Idem but allowing multiple selections
+class Calendar {
+ var $lan;
+
+ function Calendar($lan = 'ar') {
+ $this->lan = $lan;
+ }
+
+ function validDate($d, $m, $y) {
+ return checkdate($m, $d, $y);
+ }
+
+ function buildYearBox($name, $ny) {
+ print ("<select name=\"$name\">");
+
+ print ("<option value=\"$ny\">$ny</option>");
+
+ for ($i = 0; $i < 10; $i++) {
+ $y = $ny + $i;
+
+ print ("<option value=\"$y\">$y</option>");
+ }
+
+ print ("</select>");
+ }
+
+ function buildMonthBox($name, $m) {
+ print ("<select name=\"$name\">");
+
+ for ($i = 0; $i < 12; $i++) {
+ $z = $i + 1;
+
+ if ($z < 10) {
+ $zst = '0' . $z;
+ } else {
+ $zst = $z;
+ }
+
+ $name = $this->nameOfMonth($z);
+
+ if ($z == $m) {
+ print ("<option value=\"$zst\" selected>$name</option>");
+ } else {
+ print ("<option value=\"$zst\">$name</option>");
+ }
+ }
+
+ print ("</select>");
+ }
+
+ function buildDayOfWeekBox($name, $mul = false, $d = 1) {
+ if ($mul) {
+ $st = 'multiple size="1"';
+ } else {
+ $st = '';
+ }
+
+ print ("<select name=\"$name\" $st>");
+
+ for ($i = 0; $i < 7; $i++) {
+ $z = $i + 1;
+
+ $dia = $this->dayOfWeekStrFromNo($z);
+
+ if ($z == $d) {
+ print ("<option value=\"$z\" selected>$dia</option>");
+ } else {
+ print ("<option value=\"$z\">$dia</option>");
+ }
+ }
+
+ print ("</select>");
+ }
+
+ function buildDayBox($name, $d, $m, $y) {
+ $cuantos = $this->daysInMonth($m, $y);
+
+ print ("<select name=\"$name\">");
+
+ for ($i = 0; $i < $cuantos; $i++) {
+ $z = $i + 1;
+
+ if ($z < 10) {
+ $zst = '0' . $z;
+ } else {
+ $zst = $z;
+ }
+
+ if ($z == $d) {
+ print ("<option value=\"$zst\" selected>$zst</option>");
+ } else {
+ print ("<option value=\"$zst\">$zst</option>");
+ }
+ }
+
+ print ("</select>");
+ }
+
+ function buildHourBox($name, $h) {
+ print ("<select name=\"$name\">");
+
+ for ($i = 0; $i < 24; $i++) {
+ if ($i < 10) {
+ $zst = '0' . $i;
+ } else {
+ $zst = $i;
+ }
+
+ if ($i == $h) {
+ print ("<option value=\"$zst\" selected>$zst</option>");
+ } else {
+ print ("<option value=\"$zst\">$zst</option>");
+ }
+ }
+
+ print ("</select>");
+ }
+
+ function buildMinBox($name, $m) {
+ print ("<select name=\"$name\">");
+
+ for ($i = 0; $i < 60; $i++) {
+ if ($i < 10) {
+ $zst = '0' . $i;
+ } else {
+ $zst = $i;
+ }
+
+ if ($i == $m) {
+ print ("<option value=\"$zst\" selected>$zst</option>");
+ } else {
+ print ("<option value=\"$zst\">$zst</option>");
+ }
+ }
+
+ print ("</select>");
+ }
+
+ function buildMinBoxI($name, $m = 60) {
+ print ("<select name=\"$name\">");
+
+ for ($i = 5; $i < 66; $i += 5) {
+ if ($i < 10) {
+ $zst = '0' . $i;
+ } else {
+ $zst = $i;
+ }
+
+ if ($i == $m) {
+ print ("<option value=\"$zst\" selected>$zst</option>");
+ } else {
+ print ("<option value=\"$zst\">$zst</option>");
+ }
+ }
+
+ print ("</select>");
+ }
+
+ function buildIntBox($name, $min, $max, $inter, $def = 0) {
+ print ("<select name=\"$name\">");
+
+ for ($i = $min; $i <= $max; $i += $inter) {
+ if ($i < 10) {
+ $zst = '0' . $i;
+ } else {
+ $zst = $i;
+ }
+
+ if ($i == $def) {
+ print ("<option value=\"$zst\" selected>$zst</option>");
+ } else {
+ print ("<option value=\"$zst\">$zst</option>");
+ }
+ }
+
+ print ("</select>");
+ }
+
+ function buildIntBoxMul($name, $min, $max, $inter, $def = 0, $cu = 0) {
+ print ("<select name=\"$name\" multiple size=\"$cu\">");
+
+ for ($i = $min; $i <= $max; $i += $inter) {
+ if ($i < 10) {
+ $zst = '0' . $i;
+ } else {
+ $zst = $i;
+ }
+
+ if ($i == $def) {
+ print ("<option value=\"$zst\" selected>$zst</option>");
+ } else {
+ print ("<option value=\"$zst\">$zst</option>");
+ }
+ }
+
+ print ("</select>");
+ }
+
+ function getDisplayMatrix($d, $m, $y) {
+ $dw = $this->dayOfWeek(1, $m, $y);
+
+ $cu = $this->daysInMonth($m, $y);
+ $hd = date('d');
+ $hm = date('m');
+ $hy = date('Y');
+
+ //Inicializo la matriz horrible...
+ for ($i = 0; $i < 42; $i++) {
+ $mat[$i] = ' ';
+ }
+
+ for ($j = 0; $j < $cu; $j++) {
+ $v = $j + 1;
+
+ $mat[$j + ($dw - 1)] = "$v";
+
+ if ($hm == $m && $hy == $y && $hd == $v) {
+ $mat[$j + ($dw - 1)] = '+' . $mat[$j + ($dw - 1)] . '';
+ }
+ }
+
+ return $mat;
+ }
+
+ function getPureMatrix($d, $m, $y) {
+ $dw = $this->dayOfWeek(1, $m, $y);
+
+ $cu = $this->daysInMonth($m, $y);
+
+ //Inicializo la matriz horrible...
+ for ($i = 0; $i < 42; $i++) {
+ $mat[$i] = ' ';
+ }
+
+ for ($j = 0; $j < $cu; $j++) {
+ $v = $j + 1;
+
+ $mat[$j + ($dw - 1)] = "$v";
+ }
+
+ return $mat;
+ }
+
+ function validTime($h, $m, $s) {
+ return (($h <= 24) && ($h >= 0) && ($m <= 60) && ($m >= 0) && ($s >= 0) && ($s <= 60));
+ }
+
+ // Returns true if the given year is 'leap' false if not. Year MUST use 4 digits!
+ function isLeap($year) {
+ if (($year % 4 == 0) && (($year % 100 <> 0) || ($year % 400 == 0))) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ // Returns the name of month in the given language.
+ function nameOfMonth($month, $lan = false) {
+ $month = ceil($month);
+
+ if (!$lan) {
+ $lan = $this->lan;
+ }
+
+ $ar = array(
+ '',
+ 'Enero',
+ 'Febrero',
+ 'Marzo',
+ 'Abril',
+ 'Mayo',
+ 'Junio',
+ 'Julio',
+ 'Agosto',
+ 'Setiembre',
+ 'Octubre',
+ 'Noviembre',
+ 'Diciembre'
+ );
+
+ $br = array(
+ '',
+ 'Janeiro',
+ 'Fevereiro',
+ 'Maro',
+ 'Abril',
+ 'Junho',
+ 'Julho',
+ 'Agosto',
+ 'Stembro',
+ 'Outubro',
+ 'Novembro',
+ 'Dezembro'
+ );
+
+ $en = array(
+ '',
+ 'January',
+ 'February',
+ 'March',
+ 'April',
+ 'May',
+ 'June',
+ 'July',
+ 'August',
+ 'September',
+ 'October',
+ 'November',
+ 'December'
+ );
+
+ $coso = ${$lan}[$month];
+ return ${$lan}[$month];
+ }
+
+ // Returns the number of days in the given month for a give 4 DIGITS year.
+ function daysInMonth($month, $year) {
+ if (substr($month, 0, 1) == '0') {
+ $month = substr($month, 1, 1);
+ }
+
+ $vec = array(
+ 0,
+ 31,
+ 28,
+ 31,
+ 30,
+ 31,
+ 30,
+ 31,
+ 31,
+ 30,
+ 31,
+ 30,
+ 31
+ );
+
+ if ($this->isLeap($year)) {
+ $vec[2] += 1;
+ }
+
+ return $vec[$month];
+ }
+
+ // Returns the day of week for the passed date. 1=Sun,2=Mon,...,7=Sat
+ function dayOfWeek($dia, $mes, $anio) {
+ $u = mktime(10, 1, 1, $mes, $dia, $anio);
+
+ $w = date('w', $u);
+ return $w + 1;
+ }
+
+ function dayOfWeekStrFromNo($x, $lan = false) {
+ if (!$lan) {
+ $lan = $this->lan;
+ }
+
+ $ar = array(
+ '',
+ 'Domingo',
+ 'Lunes',
+ 'Martes',
+ 'Miercoles',
+ 'Jueves',
+ 'Viernes',
+ 'Sabado'
+ );
+
+ $en = array(
+ '',
+ 'Sunday',
+ 'Monday',
+ 'Tuesday',
+ 'Wednesday',
+ 'Thursday',
+ 'Friday',
+ 'Saturday'
+ );
+
+ $br = array(
+ '',
+ 'Domingo',
+ 'Segunda-feira',
+ 'Tera-feira',
+ 'Quarta-feira',
+ 'Quinta-feira',
+ 'Sexta-feira',
+ 'Sbado'
+ );
+
+ return ${$lan}[$x];
+ }
+
+ // Returns the day_of_week in the language choosen.
+ function dayOfWeekStr($dia, $mes, $anio, $lan = false) {
+ if (!$lan) {
+ $lan = $this->lan;
+ }
+
+ $ar = array(
+ '',
+ 'Domingo',
+ 'Lunes',
+ 'Martes',
+ 'Miercoles',
+ 'Jueves',
+ 'Viernes',
+ 'Sabado'
+ );
+
+ $en = array(
+ '',
+ 'Sunday',
+ 'Monday',
+ 'Tuesday',
+ 'Wednesday',
+ 'Thursday',
+ 'Friday',
+ 'Saturday'
+ );
+
+ $br = array(
+ '',
+ 'Domingo',
+ 'Segunda-feira',
+ 'Tera-feira',
+ 'Quarta-feira',
+ 'Quinta-feira',
+ 'Sexta-feira',
+ 'Sbado'
+ );
+
+ $w = $this->dayOfWeek($dia, $mes, $anio);
+ return ${$lan}[$w];
+ }
+}
+
+?>
+
+<?php
+
+// example
+//$c=new calendar('en');
+//$x=$c->day_of_week_str(2,3,2000,'po');
+//print("$x\n");
+//''
+
+?> \ No newline at end of file
diff --git a/add_calendar.php b/add_calendar.php
new file mode 100644
index 0000000..4ee6059
--- /dev/null
+++ b/add_calendar.php
@@ -0,0 +1,123 @@
+<?php
+
+// $Header: /cvsroot/bitweaver/_bit_calendar/Attic/add_calendar.php,v 1.1 2005/07/15 12:25:01 bitweaver Exp $
+
+// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
+// All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
+
+// Initialization
+require_once( '../bit_setup_inc.php' );
+
+include_once( CALENDAR_PKG_PATH.'calendar_lib.php' );
+
+if ($bit_p_admin_calendar != 'y' and $bit_p_admin != 'y') {
+ $smarty->assign('msg', tra("You dont have permission to use this feature"));
+ $gBitSystem->display( 'error.tpl' );
+ die;
+}
+
+if (!isset($_REQUEST["calendar_id"])) {
+ $_REQUEST["calendar_id"] = 0;
+}
+
+$calendarlib = new CalendarLib();
+
+if (isset($_REQUEST["drop"])) {
+
+ $calendarlib->dropCalendar($_REQUEST["drop"]);
+ $_REQUEST["calendar_id"] = 0;
+}
+
+if (isset($_REQUEST["save"])) {
+
+ $customflags["customlanguages"] = $_REQUEST["customlanguages"];
+ $customflags["customlocations"] = $_REQUEST["customlocations"];
+ $customflags["customcategories"] = $_REQUEST["customcategories"];
+ $customflags["custompriorities"] = $_REQUEST["custompriorities"];
+ $_REQUEST["calendar_id"] = $calendarlib->setCalendar($_REQUEST["calendar_id"],$gBitUser->mUserId,$_REQUEST["name"],$_REQUEST["description"],$customflags);
+}
+
+if ($_REQUEST["calendar_id"]) {
+ $info = $calendarlib->getCalendar($_REQUEST["calendar_id"]);
+ setcookie("activeTabs".urlencode(substr($_SERVER["REQUEST_URI"],1)),"tab2");
+} else {
+ $info = array();
+ $info["name"] = '';
+ $info["description"] = '';
+ $info["customlanguages"] = 'n';
+ $info["customlocations"] = 'n';
+ $info["customcategories"] = 'n';
+ $info["custompriorities"] = 'n';
+ $info["user_id"] = $gBitUser->mUserId;
+}
+
+$smarty->assign('name', $info["name"]);
+$smarty->assign('description', $info["description"]);
+$smarty->assign('user_id', $info["user_id"]);
+$smarty->assign('customlanguages', $info["customlanguages"]);
+$smarty->assign('customlocations', $info["customlocations"]);
+$smarty->assign('customcategories', $info["customcategories"]);
+$smarty->assign('custompriorities', $info["custompriorities"]);
+$smarty->assign('calendar_id', $_REQUEST["calendar_id"]);
+
+if ( empty( $_REQUEST["sort_mode"] ) ) {
+ $sort_mode = 'name_desc';
+} else {
+ $sort_mode = $_REQUEST["sort_mode"];
+}
+
+if (isset($_REQUEST["find"])) {
+ $find = $_REQUEST["find"];
+} else {
+ $find = '';
+}
+
+$pagination_url = $tikilib->pagination_url($find, $sort_mode);
+$smarty->assign_by_ref('pagination_url', $pagination_url);
+
+$calendars = $calendarlib->listCalendars(0, -1, $sort_mode, $find, 0);
+
+if (!isset($_REQUEST["offset"])) {
+ $offset = 0;
+} else {
+ $offset = $_REQUEST["offset"];
+}
+if (isset($_REQUEST['page'])) {
+ $page = &$_REQUEST['page'];
+ $offset = ($page - 1) * $maxRecords;
+}
+$smarty->assign_by_ref('offset', $offset);
+
+$cant_pages = ceil($calendars["cant"] / $maxRecords);
+$smarty->assign_by_ref('cant_pages', $cant_pages);
+$smarty->assign('actual_page', 1 + ($offset / $maxRecords));
+
+if ($calendars["cant"] > ($offset + $maxRecords)) {
+ $smarty->assign('next_offset', $offset + $maxRecords);
+} else {
+ $smarty->assign('next_offset', -1);
+}
+
+// If offset is > 0 then prev_offset
+if ($offset > 0) {
+ $smarty->assign('prev_offset', $offset - $maxRecords);
+} else {
+ $smarty->assign('prev_offset', -1);
+}
+
+$smarty->assign_by_ref('calendars', $calendars["data"]);
+
+
+$groups = $userlib->get_groups();
+
+$cat_type = 'calendar';
+$cat_objid = $_REQUEST["calendar_id"];
+include_once( CATEGORIES_PKG_PATH.'categorize_list_inc.php' );
+
+
+
+// Display the template
+$gBitSystem->display( 'bitpackage:calendar/add_calendars.tpl');
+
+?>
diff --git a/admin/admin_calendar_inc.php b/admin/admin_calendar_inc.php
new file mode 100644
index 0000000..d2c9935
--- /dev/null
+++ b/admin/admin_calendar_inc.php
@@ -0,0 +1,55 @@
+<?php
+
+// $Header: /cvsroot/bitweaver/_bit_calendar/admin/admin_calendar_inc.php,v 1.1 2005/07/15 12:25:01 bitweaver Exp $
+
+// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
+// All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
+
+if (isset($_REQUEST["calendarset"]) && isset($_REQUEST["homeCalendar"])) {
+
+ $gBitSystem->storePreference("home_calendar", $_REQUEST["homeCalendar"]);
+ $smarty->assign('home_calendar', $_REQUEST["homeCalendar"]);
+}
+
+include_once( CALENDAR_PKG_PATH.'calendar_lib.php' );
+
+$formCalendarFeatures = array(
+ "calendar_blogs" => array(
+ 'label' => 'Display blog updates',
+ ),
+ "calendar_users" => array(
+ 'label' => 'Display user personal page updates',
+ ),
+ "calendar_wiki" => array(
+ 'label' => 'Display wiki page updates',
+ ),
+ "calendar_contact" => array(
+ 'label' => 'Display contact record updates',
+ ),
+ "feature_jscalendar" => array(
+ 'label' => 'Enable jscalendar popup',
+ ),
+);
+$smarty->assign( 'formCalendarFeatures',$formCalendarFeatures );
+
+if (isset($_REQUEST["calendarfeatures"])) {
+
+ foreach( $formCalendarFeatures as $item => $data ) {
+ simple_set_toggle( $item );
+ }
+
+ if ($gBitSystem->isPackageActive( 'categories' )) {
+ if (isset($_REQUEST["cal_categ"]) && $_REQUEST["cal_categ"] == "on") {
+ $gBitSystem->storePreference("cal_categ", 'y');
+ $smarty->assign("cal_categ", 'y');
+ } else {
+ $gBitSystem->storePreference("blog_categ", 'n');
+ $smarty->assign("blog_categ", 'n');
+ }
+ $gBitSystem->storePreference("cal_parent_categ", $_REQUEST["cal_parent_categ"]);
+ $smarty->assign('cal_parent_categ', $_REQUEST['cal_parent_categ']);
+ }
+}
+
+?>
diff --git a/admin/index.php b/admin/index.php
new file mode 100644
index 0000000..80f6d40
--- /dev/null
+++ b/admin/index.php
@@ -0,0 +1,4 @@
+<?php
+ // This is not a package.
+ header ("location: ../index.php");
+?> \ No newline at end of file
diff --git a/admin/schema_inc.php b/admin/schema_inc.php
new file mode 100644
index 0000000..2200cf1
--- /dev/null
+++ b/admin/schema_inc.php
@@ -0,0 +1,107 @@
+<?php
+
+$tables = array(
+
+'tiki_calendar_categories' => "
+ cal_cat_id I4 AUTO PRIMARY,
+ calendar_id I4 NOTNULL,
+ name C(160) NOTNULL
+",
+
+'tiki_calendar_items' => "
+ calitem_id I4 AUTO PRIMARY,
+ calendar_id I4 NOTNULL,
+ start_time I8 NOTNULL,
+ end_time I8 NOTNULL,
+ location_id I4,
+ category_id I4,
+ priority C(1) NOTNULL DEFAULT '1',
+ status C(1) NOTNULL DEFAULT '0',
+ url C(255),
+ lang C(2) NOTNULL default 'en',
+ name C(255) NOTNULL,
+ description B,
+ user_id I4,
+ created I8 NOTNULL,
+ lastmodif I8 NOTNULL
+",
+
+'tiki_calendar_locations' => "
+ calloc_id I4 AUTO PRIMARY,
+ calendar_id I4 NOTNULL,
+ name C(160) NOTNULL,
+ description X
+",
+
+'tiki_calendar_roles' => "
+ calitem_id I4 NOTNULL PRIMARY,
+ user_id I4 NOTNULL PRIMARY,
+ role C(1) NOTNULL DEFAULT '0'
+",
+
+'tiki_calendars' => "
+ calendar_id I4 AUTO PRIMARY,
+ name C(80) NOTNULL,
+ description C(255),
+ user_id I4 NOTNULL,
+ customlocations C(1) NOTNULL DEFAULT 'n',
+ customcategories C(1) NOTNULL DEFAULT 'n',
+ customlanguages C(1) NOTNULL DEFAULT 'n',
+ custompriorities C(1) NOTNULL DEFAULT 'n',
+ customparticipants C(1) NOTNULL DEFAULT 'n',
+ created I8 NOTNULL,
+ lastmodif I8 NOTNULL
+"
+
+);
+
+global $gBitInstaller;
+
+$gBitInstaller->makePackageHomeable('calendar');
+
+foreach( array_keys( $tables ) AS $tableName ) {
+ $gBitInstaller->registerSchemaTable( CALENDAR_PKG_DIR, $tableName, $tables[$tableName] );
+}
+
+$gBitInstaller->registerPackageInfo( CALENDAR_PKG_DIR, array(
+ 'description' => "Calendar package to display tiki entries by date, and set events",
+ 'license' => '<a href="http://www.gnu.org/licenses/licenses.html#LGPL">LGPL</a>',
+ 'version' => '0.1',
+ 'state' => 'beta',
+ 'dependencies' => '',
+) );
+
+// ### Indexes
+$indices = array (
+ 'tiki_calendar_categories_idx' => array( 'table' => 'tiki_calendar_categories', 'cols' => 'calendar_id,name', 'opts' => NULL ),
+ 'tiki_calendar_items_idx' => array( 'table' => 'tiki_calendar_items', 'cols' => 'calendar_id', 'opts' => NULL ),
+ 'tiki_calendar_locations_idx' => array( 'table' => 'tiki_calendar_locations', 'cols' => 'name', 'opts' => NULL )
+);
+
+$gBitInstaller->registerSchemaIndexes( CALENDAR_PKG_DIR, $indices );
+
+// ### Defaults
+
+// ### Default Menu Options
+$gBitInstaller->registerMenuOptions( CALENDAR_PKG_DIR, array(
+ array(42,'o','Calendar','tiki-calendar.php',0,'feature_calendar','bit_p_view_calendar',''),
+ array(42,'o','Calendar','tiki-admin_calendars.php',1,'feature_calendar','bit_p_admin_calendar','')
+) );
+
+// ### Default User Permissions
+$gBitInstaller->registerUserPermissions( CALENDAR_PKG_DIR, array(
+ array('bit_p_view_calendar', 'Can browse the calendar', 'basic', 'calendar'),
+ array('bit_p_change_events', 'Can change events in the calendar', 'registered', 'calendar'),
+ array('bit_p_add_events', 'Can add events in the calendar', 'registered', 'calendar'),
+ array('bit_p_admin_calendar', 'Can create/admin calendars', 'admin', 'calendar')
+) );
+
+// ### Default Preferences
+$gBitInstaller->registerPreferences( CALENDAR_PKG_DIR, array(
+ array ('kernel', 'feature_jscalendar', 'n'),
+ array ('calendar', 'calendar_blogs', 'y'),
+ array ('calendar', 'calendar_users', 'y'),
+ array ('calendar', 'calendar_wiki', 'y')
+) );
+
+?>
diff --git a/bit_setup_inc.php b/bit_setup_inc.php
new file mode 100644
index 0000000..ee09424
--- /dev/null
+++ b/bit_setup_inc.php
@@ -0,0 +1,9 @@
+<?php
+global $gBitSystem, $smarty;
+$gBitSystem->registerPackage( 'calendar', dirname( __FILE__).'/' );
+
+if( $gBitSystem->isPackageActive( 'calendar' ) ) {
+ $gBitSystem->registerAppMenu( 'calendar', 'Calendar', CALENDAR_PKG_URL.'index.php', 'bitpackage:calendar/menu_calendar.tpl', 'calendar');
+}
+
+?>
diff --git a/calendar_lib.php b/calendar_lib.php
new file mode 100644
index 0000000..51a763b
--- /dev/null
+++ b/calendar_lib.php
@@ -0,0 +1,328 @@
+<?php
+
+class CalendarLib extends BitBase {
+ var $gContentTypes;
+
+ function CalendarLib() {
+ BitBase::BitBase();
+ }
+
+ function listCalendars($offset = 0, $maxRecords = -1, $sort_mode = 'created_desc', $find = '') {
+ $mid = '';
+ $res = array();
+ $bindvars = array();
+ if ($find) {
+ $mid = "where `name` like ?";
+ $bindvars[] = $findesc;
+ }
+ $query = "select * from `".BIT_DB_PREFIX."tiki_calendars` $mid order by ".$this->convert_sortmode($sort_mode);
+ $result = $this->query($query,$bindvars,$maxRecords,$offset);
+ $query_cant = "select count(*) from `".BIT_DB_PREFIX."tiki_calendars` $mid";
+ $cant = $this->getOne($query_cant,$bindvars);
+
+ $res = array();
+ while ($r = $result->fetchRow()) {
+ $k = $r["calendar_id"];
+ $res["$k"] = $r;
+ }
+ $retval["data"] = $res;
+ $retval["cant"] = $cant;
+ return $retval;
+ }
+
+ // give out an array with Ids viewable by $user_id
+ function listUserCalIds() {
+ global $gBitUser;
+ $user_id = $gBitUser->getUserId();
+ if ($user_id) {
+ // $groups = $userlib->get_user_groups($user_id);
+ // need to add something
+ $query = "select `calendar_id` from `".BIT_DB_PREFIX."tiki_calendars` where `user_id`=?";
+ $bindvars=array($user_id);
+ } else {
+ $query = "select `calendar_id` from `".BIT_DB_PREFIX."tiki_calendars`";
+ $bindvars=array();
+ }
+ $result = $this->query($query,$bindvars);
+ $ret = array();
+ while ($r = $result->fetchRow()) {
+ $res[] = $r['calendar_id'];
+ }
+ return $res;
+ }
+
+ function setCalendar($calendar_id, $user_id, $name, $description, $customflags=array()) {
+ $name = strip_tags($name);
+ $description = strip_tags($description);
+ $now = time();
+ if ($calendar_id > 0) {
+ // modification of a calendar
+ $query = "update `".BIT_DB_PREFIX."tiki_calendars` set `name`=?, `user_id`=?, `description`=?, ";
+ $bindvars = array($name,$user_id,$description);
+ foreach ($customflags as $k => $v) {
+ $query .= "`$k`=?, ";
+ $bindvars[]=$v;
+ }
+ $query .= "`lastmodif`=? where `calendar_id`=?";
+ $bindvars[] = $now;
+ $bindvars[] = $calendar_id;
+ $result = $this->query($query,$bindvars);
+ } else {
+ // create a new calendar
+ $query = "insert into `".BIT_DB_PREFIX."tiki_calendars` (`name`,`user_id`,`description`,`created`,`lastmodif`,`" . implode("`,`", array_keys($customflags)). "`) ";
+ $query.= "values (?,?,?,?,?," . implode(",", array_fill(0,count($customflags),"?")). ")";
+ $bindvars=array($name,$user_id,$description,$now,$now);
+ foreach ($customflags as $k => $v) $bindvars[]=$v;
+ $result = $this->query($query,$bindvars);
+ $calendar_id=$this->GetOne("select `calendar_id` from `".BIT_DB_PREFIX."tiki_calendars` where `created`=?",array($now));
+ }
+ return $calendar_id;
+ }
+
+ function getCalendar($calendar_id) {
+ $res = $this->query("select * from `".BIT_DB_PREFIX."tiki_calendars` where `calendar_id`=?",array((int)$calendar_id));
+ return $res->fetchRow();
+ }
+
+ function dropCalendar($calendar_id) {
+ $query = "delete from `".BIT_DB_PREFIX."tiki_calendars` where `calendar_id`=?";
+ $this->query($query,array($calendar_id));
+ }
+
+ function loadContentTypes() {
+ global $gBitSystem, $gBitUser;
+ $query = "select `content_type_guid`, `content_description`, `handler_class`, `handler_package`, `handler_file` from `".BIT_DB_PREFIX."tiki_content_types` order by `content_type_guid`";
+ $rs = $this->query($query);
+ $this->gContentTypes = array();
+ if ($rs) {
+ while (!$rs->EOF) {
+ $ctg = $rs->fields['content_type_guid'];
+ $this->gContentTypes[$ctg] = array();
+ $this->gContentTypes[$ctg]['label'] = tra($rs->fields['content_description']);
+ $this->gContentTypes[$ctg]['feature'] = $gBitSystem->getPreference('calendar_'.$rs->fields['handler_package'], 'y');
+ $this->gContentTypes[$ctg]['right'] = $gBitUser->getPreference('bit_p_calendar_'.$rs->fields['handler_package'], 'y');
+ $this->gContentTypes[$ctg]['content_type_guid'] = $rs->fields['content_type_guid'];
+ $this->gContentTypes[$ctg]['handler'] = $rs->fields['handler_package'];
+ $rs->MoveNext();
+ }
+ }
+ }
+
+ function listItems($calIds, $user_id, $tstart, $tstop, $offset, $maxRecords, $sort_mode, $find) {
+ $where = array();
+ $bindvars=array();
+ foreach ($calIds as $calendar_id) {
+ $where[] = "i.`calendar_id`=?";
+ $bindvars[] = $calendar_id;
+ }
+
+ $cond = "(" . implode(" or ", $where). ")";
+ $cond .= " and ((i.`start_time` > ? and i.`end_time` < ?) or (i.`start_time` < ? and i.`end_time` > ?))";
+ $bindvars[] = $tstart;
+ $bindvars[] = $tstop;
+ $bindvars[] = $tstop;
+ $bindvars[] = $tstart;
+
+ $query = "select i.`calitem_id`, i.`name`, i.`description`, i.`start_time`, i.`end_time`, ";
+ $query .= "i.`url`, i.`status`, i.`priority`, c.`name` as `calname`, i.`calendar_id` ";
+ $query .= "from `".BIT_DB_PREFIX."tiki_calendar_items` i left join `".BIT_DB_PREFIX."tiki_calendars` c on i.`calendar_id`=c.`calendar_id` ";
+ $query .= "where ($cond) ";
+ $result = $this->query($query,$bindvars);
+ $ret = array();
+ while ($res = $result->fetchRow()) {
+ $dstart = mktime(0, 0, 0, date("m", $res['start_time']), date("d", $res['start_time']), date("Y", $res['start_time']));
+ $dend = mktime(0, 0, 0, date("m", $res['end_time']), date("d", $res['end_time']), date("Y", $res['end_time']));
+ $tstart = date("Hi", $res["start_time"]);
+ $tend = date("Hi", $res["end_time"]);
+ for ($i = $dstart; $i <= $dend; $i = ($i + (60 * 60 * 24))) {
+ if ($dstart == $dend) {
+ $head = date("H:i", $res["start_time"]). " - " . date("H:i", $res["end_time"]);
+ } elseif ($i == $dstart) {
+ $head = date("H:i", $res["start_time"]). " ...";
+ } elseif ($i == $dend) {
+ $head = " ... " . date("H:i", $res["end_time"]);
+ } else {
+ $head = " ... " . tra("continued"). " ... ";
+ }
+
+ $ret["$i"][] = array(
+ "result" => $res,
+ "calitem_id" => $res["calitem_id"],
+ "calname" => $res["calname"],
+ "time" => $tstart,
+ "type" => $res["status"],
+ "web" => $res["url"],
+ "prio" => $res["priority"],
+ "url" => CALENDAR_PKG_URL."index.php?todate=$i&amp;editmode=1&amp;calitem_id=" . $res["calitem_id"],
+ "name" => $res["name"],
+ "extra" => "<div align='right'>... " . tra("click to edit"),
+ "head" => $head,
+ "description" => str_replace("\n|\r", "", $res["description"])
+ );
+ }
+ }
+ return $ret;
+ }
+
+ function listTikiItems($tikiobj, $user_id, $tstart, $tstop, $offset, $maxRecords, $sort_mode, $find) {
+ $ret = array();
+
+ $res = $dstart = '';
+
+ foreach ($tikiobj as $tik) {
+// $query = "select *, ( select page_id from `".BIT_DB_PREFIX."tiki_pages` where `content_id` = tc.`content_id` )" .
+ $query = "select * from `".BIT_DB_PREFIX."tiki_content` tc where (`last_modified`>? and `last_modified`<?) and `content_type_guid` = '".$tik."'";
+ $result = $this->query($query,array($tstart,$tstop));
+
+ while ($res = $result->fetchRow()) {
+ $dstart = mktime(0, 0, 0, date("m", $res['last_modified']), date("d", $res['last_modified']), date("Y", $res['last_modified']));
+ $tstart = date("Hi", $res["last_modified"]);
+ $quote = "<i>" . tra("by"). " " . $res["modifier_user_id"] . "</i><br/>" . addslashes(str_replace('"', "'", $res["title"]));
+ $ret["$dstart"][] = array(
+ "calitem_id" => "",
+ "calname" => "",
+ "prio" => "",
+ "time" => $tstart,
+ "type" => $tik,
+ "url" => BIT_ROOT_URL.$this->gContentTypes[$tik]['handler']."/index.php?content_id=" . $res["content_id"],
+ "name" => $res["title"],
+ "head" => "<b>" . date("H:i", $res["last_modified"]). "</b> " . tra("in"). " <b>$tik</b>",
+ "description" => str_replace("\n|\r", "", $quote)
+ );
+ }
+ }
+ return $ret;
+ }
+
+ function getItem($calitem_id) {
+ $query = "select i.`calitem_id`, i.`calendar_id`, i.`user_id`, i.`start_time`, i.`end_time`, t.`name` as `calname`, ";
+ $query.= "i.`location_id` as `location_id`, l.`name` as `locationName`, i.`category_id` as `category_id`, c.`name` as `categoryName`, i.`priority` as `priority`, ";
+ $query.= "i.`status` as `status`, i.`url` as `url`, i.`lang` as `lang`, i.`name` as `name`, i.`description` as `description`, i.`created` as `created`, i.`lastmodif` as `last_modified`, ";
+ $query.= "t.`customlocations` as `customlocations`, t.`customcategories` as `customcategories`, t.`customlanguages` as `customlanguages`, t.`custompriorities` as `custompriorities`, ";
+ $query.= "t.`customparticipants` as `customparticipants` from `".BIT_DB_PREFIX."tiki_calendar_items` i ";
+ $query.= "left join `".BIT_DB_PREFIX."tiki_calendar_locations` l on i.`location_id`=l.`calloc_id` ";
+ $query.= "left join `".BIT_DB_PREFIX."tiki_calendar_categories` c on i.`category_id`=c.`cal_cat_id` ";
+ $query.= "left join `".BIT_DB_PREFIX."tiki_calendars` t on i.`calendar_id`=t.`calendar_id` where `calitem_id`=?";
+ $result = $this->query($query,array($calitem_id));
+ $res = $result->fetchRow();
+ $query = "select `user_id`, `role` from `tiki_calendar_roles` where `calitem_id`=? order by `role`";
+ $rezult = $this->query($query,array($calitem_id));
+ $ppl = array();
+ $org = array();
+
+ while ($rez = $rezult->fetchRow()) {
+ if ($rez["role"] == '6') {
+ $org[] = $rez["user_id"];
+ } elseif ($rez["user_id"]) {
+ $ppl[] = $rez["user_id"] . ":" . $rez["role"];
+ }
+ }
+
+ $res["participants"] = implode(',', $ppl);
+ $res["organizers"] = implode(',', $org);
+ return $res;
+ }
+
+ function setItem($user_id, $calitem_id, $data) {
+ if (!$data["location_id"] and !$data["newloc"]) {
+ $data["newloc"] = tra("not specified");
+ }
+ else if (trim($data["newloc"])) {
+ $query = "delete from `".BIT_DB_PREFIX."tiki_calendar_locations` where `calendar_id`=? and `name`=?";
+ $bindvars=array($data["calendar_id"],trim($data["newloc"]));
+ $this->query($query,$bindvars,-1,-1,false);
+ $query = "insert into `".BIT_DB_PREFIX."tiki_calendar_locations` (`calendar_id`,`name`) values (?,?)";
+ $this->query($query,$bindvars);
+ $data["location_id"] = $this->GetOne("select `calloc_id` from `".BIT_DB_PREFIX."tiki_calendar_locations` where `calendar_id`=? and `name`=?",$bindvars);
+ }
+
+ if (!$data["location_id"] and !$data["newcat"]) {
+ $data["newcat"] = tra("not specified");
+ }
+ else if (trim($data["newcat"])) {
+ $query = "delete from `".BIT_DB_PREFIX."tiki_calendar_locations` where `calendar_id`=? and `name`=?";
+ $bindvars=array($data["calendar_id"],trim($data["newcat"]));
+ $this->query($query,$bindvars,-1,-1,false);
+ $query = "insert into `".BIT_DB_PREFIX."tiki_calendar_locations` (`calendar_id`,`name`) values (?,?)";
+ $this->query($query,$bindvars);
+ $data["location_id"] = $this->GetOne("select `calloc_id` from `".BIT_DB_PREFIX."tiki_calendar_locations` where `calendar_id`=? and `name`=?",$bindvars);
+ }
+
+ $roles = array();
+ if ($data["organizers"]) {
+ $orgs = split(',', $data["organizers"]);
+ foreach ($orgs as $o) {
+ $roles['6'][] = trim($o);
+ }
+ }
+ if ($data["participants"]) {
+ $parts = split(',', $data["participants"]);
+ foreach ($parts as $pa) {
+ $p = split('\:', trim($pa));
+ if (isset($p[0])and isset($p[1])) {
+ $roles["$p[1]"][] = trim($p[0]);
+ }
+ }
+ }
+
+ if ($calitem_id) {
+ $query = "update `".BIT_DB_PREFIX."tiki_calendar_items` set `calendar_id`=?,`user_id`=?,`start_time`=?,`end_time`=? ,`location_id`=? ,`category_id`=?,`priority`=?,`status`=?,`url`=?,";
+ $query.= "`lang`=?,`name`=?,`description`=?,`lastmodif`=? where `calitem_id`=?";
+ $bindvars=array((int)$data["calendar_id"],$user_id,(int)$data["start"],(int)$data["end"],(int)$data["location_id"],(int)$data["category_id"],(int)$data["priority"],
+ $data["status"],$data["url"],$data["lang"],$data["name"],$data["description"],(int)time(),(int)$calitem_id);
+ $result = $this->query($query,$bindvars);
+ } else {
+ $now=time();
+ $query = "insert into `".BIT_DB_PREFIX."tiki_calendar_items` (`calendar_id`, `user_id`, `start_time`, `end_time`, `location_id`, `category_id`, ";
+ $query.= " `priority`, `status`, `url`, `lang`, `name`, `description`, `created`, `lastmodif`) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+ $bindvars=array($data["calendar_id"],$user_id,$data["start"],$data["end"],$data["location_id"],$data["category_id"],$data["priority"],$data["status"],$data["url"],$data["lang"],$data["name"],$data["description"],$now,$now);
+ $result = $this->query($query,$bindvars);
+ $calitem_id = $this->GetOne("select `calitem_id` from `".BIT_DB_PREFIX."tiki_calendar_items` where `calendar_id`=? and `created`=?",array($data["calendar_id"],$now));
+ }
+
+ if ($calitem_id) {
+ $query = "delete from `".BIT_DB_PREFIX."tiki_calendar_roles` where `calitem_id`=?";
+ $this->query($query,array($calitem_id));
+ }
+
+ foreach ($roles as $lvl => $ro) {
+ foreach ($ro as $r) {
+ $query = "insert into `".BIT_DB_PREFIX."tiki_calendar_roles` (`calitem_id`,`user_id`,`role`) values (?,?,?)";
+ $this->query($queryi,array($calitem_id,$r,$lvl));
+ }
+ }
+ return $calitem_id;
+ }
+
+ function dropItem($user_id, $calitem_id) {
+ if ($calitem_id) {
+ $query = "delete from `".BIT_DB_PREFIX."tiki_calendar_items` where `calitem_id`=?";
+ $this->query($query,array($calitem_id));
+ }
+ }
+
+ function listLocations($calendar_id) {
+ $res = array();
+ if ($calendar_id > 0) {
+ $query = "select `calloc_id` as location_id, `name` from `".BIT_DB_PREFIX."tiki_calendar_locations` where `calendar_id`=?";
+ $result = $this->query($query,array($calendar_id));
+ while ($rez = $result->fetchRow()) {
+ $res[] = $rez;
+ }
+ }
+ return $res;
+ }
+
+ function listCategories($calendar_id) {
+ $res = array();
+ if ($calendar_id > 0) {
+ $query = "select `cal_cat_id` as `category_id`, `name` from `".BIT_DB_PREFIX."tiki_calendar_categories` where `calendar_id`=?";
+ $result = $this->query($query,array($calendar_id));
+ while ($rez = $result->fetchRow()) {
+ $res[] = $rez;
+ }
+ }
+ return $res;
+ }
+}
+?>
diff --git a/icons/calendar.gif b/icons/calendar.gif
new file mode 100644
index 0000000..1831720
--- /dev/null
+++ b/icons/calendar.gif
Binary files differ
diff --git a/icons/calendar2.gif b/icons/calendar2.gif
new file mode 100644
index 0000000..8526cf5
--- /dev/null
+++ b/icons/calendar2.gif
Binary files differ
diff --git a/icons/calendar3.gif b/icons/calendar3.gif
new file mode 100644
index 0000000..954393c
--- /dev/null
+++ b/icons/calendar3.gif
Binary files differ
diff --git a/icons/calendar4.gif b/icons/calendar4.gif
new file mode 100644
index 0000000..4228a24
--- /dev/null
+++ b/icons/calendar4.gif
Binary files differ
diff --git a/icons/day.gif b/icons/day.gif
new file mode 100644
index 0000000..0e19bf3
--- /dev/null
+++ b/icons/day.gif
Binary files differ
diff --git a/icons/month.gif b/icons/month.gif
new file mode 100644
index 0000000..c7da143
--- /dev/null
+++ b/icons/month.gif
Binary files differ
diff --git a/icons/pkg_calendar.png b/icons/pkg_calendar.png
new file mode 100644
index 0000000..af736c7
--- /dev/null
+++ b/icons/pkg_calendar.png
Binary files differ
diff --git a/icons/week.gif b/icons/week.gif
new file mode 100644
index 0000000..4621306
--- /dev/null
+++ b/icons/week.gif
Binary files differ
diff --git a/icons/year.gif b/icons/year.gif
new file mode 100644
index 0000000..17272f9
--- /dev/null
+++ b/icons/year.gif
Binary files differ
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..95f1f2d
--- /dev/null
+++ b/index.php
@@ -0,0 +1,529 @@
+<?php
+
+// $Header: /cvsroot/bitweaver/_bit_calendar/index.php,v 1.1 2005/07/15 12:25:01 bitweaver Exp $
+
+// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
+// All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
+require_once( '../bit_setup_inc.php' );
+
+include_once( CALENDAR_PKG_PATH.'calendar_lib.php' );
+
+# perms are
+# $bit_p_view_calendar
+# $bit_p_admin_calendar
+# $bit_p_change_events
+# $bit_p_add_events
+$gBitSystem->isPackageActive('calendar', TRUE);
+
+$bufid = array();
+$bufdata = array();
+$modifiable = array();
+
+$calendarlib = new CalendarLib();
+$calendarlib->loadContentTypes();
+
+$rawcals = $calendarlib->listCalendars();
+
+foreach ($rawcals["data"] as $cal_id=>$cal_data) {
+ if ($bit_p_admin == 'y') {
+ $cal_data["bit_p_view_calendar"] = 'y';
+ $cal_data["bit_p_add_events"] = 'y';
+ $cal_data["bit_p_change_events"] = 'y';
+ } else {
+ $cal_data["bit_p_view_calendar"] = 'y';
+ $cal_data["bit_p_add_events"] = 'y';
+ $cal_data["bit_p_change_events"] = 'y';
+ }
+ if ($cal_data["bit_p_view_calendar"] == 'y') {
+ $bufid[] = $cal_id;
+ $bufdata["$cal_id"] = $cal_data;
+ }
+ if (($cal_data["bit_p_add_events"] == 'y') or ($cal_data["bit_p_change_events"] == 'y')) {
+ $modifiable[] = $cal_id;
+ }
+}
+$listcals = $bufid;
+$infocals["data"] = $bufdata;
+
+$smarty->assign('infocals', $infocals["data"]);
+$smarty->assign('listcals', $listcals);
+$smarty->assign('modifiable', count($modifiable));
+
+// set up list of groups
+if (isset($_REQUEST["calIds"])and is_array($_REQUEST["calIds"])and count($_REQUEST["calIds"])) {
+ $_SESSION['CalendarViewGroups'] = $_REQUEST["calIds"];
+} elseif (!isset($_SESSION['CalendarViewGroups'])) {
+ $_SESSION['CalendarViewGroups'] = $listcals;
+} elseif (isset($_REQUEST["refresh"])and !isset($_REQUEST["calIds"])) {
+ $_SESSION['CalendarViewGroups'] = array();
+}
+
+// setup list of tiki items displayed
+if (isset($_REQUEST["tikicals"])and is_array($_REQUEST["tikicals"])and count($_REQUEST["tikicals"])) {
+ $_SESSION['CalendarViewTikiCals'] = $_REQUEST["tikicals"];
+} elseif (!isset($_SESSION['CalendarViewTikiCals'])) {
+ $_SESSION['CalendarViewTikiCals'] = array();
+} elseif (isset($_REQUEST["refresh"])and !isset($_REQUEST["tikicals"])) {
+ $_SESSION['CalendarViewTikiCals'] = array();
+}
+
+// this should be a global array generated by the some object in the kernel
+$tikiItems = $calendarlib->gContentTypes;
+$smarty->assign('tikiItems', $tikiItems);
+
+$smarty->assign('displayedcals', $_SESSION['CalendarViewGroups']);
+$smarty->assign('displayedtikicals', $_SESSION['CalendarViewTikiCals']);
+
+$thiscal = array();
+
+foreach ($listcals as $thatid) {
+ if (is_array($_SESSION['CalendarViewGroups']) && (in_array("$thatid", $_SESSION['CalendarViewGroups']))) {
+ $thiscal["$thatid"] = 1;
+ } else {
+ $thiscal["$thatid"] = 0;
+ }
+}
+
+$smarty->assign('thiscal', $thiscal);
+
+$tikical = array();
+
+foreach ($_SESSION['CalendarViewTikiCals'] as $calt) {
+ $tikical["$calt"] = 1;
+}
+
+$trunc = "12"; // put in a pref, number of chars displayed in cal cells
+$smarty->assign('tikical', $tikical);
+
+if (isset($_REQUEST["todate"]) && $_REQUEST['todate']) {
+ $_SESSION['CalendarFocusDate'] = $_REQUEST['todate'];
+} elseif (isset($_SESSION['CalendarFocusDate']) && $_SESSION['CalendarFocusDate']) {
+ $_REQUEST["todate"] = $_SESSION['CalendarFocusDate'];
+} else {
+ $_SESSION['CalendarFocusDate'] = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
+ $_REQUEST["todate"] = $_SESSION['CalendarFocusDate'];
+}
+
+$focusdate = $_REQUEST['todate'];
+list($focus_day, $focus_month, $focus_year) = array(
+ date("d", $focusdate),
+ date("m", $focusdate),
+ date("Y", $focusdate)
+);
+$focusdate = mktime(0,0,0,$focus_month,$focus_day,$focus_year);
+
+if (isset($_REQUEST["viewmode"]) and $_REQUEST["viewmode"]) {
+ $_SESSION['CalendarViewMode'] = $_REQUEST["viewmode"];
+}
+
+if (!isset($_SESSION['CalendarViewMode']) or !$_SESSION['CalendarViewMode']) {
+ $_SESSION['CalendarViewMode'] = 'month';
+}
+$smarty->assign('viewmode', $_SESSION['CalendarViewMode']);
+
+if (isset($_REQUEST["delete"])and ($_REQUEST["delete"]) and isset($_REQUEST["calitem_id"])) {
+ $calendarlib->dropItem($user_id, $_REQUEST["calitem_id"]);
+ $_REQUEST["calitem_id"] = 0;
+}
+
+if (!isset($_REQUEST["calitem_id"]))
+ $_REQUEST["calitem_id"] = 0;
+
+if (!isset($_REQUEST["location_id"]))
+ $_REQUEST["location_id"] = 0;
+
+if (!isset($_REQUEST["category_id"]))
+ $_REQUEST["category_id"] = 0;
+
+if (!isset($_REQUEST["organizers"]))
+ $_REQUEST["organizers"] = "";
+
+if (!isset($_REQUEST["participants"]))
+ $_REQUEST["participants"] = "";
+
+if (!isset($_REQUEST["newloc"]))
+ $_REQUEST["newloc"] = "";
+
+if (!isset($_REQUEST["newcat"]))
+ $_REQUEST["newcat"] = "";
+
+if (!isset($_REQUEST["priority"]))
+ $_REQUEST["priority"] = "5";
+
+if (!isset($_REQUEST["lang"]))
+ $_REQUEST["lang"] = $gBitLanguage;
+
+if (!isset($_REQUEST["status"]))
+ $_REQUEST["status"] = 0;
+
+if (isset($_REQUEST["copy"])and ($_REQUEST["copy"])) {
+
+ $_REQUEST["calitem_id"] = 0;
+ $_REQUEST["save"] = true;
+}
+
+if (isset($_REQUEST["save"])and ($_REQUEST["save"])) {
+
+ if (!isset($_REQUEST["name"])or !(trim($_REQUEST["name"]))) {
+ $_REQUEST["name"] = tra("event without name");
+ }
+ if (isset($_REQUEST["start_date_input"]) and $_REQUEST["start_date_input"]) {
+ $event_start = strtotime($_REQUEST["start_date_input"]);
+ } else {
+ if (isset($_REQUEST["start_freeform"])and $_REQUEST["start_freeform"]) {
+ $event_start = strtotime($_REQUEST["start_freeform"]);
+ }
+ if (!isset($event_start)) {
+ $event_start = mktime($_REQUEST["starth_Hour"], $_REQUEST["starth_Minute"],
+ 0, $_REQUEST["start_Month"], $_REQUEST["start_Day"], $_REQUEST["start_Year"]);
+ }
+ }
+ if (isset($_REQUEST["end_date_input"]) and $_REQUEST["end_date_input"]) {
+ $event_end = strtotime($_REQUEST["end_date_input"]);
+ } else {
+ if (isset($_REQUEST["end_freeform"])and $_REQUEST["end_freeform"]) {
+ $event_end = strtotime($_REQUEST["end_freeform"]);
+ }
+ if (!isset($event_end)) {
+ $event_end = mktime($_REQUEST["endh_Hour"], $_REQUEST["endh_Minute"],
+ 0, $_REQUEST["end_Month"], $_REQUEST["end_Day"], $_REQUEST["end_Year"]);
+ }
+ }
+ $_REQUEST["calitem_id"] = $calendarlib->setItem($gBitUser->mUserId, $_REQUEST["calitem_id"], array(
+ "user_id" => $gBitUser->mUserId,
+ "organizers" => $_REQUEST["organizers"],
+ "participants" => $_REQUEST["participants"],
+ "calendar_id" => $_REQUEST["calendar_id"],
+ "start" => $event_start,
+ "end" => $event_end,
+ "location_id" => $_REQUEST["location_id"],
+ "newloc" => $_REQUEST["newloc"],
+ "category_id" => $_REQUEST["category_id"],
+ "newcat" => $_REQUEST["newcat"],
+ "priority" => $_REQUEST["priority"],
+ "status" => $_REQUEST["status"],
+ "url" => $_REQUEST["url"],
+ "lang" => $_REQUEST["lang"],
+ "name" => $_REQUEST["name"],
+ "description" => $_REQUEST["description"]
+ ));
+}
+
+if ($_REQUEST["calitem_id"]) {
+ $info = $calendarlib->getItem($_REQUEST["calitem_id"]);
+} else {
+ $info = array();
+
+ $info["calitem_id"] = "";
+ $info["calendar_id"] = "";
+ $info["user_id"] = "";
+ $info["calname"] = "";
+ $info["organizers"] = $gBitUser->mUsername . ",";
+ $info["participants"] = $gBitUser->mUsername . ":0,";
+ $info["start_time"] = $focusdate + date("H") * 60 * 60;
+ $info["end_time"] = $focusdate + (date("H") + 2) * 60 * 60;
+ $info["location_id"] = 0;
+ $info["locationName"] = '';
+ $info["category_id"] = 0;
+ $info["categoryName"] = '';
+ $info["priority"] = 5;
+ $info["url"] = '';
+// $info["lang"] = $gBitUser->getPreference("language");
+ $info["name"] = '';
+ $info["description"] = '';
+ $info["created"] = time();
+ $info["last_modified"] = time();
+ $info["status"] = '0';
+ $info["customlocations"] = 'n';
+ $info["customcategories"] = 'n';
+ $info["customlanguages"] = 'n';
+ $info["custompriorities"] = 'n';
+ $info["customparticipants"] = 'n';
+}
+
+if (!isset($_REQUEST["calendar_id"])or !$_REQUEST["calendar_id"]) {
+ $_REQUEST["calendar_id"] = $info["calendar_id"];
+}
+
+$smarty->assign('calitem_id', $info["calitem_id"]);
+$smarty->assign('calendar_id', $_REQUEST["calendar_id"]);
+$smarty->assign('organizers', $info["organizers"]);
+$smarty->assign('participants', $info["participants"]);
+$smarty->assign('calname', $info["calname"]);
+if (isset( $info["start_time"] ) ) {
+ $smarty->assign('start_time', $info["start_time"]);
+ $smarty->assign('end_time', $info["end_time"]);
+}
+$smarty->assign('location_id', $info["location_id"]);
+//$smarty->assign('locationName', $info["locationName"]);
+$smarty->assign('category_id', $info["category_id"]);
+//$smarty->assign('categoryName', $info["categoryName"]);
+$smarty->assign('priority', $info["priority"]);
+$smarty->assign('url', $info["url"]);
+//$smarty->assign('lang', $info["lang"]);
+$smarty->assign('name', $info["name"]);
+$smarty->assign('description', $info["description"]);
+$smarty->assign('created', $info["created"]);
+$smarty->assign('last_modified', $info["last_modified"]);
+$smarty->assign('lastUser', $info["user_id"]);
+$smarty->assign('status', $info["status"]);
+
+if (!isset($_REQUEST["editmode"])) $_REQUEST["editmode"] = 0;
+
+if ($_REQUEST["editmode"]) {
+ $thatcal = $calendarlib->getCalendar($_REQUEST["calendar_id"]);
+
+ $info["customlocations"] = $thatcal["customlocations"];
+ $info["customcategories"] = $thatcal["customcategories"];
+ $info["customlanguages"] = $thatcal["customlanguages"];
+ $info["custompriorities"] = $thatcal["custompriorities"];
+ $info["customparticipants"] = $thatcal["customparticipants"];
+ $listcat = array();
+ $listloc = array();
+ $listpeople = array();
+ $languages = array();
+
+ if ($thatcal["customcategories"] == 'y') {
+ $listcat = $calendarlib->listCategories($_REQUEST["calendar_id"]);
+ }
+
+ if ($thatcal["customlocations"] == 'y') {
+ $listloc = $calendarlib->listLocations($_REQUEST["calendar_id"]);
+ }
+
+ if ($thatcal["customlanguages"] == 'y') {
+ $languages = $tikilib->list_languages();
+ }
+
+ $smarty->assign('listcat', $listcat);
+ $smarty->assign('listloc', $listloc);
+ $smarty->assign_by_ref('languages', $languages);
+}
+
+$smarty->assign('customlocations', $info["customlocations"]);
+$smarty->assign('customcategories', $info["customcategories"]);
+$smarty->assign('customlanguages', $info["customlanguages"]);
+$smarty->assign('custompriorities', $info["custompriorities"]);
+$smarty->assign('customparticipants', $info["customparticipants"]);
+
+if (isset($_REQUEST["find"])) {
+ $find = $_REQUEST["find"];
+} else {
+ $find = '';
+}
+
+$smarty->assign('find', $find);
+
+if (isset($_REQUEST['drop'])) {
+
+ if (is_array($_REQUEST['drop'])) {
+ foreach ($_REQUEST['drop'] as $dropme) {
+ $calendarlib->dropItem($gBitUser->mUserId, $dropme);
+ }
+ } else {
+ $calendarlib->dropItem($gBitUser->mUserId, $_REQUEST['drop']);
+ }
+}
+
+$z = date("z");
+
+$focus_prevday = mktime(0, 0, 0, $focus_month, $focus_day - 1, $focus_year);
+$focus_nextday = mktime(0, 0, 0, $focus_month, $focus_day + 1, $focus_year);
+$focus_prevweek = mktime(0, 0, 0, $focus_month, $focus_day - 7, $focus_year);
+$focus_nextweek = mktime(0, 0, 0, $focus_month, $focus_day + 7, $focus_year);
+$focus_prevmonth = mktime(0, 0, 0, $focus_month - 1, $focus_day, $focus_year);
+$focus_nextmonth = mktime(0, 0, 0, $focus_month + 1, $focus_day, $focus_year);
+
+$smarty->assign('daybefore', $focus_prevday);
+$smarty->assign('weekbefore', $focus_prevweek);
+$smarty->assign('monthbefore', $focus_prevmonth);
+$smarty->assign('dayafter', $focus_nextday);
+$smarty->assign('weekafter', $focus_nextweek);
+$smarty->assign('monthafter', $focus_nextmonth);
+$smarty->assign('focusmonth', $focus_month);
+$smarty->assign('focusdate', $focusdate);
+$smarty->assign('now', mktime(0, 0, 0, date('m'), date('d'), date('Y')));
+
+$weekdays = range(0, 6);
+
+$d = 60 * 60 * 24;
+$currentweek = date("W", $focusdate);
+$wd = date('w', $focusdate);
+
+#if ($wd == 0) $w = 7;
+#$wd--;
+
+// calculate timespan for sql query
+if ($_SESSION['CalendarViewMode'] == 'month') {
+ $viewstart = mktime(0,0,0,$focus_month, 1, $focus_year);
+ $TmpWeekday = date("w",$viewstart);
+ // move viewstart back to Sunday....
+ $viewstart -= $TmpWeekday * $d;
+ // this is the last day of $focus_month
+ $viewend = mktime(0,0,0,$focus_month + 1, 0, $focus_year);
+ $TmpWeekday = date("w", $viewend);
+ $viewend += (6 - $TmpWeekday) * $d;
+ $viewend -= 1;
+ // ISO weeks --- kinda mangled because ours begin on Sunday...
+ $firstweek = date("W", $viewstart + $d);
+ $lastweek = date("W", $viewend);
+ if ($lastweek < $firstweek) {
+ if ($currentweek < $firstweek) {
+ $firstweek -= 52;
+ } else {
+ $lastweek += 52;
+ }
+ }
+ $numberofweeks = $lastweek - $firstweek;
+} elseif ($_SESSION['CalendarViewMode'] == 'week') {
+ $firstweek = $currentweek;
+ $lastweek = $currentweek;
+ // start by putting $viewstart at midnight starting focusdate
+ $viewstart = mktime(0,0,0,$focus_month, $focus_day, $focus_year);
+ // then back up to the preceding Sunday;
+ $viewstart -= $wd * $d;
+ // then go to the end of the week for $viewend
+ $viewend = $viewstart + ((7 * $d) - 1);
+ $numberofweeks = 0;
+} else {
+ $firstweek = $currentweek;
+ $lastweek = $currentweek;
+ $viewstart = mktime(0,0,0,$focus_month, $focus_day, $focus_year);
+ $viewend = $viewstart + ($d - 1);
+ $weekdays = array(date('w',$focusdate));
+ $numberofweeks = 0;
+}
+// untested (by me, anyway!) function grabbed from the php.net site:
+// [2004/01/05:rpg]
+function m_weeks($y, $m){
+ // monthday array
+ $monthdays = array(1=>31, 3=>31, 4=>30, 5=>31, 6=>30,7=>31,
+ 8=>31, 9=>30, 10=>31, 11=>30, 12=>31);
+ // weekdays remaining in a week starting on 7 - Sunday...(could be changed)
+ $weekdays = array(7=>7, 1=>6, 2=>5, 3=>4, 4=>3, 5=>2, 6=>1);
+ $date = mktime( 0, 0, 0, $m, 1, $y);
+ $leap = date("L", $date);
+ // if it is a leap year set February to 29 days, otherwise 28
+ $monthdays[2] = ($leap ? 29 : 28);
+ // get the weekday of the first day of the month
+ $wn = strftime("%u",$date);
+ $days = $monthdays[$m] - $weekdays[$wn];
+ return (ceil($days/7) + 1);
+}
+
+
+$smarty->assign('viewstart', $viewstart);
+$smarty->assign('viewend', $viewend);
+$smarty->assign('numberofweeks', $numberofweeks);
+
+$daysnames = array(
+ tra("Sunday"),
+ tra("Monday"),
+ tra("Tuesday"),
+ tra("Wednesday"),
+ tra("Thursday"),
+ tra("Friday"),
+ tra("Saturday")
+);
+
+$weeks = array();
+$cell = array();
+
+if ($_SESSION['CalendarViewGroups']) {
+ $listevents = $calendarlib->listItems($_SESSION['CalendarViewGroups'], $gBitUser->mUserId, $viewstart, $viewend, 0, 50, 'name_desc', '');
+} else {
+ $listevents = array();
+}
+
+if ($_SESSION['CalendarViewTikiCals']) {
+ $listtikievents = $calendarlib->listTikiItems($_SESSION['CalendarViewTikiCals'], $gBitUser->mUserId, $viewstart, $viewend, 0, 50, 'name_desc', '');
+} else {
+ $listtikievents = array();
+}
+
+define("weekInSeconds", 604800);
+
+// note that number of weeks starts at ZERO (i.e., zero = 1 week to display).
+for ($i = 0; $i <= $numberofweeks; $i++) {
+ $wee = $firstweek + $i;
+
+ $weeks[] = $wee;
+
+ // $startOfWeek is a unix timestamp
+ $startOfWeek = $viewstart + $i * weekInSeconds;
+
+ foreach ($weekdays as $w) {
+ $leday = array();
+ $dday = $startOfWeek + $d * $w;
+ $cell[$i][$w]['day'] = $dday;
+ if (isset($listevents["$dday"])) {
+ $e = 0;
+
+ foreach ($listevents["$dday"] as $le) {
+ $leday["{$le['time']}$e"] = $le;
+
+ $smarty->assign_by_ref('cellextra', $le["extra"]);
+ $smarty->assign_by_ref('cellhead', $le["head"]);
+ $smarty->assign_by_ref('cellprio', $le["prio"]);
+ $smarty->assign_by_ref('cellcalname', $le["calname"]);
+ $smarty->assign_by_ref('cellname', $le["name"]);
+ $smarty->assign_by_ref('celldescription', $le["description"]);
+ $leday["{$le['time']}$e"]["over"] = $smarty->fetch("bitpackage:calendar/calendar_box.tpl");
+ $e++;
+ }
+ }
+
+ if (isset($listtikievents["$dday"])) {
+ $e = 0;
+
+ foreach ($listtikievents["$dday"] as $lte) {
+ $leday["{$lte['time']}$e"] = $lte;
+
+ $smarty->assign('cellextra', "");
+ $smarty->assign_by_ref('cellhead', $lte["head"]);
+ $smarty->assign_by_ref('cellprio', $lte["prio"]);
+ $smarty->assign_by_ref('cellcalname', $lte["calname"]);
+ $smarty->assign_by_ref('cellname', $lte["name"]);
+ $smarty->assign_by_ref('celldescription', $lte["description"]);
+ $leday["{$lte['time']}$e"]["over"] = $smarty->fetch("bitpackage:calendar/calendar_box.tpl");
+ $e++;
+ }
+ }
+
+ if (is_array($leday)) {
+ ksort ($leday);
+ $cell[$i][$w]['items'] = array_values($leday);
+ }
+ }
+}
+
+$hrows = array();
+if ($_SESSION['CalendarViewMode'] == 'day') {
+ foreach ($cell[0]["{$weekdays[0]}"]['items'] as $dayitems) {
+ $rawhour = substr($dayitems['time'],0,2);
+ $dayitems['mins'] = substr($dayitems['time'],2);
+ $hrows["$rawhour"][] = $dayitems;
+ }
+}
+$smarty->assign('hrows', $hrows);
+
+$smarty->assign('trunc', $trunc);
+$smarty->assign('daformat', $tikilib->get_long_date_format()." ".tra("at")." %H:%M");
+$smarty->assign('daformat2', $tikilib->get_long_date_format());
+$smarty->assign('currentweek', $currentweek);
+$smarty->assign('firstweek', $firstweek);
+$smarty->assign('lastweek', $lastweek);
+$smarty->assign('weekdays', $weekdays);
+$smarty->assign('weeks', $weeks);
+$smarty->assign('daysnames', $daysnames);
+$smarty->assign('cell', $cell);
+$smarty->assign('var', '');
+
+$section = 'calendar';
+
+
+$gBitSystem->display( 'bitpackage:calendar/calendar.tpl');
+
+//echo "<pre>";print_r($cell);echo "</pre>";
+?>
diff --git a/modules/index.php b/modules/index.php
new file mode 100644
index 0000000..3e305fe
--- /dev/null
+++ b/modules/index.php
@@ -0,0 +1,6 @@
+<?php
+
+ // This is not a package.
+ header ("location: ../index.php");
+
+?> \ No newline at end of file
diff --git a/modules/mod_calendar.tpl b/modules/mod_calendar.tpl
new file mode 100644
index 0000000..69a7fc4
--- /dev/null
+++ b/modules/mod_calendar.tpl
@@ -0,0 +1,137 @@
+{* $Header: /cvsroot/bitweaver/_bit_calendar/modules/mod_calendar.tpl,v 1.1 2005/07/15 12:25:01 bitweaver Exp $ *}
+
+{php}
+include_once( CALENDAR_PKG_PATH."Calendar.php");
+global $dbTiki,$tikilib;
+if(isset($_SESSION["thedate"])) {
+ $day=date("d",$_SESSION["thedate"]);
+ $mon=date("m",$_SESSION["thedate"]);
+ $year=date("Y",$_SESSION["thedate"]);
+} else {
+ $day=date( "d", $tikilib->server_time_to_site_time( time() ) );
+ $mon=date( "m", $tikilib->server_time_to_site_time( time() ) );
+ $year=date( "Y", $tikilib->server_time_to_site_time( time() ) );
+}
+if(isset($_REQUEST["day"])) {
+ $day = $_REQUEST["day"];
+}
+
+if(isset($_REQUEST["mon"])) {
+ $mon = $_REQUEST["mon"];
+}
+
+if(isset($_REQUEST["year"])) {
+ $year = $_REQUEST["year"];
+}
+
+$thedate = mktime(23,59,59,$mon,$day,$year);
+$_SESSION["thedate"] = $thedate;
+
+// Calculate number of days in month
+// The format is S M T W T F S
+$c = new Calendar("en");
+$v = mb_substr(tra($c->nameOfMonth($mon)),0,3);
+$dayofweek = tra($c->dayOfWeekStr($day,$mon,$year));
+if (false) { // to have the months collected by get_strings.php
+ tra("January"); tra("February"); tra("March"); tra("April"); tra("May");tra("June"); tra("July"); tra("August"); tra("September"); tra("October"); tra("November"); tra("December" );
+}
+
+$parsed = parse_url($_SERVER["REQUEST_URI"]);
+if (!isset($parsed["query"])) {
+ $parsed["query"]='';
+}
+parse_str($parsed["query"],$query);
+unset($query["day"]);
+unset($query["mon"]);
+unset($query["year"]);
+$father=$parsed["path"];
+if (count($query)>0) {
+ $first=1;
+ foreach ($query as $name => $val) {
+ if ($first) {
+ $first=false;
+ $father.='?'.$name.'='.$val;
+ } else {
+ $father.='&amp;'.$name.'='.$val;
+ }
+ }
+ $father.='&amp;';
+} else {
+ $father.='?';
+}
+
+if (!strstr($father,"?")) {
+ $todaylink=$father."day=".date("d")."&amp;mon=".date("m")."&amp;year=".date("Y");
+} else {
+ $todaylink=$father."day=".date("d")."&amp;mon=".date("m")."&amp;year=".date("Y");
+}
+{/php}
+
+{bitmodule title="$moduleTitle" name="tikicalendar"}
+ <!-- THIS ROW DISPLAYS THE YEAR AND MONTH -->
+ <div class="navigation">
+{php}
+ $mong=$mon-1;
+ $url="$father"."day=$day&amp;mon=$mong&amp;year=$year";
+ print( "<a href=\"".$url."\"> &laquo; </a>" );
+ print( $v );
+ $mong=$mon+1;
+ $url="$father"."day=$day&amp;mon=$mong&amp;year=$year";
+ print( "<a href=\"".$url."\"> &raquo; </a>" );
+ print( "&nbsp;" );
+ $mong=$year-1;
+ $url="$father"."day=$day&amp;mon=$mon&amp;year=$mong";
+ print( "<a href=\"".$url."\"> &laquo; </a>" );
+ print( $year );
+ $mong=$year+1;
+ $url="$father"."day=$day&amp;mon=$mon&amp;year=$mong";
+ print( "<a href=\"".$url."\"> &raquo; </a>" );
+{/php}
+ </div>
+{php}
+ $mat = $c->getDisplayMatrix($day,$mon,$year);
+ $pmat = $c->getPureMatrix($day,$mon,$year);
+{/php}
+ <table class="mother">
+ <!-- DAYS OF THE WEEK -->
+ <tr>
+{php}
+ for ($i=0;$i<7;$i++) {
+ $dayW = tra($c->dayOfWeekStrFromNo($i+1));
+ $dayp = mb_substr($dayW,0,1);
+ print("<th>$dayp</th>");
+ }
+{/php}
+ </tr>
+ <!-- TRs WITH DAYS -->
+{php}
+ for ($i=0;$i<6;$i++) {
+ print("<tr>");
+ for ($j=0;$j<7;$j++) {
+ $in = $i*7+$j;
+ $pval = $pmat[$in];
+ $val = $mat[$in];
+ if (substr($val,0,1)=='+') {
+ $val = substr($val,1,strlen($val)-1);
+ $classval = "class=\"highlight\"";
+ } else {
+ $classval = "";
+ }
+ if ($val != " ") {
+ print( "<td>" );
+ $url = $father."day=$pval&amp;mon=$mon&amp;year=$year";
+ print( "<a $classval href=\"$url\">$val</a></td>");
+ } else {
+ print( "<td>&nbsp;</td>" );
+ }
+ }
+ print("</tr>");
+ }
+{/php}
+ </table>
+ <div class="navigation">
+{php}
+ print( "<a href=\"".$todaylink."\">".tra("Today")."</a>" );
+{/php}
+ </div>
+{/bitmodule}
diff --git a/templates/add_calendars.tpl b/templates/add_calendars.tpl
new file mode 100644
index 0000000..c45bf3a
--- /dev/null
+++ b/templates/add_calendars.tpl
@@ -0,0 +1,109 @@
+<div class="display tikicalendar">
+<div class="header">
+<h1><a href="{$gBitLoc.CALENDAR_PKG_URL}admin/index.php">{tr}Manage Calendars{/tr}</a></h1>
+</div>
+
+<div class="body">
+
+<h2>{tr}Create/edit Calendars{/tr}</h2>
+
+<form action="{$gBitLoc.CALENDAR_PKG_URL}add_calendar.php" method="post">
+ <input type="hidden" name="calendar_id" value="{$calendar_id|escape}" />
+ <table class="panel">
+ <tr><td>
+ {tr}Name{/tr}:</td><td>
+ <input type="text" name="name" value="{$name|escape}" />
+ </td></tr>
+ <tr><td>
+ {tr}Description{/tr}:</td><td>
+ <textarea name="description" rows="5" cols="40">{$description|escape}</textarea>
+ </td></tr>
+ <tr><td>
+ {tr}Custom Locations{/tr}:</td><td>
+ <select name="customlocations">
+ <option value="y" {if $customlocations eq 'y'}selected="selected"{/if}>{tr}yes{/tr}</option>
+ <option value="n" {if $customlocations eq 'n'}selected="selected"{/if}>{tr}no{/tr}</option>
+ </select>
+ </td></tr>
+ <tr><td>
+ {tr}Custom Categories{/tr}:</td><td>
+ <select name="customcategories">
+ <option value="y" {if $customcategories eq 'y'}selected="selected"{/if}>{tr}yes{/tr}</option>
+ <option value="n" {if $customcategories eq 'n'}selected="selected"{/if}>{tr}no{/tr}</option>
+ </select>
+ </td></tr>
+ <tr><td>
+ {tr}Custom Languages{/tr}:</td><td>
+ <select name="customlanguages">
+ <option value="y" {if $customlanguages eq 'y'}selected="selected"{/if}>{tr}yes{/tr}</option>
+ <option value="n" {if $customlanguages eq 'n'}selected="selected"{/if}>{tr}no{/tr}</option>
+ </select>
+ </td></tr>
+ <tr><td>
+ {tr}Custom Priorities{/tr}:</td><td>
+ <select name="custompriorities">
+ <option value="y" {if $custompriorities eq 'y'}selected="selected"{/if}>{tr}yes{/tr}</option>
+ <option value="n" {if $custompriorities eq 'n'}selected="selected"{/if}>{tr}no{/tr}</option>
+ </select>
+ </td></tr>
+ <tr class="panelsubmitrow"><td colspan="2">
+ <input type="submit" name="save" value="{tr}Save{/tr}" />
+ </td></tr>
+</table>
+</form>
+
+<div class="navbar">
+ <a href="{$gBitLoc.CALENDAR_PKG_URL}add_calendar.php">{tr}Create new calendar{/tr}</a>
+</div>
+
+<h2>{tr}List of Calendars{/tr}</h2>
+{if count($calendars) gt 0}
+<form method="get" action="{$gBitLoc.CALENDAR_PKG_URL}add_calendar.php">
+<table class="find">
+<tr><td>{tr}Find{/tr}</td>
+ <td>
+ <input type="text" name="find" value="{$find|escape}" />
+ </td><td>
+ <input type="submit" value="{tr}find{/tr}" name="search" />
+ <input type="hidden" name="sort_mode" value="{$sort_mode|escape}" />
+ </td>
+</tr>
+</table>
+</form>
+
+<table class="data">
+<tr>
+<th><a href="{$gBitLoc.CALENDAR_PKG_URL}add_calendar.php?offset={$offset}&amp;sort_mode={if $sort_mode eq 'calendar_id_desc'}calendar_id_asc{else}calendar_id_desc{/if}">{tr}ID{/tr}</a></th>
+<th><a href="{$gBitLoc.CALENDAR_PKG_URL}add_calendar.php?offset={$offset}&amp;sort_mode={if $sort_mode eq 'name_desc'}name_asc{else}name_desc{/if}">{tr}name{/tr}</a></th>
+<th><a href="{$gBitLoc.CALENDAR_PKG_URL}add_calendar.php?offset={$offset}&amp;sort_mode={if $sort_mode eq 'customlocations_desc'}customlocations_asc{else}customlocations_desc{/if}">{tr}location{/tr}</a></th>
+<th><a href="{$gBitLoc.CALENDAR_PKG_URL}add_calendar.php?offset={$offset}&amp;sort_mode={if $sort_mode eq 'customcategories_desc'}customcategories_asc{else}customcategories_desc{/if}">{tr}category{/tr}</a></th>
+<th><a href="{$gBitLoc.CALENDAR_PKG_URL}add_calendar.php?offset={$offset}&amp;sort_mode={if $sort_mode eq 'customlanguages_desc'}customlanguages_asc{else}customlanguages_desc{/if}">{tr}language{/tr}</a></th>
+<th><a href="{$gBitLoc.CALENDAR_PKG_URL}add_calendar.php?offset={$offset}&amp;sort_mode={if $sort_mode eq 'custompriorities_desc'}custompriorities_asc{else}custompriorities_desc{/if}">{tr}priority{/tr}</a></th>
+<th>{tr}action{/tr}</th>
+</tr>
+{cycle values="even,odd" print=false}
+{foreach key=id item=cal from=$calendars}
+<tr class="{cycle}">
+<td>{$id}</td>
+<td><a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?calIds[]={$id}">{$cal.name}</a></td>
+<td align="center">{$cal.customlocations}</td>
+<td align="center">{$cal.customcategories}</td>
+<td align="center">{$cal.customlanguages}</td>
+<td align="center">{$cal.custompriorities}</td>
+<td align="right">
+ &nbsp;&nbsp;<a href="{$gBitLoc.CALENDAR_PKG_URL}add_calendar.php?offset={$offset}&amp;sort_mode={$sort_mode}&amp;drop={$id}" onclick="return confirmTheLink(this,'{tr}Are you sure you want to delete this calendar?{/tr}')" title="Click here to delete this calendar"><img class="icon" alt="{tr}Remove{/tr}" src="{$gBitLoc.LIBERTY_PKG_URL}icons/delete.gif" /></a>&nbsp;&nbsp;
+ <a href="{$gBitLoc.CALENDAR_PKG_URL}add_calendar.php?offset={$offset}&amp;sort_mode={$sort_mode}&amp;calendar_id={$id}"><img class="icon" alt="{tr}Edit{/tr}" src="{$gBitLoc.LIBERTY_PKG_URL}icons/edit.gif" /></a>
+</td></tr>
+{/foreach}
+</table>
+
+</div> {* end .body *}
+
+{*not working just now*}
+{*include file="bitpackage:kernel/pagination.tpl"*}
+
+{else}
+<div class="norecords">{tr}No records found{/tr}</div>
+{/if}
+
+</div> {* end .tikicalendar *}
diff --git a/templates/admin_calendar.tpl b/templates/admin_calendar.tpl
new file mode 100644
index 0000000..2b2c7c9
--- /dev/null
+++ b/templates/admin_calendar.tpl
@@ -0,0 +1,40 @@
+{strip}
+{form legend="Home Calendar"}
+ <input type="hidden" name="page" value="{$page}" />
+ <div class="row">
+ {formlabel label="Home Calendar" for="homeCalendar"}
+ {forminput}
+ <select name="homeCalendar" id="homeCalendar">
+ {section name=ix loop=$blogs}
+ <option value="{$blogs[ix].blog_id|escape}" {if $blogs[ix].blog_id eq $home_blog}selected="selected"{/if}>{$blogs[ix].title|truncate:20:"...":true}</option>
+ {sectionelse}
+ <option>{tr}No records found{/tr}</option>
+ {/section}
+ </select>
+ {/forminput}
+ </div>
+
+ <div class="row submit">
+ <input type="submit" name="calendarset" value="{tr}Change preference{/tr}" />
+ </div>
+{/form}
+
+{form legend="Calendar Features"}
+ <input type="hidden" name="page" value="{$page}" />
+
+ {foreach from=$formCalendarFeatures key=item item=output}
+ <div class="row">
+ {formlabel label=`$output.label` for=$item}
+ {forminput}
+ {html_checkboxes name="$item" values="y" checked=`$gBitSystemPrefs.$item` labels=false id=$item}
+ {/forminput}
+ {formhelp note=`$output.help` page=`$output.page`}
+ </div>
+ {/foreach}
+
+ <div class="row submit">
+ <input type="submit" name="calendarfeatures" value="{tr}Change preferences{/tr}" />
+ </div>
+{/form}
+
+{/strip} \ No newline at end of file
diff --git a/templates/calendar.tpl b/templates/calendar.tpl
new file mode 100644
index 0000000..6b4cbfd
--- /dev/null
+++ b/templates/calendar.tpl
@@ -0,0 +1,458 @@
+{* $Header: /cvsroot/bitweaver/_bit_calendar/templates/calendar.tpl,v 1.1 2005/07/15 12:25:01 bitweaver Exp $ *}
+
+{popup_init src="`$gBitLoc.THEMES_PKG_URL`overlib.js"}
+<div class="floaticon">
+{if $bit_p_admin_calendar eq 'y' or $bit_p_admin eq 'y'}
+ <a href="{$gBitLoc.CALENDAR_PKG_URL}admin/index.php"><img class="icon" src="{$gBitLoc.LIBERTY_PKG_URL}icons/config.gif" alt="{tr}admin{/tr}" /></a>
+{/if}
+</div>
+
+<div class="display tikicalendar">
+<div class="header">
+<h1><a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?view={$view}">{tr}Calendar{/tr}</a></h1>
+</div>
+
+<div class="body">
+
+{* ----------------------------------- *}
+
+<div id="tab" style="display:{if $smarty.cookies.tab eq 'c' or $show_navtab or $calendar_id gt 0}none{else}block{/if};">
+ <div class="navbar above">
+ <a href="javascript:show('tabcal',1);{if $modifiable}hide('tabnav',1);{/if}hide('tab',1);">{tr}Calendars Panel{/tr}</a>
+ {if $modifiable}
+ <a href="javascript:hide('tabcal',1);show('tabnav',1);hide('tab',1);">{tr}Events Panel{/tr}</a>
+ {/if}
+ </div>
+</div>
+
+{* ----------------------------------- *}
+
+<div id="tabcal" style="display:{if $smarty.cookies.tabcal eq 'o' and !$show_navtab}block{else}none{/if};">
+ <div class="navbar above">
+ <a class="highlight" href="javascript:show('tabcal',1);{if $modifiable}hide('tabnav',1);{/if}hide('tab',1);">{tr}Calendars Panel{/tr}</a>
+ {if $modifiable}
+ <a href="javascript:hide('tabcal',1);show('tabnav',1);hide('tab',1);">{tr}Events Panel{/tr}</a>
+ {/if}
+ <a href="javascript:hide('tabcal',1);{if $modifiable}hide('tabnav',1);{/if}show('tab',1);">{tr}Hide{/tr}</a>
+ </div>
+
+ <div class="tikicalendar box">
+ <form method="get" action="{$gBitLoc.CALENDAR_PKG_URL}index.php" id="f">
+ <table class="panel">
+ <tr>
+
+ {if $modifiable}
+ <td valign="top" width="50%">
+ <div class="boxtitle">{tr}Group Calendars{/tr}</div>
+ <div class="boxcontent">
+ <div
+ onclick="document.getElementById('calswitch').click();document.getElementById('calswitch').checked=!document.getElementById('calswitch').checked;document.getElementById('calswitch').click();"
+ ><input name="calswitch" id="calswitch" type="checkbox" onclick="switchCheckboxes(this.form.id,'calIds[]','calswitch');this.checked=!this.checked;" /> {tr}check / uncheck all{/tr}
+ </div>
+ {foreach item=k from=$listcals}
+ <div
+ onclick="document.getElementById('groupcal_{$k}').checked=!document.getElementById('groupcal_{$k}').checked;"
+ onmouseout="this.style.textDecoration='none';"
+ onmouseover="this.style.textDecoration='underline';"
+ ><input type="checkbox" name="calIds[]" value="{$k|escape}" id="groupcal_{$k}" {if $thiscal.$k}checked="checked"{/if}
+ onclick="this.checked=!this.checked;" />
+ {$infocals.$k.name} (id #{$k})
+ </div>
+ {/foreach}
+ <span class="Cal0">{tr}Tentative{/tr}</span>
+ <span class="Cal1">{tr}Confirmed{/tr}</span>
+ <span class="Cal2">{tr}Cancelled{/tr}</span>
+ </div>
+ </td>
+ {/if}
+
+ {if $modifiable}
+ <td valign="top" width="50%">
+ {else}
+ <td valign="top" width="100%">
+ {/if}
+ <div class="boxtitle">{tr}Tools Calendars{/tr}</div>
+ <div class="boxcontent">
+ <div
+ onclick="document.getElementById('tikiswitch').click();document.getElementById('tikiswitch').checked=!document.getElementById('tikiswitch').checked;document.getElementById('tikiswitch').click();"
+ ><input name="tikiswitch" id="tikiswitch" type="checkbox" onclick="switchCheckboxes(this.form.id,'tikicals[]','tikiswitch');this.checked=!this.checked;" /> {tr}check / uncheck all{/tr}
+ </div>
+ {foreach from=$tikiItems key=ki item=vi}
+ {if $vi.feature eq 'y' and $vi.right eq 'y'}
+ <div
+ onclick="document.getElementById('tikical_{$ki}').checked=!document.getElementById('tikical_{$ki}').checked;"
+ onmouseout="this.style.textDecoration='none';"
+ onmouseover="this.style.textDecoration='underline';"
+ ><input type="checkbox" name="tikicals[]" value="{$ki|escape}" id="tikical_{$ki}" {if $tikical.$ki}checked="checked"{/if} onclick="this.checked=!this.checked;"/>
+ <span class="Cal{$ki}">{$vi.label}</span>
+ </div>
+ {/if}
+ {/foreach}
+ </div>
+ </td>
+ </tr>
+ <tr class="panelsubmitrow">
+ <td colspan="2">
+ <input type="submit" name="refresh" value="{tr}Refresh{/tr}" />
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+</div>
+
+{if $modifiable}
+{* - Edit Event Panel - *}
+<div id="tabnav" style="display:{if $smarty.cookies.tabnav eq 'o' or $show_navtab or $calendar_id gt 0}block{else}none{/if};">
+ <div class="navbar above">
+ <a href="javascript:show('tabcal',1);hide('tabnav',1);hide('tab',1);">{tr}Calendars Panel{/tr}</a>
+ <a href="javascript:hide('tabcal',1);show('tabnav',1);hide('tab',1);" class="highlight">{tr}Events Panel{/tr}</a>
+ <a href="javascript:hide('tabcal',1);hide('tabnav',1);show('tab',1);">{tr}Hide{/tr}</a>
+ </div>
+
+ <div class="tikicalendar box">
+ {* ······························· *}
+ {if ($calitem_id > 0 and $bit_p_change_events eq 'y') or ($calendar_id > 0 and $bit_p_add_events eq 'y')}
+
+ {if $calitem_id}
+ <div class="boxtitle">{tr}Edit Calendar Item{/tr}</div>
+ <h3>{$calname}: {$name|default:"new event"} (id #{$calitem_id})</h3>
+ <small>
+ {tr}Created on{/tr} {$created|bit_long_date} {$created|bit_long_time}<br />
+ {tr}Modified on{/tr} {$last_modified|bit_long_date} {$last_modified|bit_long_time}<br />
+ {tr}by{/tr} <span class="user_id">{$lastUser}</span>
+ </small>
+ {else}
+ <div class="boxtitle">{tr}New Calendar Item{/tr}</div>
+ {/if}
+
+ <form enctype="multipart/form-data" method="post" action="{$gBitLoc.CALENDAR_PKG_URL}index.php" id="editcalitem" id="f" style="display:block;">
+ <input type="hidden" name="editmode" value="1" />
+ {if $bit_p_change_events and $calitem_id}
+ <input type="hidden" name="calitem_id" value="{$calitem_id}" />
+ {/if}
+ <table class="panel">
+ {if $customcategories eq 'y'}
+ <tr><td>{tr}Category{/tr}</td><td>
+ <select name="category_id">
+ {section name=t loop=$listcat}
+ {if $listcat[t]}
+ <option value="{$listcat[t].category_id|escape}" {if $category_id eq $listcat[t].category_id}selected="selected"{/if}>{$listcat[t].name}</option>
+ {/if}
+ {/section}
+ </select>
+ {tr}or create a new category{/tr}
+ <input type="text" name="newcat" value="" />
+ {if $category_id}
+ <small>( {$categoryName} )</small>
+ {/if}
+ </td></tr>
+ {/if}
+
+ {if $customlocations eq 'y'}
+ <tr><td class="form">{tr}Location{/tr}</td><td class="form">
+ <select name="location_id">
+ {section name=l loop=$listloc}
+ {if $listloc[l]}
+ <option value="{$listloc[l].location_id|escape}" {if $location_id eq $listloc[l].location_id}selected="selected"{/if}>{$listloc[l].name}</option>
+ {/if}
+ {/section}
+ </select>
+ {tr}or create a new location{/tr}
+ <input type="text" name="newloc" value="" />
+ {if $location_id}
+ <span class="mini">( {$locationName} )</span>
+ {/if}
+ </td></tr>
+ {/if}
+
+ {if $customparticipants eq 'y'}
+ <tr><td class="form">{tr}Organized by{/tr}</td><td class="form">
+ <input type="text" name="organizers" value="{$organizers|escape}" id="organizers" />
+ {tr}comma separated usernames{/tr}
+ </td></tr>
+
+ <tr><td class="form">{tr}Participants{/tr}</td><td class="form">
+ <input type="text" name="participants" value="{$participants|escape}" id="participants" />
+ {tr}comma separated username:role{/tr}
+ {tr}with roles{/tr} {tr}Chair{/tr}:0, {tr}Required{/tr}:1, {tr}Optional{/tr}:2, {tr}None{/tr}:3
+ </td></tr>
+ {/if}
+
+ <tr><td>{tr}Start{/tr}</td><td>
+ {if $gBitSystemPrefs.feature_jscalendar eq 'y'}
+ <input type="hidden" name="start_date_input" value="{$start_time|date_format:"%m/%d/%Y %H:%M"}" id="start_date_input" />
+ <span id="start_date_display" class="daterow">{$start_time|date_format:$daformat}</span>
+ <script type="text/javascript">
+{literal}Calendar.setup( { {/literal}
+date : "{$start_time|date_format:"%m/%d/%Y %H:%M"}", // initial date
+inputField : "start_date_input", // ID of the input field
+ifFormat : "%m/%d/%Y %H:%M", // the date format
+displayArea : "start_date_display", // ID of the span where the date is to be shown
+daFormat : "{$daformat}", // format of the displayed date
+showsTime : true,
+electric : true,
+align : "bR"
+{literal} } );{/literal}
+ </script>
+ {else}
+ {html_select_date time=$start_time prefix="start_" end_year="+4" field_order=DMY}
+ {html_select_time minute_interval=10 time=$start_time prefix="starth_" display_seconds=false use_24_hours=true}
+ {/if}
+ </td></tr>
+
+ <tr><td>{tr}End{/tr}</td><td>
+ {if $gBitSystemPrefs.feature_jscalendar eq 'y'}
+ <input type="hidden" name="end_date_input" value="{$end_time|date_format:"%m/%d/%Y %H:%M"}" id="end_date_input" />
+ <span id="end_date_display" class="daterow">{$end_time|date_format:$daformat}</span>
+ <script type="text/javascript">
+{literal}Calendar.setup( { {/literal}
+date : "{$end_time|date_format:"%m/%d/%Y %H:%M"}", // initial date
+inputField : "end_date_input", // ID of the input field
+ifFormat : "%m/%d/%Y %H:%M", // the date format
+displayArea : "end_date_display", // ID of the span where the date is to be shown
+daFormat : "{$daformat}", // format of the displayed date
+showsTime : true,
+electric : true,
+align : "bR"
+{literal} } );{/literal}
+ </script>
+ {else}
+ {html_select_date time=$end_time prefix="end_" end_year="+4" field_order=DMY}
+ {html_select_time minute_interval=10 time=$end_time prefix="endh_" display_seconds=false use_24_hours=true}
+ {/if}
+ </td></tr>
+
+ <tr><td>{tr}Name{/tr}</td><td><input type="text" name="name" value="{$name|escape}" />
+ {if $name}<span class="mini">( {$name} )</span>{/if}
+ </td></tr>
+ <tr><td>{tr}Description{/tr}</td><td>
+ <textarea name="description" rows="8" cols="80" id="description">{$description|escape}</textarea>
+ {if $description}<div class="description">({$description})</div>{/if}
+ </td></tr>
+
+ <tr><td>{tr}URL{/tr}</td><td><input type="text" name="url" value="{$url|escape}" />
+ {if $url}<span class="url">(<a href="{$url}">{$url}</a>)</span>{/if}
+ </td></tr>
+
+ {if $custompriorities eq 'y'}
+ <tr>
+ <td>{tr}Priority{/tr}</td>
+ <td>
+ <select name="priority">
+ <option value="1" {if $priority eq 1}selected="selected"{/if} class="cal prio1">1</option>
+ <option value="2" {if $priority eq 2}selected="selected"{/if} class="cal prio2">2</option>
+ <option value="3" {if $priority eq 3}selected="selected"{/if} class="cal prio3">3</option>
+ <option value="4" {if $priority eq 4}selected="selected"{/if} class="cal prio4">4</option>
+ <option value="5" {if $priority eq 5}selected="selected"{/if} class="cal prio5">5</option>
+ <option value="6" {if $priority eq 6}selected="selected"{/if} class="cal prio6">6</option>
+ <option value="7" {if $priority eq 7}selected="selected"{/if} class="cal prio7">7</option>
+ <option value="8" {if $priority eq 8}selected="selected"{/if} class="cal prio8">8</option>
+ <option value="9" {if $priority eq 9}selected="selected"{/if} class="cal prio9">9</option>
+ </select>
+ {if $priority}<span class="mini">( <span class="cal prio{$priority}">{$priority}</span> )</span>{/if}
+ </td>
+ </tr>
+ {/if}
+
+ <tr>
+ <td>{tr}Status{/tr}</td>
+ <td>
+ <select name="status">
+ <option value="0" {if $status eq 0}selected="selected"{/if}>0:{tr}Tentative{/tr}</option>
+ <option value="1" {if $status eq 1}selected="selected"{/if}>1:{tr}Confirmed{/tr}</option>
+ <option value="2" {if $status eq 2}selected="selected"{/if}>2:{tr}Cancelled{/tr}</option>
+ </select>
+ {if $calitem_id}<span class="Cal{$status}"><span class="mini">( {$status} )</span></span>{/if}
+ </td>
+ </tr>
+
+ {if $customlanguages eq 'y'}
+ <tr>
+ <td>{tr}Language{/tr}</td>
+ <td>
+ <select name="lang">
+ {section name=ix loop=$languages}
+ <option value="{$languages[ix].value|escape}"
+ {$languages[ix].name}
+ {if $lang eq $languages[ix].value}selected="selected"{/if}>
+ </option>
+ {/section}
+ </select>
+ {if $lang}<span class="mini">( {$lang} )</span>{/if}
+ </td>
+ </tr>
+ {/if}
+
+ <tr class="panelsubmitrow">
+ <td colspan="2">
+ <input type="submit" name="save" value="{tr}save{/tr}" />
+ {if $calitem_id and $bit_p_change_events}
+ <input type="submit" name="copy" value="{tr}duplicate{/tr}" />
+ {/if}
+ {tr}to{/tr}
+ <select name="calendar_id">
+ {foreach item=lc from=$listcals}
+ <option value="{$lc|escape}" {if $calendar_id eq $lc}selected="selected"{/if} onchange="document.forms[f].submit();">{$infocals.$lc.name}</option>
+ {/foreach}
+ </select>
+ {tr}or{/tr}
+ <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?calitem_id={$calitem_id}&amp;delete=1">{tr}delete{/tr}</a>
+ </td>
+ </tr>
+
+ </table>
+ </form>
+ {else}
+ {* - Add New Event - *}
+ <h2>{tr}Add Calendar Item{/tr}</h2>
+ <ul>
+ {foreach name=licals item=k from=$listcals}
+ {if $infocals.$k.bit_p_add_events eq 'y'}
+ <li>{tr}in{/tr} <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?todate={$focusdate}&amp;calendar_id={$k}&amp;editmode=add" class="link">{$infocals.$k.name}</a></li>
+ {/if}
+ {/foreach}
+ </ul>
+ {* ······························· *}
+ {/if}
+ </div>
+</div>
+{/if}
+
+{* - Date Selection Row - *}
+<div class="navigation">
+<table>
+ <tr><td>
+ {if $gBitSystemPrefs.feature_jscalendar eq 'y'}
+ <form action="{$gBitLoc.CALENDAR_PKG_URL}index.php" method="get" id="f">
+ <input type="hidden" id="todate" name="todate" value="{$focusdate|date_format:"%B %e, %Y %H:%M"}" />
+ <span title="{tr}Date Selector{/tr}" id="datrigger" class="daterow" >{$focusdate|bit_long_date}</span>
+ &lt;- {tr}click to navigate{/tr}
+ </form>
+ <script type="text/javascript">
+{literal}function gotocal() { {/literal}
+window.location = '{$gBitLoc.CALENDAR_PKG_URL}index.php?todate='+document.getElementById('todate').value+'{if $calendar_id}&amp;calendar_id={$calendar_id}&amp;editmode=add{/if}';
+{literal} } {/literal}
+{literal}Calendar.setup( { {/literal}
+date : "{$focusdate|date_format:"%m/%d/%Y %H:%M"}", // initial date
+inputField : "todate", // ID of the input field
+ifFormat : "%s", // the date format
+displayArea : "datrigger", // ID of the span where the date is to be shown
+daFormat : "{"%d/%m/%Y %H:%M"}", // format of the displayed date
+electric : false,
+onUpdate : gotocal
+{literal} } );{/literal}
+ </script>
+ </td>
+ <td nowrap="nowrap" width="120" align="right">
+ <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?viewmode=day" class="viewmode{if $viewmode eq 'day'}on{else}off{/if}"><img class="icon" src="{$gBitLoc.IMG_PKG_URL}icons/day.gif" width="30" height="24" border="0" alt="{tr}day{/tr}" align="top" /></a>
+ <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?viewmode=week" class="viewmode{if $viewmode eq 'week'}on{else}off{/if}"><img class="icon" src="{$gBitLoc.IMG_PKG_URL}icons/week.gif" width="30" height="24" border="0" alt="{tr}week{/tr}" align="top" /></a>
+ <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?viewmode=month" class="viewmode{if $viewmode eq 'month'}on{else}off{/if}"><img class="icon" src="{$gBitLoc.IMG_PKG_URL}icons/month.gif" width="30" height="24" border="0" alt="{tr}month{/tr}" align="top" /></a>
+ {else}
+ <table><tr><td rowspan="2" align="left">
+ <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?todate={$daybefore}" title="{$daybefore|bit_long_date}">&laquo; {tr}day{/tr}</a><br />
+ <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?todate={$weekbefore}" title="{$weekbefore|bit_long_date}">&laquo; {tr}week{/tr}</a><br />
+ <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?todate={$monthbefore}" title="{$monthbefore|bit_long_date}">&laquo; {tr}month{/tr}</a>
+ </td>
+ <td align="center">
+ <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?todate={$now}" title="{$now|bit_short_date}"><b>{tr}today{/tr}:</b> {$now|bit_short_date}</a>
+ </td>
+ <td rowspan="2" align="right">
+ <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?todate={$dayafter}" title="{$dayafter|bit_long_date}">{tr}day{/tr} &raquo;</a><br />
+ <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?todate={$weekafter}" title="{$weekafter|bit_long_date}">{tr}week{/tr} &raquo;</a><br />
+ <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?todate={$monthafter}" title="{$monthafter|bit_long_date}">{tr}month{/tr} &raquo;</a>
+ </td>
+ </tr><tr>
+ <td align="center">
+ <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?viewmode=day" class="viewmode{if $viewmode eq 'day'}on{else}off{/if}"><img class="icon" src="{$gBitLoc.IMG_PKG_URL}icons/day.gif" width="30" height="24" border="0" alt="{tr}day{/tr}" align="top" /></a>
+ <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?viewmode=week" class="viewmode{if $viewmode eq 'week'}on{else}off{/if}"><img class="icon" src="{$gBitLoc.IMG_PKG_URL}icons/week.gif" width="30" height="24" border="0" alt="{tr}week{/tr}" align="top" /></a>
+ <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?viewmode=month" class="viewmode{if $viewmode eq 'month'}on{else}off{/if}"><img class="icon" src="{$gBitLoc.IMG_PKG_URL}icons/month.gif" width="30" height="24" border="0" alt="{tr}month{/tr}" align="top" /></a>
+ </td>
+ </tr></table>
+ {/if}
+ </td>
+</tr></table>
+</div>
+
+
+
+{* - Calendar Grid - *}
+<table class="tikicalendar">
+<caption>{tr}selection{/tr}: {$focusdate|bit_long_date}</caption>
+{if $viewmode eq 'day'}
+{* - Single Day - *}
+ <tr>
+ <th width="42">{tr}Hours{/tr}</th>
+ <th>{tr}Events{/tr}</th>
+ </tr>
+ {cycle values="odd,even" print=false}
+ {section name=h loop=$hours}
+ <tr class="{cycle}">
+ <td width="42">{$hours[h]}{tr}h{/tr}</td>
+ <td>
+ {section name=hr loop=$hrows[h]}
+ <div class="Cal{$hrows[h][hr].type}">
+ {$hours[h]}:{$hrows[h][hr].mins} :
+ <a href="{$hrows[h][hr].url}">{$hrows[h][hr].name}</a>
+ {$hrows[h][hr].description}
+ </div>
+ {/section}
+ </td>
+ </tr>
+ {/section}
+{else}
+{* - Calendar Headings - *}
+ <tr>
+ <th width="2%"></th>
+ {section name=dn loop=$daysnames}
+ <th width="14%">{$daysnames[dn]}</th>
+ {/section}
+ </tr>
+ {section name=w loop=$cell}
+ <tr>
+ <th class="weeknumber">{$weeks[w]}</th>
+ {section name=d loop=$weekdays}
+
+ {if $viewmode eq "month"}
+ {if $cell[w][d].day|date_format:"%m" eq $focusmonth}
+ {cycle values="odd,even" print=false advance=false}
+ {else}
+ {cycle values="notmonth" print=false advance=false}
+ {/if}
+ {else}
+ {cycle values="odd,even" print=false advance=false}
+ {/if}
+
+ <td class="{cycle}">
+ {if $cell[w][d].day|date_format:"%m" eq $focusmonth or $viewmode eq "week"}
+ <div class="calday{if $cell[w][d].day eq $focusdate} highlight{/if}">
+ <a href="{$gBitLoc.CALENDAR_PKG_URL}index.php?todate={$cell[w][d].day}">{$cell[w][d].day|date_format:"%d/%m"}</a>
+ </div>
+
+ {* - Calendar Content - *}
+ <div class="calcontent">
+ {section name=items loop=$cell[w][d].items}
+ {assign var=over value=$cell[w][d].items[items].over}
+ <div class="Cal{$cell[w][d].items[items].type}{if $cell[w][d].items[items].calitem_id eq $calitem_id and $calitem_id|string_format:"%d" ne 0} highlight{/if}">
+ <span class="cal prio{$cell[w][d].items[items].prio}"><a href="{$cell[w][d].items[items].url}" {popup fullhtml="1" text=$over|escape:"javascript"|escape:"html"}>
+ {$cell[w][d].items[items].name|truncate:$trunc:".."|default:"..."}</a>
+ </span>
+ {if $cell[w][d].items[items].web}
+ <a href="{$cell[w][d].items[items].web}" class="calweb" title="{$cell[w][d].items[items].web}">w</a>
+ {/if}
+ <br />
+ </div>
+ {/section}
+ </div>
+ {else}
+ &nbsp;
+ {/if}
+ </td>
+ {/section}
+ </tr>
+ {/section}
+{/if}
+</table>
+
+</div>
+</div>
diff --git a/templates/calendar_box.tpl b/templates/calendar_box.tpl
new file mode 100644
index 0000000..c149c43
--- /dev/null
+++ b/templates/calendar_box.tpl
@@ -0,0 +1,13 @@
+<div class="tikicalendar popup box">
+ <div class="boxtitle">{$cellhead}
+ {if $cellprio}
+ <span class="calprio{$cellprio}">{$cellprio}</span>
+ {/if}
+ </div>
+ <div class="boxcontent"><b>{$cellname}</b>
+ {if $cellcalname}
+ {tr}in{/tr} <b>{$cellcalname}</b>
+ {/if}<br />
+ {$celldescription}
+ </div>
+</div>
diff --git a/templates/index.php b/templates/index.php
new file mode 100644
index 0000000..3e305fe
--- /dev/null
+++ b/templates/index.php
@@ -0,0 +1,6 @@
+<?php
+
+ // This is not a package.
+ header ("location: ../index.php");
+
+?> \ No newline at end of file
diff --git a/templates/menu_calendar.tpl b/templates/menu_calendar.tpl
new file mode 100644
index 0000000..466111a
--- /dev/null
+++ b/templates/menu_calendar.tpl
@@ -0,0 +1,10 @@
+{strip}
+<ul>
+{if $bit_p_view_calendar eq 'y'}
+ <li><a class="item" href="{$gBitLoc.CALENDAR_PKG_URL}index.php">{tr}Display Calendar{/tr}</a></li>
+{/if}
+{if $bit_p_add_events eq 'y'}
+ <li><a class="item" href="{$gBitLoc.CALENDAR_PKG_URL}edit.php">{tr}Create/Edit an Event{/tr}</a></li>
+{/if}
+</ul>
+{/strip} \ No newline at end of file
diff --git a/templates/menu_calendar_admin.tpl b/templates/menu_calendar_admin.tpl
new file mode 100644
index 0000000..e424fc0
--- /dev/null
+++ b/templates/menu_calendar_admin.tpl
@@ -0,0 +1,6 @@
+{strip}
+<ul>
+ <li><a class="item" href="{$gBitLoc.CALENDAR_PKG_URL}add_calendar.php">{tr}Create/Edit a Calendar{/tr}</a></li>
+ <li><a class="item" href="{$gBitLoc.KERNEL_PKG_URL}admin/index.php?page=calendar">{tr}Calendar settings{/tr}</a></li>
+</ul>
+{/strip} \ No newline at end of file