Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/01/2012, 11:08
ugluck
 
Fecha de Ingreso: enero-2012
Mensajes: 21
Antigüedad: 12 años, 3 meses
Puntos: 0
cambiar dias de la semana a español

Buenas, soy desarrollador de paginas web, pero tengo pocos conocimientos (entiéndase por pocos.. 0 ) de php. Tengo un cliente que necesitaba un calendario de eventos en su web y conseguí un estupendo calendario.. en ingles.
Así que no consigo traducirlo de ningún modo, espero que algún crack pueda echarme una mano, siempre podemos hablar de la recompensa.

Codigo:

<?php

include('admin/dbconn.php');
include('functions/functions.php');

$first_day_of_week = 'Monday'; // or 'Sunday'

$type = CAL_GREGORIAN;

if(isset($_GET['month'])) $month = trim(stripslashes(strip_tags($_GET['month'])));
if(isset($_GET['year'])) $year = trim(stripslashes(strip_tags($_GET['year'])));

if(!isset($_GET['month']) || !is_numeric($_GET['month'])) $month = date('n'); // Month ID, 1 through to 12.
if(!isset($_GET['year']) || !is_numeric($_GET['year'])) $year = date('Y'); // Year in 4 digit 2009 format.

$today = date('Y/n/d');

$day_count = cal_days_in_month($type, $month, $year); // Get the amount of days in the chosen month to give to our function.

echo "<div id='calendar'>";
echo "<div id='calendar_wrap'>";

// Function for year change. //

$last_month = $month - 1;
$next_month = $month + 1;

$last_year = $year - 1;
$next_year = $year + 1;

if($month == 12):
$change_year = $year;
$change_month = $last_month;
elseif($month == 1):
$change_year = $last_year;
$change_month = '12';
else:
$change_year = $year;
$change_month = $last_month;
endif;

if($month == 1):
$change_year_next = $year;
$change_month_next = $next_month;
elseif($month == 12):
$change_year_next = $next_year;
$change_month_next = '1';
else:
$change_year_next = $year;
$change_month_next = $next_month;
endif;

echo "<div class='title_bar'>";

echo "<a href='".$_SERVER['PHP_SELF']."?month=". $change_month ."&year=". $change_year ."'><div class='previous'></div></a>";
echo "<a href='".$_SERVER['PHP_SELF']."?month=". $change_month_next ."&year=". $change_year_next ."'><div class='next'></div></a>";
echo "<h2 class='month'>" . date('F', mktime(0,0,0,$month,1)) . "&nbsp;" . $year . "</h2>";


echo "</div>";

/* Previous Month */

$first_day = date('N', mktime(0,0,0,$month,1,$year));

if ( ($first_day_of_week=='Monday' && $first_day != 1) || ($first_day_of_week=='Sunday' && $first_day != 7) ) :

$last_month_day_count = cal_days_in_month($type, $change_month, $change_year);

if ($first_day_of_week=='Monday') :
if ( 'Monday' == date('l', mktime(0,0,0,$change_month,$last_month_day_count,$ change_year)) ) :
$final_day = date('j', mktime(0,0,0,$change_month,$last_month_day_count,$ change_year));
else :
$final_day = date('j', strtotime('last Monday', mktime(0,0,0,$change_month,$last_month_day_count,$ change_year) ) );
endif;
else :
if ( 'Sunday' == date('l', mktime(0,0,0,$change_month,$last_month_day_count,$ change_year)) ) :
$final_day = date('j', mktime(0,0,0,$change_month,$last_month_day_count,$ change_year));
else :
$final_day = date('j', strtotime('last Sunday', mktime(0,0,0,$change_month,$last_month_day_count,$ change_year) ) );
endif;
endif;

// Not a monday so fill the gap
for($i=$final_day; $i<=$last_month_day_count; $i++):

$date = $change_year.'/'.$change_month.'/'.$i;

$get_name = date('l', strtotime($date));
$month_name = date('F', strtotime($date));
$day_name = substr($get_name, 0, 3); // Trim day name to 3 chars

$count = count_events($i,$change_month,$change_year);
if($count >= 1)
echo "<a href='day_view.php?day=$i&month=$change_month&year =$change_year' title='$i $month_name' rel='day_view'>";
echo "<div class='cal_day last_month'>"; // Calendar Day

echo "<div class='day_heading'>" . $day_name . "</div>";

if($count >= 1) echo "<div class='day_count'><span class='event'>" . $count . "</span></div>";

if($today == $date):
echo "<div class='day_number today'>" . $i . "</div>";
else:
echo "<div class='day_number'>" . $i . "</div>";
endif;

echo "</div>";
echo "</a>";

endfor;

endif;

/* Current Month */

for($i=1; $i<= $day_count; $i++): // Start of for $i

$date = $year.'/'.$month.'/'.$i;

$get_name = date('l', strtotime($date));
$month_name = date('F', strtotime($date));
$day_name = substr($get_name, 0, 3); // Trim day name to 3 chars

$count = count_events($i,$month,$year);
if($count >= 1)
echo "<a href='day_view.php?day=$i&month=$month&year=$year' title='$i $month_name' rel='day_view'>";
echo "<div class='cal_day'>"; // Calendar Day

echo "<div class='day_heading'>" . $day_name . "</div>";

if($count >= 1) echo "<div class='day_count'><span class='event'>" . $count . "</span></div>";

if($today == $date):
echo "<div class='day_number today'>" . $i . "</div>";
else:
echo "<div class='day_number'>" . $i . "</div>";
endif;

echo "</div>";
echo "</a>";

endfor; // EOF for $i

/* Next Month */

$last_day = date('N', mktime(0,0,0,$month,$day_count,$year));

if ( ($first_day_of_week=='Monday' && $last_day != 7) || ($first_day_of_week=='Sunday' && $last_day != 1) ) :

if ($first_day_of_week=='Monday') :
if ( 'Sunday' == date('l', mktime(0,0,0,$change_month_next,1,$change_year_nex t)) ) :
$first_day = date('j', mktime(0,0,0,$change_month_next,1,$change_year_nex t));
else :
$first_day = date('j', strtotime('first Sunday', mktime(0,0,0,$change_month_next,1,$change_year_nex t) ) );
endif;
else :
if ( 'Saturday' == date('l', mktime(0,0,0,$change_month_next,1,$change_year_nex t)) ) :
$first_day = date('j', mktime(0,0,0,$change_month_next,1,$change_year_nex t));
else :
$first_day = date('j', strtotime('first Saturday', mktime(0,0,0,$change_month_next,1,$change_year_nex t) ) );
endif;
endif;


// Not a monday so fill the gap
for($i=1; $i<=$first_day; $i++):

$date = $change_year_next.'/'.$change_month_next.'/'.$i;

$get_name = date('l', strtotime($date));
$month_name = date('F', strtotime($date));
$day_name = substr($get_name, 0, 3); // Trim day name to 3 chars

$count = count_events($i,$change_month_next,$change_year_ne xt);
if($count >= 1)
echo "<a href='day_view.php?date=$i&month=$change_month_nex t&year=$change_year_next' title='$i $month_name' rel='day_view'>";
echo "<div class='cal_day next_month'>"; // Calendar Day

echo "<div class='day_heading'>" . $day_name . "</div>";

if($count >= 1) echo "<div class='day_count'><span class='event'>" . $count . "</span></div>";

if($today == $date):
echo "<div class='day_number today'>" . $i . "</div>";
else:
echo "<div class='day_number'>" . $i . "</div>";
endif;

echo "</div>";
echo "</a>";

endfor;

endif;

echo "</div>";
?>