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

Te passo el codigo base( que funciona):

Código PHP:
Ver original
  1. <?php
  2.  
  3.                 include('admin/dbconn.php');
  4.                 include('functions/functions.php');
  5.  
  6.  
  7.                 $type = CAL_GREGORIAN;
  8.  
  9.                 if(isset($_GET['month'])) $month = trim(stripslashes(strip_tags($_GET['month'])));
  10.                 if(isset($_GET['year'])) $year = trim(stripslashes(strip_tags($_GET['year'])));
  11.  
  12.                 if(!isset($_GET['month']) || !is_numeric($_GET['month'])) $month = date('n'); // Month ID, 1 through to 12.
  13.                 if(!isset($_GET['year']) || !is_numeric($_GET['year'])) $year = date('Y'); // Year in 4 digit 2009 format.
  14.  
  15.                 $today = date('Y/n/d');
  16.  
  17.                 $day_count = cal_days_in_month($type, $month, $year); // Get the amount of days in the chosen month to give to our function.
  18.  
  19.                 echo "<div id='calendar'>";
  20.                 echo "<div id='calendar_wrap'>";
  21.                
  22.                 // Function for year change. //
  23.  
  24.                 $last_month = $month - 1;
  25.                 $next_month = $month + 1;
  26.  
  27.                 $last_year = $year - 1;
  28.                 $next_year = $year + 1;
  29.  
  30.                 if($month == 12):
  31.                     $change_year = $year;
  32.                     $change_month  = $last_month;
  33.                 elseif($month == 1):
  34.                     $change_year = $last_year;
  35.                     $change_month  = '12';
  36.                 else:
  37.                     $change_year = $year;
  38.                     $change_month  = $last_month;
  39.                 endif;
  40.  
  41.                 if($month == 1):
  42.                     $change_year_next = $year;
  43.                     $change_month_next  = $next_month;
  44.                 elseif($month == 12):
  45.                     $change_year_next = $next_year;
  46.                     $change_month_next  = '1';
  47.                 else:
  48.                     $change_year_next = $year;
  49.                     $change_month_next  = $next_month;
  50.                 endif;
  51.  
  52.                 echo "<div class='title_bar'>";
  53.  
  54.                 echo "<a href='".$_SERVER['PHP_SELF']."?month=". $change_month ."&year=". $change_year ."'><div class='previous'></div></a>";
  55.                 echo "<a href='".$_SERVER['PHP_SELF']."?month=". $change_month_next ."&year=". $change_year_next ."'><div class='next'></div></a>";
  56.                 echo "<h2 class='month'>" . date('F',  mktime(0,0,0,$month,1)) . "&nbsp;" . $year . "</h2>";
  57.  
  58.  
  59.                 echo "</div>";
  60.  
  61.                 /* Previous Month */
  62.  
  63.                 $first_day = date('N', mktime(0,0,0,$month,1,$year));
  64.  
  65.                 if ( ($first_day_of_week=='Monday' && $first_day != 1) || ($first_day_of_week=='Sunday' && $first_day != 7) ) :
  66.  
  67.                     $last_month_day_count = cal_days_in_month($type, $change_month, $change_year);
  68.  
  69.                     if ($first_day_of_week=='Monday') :
  70.                         if ( 'Monday' == date('l', mktime(0,0,0,$change_month,$last_month_day_count,$change_year)) ) :
  71.             $final_day = date('j', mktime(0,0,0,$change_month,$last_month_day_count,$change_year));
  72.                         else :
  73.             $final_day = date('j', strtotime('last Monday', mktime(0,0,0,$change_month,$last_month_day_count,$change_year) ) );
  74.                         endif;
  75.                     else :
  76.                         if ( 'Sunday' == date('l', mktime(0,0,0,$change_month,$last_month_day_count,$change_year)) ) :
  77.                             $final_day = date('j', mktime(0,0,0,$change_month,$last_month_day_count,$change_year));
  78.                         else :
  79.                             $final_day = date('j', strtotime('last Sunday', mktime(0,0,0,$change_month,$last_month_day_count,$change_year) ) );
  80.                         endif;
  81.                     endif;
  82.  
  83.                     // Not a monday so fill the gap
  84.                     for($i=$final_day; $i<=$last_month_day_count; $i++):
  85.  
  86.                         $date = $change_year.'/'.$change_month.'/'.$i;
  87.  
  88.         $get_name = date('l', strtotime($date));
  89.         $month_name = date('F', strtotime($date));
  90.         $day_name = substr($get_name, 0, 3); // Trim day name to 3 chars
  91.  
  92.         $count = count_events($i,$change_month,$change_year);
  93.         if($count >= 1)
  94.         echo "<a href='day_view.php?day=$i&month=$change_month&year=$change_year' title='$i $month_name' rel='day_view'>";
  95.         echo "<div class='cal_day last_month'>"; // Calendar Day
  96.  
  97.             echo "<div class='day_heading'>" . $day_name . "</div>";
  98.  
  99.             if($count >= 1) echo "<div class='day_count'><span class='event'>" . $count . "</span></div>";
  100.  
  101.             if($today == $date):
  102.                 echo "<div class='day_number today'>" . $i . "</div>";
  103.             else:
  104.                 echo "<div class='day_number'>" . $i . "</div>";
  105.             endif;
  106.  
  107.         echo "</div>";
  108.         echo "</a>";
  109.  
  110.     endfor;
  111.  
  112. endif;
  113.  
  114. /* Current Month */
  115.  
  116. for($i=1; $i<= $day_count; $i++): // Start of for $i
  117.  
  118.     $date = $year.'/'.$month.'/'.$i;
  119.  
  120.     $get_name = date('l', strtotime($date));
  121.     $month_name = date('F', strtotime($date));
  122.     $day_name = substr($get_name, 0, 3); // Trim day name to 3 chars
  123.  
  124.     $count = count_events($i,$month,$year);
  125.     if($count >= 1)
  126.     echo "<a href='day_view.php?day=$i&month=$month&year=$year' title='$i $month_name' rel='day_view'>";
  127.     echo "<div class='cal_day'>"; // Calendar Day
  128.  
  129.         echo "<div class='day_heading'>" . $day_name . "</div>";
  130.  
  131.         if($count >= 1) echo "<div class='day_count'><span class='event'>" . $count . "</span></div>";
  132.  
  133.         if($today == $date):
  134.             echo "<div class='day_number today'>" . $i . "</div>";
  135.         else:
  136.             echo "<div class='day_number'>" . $i . "</div>";
  137.         endif;
  138.  
  139.     echo "</div>";
  140.     echo "</a>";
  141.  
  142. endfor; // EOF for $i
  143.  
  144. /* Next Month */
  145.  
  146. $last_day = date('N', mktime(0,0,0,$month,$day_count,$year));
  147.  
  148. if ( ($first_day_of_week=='Monday' && $last_day != 7) || ($first_day_of_week=='Sunday' && $last_day != 1) ) :
  149.  
  150.     if ($first_day_of_week=='Monday') :
  151.         if ( 'Sunday' == date('l', mktime(0,0,0,$change_month_next,1,$change_year_next)) ) :
  152.             $first_day = date('j', mktime(0,0,0,$change_month_next,1,$change_year_next));
  153.         else :
  154.             $first_day = date('j', strtotime('first Sunday', mktime(0,0,0,$change_month_next,1,$change_year_next) ) );
  155.         endif;
  156.     else :
  157.         if ( 'Saturday' == date('l', mktime(0,0,0,$change_month_next,1,$change_year_next)) ) :
  158.             $first_day = date('j', mktime(0,0,0,$change_month_next,1,$change_year_next));
  159.         else :
  160.             $first_day = date('j', strtotime('first Saturday', mktime(0,0,0,$change_month_next,1,$change_year_next) ) );
  161.         endif;
  162.     endif;
  163.  
  164.  
  165.     // Not a monday so fill the gap
  166.     for($i=1; $i<=$first_day; $i++):
  167.  
  168.         $date = $change_year_next.'/'.$change_month_next.'/'.$i;
  169.  
  170.         $get_name = date('l', strtotime($date));
  171.         $month_name = date('F', strtotime($date));
  172.         $day_name = substr($get_name, 0, 3); // Trim day name to 3 chars
  173.  
  174.         $count = count_events($i,$change_month_next,$change_year_next);
  175.         if($count >= 1)
  176.         echo "<a href='day_view.php?date=$i&month=$change_month_next&year=$change_year_next' title='$i $month_name' rel='day_view'>";
  177.         echo "<div class='cal_day next_month'>"; // Calendar Day
  178.  
  179.             echo "<div class='day_heading'>" . $day_name . "</div>";
  180.  
  181.             if($count >= 1) echo "<div class='day_count'><span class='event'>" . $count . "</span></div>";
  182.  
  183.             if($today == $date):
  184.                 echo "<div class='day_number today'>" . $i . "</div>";
  185.             else:
  186.                 echo "<div class='day_number'>" . $i . "</div>";
  187.             endif;
  188.  
  189.         echo "</div>";
  190.         echo "</a>";
  191.  
  192.     endfor;
  193.  
  194. endif;
  195.  
  196.     echo "</div>";
  197. ?>

Última edición por ugluck; 05/01/2012 a las 12:52