We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14050
    • 788 Posts
    Kyle,

    Have you checked out FeedX?

    I just started playing with it. This might work great with what we are trying to do.

    Here is a quick implementation just using the Titles:

    http://www.cmssandbox.com/MODx095/index.php?id=57

    Using the full feed at:

    http://www.google.com/calendar/feeds/[email protected]/public/full
      Jesse R.
      Consider trying something new and extraordinary.
      Illinois Wine

      Have you considered donating to MODx lately?
      Donate now. Every contribution helps.
      • 15987
      • 786 Posts
      I am doing it right now, I had the same idea once I saw it.
        • 14050
        • 788 Posts
        Well, once we get this ironed out, I think it is due for a new release. I am going to package your recent changes into a minor release, as I would think switching to FeedX, would indicate a bigger release.

        [Edit]Done.
          Jesse R.
          Consider trying something new and extraordinary.
          Illinois Wine

          Have you considered donating to MODx lately?
          Donate now. Every contribution helps.
          • 8471
          • 333 Posts
          Hi, with this simple call:
          [!GoogleEvents?dayNameSize=`1` &outputType=`calendar` &calendarType=`small` &email=`[email protected]`!]
          I receive this parse error:
          « MODx Parse Error »
          MODx encountered the following error while attempting to parse the requested resource: 
          « PHP Parse Error » 
            
          PHP error debug 
            Error:  sort() expects parameter 1 to be array, null given   
            Error type/ Nr.:  Warning - 2   
            File:  C:\sito\manager\includes\document.parser.class.inc.php(748) : eval()'d code   
            Line:  240   
            
          Parser timing 
            MySQL:  0.0514 s (8 Requests) 
            PHP:  0.9020 s   
            Total:  0.9534 s   
          
            Sorry for my bad English grin
            • 14050
            • 788 Posts
            What version are you using? Make sure you have this version installed:

            http://www.modxcms.com/Google-Events-1301.html

            After that, please add the &debug=`1` parameter to your call and paste the output here?

            Do you have any events in your calendar?
            Have you made your calendar public?
            What is the address of your public feed?
              Jesse R.
              Consider trying something new and extraordinary.
              Illinois Wine

              Have you considered donating to MODx lately?
              Donate now. Every contribution helps.
              • 8471
              • 333 Posts
              I’m using the last version (1.3.4)
              Debug output:
              Debug mode is on.
              
              Getting XML feed
              
              Description to be parsed: 
              Quando: dal Sab. 28 Apr. 2007 al Lun. 30 Apr. 2007  <br> <br>Stato evento: confermato
              
              Atempting to parse the following date:
              
              
              Parsed Date:
              Starting Day: Thursday, January, 1st, 1970
              Starting Time: 
              Ending Day: Thursday, January, 1st, 1970
              Ending Time: 
              Time Greater Than 0? 
              
              This is what I think the "Where" string should be:
              
              
              Description to be parsed: 
              Quando: dal Sab. 28 Apr. 2007 al Lun. 30 Apr. 2007  <br> <br>Stato evento: confermato
              
              Atempting to parse the following date:
              
              
              Parsed Date:
              Starting Day: Thursday, January, 1st, 1970
              Starting Time: 
              Ending Day: Thursday, January, 1st, 1970
              Ending Time: 
              Time Greater Than 0? 
              
              This is what I think the "Where" string should be:
              
              
              Description to be parsed: 
              Quando: dal Ven. 20 Apr. 2007 18:00 al 20:00  CEST<br> <br>Dove: Piazza San Domenico 2, San Domenico di Fiesole (Firenze) <br>Stato evento: confermato
              
              Atempting to parse the following date:
              
              
              Parsed Date:
              Starting Day: Thursday, January, 1st, 1970
              Starting Time: 
              Ending Day: Thursday, January, 1st, 1970
              Ending Time: 
              Time Greater Than 0? 
              
              This is what I think the "Where" string should be:
              
              
              Description to be parsed: 
              Quando: dal Ven. 4 Mag. 2007 18:00 al 20:00  CEST<br> <br>Dove: Piazza San Domenico 2, San Domenico di Fiesole (Firenze) <br>Stato evento: confermato
              
              Atempting to parse the following date:
              
              
              Parsed Date:
              Starting Day: Thursday, January, 1st, 1970
              Starting Time: 
              Ending Day: Thursday, January, 1st, 1970
              Ending Time: 
              Time Greater Than 0? 
              
              This is what I think the "Where" string should be:
              
              
              Description to be parsed: 
              Quando: dal Ven. 27 Apr. 2007 18:00 al 20:00  CEST<br> <br>Dove: Piazza San Domenico 2, San Domenico di Fiesole (Firenze) <br>Stato evento: confermato
              
              Atempting to parse the following date:
              
              
              Parsed Date:
              Starting Day: Thursday, January, 1st, 1970
              Starting Time: 
              Ending Day: Thursday, January, 1st, 1970
              Ending Time: 
              Time Greater Than 0? 
              
              This is what I think the "Where" string should be:
              
              
              Description to be parsed: 
              Quando: dal Ven. 11 Mag. 2007 18:00 al 20:00  CEST<br> <br>Dove: Piazza San Domenico 2, San Domenico di Fiesole (Firenze) <br>Stato evento: confermato
              
              Atempting to parse the following date:
              
              
              Parsed Date:
              Starting Day: Thursday, January, 1st, 1970
              Starting Time: 
              Ending Day: Thursday, January, 1st, 1970
              Ending Time: 
              Time Greater Than 0? 
              
              This is what I think the "Where" string should be:
              
              
              Description to be parsed: 
              Quando: dal Sab. 28 Apr. 2007 al Lun. 30 Apr. 2007  <br> <br>Stato evento: confermato <br>Descrizione evento: Campo di Primavera, dettagli non ancora disponibili.
              
              Atempting to parse the following date:
              
              
              Parsed Date:
              Starting Day: Thursday, January, 1st, 1970
              Starting Time: 
              Ending Day: Thursday, January, 1st, 1970
              Ending Time: 
              Time Greater Than 0? 
              
              This is what I think the "Where" string should be:
              
              
              Description to be parsed: 
              Quando: dal Sab. 21 Apr. 2007 al Dom. 22 Apr. 2007  <br> <br>Stato evento: confermato <br>Descrizione evento: Fine Settimana di Branco, dettagli ancora non disponibili.
              
              Atempting to parse the following date:
              
              
              Parsed Date:
              Starting Day: Thursday, January, 1st, 1970
              Starting Time: 
              Ending Day: Thursday, January, 1st, 1970
              Ending Time: 
              Time Greater Than 0? 
              
              This is what I think the "Where" string should be:
              
              
              Description to be parsed: 
              Quando: dal Sab. 5 Mag. 2007 15:00 al 17:00  CEST<br> <br>Dove: Via Leonardo da Vinci 4/R, Firenze <br>Stato evento: confermato <br>Descrizione evento: Riunione del Branco
              
              Atempting to parse the following date:
              
              
              Parsed Date:
              Starting Day: Thursday, January, 1st, 1970
              Starting Time: 
              Ending Day: Thursday, January, 1st, 1970
              Ending Time: 
              Time Greater Than 0? 
              
              This is what I think the "Where" string should be:
              
              
              Description to be parsed: 
              Quando: dal Sab. 14 Apr. 2007 15:00 al 17:00  CEST<br> <br>Dove: Via Leonardo da Vinci 4/R, Firenze <br>Stato evento: confermato <br>Descrizione evento: Riunione del Branco
              
              Atempting to parse the following date:
              
              
              Parsed Date:
              Starting Day: Thursday, January, 1st, 1970
              Starting Time: 
              Ending Day: Thursday, January, 1st, 1970
              Ending Time: 
              Time Greater Than 0? 
              
              This is what I think the "Where" string should be:
              
              
              Description to be parsed: 
              Quando: dal Sab. 12 Mag. 2007 15:00 al 17:00  CEST<br> <br>Dove: Via Leonardo da Vinci 4/R, Firenze <br>Stato evento: confermato <br>Descrizione evento: Riunione del Branco
              
              Atempting to parse the following date:
              
              
              Parsed Date:
              Starting Day: Thursday, January, 1st, 1970
              Starting Time: 
              Ending Day: Thursday, January, 1st, 1970
              Ending Time: 
              Time Greater Than 0? 
              
              This is what I think the "Where" string should be:
              
              
              Description to be parsed: 
              Quando: dal Sab. 21 Apr. 2007 15:00 al 17:00  CEST<br> <br>Dove: Via Leonardo da Vinci 4/R, Firenze <br>Stato evento: confermato <br>Descrizione evento: Riunione del Branco
              
              Atempting to parse the following date:
              
              
              Parsed Date:
              Starting Day: Thursday, January, 1st, 1970
              Starting Time: 
              Ending Day: Thursday, January, 1st, 1970
              Ending Time: 
              Time Greater Than 0? 
              
              This is what I think the "Where" string should be:
              
              
              Description to be parsed: 
              Quando: dal Gio. 26 Apr. 2007 21:00 al 23:00  CEST<br> <br>Dove: Piazza San Domenico 2, San Domenico di Fiesole (Firenze) <br>Stato evento: confermato <br>Descrizione evento: Riunione di Noviziato
              
              Atempting to parse the following date:
              
              
              Parsed Date:
              Starting Day: Thursday, January, 1st, 1970
              Starting Time: 
              Ending Day: Thursday, January, 1st, 1970
              Ending Time: 
              Time Greater Than 0? 
              
              This is what I think the "Where" string should be:
              
              
              Description to be parsed: 
              Quando: dal Gio. 3 Mag. 2007 21:00 al 23:00  CEST<br> <br>Dove: Piazza San Domenico 2, San Domenico di Fiesole (Firenze) <br>Stato evento: confermato <br>Descrizione evento: Riunione di Noviziato
              
              Atempting to parse the following date:
              
              
              Parsed Date:
              Starting Day: Thursday, January, 1st, 1970
              Starting Time: 
              Ending Day: Thursday, January, 1st, 1970
              Ending Time: 
              Time Greater Than 0? 
              
              This is what I think the "Where" string should be:
              
              
              Description to be parsed: 
              Quando: dal Gio. 10 Mag. 2007 21:00 al 23:00  CEST<br> <br>Dove: Piazza San Domenico 2, San Domenico di Fiesole (Firenze) <br>Stato evento: confermato <br>Descrizione evento: Riunione di Noviziato
              
              Atempting to parse the following date:
              
              
              Parsed Date:
              Starting Day: Thursday, January, 1st, 1970
              Starting Time: 
              Ending Day: Thursday, January, 1st, 1970
              Ending Time: 
              Time Greater Than 0? 
              
              This is what I think the "Where" string should be:
              
              
              Description to be parsed: 
              Quando: dal Gio. 19 Apr. 2007 21:00 al 23:00  CEST<br> <br>Dove: Piazza San Domenico 2, San Domenico di Fiesole (Firenze) <br>Stato evento: confermato <br>Descrizione evento: Riunione di Noviziato
              
              Atempting to parse the following date:
              
              
              Parsed Date:
              Starting Day: Thursday, January, 1st, 1970
              Starting Time: 
              Ending Day: Thursday, January, 1st, 1970
              Ending Time: 
              Time Greater Than 0? 
              
              This is what I think the "Where" string should be:
              
              
              Description to be parsed: 
              Quando: dal Gio. 26 Apr. 2007 20:30 al 22:30  CEST<br> <br>Dove: Via Leonardo da Vinci 4/R, Firenze <br>Stato evento: confermato <br>Descrizione evento: Riunione di Clan... arrivare puntuali e con la cena al sacco!
              
              Atempting to parse the following date:
              
              
              Parsed Date:
              Starting Day: Thursday, January, 1st, 1970
              Starting Time: 
              Ending Day: Thursday, January, 1st, 1970
              Ending Time: 
              Time Greater Than 0? 
              
              This is what I think the "Where" string should be:
              
              
              Description to be parsed: 
              Quando: dal Gio. 19 Apr. 2007 20:30 al 22:30  CEST<br> <br>Dove: Via Leonardo da Vinci 4/R, Firenze <br>Stato evento: confermato <br>Descrizione evento: Riunione di Clan... arrivare puntuali e con la cena al sacco!
              
              Atempting to parse the following date:
              
              
              Parsed Date:
              Starting Day: Thursday, January, 1st, 1970
              Starting Time: 
              Ending Day: Thursday, January, 1st, 1970
              Ending Time: 
              Time Greater Than 0? 
              
              This is what I think the "Where" string should be:
              
              
              Description to be parsed: 
              Quando: dal Gio. 3 Mag. 2007 20:30 al 22:30  CEST<br> <br>Dove: Via Leonardo da Vinci 4/R, Firenze <br>Stato evento: confermato <br>Descrizione evento: Riunione di Clan... arrivare puntuali e con la cena al sacco!
              
              Atempting to parse the following date:
              
              
              Parsed Date:
              Starting Day: Thursday, January, 1st, 1970
              Starting Time: 
              Ending Day: Thursday, January, 1st, 1970
              Ending Time: 
              Time Greater Than 0? 
              
              This is what I think the "Where" string should be:
              
              
              Description to be parsed: 
              Quando: dal Gio. 10 Mag. 2007 20:30 al 22:30  CEST<br> <br>Dove: Via Leonardo da Vinci 4/R, Firenze <br>Stato evento: confermato <br>Descrizione evento: Riunione di Clan... arrivare puntuali e con la cena al sacco!
              
              Atempting to parse the following date:
              
              
              Parsed Date:
              Starting Day: Thursday, January, 1st, 1970
              Starting Time: 
              Ending Day: Thursday, January, 1st, 1970
              Ending Time: 
              Time Greater Than 0? 
              
              This is what I think the "Where" string should be:
              
              
              « MODx Parse Error »
              MODx encountered the following error while attempting to parse the requested resource: 
              « PHP Parse Error » 
                
              PHP error debug 
                Error:  sort() expects parameter 1 to be array, null given   
                Error type/ Nr.:  Warning - 2   
                File:  C:\sito\manager\includes\document.parser.class.inc.php(748) : eval()'d code   
                Line:  240   
                
              Parser timing 
                MySQL:  0.0504 s (8 Requests) 
                PHP:  1.6622 s   
                Total:  1.7126 s   
              


              Yes my calendar is public and this is the address of my public feed: link
                Sorry for my bad English grin
                • 14050
                • 788 Posts
                Unfortunately, this snippet only works with English feeds. This snippet has definite downfalls in that it tries to parse the plain text and doesn’t take advantage of the tags provided in the feed. At one time Kyle was talking about redoing this snippet utilizing FeedX. If that is done then this snippet should be more international friendly as the tags don’t change with the language being used. Regrettably, I don’t have the time to do this right now. Kyle, have you made any headway in this area?

                I have your feed running here:
                http://cmssandbox.com/MODx095/index.php?id=82

                I can see from the debug output, that this snippet is having difficulty parsing the date when it spans over multiple days. Try changing all these to multiple single day events (especially since you are using calendar output).

                I have pulled out the English constants, and you can translate them, and that will get you started. I would also guess you need to change the function "strtotime" to "strftime" as "strtotime" requires an English date string. Once you get the date logic figured out, I think the rest should all work.

                <?php
                // Resource Name: GoogleEvents
                // Author: Jesse Rochman
                // Forum Alias: jesster444
                // Version: 1.3.5
                // Compatible with .951
                // Released: 1/9/2007
                // Modified: 3/1/2007 by KyleJ
                // Modified: 3/2/2007 by Jesse
                // Modified: 4/14/2007 by Jesse
                // Inspired by James Cridlands Google Calendar Code
                //Calendar Class is from Giorgos Tsiledakis Active Calendar
                
                
                //Language Strings -- MUST TRANSLATE FOR SNIPPET TO WORK
                $WHEN_TEXT = 'When:';
                $WHERE_TEXT = 'Where:';
                $EVENT_DESCRIPTION_TEXT = 'Event Description: ';
                $CHARACTERS_IN_EVENT_DESCRIPTION_TEXT = 18;
                
                //Some General Configurations
                $basePath = $modx->config['base_path'];
                $siteURL = $modx->config['site_url'];
                $VERSION = '1.3.5';
                
                // Your Gmail address
                $email = isset($email)? $email : "[email protected]";
                
                //Set month and day names.  You can translate here.
                $dayNames1 = array('S','M','T','W','T','F','S');
                $dayNames3 = array('Sun','Mon','Tue','Wed','Thur','Fri','Sat');
                $dayNamesFull = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
                $monthNames = array('January','February','March','April','May','June','July','August','September','October','November','December');
                
                if (!isset ($dayNameSize)) {
                	$dayNameSize = $dayNames3;
                	} elseif (strtolower($dayNameSize) == 'full') {
                	$dayNameSize = $dayNamesFull;
                	} elseif ($dayNameSize == 1) {
                	$dayNameSize = $dayNames1;
                	} else {
                	$dayNameSize = $dayNames3;
                	}
                
                //This will determine whether to output the calendar, the list, or both.
                $outputType = isset($outputType)? $outputType : "both";
                
                // Format for date and time
                $dateFormat = isset($dateFormat)? $dateFormat : "l, F, jS, Y"; // Thursday, 10 March - see http://www.php.net/date for details
                $timeFormat = isset($timeFormat)? $timeFormat : "g:ia";
                
                //Order of Output.  True for Reverse Chronilogical and False for Chronilogical
                $order = isset($order)? $order : 0;
                
                //Show Events For This Many Days Out
                $lastEvent = isset($lastEvent)? $lastEvent : 30;
                
                //Show only this many events
                $maxEvents = isset($maxEvents)? $maxEvents : 30;
                
                //Skip this many events.  This way you can make two snippet calls and jump around
                $skipEvents = isset($skipEvents)? $skipEvents : 0;
                
                // Cache location for your XML file
                $cache_location= $basePath.'assets/snippets/GoogleEvents/cache';
                
                // Here is where your copy of Simplepie lives
                include_once ($basePath.'assets/snippets/GoogleEvents/php/simplepie.inc');
                
                //Sets a big or small calendar
                $calendarType = isset($calendarType)? $calendarType : '';
                
                //Determine the first day of the week
                $firstDay = isset($firstDay)? $firstDay : 0;
                
                // Change this to 'true' to see some debug code
                $debug = isset($debug)? $debug : 0;
                
                //Config ends
                
                if ($outputType == 'calendar' || $outputType == 'both') {
                	include_once('assets/snippets/GoogleEvents/source/activecalendar.php');
                	//For the calendar script
                	//Variables for Calendar
                	$myurl='?id='.$modx->documentIdentifier; // the links url is this page
                	$yearID=false; // init false to display current year
                	$monthID=false; // init false to display current month
                	$dayID=false; // init false to display current day
                	extract($_GET); // get the new values (if any) of $yearID,$monthID,$dayID
                	$arrowBack="<img src=\"assets/snippets/GoogleEvents/data/img/back.png\" alt=\"<<\" />"; // use png arrow back
                	$arrowForw="<img src=\"assets/snippets/GoogleEvents/data/img/forward.png\" alt=\">>\" />"; // use png arrow forward
                	$cal = new activeCalendar($yearID,$monthID,$dayID);
                }
                
                if ($outputType == 'list' || $outputType == 'both') {	
                	//Grab the templates.  If one isn't passed to the program, then setup a default template.
                	$defaultTemplate = '<div><h2><a href="[+linkURL+]">[+title+]</a></h2><p>[+startDate+] at [+startTime+]<br />Description: [+content+]</p></div>';
                	$numberOfEvents = 0;
                	$tpl = $modx->getChunk($tpl);
                	$tplOddRow = $modx->getChunk($tplOddRow);
                	$tplEvenRow = $modx->getChunk($tplEvenRow);
                	$tplFirstRow = $modx->getChunk($tplFirstRow);
                	$tplLastRow = $modx->getChunk($tplLastRow);
                
                	if ($tpl) {
                	  $defaultTemplate = $tpl;
                	}
                	if (!$tplOddRow) {
                	  $tplOddRow = $defaultTemplate;
                	}
                	if (!$tplEvenRow) {
                	  $tplEvenRow = $defaultTemplate;
                	}
                	if (!$tplFirstRow) {
                	  $tplFirstRow = $defaultTemplate;
                	}
                	if (!$tplLastRow) {
                	  $tplLastRow = $defaultTemplate;
                	}
                }
                
                $startMax = date('Y-m-d',mktime(0, 0, 0, date("m")  , date("d")+$lastEvent, date("Y")));
                
                if ($debug) {echo "<p>Version: $VERSION<br />Debug mode is on.</p>";}
                
                $calendar_xml_address = "http://www.google.com/calendar/feeds/".$email."/public/basic?start-min=".date("Y-m-d").'&start-max='.$startMax.'&singleevents=true';
                
                if ($debug) {echo "<p>Getting <a href='$calendar_xml_address'>$calendar_xml_address</a></p>
                <p>Language Constants:<br />$WHERE_TEXT | $WHEN_TEXT | $EVENT_DESCRIPTION_TEXT | $CHARACTERS_IN_EVENT_DESCRIPTION_TEXT</p>";}
                
                $feed = new SimplePie();
                $feed->feed_url($calendar_xml_address);
                $feed->cache_location($cache_location);
                //$feed->enable_caching(FALSE);
                //$feed->enable_xmldump(true);
                $feed->init();
                $feed->handle_content_type();
                
                if($feed->get_items()) {
                	foreach($feed->get_items() as $item) {	
                		//echo '<pre>' . print_r($item,1) . '</pre>';
                	    $description = $item->get_description();
                		if ($description) {
                		    if ($debug) { echo "<p><b>Description to be parsed:</b> <br />".$description."</p>"; }
                			
                			//Remove some of the html entity oddities that Google produces like &amp; which displays "&"
                			$description = str_replace ("&amp;","&",$description);
                			$description = str_replace ("&#39;","&#39;",$description);
                			$description = str_replace ("&quot;",""",$description);
                			
                			// Extract the 'when' information from the item summary, and ignore everything else
                			$from = trim(textBetween($WHEN_TEXT,"<",$description));
                			if (strlen($from) > 16) {
                				$from = trim(textBetween($WHEN_TEXT,"&",$description));
                			}
                			
                			//Put all event information into an array
                			$from = str_replace(',','',$from);
                			$fromInfo = explode(" ",$from);
                			
                			if (count($fromInfo) < 8 ) {
                				$useInfo = array(
                					'startDow' => $fromInfo[0],
                					'startMon' => $fromInfo[1],
                					'startDay' => $fromInfo[2],
                					'startYear' => $fromInfo[3],
                					'startTime' => $fromInfo[4],
                					'endDow' => $fromInfo[0],
                					'endMon' => $fromInfo[1],
                					'endDay' => $fromInfo[2],
                					'endYear' => $fromInfo[3],
                					'endTime' => $fromInfo[6],
                				);
                			} else {
                				$useInfo = array(
                					'startDow' => $fromInfo[0],
                					'startMon' => $fromInfo[1],
                					'startDay' => $fromInfo[2],
                					'startYear' => $fromInfo[3],
                					'startTime' => $fromInfo[4],
                					'endDow' => $fromInfo[6],
                					'endMon' => $fromInfo[7],
                					'endDay' => $fromInfo[8],
                					'endYear' => $fromInfo[9],
                					'endTime' => $fromInfo[10],
                				);
                			}
                			//Add a leading zero to the day if none
                			if (strlen($useInfo['startDay']) < 2) { $useInfo['startDay'] = "0{$useInfo['startDay']}"; }
                			if (strlen($useInfo['endDay']) < 2) { $useInfo['endDay'] = "0{$useInfo['endDay']}"; }
                			//Make start time include mintues and leading 0 if necessary for correct time calculation
                			if (strlen($useInfo['startTime']) == 3) { $useInfo['startTime'] = '0' . substr($useInfo['startTime'],0,1) . ':00' . substr($fromInfo['startTime'],1,2); }
                			if (strlen($useInfo['startTime']) == 4) { $useInfo['startTime'] = substr($useInfo['startTime'],0,2) . ':00' . substr($useInfo['startTime'],2,2); }
                			if (strlen($useInfo['startTime']) == 6) { $useInfo['startTime'] = '0' . $useInfo['startTime']; }
                			//Make end time include mintues and leading 0 if necessary for correct time calculation
                			if (strlen($useInfo['endTime']) == 3) { $useInfo['endTime'] = '0' . substr($useInfo['endTime'],0,1) . ':00' . substr($useInfo['endTime'],1,2); }
                			if (strlen($useInfo['endTime']) == 4) { $useInfo['endTime'] = substr($useInfo['endTime'],0,2) . ':00' . substr($useInfo['endTime'],2,2); }
                			if (strlen($useInfo['endTime']) == 6) { $useInfo['endTime'] = '0' . $useInfo['endTime']; }
                			
                			//Convert start date & time to a unix time stamp & fill other vars
                			$tempStartDate = strtotime("{$useInfo['startDay']} {$useInfo['startMon']} {$useInfo['startYear']} {$useInfo['startTime']}");
                			$startDate = date($dateFormat,$tempStartDate);
                			$startDay = $useInfo['startDay'];
                			$startYear = $useInfo['startYear'];
                			$startTime = $useInfo['startTime'] ? date($timeFormat,$tempStartDate) : '';
                			$startMonthCal = date('n',$tempStartDate);
                			
                			//Convert end date & time to a unix time stamp & fill other vars
                			$tempEndTime = strtotime("{$useInfo['endDay']} {$useInfo['endMon']} {$useInfo['endYear']} {$useInfo['endTime']}");
                			$endDate = date($dateFormat,$tempEndTime);
                			$endTime = $useInfo['endTime'] ? date($timeFormat,$tempEndTime) : '';
                
                			$time = $tempStartDate;	
                			if ($debug) { 
                			echo "<p><b>Atempting to parse the following date:</b><br />$from</p>
                				  <p><b>Parsed Date:</b><br />
                					 Starting Day: $startDate<br />
                					 Starting Time: $startTime<br />
                					 Ending Day: $endDate<br />
                					 Ending Time: $endTime<br />
                					 Time Greater Than 0? $time</p>";
                					 }
                
                			// Extract the 'where' information from the item summary, and ignore everything else
                			$where = textBetween($WHERE_TEXT,"<",$description);
                			if (empty ($where)) $where = '';
                			if ($debug) {
                				echo "<p><b>This is what I think the "Where" string should be:</b><br />$where</p>";
                			}
                			
                			// Extract the "Event Description" information from the item summary, and ignore everything else
                			if (strpos($description,$EVENT_DESCRIPTION_TEXT)) {
                				$eventDescription = substr($description,strpos($description,$EVENT_DESCRIPTION_TEXT)+$CHARACTERS_IN_EVENT_DESCRIPTION_TEXT);
                			} else {
                				$eventDescription = '';
                			}
                
                			// Extract the link for Google Calendar
                			$url=$item->get_links();
                
                			// Stick into a nice array if it has a valid timestamp (not a recurring event).
                			if ($time > 0) {
                				$events[]=array('time'=>$time,'where'=>$where,'title'=>$item->get_title(),'url'=>$url[0],'eventDescription'=>$eventDescription,'startDate'=>$startDate,'startTime'=>$startTime,'endDate'=>$endDate,'endTime'=>$endTime,'startYear'=>$startYear,'startDay'=>$startDay,'startMonthCal'=>$startMonthCal);
                			}
                		}
                	}
                
                	// Sort the bookings into time order
                	if (!$order){
                		// Sort the events into chronilogical order.
                		sort($events);
                		} else {
                		rsort($events);
                		}
                
                	$counterMaxEvents = 0;
                	$counterSkipEvents = 0;
                	foreach($events as $event) {
                		if ($outputType == 'list' || $outputType == 'both') {
                			$numberOfEvents++;
                			if ($counterSkipEvents >= $skipEvents){
                				//Figure out what template to use
                				if($numberOfEvents == 1 || $counterSkipEvents == $skipEvents) {
                					$template = $tplFirstRow;
                					} elseif ($numberOfEvents == count($events) || $counterMaxEvents == ($maxEvents-1)) {
                					$template = $tplLastRow;
                					} elseif (($numberOfEvents & 1) == 0) {
                					$template = $tplEvenRow;
                					} else {
                					$template = $tplOddRow;
                					}
                				$counterSkipEvents++;
                				//Output the data in the appropriate template
                				if ($counterMaxEvents < $maxEvents) {
                					$output = str_replace('[+title+]',$event['title'],$template);
                					$output = str_replace('[+startDate+]',$event['startDate'],$output);
                					$output = str_replace('[+startTime+]',$event['startTime'],$output);
                					$output = str_replace('[+endDate+]',$event['endDate'],$output);
                					$output = str_replace('[+endTime+]',$event['endTime'],$output);
                					$output = str_replace('[+where+]',$event['where'],$output);
                					$output = str_replace('[+content+]',$event['eventDescription'],$output);
                					$output = str_replace('[+eventNumber+]',$numberOfEvents,$output);
                					$output = str_replace('[+linkURL+]',$event['url'],$output);
                					echo $output;
                					$counterMaxEvents++;
                					} 
                			} else { 
                				$counterSkipEvents++;
                				}
                			} 
                			if($outputType == 'calendar' || $outputType == 'both') {
                				$cal->setEvent($event['startYear'],$event['startMonthCal'],$event['startDay'],"event",$event['url']);
                				if($calendarType == 'wide') {
                					$multipleLinesEvent=array($event['title'],$event['startTime'].'-'.$event['endTime']);
                					$cal->setEventContent($event['startYear'],$event['startMonthCal'],$event['startDay'],$multipleLinesEvent,$event['url']);
                				}
                			}
                	}	
                	if($outputType == 'calendar' || $outputType == 'both') {
                			//outPutCalendar($fullMonths, $shortMonths,$mDays, $arrangedEvents);
                			$cal->setDayNames($dayNameSize);
                			$cal->setMonthNames($monthNames);
                			$cal->setFirstWeekDay($firstDay);
                			$cal->enableMonthNav($myurl,$arrowBack,$arrowForw); // enables navigation controls
                			print $cal->showMonth();
                	}
                
                	return '';
                	} else {
                	return "<p>The feed is unavailable.  This could be caused by the server being down, an incorrect feed address, or if you have no events in your feed.  The feed address you tried to load was <a href='$calendar_xml_address'>$calendar_xml_address</a>.</p>";
                	}
                
                function textBetween($s1,$s2,$s){
                  $s1 = strtolower($s1);
                  $s2 = strtolower($s2);
                  $L1 = strlen($s1);
                  $scheck = strtolower($s);
                
                  if($L1>0){$pos1 = strpos($scheck,$s1);} else {$pos1=0;}
                  if($pos1 !== false){
                   if($s2 == '') return substr($s,$pos1+$L1);
                   $pos2 = strpos(substr($scheck,$pos1+$L1),$s2);
                   if($pos2!==false) return substr($s,$pos1+$L1,$pos2);
                  }
                  return '';
                }
                ?>
                  Jesse R.
                  Consider trying something new and extraordinary.
                  Illinois Wine

                  Have you considered donating to MODx lately?
                  Donate now. Every contribution helps.
                  • 8471
                  • 333 Posts
                  Thanks so much jesster444! smiley
                  I’ll try the snippet version.
                    Sorry for my bad English grin
                    • 867
                    • 241 Posts
                    Then we could provide for a way for users to add simple events from a MODx frontend form and do other neat things using Google as the calendar backend.

                    That would be great grin

                    Something new with this snippet ?

                    thks.
                      • 14050
                      • 788 Posts
                      Unfortunately, I haven’t had the chance to learn the Google Calendar API, which would be required to publish to the calendar from a MODx form. If anyone wants to pick it up, feel free.
                        Jesse R.
                        Consider trying something new and extraordinary.
                        Illinois Wine

                        Have you considered donating to MODx lately?
                        Donate now. Every contribution helps.