Stud.IP  4.0
 All Data Structures Namespaces Files Functions Variables Groups
CalendarView Class Reference
Inheritance diagram for CalendarView:
CalendarWeekView CalendarWidgetView

Public Member Functions

 __construct ($entries=[])
 
 setHeight ($height)
 
 setRange ($start_hour, $end_hour)
 
 addColumn ($title, $url="", $id=null)
 
 addEntry ($entry_array)
 
 groupEntries ($grouped=true)
 
 setInsertFunction ($js_function_object)
 
 render ($params=[])
 
 getEntries ()
 
 getMatrix ()
 
 getRange ()
 
 isGrouped ()
 
 getHeight ()
 
 getOverallHeight ()
 
 getInsertFunction ()
 
 getColumns ()
 
 setReadOnly ($readonly=true)
 
 getReadOnly ()
 

Data Fields

 $sorted_entries = []
 

Protected Member Functions

 checkEntries ($entries)
 

Protected Attributes

 $entries = []
 
 $entry_columns = []
 
 $height = 40
 
 $grouped = false
 
 $start_hour = 8
 
 $end_hour = 21
 
 $insertFunction = ""
 
 $templates = []
 
 $read_only = false
 
 $view_id
 

Static Protected Attributes

static $number_of_instances = 1
 

Detailed Description

Kind of bean class for the calendar view.

Example of use:

// create a calendar-view and add a column $plan = new CalendarView(); $plan->addColumn(_('Spalte 1')) ->addEntry(array( 'id' => 1, 'color' => '#5C2D64', 'start' => '0930', 'end' => '1100', 'title' => 'Mathe 2', 'content' => 'Die Mathematiker kreiden sich mal wieder was an.' ) );

// display the calendar (containing one column) print $plan->render();

Since
2.0

Constructor & Destructor Documentation

__construct (   $entries = [])

You need to pass an instance of this class to the template. The constructor expects an array of entries of the following type: array( $day_number => array(array ( 'color' => the color in hex (css-like, without the #) 'start' => the (start hour * 100) + (start minute) 'end' => the (end hour * 100) + (end minute) //'day' => day of week (0 = Sunday, ... , 6 = Saturday) 'title' => the entry`s title 'content' => whatever shall be the content of the entry as a string ) ...) ... )

Parameters
mixed$entriesan array of entries (see above)
string$controllerthe name of the controller. Used to create links.

Member Function Documentation

addColumn (   $title,
  $url = "",
  $id = null 
)

adds a new column to this view. All entries created with addEntry will be added to this column.

Parameters
string$titlelike "monday" to be displayed on top of the column
string$urlto be called when clicked on the title of the column
string$idany kind of id of the column
Returns
CalendarView
addEntry (   $entry_array)

adds a new entry to the last current column. The entry needs to be an associative array with parameters as follows:

Parameters
array$entry_array,:associative array for an entry in the column like array ( 'color' => the color in hex (css-like, without the #) 'start' => the (start hour * 100) + (start minute) 'end' => the (end hour * 100) + (end minute) 'title' => the entry`s title 'content' => whatever shall be the content of the entry as a string )
Returns
CalendarView
checkEntries (   $entries)
protected

does some plausability checks on an array of calendar-entries

Parameters
mixed$entriesan array of calendar-entries
Returns
bool false if check failed, true otherwise
getColumns ( )

returns all columns of the calendar-view

Returns
array of CalendarColumn
getEntries ( )

Returns an array of calendar-entries, grouped by day and additionally grouped by same start and end if groupEntries(true) has been called.

Returns
mixed the (double-)grouped entries
getHeight ( )

returns the previously set height for one hour

Returns
mixed the height
getInsertFunction ( )

returns the previously set javasscript insert-function

Returns
string name of js-function or anonymous js-function
getMatrix ( )

Returns an array where for each hour the number of concurrent entries is denoted. Used by the calendar to display the entries in parallel.

Returns
mixed concurrent entries at each hour
getOverallHeight ( )

returns the overall height of the calendar

Returns
mixed the overall height
getRange ( )

returns the previously set start- and end-hour, denoting the range of entries to be displayed in the current calendar-view

Returns
array consisting of the start and end hour
getReadOnly ( )

Return the read-only status of this calendar

Returns
bool the read-only status of this calendar
groupEntries (   $grouped = true)

Call this function to enable/disable the grouping of entries with the same start and end.

Parameters
bool$groupoptional, defaults to true
isGrouped ( )

the calendar can be used in two modes. Use this function to check, if the grouping-mode is enabled for the current calendar-view

Returns
bool true if grouped, false otherwise
render (   $params = [])

outputs the CalendarView with all (grouped) dates in columns.

Parameters
array$paramsyou can pass some additional variables to the templates
Returns
string
setHeight (   $height)

set the height for one hour. This value is used to calculate the whole height of the schedule.

Parameters
int$entry_heightthe height of one hour in the schedule
setInsertFunction (   $js_function_object)

When a column is clicked at no entry this function is called. First the templates generates a new entry at the clicked time. Then this js-function is called which gets the parameters "function (new_entry_dom_object, column_id, hour) { ... }" with new_entry_dom_object: a real dom-object of the div of the entry column_id: id of the column hour: integer number from 0 to 23 If js_function_object is an empty string, nothing will be done.

Parameters
string$js_function_objectname of js-function or anonymous js-function
Returns
CalendarView
setRange (   $start_hour,
  $end_hour 
)

set the range of hours to be displayed. the start_hour has to be smaller than the end_hour

Parameters
int$start_hourthe hour to start displaying at
int$end_hourthe hour to stop displaying at
setReadOnly (   $readonly = true)

Set the read-only status of the calendar

Parameters
bool$readonlytrue to make it read only, false otherwise
Returns
void

Field Documentation

$end_hour = 21
protected
$entries = []
protected
$entry_columns = []
protected
$grouped = false
protected
$height = 40
protected
$insertFunction = ""
protected
$number_of_instances = 1
staticprotected
$read_only = false
protected
$sorted_entries = []
$start_hour = 8
protected
$templates = []
protected
$view_id
protected

The documentation for this class was generated from the following file: