Exporting data from a plugin

Here you can find plenty of help with your general coding needs and projects
If it is about a specific program, use the corresponding forum
DO NOT ask basic questions such as "How do I print a variable", use Google for that

Exporting data from a plugin

Postby lukes » Sun Aug 31, 2008 1:51 am

Hi guys,

I'm trying atm to extend the group calendar addon with an iCal export function. I've got the code down to create the iCal string and put that into an ical.php in GroupCalendar/guild/. I can open the export with index.php?p=guild-GroupCalendar-ical. But there are always empty lines before my output and the google calendar doesn't recognize iCal formated that way. Any idea where thats coming from? Sorry, I'm no php god and it's the first time i meddle in the code of the roster. :)

TIA, Jakob

Thats my complete code, I just removed the iCal code for now, since it's incomplete and unimportant for the problem. :)
Code: Select all
<?php
   define('CALENDAR_TABLE',$roster->db->table('info',$addon['basename']));
   define('ATTENDANCE_TABLE',$roster->db->table('attend',$addon['basename']));
   define('OTHERINFO_TABLE',$roster->db->table('other',$addon['basename']));

   $roster->output['show_header'] = false;  // Disable the roster header
   $roster->output['show_menu'] = false;    // Disable roster menu
   $roster->output['show_footer'] = false;  // Disable roster footer
   $roster->output['html_head'] = '';

   global $roster, $addon;

   header("Content-type: text/calendar");

   // [...] creation of the iCal [...]
   echo $ical;
?>
User avatar
lukes
WR.net Apprentice
WR.net Apprentice
 
Posts: 35
Joined: Tue Jan 22, 2008 4:46 pm

Exporting data from a plugin

Postby zanix » Sun Aug 31, 2008 2:41 am

Is there a way I could see the exported code?
A link to the output of this might be helpful
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Re: Exporting data from a plugin

Postby lukes » Sun Aug 31, 2008 4:25 am

Thats what I cut out. It's neither a secret, nor is it nice. :-) I need to add some code with attendece info, but for that I wan't to be sure that I can import it into google.
I'll PM you a link to the page, I don't need google crawling there ATM. (paranoid :))

Thanks for your time, Jakob

Code: Select all
   // iCal header
   $ical = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//WoWRoster Group Calendar iCal Export//NONSGML v1.0//EN\n";
   $events = array();

   // get the events
   $sql = "SELECT id, creator, type, description, title, duration, DATE_FORMAT(start, '%Y%m%dT%H%i%S') as dtstart FROM " . CALENDAR_TABLE;
        $result = $roster->db->query($sql);

   // create VEVENTS for each event
   while($row = mysql_fetch_array($result)){
      if($row['type'] == "Birth") continue;
      $ical .= "BEGIN:VEVENT\n";
      if(!empty($row['creator'])) $ical .= "ORGANIZER:" . $row['creator'] . "\n";
      $ical .= "DTSTART:" . $row['dtstart'] . "\n";
      if(!empty($row['duration'])) $ical .= "DURATION:P" . $row['duration'] . "M\n";
      if(!empty($row['title'])) $ical .= "SUMMARY:" . $row['title'] . "\n";
      if(!empty($row['description'])) $ical .= "DESCRIPTION:" . $row['description'] . "\n";
      // TODO: ATTENDEES
      // TODO: summary text
      $ical .= "END:VEVENT\n";
   }
   
   $ical .= "END:VCALENDAR\n";
User avatar
lukes
WR.net Apprentice
WR.net Apprentice
 
Posts: 35
Joined: Tue Jan 22, 2008 4:46 pm

Exporting data from a plugin

Postby zanix » Sun Aug 31, 2008 9:33 am

Hmm, 4 lines of blank then the code...

I tried making a minimal addon and turned off the header, footer, and menu and I was not getting the lines on my roster install

Could you pm me the entire source code, or a link to it?
Last edited by zanix on Sun Aug 31, 2008 9:33 am, edited 1 time in total.
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Re: Exporting data from a plugin

Postby lukes » Sun Aug 31, 2008 12:22 pm

Sure, I'll send you the PM in a minute, but you've seen the whole source by now, only in small pieces. :)

If I open my ical.php by /index.php?p=guild-GroupCalendar-ical, is there something else from the GroupCalendar loaded or only my file?

Jakob
User avatar
lukes
WR.net Apprentice
WR.net Apprentice
 
Posts: 35
Joined: Tue Jan 22, 2008 4:46 pm

Exporting data from a plugin

Postby zanix » Sun Aug 31, 2008 11:21 pm

It's possible, I'll install the addon and copy your iCal.php to the install

I do have some questions though
Did you modify Roster?
Did you modify GroupCalendar other than the iCal.php file?
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Exporting data from a plugin

Postby PleegWat » Sun Aug 31, 2008 11:29 pm

It will include addons/guildcalendar/inc/conf.php, as well as all locale files for guildcalendar.
I <3 /bin/bash
User avatar
PleegWat
WoWRoster.net Dev Team
WoWRoster.net Dev Team
 
Posts: 1636
Joined: Tue Jul 04, 2006 1:43 pm

Exporting data from a plugin

Postby zanix » Sun Aug 31, 2008 11:40 pm

That's it

The locale files enUS.php and frFR.php have a ?> at the end along with some white space
This is also against the coding guidelines which state to not put a ?> at the end of php files. If the author of this addon followed the guidelines, it would have avoided this issue

I would remove the ?> at the end of all the group calendar php files
That should fix your issue
Last edited by zanix on Sun Aug 31, 2008 11:41 pm, edited 1 time in total.
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Exporting data from a plugin

Postby Ulminia » Mon Sep 01, 2008 8:24 am

sorry .. hurried coding makes mistakes fixed white space and endtages for next ver..
Ulminia of Zangarmarsh
Zonous of Zangarmarsh
Author of Roster Gallery
WoWRoster-Profiler Redesigner
User avatar
Ulminia
WoWRoster.net Dev Team
WoWRoster.net Dev Team
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 1223
Joined: Tue Jul 04, 2006 4:41 pm
Location: New Brunswick, Canada
Realm: Zangarmarsh (PvE) - US
gmail/gtalk: ulminia@gmail.com

Exporting data from a plugin

Postby zanix » Mon Sep 01, 2008 9:17 am

I was trying to be subtle...lol
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Re: Exporting data from a plugin

Postby lukes » Tue Sep 02, 2008 12:03 am

Thanks, that solved it!
Google still didn't liked it until I added the following header:
Code: Select all
   header('Content-Disposition: attachment; filename="GuildCalendar.ics"');


Jakob
User avatar
lukes
WR.net Apprentice
WR.net Apprentice
 
Posts: 35
Joined: Tue Jan 22, 2008 4:46 pm


Return to General Code Help

Who is online

Users browsing this forum: No registered users and 1 guest

cron