Skip to content

Instantly share code, notes, and snippets.

@chssweb
Created November 15, 2013 10:09
Show Gist options
  • Save chssweb/7482065 to your computer and use it in GitHub Desktop.
Save chssweb/7482065 to your computer and use it in GitHub Desktop.
Events Manager calendar modificiations
<?php
/*
* This file contains the HTML generated for full calendars. You can copy this file to yourthemefolder/plugins/events/templates and modify it in an upgrade-safe manner.
*
* There are two variables made available to you:
*
* $calendar - contains an array of information regarding the calendar and is used to generate the content
* $args - the arguments passed to EM_Calendar::output()
*
* Note that leaving the class names for the previous/next links will keep the AJAX navigation working.
*/
?>
<table class="em-full-calendar">
<caption><?php echo ucfirst(date_i18n('F Y', $calendar['month_start'])); ?></caption>
<thead>
<tr>
<th class="days-names" scope="col" title="Monday">Mon</th>
<th class="days-names" scope="col" title="Tuesday">Tue</th>
<th class="days-names" scope="col" title="Wednesday">Wed</th>
<th class="days-names" scope="col" title="Thursday">Thu</th>
<th class="days-names" scope="col" title="Friday">Fri</th>
<th class="days-names" scope="col" title="Saturday">Sat</th>
<th class="days-names" scope="col" title="Sunday">Sun</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4" id="prev"><a class="em-calnav" href="<?php echo $calendar['links']['previous_url']; ?>">&laquo; <?php echo ucfirst(date_i18n('M', mktime(0, 0, 0,$calendar['month_last']))); ?></a></td>
<td colspan="3" id="next"><a class="em-calnav" href="<?php echo $calendar['links']['next_url']; ?>"><?php echo ucfirst(date_i18n('M', mktime(0, 0, 0,$calendar['month_next']))); ?> &raquo;</a></td>
</tr>
</tfoot>
<tbody>
<tr>
<?php
$col_count = 1; //this counts collumns in the $calendar_array['cells'] array
$col_max = count($calendar['row_headers']); //each time this collumn number is reached, we create a new collumn, the number of cells should divide evenly by the number of row_headers
foreach($calendar['cells'] as $date => $cell_data ){
$class = ( !empty($cell_data['events']) && count($cell_data['events']) > 0 ) ? 'eventful':'eventless';
if(!empty($cell_data['type'])){
$class .= "-".$cell_data['type'];
}
?>
<td class="<?php echo $class; ?>">
<?php
if ($class == 'eventful' || $class == 'eventful-today' ){
$cell_events = array();
if( get_option('dbem_display_calendar_events_limit') ){
$count = 0;
foreach($cell_data['events'] as $cell_event){
$cell_events[] = $cell_event;
$count++;
if($count > get_option('dbem_display_calendar_events_limit')) break;
}
}else{
$cell_events = $cell_data['events'];
}
}
?>
<div class="day"><?php if( $class == 'eventful' || $class == 'eventful-today' ): ?>
<a href="<?php echo esc_url($cell_data['link']); ?>" title="<?php echo esc_attr($cell_data['link_title']); ?>"><?php echo date('j',$cell_data['date']); ?></a>
</div>
<ul>
<?php echo EM_Events::output($cell_events,array('format'=>get_option('dbem_full_calendar_event_format'))); ?>
<?php if( count($cell_events) > get_option('dbem_display_calendar_events_limit',3) && get_option('dbem_display_calendar_events_limit_msg') != '' ): ?>
<li><a href="<?php echo esc_url($cell_data['link']); ?>"><?php echo get_option('dbem_display_calendar_events_limit_msg'); ?></a></li>
<?php endif; ?>
</ul>
<?php else:?>
<?php echo date('j',$cell_data['date']); ?>
</div>
<?php endif; ?>
</td>
<?php
//create a new row once we reach the end of a table collumn
$col_count= ($col_count == $col_max ) ? 1 : $col_count+1;
echo ($col_count == 1) ? '</tr><tr>':'';
}
?>
</tr>
</tbody>
</table>
<?php
/*
* This file contains the HTML generated for small calendars. You can copy this file to yourthemefolder/plugins/events/templates and modify it in an upgrade-safe manner.
*
* There are two variables made available to you:
*
* $calendar - contains an array of information regarding the calendar and is used to generate the content
* $args - the arguments passed to EM_Calendar::output()
*
* Note that leaving the class names for the previous/next links will keep the AJAX navigation working.
*/
?>
<table class="em-calendar">
<caption><?php echo ucfirst(date_i18n('M Y', $calendar['month_start'])); ?></caption>
<thead>
<tr>
<th class="days-names" scope="col" title="Monday">M</th>
<th class="days-names" scope="col" title="Tuesday">T</th>
<th class="days-names" scope="col" title="Wednesday">W</th>
<th class="days-names" scope="col" title="Thursday">T</th>
<th class="days-names" scope="col" title="Friday">F</th>
<th class="days-names" scope="col" title="Saturday">S</th>
<th class="days-names" scope="col" title="Sunday">S</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4" id="prev"><a class="em-calnav" href="<?php echo $calendar['links']['previous_url']; ?>">&laquo; <?php echo ucfirst(date_i18n('M', mktime(0, 0, 0,$calendar['month_last']))); ?></a></td>
<td colspan="3" id="next"><a class="em-calnav" href="<?php echo $calendar['links']['next_url']; ?>"><?php echo ucfirst(date_i18n('M', mktime(0, 0, 0,$calendar['month_next']))); ?> &raquo;</a></td>
</tr>
</tfoot>
<tbody>
<tr>
<?php
$col_count = 1; //this counts collumns in the $calendar_array['cells'] array
$col_max = count($calendar['row_headers']); //each time this collumn number is reached, we create a new collumn, the number of cells should divide evenly by the number of row_headers
foreach($calendar['cells'] as $date => $cell_data ){
$class = ( !empty($cell_data['events']) && count($cell_data['events']) > 0 ) ? 'eventful':'eventless';
if(!empty($cell_data['type'])){
$class .= "-".$cell_data['type'];
}
?>
<td class="<?php echo $class; ?>">
<?php if( !empty($cell_data['events']) && count($cell_data['events']) > 0 ): ?>
<a href="<?php echo esc_url($cell_data['link']); ?>" title="<?php echo esc_attr($cell_data['link_title']); ?>"><?php echo date('j',$cell_data['date']); ?></a>
<?php else:?>
<?php echo date('j',$cell_data['date']); ?>
<?php endif; ?>
</td>
<?php
//create a new row once we reach the end of a table collumn
$col_count= ($col_count == $col_max ) ? 1 : $col_count+1;
echo ($col_count == 1) ? '</tr><tr>':'';
}
?>
</tr>
</tbody>
</table>
/* Mixin */
@import "elements";
.no-shadow(){
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
/* Less Variables */
@white: #FFFFFF;
@blue: #366BBD;
@heading: #666;
@dark-grey: #444;
@medium-grey: #A6A6A6;
@light-grey: #F6F6F6;
@light-text: #FEFEFE;
@see-thru: transparent;
@caption-blue: #25476C;
@font-12px: 0.9230769em;
/* CSS Document */
#content {
.em-calendar {
.drop-shadow(0,1px,5px,0.3);
border-collapse: collapse;
border: 1px solid #CCC;
color: @dark-grey;
width: 220px;
caption {
.border-radius(5px,0,0,5px);
.drop-shadow(0,1px,5px,0.1);
background: @caption-blue;
border: 1px solid @dark-grey;
color: #FFF;
font-weight: bold;
font-size: 1em;
text-align: center;
margin-bottom: 0;
padding: 5px 0;
}
thead {
th {
font-size: 0.6153em;
padding: 5px 0;
color: #666;
text-align: center;
text-transform: uppercase;
text-shadow: 0 1px 0 rgba(255,255,255,0.5);
border-bottom: 1px solid #bbbbbb;
.bw-gradient(#F7F7F7, 245, 255);
}
}
tfoot {
color: #e0e0e0;
font-size: 12px;
text-align: center;
tr {
.bw-gradient(#F7F7F7, 245, 255);
}
td {
padding: 5px;
&#next {
text-align: right;
}
&#prev {
text-align: left;
}
a {
color: #666;
text-shadow: 0 1px 0 rgba(255,255,255,0.5);
text-decoration: none;
&:hover { text-decoration:underline; color: @dark-grey; }
&:focus { text-decoration:underline; color: @dark-grey; }
}
}
}
tbody {
td {
color: #666;
font-size: .9230769em;
text-shadow: 0 1px 0 rgba(255,255,255,0.5);
padding: 6px;
text-align: center;
font-weight: normal;
border: 1px solid;
border-color: #BBB;
.bw-gradient(#F7F7F7, 245, 255);
&.eventless-pre {
color: #CCCCCC;
border-color: #CCCCCC;
}
&.eventless-post {
color: #CCCCCC;
border-color: #CCCCCC;
}
&.eventful {
a {
color: @blue;
}
}
&.eventless-today {
color: #ED174F;
text-decoration: none;
}
&.eventful-today {
a {
color: #ED174F;
}
}
}
}
}
.sidebar-2 {
.em-calendar {
box-shadow: none;
width: 100%;
font-size: .86em;
caption {
box-shadow: none;
background: @light-grey;
border-color: #BBBBBB;
border-width: 1px;
border-style: solid solid none solid;
color: @caption-blue;
}
tbody {
td {
.bw-gradient(#F9F9F9, 250, 255);
}
}
}
}
}
/*Full Calendar */
#content {
.em-full-calendar {
color: @dark-grey;
border-collapse: collapse;
width: 100%;
max-width: 580px;
white-space: nowrap;
table-layout: fixed;
caption {
.border-radius(5px,0,0,5px);
background: @caption-blue;
color: #FFFFFF;
font-size: 1.2em;
font-weight: normal;
padding: 10px 0;
text-align: center;
margin-bottom: 0;
}
thead {
th {
font-size: 1em;
padding: 5px 0;
color: @dark-grey;
border: 1px solid #BBB;
background: #f7f7f7;
text-align: center;
}
}
tfoot {
color: #e0e0e0;
font-size: 1em;
text-align: center;
tr {
.bw-gradient(#F7F7F7, 245, 255);
}
td {
padding: 1em;
&#next {
text-align: right;
}
&#prev {
text-align: left;
}
a {
color: #666;
text-shadow: 0 1px 0 rgba(255,255,255,0.5);
text-decoration: none;
&:hover { text-decoration:underline; color: @dark-grey; }
&:focus { text-decoration:underline; color: @dark-grey; }
}
}
}
tbody {
td {
border: 1px solid #CCC;
padding:0;
background-color: #FFFFFF;
text-align: left;
vertical-align: top;
height: 70px;
min-height: 70px;
overflow: hidden;
&.eventless-pre {
color: #CCCCCC;
border-color: #CCCCCC;
}
&.eventless-post {
color: #CCCCCC;
border-color: #CCCCCC;
}
&.eventless-today {
background-color: @light-grey;
.day {
color: #ED174F;
}
}
&.eventful-today {
background-color: @light-grey;
.day {
a {
color: #ED174F;
}
}
}
.day {
font-size: 0.9230769em;
padding: 2px;
display: block;
width: 100%;
}
ul {
list-style: none;
padding: 0;
margin: 0;
li {
.rounded(3px);
padding:1px;
margin-left:0;
background-color: #F7F7F7;
margin-bottom: 2px;
font-size: 0.84615em;
&:nth-child(odd) { background-color:@blue; }
&:nth-child(even) { background-color:lighten(@blue, 10%); }
a {
color: white;
text-decoration: none;
white-space: nowrap;
}
}
}
}
}
}
}
LESS requires http://lesselements.com/ mixins to work
<?php
/*
* RSS Page
* This page handles the even RSS feed.
* You can override this file by and copying it to yourthemefolder/plugins/events-manager/templates/ and modifying as necessary.
*
*/
header ( "Content-type: application/rss+xml; charset=UTF-8" );
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<rss version="2.0">
<channel>
<title><?php echo htmlentities(get_option ( 'dbem_rss_main_title' )); ?></title>
<link><?php echo get_permalink ( get_option('dbem_events_page') ); ?></link>
<description><?php echo htmlentities(get_option('dbem_rss_main_description')); ?></description>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<pubDate><?php echo get_option('em_rss_pubdate', date('D, d M Y H:i:s T')); ?></pubDate>
<atom:link href="<?php echo esc_attr(EM_RSS_URI); ?>" rel="self" type="application/rss+xml" />
<?php
$description_format = str_replace ( ">", "&gt;", str_replace ( "<", "&lt;", get_option ( 'dbem_rss_description_format' ) ) );
//$EM_Events = new EM_Events( array('limit'=>1, 'owner'=>false) );
//print_r($EM_Events);
$EM_Events = EM_Events::get( array('scope'=>'future', 'owner'=>false, 'category'=>$_GET["category"]) ); // hack by EC
foreach ( $EM_Events as $EM_Event ) {
$description = $EM_Event->output( get_option ( 'dbem_rss_description_format' ), "rss");
$description = ent2ncr(convert_chars(strip_tags($description))); //Some RSS filtering
$event_url = $EM_Event->output('#_EVENTURL');
?>
<item>
<title><?php echo $EM_Event->output( get_option('dbem_rss_title_format'), "rss" ); ?></title>
<link><?php echo $event_url; ?></link>
<guid><?php echo $event_url; ?></guid>
<description><?php echo $description; ?></description>
</item>
<?php
}
?>
</channel>
</rss>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment