Author: josx Date: 2007-07-11 17:31:34 -0300 (Wed, 11 Jul 2007) New Revision: 4811 Added: prosistem/alba/trunk/alba/apps/principal/modules/icalVisualizador/i18n/ prosistem/alba/trunk/alba/apps/principal/modules/icalVisualizador/i18n/messages.es.xml prosistem/alba/trunk/alba/apps/principal/modules/relDivisionActividadDocente/templates/verCalendarioSuccess.php Removed: prosistem/alba/trunk/alba/apps/principal/modules/relDivisionActividadDocente/templates/verCalendarioPorDiaSuccess.php Modified: prosistem/alba/trunk/alba/apps/principal/modules/cuenta/actions/actions.class.php prosistem/alba/trunk/alba/apps/principal/modules/icalVisualizador/actions/components.class.php prosistem/alba/trunk/alba/apps/principal/modules/icalVisualizador/lib/ical_parser.php prosistem/alba/trunk/alba/apps/principal/modules/icalVisualizador/templates/_verPorDia.php prosistem/alba/trunk/alba/apps/principal/modules/icalVisualizador/templates/_verPorSemana.php prosistem/alba/trunk/alba/apps/principal/modules/relDivisionActividadDocente/actions/actions.class.php prosistem/alba/trunk/alba/apps/principal/modules/relDivisionActividadDocente/templates/_list_actions.php Log: Agregue soporte para los eventos recurrentes Modified: prosistem/alba/trunk/alba/apps/principal/modules/cuenta/actions/actions.class.php =================================================================== --- prosistem/alba/trunk/alba/apps/principal/modules/cuenta/actions/actions.class.php 2007-07-03 19:50:49 UTC (rev 4810) +++ prosistem/alba/trunk/alba/apps/principal/modules/cuenta/actions/actions.class.php 2007-07-11 20:31:34 UTC (rev 4811) @@ -53,7 +53,6 @@ $c = new Criteria(); $c->add(ResponsablePeer::FK_CUENTA_ID, $this->getRequestParameter('id')); $this->aResponsable = ResponsablePeer::doSelect($c); - } protected function addSortCriteria ($c) { Modified: prosistem/alba/trunk/alba/apps/principal/modules/icalVisualizador/actions/components.class.php =================================================================== --- prosistem/alba/trunk/alba/apps/principal/modules/icalVisualizador/actions/components.class.php 2007-07-03 19:50:49 UTC (rev 4810) +++ prosistem/alba/trunk/alba/apps/principal/modules/icalVisualizador/actions/components.class.php 2007-07-11 20:31:34 UTC (rev 4811) @@ -19,9 +19,11 @@ public function executeVerPorDia() { $aAllDay = array(); $minutes = 60; + $date = $this->getDate(); + $this->aWeek = $this->getWeekRange($date); require(sfConfig::get('sf_app_module_dir')."/icalVisualizador/".sfConfig::get('sf_app_module_lib_dir_name')."/ical_parser.php"); - $aEvent = @icalToArray($this->archivo); + $aEvent = @icalToArray($this->archivo, date("Ymd",$this->aWeek[0]['day']), date("Ymd",$this->aWeek[6]['day']) ); $nbrGridCols = 1; foreach($aEvent as $day) { @@ -32,8 +34,7 @@ } } - $date = $this->getDate(); - $this->aWeek = $this->getWeekRange($date); + $this->aTime = $this->getTimeRange(); $this->nbrGridCols = $nbrGridCols; $this->aEvent = $aEvent; @@ -46,12 +47,13 @@ public function executeVerPorSemana() { + $date = $this->getDate(); + $aWeek = $this->getWeekRange($date); + require(sfConfig::get('sf_app_module_dir')."/icalVisualizador/".sfConfig::get('sf_app_module_lib_dir_name')."/ical_parser.php"); - $aEvent = @icalToArray($this->archivo); + $aEvent = @icalToArray($this->archivo, date("Ymd",$aWeek[0]['day']), date("Ymd",$aWeek[6]['day']) ); - $date = $this->getDate(); $this->aEvent = $aEvent; - $aWeek = $this->getWeekRange($date); $this->aTime = $this->getTimeRange(); $this->l_calendar = ""; $this->calendar_name = ""; @@ -70,15 +72,12 @@ } } } + $this->nbrGridCols = $nbrGridCols; $this->aWeek = $aWeek; } - - - - private function getTimeRange() { $aTime = array(); $time_start = "7:00"; Added: prosistem/alba/trunk/alba/apps/principal/modules/icalVisualizador/i18n/messages.es.xml =================================================================== --- prosistem/alba/trunk/alba/apps/principal/modules/icalVisualizador/i18n/messages.es.xml 2007-07-03 19:50:49 UTC (rev 4810) +++ prosistem/alba/trunk/alba/apps/principal/modules/icalVisualizador/i18n/messages.es.xml 2007-07-11 20:31:34 UTC (rev 4811) @@ -0,0 +1,63 @@ +<?xml version="1.0" ?> +<xliff version="1.0"> + <file orginal="global" source-language="en_US" datatype="plaintext"> + <body> + <trans-unit id="1"> + <source>monday</source> + <target>lunes</target> + </trans-unit> + <trans-unit id="2"> + <source>tuesday</source> + <target>martes</target> + </trans-unit> + <trans-unit id="3"> + <source>wednesday</source> + <target>miércoles</target> + </trans-unit> + <trans-unit id="4"> + <source>thursday</source> + <target>jueves</target> + </trans-unit> + <trans-unit id="5"> + <source>friday</source> + <target>viernes</target> + </trans-unit> + <trans-unit id="6"> + <source>saturday</source> + <target>sabado</target> + </trans-unit> + <trans-unit id="7"> + <source>sunday</source> + <target>domingo</target> + </trans-unit> + <trans-unit id="8"> + <source>Mon</source> + <target>lun</target> + </trans-unit> + <trans-unit id="9"> + <source>tue</source> + <target>mar</target> + </trans-unit> + <trans-unit id="10"> + <source>Wed</source> + <target>mié</target> + </trans-unit> + <trans-unit id="11"> + <source>thu</source> + <target>jue</target> + </trans-unit> + <trans-unit id="12"> + <source>fri</source> + <target>vie</target> + </trans-unit> + <trans-unit id="13"> + <source>sat</source> + <target>sab</target> + </trans-unit> + <trans-unit id="14"> + <source>sun</source> + <target>dom</target> + </trans-unit> + </body> + </file> +</xliff> \ No newline at end of file Modified: prosistem/alba/trunk/alba/apps/principal/modules/icalVisualizador/lib/ical_parser.php =================================================================== --- prosistem/alba/trunk/alba/apps/principal/modules/icalVisualizador/lib/ical_parser.php 2007-07-03 19:50:49 UTC (rev 4810) +++ prosistem/alba/trunk/alba/apps/principal/modules/icalVisualizador/lib/ical_parser.php 2007-07-11 20:31:34 UTC (rev 4811) @@ -1,13 +1,103 @@ -<? +<?php +// ______________________________________ +// | PHP iCalendar | +// | http://www.phpicalendar.net/ | +// |______________________________________| +// +//Introduction: +//------------- +//PHP iCalendar is a PHP-based iCal file viewer/parser to display iCals in a Web browser. +//Its based on v2.0 of the IETF spec. It displays iCal files in a nice logical, +//clean manner with day, week, month, and year navigation. It is available in 13 +//languages and includes support for printing, searching and RSS news feeds. +//If you need a Calendar application (for creating calendar files), please check +//the 'Supported Calendar Applications' section of the README. +// +//This is GPL code extrated from PHP iCalendar +// +//TZIDs in calendars often contain leading information that should be stripped +//Example: TZID=/mozilla.org/20050126_1/Europe/Berlin +//Need to return the last part only +function parse_tz($data){ + $fields = explode("/",$data); + $tz = array_pop($fields); + $tmp = array_pop($fields); + if (isset($tmp) && $tmp != "") $tz = "$tmp/$tz"; + return $tz; +} +// function to compare to dates in Ymd and return the number of days +// that differ between them. +function dayCompare($now, $then) { + $seconds_now = strtotime($now); + $seconds_then = strtotime($then); + $diff_seconds = $seconds_now - $seconds_then; + $diff_minutes = $diff_seconds/60; + $diff_hours = $diff_minutes/60; + $diff_days = round($diff_hours/24); + + return $diff_days; +} + + +// function to compare to dates in Ymd and return the number of weeks +// that differ between them. requires dateOfWeek() +function weekCompare($now, $then) { + $sun_now = dateOfWeek($now, "Sunday"); + $sun_then = dateOfWeek($then, "Sunday"); + $seconds_now = strtotime($sun_now); + $seconds_then = strtotime($sun_then); + $diff_weeks = round(($seconds_now - $seconds_then)/(60*60*24*7)); + return $diff_weeks; +} + + + + +// dateOfWeek() takes a date in Ymd and a day of week in 3 letters or more +// and returns the date of that day. (ie: "sun" or "sunday" would be acceptable values of $day but not "su") +function dateOfWeek($Ymd, $day, $week_start_day = 'Sunday') { +// global $week_start_day; + if (!isset($week_start_day)) $week_start_day = 'Sunday'; + $timestamp = strtotime($Ymd); + $num = date('w', strtotime($week_start_day)); + $start_day_time = strtotime((date('w',$timestamp)==$num ? "$week_start_day" : "last $week_start_day"), $timestamp); + $ret_unixtime = strtotime($day,$start_day_time); + // Fix for 992744 + // $ret_unixtime = strtotime('+12 hours', $ret_unixtime); + $ret_unixtime += (12 * 60 * 60); + $ret = date('Ymd',$ret_unixtime); + return $ret; +} + + + +// takes iCalendar 2 day format and makes it into 3 characters +// if $txt is true, it returns the 3 letters, otherwise it returns the +// integer of that day; 0=Sun, 1=Mon, etc. +function two2threeCharDays($day, $txt=true) { + switch($day) { + case 'SU': return ($txt ? 'sun' : '0'); + case 'MO': return ($txt ? 'mon' : '1'); + case 'TU': return ($txt ? 'tue' : '2'); + case 'WE': return ($txt ? 'wed' : '3'); + case 'TH': return ($txt ? 'thu' : '4'); + case 'FR': return ($txt ? 'fri' : '5'); + case 'SA': return ($txt ? 'sat' : '6'); + } +} + // localizeDate() - similar to strftime but uses our preset arrays of localized // months and week days and only supports %A, %a, %B, %b, %e, and %Y // more can be added as needed but trying to keep it small while we can function localizeDate($format, $timestamp) { + global $daysofweek_lang, $daysofweekshort_lang, $daysofweekreallyshort_lang, $monthsofyear_lang, $monthsofyear_lang, $monthsofyearshort_lang; + + $year = date("Y", $timestamp); $month = date("n", $timestamp)-1; $day = date("j", $timestamp); @@ -27,7 +117,7 @@ // Remove an event from the overlap data. // This could be completely bogus, since overlap array is empty when this gets called in my tests, but I'm leaving it in anyways. -function removeOverlap($ol_start_date, $ol_start_time, &$ol_key,$master_array, &$overlap_array) { +function removeOverlap($ol_start_date, $ol_start_time, $ol_key, &$master_array, &$overlap_array) { // global $master_array, $overlap_array; if (isset($overlap_array[$ol_start_date])) { if (sizeof($overlap_array[$ol_start_date]) > 0) { @@ -338,6 +428,18 @@ } +// calcOffset takes an offset (ie, -0500) and returns it in the number of seconds +function calcOffset($offset_str) { + $sign = substr($offset_str, 0, 1); + $hours = substr($offset_str, 1, 2); + $mins = substr($offset_str, 3, 2); + $secs = ((int)$hours * 3600) + ((int)$mins * 60); + if ($sign == '-') $secs = 0 - $secs; + return $secs; +} + + + function chooseOffset($time, &$timezone, &$tz_array) { // global $timezone, $tz_array; if (!isset($timezone)) $timezone = ''; @@ -447,20 +549,30 @@ -function icalToArray($filename) { +function icalToArray($filename, $fromdate, $todate) { // $filename = "/var/www/phpicalendar/calendars/pepe.ics"; + +$timezone = "America/Buenos_Aires"; +$tz_array['America/Buenos_Aires'] = array('-0300', '-0300'); + $master_array = array(); $ifile = @fopen($filename, "r"); if ($ifile == FALSE) exit("Cant Open file: ". $filename."\n"); $nextline = fgets($ifile, 1024); if (trim($nextline) != 'BEGIN:VCALENDAR') exit("It is not a valid ical file: ". $filename."\n"); +// $master_array['-4'] = Array ( Array ( 'mtime' => 1182541233, 'filename' => './calendars/pepe.ics','webcal' => 'no')); + +// $master_array['-3'] = Array ( 'pepe'); + // Set a value so we can check to make sure $master_array contains valid data -// $master_array['-1'] = 'valid cal file'; + $master_array['-1'] = 'valid cal file'; // Set default calendar name - can be overridden by X-WR-CALNAME $calendar_name = $cal_filename; -// $master_array['calendar_name'] = $calendar_name; + $master_array['calendar_name'] = $calendar_name; + +$overlap_array = array(); // read file in line by line // XXX end line is skipped because of the 1-line readahead @@ -759,18 +871,19 @@ $start_date_time = strtotime($start_date); if (!isset($fromdate)){ #this should happen if not in one of the rss views - $this_month_start_time = strtotime($this_year.$this_month.'01'); +/* $this_month_start_time = strtotime($this_year.$this_month.'01'); if ($current_view == 'year' || ($save_parsed_cals == 'yes' && !$is_webcal)|| $current_view == 'print' && $printview == 'year') { $start_range_time = strtotime($this_year.'-01-01 -2 weeks'); $end_range_time = strtotime($this_year.'-12-31 +2 weeks'); } else { $start_range_time = strtotime('-1 month -2 day', $this_month_start_time); $end_range_time = strtotime('+2 month +2 day', $this_month_start_time); - } + }*/ }else{ - $start_range_time = strtotime($fromdate); - $end_range_time = strtotime($todate)+60*60*24; + $start_range_time = strtotime($fromdate); + $end_range_time = strtotime($todate)+60*60*24; } + foreach ($rrule_array as $key => $val) { switch($key) { case 'FREQ': @@ -864,13 +977,15 @@ } if (!isset($number)) $number = 1; - // if $until isn't set yet, we set it to the end of our range we're looking at + // if $until isn't set yet, we set it to the end of our range we're looking at if (!isset($until)) $until = $end_range_time; if (!isset($abs_until)) $abs_until = date('YmdHis', $end_range_time); $end_date_time = $until; $start_range_time_tmp = $start_range_time; $end_range_time_tmp = $end_range_time; +// echo date("Ymd",$until)." ".date("Ymd",$end_range_time)."<br>"; +// echo date("Ymd",$end_range_time_tmp)." >= ".date("Ymd",$start_date_time)." && ".date("Ymd",$start_range_time_tmp)." <= ".date("Ymd",$end_date_time)."<br>"; // If the $end_range_time is less than the $start_date_time, or $start_range_time is greater // than $end_date_time, we may as well forget the whole thing @@ -1379,7 +1494,8 @@ $data = str_replace("\\r", "<br />", $data); $data = str_replace('$', '$', $data); $data = stripslashes($data); - $data = htmlentities(urlencode($data)); +// $data = htmlentities(urlencode($data)); + $data = htmlentities($data); if ($valarm_set == FALSE) { $summary = $data; } else { @@ -1501,6 +1617,14 @@ } } } + + unset($master_array['calendar_name']); + unset($master_array['-1']); + unset($master_array['-3']); + unset($master_array['-4']); + +// print_R($master_array); +// print_R($overlap_array); return $master_array; } Modified: prosistem/alba/trunk/alba/apps/principal/modules/icalVisualizador/templates/_verPorDia.php =================================================================== --- prosistem/alba/trunk/alba/apps/principal/modules/icalVisualizador/templates/_verPorDia.php 2007-07-03 19:50:49 UTC (rev 4810) +++ prosistem/alba/trunk/alba/apps/principal/modules/icalVisualizador/templates/_verPorDia.php 2007-07-11 20:31:34 UTC (rev 4811) @@ -1,4 +1,4 @@ - +<?php use_helper('I18N') ?> <link rel="stylesheet" type="text/css" href="<?php echo sfContext::getInstance()->getRequest()->getRelativeUrlRoot()?>/icalVisualizador/css/icalVisualizador.css"/> <center> Modified: prosistem/alba/trunk/alba/apps/principal/modules/icalVisualizador/templates/_verPorSemana.php =================================================================== --- prosistem/alba/trunk/alba/apps/principal/modules/icalVisualizador/templates/_verPorSemana.php 2007-07-03 19:50:49 UTC (rev 4810) +++ prosistem/alba/trunk/alba/apps/principal/modules/icalVisualizador/templates/_verPorSemana.php 2007-07-11 20:31:34 UTC (rev 4811) @@ -1,3 +1,4 @@ +<?php use_helper('I18N') ?> <link rel="stylesheet" type="text/css" href="<?php echo sfContext::getInstance()->getRequest()->getRelativeUrlRoot()?>/icalVisualizador/css/icalVisualizador.css"/> <center> Modified: prosistem/alba/trunk/alba/apps/principal/modules/relDivisionActividadDocente/actions/actions.class.php =================================================================== --- prosistem/alba/trunk/alba/apps/principal/modules/relDivisionActividadDocente/actions/actions.class.php 2007-07-03 19:50:49 UTC (rev 4810) +++ prosistem/alba/trunk/alba/apps/principal/modules/relDivisionActividadDocente/actions/actions.class.php 2007-07-11 20:31:34 UTC (rev 4811) @@ -94,12 +94,11 @@ } - public function executeVerCalendarioPorDia() { + public function executeVerCalendario() { $this->executeList(); include("miExportadorIcal.class.php"); $e = new miExportadorIcal(); $this->archivo = sfConfig::get('app_alba_tmpdir')."/".$e->exportar($this->pager->getResults(), 0); - if($this->getRequestParameter('date')) { $this->date_component = $this->getRequestParameter('date'); } else { @@ -115,8 +114,6 @@ } else { $this->view = "verPorDia"; } - - } Modified: prosistem/alba/trunk/alba/apps/principal/modules/relDivisionActividadDocente/templates/_list_actions.php =================================================================== --- prosistem/alba/trunk/alba/apps/principal/modules/relDivisionActividadDocente/templates/_list_actions.php 2007-07-03 19:50:49 UTC (rev 4810) +++ prosistem/alba/trunk/alba/apps/principal/modules/relDivisionActividadDocente/templates/_list_actions.php 2007-07-11 20:31:34 UTC (rev 4811) @@ -11,7 +11,7 @@ 'class' => '', )) ?></li> -<li><?php echo button_to(__('ver calendario'), 'relDivisionActividadDocente/verCalendarioPorDia', array ( +<li><?php echo button_to(__('ver calendario'), 'relDivisionActividadDocente/verCalendario', array ( 'class' => '', )) ?></li> Deleted: prosistem/alba/trunk/alba/apps/principal/modules/relDivisionActividadDocente/templates/verCalendarioPorDiaSuccess.php =================================================================== --- prosistem/alba/trunk/alba/apps/principal/modules/relDivisionActividadDocente/templates/verCalendarioPorDiaSuccess.php 2007-07-03 19:50:49 UTC (rev 4810) +++ prosistem/alba/trunk/alba/apps/principal/modules/relDivisionActividadDocente/templates/verCalendarioPorDiaSuccess.php 2007-07-11 20:31:34 UTC (rev 4811) @@ -1,3 +0,0 @@ -<?php - include_component('icalVisualizador', $view, array('archivo' => $archivo, 'date_component' => $date_component)); -?> \ No newline at end of file Added: prosistem/alba/trunk/alba/apps/principal/modules/relDivisionActividadDocente/templates/verCalendarioSuccess.php =================================================================== --- prosistem/alba/trunk/alba/apps/principal/modules/relDivisionActividadDocente/templates/verCalendarioSuccess.php 2007-07-03 19:50:49 UTC (rev 4810) +++ prosistem/alba/trunk/alba/apps/principal/modules/relDivisionActividadDocente/templates/verCalendarioSuccess.php 2007-07-11 20:31:34 UTC (rev 4811) @@ -0,0 +1,3 @@ +<?php + include_component('icalVisualizador', $view, array('archivo' => $archivo, 'date_component' => $date_component)); +?> \ No newline at end of file Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/relDivisionActividadDocente/templates/verCalendarioSuccess.php ___________________________________________________________________ Name: svn:keywords + "Id Author URL Date Rev"