ApPHP Calendar v.3.3.8 - Example of code


   [View LIVE DEMO]     [Back to Site]

Show Plain Text »
  1. <?php
  2.  
  3. ## +-----------------------------------------------------------------------
  4. ## | 1. Creating & Calling:                                                
  5. ## +-----------------------------------------------------------------------
  6. ## *** define a relative (virtual) path to calendar.class.php file  
  7. ## *** and other files (relatively to the current file)
  8. ## *** RELATIVE PATH ONLY *** Ex.: "", "calendar/" or "../calendar/"
  9. define ("CALENDAR_DIR", "");                    
  10. require_once(CALENDAR_DIR."inc/connection.inc.php");
  11. require_once(CALENDAR_DIR."calendar.class.php");
  12.  
  13. ## *** create calendar object
  14. $objCalendar = new Calendar();
  15.  
  16. ## +-----------------------------------------------------------------------
  17. ## | 2. General Settings:                                                  
  18. ## +-----------------------------------------------------------------------
  19. ## +-- Submission Settings & Debug Mode -----------------------------------
  20. ## *** set PostBack method: "get" or "post"
  21. $objCalendar->SetPostBackMethod("post");
  22. ## *** show debug info - false|true
  23. $objCalendar->Debug(false);
  24.  
  25. ## +-- Users Settings -----------------------------------------------------
  26. ## *** set user ID (must be numeric value)
  27. /// $user_id = 0;
  28. /// $objCalendar->SetUserID($user_id);    
  29.  
  30. ## +-- Passing Parameters -------------------------------------------------
  31. ## *** save http request variables between  calendar's sessions
  32. /// $http_request_vars = array("param1", "param2");
  33. /// $objCalendar->SaveHttpRequestVars($http_request_vars);
  34.  
  35. ## +-- Cache Settings -----------------------------------------------------
  36. ## *** define caching parameters:
  37. ## *** 1st - allow caching or not, 2nd - caching lifetime in minutes
  38. $objCalendar->SetCachingParameters(true, 15);
  39. ## *** define all caching pages
  40. /// $objCalendar->DeleteCache();
  41.  
  42. ## +-- Languages ----------------------------------------------------------
  43. ## *** set interface language (default - English)
  44. ## *** (en) - English  (es) - Spanish  (de) - German  (fr) - French  (it) - Italian
  45. $objCalendar->SetInterfaceLang("en");    
  46.  
  47. ## +-- Week Settings ------------------------------------------------------
  48. ## *** set week day name length - "short" or "long"
  49. $objCalendar->SetWeekDayNameLength("long");
  50. ## *** set start day of the week: from 1 (Sunday) to 7 (Saturday)
  51. $objCalendar->SetWeekStartedDay("1");
  52. ## *** disable certain days of the week: from 1 (Sunday) to 7 (Saturday). Ex.: 1,2 or 7
  53. /// $objCalendar->SetDisabledDays(6,7);
  54. ## *** define showing a week number of the year
  55. $objCalendar->ShowWeekNumberOfYear(true);
  56.  
  57.  
  58. ## +-----------------------------------------------------------------------
  59. ## | 3. Events & Categories Settings:                                      
  60. ## +-----------------------------------------------------------------------
  61. ## +-- Events Actions & Operations ----------------------------------------
  62. ## *** allow multiple occurrences for events in the same time slot: false|true - default
  63. $objCalendar->SetEventsMultipleOccurrences(true);
  64. ## *** allow editing events in past
  65. /// $objCalendar->EditingEventsInPast(false);
  66. ## *** block deleting events before certain period of time (in hours)
  67. // $objCalendar->BlockEventsDeletingBefore(24);
  68. ## *** set (allow) calendar events operations
  69. $events_operations = array(
  70.     "add"=>true,
  71.     "edit"=>true,
  72.     "details"=>true,
  73.     "delete"=>true,
  74.     "delete_by_range"=>true,
  75.     "manage"=>true,
  76. );
  77. $objCalendar->SetEventsOperations($events_operations);
  78.  
  79. ## +-- Categories Actions & Operations ------------------------------------
  80. ## *** set (allow) using categories
  81. $objCalendar->AllowCategories(true);
  82. ## *** set calendar categories settings
  83. $cat_operations = array(
  84.     "add"=>true,
  85.     "edit"=>true,
  86.     "details"=>true,
  87.     "delete"=>true,
  88.     "manage"=>true,
  89.     "allow_colors"=>true
  90. );
  91. $objCalendar->SetCategoriesSettings($cat_operations);
  92.  
  93.  
  94. ## +-----------------------------------------------------------------------
  95. ## | 4. Users Settings:                                                    
  96. ## +-----------------------------------------------------------------------
  97. ## +-- Users Settings -----------------------------------------------------
  98. ## *** set (allow) calendar users operations
  99. $objCalendar->AllowUsers(true);
  100. ## *** set users settings
  101. $users_operations = array(
  102.     "add"=>true,
  103.     "edit"=>true,
  104.     "details"=>true,
  105.     "delete"=>true,
  106.     "manage"=>true
  107. );
  108. $objCalendar->SetUsersSettings($users_operations);
  109.  
  110.  
  111. ## +-----------------------------------------------------------------------
  112. ## | 5. Time Settings and Formatting:                                      
  113. ## +-----------------------------------------------------------------------
  114. ## +-- TimeZone Settings --------------------------------------------------
  115. ## *** set timezone
  116. ## *** (list of supported Timezones - http://us3.php.net/manual/en/timezones.php)
  117. $objCalendar->SetTimeZone("America/Los_Angeles");    
  118. ## *** get current timezone
  119. /// echo $objCalendar->GetCurrentTimeZone();
  120.  
  121. ## +-- Time Format & Settings ----------------------------------------------
  122. ## *** define time format - 24|AM/PM
  123. $objCalendar->SetTimeFormat("24");
  124. ## *** define allowed hours frame (from, to). Possible values: 0...24
  125. $objCalendar->SetAllowedHours(0, 22);
  126. ## *** define time slot - 15|30|45|60 minutes
  127. $objCalendar->SetTimeSlot("60");
  128. ## *** set showing times in Daily, Weekly and List views
  129. $objCalendar->ShowTime("true");
  130.  
  131.  
  132. ## +-----------------------------------------------------------------------
  133. ## | 6. Visual Settings:                                                    
  134. ## +-----------------------------------------------------------------------
  135. ## +-- Calendar Views -----------------------------------------------------
  136. ## *** set (allow) calendar Views
  137. $views = array("daily"=>true,
  138.                "weekly"=>true,
  139.                "monthly"=>true,
  140.                "monthly_double"=>true,
  141.                "yearly"=>true,
  142.                "list_view"=>true);                        
  143. $objCalendar->SetCalendarViews($views);
  144. ## *** set default calendar view - "daily"|"weekly"|"monthly"|"yearly"|"list_view"|"monthly_small"|"monthly_double"
  145. $objCalendar->SetDefaultView("monthly");    
  146. ## *** Set action link for monthly small view - file2.php or ../file3.php etc.
  147. /// $objCalendar->SetMonthlySmallLinks("");    
  148.  
  149. ## +-- Calendar Actions -----------------------------------------------------
  150. ## *** set (allow) calendar actions
  151. $calendar_actions = array(
  152.     "statistics"=>true,
  153.     "exporting"=>true,
  154.     "printing"=>true
  155. );
  156. $objCalendar->SetCalendarActions($calendar_actions);
  157.  
  158. ## *** set CSS style: "green"|"brown"|"blue" - default
  159. $objCalendar->SetCssStyle("blue");
  160. ## *** specify using of WYSIWYG editor
  161. $objCalendar->AllowWYSIWYG(true);
  162. ## *** set calendar width and height
  163. $objCalendar->SetCalendarDimensions("800px", "500px");
  164. ## *** set type of displaying for events
  165. ## *** possible values for daily   - "inline"|"block"
  166. ## *** possible values for weekly  - "inline"|"tooltip"
  167. ## *** possible values for monthly - "inline"|"list"|"tooltip"
  168. $events_display_type = array("daily"=>"block", "weekly"=>"tooltip", "monthly"=>"tooltip");
  169. $objCalendar->SetEventsDisplayType($events_display_type);
  170. ## *** set Sunday color - true|false
  171. $objCalendar->SetSundayColor(true);    
  172. ## *** set calendar caption
  173. $objCalendar->SetCaption("ApPHP Calendar v".Calendar::Version());
  174.  
  175.  
  176. ## +-----------------------------------------------------------------------
  177. ## | 7. Draw Calendar:                                                      
  178. ## +-----------------------------------------------------------------------
  179. ## *** drawing calendar
  180. $objCalendar->Show();
  181.  
  182.  
  183. ?>