As I promise, to make the understanding of the code easier.
ArchitectureBuild upon Calendar class created by David Wilkinson (
http://www.cascade.org.uk/software/php/calendar/)
I extend the class directly into the class itself, instead of extending it, ebcause I figure out that the current class is not flexible enough, so I added a few changes, and it's ended up to the horse power of the whole system.
To output a calendar view, all that it akes is to declare a new calendar object, and call the right function to display it in either day, month, or year view. This is all being done by the snippet. The snippet also works as the place to validate the current user, if they are log in with the right role, it will set a session to let calendar know that the user has calendar admin priviledge. The web group can be set on the snippet, and the manager group will depend upon the document group that is associated with the manager group. Snippet also work to customize certain template with a chunk for that certain calendar only. You can also use the available variable to change the name of the Sunday, Monday, and etc for month or year view.
Considering the needs to include certain javascript, stylesheet, or html tag inside the header tag, as well as at the begining of open body tag, then here comes the plugin. Plugin will use a shared module parameter to determine the corresponsing pageid that has this calendar snippet. It needs to be set manually. In that sharing parameters, it also has the chunk name for the inserted header or body tag, if it's set to 'default', then it will use the on included in the calendar class. All default template is inside the calendar class file, even some javascript code required to make the popup admin work is inside there as well.
The template also being set like this, "[+Content+]" or "[+Admin+]" will be replaced by the inner output of the other template. Here is a better view of the whole template. I will represent each template as a variable name for the snippet. The default variable inside the class for default template will be named the same, with 'Default' being inserted between 'tpl' and 'VAR_NAME'.
[b]Year View[/b]
tplTemplate
tplMonth
*Auto generated month table (table is labeled with css class for easy styling)
tplMonthNone or tplMonthDay
tplMonthDayList (repeated by the ammount of events on that day)
tplMonthAdmin (for edit and delete button, because it's related to events, new button is available everywhere)
[b]Month View[/b]
tplTemplate
tplYear
tplYearMonth (displaying the month box/table)
*Auto generated month table (table is labeled with css class for easy styling)
tplYearNone or tplMonthDay
tplYearDayList (repeated by the ammount of events on that day)
tplYearAdmin (for edit and delete button, because it's related to events, new button is available everywhere)
[b]Day View[/b]
tplTemplate
tplDay
tplDayList (repeated by the ammount of events on that day)
tplDayAdmin (for edit and delete button, because it's related to events, new button is available everywhere)
For reserved placeholder, it's listed inside snippet, but it's not complete yet, so I will work on that later. Btw, for databasel column, everything is lower case letter. I haven't try this yet, but I assume MODx placeholder is case sensitive, is that true?
To insert header and body extra tag, please set the chunk name on the module.
Current architecture that need to be improved, the database access, so that it will support recuring events.