KBD

Keith Devens .com

Friday, July 4, 2008 Flag waving
... it's a lot faster to not do something than to do it. – Dan Sugalski
← Entry 1264Entry 1266 →

Daily link icon Friday, January 18, 2002

Entry 1265

I just updated my PHP Calendar code. I did a major update, actually. Yet again the code turned out shorter, as well as more powerful, and hopefully easier to understand, but just to make sure I added a whole bunch of comments that unfortunately increased the total size of the file. Smiley

Because of PHP's limited features, I had to make a little trade-off. I got a ton more flexibility, but I had to use from zero to three global variables, depending on what features you want to use. You can easily name the variables whatever you want to avoid name clases, and the default names should be safe enough. Actually, now that I think about it, you can avoid the global variables if you really try (by serializing them and unserializing them into the 'eval'ed code I use, but that gain is not worth the pain.

New feature: Now, instead of providing an anonymous function that controls which days have the date linked, you just provide some code to eval. That code can use whatever variables it wants (that's where the globals come in). The code can return up to three types of metadata. It can return a URL to link the date with, a set of CSS classes to link the day with (I'll be using this for my task manager to make certain days come up with different colors depending on whether there is any task for that day and what the task's priority is), and finally a string that can be substituted for the date, so if you want to say "first", "second", "third" instead of 1, 2, 3 in your calendar, you can do that (I'll be using this for my task manager too).

That's about it. Check out the code, and feel free to e-mail if you have any questions.

← Entry 1264Entry 1266 →

Comments XML gif


Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

July 2008
SunMonTueWedThuFriSat
 12345
6789101112
13141516171819
20212223242526
2728293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 5 posts

Recent comments XML

Girls, please don't get breast implants

> And no, you will not be receiving​a picture.

:-(...

Keith: Jul 2, 6:05am

Javascript clone function

This is a clever way to clone an​object if you are using YAHOO UI.​Same tec...

Antonio: Jul 1, 12:47pm

I hate Norton Antivirus

Oh just one other thing norton is​great at keeping people out of your​compu...

kevin.sands: Jul 1, 12:50am

Terminator 3 was awful

I think the biggest reason why T3​totally blew was because Edward​Furlong g...

76.167.172.64: Jun 29, 3:06am

Generated in about 0.104s.

(Used 8 db queries)

mobile phone