source: trunk/calendar/inc/class.uiicalendar.inc.php @ 2

Revision 2, 7.0 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2  /**************************************************************************\
3  * eGroupWare - Calendar                                                    *
4  * http://www.egroupware.org                                                *
5  * Based on Webcalendar by Craig Knudsen <cknudsen@radix.net>               *
6  *          http://www.radix.net/~cknudsen                                  *
7  * Modified by Mark Peters <skeeter@phpgroupware.org>                       *
8  * --------------------------------------------                             *
9  *  This program is free software; you can redistribute it and/or modify it *
10  *  under the terms of the GNU General Public License as published by the   *
11  *  Free Software Foundation; either version 2 of the License, or (at your  *
12  *  option) any later version.                                              *
13  \**************************************************************************/
14
15
16        class uiicalendar
17        {
18                var $bo;
19                var $template;
20
21                var $public_functions = array(
22                        'test'          => True,
23                        'import'                => True
24                );
25
26
27
28                function uiicalendar()
29                {
30                        $this->bo = CreateObject('calendar.boicalendar');
31                        $this->template = $GLOBALS['phpgw']->template;
32                        $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Calendar - [iv]Cal Importer');
33                }
34
35                function print_test($val,$title,$x_pre='')
36                {
37//                      echo 'VAL = '._debug_array($val,False)."<br>\n";
38                        if(is_array($val))
39                        {
40                                @reset($val);
41                                while(list($key,$value) = each($val))
42                                {
43                                        if(is_array($key))
44                                        {
45                                                $this->print_test($key,$title,$x_pre);
46                                        }
47                                        elseif(is_array($value))
48                                        {
49                                                $this->print_test($value,$title,$x_pre);
50                                        }
51                                        else
52                                        {
53                                                if($x_pre && $key == 'name')
54                                                {
55                                                        $x_key = $x_pre.$value;
56                                                        list($key,$value) = each($val);
57                                                        $key=$x_key;
58                                                }
59                                                if($this->bo->parameter[$key]['type'] == 'function')
60                                                {
61                                                        $function = $this->bo->parameter[$key]['function'];
62                                                        $v_value = $this->bo->$function($value);
63                                                }
64                                                else
65                                                {
66                                                        $v_value = $value;
67                                                }
68                                                echo $title.' ('.$key.') = '.$v_value."<br>\n";
69                                        }
70                                }
71                        }
72                        elseif($val != '')
73                        {
74                                echo $title.' = '.$val."<br>\n";
75                        }
76                }
77
78                function test()
79                {
80                        $print_events = True;
81                       
82                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
83                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
84                        $GLOBALS['phpgw']->common->phpgw_header();
85
86                        echo "Start Time : ".$GLOBALS['phpgw']->common->show_date()."<br>\n";
87                        @set_time_limit(0);
88
89                        $icsfile=PHPGW_APP_INC.'/events.ics';
90                        $fp=fopen($icsfile,'rt');
91                        $contents = explode("\n",fread($fp, filesize($icsfile)));
92                        fclose($fp);
93
94                        $vcalendar = $this->bo->parse($contents);
95
96                        if($print_events)
97                        {
98                                $this->print_test($vcalendar['prodid'],'Product ID');
99                                $this->print_test($vcalendar['method'],'Method');
100                                $this->print_test($vcalendar['version'],'Version');
101
102                                for($i=0;$i<count($vcalendar['event']);$i++)
103                                {
104                                        $event = $vcalendar['event'][$i];
105
106                                        echo "<br>\nEVENT<br>\n";
107//                                      echo 'TEST Debug : '._debug_array($event,False)."<br>\n";
108                                        $this->print_test($event['uid'],'UID','X-');
109                                        $this->print_test($event['valscale'],'Calscale','X-');
110                                        $this->print_test($event['description'],'Description','X-');
111                                        $this->print_test($event['summary'],'Summary','X-');
112                                        $this->print_test($event['comment'],'Comment','X-');
113                                        $this->print_test($event['location'],'Location','X-');
114                                        $this->print_test($event['sequence'],'Sequence','X-');
115                                        $this->print_test($event['priority'],'Priority','X-');
116                                        $this->print_test($event['categories'],'Categories','X-');
117                                        $this->print_test($event['dtstart'],'Date Start','X-');
118                                        $this->print_test($event['dtstamp'],'Date Stamp','X-');
119                                        $this->print_test($event['rrule'],'Recurrence','X-');
120
121                                        echo "Class = ".$this->bo->switch_class($event['class'])."<br>\n";
122
123                                        $this->print_test($event['organizer'],'Organizer','X-');
124                                        $this->print_test($event['attendee'],'Attendee','X-');
125                                        $this->print_test($event['x_type'],'X-Type','X-');
126                                        $this->print_test($event['alarm'],'Alarm','X-');
127                                }
128                        }
129
130/*
131                        for($i=0;$i<count($vcalendar->todo);$i++)
132                        {
133                                echo "<br>\nTODO<br>\n";
134                                if($vcalendar['todo'][$i]['summary']['value'])
135                                {
136                                        echo "Summary = ".$vcalendar['todo'][$i]['summary']['value']."<br>\n";
137                                }
138                                if($vcalendar['todo'][$i]['description']['value'])
139                                {
140                                        echo "Description (Value) = ".$vcalendar['todo'][$i]['description']['value']."<br>\n";
141                                }
142                                if($vcalendar['todo'][$i]['description']['altrep'])
143                                {
144                                        echo "Description (Alt Rep) = ".$vcalendar['todo'][$i]['description']['altrep']."<br>\n";
145                                }
146                                if($vcalendar['todo'][$i]['location']['value'])
147                                {
148                                        echo "Location = ".$vcalendar['todo'][$i]['location']['value']."<br>\n";
149                                }
150                                echo "Sequence = ".$vcalendar['todo'][$i]['sequence']."<br>\n";
151                                echo "Date Start : ".$GLOBALS['phpgw']->common->show_date(mktime($vcalendar['todo'][$i]['dtstart']['hour'],$vcalendar['todo'][$i]['dtstart']['min'],$vcalendar['todo'][$i]['dtstart']['sec'],$vcalendar['todo'][$i]['dtstart']['month'],$vcalendar['todo'][$i]['dtstart']['mday'],$vcalendar['todo'][$i]['dtstart']['year']) - $this->datatime->tz_offset)."<br>\n";
152                                echo "Class = ".$vcalendar['todo'][$i]['class']['value']."<br>\n";
153                        }
154
155*/
156                        include(PHPGW_APP_INC.'/../setup/setup.inc.php');
157
158                        $this->bo->set_var($vcalendar['prodid'],'value','-//phpGroupWare//phpGroupWare '.$setup_info['calendar']['version'].' MIMEDIR//'.strtoupper($GLOBALS['phpgw_info']['user']['preferences']['common']['lang']));
159                        $this->bo->set_var($vcalendar['version'],'value','2.0');
160                        $this->bo->set_var($vcalendar['method'],'value',strtoupper('publish'));
161                        echo "<br><br><br>\n";
162                        echo nl2br($this->bo->build_ical($vcalendar));
163                        echo "End Time : ".$GLOBALS['phpgw']->common->show_date()."<br>\n";
164                }
165
166                function import()
167                {
168                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
169                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
170                        $GLOBALS['phpgw_info']['flags']['nonappheader'] = True;
171                        $GLOBALS['phpgw_info']['flags']['nonappfooter'] = True;
172                        $GLOBALS['phpgw']->common->phpgw_header();
173
174                        if(!@is_dir($GLOBALS['phpgw_info']['server']['temp_dir']))
175                        {
176                                mkdir($GLOBALS['phpgw_info']['server']['temp_dir'],0700);
177                        }
178
179                        echo '<body bgcolor="' . $GLOBALS['phpgw_info']['theme']['bg_color'] . '">';
180
181                        if ($GLOBALS['HTTP_GET_VARS']['action'] == 'GetFile')
182                        {
183                                echo '<b><center>' . lang('You must select a [iv]Cal. (*.[iv]cs)') . '</b></center><br><br>';
184                        }
185
186                        $this->template->set_file(
187                                Array(
188                                        'vcalimport' => 'vcal_import.tpl'
189                                )
190                        );
191
192                        $var = Array(
193                                'vcal_header'   => '<p>',
194                                'ical_lang'             => lang('(i/v)Cal'),
195                                'action_url'    => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.boicalendar.import'),
196                                'lang_access'   => lang('Access'),
197                                'lang_groups'   => lang('Which groups'),
198                                'access_option'=> $access_option,
199                                'group_option'  => $group_option,
200                                'load_vcal'     => lang('Load [iv]Cal')
201                        );
202                        $this->template->set_var($var);
203                        $this->template->pparse('out','vcalimport');
204                }
205        }
206?>
Note: See TracBrowser for help on using the repository browser.