Hi I have been working on a scrolling calendar for my xibo display
It uses simplepie and jquery.newsScroll
it works atm but not as I would like it to so that I could share it
here is the codeat the moment you need to change Parents Calander manually as a lot of the code does not work i have zipped the other files if anyone else wants a play.PHP Code:<?php
require 'simplepie.inc';
// Create a new class that extends an existing class
class SimplePie_Item_Extras extends SimplePie_Item {
var $show_past_events = TRUE;
function set_show_past_events($value = FALSE){
$this->show_past_events = $value;
}
/**
This is an example of adding a new method to an existing class
*/
function check_url($url_to_check){
$tmp = str_replace("/basic","/full",$url_to_check);
// if(!strpos($tmp,'?'))
// $tmp = $this->append($tmp,"?")
// else{
// if(!(substr($tmp, -1) === '&'))
// $tmp = $this->append($tmp,'&');
// }
// if($this->show_past_events)
// $tmp = $this->append($tmp,'futureevents=false&');
// else
// $tmp = $this->append($tmp,'futureevents=true&');
// if($this->sort_ascending)
// $tmp = $this->append($tmp,'sortorder=ascending&');
// else
// $tmp = $this->append($tmp,'sortorder=descending&');
// if($this->orderby_by_start_date)
// $tmp = $this->append($tmp,'orderby=starttime&');
// else
// $tmp = $this->append($tmp,'orderby=lastmodified&');
// if($this->expand_single_events)
// $tmp = $this->append($tmp,'singleevents=true&');
// else
// $tmp = $this->append($tmp,'singleevents=false&');
// return $tmp;
}
// Retrieve the <gd:when startTime="" /> value.
function get_gcal_starttime($format = false)
{
// We want to grab the Google-namespaced <gd:when> tag.
// http://simplepie.org/wiki/tutorial/grab_custom_tags_or_attributes
$when = $this->get_item_tags('http://schemas.google.com/g/2005', 'when');
// Once we grab the tag, let's grab the startTime attribute
$date = $when[0]['attribs']['']['startTime'];
if ($format)
{
// Let's pass it through strtotime() and then format it with date(). This will be the date we display.
return date($format, strtotime($date));
}
else
{
// Otherwise we'll return it as-is with no modifications.
return $date;
}
}
function get_gcal_endtime($format = false)
{
// We want to grab the Google-namespaced <gd:when> tag.
// http://simplepie.org/wiki/tutorial/grab_custom_tags_or_attributes
$when = $this->get_item_tags('http://schemas.google.com/g/2005', 'when');
// Once we grab the tag, let's grab the startTime attribute
$date = $when[0]['attribs']['']['endTime'];
if ($format)
{
// Let's pass it through strtotime() and then format it with date(). This will be the date we display.
return date($format, strtotime($date));
}
else
{
// Otherwise we'll return it as-is with no modifications.
return $date;
}
}
function get_gcal_where()
{
// We want to grab the Google-namespaced <gd:when> tag.
// http://simplepie.org/wiki/tutorial/grab_custom_tags_or_attributes
$where = $this->get_item_tags('http://schemas.google.com/g/2005','where');
// Once we grab the tag, let's grab the startTime attribute
return $where[0]['attribs']['']['valueString'];
}
/**
This is an example of modifying an existing method of an existing class.
*/
function get_id()
{
return $this->__toString();
}
}
$feed = new SimplePie('http://www.google.com/calendar/feeds/ford.plymouth.sch.uk_fcbr34ae6jag4pah8oogd7id50%40group.calendar.google.com/private-9b334582e4341761e0cc732328184757/full?futureevents=true');
$feed->handle_content_type();
$feed->set_item_class('SimplePie_Item_Extras');
$feed->init();
$feed->handle_content_type();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="style.css" type="text/css" media="screen" charset="utf-8" />
<title>Super Duper News Scroller</title>
</head>
<body>
<div id="container">
<?php echo $tmp ?>
<ul id="widget">
<?php foreach($feed->get_items(0, 15) as $item) : ?>
<li>
<h4><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h4>
<p>
Date <?php echo $item->get_gcal_starttime('j F Y'); ?><br>
Time <?php if($item->get_gcal_starttime('h:i') =='12:00'){echo "all day";}
else
{echo $item->get_gcal_starttime('H:i');echo' - ';echo $item->get_gcal_endtime('H:i');}?><br>
Event <?php echo $item->get_content('j F Y H:i'); ?><br>
Location <?php echo $item->get_gcal_where($string); ?>
</p>
</li>
<?php endforeach; ?>
</ul>
</div><!--end container-->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="jquery.newsScroll.js"></script>
<script type="text/javascript">
$('#widget').newsScroll({
speed: 2000,
delay: 5000
});
// or just call it like:
// $('#widget').newsScroll();
</script>
</body>
</html>
I have used various of open sources to create this I just want to make it easier for other people to use.


LinkBack URL
About LinkBacks



