Skip to content
This repository has been archived by the owner on May 14, 2019. It is now read-only.

Commit

Permalink
Adding new Calendar Helper Plugin
Browse files Browse the repository at this point in the history
== What is the calendar helper?

A simple helper for creating an XHTML and CSS calendar. 

The "calendar" and "day_months" methods will be automatically available to your view templates.

== Installation

{{{
    ./script/plugin install http://svn.akelos.org/plugins/calendar_helper
}}}

== Using the calendar helper

Printing a calendar

{{{
    <%= calendar :month => 10, :year => 2007 %>
}}}

Adding special meaning to a given day in the calendar. The calendar helper implements
something similar to blocks in Ruby by using PHP variable references.

This example will add the class specialDay to the days found in the array $list_of_special_days

{{{
<? while($calendar_helper->month_days(array('month' => 6, 'year' => 2010), $d)) :
    if(in_array($d->day, $list_of_special_days)){
        $d->cell_attributes = array('class' => 'specialDay');
    }
endwhile; ?>
}}}

This example will replace the inner content of the <td></td> cell with the content 
you output in the while loop, when the day is found in the $list_of_special_days array. 
This is really convenient for generating links and Ajax for a given day in the calendar.

{{{
<? while($calendar_helper->month_days(array('month' => 9, 'year' => 2006), $d)) :

    if(in_array($d->day, $list_of_special_days)) : ?>
        <%= link_to d.day, :controller => 'events', :day => d.day %>

     <? endif; 
endwhile; ?>
}}}

== Generating the default stylesheets for the calendar

{{{
    ./script/generate calendar_styles
}}}

CSS will be copied to subdirectories of public/stylesheets/calendar.




git-svn-id: http://svn.akelos.org/plugins/calendar_helper@399 a2fa5c27-f921-0410-a72c-bf682d381be0
  • Loading branch information
bermi committed Oct 15, 2007
0 parents commit e5177cc
Show file tree
Hide file tree
Showing 13 changed files with 1,391 additions and 0 deletions.
458 changes: 458 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Akelos PHP Framework version, Bermi Ferrer Martinez <bermi-a.t-akelos-d.ot-co.m> Lead developer

Special thanks to Jeremy Voorhis and Geoffrey Grosenbach for the original calendar_helper Rails plugin.
51 changes: 51 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Calendar Helper
===================================

A simple helper for creating an XHTML and CSS calendar.

The "calendar" and "day_months" methods will be automatically available to your view templates.


Installation
--------------------------------

./script/plugin install http://svn.akelos.org/plugins/calendar_helper

Using the calendar helper
--------------------------------

Printing a calendar

<%= calendar :month => 10, :year => 2007 %>

Adding special meaning to a given day in the calendar. The calendar helper implements
something similar to blocks in Ruby by using PHP variable references.

This example will add the class specialDay to the days found in the array $list_of_special_days

<? while($calendar_helper->month_days(array('month' => 6, 'year' => 2010), $d)) :
if(in_array($d->day, $list_of_special_days)){
$d->cell_attributes = array('class' => 'specialDay');
}
endwhile; ?>

This example will replace the inner content of the <td></td> cell with the content
you output in the while loop, when the day is found in the $list_of_special_days array.
This is really convenient for generating links and Ajax for a given day in the calendar.

<? while($calendar_helper->month_days(array('month' => 9, 'year' => 2006), $d)) :

if(in_array($d->day, $list_of_special_days)) : ?>
<%= link_to d.day, :controller => 'events', :day => d.day %>

<? endif;
endwhile; ?>


Generating the default stylesheets for the calendar
---------------------------------

./script/generate calendar_styles

CSS will be copied to subdirectories of public/stylesheets/calendar.

6 changes: 6 additions & 0 deletions generators/calendar_styles/USAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Description:
Copies calendar helper stylesheets to public/stylesheets/calendar/

Example:
>> generate calendar_styles

41 changes: 41 additions & 0 deletions generators/calendar_styles/calendar_styles_generator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

// +----------------------------------------------------------------------+
// | Akelos Framework - http://www.akelos.org |
// +----------------------------------------------------------------------+
// | Copyright (c) 2002-2007, Akelos Media, S.L. & Bermi Ferrer Martinez |
// | Released under the GNU Lesser General Public License, see LICENSE.txt|
// +----------------------------------------------------------------------+

/**
* @package ActiveSupport
* @subpackage Generators
* @author Bermi Ferrer <bermi a.t akelos c.om>
* @copyright Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.org
* @license GNU Lesser General Public License <http://www.gnu.org/copyleft/lesser.html>
*/

class CalendarStylesGenerator extends AkelosGenerator
{
function manifest()
{
Ak::copy($this->_generator_base_path.DS.'templates', AK_PUBLIC_DIR.DS.'stylesheets'.DS.'calendar');
}

function hasCollisions()
{
$this->collisions = array();
if(is_dir(AK_PUBLIC_DIR.DS.'stylesheets'.DS.'calendar')){
$this->collisions[] = Ak::t('%path directory already exists',array('%path'=>AK_PUBLIC_DIR.DS.'stylesheets'.DS.'calendar'));
}
return !empty($this->collisions);
}

function printLog()
{
echo Ak::t("Added calendar stylesheets at %path", array('%path'=>AK_PUBLIC_DIR.DS.'stylesheets'.DS.'calendar'))."\n";
}
}

