Jul 05, 2009, 09:29 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Search via SMF or Google: modx forums all of modxcms.com web
  MODxCMS.com   Forums   Help Login Register  
Pages: [1] 2 3 ... 14   Go Down
  Print  
Author Topic: [Snippet] Calendar (Used to be DBCalendar)  (Read 53262 times)
0 Members and 1 Guest are viewing this topic.
Djamoer
Emeritus
******
Posts: 1,495

No one can limit a man other than the man himself.


WWW
« on: Jan 12, 2006, 02:49 PM »


Name: Calendar (Used to be DBCalendar)
For: MODx cms (modxcms.com)
Description: Database calendar module for MODx
Version: 0.2a
Written by: Wendy Novianto
Created: 1/12/2006
Modified: 1/14/2006

Fully Tested on MODx v0.9.1


Hi guys,

This is the first alpha release of DBCalendar module that I build. The modules itself serve as a sharing parameter for now, but in the future, I would like to have an administration capability inside the manager.

Here is a full details about the modules.
http://test.djamoer.net/calendar.html

If you want to see inside the code and how the administration interface looks like, please login using this info.
Address: http://test.djamoer.net/manager/
Username: calendar
Password: password

After you're log in, feel free to browse the snippet, plugin, and module that make this thing come to work. If you want to edit the calendar, go back to http://test.djamoer.net/calendar.html, then you will have an admin capability to add, delete, and edit events.

WARNING: This is just an alpha release, don't use this for production website! You've been warn! The last included version is not the final release of v0.2b. I'll release the official one soon, as soon as I'm able to get this working on at least Mark's server. Smiley Check the preview site for more updated information.

NOTE:




Regards,

edit: Link updated

* calendar_v0.2a.zip (593.61 KB - downloaded 1085 times.)
* calendar_v0.2b.zip (593.43 KB - downloaded 1324 times.)
« Last Edit: Jun 15, 2006, 01:59 AM by zi » Logged

banzai
Testers
*
Posts: 870


MODx Italia


WWW
« Reply #1 on: Jan 12, 2006, 02:53 PM »

Nice! nice! very nice module!!!!  Grin
Logged

MODx Websites Showcase 
Add your site to www.modx.it!
-----------------------------------------------------
FREE MODx Templates
www.tattoocms.it
-----------------------------------------------------
VIDEO: whats new in MODx 0.9.5   | VIDEO: MODx PHP Application Framework  |  modx Revolution  

bubuna.com - Web & Multimedia Design
Djamoer
Emeritus
******
Posts: 1,495

No one can limit a man other than the man himself.


WWW
« Reply #2 on: Jan 12, 2006, 02:57 PM »

Thanks Banzai
Logged

davidm
MODx evangelist
Marketing & Design Team
*
Posts: 7,026


Software is like sex, it's better when it's free !


WWW
« Reply #3 on: Jan 12, 2006, 03:09 PM »

I'll install it and test it local, and report !

Thanks for this much useful module Grin
Logged

.: nodeo.net : Pour un web libre, moderne et ouvert ! :: david-molliere.net : Suivez en "live" mes expérimentations et billets sur les CMS et autres applications web :.

*** Forums modxcms.fr Participez ŕ l'élaboration du site MODx francophone ! ***

! Nouveau !  En live, ne manquez pas les news de modxcms.fr sur Twitter   ! Nouveau !

MODx est l'outil idéal pour les developpeurs et webdesigners qui cherchent un framework de gestion de contenu hautement flexible et performant, tout en étant simple d'accčs pour les utilisateurs finaux.

Config : Apache 2.2.8 - MySQL 5.0.67 - PHP 5.2.8 | Debian 4.0 (Etch)

Réalisations sous MODx : | pargade-notaires.fr | soleil.info | gican.asso.fr | michelez-notaires.com | amadom.gerondicap.com | jocelyne-violet.net
Djamoer
Emeritus
******
Posts: 1,495

No one can limit a man other than the man himself.


WWW
« Reply #4 on: Jan 12, 2006, 03:20 PM »

As I promise, to make the understanding of the code easier.

Architecture

Build 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'.

