* Fixed minor bug relating to event date not displaying in order.
* Thanks kirk for suggesting a bunch of changes. I have implemented quite a few – too wordy to describe them here. If you are interested, see the evolt comments that kirk837 has written.
* Added category to events. This impacted the code and query quite abit.
* Added sms and emailing capability. Email alert is straight forward. For sms, you have to add your own code. See cron.php
* Updated admin to include new features. The focus on admin area is still on the functionality. Will work on the look and feel later.
* Made further changes to filenames. Added new css for longdesc file.
* fixed hyperlink jumpiness problem. Removed the use of # as hyperlink.
* Used single quotation instead of double in some places. Not really necessary but good practice.
* Added new tiny calendar template.
* Added new complex calendar template. I attempted to combine different types of calendar together and did some tricks.
* This application is getting quite complicated now. I didn’t expect it to evolve till this stage. But… anyway, have fun.
17 Jan (Ver 2.3)
* Made changes to DB. There are different types of link now.
* Implemented full MVC architecture. Well, you can’t escape from not using for-loop but at least everything is more organised. That is why rendering calendar can be complicated. At least the view file looks manageable.
* Major rename of file names and re-organised folders.
* Mass cleanup of CSS in demos. Removed redundant CSS.
* Fixed fillArray logic. User can now start the week with anyday.
* Fixed typos and added comments.
* Updated admin area.
* Added a plain calendar.
* Updated multiple template.
* Still not very happy with the controller… Man, I wanted to stop but my fingers doesn’t allow me to!! Have fun guys.
14 Jan 2009 (Ver 2.2)
* Calendar now supports hrs, mins and images.
* Add ‘order by’ to sql statements.
* Made admin area more user friendly but still very basic.
* Displaying multiple calendars in one page is now very easy to achieve (See demo).
* Improve logic flow and fix typos.
I’ve finally added a simple admin panel for users to administer the events.
As I have said, it is purely functional. Nothing fancy yet. This will help non-programmers or lazy programmers to administer the events easily.
Using other DB instead of MYSQ is straight forward because mysql built-in functions are only used in 3 areas. The SQL are not perculiar to MYSQL and should be compatible with any other DB.
1. In config.php (about line 20 to 27), change the mysql functions there, ie instead of ‘mysql_connect’, use ‘pg_connect’ for example.
2. In controller.php (about line 54 to 60), replace all mysql related function there.
3. In QCalendarBase.php (about line 109 to 115), replace all mysql related function there.
If you are already using a DB Abstraction Library (such as ADODB or PEAR_DB) in your current CMS, replacing these native mysql functions should be straight forward. I chose to use the native mysql functions for now because I don’t want to complicate the installation process. My philosophy is to not make PHP Quick Calendar depend on external libraries to work.
1. Under themes, duplicate the skeleton theme and give a new theme name to the new directory created.
2. In view/calendar.css, replace all style name with .yourtheme.
3. In view/longdesc.css, replace all style name with .yourtheme_longdesc.
4. Change the class name in both model/Calendar.php and model/Longdesc.php to QCalendarYourtheme and LongdescYourtheme.
4. Now the big headache, add in the logic for the model (model/Calendar.php, model/Longdesc.php) and view (view/calendar.phtml, view/longdesc.phtml).
5. Have fun!
There are 2 important files that contain the core logic. Init.php and QCalendarBase.php.
init.php initialises the calendar and also acts like a controller for all incoming ajax request. It has a factory method that creates different calendar templates/theme based on user initialisation parameters.
QCalendarBase.php is the master template/theme file. It contains many commonly used functions for the calendar. All template classes inherits from this class.
The template classes are store under the ‘themes’ directory. Each template is a combination of the ‘Model’ and ‘View’ (MVC). I wanted to separate the view but come to think about it, rendering the view for the calendar still requires significant amount of programming as there would be some sort of looping involved. I suppose other programmers might want to implement the ‘View’ using a templating engine. This is open for discussion.
To customise the calendar, the only files that the user need to change are the template class and css files. At the moment, changing the template class still requires abit of programming skills though. I feel that I can still clean up the logic there abit to make the customisation easier.
I was thinking of a good name for the calendar. I decided to use a functional name, “PHP Quick Calendar”. Well, doesn’t sound too cool, does it? I have also package it under GNU license. I am in the process of doing another template and will release for download soon.
Installing the quick calendar is easy. Follow the steps below:
- Make sure your have LAMP running.
- If using PHP 4, need to have magic_quote off. Check that the php directive short_open_tag is 1 (editable via php.ini or .htaccess). The phpinfo() function reveals all your settings.
- Download the source code from here
- Unzip the downloaded code into a directory of your choice.
- Rename config.bak.php to config.php. Configure config.php with the right db and path details.
- There should be a sql file in the dowloaded code. Run the sql in your server to create the sample tables and data. You can of course empty the tables and populate with new data later.
- Lets try to insert a ‘small’ calendar. Paste the following code into the page where you want your calendar to appear:
- If you want to customise the calendar, you need to have the right parameters for the initQCalendar() function depending on the theme you choose:
- That’s it. The best way to learn is to look at the demos. Duplicate the theme in the demo and play around.
// configure calendar theme
initQCalendar('small','qCalendarSmall', $cssCalendar, 'myContentSmall', $cssLongDesc, 0,0,0,0,0);
make sure the 'path_to' is the system path to your quick calendar directory.
initQCalendar(theme, divCalendar, calendarCss, divLongDesc, longDescCss, day, month, year, category_id, ajax)
'theme': name of the theme you want to use. It is the directory name under the themes directory.
'divCalendar': name of the div you want to use to wrap around the calendar.
'calendarCSS': CSS for DivCalendar above.
'divLongDesc': name of the div where you want the long description to populate. This can be a new div or an existing one in the page. If it is a new div, you need to create one as shown in the sample above.
'longDescCss': CSS for the Long Description.
'day': current day. Leave 0 as the default.
'month': current month. Leave 0 as the default.
'year': current year. Leave 0 as the default.
'category_id': 0 means show all categories.
'ajax': Determines if this is an ajax call or not. Leave 0 as the default.