From 5db6cc52ec43fefe8a9ae27bdf79748422a995d2 Mon Sep 17 00:00:00 2001 From: Benjamin Hall Date: Sun, 4 Feb 2018 23:02:42 +0000 Subject: [PATCH] Update --- README.md | 101 +++++++++++------- composer.json | 23 ++++ .../Calendar.php | 0 3 files changed, 87 insertions(+), 37 deletions(-) create mode 100755 composer.json rename src/{php-calendar => phpCalendar}/Calendar.php (100%) diff --git a/README.md b/README.md index 73d2701..990edb8 100755 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ A PHP class that makes generating calendars as easy as possible. You can use the addEvent() or addEvents() methods to mark events on the generated calendar. +This is fully compatible with *PHP 5 through to **PHP 7*** + # Usage Please make sure you have added the required classes. @@ -16,54 +18,79 @@ In its simplest form, use the following to create a calendar ```php # create the calendar object + $calendar = new Calendar(); # if needed, add event - $calendar->addEvent( - '2017-01-14', # start date in Y-m-d format - '2017-01-14', # end date in Y-m-d format - 'My Birthday', # event name text - true, # should the date be masked - boolean default true - 'myclass abc' # (optional) additional classes to be included on the event days - ); + + $calendar->addEvent( + '2017-01-14', # start date in Y-m-d format + '2017-01-14', # end date in Y-m-d format + 'My Birthday', # event name text + true, # should the date be masked - boolean default true + 'myclass abc' # (optional) additional classes to be included on the event days + ); # or for multiple events - $events = array(); - $events[] = array('2017-01-14', '2017-01-14', 'My Birthday', true, 'myclass abc'); - $events[] = array('2017-12-25', '2017-12-25', 'Christmas', true); - - $calendar->addEvents($events); - - # finally, to draw a calendar - echo $calendar->draw(date('Y-m-d')); # draw this months calendar - - # this can be repeated as many times as needed with different dates passed, such as: - echo $calendar->draw(date('Y-01-01')); # draw a calendar for January this year - echo $calendar->draw(date('Y-02-01')); # draw a calendar for February this year - echo $calendar->draw(date('Y-03-01')); # draw a calendar for March this year - echo $calendar->draw(date('Y-04-01')); # draw a calendar for April this year - echo $calendar->draw(date('Y-05-01')); # draw a calendar for May this year - echo $calendar->draw(date('Y-06-01')); # draw a calendar for June this year - - # to use the pre-made color schemes, include the calendar.css stylesheet - # and pass the color choice to the draw method, such as: - echo $calendar->draw(date('Y-m-d')); # print a (default) turquoise calendar - echo $calendar->draw(date('Y-m-d'), 'purple'); # print a purple calendar - echo $calendar->draw(date('Y-m-d'), 'pink'); # print a pink calendar - echo $calendar->draw(date('Y-m-d'), 'orange'); # print a orange calendar - echo $calendar->draw(date('Y-m-d'), 'yellow'); # print a yellow calendar - echo $calendar->draw(date('Y-m-d'), 'green'); # print a green calendar - echo $calendar->draw(date('Y-m-d'), 'grey'); # print a grey calendar - echo $calendar->draw(date('Y-m-d'), 'blue'); # print a blue calendar + + $events = array(); + + $events[] = array('2017-01-14', '2017-01-14', 'My Birthday', true, 'myclass abc'); + + $events[] = array('2017-12-25', '2017-12-25', 'Christmas', true); + + $calendar->addEvents($events); + + # finally, to draw a calendar + + echo $calendar->draw(date('Y-m-d')); # draw this months calendar + + # this can be repeated as many times as needed with different dates passed, such as: + + echo $calendar->draw(date('Y-01-01')); # draw a calendar for January this year + + echo $calendar->draw(date('Y-02-01')); # draw a calendar for February this year + + echo $calendar->draw(date('Y-03-01')); # draw a calendar for March this year + + echo $calendar->draw(date('Y-04-01')); # draw a calendar for April this year + + echo $calendar->draw(date('Y-05-01')); # draw a calendar for May this year + + echo $calendar->draw(date('Y-06-01')); # draw a calendar for June this year + + # to use the pre-made color schemes, include the calendar.css stylesheet and pass the color choice to the draw method, such as: + + echo $calendar->draw(date('Y-m-d')); # print a (default) turquoise calendar + + echo $calendar->draw(date('Y-m-d'), 'purple'); # print a purple calendar + + echo $calendar->draw(date('Y-m-d'), 'pink'); # print a pink calendar + + echo $calendar->draw(date('Y-m-d'), 'orange'); # print a orange calendar + + echo $calendar->draw(date('Y-m-d'), 'yellow'); # print a yellow calendar + + echo $calendar->draw(date('Y-m-d'), 'green'); # print a green calendar + + echo $calendar->draw(date('Y-m-d'), 'grey'); # print a grey calendar + + echo $calendar->draw(date('Y-m-d'), 'blue'); # print a blue calendar ``` # Requirements -PHP 5.3+ -PHP DateTime +**Fully tested to work with PHP 5.3, PHP 5.5, PHP 5.6, and PHP 7** + +**PHP DateTime** # License -Copyright (c) Benjamin Hall, benhall14@hotmail.com +Copyright (c) 2016-2018 Benjamin Hall, benhall14@hotmail.com Licensed under the MIT license + +# Donate? +If you find this project helpful or useful in anyway, please consider getting me a cup of coffee - It's really apprechiated :) + +[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/benhall14) \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100755 index 0000000..c64333e --- /dev/null +++ b/composer.json @@ -0,0 +1,23 @@ +{ + "name": "benhall14/php-calendar", + "description": "A simple PHP class to generate calendars.", + "homepage": "https://github.com/benhall14/php-calendar", + "keywords": ["calendar", "time", "date", "calendars"], + "license": "MIT", + "authors": [ + { + "name": "Benjamin Hall", + "email": "benhall14@hotmail.com", + "homepage": "https://github.com/benhall14", + "role": "Developer" + } + ], + "require": { + "php": ">=5.3" + }, + "autoload": { + "psr-4": { + "benhall14\\": "src/" + } + } +} diff --git a/src/php-calendar/Calendar.php b/src/phpCalendar/Calendar.php similarity index 100% rename from src/php-calendar/Calendar.php rename to src/phpCalendar/Calendar.php