Code:
[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.
« Last Edit: Jan 12, 2006, 03:28 PM by wendy » Logged

Mark
Coding Team
*
Posts: 3,250


Ditto Developer


WWW
« Reply #5 on: Jan 12, 2006, 04:38 PM »

This is AWESOME wendy! GREAT work!
Logged

OpenGeek
MODx Co-Founder
Foundation
*
Posts: 5,814


damn accurate caricatures...


WWW
« Reply #6 on: Jan 12, 2006, 04:48 PM »

Very, very nice Wendy!  This is a great start.  I can simply create the iCalendarExport and hCalendar-compatible EventListing snippets I was talking about directly from this data structure.  Or potentially, we could even integrate phpicalendar so the events could be persisted and managed directly in the ics files, rather than a separate database (this could give iCal users the ability to manage shared calendars from their local clients, which I personally would love).

Ideally, I'd like to be able to provide the necessary event data to any of these components from whatever data source I want.  By de-coupling the data source from these other portions, we just increase the usefullness and usability of each component in the module.  We can probably do this by simply creating an Event class based on the iCal structure and allowing different extensions of the class to define their own data access methods, or limit/extend access to specific attributes applicable only to that event data source.  Make any sense?
Logged

Jason Coward
MODx Co-Founder
xPDO Founder
CTO @ Collabpad
work productively.
work intelligently.
work together.
Light is just a vibration of a note too. Everything is. You've got to keep that in mind.
  Frank Zappa
Djamoer
Emeritus
******
Posts: 1,495

No one can limit a man other than the man himself.


WWW
« Reply #7 on: Jan 12, 2006, 05:09 PM »

Make sense to me, but not entirely.

Let see, to extend the class, I was thinking that we can just extend the class in a snippet to support different data sources, for example, instead of database, we can overwrite the function that start with db to return a set of array from different sources, with this, different snippet will provide different data sources.

Now from your view point, you're thinking to add event based system to the class, which I think it will be great. Basically it will work just like MODx. So instead of overwriting function from class, you want to add event to interupt the current process and do modification during accessing the database, and use ical format instead. It sounds great to me, but, I don't have basic flow inside the class, which is not like MODx.

In document.parser of MODx, it has executeParser function that will do the whole routine from receiving request, accessing data until it outputing content. It's awesome if the current system have the needs to have a basic flow, but I don't think the current model doesn't need an event based system.

I'm not to for sure that I got this right though, so if I misunderstand your post, then correct me. Btw, the big reason that I don't want to use event based, because I don't really have that many experience with event base system, other than in .Net. lol

I'm looking forward to learn event based system from you in PHP. Honestly, I'm a ASP .Net programmer before, and I made a proposal to my company, and they approve it to move to PHP and Open Source system. So I use PHP just for a while right now. I know about trigering event and capturing event in ASP .Net, but not in PHP though. If you could direct me to the right place, I will do it.

Thhank you Jason.
Logged

OpenGeek
MODx Co-Founder
Foundation
*
Posts: 5,814


damn accurate caricatures...


WWW
« Reply #8 on: Jan 12, 2006, 05:18 PM »

No, I mean a class to represent the data access for events, that could easily be extended for any data source.  Plain and simple.  The calendar class would then use this event class to get the data it needs to do it's job, as could any other snippet you wanted to create to deal with events in a calendar.  Not talking about event based programming at all.
Logged

Jason Coward
MODx Co-Founder
xPDO Founder
CTO @ Collabpad
work productively.
work intelligently.
work together.
Light is just a vibration of a note too. Everything is. You've got to keep that in mind.
  Frank Zappa
Djamoer
Emeritus
******
Posts: 1,495

No one can limit a man other than the man himself.


WWW
« Reply #9 on: Jan 12, 2006, 09:07 PM »

lol.

I knew I was wrong. When I read the evnt stuff, I'm expecting about the invoke event on MODx core. Sorry for misunderstanding it.  Embarrassed

Btw, that's a good idea. So are we going to back into the drawing board? I mean we have the class, except we need to set the right way to represent the data, for the calendar class to be able to access it and display it in the right way.

As for iCal, I believe it's still better to have it based on database. If we can provide some kind of syncronization between the database and iCal, that will be great.

I'm looking forward to be walkthrough by you.

Regards,
Logged

OpenGeek
MODx Co-Founder
Foundation
*
Posts: 5,814


damn accurate caricatures...


WWW
« Reply #10 on: Jan 12, 2006, 09:25 PM »

Btw, that's a good idea. So are we going to back into the drawing board? I mean we have the class, except we need to set the right way to represent the data, for the calendar class to be able to access it and display it in the right way.
I don't think we have to go back to the drawing board at all.  Give me a day to catch my breath from other projects and I'll go ahead and create the base CalendarEvent class and the DBCalendarEvent class we can use to represent your current data source implementation of a CalendarEvent, and then use that in the Calendar class you've chosen here.  It should be transparent to the components and will require minimal changes to the Calendar class.  It'll all make sense when I show you what I'm talking about.

As for iCal, I believe it's still better to have it based on database. If we can provide some kind of syncronization between the database and iCal, that will be great.
That's a good idea, but everyone wants something different, so why not give them the option?  By implementing this as I am suggesting, someone could implement an iCalendarEvent class implementation that handled ics file persistence of the data and another could implement an AggregateCalendarEvent class that syncronized data to and from the DBCalendarEvent and iCalendarEvent implementations as you suggest.  Follow?  But in this way, we can reduce the number of one-off components that pop-up in the community for Calendaring, as well as provide plug and play components that could all use a common model to interact with any number of potential event data sources.  I mean, I'm sure someone wants this to work with Outlook too, right?   Cheesy
Logged

Jason Coward
MODx Co-Founder
xPDO Founder
CTO @ Collabpad
work productively.
work intelligently.
work together.
Light is just a vibration of a note too. Everything is. You've got to keep that in mind.
  Frank Zappa
Djamoer
Emeritus
******
Posts: 1,495

No one can limit a man other than the man himself.


WWW
« Reply #11 on: Jan 12, 2006, 10:19 PM »

Sure thing, that sounds awesome. I'll wait for your implementation then. If you want to, just give me the class and functions with description of input and output, so that I can help you out with it. Just drop me an email if you need my help. How long do you think this thing will take?

Btw, any idea on why the window is not closing, and it's not able to reload the parent page with javascript on IE browser? I copy and paste the one on QuickEdit, but I'm lost with the implementation of AJAX and etc. Pardon me for being ignorant about the latest technology trend here.

I also realize the defect in the layout on IE browser. Hate IE...
Logged

philpond
Jr. Member
*
Posts: 30


« Reply #12 on: Jan 13, 2006, 03:44 AM »

Yay!  Cheesy

Sorry guys, I know I said I would help but it looks like I'm going to get very busy again next week. Between 8 hours at work and 3-4 hours freelancing 5 days a week it's hard to find the time to catch a breath (let alone work on my own projects). Anyway, it looks like you have everything under control. I'm going to install this and put back in whatever way I can.

Cheers,

Phil
Logged
Djamoer
Emeritus
******
Posts: 1,495

No one can limit a man other than the man himself.


WWW
« Reply #13 on: Jan 13, 2006, 10:49 AM »

Jason,

After reading your post, I did a few update to the current class. I added a data source wrapper and calendar view wrapper.

This might be the end modificaiton of the current class, in terms about accessing data source wrapper. When there is a new data source layer to be added, for example when you're done making a class for the event database/iCal, then all you need is to modify the current fetchDataSource function inside the class to return the right array for the calendar class to output the result.

Note:
the necessary field for the current array is still undecided. Here is what I have in mind:
1. calendardbid -> event id to be used for deleting or editing
2. datebegin -> event begin date
3. dateended -> event ended date
4. timebegin -> event begin time
5. timeended -> event ended time
6. description -> short title/description for events
7. details -> full information of events
8. category -> category name, currently it was stored as a string, instead of another id to special table handling category, to ease the database clutter when installing this.

I think that's going to be enough, unless you have other things that needed to be added to the array for data processing.

Talking about recuring events, when it fetch for the current date, month, or year, the data source layer has to return duplicate events entry to the array, whenever there is a recuring event happen on that period of display.

Here is the question, do you think it's better to store the events in 3 dimensional array with the key name as the date in "20061230" format and the value will be a 2 dimensional array containing the current events listed in there?

So the display function will only need to fetch the array based on the date. The processing power to store the data in the right array format like this will be handled by the data source layer. Currently, in the display functin, I go over the array and added the date span to detect whether the current event is spanning to how many day, and detect which events will be displayed on the current date. This process will be processed for every date.

I think the full-job of setting up the right array format is better to be handled by the data source layer. Easier to be extended as well.

Please give me a reply by today, so I can decide which direction I should be heading.

Thanks
Logged

rthrash
Foundation
*
Posts: 10,471



WWW
« Reply #14 on: Jan 13, 2006, 03:31 PM »

Hi wendy,

I'm definitely following this thread... any reason not to just use unix timestamps for the start / stop date+times?

Logged

MODx is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you help us help you, read the wiki, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
Pages: [1] 2 3 ... 14   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP

Copyright © 2005-2008 MODxCMS, All rights reserved. Contact Us
Styles by ziworks.com

Powered by SMF | SMF © 2006-2008, Simple Machines LLC

Valid XHTML 1.0! Valid CSS!