?>
47 changes: 47 additions & 0 deletions generators/calendar_styles/templates/blue/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Author: Bermi Ferrer
*/
table.calendar caption.monthName{
font-size:130%;
padding:8px 0;
}
table.calendar thead th{
padding:2px 8px 5px 8px;
background-color: #bbb;
color: #fff;
border-right: 1px solid white;
border-bottom:1px solid #fff;
}
table.calendar tbody td{
text-align:center;
background-color: #fff;
color: #444;
border-right: 1px solid #fff;
padding:5px 10px;
}

table.calendar tbody a,
table.calendar tbody a:link,
table.calendar tbody a:visited{
text-decoration: none;
color: #eee;
}

table.calendar tbody td.specialDay{
border-bottom: 1px dotted #bbb;
color: #eee;
background-color: #035;
}

table.calendar tbody td.weekendDay{
background-color: #ffd;
}

table.calendar tbody td.today{
background-color: #4682b4;
}

table.calendar tbody td.otherMonth{
color: #eee;
background-color: #fff;
}
70 changes: 70 additions & 0 deletions generators/calendar_styles/templates/default/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Author: Bermi Ferrer
*/
table.calendar{
color:#667;
font-size:80%;
border-right:0.003em solid #ccc;
}
table.calendar caption.monthName{
letter-spacing:0.2em;
font-weight:bold;
color:#fff;
font-size:90%;
background:#aab;
padding:4px;
border: 0.003em solid #aab;
}
table.calendar thead th{
padding:5px 8px;
color: #667;
background: #d9e5e5;
border: 0.003em solid #abc;
}

table.calendar tbody td{
border:0.003em solid #ccc;
border-right:none;
}
table.calendar tbody td{
text-align:center;
background-color: #fff;
margin-right: 1px solid white;
padding:5px 10px;
}


table.calendar tbody a,
table.calendar tbody a:link,
table.calendar tbody a:visited{
text-decoration: none;
color:#a00;
}

table.calendar tbody a:hover{
color:#000;
}

table.calendar tbody td.specialDay{
border:2px solid #c66;
border-left:none;
border-right:none;
background-color: #d99;
font-weight:bold;
color:#a00;
}

table.calendar tbody td.today{
border:2px solid #c66;
background-color: #d99;
font-weight:bold;
}

table.calendar tbody td.otherMonth{
background-color: #fff;
color: #ecc;
}

table.calendar tbody td.weekendDay{
background-color: #fee;
}
48 changes: 48 additions & 0 deletions generators/calendar_styles/templates/grey/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Author: Bermi Ferrer
*/
table.calendar caption.monthName{
font-size:120%;
padding:6px 0;
}
table.calendar thead th{
padding:5px 8px 5px 8px;
background-color: #777;
color: #fff;
border-right: 1px solid white;
border-bottom:1px solid #fff;
}
table.calendar tbody td{
text-align:center;
background-color: #d9d9d9;
color: #333;
border-right: 1px solid #fff;
padding:5px 10px;
}

table.calendar tbody a,
table.calendar tbody a:link,
table.calendar tbody a:visited{
text-decoration: none;
color: #eee;
}

table.calendar tbody td.specialDay{
border-bottom: 1px dotted #bbb;
color: #fff;
background-color: #333;
}

table.calendar tbody td.weekendDay{
background-color: #eee;
color:#777;
}

table.calendar tbody td.today{
background-color: #888;
color:#fff;
}

table.calendar tbody td.otherMonth{
color: #bbb;
}
53 changes: 53 additions & 0 deletions generators/calendar_styles/templates/red/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Author: Bermi Ferrer
*/
table.calendar{
}
table.calendar caption.monthName{
padding:8px 0;
letter-spacing:0.3em;
font-weight:bold;
}
table.calendar thead th{
padding:5px 8px;
color: #444;
}

table.calendar tbody td{
border:0.003em solid #ccc;
}
table.calendar tbody td{
text-align:center;
background-color: #fff;
color: #444;
margin-right: 1px solid white;
padding:5px 10px;
}

table.calendar tbody a,
table.calendar tbody a:link,
table.calendar tbody a:visited{
text-decoration: none;
color: #eee;
}

table.calendar tbody td.specialDay{
border-bottom: 1px dotted #bbb;
color: #eee;
background-color: #a00;
}

table.calendar tbody td.weekendDay{
background-color: #fdd;
}

table.calendar tbody td.today{
border:2px solid #c66;
background-color: #fee;
font-weight:bold;
}

table.calendar tbody td.otherMonth{
color: #fcd;
background-color: #fff;
}
11 changes: 11 additions & 0 deletions init.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

class CalendarHelperPlugin extends AkPlugin
{
function load()
{
$this->addHelper('CalendarHelper');
}
}

?>
Loading

0 comments on commit e5177cc

Please sign in to comment.