SpiffyJr's Blogaroo

Happenings of the man known as SpiffyJr

  • Home
  • About
    • Inspiration
    • Resume
  • Projects
    • Blitzaroo
    • phpRaider
    • Zend Calendar
  • Docs
    • Blitzaroo API
    • SpiffyCalendar Docs
    • SpiffyDb Docs
  • Downloads
  • Technologies
    • Doctrine ORM
    • Dojo
    • PHP
    • Zend Framework
  • Other
    • License
Twitter RSS

Calendar

About

I ran into a situation where I needed a calendar generator for the Zend Framework. I spent an hour or so searching but couldn’t find anything that fit my tastes so I wrote my own. My calendar uses Zend_Date and Zend_Locale and is truly Zendy (new word?). It uses a view script to generate the calendar so it’s completely customizable and cssable (another new word?). I call it SpiffyCalendar (dun dun dun)!

Features

  • Completely integrated as a library package for Zend Framework.
  • Utilizes Zend_Date and Zend_Locale provided by the Zend Framework.
  • Rendered using different adapters (ships with Zend_View and a view script).
  • Released under the GNU GPL license
  • Support for adding events/appointments.
  • Easily AJAXified

Source

You can checkout the latest source from the SpiffyLib Google Project’s page.

Download

Download the latest version of SpiffyCalendar here.

Examples

Below are a few examples to show the capabilities of SpiffyCalendar. This is by no means an exhaustive list so if you have something you want to be able to do and don’t know how post a comment and I’ll see if I will try my best to update this page with the answers.

Generating a simple calendar

view->cal = $cal;
echo $cal;

Adding an event from an array

This example will add two events using an array to the calendar. Event #1 is added to the calendar using a day of 1 with the current month and year. Event #2 is added using the default day of 5 with a current month and year. Event #3 is added to the current day, month, and year. The event array source always uses the ‘eventDate’ to determine the date and falls back to the default date and finally the current date. All values passed as date can be retrieved in the renderer using $cal->getData().

createEvent(
    'array',
    array(
        array(
            'title' => 'Event #1',
            'eventDate' => array('day' => 1))
        array('title' => 'Event #2')
    ),
    array(
            'day' => 5
    ));
$cal->createEvent('array', array(array('title' =>; 'Event #3')));

Adding an event from a Zend_Db_Table using objects

SpiffyCalendar also supports the ability to use a Zend_Db_Table as a data source. You can use every method that a table has but the most common method is using select() to filter results.

setTable(new Default_Model_DbTable_Event());

// Only shows ids greater than 10
$events->getSelect()->where('id = 10');

// Set a default date in case the table doesn't have one
$events->setDate(array('day' => 10));

// Set the dateField and dateFormat of the date field from the database.
$events->setParams(
	array('dateField' => 'date', 'dateFormat' => 'YYYY-MM-DD'));

// Create the event
$cal->createEvent($events);
$this->view->calendar = $cal

Changelog

1.0.1 – 10.02.2009

  • Fixed getMonthNames() to use the new date object’s locale.
  • Fixed getEndDay() to use all days of the week.
  • Fixed a bug with getDay() which would sometimes cause duplicate days.
  • Added method getNextMonthName($format = Zend_Date::MONTH_NAME); which returns the next month’s name using the specified format.
  • Added method getPrevMonthName($format = Zend_Date::MONTH_NAME); which returns the previous month’s name using the specified format.
  • Added method getNextYear($format = Zend_Date::YEAR); which returns the next year using the specified format.
  • Added method getPrevYear($format = Zend_Date::YEAR); which returns the previous year using the specified format.
  • Added method getYearList($limit = 5, $format = Zend_Date::YEAR); which returns an array of years beginning with the current year and going +/- $limit years.
  • Added automatic cache detection by setting a registry key of “Spiffy_Calendar_Cache”
  • Added parameter check of day, month, year which can be passed via $_POST, $_GET or the URI.
  • Added methods getDayDigit(), getMonthDigit(), and getYearDigit(). Returns the day (1-31), month (1-12), and year (YYYY) respectively.

1.0.0 – 09.18.2009

  • Initial Release
GD Star Rating
loading...
Calendar, 4.0 out of 10 based on 1 rating

6 Responses to “Calendar”

  1. woto says:
    September 18, 2009 at 3:17 am

    Sorry for bad English. There are seems error in calculating in function getWeeks. I saw doubled days. 1 1 2 3 etc… I’ll try to find error, good work.

  2. woto says:
    September 18, 2009 at 4:48 am

    Gotcha in Calendar.php function getDay
    from
    $newDay->setDay($day)->setMonth($month)->setYear($year);
    to
    $newDay->setYear($year)->setMonth($month)->setDay($day);

  3. SpiffyJr says:
    September 18, 2009 at 7:21 am

    I’m not quite sure how that would have any relevance to what you were seeing.

  4. SpiffyDb and SpiffyCalendar updated | SpiffyJr's Blogaroo says:
    October 2, 2009 at 9:21 am

    [...] SpiffyCalendar Docs [...]

  5. meti says:
    January 24, 2012 at 9:13 am

    I was wondering do you have a demo of this ??

  6. SpiffyJr says:
    January 24, 2012 at 9:37 am

    No, it’s pretty old and I wouldn’t really recommend using it.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

*

*


question razz sad evil exclaim smile redface biggrin surprised eek confused cool lol mad twisted rolleyes wink idea arrow neutral cry mrgreen

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Recent Posts

    • Keep your Git fork clean
    • Get started with Zend Framework 2 modules!
    • More Doctrine 2 and Zend Framework integration goodies!
    • Super sexy URLs with ZF and the joy of controller plugins!
    • Formatting your API to work with dojox.data.JsonRestStore (#dojo)
  • Categories

    • Other
      • Random
    • Projects
      • Blitzaroo
      • phpRaider
      • SpiffyDb
      • View Helpers
      • Zend Calendar
    • SpiffyJr
    • Technologies
      • Dojo
      • PHP
      • Zend Framework
  • Tag Cloud

      Ajax Algorithm api Blitzaroo Blog BSD licenses calendar Cascading Style Sheets CSS database Data Formats Dojo Dojo Toolkit event Framework game Google HTML HTML element JavaScript JQuery json Languages mapper Marketing mmorpg model php Programming Projects Scripts Source code Style sheet Style Sheets Twitter Website zend Zend Framework
  • Archives

    • December 2011
    • November 2011
    • July 2011
    • April 2011
    • March 2011
    • December 2010
    • November 2010
    • October 2010
    • March 2010
    • February 2010
    • November 2009
    • October 2009
    • September 2009
© SpiffyJr's Blogaroo. Proudly Powered by WordPress | Nest Theme by YChong