+ Post New Thread
Results 1 to 1 of 1
Coding Thread, simplepie php for google calander in Coding and Web Development; Hi I have been working on a scrolling calendar for my xibo display It uses simplepie and jquery.newsScroll it works ...
  1. #1
    alonebfg's Avatar
    Join Date
    Aug 2006
    Location
    south west some of the time
    Posts
    834
    Thank Post
    12
    Thanked 34 Times in 21 Posts
    Blog Entries
    5
    Rep Power
    24

    simplepie php for google calander

    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 code
    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($formatstrtotime($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($formatstrtotime($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(015) 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>
    at 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.
    I have used various of open sources to create this I just want to make it easier for other people to use.
    Attached Files Attached Files

SHARE:
+ Post New Thread

Similar Threads

  1. [Pics] I want to work for google!
    By Little-Miss in forum Jokes/Interweb Things
    Replies: 4
    Last Post: 28th September 2010, 11:18 AM
  2. Replies: 3
    Last Post: 8th May 2010, 01:18 PM
  3. Set send time for Google Groups Digest
    By garethedmondson in forum How do you do....it?
    Replies: 1
    Last Post: 22nd June 2009, 02:04 PM
  4. Anyone have an MSI for Google Earth 5
    By careless in forum Educational Software
    Replies: 20
    Last Post: 21st April 2009, 07:42 PM
  5. Replies: 1
    Last Post: 14th June 2007, 07:50 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •